chore: import upstream snapshot with attribution
Integ / changes (push) Has been skipped
Pre-commit / pre-commit (push) Failing after 1s
CLI exit codes / changes (push) Has been skipped
Test (Install) / changes (push) Has been skipped
Test (Python) / changes (push) Has been skipped
Test (TypeScript) / changes (push) Has been skipped
CLI exit codes / cli-gate (push) Has been cancelled
Test (Install) / test-install-gate (push) Has been cancelled
Integ / integ-gate (push) Has been cancelled
Test (Python) / test-python-gate (push) Has been cancelled
Test (TypeScript) / test-typescript-gate (push) Has been cancelled
Test (Install) / python-minimal (3.12) (push) Has been cancelled
Test (Install) / python-minimal (3.11) (push) Has been cancelled
Test (Install) / python-extra (agno, mirage.agents.agno) (push) Has been cancelled
Test (Install) / python-extra (chroma, mirage.resource.chroma) (push) Has been cancelled
Test (Install) / python-extra (pdf, mirage.core.filetype.pdf) (push) Has been cancelled
Integ / integ (push) Has been cancelled
Integ / integ-database (push) Has been cancelled
Integ / integ-database-ts (push) Has been cancelled
Integ / integ-data (push) Has been cancelled
Integ / integ-ssh (push) Has been cancelled
Integ / integ-ssh-ts (push) Has been cancelled
Test (Python) / audit (push) Has been cancelled
Test (TypeScript) / test (push) Has been cancelled
Test (TypeScript) / python-fs-shim (push) Has been cancelled
CLI exit codes / Python CLI (push) Has been cancelled
CLI exit codes / TypeScript CLI (push) Has been cancelled
CLI exit codes / Cross-language snapshot interop (push) Has been cancelled
Test (Python) / test (push) Has been cancelled
Test (Python) / import-isolation (deepagents, openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Python) / import-isolation (deepagents, pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Integ / integ-ts (push) Has been cancelled
Integ / integ-fuse (push) Has been cancelled
Test (Install) / python-extra (databricks, mirage.resource.databricks_volume) (push) Has been cancelled
Test (Install) / python-extra (deepagents, mirage.agents.langchain) (push) Has been cancelled
Test (Install) / python-extra (email, mirage.resource.email) (push) Has been cancelled
Test (Install) / python-extra (fuse, mirage.fuse.mount) (push) Has been cancelled
Test (Install) / python-extra (hdf5, mirage.core.filetype.hdf5) (push) Has been cancelled
Test (Install) / python-extra (hf, mirage.resource.hf_buckets) (push) Has been cancelled
Test (Install) / python-extra (lancedb, mirage.resource.lancedb) (push) Has been cancelled
Test (Install) / python-extra (langfuse, mirage.resource.langfuse) (push) Has been cancelled
Test (Install) / python-extra (mongodb, mirage.resource.mongodb) (push) Has been cancelled
Test (Install) / python-extra (nextcloud, mirage.resource.nextcloud) (push) Has been cancelled
Test (Install) / python-extra (openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Install) / python-extra (openhands, mirage.agents.openhands, 3.12) (push) Has been cancelled
Test (Install) / python-extra (parquet, mirage.core.filetype.parquet) (push) Has been cancelled
Test (Install) / python-extra (postgres, mirage.resource.postgres) (push) Has been cancelled
Test (Install) / python-extra (pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Test (Install) / python-extra (qdrant, mirage.resource.qdrant) (push) Has been cancelled
Test (Install) / python-extra (redis, mirage.resource.redis) (push) Has been cancelled
Test (Install) / python-extra (s3, mirage.resource.s3) (push) Has been cancelled
Test (Install) / python-extra (ssh, mirage.resource.ssh) (push) Has been cancelled
Test (Install) / ts-minimal (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:30:44 +08:00
commit bcbd1bdb22
5748 changed files with 562488 additions and 0 deletions
+305
View File
@@ -0,0 +1,305 @@
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
import asyncio
import os
import re
from dotenv import load_dotenv
from mirage import MountMode, Workspace
from mirage.resource.discord import DiscordConfig, DiscordResource
load_dotenv(".env.development")
config = DiscordConfig(token=os.environ["DISCORD_BOT_TOKEN"])
resource = DiscordResource(config=config)
def _assert_nonempty(text: str, msg: str) -> None:
if not text.strip():
raise AssertionError(f"regression: {msg}")
async def main():
ws = Workspace({"/discord": resource}, mode=MountMode.READ)
print("=== not-found errors show the full virtual path ===")
for cmd in ("cat /discord/__nf_missing__.txt",
"head /discord/__nf_missing__.txt",
"stat /discord/__nf_missing__.txt"):
result = await ws.execute(cmd)
print(f"$ {cmd}")
print(f" exit={result.exit_code} "
f"{(await result.stderr_str()).strip()}")
# ── discover structure ────────────────────────────
print("=== ls /discord/ (guilds) ===")
r = await ws.execute("ls /discord/")
print(await r.stdout_str())
_assert_nonempty(await r.stdout_str(), "ls /discord/ returned no guilds")
guilds = (await r.stdout_str()).strip().split("\n")
guild = guilds[0].strip()
print(f"=== ls /discord/{guild}/channels/ ===")
r = await ws.execute(f'ls "/discord/{guild}/channels/"')
print(await r.stdout_str())
_assert_nonempty(await r.stdout_str(), "no channels in first guild")
print(f"=== ls -l /discord/{guild}/channels/ "
"(mtime from last_message_id) ===")
long_ch = await ws.execute(
f'ls -l "/discord/{guild}/channels/" | head -n 5')
print(await long_ch.stdout_str())
channels = (await r.stdout_str()).strip().splitlines()
ch = channels[0].strip()
base = f"/discord/{guild}/channels/{ch}"
# ── pick the most recent date that has messages ────
print(f"\n=== ls {base}/ (date directories) ===")
r = await ws.execute(f'ls "{base}/" | tail -n 5')
print(await r.stdout_str())
dates = (await r.stdout_str()).strip().splitlines()
if not dates:
print(" (no date directories — channel is empty)")
return
# Walk newest → oldest, find one with non-empty chat.jsonl
target_date: str | None = None
for d in reversed(dates):
d = d.strip()
r = await ws.execute(f'cat "{base}/{d}/chat.jsonl" | head -c 1')
if (await r.stdout_str()).strip():
target_date = d
break
if target_date is None:
target_date = dates[-1].strip()
print(f" using date: {target_date}")
file_path = f"{base}/{target_date}/chat.jsonl"
# ── cat the chat.jsonl ────────────────────────────
print(f"\n=== cat {target_date}/chat.jsonl | head -n 3 ===")
r = await ws.execute(f'cat "{file_path}" | head -n 3')
print((await r.stdout_str())[:300])
# ── list date contents (chat.jsonl + files dir) ────
print(f"\n=== ls {base}/{target_date}/ ===")
r = await ws.execute(f'ls "{base}/{target_date}/"')
print(await r.stdout_str())
# ── list attachments for that date (may be empty) ─
print(f"\n=== ls {base}/{target_date}/files/ (attachments) ===")
r = await ws.execute(f'ls "{base}/{target_date}/files/"')
files_out = (await r.stdout_str()).strip()
if files_out:
for line in files_out.splitlines()[:5]:
print(f" {line}")
else:
print(" (no attachments on this date)")
# ── stat + cat first attachment (byte-exact CDN download) ──
if files_out:
first_att = files_out.splitlines()[0].strip()
att_path = f"{base}/{target_date}/files/{first_att}"
print(f"\n=== stat {first_att} ===")
r = await ws.execute(f'stat "{att_path}"')
stat_out = (await r.stdout_str()).strip()
print(f" {stat_out[:200]}")
size_match = re.search(r"size=(\d+)", stat_out)
expected_size = int(size_match.group(1)) if size_match else None
print(f"\n=== cat {first_att} (byte-exact CDN download) ===")
r = await ws.execute(f'cat "{att_path}"')
data = await r.materialize_stdout()
print(f" bytes={len(data)} expected={expected_size} "
f"exit={r.exit_code}")
if expected_size is not None and len(data) != expected_size:
raise AssertionError(
f"regression: attachment cat got {len(data)} bytes, "
f"expected {expected_size}")
# ── grep at FILE level ────────────────────────────
print(f"\n=== grep at FILE level: grep . {target_date}/chat.jsonl ===")
r = await ws.execute(f'grep -c . "{file_path}"')
print(f" line count: {(await r.stdout_str()).strip()}")
# ── grep at CHANNEL level (Discord search push-down) ──
print(f"\n=== grep at CHANNEL level: grep . {base}/ ===")
r = await ws.execute(f'grep -m 5 . "{base}/"')
print(f" exit={r.exit_code}")
out = (await r.stdout_str()).strip()
if out:
for line in out.splitlines()[:5]:
print(f" {line[:120]}")
else:
print(" (no results)")
err = await r.stderr_str()
if err:
print(f" stderr: {err[:200]}")
# ── grep at GUILD level ──────────────────────────
print(f"\n=== grep at GUILD level: grep . /discord/{guild}/ ===")
r = await ws.execute(f'grep -m 5 . "/discord/{guild}/"')
print(f" exit={r.exit_code}")
out = (await r.stdout_str()).strip()
if out:
for line in out.splitlines()[:5]:
print(f" {line[:120]}")
else:
print(" (no results)")
# ── jq pipeline ──────────────────────────────────
print(f"\n=== jq '.[] | .author.username' {target_date}/chat.jsonl ===")
r = await ws.execute(f'jq -r ".[] | .author.username" "{file_path}"'
' | head -n 5')
out = (await r.stdout_str()).strip()
if out:
for line in out.splitlines()[:5]:
print(f" {line}")
# ── stat ─────────────────────────────────────────
print(f"\n=== stat {file_path} ===")
r = await ws.execute(f'stat "{file_path}"')
print(f" {(await r.stdout_str()).strip()[:200]}")
# ── wc / head / tail ─────────────────────────────
print(f"\n=== wc -l {target_date}/chat.jsonl ===")
r = await ws.execute(f'wc -l "{file_path}"')
print(f" {(await r.stdout_str()).strip()}")
# ── basename / dirname / realpath (path ops) ─────
print(f"\n=== basename {file_path} ===")
r = await ws.execute(f'basename "{file_path}"')
out = (await r.stdout_str()).strip()
print(f" {out}")
assert out == "chat.jsonl", f"basename expected 'chat.jsonl', got {out!r}"
expected_dir = f"{base}/{target_date}"
print(f"\n=== dirname {file_path} ===")
r = await ws.execute(f'dirname "{file_path}"')
out = (await r.stdout_str()).strip()
print(f" {out}")
assert out == expected_dir, (
f"dirname expected {expected_dir!r}, got {out!r}")
print(f"\n=== realpath {file_path} ===")
r = await ws.execute(f'realpath "{file_path}"')
out = (await r.stdout_str()).strip()
print(f" {out}")
assert out == file_path, f"realpath expected {file_path!r}, got {out!r}"
print(f"\n=== realpath -e {file_path} (must exist) ===")
r = await ws.execute(f'realpath -e "{file_path}"')
print(f" exit={r.exit_code} {(await r.stdout_str()).strip()}")
assert r.exit_code == 0, (
"regression: realpath -e failed for existing file; "
f"stderr={await r.stderr_str()}")
# ── tree ─────────────────────────────────────────
print(f"\n=== tree -L 2 /discord/{guild}/ ===")
r = await ws.execute(f'tree -L 2 "/discord/{guild}/" | head -n 20')
out = (await r.stdout_str()).strip()
for line in out.splitlines()[:20]:
print(f" {line}")
# ── find chat.jsonl everywhere ───────────────────
print(f"\n=== find /discord/{guild}/ -name chat.jsonl | head -n 5 ===")
r = await ws.execute(f'find "/discord/{guild}/" -name "chat.jsonl"'
' | head -n 5')
print(f" exit={r.exit_code}")
out = (await r.stdout_str()).strip()
if out:
for line in out.splitlines():
print(f" {line}")
if r.exit_code != 0:
raise AssertionError(
f"regression: find chat.jsonl exited {r.exit_code} "
"(soft errors should not abort)")
# -path matches the display path; -size counts dirs and sizeless
# rendered files as 0 (so +0c drops them, -1k keeps them).
print(f"\n=== find /discord/{guild}/ -path '*channels*' | head -n 5 ===")
r = await ws.execute(f'find "/discord/{guild}/" -path "*channels*"'
' | head -n 5')
print(f" exit={r.exit_code}")
out = (await r.stdout_str()).strip()
if out:
for line in out.splitlines():
print(f" {line}")
if r.exit_code != 0 or not out:
raise AssertionError("regression: find -path returned nothing")
print(f"\n=== find /discord/{guild}/ -maxdepth 1 -size +0c ===")
r = await ws.execute(f'find "/discord/{guild}/" -maxdepth 1 -size +0c')
print(f" exit={r.exit_code} (dirs count as size 0, expect no output)")
if (await r.stdout_str()).strip():
raise AssertionError("regression: -size +0c matched a directory")
# ── pwd / cd / relative ──────────────────────────
print(f"\n=== cd {base} ===")
r = await ws.execute(f'cd "{base}"')
print(f" exit={r.exit_code}")
print("\n=== pwd (after cd) ===")
r = await ws.execute("pwd")
print(f" {(await r.stdout_str()).strip()}")
print(f"\n=== cat {target_date}/chat.jsonl (relative) | head -n 1 ===")
r = await ws.execute(f'cat "{target_date}/chat.jsonl" | head -n 1')
out = (await r.stdout_str()).strip()
if out:
print(f" {out[:120]}")
# ── members ──────────────────────────────────────
print(f"\n=== ls /discord/{guild}/members/ | head -n 5 ===")
r = await ws.execute(f'ls "/discord/{guild}/members/" | head -n 5')
mem_out = (await r.stdout_str()).strip()
if mem_out:
for line in mem_out.splitlines():
print(f" {line}")
first_member = mem_out.splitlines()[0].strip()
print(f"\n=== cat /discord/{guild}/members/{first_member} ===")
r = await ws.execute(f'cat "/discord/{guild}/members/{first_member}"')
body = (await r.stdout_str()).strip()
print(f" {body[:200]}")
else:
print(" (no members visible)")
# ── glob expansion: a mid-path glob replaces the guild segment
# (which may contain spaces) and walks into the literal tail.
print("\n=== echo /discord/*/channels (mid-path glob) ===")
r = await ws.execute("echo /discord/*/channels")
out = (await r.stdout_str()).strip()
print(f" {out[:200]}")
assert out.endswith("/channels"), "mid-path glob did not expand"
print("\n=== for f in /discord/*/channels/* (channel glob loop) ===")
r = await ws.execute(
"for f in /discord/*/channels/*; do echo found:$f; done | head -n 3")
out = (await r.stdout_str()).strip()
for line in out.splitlines():
print(f" {line[:120]}")
# A glob that matches nothing stays the literal word, so the
# command reports it like GNU coreutils.
print("\n=== cat /discord/zz-none-*/guild.json (no match) ===")
r = await ws.execute("cat /discord/zz-none-*/guild.json")
err = (await r.stderr_str()).strip()
print(f" exit={r.exit_code} {err[:120]}")
assert r.exit_code == 1 and "zz-none-*" in err
if __name__ == "__main__":
asyncio.run(main())
+152
View File
@@ -0,0 +1,152 @@
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
import json
import os
import subprocess
from dotenv import load_dotenv
from mirage import Mount, MountMode, Workspace
from mirage.resource.discord import DiscordConfig, DiscordResource
load_dotenv(".env.development")
config = DiscordConfig(token=os.environ["DISCORD_BOT_TOKEN"])
resource = DiscordResource(config=config)
with Workspace({"/discord/": Mount(resource, mode=MountMode.READ,
fuse=True)}) as ws:
mp = ws.fuse_mountpoint
print(f"=== FUSE MODE: mounted at {mp} ===\n")
# ── list guilds ──────────────────────────────
print("--- os.listdir() guilds ---")
# Skip the virtual /.mirage dir (agent metadata), it is not a guild.
guilds = [g for g in os.listdir(mp) if not g.startswith(".")]
for g in guilds:
print(f" {g}")
if not guilds:
print("no guilds found")
else:
guild = guilds[0]
# ── list guild contents ──────────────────
print(f"\n--- os.listdir() {guild} ---")
contents = os.listdir(f"{mp}/{guild}")
for c in contents:
print(f" {c}")
# ── list channels ────────────────────────
print(f"\n--- os.listdir() {guild}/channels ---")
channels = os.listdir(f"{mp}/{guild}/channels")
for ch in channels:
print(f" {ch}")
if channels:
ch = channels[0]
# ── list date files ──────────────────
print(f"\n--- os.listdir() {ch} (last 5 dates) ---")
dates = os.listdir(f"{mp}/{guild}/channels/{ch}")
for d in dates[-5:]:
print(f" {d}")
# ── read chat.jsonl ──────────────────
if dates:
target = dates[-1]
date_dir = f"{mp}/{guild}/channels/{ch}/{target}"
chat_path = f"{date_dir}/chat.jsonl"
# chat.jsonl has no size until fetched: unopened it stats as
# 0 bytes; any open (cat/wc/cp) hydrates it, and stat then
# reports the real size (see docs/python/setup/fuse.mdx).
print(
f"\n--- size-unknown semantics on {target}/chat.jsonl ---")
print(
f" stat before open: {os.stat(chat_path).st_size} bytes")
wc = subprocess.run(["wc", "-lc", chat_path],
capture_output=True,
text=True)
n_lines, n_bytes = wc.stdout.split()[:2]
print(
f" wc -lc : {n_lines} messages, {n_bytes} bytes")
print(
f" stat after read : {os.stat(chat_path).st_size} bytes")
print(f"\n--- open() + read {target}/chat.jsonl ---")
with open(chat_path) as f:
text = f.read().strip()
if text:
for i, line in enumerate(text.splitlines()):
if i >= 5:
print(" ...")
break
line = line.strip()
if not line:
continue
try:
msg = json.loads(line)
except json.JSONDecodeError:
break
author = msg.get("author", {}).get("username", "?")
content = msg.get("content", "")
print(f" [{author}] {content[:80]}")
else:
print(" (empty — no messages on this date)")
# list attachments
files_dir = f"{date_dir}/files"
try:
atts = os.listdir(files_dir)
except (FileNotFoundError, OSError):
atts = []
if atts:
print(f"\n--- os.listdir() {target}/files ---")
for a in atts[:5]:
print(f" {a}")
# ── list members ─────────────────────────
print(f"\n--- os.listdir() {guild}/members ---")
members = os.listdir(f"{mp}/{guild}/members")
for m in members:
print(f" {m}")
if members:
member_path = f"{mp}/{guild}/members/{members[0]}"
print(f"\n--- open() + read {members[0]} ---")
with open(member_path) as f:
text = f.read().strip()
if text:
try:
data = json.loads(text)
user = data.get("user", {})
print(f" username: {user.get('username')}")
print(f" id: {user.get('id')}")
except json.JSONDecodeError:
print(f" (raw: {text[:100]})")
else:
print(" (empty)")
# ── interactive: browse the mount in another terminal ──
print(f"\n>>> FUSE mounted at: {mp}")
print(">>> Open another terminal and run:")
print(f">>> ls {mp}/")
print(f">>> cat {mp}/<guild>/channels/<ch>/<date>/chat.jsonl")
print(">>> Press Enter to unmount and exit...")
input()
# ── stats ────────────────────────────────────
records = ws.ops.records
total = sum(r.bytes for r in records)
print(f"\nStats: {len(records)} ops, {total} bytes transferred")
+152
View File
@@ -0,0 +1,152 @@
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
import asyncio
import json
import os
import re
import sys
from dotenv import load_dotenv
from mirage import MountMode, Workspace
from mirage.resource.discord import DiscordConfig, DiscordResource
load_dotenv(".env.development")
config = DiscordConfig(token=os.environ["DISCORD_BOT_TOKEN"])
resource = DiscordResource(config=config)
async def main():
with Workspace({"/discord/": resource}, mode=MountMode.READ) as ws:
vos = sys.modules["os"]
print("=== VFS MODE: open() reads from Discord transparently ===\n")
print("--- os.listdir() guilds ---")
guilds = vos.listdir("/discord")
for g in guilds:
print(f" {g}")
if not guilds:
return
guild = guilds[0]
guild_dir = f"/discord/{guild}"
print(f"\n--- os.listdir() {guild_dir} ---")
for s in vos.listdir(guild_dir):
print(f" {s}")
ch_root = f"{guild_dir}/channels"
print(f"\n--- os.listdir() {ch_root} ---")
channels = vos.listdir(ch_root)
for ch in channels[:5]:
print(f" {ch}")
if not channels:
return
ch = channels[0]
ch_dir = f"{ch_root}/{ch}"
print(f"\n--- os.listdir() {ch_dir} (last 5 dates) ---")
dates = vos.listdir(ch_dir)
for d in dates[-5:]:
print(f" {d}")
if dates:
for d in reversed(dates):
chat_path = f"{ch_dir}/{d}/chat.jsonl"
try:
with open(chat_path) as f:
content = f.read()
except FileNotFoundError:
continue
lines = [
line_text for line_text in content.strip().split("\n")
if line_text.strip()
]
if lines:
print(f"\n--- open() + read {d}/chat.jsonl ---")
print(f" messages: {len(lines)}")
for line in lines[:3]:
rec = json.loads(line)
author = rec.get("author", {}).get("username", "?")
text = rec.get("content", "")[:80]
print(f" [{author}] {text}")
# also list attachments in that day's files dir
files_dir = f"{ch_dir}/{d}/files"
try:
atts = vos.listdir(files_dir)
except FileNotFoundError:
atts = []
if atts:
print(f"\n--- os.listdir() {d}/files ---")
for a in atts[:5]:
print(f" {a}")
print("\n--- os.path.isfile / isdir / exists ---")
print(f" isfile(chat.jsonl): "
f"{vos.path.isfile(chat_path)}")
print(f" isdir(files/): "
f"{vos.path.isdir(files_dir)}")
print(f" exists(bogus): "
f"{vos.path.exists(f'{ch_dir}/{d}/nope.txt')}")
print(f"\n--- os.stat {d}/chat.jsonl ---")
st = vos.stat(chat_path)
print(f" type={st.type} size={st.size}")
if atts:
att_path = f"{files_dir}/{atts[0]}"
print(f"\n--- os.stat {atts[0]} ---")
ast = vos.stat(att_path)
print(f" type={ast.type} size={ast.size}")
print(f"\n--- open({atts[0]}, 'rb') ---")
with open(att_path, "rb") as f:
blob = f.read()
print(f" bytes={len(blob)} expected={ast.size} "
f"match={len(blob) == ast.size}")
if ast.size is not None and len(blob) != ast.size:
raise AssertionError(
f"regression: open('rb') got {len(blob)} "
f"bytes, expected {ast.size}")
print("\n--- json.loads + regex search on chat.jsonl ---")
pattern = re.compile(r"\S+")
matches = 0
for raw in lines:
rec = json.loads(raw)
text = rec.get("content", "") or ""
if pattern.search(text):
matches += 1
print(f" messages with non-whitespace content: "
f"{matches}/{len(lines)}")
break
else:
print("\n (no messages found in recent dates)")
print("\n--- bash history ---")
with open("/.bash_history") as f:
for i, line in enumerate(f):
if i >= 6:
break
print(f" {line.rstrip()[:120]}")
records = ws.ops.records
total = sum(r.bytes for r in records)
print(f"\nStats: {len(records)} ops, {total} bytes transferred")
asyncio.run(main())