split tooling: line-map splitter, post edits, node checks, harness fragments as modules over window.g, a workflow that performs a step
The harness fragments now run as inline modules (after app.js) and stub the renderer through render.setFetcher; harness.sh's loop mode goes over http + DevTools like resume (file:// cannot load modules; --dump-dom also hangs on current Chrome). No page change yet. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dhu3iHseRewQ2WpBSVLokG
This commit is contained in:
1 parent
0786964677
commit
f855ee15b7
9 files changed
+184
-37
No files matched your search
@@ -0,0 +1,26 @@
|
||||
# tools/split-post.py: the hand edits after split.js wrote a step. Idempotent.
|
||||
import re, pathlib, sys
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
files = [p for p in list(ROOT.glob("*.js")) + list(ROOT.glob("ui/*.js")) if p.name not in ("brain.js", "sw.js")] + [ROOT / "index.html"]
|
||||
for p in files:
|
||||
s = t = p.read_text()
|
||||
t = t.replace("export let seq = 0;", "export const ids = { seq: 0 }; // job ids; brain.js reaches it as window.seq")
|
||||
t = t.replace("let seq = 0;", "const ids = { seq: 0 }; // job ids; brain.js reaches it as window.seq")
|
||||
t = re.sub(r"\+\+seq\b", "++ids.seq", t)
|
||||
t = re.sub(r"^(import \{[^}]*?)\bseq\b", r"\1ids", t, flags=re.M)
|
||||
if "async function venice(path" in t:
|
||||
t = t.replace("export async function venice(path, body, { raw = false } = {}) {", "async function veniceFetch(path, body, { raw = false } = {}) {", 1)
|
||||
t = t.replace("async function venice(path, body, { raw = false } = {}) {", "async function veniceFetch(path, body, { raw = false } = {}) {", 1)
|
||||
j = t.index("\n}\n", t.index("async function veniceFetch")) + 3
|
||||
t = t[:j] + "/* the fetcher is injectable: the harness fragments stub it (render.setFetcher); every call goes through venice() */\nlet fetcher = veniceFetch;\nexport const setFetcher = (fn) => { fetcher = fn || veniceFetch; };\nexport const venice = (...a) => fetcher(...a);\n" + t[j:]
|
||||
t = t.replace("\nasync function makeTone(", "\nexport async function makeTone(").replace("\nasync function makeNoise(", "\nexport async function makeNoise(")
|
||||
t = t.replace('import { crackle } from "./player.js";\n', "") # a regex literal in noiseSpec mentions crackle; not a use
|
||||
if t != s: p.write_text(t)
|
||||
h = ROOT / "index.html"; s = h.read_text()
|
||||
s = s.replace('<script src="brain.js"></script>', '<script src="brain.js" defer></script>') # after the module, which is deferred too
|
||||
h.write_text(s)
|
||||
sw = ROOT / "sw.js"; s = sw.read_text()
|
||||
mods = sorted(str(p.relative_to(ROOT)) for p in list(ROOT.glob("*.js")) + list(ROOT.glob("ui/*.js")) if p.name not in ("brain.js", "sw.js"))
|
||||
s = re.sub(r'const FILES = \["/", "/index.html",( "/[a-z/]+\.js",)*', 'const FILES = ["/", "/index.html",' + "".join(f' "/{m}",' for m in mods), s)
|
||||
sw.write_text(s)
|
||||
print("post ok:", mods)
|
||||
Reference in new issue
Block a user