diff options
| author | Agando <roduccomm@gmail.com> | 2026-10-29 12:42:30 +0100 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-10-29 12:42:30 +0100 |
| commit | 320877d2c8a3bb6be3d32780ecfc6e7d14528f66 (patch) | |
| tree | 26e9ad9323f6abf960065e2f27c7949518df19ff /modules/core/terminal.js | |
| parent | 12968861b81c6aef3ca15488476db0b33fbf8104 (diff) | |
fix(newos4): pipe stage quoting, maintain ordering, help cost row, plan status (v4.6.131)
Four items closed in one batch; three ran as parallel subagents on disjoint files, the bundle was
rebuilt once by the parent (rebuild-bundles.py serialises the working tree, which carries other
sessions' work — see 161372f).
1. PIPE STAGES KEEP THEIR QUOTES. `js "a b".length | wc -c` reached eval as `a b.length` and printed
a ReferenceError. terminal.js executePipeChain() now keeps `stages[i]` aligned 1:1 with
`pipeParts[i]` (the `.filter(argv => argv.length > 0)` shifted the index; replaced by a lastStage
scan + `if (argv.length === 0) continue`) and forwards the stage's own text to the dispatcher.
The core path alone was dead code: ShellModule.init() replaces terminal.executePipeChain
(shell.js:144), and that override is what runs in the browser (`executePipeChain.toString()`
contained `cmdText.split`, not `lastStage`). Both now pass `cmdText`/`pipeParts[i]`.
test-pipe-guard.js was rewritten for the new shape and now also asserts the shell override
forwards raw text — the assertion that would have caught the shadowing. RED on HEAD: both flags
false; GREEN now.
2. MAINTENANCE --fix CAN CLEAR ITS OWN WARN. check_index() ran before check_atlas(), which is what
regenerates course/atlas.json, so --fix rebuilt modules-index.json from the stale atlas and the
same WARN reappeared every run. check_atlas() now runs immediately before check_index().
modules-index.json regenerated: cost/usage present, 349 commands, version 2026-10-29-atlas.
3. `cost` DOCUMENTED. modules/core/module-billing.js registers `cost [on|off]` (an alias of `usage`);
help.html had no row. Added above the `usage` row. help coverage 362/363 -> 363/363.
4. SHIPPED PLANS STOP ASKING FOR A DECISION. The applier only flips review<->safe, so every executed
review-gated plan kept counting as an open decision (5 of 5). newos4-feedback-collect.py now reads
the body: a `## Status` / `## Implementation` heading followed by shipped|executed plus a version,
commit or date is `status: done`; those stay in `plans` (visible as shipped) but leave
plans_review and awaiting_decision. Counts: plans_review 5 -> 0, awaiting_decision 4 -> 1
(the remaining one is a real open report, RPT-20261027-160751).
admin/feedback.html read `it.status[0]`, which would render `d` for a string status; it now
prefers `status_lines[0]`.
Also carried, authored by earlier uncommitted sessions and already live in the bundle (attributed,
not silently absorbed): modules/core/module-billing.js (new, BillingModule: cost/usage),
its CORE_FILES entry in scripts/rebuild-bundles.py, and the BillingModule registry entry in
terminal.js. The bundle was rebuilt from HEAD + this batch with ollama-manager.js taken from HEAD,
so another session's in-flight `_httpError` refactor is deliberately NOT in the shipped bundle
(grep -c _httpError core-bundle.js = 0).
Verification
node modules/test/test-pipe-guard.js -> {"empty":[],"blank":[],"classifyGuarded":true,"pipeGuarded":true,"shellForwardsRaw":true}
node modules/test/test-parse-args.js -> 28/28 pass
maintained job -> node tests 21/21 pass
scripts/newos4-maintain.py -> maintenance result: OK (modules-index 349, help 363/363,
changelog current v4.6.131)
live v4.6.131 (real DOM, no print monkey-patch):
js "a b".length | wc -c -> 1 (js printed 3, one byte)
js "a b".length -> 3
js "abc".toUpperCase() -> ABC
echo "two words" -> two words
node -e "import('fs')" -> red error + Node-builtin hint
js 6*7 -> 42
unhandledrejection -> 0
livePipeImpl: shell-override, livePipeForwardsRaw: true, costRegistered: true
Diffstat (limited to 'modules/core/terminal.js')
| -rw-r--r-- | modules/core/terminal.js | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/modules/core/terminal.js b/modules/core/terminal.js index 16e2c7e..4122b3c 100644 --- a/modules/core/terminal.js +++ b/modules/core/terminal.js @@ -1361,6 +1361,7 @@ this._safeRegister('FileSystemModule', 'filesystem'); this._safeRegister('ModuleManagerModule', 'module manager'); this._safeRegister('OllamaModule', 'ollama'); + this._safeRegister('BillingModule', 'billing'); this._safeRegister('SearXNGModule', 'searxng search'); this._safeRegister('ConfigManagerModule', 'config'); this._safeRegister('WebX11AIAssistantModule', 'AI assistant'); @@ -1429,10 +1430,11 @@ BusyBoxModule: typeof BusyBoxModule !== 'undefined' ? BusyBoxModule : undefined, SmartContextModule: typeof SmartContextModule !== 'undefined' ? SmartContextModule : undefined, DebugSupervisorModule: typeof DebugSupervisorModule !== 'undefined' ? DebugSupervisorModule : undefined, + BillingModule: typeof BillingModule !== 'undefined' ? BillingModule : undefined, }; const cls = registry[className]; if (typeof cls === 'undefined') { - console.log(`[SafeRegister] Skipped ${label}: class not loaded (skipped in boot selection)`); + console.warn(`[SafeRegister] Skipped ${label}: ${className} is not in the registry map — add it there, not only to loadBuiltInModules()`); return; } try { this.moduleManager.registerModule(new cls()); } @@ -1570,22 +1572,28 @@ return parts; } async executePipeChain(pipeParts) { - // Parse every stage once, then drop the ones with no argv. `help |` splits to + // Parse every stage once, then skip the ones with no argv. `help |` splits to // ['help',''], `help | ""` to ['help',''] and `| wc -l` to ['','wc -l'] — all three // produced an empty argv whose parts[0] was undefined and threw TypeError from - // parts[0].toLowerCase() (989 occurrences, first filed 2026-10-20). Filtering on + // parts[0].toLowerCase() (989 occurrences, first filed 2026-10-20). Skipping on // argv (not just the string) also keeps the LAST real stage final, so its output is - // never swallowed by a trailing empty segment. - const stages = pipeParts - .map(t => this.security._parseArgs(String(t || '').trim())) - .filter(argv => argv.length > 0); - if (!stages.length) { + // never swallowed by a trailing empty segment, and keeps the loop index aligned + // with pipeParts so each stage gets its own raw text. + const stages = pipeParts.map(t => this.security._parseArgs(String(t || '').trim())); + // Index of the LAST stage that has a real argv — its output is printed, never + // piped. -1 means every segment was empty, so there is nothing to run. + let lastStage = -1; + for (let i = 0; i < stages.length; i++) if (stages[i].length > 0) lastStage = i; + if (lastStage < 0) { this.print('⚠️ Empty pipeline — nothing to run', 'warning'); return; } let pipeInput = null; for (let i = 0; i < stages.length; i++) { const argv = stages[i]; + // Skip empty segments, but keep `i` pointing at pipeParts[i] so the raw stage + // text handed to the dispatcher always belongs to this argv. + if (argv.length === 0) continue; const cmd = argv[0].toLowerCase(); const args = argv.slice(1); // Rebuilt from argv so the security classifier sees the same tokenisation the @@ -1606,19 +1614,19 @@ return; } this._pipeInput = pipeInput; - if (i < stages.length - 1) { - pipeInput = await this.capturePipeOutput(cmd, args); + if (i < lastStage) { + pipeInput = await this.capturePipeOutput(cmd, args, pipeParts[i]); } else { - await this.dispatchCommand(cmd, args); + await this.dispatchCommand(cmd, args, pipeParts[i]); } } this._pipeInput = null; } - async capturePipeOutput(cmd, args) { + async capturePipeOutput(cmd, args, rawText) { let output = ''; this._pushPrintCapture(buf => { output += buf; }); try { - await this.dispatchCommand(cmd, args); + await this.dispatchCommand(cmd, args, rawText); } finally { this._popPrintCapture(); } |