3.4 KiB
name, description
| name | description |
|---|---|
| omp-bundle-implementation-port | Extract and port a working implementation from omp's minified dist/cli.js bundle (copy-not-invent requests); anchors, python slicing, regex-constant sweep, trace-driven test prediction. |
Porting built-in omp behavior out of the minified bundle
Use when Frank says "copy the omp implementation / work off known-working code" — i.e. port a built-in feature (vocalizer segmentation, retry logic, formatting rules) into our own file instead of hand-rolling a heuristic. For merely auditing behavior claims, use omp-bundle-claim-audit; this skill is extraction-for-porting.
Bundle: ~/.bun/install/global/node_modules/@oh-my-pi/pi-coding-agent/dist/cli.js (minified; single-letter names, private #x fields survive).
Extraction recipe
- Find the setting/entry strings first.
grep -o 'ce({id:"<area>[^"]*"[^}]\{0,200\}' cli.js— setting descriptions state semantics verbatim (e.g.speech.enhanced= "Rewrite assistant output into natural spoken prose with the tiny/smol model"). Descriptions are quotable ground truth. - Anchor to code with a distinctive token, not guesses: a method name (
pushDelta), a state init, or a string. Then slice generously with python (bash heredoc), NOT grep -o which truncates:src = open('cli.js').read() i = src.index('pushDelta'); print(src[i-1500:i+3000]) - Follow the constructor: pipeline classes instantiate collaborators there (
this.#t ??= new fHe→fHeis the real worker;#g()returned{speakable:new fHe, pending:[]…}). Dumpclass fHe{+4000 chars. - Regex/helper sweep: minified code declares shared constants in a trailing
var a,b,c,…list and initializes them elsewhere (Xyr=,Pwc=function). Loop the names withre.search(rf'{name}=', src)and print ~400 chars each — the actual boundary/cleanup rules live in these one-liners. - Write slices to
/tmp/*.txtandreadthem; don't eyeball megabyte greps.
Port rules
- Rename fields/methods to readable names but keep logic 1:1 — the value is behavioral fidelity (Frank's "known-working set of code").
- Private
#xfields port cleanly: TS classes in Bun extensions support#. - Global-regex
.lastIndex=0before each scan loop — minified code relies on it; keep it.
Verification shortcut
Before running tests, hand-trace each test input through the ported rules (boundary indices, state transitions) and predict exact segment counts/strings; then run — predicted-vs-actual mismatch localizes port errors faster than test output alone. Worked example (2026-10-19, dankvoice PR #26): traced "First stop here. Second one goes!!! Really? Third ... done" → predicted 3 segments incl. "Third ... done" merged via flush (10-char boundary < 24-char started-min) → bats green first run.
Known anchors (2026-10-19 bundle)
- Speak-aloud vocalizer pipeline: class
I6o(gating onspeech.enabled, suspend counter, enhancer,#g()per-message state). - Utterance segmenter: class
fHe+ helpersPwc(line-head classify),Iwc/_wc/b6o/w6o(boundary search),Cwc+y6o(cleanup: links→label, URL→host, path→basename). Regex consts:Xyrsentence-end runs,pHeweak breaks,mwcabbreviations,hwcundecided line-heads,g6ohorizontal rules. - Port already living in
agent/extensions/dankvoice.ts(SpeechSegmenter) — when the bundle updates, re-extractfHeand diff against it before assuming our copy still matches.