Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(cli): D5 baseline shrinks by 43; 7 more selfHelp commands answer --help brainless
garrytana3ab25ce2ac0
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex 02eb556dc5..7b6b9b7484 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -3,7 +3,7 @@# Raising a ceiling is a conscious, reviewer-visible act. Lower ceilings in# the same commit as any peel (the guard fails on >50 lines of stale slack).# Columns: path max_lines policy note-src/cli.ts 3171 ratchet +9 agent operator wave D3/D4: curated --help short-circuit (renderer in cli/help/render.ts), curated flag-value validation call (cli/help/validate.ts), table-dispatched SELF_HELP_WITHOUT_ENGINE entries for the selfHelp flips; +5 agent operator wave C10 (merged from the collector): serve --fail-fast in the connect-failure path; +31 #5950 (D6): connectEngine thin-client backstop, engine-free MCP-twin dispatch, recall/advisor/export refusal hints, refusal fix subcommand (lowered to 3131 by D1's renderCliError seam first); +2 agent operator wave A4: observational startup (probe-only connect for startup:observational commands; completeEngineStartup split out of connectEngine, exposed as ctx.completeStartup); +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5232: write-wait import, reporter-owned verdict in the op catch, thin-client writeWaitMs, ctx.writeWaitMs (logic in persistence/write-wait.ts); +1 #4768: serve --access help line; +4 #5433: list_pages TSV cell escaping in formatResult; +2 #lane-h pricing: help line + thin-client refusal hint for `gbrain pricing`; +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5433: list_pages TSV cell escaping in formatResult+src/cli.ts 3172 ratchet +9 agent operator wave D3/D4: curated --help short-circuit (renderer in cli/help/render.ts), curated flag-value validation call (cli/help/validate.ts), table-dispatched SELF_HELP_WITHOUT_ENGINE entries for the selfHelp flips; +5 agent operator wave C10 (merged from the collector): serve --fail-fast in the connect-failure path; +31 #5950 (D6): connectEngine thin-client backstop, engine-free MCP-twin dispatch, recall/advisor/export refusal hints, refusal fix subcommand (lowered to 3131 by D1's renderCliError seam first); +2 agent operator wave A4: observational startup (probe-only connect for startup:observational commands; completeEngineStartup split out of connectEngine, exposed as ctx.completeStartup); +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5232: write-wait import, reporter-owned verdict in the op catch, thin-client writeWaitMs, ctx.writeWaitMs (logic in persistence/write-wait.ts); +1 #4768: serve --access help line; +4 #5433: list_pages TSV cell escaping in formatResult; +2 #lane-h pricing: help line + thin-client refusal hint for `gbrain pricing`; +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5433: list_pages TSV cell escaping in formatResultsrc/commands/autopilot.ts 1639 ratchet refactor wave 1 split target (W4 autopilot, cut line); ceiling rationale: docs/architecture/key-files/commands-1.md entry for src/commands/autopilot.ts; +2 fix wave 5: nosemgrep justifications on the per-brain job launchctl/systemctl calls (#5195); +2 #5813: boot reconcile names attempted and running versions in log + audit; +2 #5855: Bun floor gate before the swap and the swap-refusal hold (logic in core/bun-floor.ts)src/commands/doctor.ts 653 ratchet refactor wave 1 split target (W4 doctor); ceiling rationale: docs/architecture/key-files/commands-2.md entry for src/commands/doctor.tssrc/commands/embed.ts 2219 ratchet +2 agent operator wave D2: --json failure envelope via writeCliError; lowered v0.46.26.0: embedBatchWithBackoff + retry cluster peeled to core/embed-retry.ts (core/commands layering fix); grown wave-g (#4530): per-model input-limit wiring; wave-k #3622 reimpl: --stale zero-progress failure quarantine; +29 #4668 (#4530): oversize-heal call sites in both --stale drains — kept low by peeling the healed-row remap to core/embed-oversize-heal.ts (shared with embed-stale.ts); +35 #4647 (refs #4599): per-tick timeout+abort on the single-flight lock heartbeat refresh (interval deliberately NOT unref'd); +122 refs #4599: stall-watchdog race around the drain + shared idempotent flushAndRelease + CLI stall exit mapping (watchdog machinery itself lives in core/embed-stall.ts); +12: adversarial-review hardening (healed_splits progress key + heal-tick comment); #5105: guarded derived projection preparation and read seals; #5105: conditional embedding installer wiring; archived eligibility: active-only dispatch with honest stranded-work reporting; explicit archived admission: live-source snapshots and honest refused-installation failures; +2 fw3: embed --stale --images dispatch (sweep lives in core/embed-stale-images.ts); +5 #5289: dry run reports restamp-only chunks apart from chunks to embed (count lives in core/embedding-invalidation.ts); +6 #4616: keep a partially refused batch in embedPageTexts and name the recovery command in failure samples (guard lives in core/ai/embedding-guard.ts); +5 #5226: embed summary counts distinct pages; +3 #5804: null projection snapshot counted as a failure with one batch summary in embed --stale; +18 wave 8 lane D1: #5527 mixed-space warning subtracts current-model chunks (+4), #5885 takes option/result fields and the stale-drain takes call (pass lives in core/embed-takes.ts); +9 Foundations 1 F4d: time-budget stop result fields, stdout verdict and stop recording in embed --stale (logic in core/embed-budget-stop.ts)diff --git a/src/cli.ts b/src/cli.tsindex 187998cefe..6bf3cf9f69 100755--- a/src/cli.ts+++ b/src/cli.ts@@ -151,6 +151,7 @@ const SELF_HELP_WITHOUT_ENGINE: Record<string, true | (() => Promise<(engine: ne// D3: post-connect records whose handler answers --help before the engine; run through the table.advisor: true, anomalies: true, backfill: true, 'book-mirror': true, 'edges-backfill': true, features: true,founder: true, 'graph-query': true, orphans: true, salience: true, think: true,+ brainstorm: true, lsd: true, migrate: true, pages: true, pricing: true, 'retrieval-upgrade': true, whoknows: true,};/** Returns true when the command's own help was printed. */diff --git a/src/cli/help/import.ts b/src/cli/help/import.tsindex 61c928f842..15cae21537 100644--- a/src/cli/help/import.ts+++ b/src/cli/help/import.ts@@ -7,7 +7,7 @@ export const help: CliHelpSpec = {flags: [{ name: '--source', type: 'string', desc: 'Write into this source id (must already exist; see `gbrain sources list`).' },{ name: '--source-id', type: 'string', desc: 'Same as --source; pass one or the other.' },- { name: '--no-embed', type: 'boolean', desc: 'Skip embeddings (no provider calls); run `gbrain embed --stale` later.' },+ { name: '--no-embed', type: 'boolean', desc: 'Skip embeddings (no provider calls); embed the new pages later with `gbrain embed`.' },{ name: '--workers', type: 'number', desc: 'Parallel import workers (positive integer, default 1; clamped to the connection budget).' },{ name: '--fresh', type: 'boolean', desc: 'Ignore the resume checkpoint and walk every file again.' },{ name: '--include-gitignored', type: 'boolean', desc: 'Also import files git ignores.' },diff --git a/src/cli/help/render.ts b/src/cli/help/render.tsindex d222794b44..6d36ba26c0 100644--- a/src/cli/help/render.ts+++ b/src/cli/help/render.ts@@ -32,7 +32,7 @@ export function renderCuratedHelp(command: string, spec: CliHelpSpec): string {lines.push('', 'Examples:', ...spec.examples.map(e => ` ${e}`));if (spec.end_of_options) lines.push('', 'A bare `--` ends options; every later argument is a positional.');if (spec.flags.some(f => f.consent?.length)) lines.push('', 'A flag marked [consent: …] authorizes that effect: get the user\'s agreement before passing it.');- lines.push('', `Machine-readable: gbrain ${command} --help --json`);+ if (spec.flags.some(f => f.name === '--json')) lines.push('', `Machine-readable: gbrain ${command} --help --json`);return `${lines.join('\n')}\n`;}diff --git a/test/cli-help-without-brain.serial.test.ts b/test/cli-help-without-brain.serial.test.tsindex c74bbfb2bd..915c52d461 100644--- a/test/cli-help-without-brain.serial.test.ts+++ b/test/cli-help-without-brain.serial.test.ts@@ -46,6 +46,9 @@ const HELP_WITHOUT_BRAIN = [// through SELF_HELP_WITHOUT_ENGINE's table entries.'conversation-parser', 'advisor', 'anomalies', 'backfill', 'book-mirror', 'edges-backfill', 'features','founder', 'graph-query', 'orphans', 'salience', 'think',+ // D5: selfHelp handlers that already answered --help before the engine but+ // were reached only after connect; now SELF_HELP_WITHOUT_ENGINE table entries.+ 'brainstorm', 'lsd', 'migrate', 'pages', 'pricing', 'whoknows',];/**@@ -56,13 +59,8 @@ const HELP_WITHOUT_BRAIN = [* entry moves.*/const STILL_NEEDS_A_BRAIN = [- 'brainstorm','config','embed',- 'lsd',- 'migrate',- 'pages',- 'retrieval-upgrade',];async function runHelp(command: string): Promise<{ code: number; out: string }> {@@ -127,6 +125,14 @@ describe('--help without a configured brain', () => {}}, 30_000);+ // D5: retrieval-upgrade is an alias whose help is the `migrate embeddings` usage.+ test('retrieval-upgrade --help answers with the migrate embeddings usage', async () => {+ const { code, out } = await runHelp('retrieval-upgrade');+ expect(code).toBe(0);+ expect(out).not.toContain('No brain configured');+ expect(out).toContain('Usage: gbrain migrate embeddings --to <provider:model>');+ }, 30_000);+for (const command of HELP_WITHOUT_BRAIN) {test(`${command} --help answers`, async () => {const { code, out } = await runHelp(command);diff --git a/test/fixtures/cli-contract/help-baseline.json b/test/fixtures/cli-contract/help-baseline.jsonindex 1ac8ed92c5..8553f73a24 100644--- a/test/fixtures/cli-contract/help-baseline.json+++ b/test/fixtures/cli-contract/help-baseline.json@@ -1,19 +1,8 @@[- "advisor:missing_yes",- "advisor:stub","agent:missing_yes",- "anomalies:stub",- "apply-migrations:missing_yes",- "apply-migrations:stub","auth:missing_yes","autopilot:missing_yes",- "autopilot:stub",- "backfill:stub","bench:stub",- "book-mirror:missing_yes",- "book-mirror:stub",- "brainstorm:exit",- "brainstorm:missing_yes","calibration:missing_yes","calibration:stub","call:stub",@@ -21,7 +10,6 @@"check-backlinks:stub","check-update:missing_yes","claw-test:missing_yes",- "claw-test:stub","code-callees:missing_yes","code-callees:stub","code-callers:missing_yes",@@ -33,41 +21,21 @@"config:exit","config:missing_yes","connectors:missing_yes",- "conversation-parser:stub",- "doctor:missing_yes",- "doctor:stub","dream:missing_yes",- "edges-backfill:stub","embed:exit","embed:missing_yes","embeddings:missing_yes","engine:missing_yes","eval:missing_yes",- "features:stub","files:missing_yes","files:stub","forget:stub",- "founder:stub",- "graph-query:stub",- "import:stub","init:missing_yes",- "integrity:stub","lint:stub",- "lsd:exit",- "lsd:missing_yes","maintain:missing_yes",- "migrate:exit",- "migrate:missing_yes",- "mounts:stub","notability-eval:stub",- "onboard:missing_yes",- "onboard:stub",- "orphans:stub",- "pages:exit","post-upgrade:missing_yes",- "pricing:exit","protocol:missing_yes",- "providers:stub","publish:stub","quarantine:stub","recall:missing_yes",@@ -79,28 +47,17 @@"reindex-frontmatter:stub","reindex-search-vector:missing_yes","reindex-search-vector:stub",- "remote:stub","repair-jsonb:stub","report:stub","repos:missing_yes","repos:stub",- "resolvers:stub",- "retrieval-upgrade:exit",- "retrieval-upgrade:missing_yes",- "routing-eval:stub",- "salience:stub","self-upgrade:missing_yes","serve:missing_yes",- "serve:stub",- "skillify:stub","skillpack-check:missing_yes","skillpack:missing_yes","smoke-test:stub","status:missing_yes",- "status:stub","takes:missing_yes",- "think:stub","upgrade:missing_yes",- "whoknows:exit","whoknows:missing_yes"]diff --git a/test/fixtures/goldens/cli/membership-sets.json b/test/fixtures/goldens/cli/membership-sets.jsonindex 800eba59b3..c9c500fd77 100644--- a/test/fixtures/goldens/cli/membership-sets.json+++ b/test/fixtures/goldens/cli/membership-sets.json@@ -296,6 +296,7 @@"anomalies","backfill","book-mirror",+ "brainstorm","compile-context","connectors","dream",@@ -307,17 +308,23 @@"graph-query","jobs","loops",+ "lsd","maintain",+ "migrate","models","orphans",+ "pages",+ "pricing","repair",+ "retrieval-upgrade","salience","skillopt","sources","think","transcripts","waiting",- "watch"+ "watch",+ "whoknows"],"STARTUP_HOOK_SKIP_COMMANDS": ["check-update",