Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(mcp): one starter surface for every stdio registration gbrain writes
garrytan09aa1174c162
diff --git a/plugin-variants/gbrain-coding/skills/brain-ops/SKILL.md b/plugin-variants/gbrain-coding/skills/brain-ops/SKILL.mdindex 7f1e37ad44..48abcdf7d7 100644--- a/plugin-variants/gbrain-coding/skills/brain-ops/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/brain-ops/SKILL.md@@ -279,9 +279,9 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `sync_brain` → `gbrain sync`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-coding/skills/enrich/SKILL.md b/plugin-variants/gbrain-coding/skills/enrich/SKILL.mdindex a6d881f033..0d6f2879ae 100644--- a/plugin-variants/gbrain-coding/skills/enrich/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/enrich/SKILL.md@@ -362,8 +362,8 @@ Both page types have bidirectional back-links to every entity they mention.## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-coding/skills/idea-ingest/SKILL.md b/plugin-variants/gbrain-coding/skills/idea-ingest/SKILL.mdindex 07d78c1d6e..f021adffe3 100644--- a/plugin-variants/gbrain-coding/skills/idea-ingest/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/idea-ingest/SKILL.md@@ -144,9 +144,9 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `file_upload` → `gbrain call file_upload <params_json>`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-coding/skills/idea-lineage/SKILL.md b/plugin-variants/gbrain-coding/skills/idea-lineage/SKILL.mdindex c7c67772f0..e3b61c0630 100644--- a/plugin-variants/gbrain-coding/skills/idea-lineage/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/idea-lineage/SKILL.md@@ -231,10 +231,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `find_contradictions` → `gbrain find-contradictions`- `find_trajectory` → `gbrain find-trajectory`- `takes_search` → `gbrain takes-search`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-coding/skills/ingest/SKILL.md b/plugin-variants/gbrain-coding/skills/ingest/SKILL.mdindex 6f86473f91..53f553773c 100644--- a/plugin-variants/gbrain-coding/skills/ingest/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/ingest/SKILL.md@@ -325,9 +325,9 @@ Raw source: [preserved at path / uploaded to cloud]## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `sync_brain` → `gbrain sync`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-coding/skills/maintain/SKILL.md b/plugin-variants/gbrain-coding/skills/maintain/SKILL.mdindex a7fdd2cf11..c44f94df58 100644--- a/plugin-variants/gbrain-coding/skills/maintain/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/maintain/SKILL.md@@ -554,9 +554,9 @@ The maintenance report follows this structure:## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `get_health` → `gbrain doctor --json`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-coding/skills/query/SKILL.md b/plugin-variants/gbrain-coding/skills/query/SKILL.mdindex e2300b5009..556c6306a3 100644--- a/plugin-variants/gbrain-coding/skills/query/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/query/SKILL.md@@ -228,8 +228,8 @@ If search results seem off (wrong results, missing known pages, irrelevant hits)## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-coding/skills/signal-detector/SKILL.md b/plugin-variants/gbrain-coding/skills/signal-detector/SKILL.mdindex 1f64a5f823..b90a9a1eef 100644--- a/plugin-variants/gbrain-coding/skills/signal-detector/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/signal-detector/SKILL.md@@ -172,8 +172,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-daily/skills/briefing/SKILL.md b/plugin-variants/gbrain-daily/skills/briefing/SKILL.mdindex 2ecf97a4d7..09036600e9 100644--- a/plugin-variants/gbrain-daily/skills/briefing/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/briefing/SKILL.md@@ -218,8 +218,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-daily/skills/daily-task-prep/SKILL.md b/plugin-variants/gbrain-daily/skills/daily-task-prep/SKILL.mdindex 09318524fe..9eb50b70e8 100644--- a/plugin-variants/gbrain-daily/skills/daily-task-prep/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/daily-task-prep/SKILL.md@@ -70,8 +70,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-daily/skills/data-research/SKILL.md b/plugin-variants/gbrain-daily/skills/data-research/SKILL.mdindex 0f1f1c7291..ac2224ed60 100644--- a/plugin-variants/gbrain-daily/skills/data-research/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/data-research/SKILL.md@@ -152,10 +152,10 @@ References `skills/conventions/quality.md` for citation and back-linking rules.## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `file_upload` → `gbrain call file_upload <params_json>`- `put_raw_data` → `gbrain call put_raw_data <params_json>`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-daily/skills/gbrain-advisor/SKILL.md b/plugin-variants/gbrain-daily/skills/gbrain-advisor/SKILL.mdindex d15649f27a..cf5d0d1ca9 100644--- a/plugin-variants/gbrain-daily/skills/gbrain-advisor/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/gbrain-advisor/SKILL.md@@ -128,8 +128,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `advisor` → `gbrain advisor`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-daily/skills/ingest/SKILL.md b/plugin-variants/gbrain-daily/skills/ingest/SKILL.mdindex 6f86473f91..53f553773c 100644--- a/plugin-variants/gbrain-daily/skills/ingest/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/ingest/SKILL.md@@ -325,9 +325,9 @@ Raw source: [preserved at path / uploaded to cloud]## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `sync_brain` → `gbrain sync`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-daily/skills/media-ingest/SKILL.md b/plugin-variants/gbrain-daily/skills/media-ingest/SKILL.mdindex da2ac2bbaa..1225179b34 100644--- a/plugin-variants/gbrain-daily/skills/media-ingest/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/media-ingest/SKILL.md@@ -156,9 +156,9 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `file_upload` → `gbrain call file_upload <params_json>`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-daily/skills/meeting-ingestion/SKILL.md b/plugin-variants/gbrain-daily/skills/meeting-ingestion/SKILL.mdindex 4de2a57843..b8f1a50dad 100644--- a/plugin-variants/gbrain-daily/skills/meeting-ingestion/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/meeting-ingestion/SKILL.md@@ -550,10 +550,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `chronicle_day` → `gbrain day`- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin-variants/gbrain-daily/skills/query/SKILL.md b/plugin-variants/gbrain-daily/skills/query/SKILL.mdindex e2300b5009..556c6306a3 100644--- a/plugin-variants/gbrain-daily/skills/query/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/query/SKILL.md@@ -228,8 +228,8 @@ If search results seem off (wrong results, missing known pages, irrelevant hits)## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/README.md b/plugin/README.mdindex 4c171e84eb..31d4e71e35 100644--- a/plugin/README.md+++ b/plugin/README.md@@ -9,14 +9,15 @@ addition/exclusion).## MCP surface note (read once)The plugin's MCP server runs `gbrain serve --surface starter` — the-39-op daily-driver surface (the seven memory verbs + daily-brain ops + capture). 22+40-op daily-driver surface (the seven memory verbs + daily+brain ops + capture), the same surface every stdio registration gbrain writes+pins. 22bundled skills reference gbrain operations beyond that surface; every one ofthem has a first-class `gbrain` CLI path, which is the primary way skillsdrive gbrain. When a skill step names an operation your MCP tool list doesn't-carry, run the equivalent `gbrain` CLI command, or widen this machine's-plugin surface with `GBRAIN_SURFACE=full` (the launcher honors it; new-sessions pick it up).+carry, call `request_tools {"surface":"full"}` to add it to this session, run+the equivalent `gbrain` CLI command, or widen this machine's plugin surface+with `GBRAIN_SURFACE=full` (the server honors it; new sessions pick it up).## Requirementsdiff --git a/plugin/skills/brain-ops/SKILL.md b/plugin/skills/brain-ops/SKILL.mdindex 7f1e37ad44..48abcdf7d7 100644--- a/plugin/skills/brain-ops/SKILL.md+++ b/plugin/skills/brain-ops/SKILL.md@@ -279,9 +279,9 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `sync_brain` → `gbrain sync`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/briefing/SKILL.md b/plugin/skills/briefing/SKILL.mdindex 2ecf97a4d7..09036600e9 100644--- a/plugin/skills/briefing/SKILL.md+++ b/plugin/skills/briefing/SKILL.md@@ -218,8 +218,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/cold-start/SKILL.md b/plugin/skills/cold-start/SKILL.mdindex 8e637ebb2a..31b08d50a1 100644--- a/plugin/skills/cold-start/SKILL.md+++ b/plugin/skills/cold-start/SKILL.md@@ -567,9 +567,9 @@ Next: Phase N+1 — [description]. Ready to proceed?## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `sync_brain` → `gbrain sync`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/daily-task-prep/SKILL.md b/plugin/skills/daily-task-prep/SKILL.mdindex 09318524fe..9eb50b70e8 100644--- a/plugin/skills/daily-task-prep/SKILL.md+++ b/plugin/skills/daily-task-prep/SKILL.md@@ -70,8 +70,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/data-research/SKILL.md b/plugin/skills/data-research/SKILL.mdindex 0f1f1c7291..ac2224ed60 100644--- a/plugin/skills/data-research/SKILL.md+++ b/plugin/skills/data-research/SKILL.md@@ -152,10 +152,10 @@ References `skills/conventions/quality.md` for citation and back-linking rules.## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `file_upload` → `gbrain call file_upload <params_json>`- `put_raw_data` → `gbrain call put_raw_data <params_json>`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/eiirp/SKILL.md b/plugin/skills/eiirp/SKILL.mdindex 48c3246777..76d9510873 100644--- a/plugin/skills/eiirp/SKILL.md+++ b/plugin/skills/eiirp/SKILL.md@@ -542,8 +542,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/enrich/SKILL.md b/plugin/skills/enrich/SKILL.mdindex a6d881f033..0d6f2879ae 100644--- a/plugin/skills/enrich/SKILL.md+++ b/plugin/skills/enrich/SKILL.md@@ -362,8 +362,8 @@ Both page types have bidirectional back-links to every entity they mention.## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/gbrain-advisor/SKILL.md b/plugin/skills/gbrain-advisor/SKILL.mdindex d15649f27a..cf5d0d1ca9 100644--- a/plugin/skills/gbrain-advisor/SKILL.md+++ b/plugin/skills/gbrain-advisor/SKILL.md@@ -128,8 +128,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `advisor` → `gbrain advisor`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/google-loops/SKILL.md b/plugin/skills/google-loops/SKILL.mdindex 400171d0ca..80026630c6 100644--- a/plugin/skills/google-loops/SKILL.md+++ b/plugin/skills/google-loops/SKILL.md@@ -197,10 +197,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `loops_close` → `gbrain loops done`- `loops_mute` → `gbrain loops mute`- `open_loops` → `gbrain loops list`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/idea-ingest/SKILL.md b/plugin/skills/idea-ingest/SKILL.mdindex 07d78c1d6e..f021adffe3 100644--- a/plugin/skills/idea-ingest/SKILL.md+++ b/plugin/skills/idea-ingest/SKILL.md@@ -144,9 +144,9 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `file_upload` → `gbrain call file_upload <params_json>`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/idea-lineage/SKILL.md b/plugin/skills/idea-lineage/SKILL.mdindex c7c67772f0..e3b61c0630 100644--- a/plugin/skills/idea-lineage/SKILL.md+++ b/plugin/skills/idea-lineage/SKILL.md@@ -231,10 +231,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `find_contradictions` → `gbrain find-contradictions`- `find_trajectory` → `gbrain find-trajectory`- `takes_search` → `gbrain takes-search`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/ingest/SKILL.md b/plugin/skills/ingest/SKILL.mdindex 6f86473f91..53f553773c 100644--- a/plugin/skills/ingest/SKILL.md+++ b/plugin/skills/ingest/SKILL.md@@ -325,9 +325,9 @@ Raw source: [preserved at path / uploaded to cloud]## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `sync_brain` → `gbrain sync`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/maintain/SKILL.md b/plugin/skills/maintain/SKILL.mdindex a7fdd2cf11..c44f94df58 100644--- a/plugin/skills/maintain/SKILL.md+++ b/plugin/skills/maintain/SKILL.md@@ -554,9 +554,9 @@ The maintenance report follows this structure:## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `get_health` → `gbrain doctor --json`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/media-ingest/SKILL.md b/plugin/skills/media-ingest/SKILL.mdindex da2ac2bbaa..1225179b34 100644--- a/plugin/skills/media-ingest/SKILL.md+++ b/plugin/skills/media-ingest/SKILL.md@@ -156,9 +156,9 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `file_upload` → `gbrain call file_upload <params_json>`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/meeting-ingestion/SKILL.md b/plugin/skills/meeting-ingestion/SKILL.mdindex 4de2a57843..b8f1a50dad 100644--- a/plugin/skills/meeting-ingestion/SKILL.md+++ b/plugin/skills/meeting-ingestion/SKILL.md@@ -550,10 +550,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `chronicle_day` → `gbrain day`- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/migrate/SKILL.md b/plugin/skills/migrate/SKILL.mdindex ddbc10eb24..2965ad41ba 100644--- a/plugin/skills/migrate/SKILL.md+++ b/plugin/skills/migrate/SKILL.md@@ -187,10 +187,10 @@ Verification:## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`- `add_tag` → `gbrain tag`- `sync_brain` → `gbrain sync`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/minion-orchestrator/SKILL.md b/plugin/skills/minion-orchestrator/SKILL.mdindex d4fce1ea5c..ae5cb71214 100644--- a/plugin/skills/minion-orchestrator/SKILL.md+++ b/plugin/skills/minion-orchestrator/SKILL.md@@ -543,7 +543,7 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_job` → `gbrain jobs get`- `get_job_progress` → `gbrain call get_job_progress <params_json>`@@ -554,4 +554,4 @@ does not have it, run its gbrain CLI equivalent instead:- `send_job_message` → `gbrain call send_job_message <params_json>`- `submit_job` → `gbrain jobs submit`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/query/SKILL.md b/plugin/skills/query/SKILL.mdindex e2300b5009..556c6306a3 100644--- a/plugin/skills/query/SKILL.md+++ b/plugin/skills/query/SKILL.md@@ -228,8 +228,8 @@ If search results seem off (wrong results, missing known pages, irrelevant hits)## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_timeline` → `gbrain timeline`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/schema-author/SKILL.md b/plugin/skills/schema-author/SKILL.mdindex e5432ad511..9133f9fd25 100644--- a/plugin/skills/schema-author/SKILL.md+++ b/plugin/skills/schema-author/SKILL.md@@ -315,7 +315,7 @@ On failure, the error envelope follows the standard `StructuredAgentError` shape## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_active_schema_pack` → `gbrain schema active`- `list_schema_packs` → `gbrain schema list`@@ -327,4 +327,4 @@ does not have it, run its gbrain CLI equivalent instead:- `schema_review_orphans` → `gbrain schema review-orphans`- `schema_stats` → `gbrain schema stats`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/schema-unify/SKILL.md b/plugin/skills/schema-unify/SKILL.mdindex ec2aac2f74..12ba30d464 100644--- a/plugin/skills/schema-unify/SKILL.md+++ b/plugin/skills/schema-unify/SKILL.md@@ -280,8 +280,8 @@ For structured JSON, `gbrain call get_job '{"id": <id>}'` returns the job row; i## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `run_onboard` → `gbrain call run_onboard <params_json>`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/setup/SKILL.md b/plugin/skills/setup/SKILL.mdindex 2192f8cfed..f68c3c96fa 100644--- a/plugin/skills/setup/SKILL.md+++ b/plugin/skills/setup/SKILL.md@@ -224,10 +224,10 @@ answer, HTTP response, or job ID cannot certify the full native experience.## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `get_health` → `gbrain doctor --json`- `get_stats` → `gbrain stats`- `sync_brain` → `gbrain sync`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/plugin/skills/signal-detector/SKILL.md b/plugin/skills/signal-detector/SKILL.mdindex 1f64a5f823..b90a9a1eef 100644--- a/plugin/skills/signal-detector/SKILL.md+++ b/plugin/skills/signal-detector/SKILL.md@@ -172,8 +172,8 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f## Tools outside your MCP surfaceThis plugin serves the starter tool surface. When a step above names one of these tools and your tool list-does not have it, run its gbrain CLI equivalent instead:+does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:- `add_link` → `gbrain link`-Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).+To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.diff --git a/scripts/generate-plugin-tree.ts b/scripts/generate-plugin-tree.tsindex c1c53d8570..aa710ca395 100644--- a/scripts/generate-plugin-tree.ts+++ b/scripts/generate-plugin-tree.ts@@ -20,8 +20,9 @@* _brain-filing-rules.json) always ship, mirroring the openclaw bundler.** Starter-surface gap snapshot: each bundled skill's frontmatter `tools:`- * list is compared against STARTER_OPS (the plugin lanes serve- * `--surface starter`). Harness tools (shell/exec/read/write/edit/+ * list is compared against the REGISTRATION_SURFACE op set (the plugin lanes+ * serve `--surface starter`, the surface every stdio registration gbrain+ * writes pins; the root plugin manifests must pin the same value). Harness tools (shell/exec/read/write/edit/* web_search/web_fetch), literal `gbrain` (CLI usage marker), and unknown* non-op names are not MCP ops; `mcp:`-prefixed names count with the prefix* stripped. The computed per-skill gap set must equal the `starter_gaps`@@ -38,7 +39,8 @@import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'fs';import { join, resolve } from 'path';-import { STARTER_OPS } from '../src/mcp/surface.ts';+import { allowedOpNames } from '../src/mcp/surface.ts';+import { REGISTRATION_SURFACE } from '../src/core/mcp-registration.ts';import { operations } from '../src/core/operations.ts';import { cliEquivalent } from '../src/core/ops/cli-equivalent.ts';import { parseSkillFrontmatter } from '../src/core/skill-frontmatter.ts';@@ -130,6 +132,7 @@ try {}// ── Starter-gap snapshot ────────────────────────────────────────────────────+const SURFACE_OPS = allowedOpNames(operations, REGISTRATION_SURFACE);// Harness-native tool names a skill may declare that are not gbrain MCP ops.const HARNESS_TOOLS = new Set(['shell', 'exec', 'read', 'write', 'edit', 'web_search', 'web_fetch', 'gbrain']);@@ -150,7 +153,7 @@ function starterGaps(slug: string): string[] {// Multi-word entries ("gbrain schema add-type …") are CLI command// strings, not MCP op names — same class as the bare `gbrain` marker..filter(t => !HARNESS_TOOLS.has(t) && !t.startsWith('gbrain '));- return [...new Set(mcpOps.filter(t => !STARTER_OPS.has(t)))].sort();+ return [...new Set(mcpOps.filter(t => !SURFACE_OPS.has(t)))].sort();}const computedGaps: Record<string, string[]> = {};@@ -172,10 +175,10 @@ function surfaceNote(gaps: readonly string[]): string {});return ['', '## Tools outside your MCP surface', '',- 'This plugin serves the starter tool surface. When a step above names one of these tools and your tool list',- 'does not have it, run its gbrain CLI equivalent instead:', '',+ `This plugin serves the ${REGISTRATION_SURFACE} tool surface. When a step above names one of these tools and your tool list`,+ 'does not have it, call request_tools {"surface":"full"} to add it to this session, or run its gbrain CLI equivalent:', '',...rows, '',- "Or widen this machine's plugin surface with GBRAIN_SURFACE=full (new sessions pick it up).", '',+ "To widen every new session, set this machine's plugin surface with GBRAIN_SURFACE=full.", '',].join('\n');}@@ -206,6 +209,19 @@ if (writeGaps) {}}+// The root plugin manifests (copied into every variant) must pin the registration surface.+function pinnedSurface(args: unknown): string | undefined {+ if (!Array.isArray(args)) return undefined;+ const i = args.indexOf('--surface');+ return i >= 0 ? String(args[i + 1]) : undefined;+}+for (const file of ['.codex-plugin/mcp.json', '.claude-plugin/plugin.json']) {+ if (!existsSync(join(ROOT, file))) continue;+ const servers = (JSON.parse(readFileSync(join(ROOT, file), 'utf8')) as { mcpServers?: Record<string, { args?: unknown }> }).mcpServers;+ const pinned = pinnedSurface(servers?.gbrain?.args);+ if (pinned !== REGISTRATION_SURFACE) fail(`${file} pins --surface ${pinned ?? '(none)'}; plugin lanes serve the registration surface '${REGISTRATION_SURFACE}' (src/core/mcp-registration.ts)`);+}+if (failed) process.exit(1);// ── Emit the tree ───────────────────────────────────────────────────────────@@ -253,15 +269,16 @@ addition/exclusion).## MCP surface note (read once)-The plugin's MCP server runs \`gbrain serve --surface starter\` — the-${STARTER_OPS.size}-op daily-driver surface (the seven memory verbs + daily-brain ops + capture). ${gapSkills}+The plugin's MCP server runs \`gbrain serve --surface ${REGISTRATION_SURFACE}\` — the+${SURFACE_OPS.size}-op daily-driver surface (the seven memory verbs + daily+brain ops + capture), the same surface every stdio registration gbrain writes+pins. ${gapSkills}bundled skills reference gbrain operations beyond that surface; every one ofthem has a first-class \`gbrain\` CLI path, which is the primary way skillsdrive gbrain. When a skill step names an operation your MCP tool list doesn't-carry, run the equivalent \`gbrain\` CLI command, or widen this machine's-plugin surface with \`GBRAIN_SURFACE=full\` (the launcher honors it; new-sessions pick it up).+carry, call \`request_tools {"surface":"full"}\` to add it to this session, run+the equivalent \`gbrain\` CLI command, or widen this machine's plugin surface+with \`GBRAIN_SURFACE=full\` (the server honors it; new sessions pick it up).## Requirementsdiff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex c8d143f471..51e3589e08 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -25,7 +25,7 @@ src/core/postgres-engine.ts 2917 ratchet +1 System One v1 evals: search arms clasrc/core/search/hybrid.ts 1584 ratchet +2 System One v1: HybridSearchOpts.decide (search/decide-stage.ts); refactor wave 1 split target (W4 hybrid, cut line); ceiling rationale: docs/architecture/key-files/core-search-1.md entry for src/core/search/hybrid.ts; +10 #5691: per-request embedding_query_prefix read once and threaded to the embeds and cache keysrc/core/types.ts 2124 ratchet +5 System One v1 retrieval lane: SearchResult injection_p/injection_suspected, HybridSearchMeta answerability, egress_denied degraded reason; +4 System One v1: SearchResult rerank_score_kind/decide_evidence, HybridSearchMeta decide/rerank; +3 wave review: PAGE_SORT_SQL.updated_asc source_id + id tiebreakers (total order under federated scopes); +5 #4881: OntologyReadOpts extends PageReadScope doc; +3 #4857: PAGE_SORT_SQL.slug total-order tiebreaker comment; grown v0.46.26.0 megawave: EvidenceOpts, pacing/usage result fields, PageFilters growth (#4352 #4218); wave-k: +9 SalienceOpts/AnomaliesOpts source scope (#3867); +20 2026-09 adversarial batch 2: keyword_relaxed_carried stage + relaxed_dropped meta field docs; +16 2026-09 fix wave: SearchResult.keyword_relaxed field + full fusion-demotion doc; (#3867); +9: #4648 rerank_passthrough degraded stage + empty_result_set/malformed_shape reasons | merged v0.48.1.0 true-up; +master v0.48 merge true-up (reranker succession: no_key preflight, reranker_skipped stage, readiness); corrective release: shared internal PageReadScope and PageReadPolicy; ranker wave v0.48.4.0: HybridSearchMeta relational_rerank_pin / keyword_arm_confidence / metadata_boost_gate + SearchResult.relational_pinned (+48 over master's peel); +12: #4681 Page.updated_at_iso + keyset cursor precision docs; #5105: canonical page state shared module and transaction/snapshot delegates; #5105: public page revision fields; upstream integration: preserve independently reviewed master additions with branch facade extraction; #5252 wave: typed vector pool and readiness metadata; merged company ingestion/schema routing changes; retired provider integration removed; +1 write-path wave: 'created' effective-date source; +3 read-path wave: rerank_failed degraded stage + budget reason (closed vocabularies) and its recall classification note; +8 fw3-search: SearchOpts.source_boosts + keyword_arm_failed/title_arm_failed stages; +2 wave-2 W4: ChunkInput.embedding_input_hash (#5553); fix wave 3 x fix wave 2 (v0.60.5.0) composition: +2 at the merge; evidence delivery: optional SearchResult.delivered (+2; shape in search/evidence-delivery.ts); +2 eval wave N1-3: OntologyReadOpts.visibility (remote world-only ontology reads); +4 #5827: GraphNode.source_id and GraphPath from_source_id/to_source_id; +2 #5824: SearchOpts.vectorLegacyGuard rollback switch; +7 #5154: PageFilters.listColumnsOnly (interface field); +11 Foundations 1 F1b: WriteAttributionView + AttributedPageVersion (get_versions / get_write_attribution read shapes); +1 #5988: SearchResult.stale carries the held-file detail (interface field)src/core/minions/queue.ts 2522 ratchet grown #4078 + megawave probe-liveness unlatch (#4310) + master private-queue lifecycle: recovery classifier + monotonic lease; security: durable queued authority and confined filesystem dispatch; master integration: grown #4078 + megawave probe-liveness unlatch (#4310) + master private-queue lifecycle: recovery classifier + monotonic lease; harness support: boundary wiring to shared grants, isolated setup, withdrawal and delegated guards; merged v0.49: durable authority and delegated admission both enforced; typed readiness, configuration-blocked lifecycle and bounded release; +9: prune archives completed dream synthesis keys-src/commands/init.ts 1869 ratchet grown v0.46.x keyless capability notices; grown db-availability loop: initPostgresCore typed-failure extraction + --prefer-postgres ladder hook + pgvector rethrow fix; +1 at megawave/wave-k merge; +master-merge true-up; wave-k: merge; #3753 --force re-init engine-preservation guard; +1 wave-k merge-union brace (--prefer-postgres close); +10 ambient-writeback WP8: runWritebackNudge consent ask in both engine epilogues (logic lives in core/onboard/writeback-nudge.ts); +4: v0.48.2 reranker readiness at init + test seam; +1: v0.48.2 provider normalization; +3: v0.48.2 review fixes; master integration: +2: preserve typed PGLite busy errors in schema-only init; shared-skills integration on company-ingestion base; retired provider integration removed; retain stored-vector identity on re-init; -14: first-run bundle + quickstart registration helpers live in init-first-run.ts (writeback/skills asks folded into the bundle)+src/commands/init.ts 1874 ratchet grown v0.46.x keyless capability notices; grown db-availability loop: initPostgresCore typed-failure extraction + --prefer-postgres ladder hook + pgvector rethrow fix; +1 at megawave/wave-k merge; +master-merge true-up; wave-k: merge; #3753 --force re-init engine-preservation guard; +1 wave-k merge-union brace (--prefer-postgres close); +10 ambient-writeback WP8: runWritebackNudge consent ask in both engine epilogues (logic lives in core/onboard/writeback-nudge.ts); +4: v0.48.2 reranker readiness at init + test seam; +1: v0.48.2 provider normalization; +3: v0.48.2 review fixes; master integration: +2: preserve typed PGLite busy errors in schema-only init; shared-skills integration on company-ingestion base; retired provider integration removed; retain stored-vector identity on re-init; -14: first-run bundle + quickstart registration helpers live in init-first-run.ts (writeback/skills asks folded into the bundle); +5 agent operator follow-up Item 2: --surface flag (value flag, parse, help line, module-level registration surface, type import) for the printed harness registrationsrc/commands/integrations.ts 1739 ratchet grown v0.46.26.0 megawave (#4039 connector compat) + 1 nosemgrep dataflow annotation (path-traversal audit); wave-k: exported heartbeatPath seam (#3900)src/core/minions/handlers/subagent.ts 1918 ratchet merged: master v131 settle rework + dream-wave C5 peel + C6 accounting + C7 lease heartbeats/lost-lease aborts + C9 oneshot dispatch + adversarial fix batches; grown by #4078 subagent-loop capability fix; +6 lines (reasoning-item replay: adaptContentBlocksToChatBlocks handles 'reasoning' blocks); +3 wave G #4514: Anthropic-via-OpenRouter allowed on the subagent loop; +36 lines (code review, same PR): isPromptTooLongError walks a bounded .cause chain so it still matches post-normalizeAIError() wrapping, plus extractPromptTooLongDetail so the dead-lettered job's error carries the matched provider detail instead of the generic normalizeAIError() wrapper text; master integration: harness support: boundary wiring to shared grants, isolated setup, withdrawal and delegated guards; #5105: +13 call-site wiring to shared tool-write-identity helper across fresh and replay dispatchsrc/commands/bootstrap.ts 2142 ratchet grandfathered at merge (grew past the 1500 cap on master); raised for #4066 HOME_WORKSPACE_GUARD_EXEMPT (status/uninstall/harness); +5 for the harnessDetect test seam (bulk lives in core/bootstrap/harness.ts); +23 for the contract subcommand dispatcher glue (#4105 absorb — bulk lives in core/bootstrap/contract.ts); +codex hooks-consent gate + mcp+hooks receipt registration + uninstall arm; +42 ambient-writeback WP8: interview-time SURFACE_MULTIUSER audience apply (pre-init ordering) + applyDeclaredAudienceFromInterview; +3 #4897 harness usage clause documenting --source ID semantics; +5 #5878: --refresh-skills dispatch and usage lines (logic in core/bootstrap/harness-skills.ts); +11 #5488: SUBCOMMAND_HELP harness entry (gate on --help / -h / help) — CLI help line, cannot move; +11 #4618 seat: --seat/--no-seat help lines and the runHooks parse (parse + notes live in core/bootstrap/hooks.ts parseSeatFlags)@@ -36,7 +36,7 @@ src/core/embedding-migration.ts 1569 ratchet new row: crossed 1500 in v0.46.25.0src/core/github-source.ts 1530 ratchet new row: crossed the 1500 unlisted cap in v0.46.23.0 review fix wave (scope-state gating, client hardening, symlink containment); merged reliability/shared-skills source integration; managed sweep lease wrapper; fix wave 3 lane A: config parser peeled to github-source-config.ts (-47), +account pin wiring and pinned-installation refreshsrc/commands/hook.ts 1903 ratchet cathedral-5 heartbeat extraction offsets part of the BrainBench-seam growth; grown v0.46.26.0 megawave hooks-ipc (#4245); +108 monthly backup check: banner + gated session-start note + detached spawn (backup/status-file readers); +28 ship-review egress hardening: per-harness capture dispatch (capture-spec), memorable gate + receipt + relay block, fail-closed unscanned/newest-guess skips; +79 ambient-writeback WP4: hookStop bank step (gate -> bankWritebackTurn -> IPC flush; gate/bank logic live in core/facts + corpus-segments); +41 adversarial fix wave: wide-tail retry when the 128KB window misses the user turn, by-design heartbeat outcome classes, source-in-name banking; +11 #5413 session-end skips claude-cli self-transcripts; +11 #5701: hook lanes pass allowOversize so a long session reaches the bounded tail readsrc/core/chunkers/code.ts 1588 ratchet new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (decorated-python defs #3821, version-gate + timeout chunker fixes); grown wave-g (#4511): named defs never folded into merged chunks; grown #4669: skip WASM parse for languages without TOP_LEVEL_TYPES; +6 N13-1: CodeChunkMetadata.definesFunction field + merge-guard stamp (predicate lives in def-types.ts)-src/core/config.ts 1838 ratchet +8 #5988: sync.holds/hold_cap/hold_escalate_count/hold_escalate_pct/parser_regression key registration (read by persistence/sync-holds.ts); +3 agent operator wave A4: GBrainConfig.consent file-plane slot + 2 consent.preapprove.* key rows (logic in core/consent.ts); +1 System One v1: decide.* key prefix (validated by ai/decide/config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (spend-controls hint #3703, config-set validation); +3 wave G #3974: sync.include_working_tree key; grown wave-g (#4540 #4494 #4415): extractor caps + intent-pattern config keys; +1 chat-connectors: connectors. config prefix; wave-k: config-table snapshot serving the DB-plane reads (#3980 + #2119 merge); +8: loadConfig hook for ~/.gbrain/.env, loader lives in gbrain-env-file.ts (#3893); +17: litellm/together key-fold slots (#3904 reimpl: two GBrainConfig fields + KNOWN_CONFIG_KEYS rows); +1: link_resolution.cross_source key (#3908); +4 v0.47 gmail-loops: loops.extraction_enabled key; +1: pricing.overrides key (#4633 adoption); +7 #4667 adoption: sync.exclude key registration; +4: eval fix wave keys (quote_verify + 3 rescue knobs); +memorable file-plane key registration (integrations.memorable.enabled + consent-event doc); +33 ambient-writeback: memory.* + brain.audience key registration + GBrainConfig.memory mirror slot (resolvers live in facts/writeback-config.ts); +38 2026-08 wave: retrieval_reflex_volunteer key + env mapping (volunteer-arm kill switch) + E5a registration of the 10 adaptive_return*/autocut*/crag_* search (incl. adversarial batch isEnvDisabled dedup); ambient-writeback (master merge): facts/writeback-config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave; prior growth: sync/intent/chat-connectors/litellm/pricing/loops key folds; +34: #4702 content_sanity.disabled_patterns (type + DB-plane parse/merge + key registration); composition true-up (fix-wave multi-train) | merged v0.48.1.0: master #4788 writeback keys + wave #4702/#4748 keys; master: | merged v0.48.1.0 true-up; ranker wave v0.48.4.0: +4 KNOWN_CONFIG_KEYS rows (+8); +5 #4895: CWD_DOTENV_FILES gains the per-NODE_ENV .local variants Bun auto-loads; +2 #5003: sync.include_hidden key registration; +57 #4605: search.* registry reconciled to the keys mode.ts reads (+20 knob rows, +4 direct-read singletons) + GBrainConfig.search slot + adaptive_return* DB-plane merge; +2 pre-landing review: fts.reindex_in_progress key registration (#4795 marker escape hatch); +4 #4987: auto_timeline key registration (the documented off switch was rejected as unknown); lowered to 1793: GHSA wave v0.50.5.0 moved CWD_DOTENV_FILES + dotenvValuesForKey into core/env-trust.ts (-49, re-exported); re-summed to the merged line count after merging master v0.50.2.0 (#5122) with the v0.50.5.0 security wave; fix wave 3 x fix wave 2 (v0.60.5.0) composition: +1 at the merge; evidence delivery: 5 registered config keys + comment (+7); +2 #5691: embedding_query_prefix key registration; evidence delivery auto v2: search.return_budget_conversation key row (+1); +1 #5836: facts.entity_inference key row; +6 #5824: search.vector_legacy_guard key row + GBrainConfig.search slot + DB-plane merge; +3 wave 8 lane D1 #5885: takes.auto_embed key row; +3 #5232: GBrainConfig.persistence.write_wait_ms file-plane slot + key row (resolver in persistence/write-wait.ts); +2 F4b: planner.* and import.analyze_every_pages keys; +3 cat40 cost wave C1 (garrytan/gbrain-evals#57 follow-ups): mcp.result_rows GBrainConfig slot + key row (resolver in mcp/result-rows.ts); v0.60.46.0 merge: both waves' +3 compose (1824 + 3 = 1827 measured); +4 #5984: sync.bulk, sync.bulk_size, sync.bulk_max_txn_ms known keys; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (1838 measured)+src/core/config.ts 1841 ratchet +8 #5988: sync.holds/hold_cap/hold_escalate_count/hold_escalate_pct/parser_regression key registration (read by persistence/sync-holds.ts); +3 agent operator wave A4: GBrainConfig.consent file-plane slot + 2 consent.preapprove.* key rows (logic in core/consent.ts); +1 System One v1: decide.* key prefix (validated by ai/decide/config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (spend-controls hint #3703, config-set validation); +3 wave G #3974: sync.include_working_tree key; grown wave-g (#4540 #4494 #4415): extractor caps + intent-pattern config keys; +1 chat-connectors: connectors. config prefix; wave-k: config-table snapshot serving the DB-plane reads (#3980 + #2119 merge); +8: loadConfig hook for ~/.gbrain/.env, loader lives in gbrain-env-file.ts (#3893); +17: litellm/together key-fold slots (#3904 reimpl: two GBrainConfig fields + KNOWN_CONFIG_KEYS rows); +1: link_resolution.cross_source key (#3908); +4 v0.47 gmail-loops: loops.extraction_enabled key; +1: pricing.overrides key (#4633 adoption); +7 #4667 adoption: sync.exclude key registration; +4: eval fix wave keys (quote_verify + 3 rescue knobs); +memorable file-plane key registration (integrations.memorable.enabled + consent-event doc); +33 ambient-writeback: memory.* + brain.audience key registration + GBrainConfig.memory mirror slot (resolvers live in facts/writeback-config.ts); +38 2026-08 wave: retrieval_reflex_volunteer key + env mapping (volunteer-arm kill switch) + E5a registration of the 10 adaptive_return*/autocut*/crag_* search (incl. adversarial batch isEnvDisabled dedup); ambient-writeback (master merge): facts/writeback-config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave; prior growth: sync/intent/chat-connectors/litellm/pricing/loops key folds; +34: #4702 content_sanity.disabled_patterns (type + DB-plane parse/merge + key registration); composition true-up (fix-wave multi-train) | merged v0.48.1.0: master #4788 writeback keys + wave #4702/#4748 keys; master: | merged v0.48.1.0 true-up; ranker wave v0.48.4.0: +4 KNOWN_CONFIG_KEYS rows (+8); +5 #4895: CWD_DOTENV_FILES gains the per-NODE_ENV .local variants Bun auto-loads; +2 #5003: sync.include_hidden key registration; +57 #4605: search.* registry reconciled to the keys mode.ts reads (+20 knob rows, +4 direct-read singletons) + GBrainConfig.search slot + adaptive_return* DB-plane merge; +2 pre-landing review: fts.reindex_in_progress key registration (#4795 marker escape hatch); +4 #4987: auto_timeline key registration (the documented off switch was rejected as unknown); lowered to 1793: GHSA wave v0.50.5.0 moved CWD_DOTENV_FILES + dotenvValuesForKey into core/env-trust.ts (-49, re-exported); re-summed to the merged line count after merging master v0.50.2.0 (#5122) with the v0.50.5.0 security wave; fix wave 3 x fix wave 2 (v0.60.5.0) composition: +1 at the merge; evidence delivery: 5 registered config keys + comment (+7); +2 #5691: embedding_query_prefix key registration; evidence delivery auto v2: search.return_budget_conversation key row (+1); +1 #5836: facts.entity_inference key row; +6 #5824: search.vector_legacy_guard key row + GBrainConfig.search slot + DB-plane merge; +3 wave 8 lane D1 #5885: takes.auto_embed key row; +3 #5232: GBrainConfig.persistence.write_wait_ms file-plane slot + key row (resolver in persistence/write-wait.ts); +2 F4b: planner.* and import.analyze_every_pages keys; +3 cat40 cost wave C1 (garrytan/gbrain-evals#57 follow-ups): mcp.result_rows GBrainConfig slot + key row (resolver in mcp/result-rows.ts); v0.60.46.0 merge: both waves' +3 compose (1824 + 3 = 1827 measured); +4 #5984: sync.bulk, sync.bulk_size, sync.bulk_max_txn_ms known keys; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (1838 measured); +3 agent operator follow-up Item 2: mcp.allow_session_widen (GBrainConfig.mcp slot + known key)src/core/bootstrap/harness.ts 2711 ratchet +29 live-PGLite-serve lane: LIVE_SERVE refusal ahead of source resolution + unpinned --token hooks (CI e2e fix); +46 wave review: resolveHookSource dep (serve-parity resolver + federated grant), --source shape validation, loud SOURCE_UNRESOLVED instead of a silent 'default'; +10: #4574 parseCodexBlockBearer http_headers shape + legacy bearer_token fallback; +4 at megawave/wave-k merge; +codex hooks lane: step-7 codex hooks.json + config.toml trust pair, removeHarness arm; +234 ambient-writeback WP3: kind:'instructions' targets (plan/apply/converge-off/remove/status probes, OV-A4 override pre-check) — splice/render mechanics live in instructions-block.ts; +59 adversarial fix wave: registrar-mode block suppression, converge-failure receipt tracking, MCP-confirmed guard before block install; +26 round-3 fixes: codex-lane MCP-confirmed guard + smoke-rollback block strip; master: | merged v0.48.1.0 true-up; +41 #4897 resolveImplicitSource dep + defaultResolveImplicitSource: hooks/token/receipt bind to the serve's implicit default source when --source is omitted; +23 #4586 statusHarness live claude-code mcp verdict (URL mismatch or same-scope non-HTTP registration reads failed, receipt untouched); shared-skills integration on company-ingestion base; +18 #5671: logAmbientPostureNotes helper (registrar note moved out of applyHarness + pre-consent warning when an explicit private facts default meets the HTTP harness; text shared with doctor in facts/writeback-config.ts); +24 #5893: rotation grant carry wiring and its rotationCarry/withheldOperationsNote helpers (carry rules live in token-mint.ts carryLegacyGrant); +6 #5878: --refresh-skills flag and status epoch line (refresh logic lives in harness-skills.ts); +7 #4618 seat: HarnessFlags.seat field, --seat/--no-seat parse via hooks.ts parseSeatFlags, GBRAIN_SEAT in the hook envsrc/core/oauth-provider.ts 1236 ratchet new row: crossed the 1500 unlisted cap absorbing #3819 (DCR 400 invalid_client_metadata + scope filtering + custom-scheme redirect_uris + pseudo-scheme guard); merged v0.49: transactional grant enforcement shared with hosted grant policies; +1 #5222 resourceUrl optionsrc/core/ops/pages.ts 663 ratchet crossed the unlisted 1500 cap in the fix wave: pack-vocabulary enforcement on capture (#4721) + get_page alias follow (#4275) landed together; next growth should peel a pages-ops submodule; +3: alias hop reads the canonical in the owning source (ship-review); +5: explicit source_id liveness check in get_page/list_pages (#4620); +3: #4857 total-order slug sort + list_pages source_id parse; +5: #4620 explicit removed-source id fails loudly; master integration: +4: authenticated delegated private-write boundary and auto-link suppression; #5105: canonical page mutations peeled into persistence modules; +2 v0.50.5.0 purge parameter and shared preflight call; preparation composes through the persistence modules; +7: source-qualified deep-research fetch authorization and ambiguity refusal (codec lives in deep-research-id.ts); +1 #5567: remote get_page keeps materialized markers; +1 #5622: trusted local capture file parameter; +5 #5709: get_page include_timeline_entries (rows via get_timeline's read policy); +8 GBRA-36 security wave: required outputRedaction policy on each pages op; +1 #5154: list_pages passes listColumnsOnly; +17 #5641: list_pages exposes the updated_after_slug keyset cursor and updated_at_iso; +8 agent operator wave A2: every op declares mutating + idempotent (tags only); +7 F3b (#5954): list_pages pagination meta + listing_truncated notice for MCP callers (logic in ops/list-pages-pagination.ts); +4 #5988: get_page file_held (one indexed hold lookup; logic in persistence/held-reads.ts)diff --git a/src/commands/bootstrap.ts b/src/commands/bootstrap.tsindex 31ea0e356f..d01e80fe05 100644--- a/src/commands/bootstrap.ts+++ b/src/commands/bootstrap.ts@@ -64,6 +64,8 @@ import {removeClaudeHooks,} from '../core/bootstrap/hooks.ts';import { removeCodexHooks, writeCodexHooks } from '../core/bootstrap/codex-hooks.ts';+import { registeredSurface, stdioServeArgv } from '../core/mcp-registration.ts';+import { parseSurfaceFlag, type McpSurface } from '../mcp/surface.ts';import {guardReceiptOverwrite,readHarnessReceiptState,@@ -201,8 +203,8 @@ const SUBCOMMAND_HELP: Record<string, string> = {' under your own account), verify the privacy bit via the API, push.',hooks:'gbrain bootstrap hooks [--harness claude-code|codex|opencode] [--repair] [--no-hooks] [--gbrain-bin <path>]\n' +- ' [--seat <label> | --no-seat]\n' +- ' Register MCP (+ per-turn hooks on Claude Code, ON by default; --no-hooks opts out).\n' ++ ' [--seat <label> | --no-seat] [--surface verbs|starter|full]\n' ++ ' Register MCP (--surface starter unless given; a replaced entry keeps its surface) (+ per-turn hooks on Claude Code, ON by default; --no-hooks opts out).\n' +' --seat credits captured sessions to this agent seat (kept on re-install; --no-seat clears it; --seat off records none).',verify:'gbrain bootstrap verify [--json]\n' +@@ -385,7 +387,8 @@ export function detectHarness(env: Record<string, string | undefined> = process.** Returns 'match' (ours), 'mismatch' (points elsewhere — caller re-registers or* warns), or 'unknown' (the host has no `mcp get` / empty output — inconclusive,- * never silently blessed).+ * never silently blessed), plus the registration's surface form+ * (`registeredSurface`) so a replacement never narrows it.*/async function verifyMcpTargetsWorkspace(runner: ExecRunner,@@ -393,7 +396,7 @@ async function verifyMcpTargetsWorkspace(name: string,gbrainBin: string,sourceId: string,-): Promise<'match' | 'mismatch' | 'unknown'> {+): Promise<{ verdict: 'match' | 'mismatch' | 'unknown'; surface?: McpSurface | null }> {// Exec-lane harnesses only. opencode registrations go through the direct// JSONC writer whose 4-state fingerprint IS the [FIX7] check (structural,// no exec) — it never routes here; 'unknown' keeps a stray call honest.@@ -403,19 +406,19 @@ async function verifyMcpTargetsWorkspace(opencode: null,} as const satisfies Record<Harness, string | null>;const bin = EXEC_HARNESS_BIN[harness];- if (bin === null) return 'unknown';+ if (bin === null) return { verdict: 'unknown' };let res;try {res = await runner([bin, 'mcp', 'get', name]);} catch {- return 'unknown';+ return { verdict: 'unknown' };}- if (res.code !== 0) return 'unknown';+ if (res.code !== 0) return { verdict: 'unknown' };const out = `${res.stdout}\n${res.stderr}`;- if (out.trim() === '') return 'unknown';+ if (out.trim() === '') return { verdict: 'unknown' };const hasBin = out.includes(gbrainBin);const hasSource = out.includes(`GBRAIN_SOURCE=${sourceId}`);- return hasBin && hasSource ? 'match' : 'mismatch';+ return { verdict: hasBin && hasSource ? 'match' : 'mismatch', surface: registeredSurface(out) };}/** Wall-clock cap on the best-effort `opencode mcp list` probe: `mcp list`@@ -1083,6 +1086,7 @@ async function runHooks(// gbrain binary still matches. This flag forces the hand-wired MCP// registration through anyway.const mcpEvenIfPlugin = rest.includes('--mcp-even-if-plugin');+ const surfaceFlag = parseSurfaceFlag(rest);const state = readManifest(ws);if (state.state !== 'initialized') {@@ -1265,10 +1269,7 @@ async function runHooks(// no absolute machine paths in a file that travels, and no fail-open// analog exists — the sharing warning below is the mitigation).const configPath = mcpScope === 'project' ? opencodeProjectConfigPath(ws) : opencodeGlobalConfigPath();- const command =- mcpScope === 'project'- ? ['gbrain', 'serve', '--surface', 'full']- : [gbrainBin, 'serve', '--surface', 'full'];+ const command = stdioServeArgv(mcpScope === 'project' ? 'gbrain' : gbrainBin, surfaceFlag ?? undefined);const entry = {kind: 'local' as const,name: 'gbrain',@@ -1295,11 +1296,11 @@ async function runHooks(// pre-check parse carries the same paste-by-hand snippet the writer// uses so a corrupt config never strands the user.const existingText = existsSync(configPath) ? readFileSync(configPath, 'utf8') : '';- const existingKind = opencodeEntryKind(- parseOpencodeConfig(existingText, configPath, opencodeEntrySnippet(entry)),- 'gbrain',- { sourceId },- );+ const existing = parseOpencodeConfig(existingText, configPath, opencodeEntrySnippet(entry));+ const existingKind = opencodeEntryKind(existing, 'gbrain', { sourceId });+ const priorCommand = ((existing.mcp as Record<string, { command?: unknown }> | undefined)?.gbrain)?.command;+ const prior = existingKind !== 'absent' && !surfaceFlag && Array.isArray(priorCommand) ? registeredSurface(priorCommand.join(' ')) : undefined;+ if (prior !== undefined) entry.command = stdioServeArgv(command[0], prior);if (existingKind === 'ours-other-source') {console.error(`existing 'gbrain' opencode entry targets a DIFFERENT workspace — replacing it.`);}@@ -1420,11 +1421,10 @@ async function runHooks('workspace-bound registration with `--mcp-even-if-plugin`.',);}- const argvs = mcpPluginOwned- ? []- : harness === 'claude-code'- ? registerClaudeMcp({ gbrainBin, scope: mcpScope, sourceId, ...(gbrainHome ? { gbrainHome } : {}) })- : registerCodexMcp({ gbrainBin, sourceId, ...(gbrainHome ? { gbrainHome } : {}) });+ const buildArgvs = (surface?: McpSurface | null) => harness === 'claude-code'+ ? registerClaudeMcp({ gbrainBin, scope: mcpScope, sourceId, surface, ...(gbrainHome ? { gbrainHome } : {}) })+ : registerCodexMcp({ gbrainBin, sourceId, surface, ...(gbrainHome ? { gbrainHome } : {}) });+ const argvs = mcpPluginOwned ? [] : buildArgvs(surfaceFlag ?? undefined);for (const argv of argvs) {const mcpName = argv[3] ?? 'gbrain'; // ['<host>','mcp','add',<name>,…]const res = await runner(argv);@@ -1446,7 +1446,7 @@ async function runHooks(// [FIX7] "already registered" is NOT proof the registration is OURS.// Verify it targets this workspace's serve; if it points elsewhere,// remove + re-add rather than blessing a foreign/stale registration.- const verdict = await verifyMcpTargetsWorkspace(runner, harness, mcpName, gbrainBin, sourceId);+ const { verdict, surface: priorSurface } = await verifyMcpTargetsWorkspace(runner, harness, mcpName, gbrainBin, sourceId);if (verdict === 'match') {console.log('MCP server already registered for this workspace — kept.');} else if (verdict === 'mismatch') {@@ -1472,7 +1472,7 @@ async function runHooks();return 1;}- const re = await runner(argv);+ const re = await runner(surfaceFlag || priorSurface === undefined ? argv : buildArgvs(priorSurface)[0]);if (re.code !== 0 && !/already exists|already registered/i.test(re.stderr + re.stdout)) {console.error(`MCP re-registration failed (${argv.join(' ')}): ${re.stderr.trim() || `exit ${re.code}`}`);return 1;@@ -1482,7 +1482,7 @@ async function runHooks(// is NOT ours. Re-verify and abort rather than bless a foreign// endpoint that would intercept memory ops. (Only the recorded// warn-then-continue step-2 smoke did this before; here it's fatal.)- const post = await verifyMcpTargetsWorkspace(runner, harness, mcpName, gbrainBin, sourceId);+ const post = (await verifyMcpTargetsWorkspace(runner, harness, mcpName, gbrainBin, sourceId)).verdict;if (post === 'mismatch') {console.error(`after replacing '${mcpName}', it STILL targets a different workspace/binary — ` +@@ -1509,7 +1509,7 @@ async function runHooks(if (!mcpSkipped && !mcpPluginOwned) try {const listBin = harness === 'claude-code' ? 'claude' : 'codex';const scopeLabel = harness === 'claude-code' ? mcpScope : 'user-global';- const verdict = await verifyMcpTargetsWorkspace(runner, harness, 'gbrain', gbrainBin, sourceId);+ const { verdict } = await verifyMcpTargetsWorkspace(runner, harness, 'gbrain', gbrainBin, sourceId);if (verdict === 'match') {console.log(`MCP registered with ${harness} (scope: ${scopeLabel}) — verified targeting this workspace.`);} else if (verdict === 'mismatch') {diff --git a/src/commands/init-first-run.ts b/src/commands/init-first-run.tsindex 02bbd95dcc..01186485c3 100644--- a/src/commands/init-first-run.ts+++ b/src/commands/init-first-run.ts@@ -20,6 +20,7 @@ import type { BrainEngine } from '../core/engine.ts';import { resolveGbrainBin } from '../core/gbrain-bin.ts';import { configReadiness, embeddingEnablement, harnessWiringEntry } from '../core/readiness.ts';import type { SearchMode } from '../core/search/mode.ts';+import type { McpSurface } from '../mcp/surface.ts';export interface InitFirstRunInputs {/** The search mode init applied and why (from the install-time picker). */@@ -30,6 +31,8 @@ export interface InitFirstRunInputs {writeback?: boolean;/** Recommended skills missing from the agent workspace (`initSkillsScaffold`). */skillsScaffold?: { missing: string[]; argv: string[] } | null;+ /** `gbrain init --surface`: the surface the harness registration pins (default REGISTRATION_SURFACE). */+ surface?: McpSurface;}const SEARCH_MODE_COST =@@ -47,8 +50,8 @@ function searchModeDecision(applied: { mode: SearchMode; reason: string }): Deci};}-function harnessWiringDecision(config: GBrainConfig): Decision | null {- const entry = configReadiness(config, { transport: 'cli' }).entries.find(e => e.capability === 'harness_wiring');+function harnessWiringDecision(config: GBrainConfig, surface?: McpSurface): Decision | null {+ const entry = configReadiness(config, { transport: 'cli', ...(surface ? { surface } : {}) }).entries.find(e => e.capability === 'harness_wiring');if (!entry?.fix || entry.state === 'ok') return null;return {id: 'harness_wiring',@@ -98,7 +101,7 @@ export function buildInitFirstRunNotices(inputs: InitFirstRunInputs): Notice[] {if (inputs.searchMode) decisions.push(searchModeDecision(inputs.searchMode));if (inputs.writeback) decisions.push(writebackDecision());if (inputs.config) {- const wiring = harnessWiringDecision(inputs.config);+ const wiring = harnessWiringDecision(inputs.config, inputs.surface);if (wiring) decisions.push(wiring);}if (inputs.skillsScaffold?.missing.length) decisions.push(skillsScaffoldDecision(inputs.skillsScaffold));@@ -125,10 +128,10 @@ export function deferredEmbeddingHint(cfg: GBrainConfig): string {}/** init's bundle for this brain: reads the writeback gate and the agent workspace's missing skills. */-export async function firstRunBundle(engine: BrainEngine, searchMode: { mode: SearchMode; reason: string } | undefined): Promise<Notice[]> {+export async function firstRunBundle(engine: BrainEngine, searchMode: { mode: SearchMode; reason: string } | undefined, surface?: McpSurface): Promise<Notice[]> {const { writebackAskApplies } = await import('../core/onboard/writeback-nudge.ts');const { initSkillsScaffold } = await import('../core/skillpack/post-install-advisory.ts');- return buildInitFirstRunNotices({ searchMode, config: loadConfig(), writeback: await writebackAskApplies(engine), skillsScaffold: initSkillsScaffold() });+ return buildInitFirstRunNotices({ searchMode, config: loadConfig(), writeback: await writebackAskApplies(engine), skillsScaffold: initSkillsScaffold(), surface });}/** D2/G5: the bundle rendered into init's --json document (`notices`, empty → omitted). */@@ -139,14 +142,15 @@ export function firstRunJson(bundle: Notice[]): { notices?: unknown[]; contract_/*** The harness registration line for init's quickstart: the readiness- * `harness_wiring` fix (absolute binary, `--surface verbs`) for the detected- * harness, else the Claude Code registration built the same way. Null when- * the gbrain binary has no absolute path (never registered bare).+ * `harness_wiring` fix (absolute binary, `--surface starter` unless+ * `gbrain init --surface` names another) for the detected harness, else the+ * Claude Code registration built the same way. Null when the gbrain binary+ * has no absolute path (never registered bare).*/-export function harnessRegistrationCommand(): string | null {+export function harnessRegistrationCommand(surface?: McpSurface): string | null {const cfg = loadConfig();- const detected = cfg ? configReadiness(cfg, { transport: 'cli' }).entries.find(e => e.capability === 'harness_wiring')?.fix : undefined;+ const detected = cfg ? configReadiness(cfg, { transport: 'cli', ...(surface ? { surface } : {}) }).entries.find(e => e.capability === 'harness_wiring')?.fix : undefined;if (detected?.argv) return shellQuote(detected.argv);- const claude = harnessWiringEntry({ transport: 'cli', harnesses: ['claude-code'], lockOwner: null, gbrainBin: resolveGbrainBin() }).fix;+ const claude = harnessWiringEntry({ transport: 'cli', harnesses: ['claude-code'], lockOwner: null, gbrainBin: resolveGbrainBin(), ...(surface ? { surface } : {}) }).fix;return claude?.argv ? shellQuote(claude.argv) : null;}diff --git a/src/commands/init.ts b/src/commands/init.tsindex d5450e8916..23a94a03b5 100644--- a/src/commands/init.ts+++ b/src/commands/init.ts@@ -22,6 +22,7 @@ import { writeCliNotices } from '../core/interop-notices.ts';import { exitCodeForCode } from '../core/error-catalogue.ts';import { promptLineStderr } from '../core/interaction.ts';import type { SearchMode as SearchModeName } from '../core/search/mode.ts';+import type { McpSurface } from '../mcp/surface.ts';/** D2: `--json` writes exactly one document, after whichever branch ran (see init-json.ts). */export async function runInit(args: string[]) {@@ -45,6 +46,7 @@ async function runInitBranches(args: string[]) {}validateInitFlags(args);+ registrationSurface = (await import('../mcp/surface.ts')).parseSurfaceFlag(args) ?? undefined;const isSupabase = args.includes('--supabase');const isPGLite = args.includes('--pglite');@@ -257,6 +259,7 @@ const INIT_VALUE_FLAGS = new Set(['--issuer-url','--oauth-client-id','--oauth-client-secret',+ '--surface',]);function validateInitFlags(args: string[]) {@@ -1268,7 +1271,7 @@ export async function initPGLite(opts: {const stats = await engine.getStats();if (opts.jsonOutput) {- setInitJsonResult({ status: 'success', engine: 'pglite', path: dbPath, pages: stats.page_count, embedding_check: embedCheck, content: contentReceipt, ...firstRunJson(await firstRunBundle(engine, searchMode)) });+ setInitJsonResult({ status: 'success', engine: 'pglite', path: dbPath, pages: stats.page_count, embedding_check: embedCheck, content: contentReceipt, ...firstRunJson(await firstRunBundle(engine, searchMode, registrationSurface)) });} else if (process.env.GBRAIN_IN_AGENT_SETUP === '1') {printInAgentReady(dbPath);} else {@@ -1293,7 +1296,7 @@ export async function initPGLite(opts: {// G5: the ONE first-run decision bundle (search mode, writeback,// harness wiring, skills scaffold); never blocks init.- writeCliNotices(await firstRunBundle(engine, searchMode));+ writeCliNotices(await firstRunBundle(engine, searchMode, registrationSurface));// The single primary action, last-on-screen.printMemoryVerbsQuickstart({ emptyBrain: stats.page_count === 0, onPglite: true });@@ -1309,13 +1312,14 @@ const INIT_EMBEDDING_HINT = 'Pick an embedding model whose dimensions match (`gb* MEMORY_VERBS v1 quickstart funnel (E3 + D4B + T1 consent). Printed LAST in* both init epilogues as the ONE primary action. The copy-next block is* three commands (codex DX 9): wire the harness (the readiness- * `harness_wiring` fix: absolute binary, `--surface verbs`), save an+ * `harness_wiring` fix: absolute binary, `--surface starter` or init's `--surface`), save an* install-check marker (never a made-up fact about the user), and recall it.* The demo uses the facts arm only, so it works with NO embedding key [F-B]. Secondary paths (import, migrate) ride a single terse* "More:" footer so they never compete with the primary action.*/+let registrationSurface: McpSurface | undefined;function printMemoryVerbsQuickstart(opts: { emptyBrain?: boolean; onPglite?: boolean } = {}): void {- const register = harnessRegistrationCommand();+ const register = harnessRegistrationCommand(registrationSurface);console.log('');console.log(`→ Do this next — give your agent memory (copy these ${register ? 'three' : 'two'} commands):`);if (register) console.log(` ${register}`);@@ -1598,7 +1602,7 @@ export async function initPostgresCore(opts: {const stats = await engine.getStats();if (opts.jsonOutput) {- setInitJsonResult({ status: 'success', engine: 'postgres', pages: stats.page_count, embedding_check: embedCheck, content: contentReceipt, ...firstRunJson(await firstRunBundle(engine, searchMode)) });+ setInitJsonResult({ status: 'success', engine: 'postgres', pages: stats.page_count, embedding_check: embedCheck, content: contentReceipt, ...firstRunJson(await firstRunBundle(engine, searchMode, registrationSurface)) });} else {console.log(`\nBrain ready. ${stats.page_count} pages. Engine: Postgres (Supabase).`);if (stats.page_count > 0) {@@ -1616,7 +1620,7 @@ export async function initPostgresCore(opts: {await runInitNudge(engine);// G5: the first-run decision bundle — same contract as the PGLite arm.- writeCliNotices(await firstRunBundle(engine, searchMode));+ writeCliNotices(await firstRunBundle(engine, searchMode, registrationSurface));// The single primary action, last-on-screen.printMemoryVerbsQuickstart({ emptyBrain: stats.page_count === 0 });@@ -1847,6 +1851,7 @@ OPTIONS--chat-model <PROVIDER:MODEL>Default subagent driver (v0.27+)--no-embedding Defer embedding setup (skips the embedding-key check)+ --surface <verbs|starter|full> Tool surface the printed harness registration pins (default starter)--skip-embed-check Skip the init-time embedding-key validation (config +live test-embed). Also via GBRAIN_INIT_SKIP_EMBED_CHECK=1diff --git a/src/core/bootstrap/hooks.ts b/src/core/bootstrap/hooks.tsindex 1e323f91e1..48473e9a3f 100644--- a/src/core/bootstrap/hooks.ts+++ b/src/core/bootstrap/hooks.ts@@ -29,6 +29,8 @@ import { isAbsolute, join } from 'node:path';import { atomicWriteTextFile } from './atomic-write.ts';import { normalizeSeatLabel } from '../context/seat.ts';import { detectExecutionEnvironment } from '../execution-env.ts';+import { stdioServeArgv } from '../mcp-registration.ts';+import type { McpSurface } from '../../mcp/surface.ts';import {CLAUDE_COMMITTED_SETTINGS_FILE_RELPATH,CLAUDE_HOOK_DEFAULT_TIMEOUT_SECS,@@ -875,6 +877,8 @@ export interface ClaudeMcpRegistration {sourceId: string;/** PARENT dir for --isolated installs (config appends `.gbrain`) [CX2-8]. */gbrainHome?: string;+ /** The serve surface; default REGISTRATION_SURFACE, `null` = bare `serve` (never-narrow carry-over). */+ surface?: McpSurface | null;}export type CodexMcpRegistration = Omit<ClaudeMcpRegistration, 'scope'>;@@ -884,9 +888,11 @@ export type CodexMcpRegistration = Omit<ClaudeMcpRegistration, 'scope'>;* (binary first) — the dispatcher execs them; nothing here touches the* filesystem or the network. Shape per TARGETS['claude-code-2026-08'].*- * The serve argv pins `--surface full`: bootstrap's contract (put_page,- * get_page, timeline, …) needs the full op surface, and a pre-existing- * `mcp_surface: verbs` config row must not silently narrow the registration.+ * The serve argv comes from `stdioServeArgv`: `--surface starter` by default+ * (bootstrap's contract — put_page, get_page, add_timeline_entry, search,+ * query — is in it, and a pre-existing `mcp_surface: verbs` config row cannot+ * narrow a pinned registration); `surface` carries an existing entry's form+ * over on replacement or applies `--surface`.*/export function registerClaudeMcp(p: ClaudeMcpRegistration): string[][] {if (!isAbsolute(p.gbrainBin)) {@@ -899,15 +905,15 @@ export function registerClaudeMcp(p: ClaudeMcpRegistration): string[][] {'-e', `GBRAIN_SOURCE=${p.sourceId}`,];if (p.gbrainHome) argv.push('-e', `GBRAIN_HOME=${p.gbrainHome}`);- argv.push('--', p.gbrainBin, 'serve', '--surface', 'full');+ argv.push('--', ...stdioServeArgv(p.gbrainBin, p.surface));return [argv];}/*** `codex mcp add` argv for a LOCAL stdio serve (writes ~/.codex/config.toml* itself — no TOML writer needed in v1, see TARGETS['codex-2026-08']).- * Codex registrations are user-global; there is no scope flag.- * `--surface full` pins the full op surface (see registerClaudeMcp).+ * Codex registrations are user-global; there is no scope flag. The serve+ * argv comes from `stdioServeArgv` (see registerClaudeMcp).*/export function registerCodexMcp(p: CodexMcpRegistration): string[][] {if (!isAbsolute(p.gbrainBin)) {@@ -916,6 +922,6 @@ export function registerCodexMcp(p: CodexMcpRegistration): string[][] {const name = p.name ?? 'gbrain';const argv = ['codex', 'mcp', 'add', name, '--env', `GBRAIN_SOURCE=${p.sourceId}`];if (p.gbrainHome) argv.push('--env', `GBRAIN_HOME=${p.gbrainHome}`);- argv.push('--', p.gbrainBin, 'serve', '--surface', 'full');+ argv.push('--', ...stdioServeArgv(p.gbrainBin, p.surface));return [argv];}diff --git a/src/core/mcp-registration.ts b/src/core/mcp-registration.tsindex ea713cf2fa..2578b111b8 100644--- a/src/core/mcp-registration.ts+++ b/src/core/mcp-registration.ts@@ -1,15 +1,47 @@/**- * mcp-registration.ts — shared MCP-registration helpers for HTTP+bearer- * wiring (extracted from src/commands/connect.ts for #4043 [F5]: the harness- * lane in src/core/bootstrap/ needs these, and core must not import from- * commands). connect.ts re-exports everything here, so its public surface- * and tests are unchanged.+ * mcp-registration.ts — shared MCP-registration helpers: the one stdio+ * registration surface and serve argv every stdio registration gbrain writes+ * builds from (readiness, init's quickstart, `bootstrap hooks` for Claude+ * Code / Codex / opencode, the plugin generator), plus the HTTP+bearer+ * wiring helpers (extracted from src/commands/connect.ts for #4043 [F5]: the+ * harness lane in src/core/bootstrap/ needs these, and core must not import+ * from commands). connect.ts re-exports everything here, so its public+ * surface and tests are unchanged.*/import { shellQuote } from './shell-quote.ts';+import type { McpSurface } from '../mcp/surface.ts';export { shellQuote };+/**+ * The surface a new stdio registration pins. `starter` carries the seven+ * memory verbs plus the page reads/writes, timeline write, skills and agent+ * lane bootstrap's instructions name (`get_timeline` is the known gap the F6+ * hint and `request_tools` cover), and stays far below the full catalogue.+ */+export const REGISTRATION_SURFACE: McpSurface = 'starter';++/**+ * `<bin> serve --surface <surface>`. `null` renders a bare `<bin> serve`+ * (config/default resolution): never-narrow keeps an existing bare+ * registration bare when it replaces it.+ */+export function stdioServeArgv(bin: string, surface: McpSurface | null = REGISTRATION_SURFACE): string[] {+ return surface ? [bin, 'serve', '--surface', surface] : [bin, 'serve'];+}++/**+ * The surface form of an existing registration's command text (`mcp get`+ * output, an opencode `command` array joined): the pinned value, `null` for+ * a bare `serve`, `undefined` when no serve command is visible.+ */+export function registeredSurface(text: string): McpSurface | null | undefined {+ const pinned = /--surface[\s=]+["']?(verbs|starter|full)\b/.exec(text);+ if (pinned) return pinned[1] as McpSurface;+ return /\bserve\b/.test(text) ? null : undefined;+}+export const REDACTED = '***';export const NAME_RE = /^[a-z0-9][a-z0-9_-]*$/;diff --git a/src/core/readiness.ts b/src/core/readiness.tsindex 8af63b7742..6eee050294 100644--- a/src/core/readiness.ts+++ b/src/core/readiness.ts@@ -24,6 +24,8 @@* stops the owning serve named by `lock_owner`.*/import type { GBrainConfig } from './config.ts';+import type { McpSurface } from '../mcp/surface.ts';+import { REGISTRATION_SURFACE, stdioServeArgv } from './mcp-registration.ts';import { gbrainPath } from './config.ts';import type { BrainEngine } from './engine.ts';import { redactForTransport, type Action, type ActionInput, type Effect, type Transport } from './agent-output.ts';@@ -378,6 +380,8 @@ function lockOwnerFor(cfg: GBrainConfig): LockOwner | null {export type ReadinessHarness = 'claude-code' | 'codex' | 'opencode';export interface HarnessWiringInput {transport: Transport;+ /** The surface the registration pins; default REGISTRATION_SURFACE (`gbrain init --surface` overrides). */+ surface?: McpSurface;/** Harnesses detected on this machine (config plane: from process-scoped agent markers). */harnesses: readonly ReadinessHarness[];lockOwner: LockOwner | null;@@ -393,14 +397,21 @@ const HARNESS_DESTINATION: Record<ReadinessHarness, string> = {};const MEMORY_VERBS_INSTALL = 'docs/protocol/MEMORY_VERBS_v1.md#install-the-4-command-quickstart';-function stdioRegistration(h: ReadinessHarness, bin: string): Action {- const argv = h === 'claude-code' ? ['claude', 'mcp', 'add', 'gbrain', '--', bin, 'serve', '--surface', 'verbs']- : h === 'codex' ? ['codex', 'mcp', 'add', 'gbrain', '--', bin, 'serve', '--surface', 'verbs']- : ['gbrain', 'bootstrap', 'hooks', '--harness', 'opencode', '--no-hooks'];+const SURFACE_GLOSS: Record<McpSurface, string> = {+ verbs: 'the seven memory verbs',+ starter: 'the seven memory verbs plus page, timeline-write, skill and agent tools',+ full: 'every operation',+};++function stdioRegistration(h: ReadinessHarness, bin: string, surface: McpSurface = REGISTRATION_SURFACE): Action {+ const serve = stdioServeArgv(bin, surface);+ const argv = h === 'claude-code' ? ['claude', 'mcp', 'add', 'gbrain', '--', ...serve]+ : h === 'codex' ? ['codex', 'mcp', 'add', 'gbrain', '--', ...serve]+ : ['gbrain', 'bootstrap', 'hooks', '--harness', 'opencode', '--no-hooks', ...(surface === REGISTRATION_SURFACE ? [] : ['--surface', surface])];const hooks = h === 'opencode' ? ' No lifecycle hooks are installed (--no-hooks); it must run inside an initialized agent workspace.' : ' No hooks, tool pre-approvals or tokens are added.';return {argv, consent: ['persistent_install'], actor: 'agent', requires_exclusive: false,- why: `Registers gbrain as a stdio MCP server (${bin} serve --surface verbs, the seven memory verbs) in ${HARNESS_DESTINATION[h]}, so new ${HARNESS_LABEL[h]} sessions get memory tools.${hooks}`,+ why: `Registers gbrain as a stdio MCP server (${serve.join(' ')}, ${SURFACE_GLOSS[surface]}) in ${HARNESS_DESTINATION[h]}, so new ${HARNESS_LABEL[h]} sessions get memory tools.${hooks}`,user_message: `I'd like to add gbrain's memory tools to ${HARNESS_LABEL[h]} by writing one MCP server entry to ${HARNESS_DESTINATION[h]}. OK?`,verify: VERIFY('harness_wiring'), docs: MEMORY_VERBS_INSTALL,};@@ -426,7 +437,7 @@ export function harnessWiringEntry(input: HarnessWiringInput): ReadinessEntry {if (harnesses.length === 0) {return { ...base, state: 'missing', reason: 'no_harness_detected', why: 'No agent harness was detected.',fix: { consent: ['persistent_install'], actor: 'user', requires_exclusive: false, docs: MEMORY_VERBS_INSTALL,- why: 'Register `<absolute path to gbrain> serve --surface verbs` as a stdio MCP server in your agent host; the install section lists the exact command per harness (Claude Code, Codex, Grok Build, opencode, OpenClaw).',+ why: `Register \`<absolute path to gbrain> serve --surface ${input.surface ?? REGISTRATION_SURFACE}\` as a stdio MCP server in your agent host; the install section lists the exact command per harness (Claude Code, Codex, Grok Build, opencode, OpenClaw).`,user_message: 'Which agent app should get gbrain memory? The install guide has a one-line command for each.' } };}if (lockOwner?.transport === 'http') {@@ -444,7 +455,7 @@ export function harnessWiringEntry(input: HarnessWiringInput): ReadinessEntry {fix: { consent: ['persistent_install'], actor: 'user', requires_exclusive: false, docs: 'INSTALL_FOR_AGENTS.md',why: 'Install gbrain globally (`bun install -g github:garrytan/gbrain`) so `gbrain` resolves to an absolute path, then re-run readiness.' } };}- return { ...base, state: 'unknown', reason: 'registration_unverified', why: `${HARNESS_LABEL[h]} is the active harness; its gbrain registration has not been verified from this process.`, fix: stdioRegistration(h, input.gbrainBin) };+ return { ...base, state: 'unknown', reason: 'registration_unverified', why: `${HARNESS_LABEL[h]} is the active harness; its gbrain registration has not been verified from this process.`, fix: stdioRegistration(h, input.gbrainBin, input.surface) };}const MARKER_HARNESS: Record<string, ReadinessHarness> = {@@ -453,12 +464,12 @@ const MARKER_HARNESS: Record<string, ReadinessHarness> = {let cachedBin: { value: string | null } | null = null;-function harnessConfigEntry(transport: Transport, lockOwner: LockOwner | null): ReadinessEntry {+function harnessConfigEntry(transport: Transport, lockOwner: LockOwner | null, surface?: McpSurface): ReadinessEntry {if (transport !== 'cli') return harnessWiringEntry({ transport, harnesses: [], lockOwner, gbrainBin: null });const marker = agentProcessMarker();const harness = marker ? MARKER_HARNESS[marker] : undefined;cachedBin ??= { value: resolveGbrainBin() };- return harnessWiringEntry({ transport, harnesses: harness ? [harness] : [], lockOwner, gbrainBin: cachedBin.value });+ return harnessWiringEntry({ transport, harnesses: harness ? [harness] : [], lockOwner, gbrainBin: cachedBin.value, ...(surface ? { surface } : {}) });}// ── config plane ───────────────────────────────────────────────────────────@@ -477,18 +488,19 @@ export function readinessHttpView(entries: readonly ReadinessEntry[]): Readinessreturn redactForTransport(entries.filter(e => e.http_visible), 'http');}-export function configReadiness(cfg: GBrainConfig, ctx: { transport: Transport }): ConfigReadiness {- const memo = configMemo.get(cfg)?.get(ctx.transport);+export function configReadiness(cfg: GBrainConfig, ctx: { transport: Transport; surface?: McpSurface }): ConfigReadiness {+ const memo = ctx.surface ? undefined : configMemo.get(cfg)?.get(ctx.transport);if (memo) return memo;if (!lockMemo.has(cfg)) lockMemo.set(cfg, lockOwnerFor(cfg));const lockOwner = lockMemo.get(cfg) ?? null;const entries: ReadinessEntry[] = [embeddingsEntry(cfg), chatEntry(cfg), writebackEntry(cfg), toolSurfaceEntry(cfg)];const sync = syncConfigEntry(cfg);if (sync) entries.push(sync);- entries.push(harnessConfigEntry(ctx.transport, lockOwner));+ entries.push(harnessConfigEntry(ctx.transport, lockOwner, ctx.surface));const result: ConfigReadiness = ctx.transport === 'http'? { entries: readinessHttpView(entries), lock_owner: null }: { entries: entries.map(e => (e.fix ? { ...e, fix: exclusiveFix(e.fix, lockOwner) } : e)), lock_owner: lockOwner };+ if (ctx.surface) return result;const byTransport = configMemo.get(cfg) ?? new Map<Transport, ConfigReadiness>();byTransport.set(ctx.transport, result);configMemo.set(cfg, byTransport);diff --git a/test/bootstrap-codex-door.test.ts b/test/bootstrap-codex-door.test.tsindex 2f4eb7b4bb..8ea425a312 100644--- a/test/bootstrap-codex-door.test.ts+++ b/test/bootstrap-codex-door.test.ts@@ -8,8 +8,8 @@* 1. The RENDERED AGENTS.md carries Gate 3 ("Entity lookup (brain first)") in* full — search-the-brain-before-answering with the actual brain tools —* so a Codex agent with no hooks still pulls context every turn.- * 2. `registerCodexMcp` argv pins `serve --surface full` (bootstrap needs the- * whole op surface, not a narrowed `verbs`) and binds GBRAIN_SOURCE so a+ * 2. `registerCodexMcp` argv pins `serve --surface starter` (bootstrap's page,+ * timeline and verb tools, not a narrowed `verbs`) and binds GBRAIN_SOURCE so a* GUI-spawned serve (which inherits no shell env) writes to the workspace* source [G1, CX-P1.4].*/@@ -81,10 +81,10 @@ describe('Codex door — rendered AGENTS.md pull protocol (Gate 3)', () => {});});-describe('Codex door — registerCodexMcp argv (--surface full + GBRAIN_SOURCE)', () => {+describe('Codex door — registerCodexMcp argv (--surface starter + GBRAIN_SOURCE)', () => {const BIN = '/opt/gbrain/bin/gbrain';- test('user-global stdio registration binds the source and pins the full op surface', () => {+ test('user-global stdio registration binds the source and pins the starter surface', () => {const argvs = registerCodexMcp({ gbrainBin: BIN, sourceId: 'workspace' });expect(argvs.length).toBe(1);const argv = argvs[0]!;@@ -92,12 +92,12 @@ describe('Codex door — registerCodexMcp argv (--surface full + GBRAIN_SOURCE)'expect(argv).toEqual(['codex', 'mcp', 'add', 'gbrain','--env', 'GBRAIN_SOURCE=workspace',- '--', BIN, 'serve', '--surface', 'full',+ '--', BIN, 'serve', '--surface', 'starter',]);// The two contracts, asserted independently so a reshuffle can't hide a drop.const joined = argv.join(' ');expect(joined).toContain('--env GBRAIN_SOURCE=workspace');- expect(joined).toContain('serve --surface full');+ expect(joined).toContain('serve --surface starter');// `serve` argv must NOT narrow to the verbs surface.expect(joined).not.toContain('--surface verbs');});@@ -108,7 +108,7 @@ describe('Codex door — registerCodexMcp argv (--surface full + GBRAIN_SOURCE)'// GBRAIN_HOME is a second --env, GBRAIN_SOURCE still present, surface intact.expect(argv.filter((a) => a === '--env').length).toBe(2);expect(argv).toContain('GBRAIN_SOURCE=workspace');- expect(argv.join(' ')).toContain('serve --surface full');+ expect(argv.join(' ')).toContain('serve --surface starter');});test('a non-absolute gbrain binary is refused (GUI hosts inherit no PATH) [CX-P1.4]', () => {diff --git a/test/bootstrap-dispatcher.serial.test.ts b/test/bootstrap-dispatcher.serial.test.tsindex 7d91500c82..dc20856019 100644--- a/test/bootstrap-dispatcher.serial.test.ts+++ b/test/bootstrap-dispatcher.serial.test.ts@@ -638,6 +638,30 @@ describe('MCP registration verification [FIX7]', () => {expect(adds).toBe(1); // the failed remove halts the flow before any re-add}, 30_000);+ const serveTail = (argv: string[]) => argv.slice(argv.indexOf('--') + 2);+ const adds = (calls: string[][]) => calls.filter((c) => c[1] === 'mcp' && c[2] === 'add');++ test('a fresh registration pins the registration surface (starter)', async () => {+ const { runner, calls } = mcpHost({ initialReg: null });+ expect((await runHooks(runner)).result).toBe(0);+ expect(serveTail(adds(calls)[0])).toEqual(['serve', '--surface', 'starter']);+ }, 30_000);++ test('never narrow: a replaced entry keeps its pinned surface, a bare serve stays bare, --surface wins', async () => {+ const pinned = mcpHost({ initialReg: FOREIGN });+ expect((await runHooks(pinned.runner)).result).toBe(0);+ expect(serveTail(adds(pinned.calls)[1])).toEqual(['serve', '--surface', 'full']);++ const bare = mcpHost({ initialReg: `gbrain:\n command: /somewhere/else/gbrain serve\n env: GBRAIN_SOURCE=other-workspace` });+ expect((await runHooks(bare.runner)).result).toBe(0);+ expect(serveTail(adds(bare.calls)[1])).toEqual(['serve']);++ const explicit = mcpHost({ initialReg: FOREIGN });+ const r = await capture(() => runBootstrap(['hooks', '--workspace', ws, '--harness', 'claude-code', '--gbrain-bin', gbrainBin, '--surface', 'verbs'], { runner: explicit.runner }));+ expect(r.result).toBe(0);+ expect(adds(explicit.calls).map(serveTail)).toEqual([['serve', '--surface', 'verbs'], ['serve', '--surface', 'verbs']]);+ }, 60_000);+test('host without `mcp get` → inconclusive, kept with a note (never a false bless)', async () => {const { runner } = mcpHost({ initialReg: OURS, getSupported: false });const r = await runHooks(runner);diff --git a/test/bootstrap-hooks-writers.test.ts b/test/bootstrap-hooks-writers.test.tsindex 8fb97e8ab7..b0090163ed 100644--- a/test/bootstrap-hooks-writers.test.ts+++ b/test/bootstrap-hooks-writers.test.ts@@ -256,10 +256,10 @@ describe('removeClaudeHooks [G5]', () => {});describe('MCP registration argv builders [G1, CX-P1.4]', () => {- test('registerClaudeMcp: stdio shape with scope + source env; serve pinned to --surface full', () => {+ test('registerClaudeMcp: stdio shape with scope + source env; serve pinned to --surface starter (REGISTRATION_SURFACE)', () => {const cmds = registerClaudeMcp({ gbrainBin: BIN, scope: 'project', sourceId: 'workspace' });expect(cmds).toEqual([- ['claude', 'mcp', 'add', 'gbrain', '--scope', 'project', '-e', 'GBRAIN_SOURCE=workspace', '--', BIN, 'serve', '--surface', 'full'],+ ['claude', 'mcp', 'add', 'gbrain', '--scope', 'project', '-e', 'GBRAIN_SOURCE=workspace', '--', BIN, 'serve', '--surface', 'starter'],]);});@@ -269,14 +269,14 @@ describe('MCP registration argv builders [G1, CX-P1.4]', () => {});expect(cmds[0]).toEqual(['claude', 'mcp', 'add', 'mybrain', '--scope', 'user',- '-e', 'GBRAIN_SOURCE=s1', '-e', 'GBRAIN_HOME=/ws', '--', BIN, 'serve', '--surface', 'full',+ '-e', 'GBRAIN_SOURCE=s1', '-e', 'GBRAIN_HOME=/ws', '--', BIN, 'serve', '--surface', 'starter',]);});- test('registerCodexMcp: --env shape, no scope flag; serve pinned to --surface full', () => {+ test('registerCodexMcp: --env shape, no scope flag; serve pinned to --surface starter (REGISTRATION_SURFACE)', () => {const cmds = registerCodexMcp({ gbrainBin: BIN, sourceId: 'workspace', gbrainHome: '/ws' });expect(cmds).toEqual([- ['codex', 'mcp', 'add', 'gbrain', '--env', 'GBRAIN_SOURCE=workspace', '--env', 'GBRAIN_HOME=/ws', '--', BIN, 'serve', '--surface', 'full'],+ ['codex', 'mcp', 'add', 'gbrain', '--env', 'GBRAIN_SOURCE=workspace', '--env', 'GBRAIN_HOME=/ws', '--', BIN, 'serve', '--surface', 'starter'],]);});diff --git a/test/bootstrap-opencode-door.serial.test.ts b/test/bootstrap-opencode-door.serial.test.tsindex e5e61c11c4..087f307628 100644--- a/test/bootstrap-opencode-door.serial.test.ts+++ b/test/bootstrap-opencode-door.serial.test.ts@@ -188,8 +188,7 @@ describe('opencode workspace lane — default scope is USER-GLOBAL', () => {};expect(entry.type).toBe('local');expect(entry.command[0]).toBe(FAKE_BIN); // user scope: absolute path- expect(entry.command).toContain('--surface');- expect(entry.command).toContain('full');+ expect(entry.command.slice(1)).toEqual(['serve', '--surface', 'starter']);expect(entry.environment.GBRAIN_SOURCE).toBeDefined();expect(entry.enabled).toBe(true);@@ -323,7 +322,7 @@ describe('opencode workspace lane — explicit project opt-in', () => {const cfgPath = join(ws, 'opencode.json');const parsed = parseOpencodeConfig(readFileSync(cfgPath, 'utf8'), cfgPath);const entry = (parsed.mcp as Record<string, unknown>).gbrain as { command: string[] };- expect(entry.command[0]).toBe('gbrain'); // committed-candidate file: PATH-resolved, never absolute+ expect(entry.command).toEqual(['gbrain', 'serve', '--surface', 'starter']); // committed-candidate file: PATH-resolved, never absoluteexpect(r.out).toContain('project (explicit opt-in)');expect(r.err).toContain('SHARING WARNING');expect(r.err).toContain('"enabled": false');@@ -369,6 +368,28 @@ describe('opencode workspace lane — explicit project opt-in', () => {});});+describe('opencode never-narrow: a rewritten entry keeps its surface form', () => {+ async function rerunWith(command: string[], extra: string[] = []): Promise<string[]> {+ const ws = await readyWs();+ const cfgPath = opencodeGlobalConfigPath();+ const first = await capture(() => runBootstrap(['hooks', '--workspace', ws, '--harness', 'opencode', '--gbrain-bin', FAKE_BIN], { runner: makeRunner().runner, probeSpawn: makeProbeSpawn().spawn }));+ expect(first.result).toBe(0);+ const parsed = parseOpencodeConfig(readFileSync(cfgPath, 'utf8'), cfgPath) as { mcp: Record<string, { command: string[] }> };+ parsed.mcp.gbrain.command = command;+ writeFileSync(cfgPath, JSON.stringify(parsed, null, 2));+ const again = await capture(() => runBootstrap(['hooks', '--workspace', ws, '--harness', 'opencode', '--gbrain-bin', FAKE_BIN, ...extra], { runner: makeRunner().runner, probeSpawn: makeProbeSpawn().spawn }));+ expect(again.result).toBe(0);+ rmSync(ws, { recursive: true, force: true });+ return ((parseOpencodeConfig(readFileSync(cfgPath, 'utf8'), cfgPath).mcp as Record<string, { command: string[] }>).gbrain).command;+ }++ test('a pinned --surface full stays full, a bare serve stays bare, an explicit --surface wins', async () => {+ expect(await rerunWith([FAKE_BIN, 'serve', '--surface', 'full'])).toEqual([FAKE_BIN, 'serve', '--surface', 'full']);+ expect(await rerunWith([FAKE_BIN, 'serve'])).toEqual([FAKE_BIN, 'serve']);+ expect(await rerunWith([FAKE_BIN, 'serve', '--surface', 'full'], ['--surface', 'verbs'])).toEqual([FAKE_BIN, 'serve', '--surface', 'verbs']);+ }, 60_000);+});+describe('opencode two-filename WRITE reconcile (sibling global file)', () => {test('a gbrain LOCAL entry in the SIBLING global file is cleaned when the write lands in the other (note printed)', async () => {const ws = await readyWs();diff --git a/test/mcp-registration.test.ts b/test/mcp-registration.test.tsnew file mode 100644index 0000000000..60b5e0d79c--- /dev/null+++ b/test/mcp-registration.test.ts@@ -0,0 +1,95 @@+/**+ * One surface for every stdio registration gbrain writes+ * (src/core/mcp-registration.ts): readiness (Claude Code, Codex, opencode),+ * init's quickstart line, `registerClaudeMcp` / `registerCodexMcp`, and the+ * plugin generator all build from REGISTRATION_SURFACE through+ * `stdioServeArgv`; `registeredSurface` reads an existing entry's form for+ * never-narrow. The opencode user/project writer and the exec-lane+ * replacement are driven end to end in bootstrap-opencode-door.serial and+ * bootstrap-dispatcher.serial.+ */+import { describe, expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { REGISTRATION_SURFACE, registeredSurface, stdioServeArgv } from '../src/core/mcp-registration.ts';+import { harnessWiringEntry } from '../src/core/readiness.ts';+import { registerClaudeMcp, registerCodexMcp } from '../src/core/bootstrap/hooks.ts';++const BIN = '/opt/example/bin/gbrain';+const ROOT = resolve(import.meta.dir, '..');+const wiring = (h: 'claude-code' | 'codex' | 'opencode', surface?: 'verbs' | 'starter' | 'full') =>+ harnessWiringEntry({ transport: 'cli', harnesses: [h], lockOwner: null, gbrainBin: BIN, ...(surface ? { surface } : {}) }).fix;++describe('REGISTRATION_SURFACE and stdioServeArgv', () => {+ test('new registrations pin starter; null renders a bare serve', () => {+ expect(REGISTRATION_SURFACE).toBe('starter');+ expect(stdioServeArgv(BIN)).toEqual([BIN, 'serve', '--surface', 'starter']);+ expect(stdioServeArgv(BIN, 'full')).toEqual([BIN, 'serve', '--surface', 'full']);+ expect(stdioServeArgv(BIN, null)).toEqual([BIN, 'serve']);+ });++ test('registeredSurface reads a pinned value, a bare serve, or nothing', () => {+ expect(registeredSurface(`gbrain:\n Command: ${BIN}\n Args: serve --surface full\n`)).toBe('full');+ expect(registeredSurface(`${BIN} serve --surface=verbs --source-guard`)).toBe('verbs');+ expect(registeredSurface(`gbrain:\n Command: ${BIN}\n Args: serve\n`)).toBeNull();+ expect(registeredSurface('gbrain: http https://brain.example/mcp')).toBeUndefined();+ });+});++describe('every stdio registration path builds from REGISTRATION_SURFACE', () => {+ test('readiness harness_wiring: Claude Code and Codex pin the surface; opencode runs bootstrap hooks', () => {+ expect(wiring('claude-code')?.argv).toEqual(['claude', 'mcp', 'add', 'gbrain', '--', ...stdioServeArgv(BIN)]);+ expect(wiring('codex')?.argv).toEqual(['codex', 'mcp', 'add', 'gbrain', '--', ...stdioServeArgv(BIN)]);+ expect(wiring('opencode')?.argv).toEqual(['gbrain', 'bootstrap', 'hooks', '--harness', 'opencode', '--no-hooks']);+ expect(wiring('claude-code')?.why).toContain(`${BIN} serve --surface starter`);+ });++ test('init --surface reaches the readiness fix (the quickstart line and the first-run harness decision read it)', () => {+ expect(wiring('claude-code', 'full')?.argv).toEqual(['claude', 'mcp', 'add', 'gbrain', '--', BIN, 'serve', '--surface', 'full']);+ expect(wiring('opencode', 'verbs')?.argv).toEqual(['gbrain', 'bootstrap', 'hooks', '--harness', 'opencode', '--no-hooks', '--surface', 'verbs']);+ const missing = harnessWiringEntry({ transport: 'cli', harnesses: [], lockOwner: null, gbrainBin: BIN }).fix;+ expect(missing?.why).toContain('serve --surface starter');+ });++ test('bootstrap hooks: registerClaudeMcp and registerCodexMcp default to the surface and carry an existing form', () => {+ const claude = registerClaudeMcp({ gbrainBin: BIN, scope: 'user', sourceId: 'workspace' })[0];+ const codex = registerCodexMcp({ gbrainBin: BIN, sourceId: 'workspace' })[0];+ expect(claude.slice(claude.indexOf('--') + 1)).toEqual(stdioServeArgv(BIN));+ expect(codex.slice(codex.indexOf('--') + 1)).toEqual(stdioServeArgv(BIN));+ expect(registerClaudeMcp({ gbrainBin: BIN, scope: 'user', sourceId: 'w', surface: 'full' })[0].slice(-3)).toEqual(['serve', '--surface', 'full']);+ expect(registerCodexMcp({ gbrainBin: BIN, sourceId: 'w', surface: null })[0].slice(-2)).toEqual([BIN, 'serve']);+ });++ test('the plugin generator states the registration surface and refuses a manifest pinned elsewhere', () => {+ const out = mkdtempSync(join(tmpdir(), 'gb-reg-plugin-'));+ try {+ const ok = spawnSync('bun', ['run', join(ROOT, 'scripts/generate-plugin-tree.ts'), '--out', join(out, 'plugin')], { encoding: 'utf8', timeout: 60_000 });+ expect(ok.status, ok.stderr).toBe(0);+ expect(readFileSync(join(out, 'plugin', 'README.md'), 'utf8')).toContain(`gbrain serve --surface ${REGISTRATION_SURFACE}`);+ for (const file of ['.codex-plugin/mcp.json', '.claude-plugin/plugin.json']) {+ const args = (JSON.parse(readFileSync(join(ROOT, file), 'utf8')) as { mcpServers: { gbrain: { args: string[] } } }).mcpServers.gbrain.args;+ expect(args[args.indexOf('--surface') + 1]).toBe(REGISTRATION_SURFACE);+ }++ const root = join(out, 'fixture');+ mkdirSync(join(root, 'skills', 'alpha'), { recursive: true });+ mkdirSync(join(root, 'skills', 'conventions'), { recursive: true });+ mkdirSync(join(root, '.codex-plugin'), { recursive: true });+ writeFileSync(join(root, 'VERSION'), '0.0.0.0\n');+ writeFileSync(join(root, 'openclaw.plugin.json'), JSON.stringify({ name: 'fixture', version: '0.0.0.0', skills: ['skills/alpha'], shared_deps: [] }));+ writeFileSync(join(root, 'skills', 'alpha', 'SKILL.md'), '---\nname: alpha\ndescription: fixture skill\n---\n# alpha\n');+ writeFileSync(join(root, 'skills', 'manifest.json'), JSON.stringify({ skills: [{ name: 'alpha' }] }));+ writeFileSync(join(root, 'skills', 'plugin-lanes.json'), JSON.stringify({ starter_policy: 'x', additions: {}, base_exclusions: {}, not_added: {}, starter_gaps: {} }));+ writeFileSync(join(root, '.codex-plugin', 'mcp.json'), JSON.stringify({ mcpServers: { gbrain: { command: 'x', args: ['serve', '--surface', 'full'] } } }));+ const bad = spawnSync('bun', ['run', join(ROOT, 'scripts/generate-plugin-tree.ts'), '--out', join(root, 'out')], {+ encoding: 'utf8', timeout: 60_000, env: { ...process.env, GBRAIN_PLUGIN_TREE_ROOT: root },+ });+ expect(bad.status).toBe(1);+ expect(bad.stderr).toContain(`.codex-plugin/mcp.json pins --surface full; plugin lanes serve the registration surface '${REGISTRATION_SURFACE}'`);+ } finally {+ rmSync(out, { recursive: true, force: true });+ }+ }, 120_000);+});diff --git a/test/readiness.test.ts b/test/readiness.test.tsindex f9e6415c53..1367929d9d 100644--- a/test/readiness.test.ts+++ b/test/readiness.test.ts@@ -168,13 +168,13 @@ describe('harness_wiring by state', () => {const BIN = '/opt/gbrain/bin/gbrain';const owner = (transport: 'stdio' | 'http', is_self = false): LockOwner => ({ pid: 4242, transport, is_self });- test('one harness, no serve: harness-native stdio registration with the absolute binary and --surface verbs', () => {+ test('one harness, no serve: harness-native stdio registration with the absolute binary and --surface starter', () => {const claude = harnessWiringEntry({ transport: 'cli', harnesses: ['claude-code'], lockOwner: null, gbrainBin: BIN });- expect(claude.fix?.argv).toEqual(['claude', 'mcp', 'add', 'gbrain', '--', BIN, 'serve', '--surface', 'verbs']);+ expect(claude.fix?.argv).toEqual(['claude', 'mcp', 'add', 'gbrain', '--', BIN, 'serve', '--surface', 'starter']);expect(claude.fix?.consent).toEqual(['persistent_install']);expect(claude.fix?.why).toContain('~/.claude.json');expect(harnessWiringEntry({ transport: 'cli', harnesses: ['codex'], lockOwner: null, gbrainBin: BIN }).fix?.argv)- .toEqual(['codex', 'mcp', 'add', 'gbrain', '--', BIN, 'serve', '--surface', 'verbs']);+ .toEqual(['codex', 'mcp', 'add', 'gbrain', '--', BIN, 'serve', '--surface', 'starter']);expect(harnessWiringEntry({ transport: 'cli', harnesses: ['opencode'], lockOwner: null, gbrainBin: BIN }).fix?.argv).toEqual(['gbrain', 'bootstrap', 'hooks', '--harness', 'opencode', '--no-hooks']);});