Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(agents): one 'Which gbrain call for which lookup' table in brain-first.md, copied into AGENTS.md, INSTALL_FOR_AGENTS.md, RESOLVER.md and the bootstrap AGENTS template by scripts/build-lookup-table.ts (regen:all); every row run on a scratch brain (#7191)
garrytanb79e6c217e21
diff --git a/AGENTS.md b/AGENTS.mdindex d878104033..9dfb26ca0e 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -57,13 +57,31 @@ Bun blocks gbrain's postinstall on `bun install -g` (`Blocked 1 postinstall`); a## Memory operating protocol-**Retrieval: gbrain first.** For anything in the brain, run `gbrain search` (names,-codes, phrases) or `gbrain query` (questions), then `gbrain get <slug>` on a hit.-Don't grep, cat or SQL the brain checkout first. Filters agents miss:-`--types '["meeting"]'`, `--match keyword` (every matching page), `--since`/`--until`-on `query`, `--source <id>`, `--limit`, `--json`; `gbrain backlinks <slug>` and-`gbrain timeline <slug>` for links and dated events. Copyable examples:-[brain-first](skills/conventions/brain-first.md#retrieval-gbrain-first).+**Which gbrain call for which lookup.** Details and caveats: [brain-first](skills/conventions/brain-first.md#which-gbrain-call-for-which-lookup).++<!-- BEGIN GENERATED lookup-table (copied from skills/conventions/brain-first.md by bun run regen:all) -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END GENERATED lookup-table -->Recall relevant saved context before answering. Save explicit requests to remember with provenance; confirm corrections against the stored record. Automatic capture requires opt-in. Withdrawal (`forget`) removes a fact from active memory; history, source material, and private backups may remain. Never promise physical erasure. Verify changes with actual GBrain calls and distinguish a local test from a new-conversation test in the harness.diff --git a/INSTALL_FOR_AGENTS.md b/INSTALL_FOR_AGENTS.mdindex 897da9257a..bcf386ec4a 100644--- a/INSTALL_FOR_AGENTS.md+++ b/INSTALL_FOR_AGENTS.md@@ -341,10 +341,32 @@ Only after enabling the selected embedding provider, run `gbrain embed --stale`.Use `gbrain query` for expanded retrieval only when its provider use is intended;`--no-expand` opts out of expansion independently of the mode.-Once imported, retrieve through gbrain rather than the files: search, then-`gbrain get <slug>`. Filters (`--types`, `--match keyword`, `query --since/--until`,-`--source`, `--json`) are in-[Retrieval: gbrain first](skills/conventions/brain-first.md#retrieval-gbrain-first).+Once imported, retrieve through gbrain rather than the files+([brain-first](skills/conventions/brain-first.md#which-gbrain-call-for-which-lookup)):++<!-- BEGIN GENERATED lookup-table (copied from skills/conventions/brain-first.md by bun run regen:all) -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END GENERATED lookup-table -->## Step 4.5: Wire the Knowledge Graphdiff --git a/llms-full.txt b/llms-full.txtindex 085c0d3850..d18685c61f 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -1807,13 +1807,31 @@ Bun blocks gbrain's postinstall on `bun install -g` (`Blocked 1 postinstall`); a## Memory operating protocol-**Retrieval: gbrain first.** For anything in the brain, run `gbrain search` (names,-codes, phrases) or `gbrain query` (questions), then `gbrain get <slug>` on a hit.-Don't grep, cat or SQL the brain checkout first. Filters agents miss:-`--types '["meeting"]'`, `--match keyword` (every matching page), `--since`/`--until`-on `query`, `--source <id>`, `--limit`, `--json`; `gbrain backlinks <slug>` and-`gbrain timeline <slug>` for links and dated events. Copyable examples:-[brain-first](skills/conventions/brain-first.md#retrieval-gbrain-first).+**Which gbrain call for which lookup.** Details and caveats: [brain-first](skills/conventions/brain-first.md#which-gbrain-call-for-which-lookup).++<!-- BEGIN GENERATED lookup-table (copied from skills/conventions/brain-first.md by bun run regen:all) -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END GENERATED lookup-table -->Recall relevant saved context before answering. Save explicit requests to remember with provenance; confirm corrections against the stored record. Automatic capture requires opt-in. Withdrawal (`forget`) removes a fact from active memory; history, source material, and private backups may remain. Never promise physical erasure. Verify changes with actual GBrain calls and distinguish a local test from a new-conversation test in the harness.@@ -2962,10 +2980,32 @@ Only after enabling the selected embedding provider, run `gbrain embed --stale`.Use `gbrain query` for expanded retrieval only when its provider use is intended;`--no-expand` opts out of expansion independently of the mode.-Once imported, retrieve through gbrain rather than the files: search, then-`gbrain get <slug>`. Filters (`--types`, `--match keyword`, `query --since/--until`,-`--source`, `--json`) are in-[Retrieval: gbrain first](skills/conventions/brain-first.md#retrieval-gbrain-first).+Once imported, retrieve through gbrain rather than the files+([brain-first](skills/conventions/brain-first.md#which-gbrain-call-for-which-lookup)):++<!-- BEGIN GENERATED lookup-table (copied from skills/conventions/brain-first.md by bun run regen:all) -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END GENERATED lookup-table -->## Step 4.5: Wire the Knowledge Graph@@ -4647,6 +4687,32 @@ wins; fix the row.[agent operator protocol](./conventions/agent-operator-protocol.md). Read theerror's `code` (fall back to `error`), follow `fix.next`, then run `fix.verify`.+## Which gbrain call for which lookup++<!-- BEGIN GENERATED lookup-table (copied from skills/conventions/brain-first.md by bun run regen:all) -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END GENERATED lookup-table -->+## Memory defaultsPreserve the existing agent's identity and instructions. Ordinary setup addsdiff --git a/plugin-variants/gbrain-coding/skills/brain-ops/SKILL.md b/plugin-variants/gbrain-coding/skills/brain-ops/SKILL.mdindex ad98da1d90..55b34d62bc 100644--- a/plugin-variants/gbrain-coding/skills/brain-ops/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/brain-ops/SKILL.md@@ -134,7 +134,7 @@ Before using ANY external API to research a person, company, or topic:The brain almost always has something. External APIs fill gaps, not start from scratch.Search gbrain before reading, grepping or querying brain files directly; filters(`--types`, `--match keyword`, `query --since/--until`, `--source`, `--json`) are-in the brain-first convention's "Retrieval: gbrain first" block.+in the brain-first convention's "Which gbrain call for which lookup" table.**⚠️ NEVER scope/count a corpus with shallow `ls` — query gbrain or `find`.** Federated sources often carry MULTIPLE coexisting directory conventions — a flat legacy layer AND a date-nested `meetings/YYYY/MM/` layer. A non-recursive `ls dir/*.md` sees only one and undercounts massively. Real example: a shallow `ls` of one source's `meetings/` counted 132 files, almost all the user's, and concluded that WAS the corpus — missing thousands of transcripts nested under `meetings/YYYY/MM/`. To count/scope a brain corpus:- **Best:** `gbrain sources list` (shows per-source indexed page counts) + `gbrain query`. gbrain indexes ALL federated sources correctly; trust its index, not the filesystem.diff --git a/plugin-variants/gbrain-coding/skills/conventions/brain-first.md b/plugin-variants/gbrain-coding/skills/conventions/brain-first.mdindex c73679a4fe..b1acc6dda9 100644--- a/plugin-variants/gbrain-coding/skills/conventions/brain-first.md+++ b/plugin-variants/gbrain-coding/skills/conventions/brain-first.md@@ -5,44 +5,31 @@Sub-agents and fresh sessions inherit gbrain tools but not the knowledge ofwhen and how to use them. This file is that knowledge.-## Retrieval: gbrain first--For anything in the brain, search gbrain, then read the page a hit names. Don't-`grep`, `rg` or `cat` the brain checkout, or run SQL over pages and-frontmatter, before gbrain: gbrain reads the index across sources, ranks results,-filters by type, date and source, and returns the slug to read next. Use the-files only when gbrain is unreachable or for an edit not yet synced.--Prefer the gbrain MCP tools (`search`, `query`, `get_page`, `recall`) when your-harness has the server connected: it stays connected, so each call skips the-CLI's startup, which costs seconds per call on a large pooled Postgres brain.-The CLI commands below take the same filters.--```bash-gbrain search "Acme Example" # names, codes, exact phrases-gbrain search '"ZEBRA-42" OR "inventory sync"' --match keyword # every page with any term (instead of grep)-gbrain query "why did the launch move" # questions and concepts-gbrain search "launch" --types '["meeting","person"]' # only these page types-gbrain query "launch" --since 2026-09-01 --until 2026-09-30 # date window (also --since 30d)-gbrain search "launch" --source source-a --limit 5 --json 2>/dev/null | jq -r '.[].slug'-gbrain get companies/acme-example # read the page a hit points to-gbrain recall "Alice Example" # facts saved with remember-gbrain backlinks companies/acme-example --type meeting # pages that link here (instead of grepping a slug)-gbrain timeline companies/acme-example --since 2026-10-01 # dated events on one page-gbrain list --type meeting --limit 50 # enumerate by type or --tag (instead of SQL)-gbrain find 'people/*acme*' # glob, slug prefix or name (instead of ls/find)-gbrain stats --by source,type --since 30d # page counts per source and type (instead of grep -c/SQL)-```--- `--types` takes a JSON array. `--since`/`--until` are `query` flags- (YYYY-MM-DD or 7d/2w/1y) and match each page's effective date: its- frontmatter date, else when it was imported.-- Keyword search matches words, not slugs: search `"Acme Example"`, and use- `backlinks` to find pages linking to `companies/acme-example`.-- Without `--source`, a search reads the resolved source (a notice names it- when it routes); `--source __all__` searches every source.-- Notices and `[AGENT]` blocks go to stderr, so `--json` stdout is clean JSON.- Read a degraded notice before concluding the brain has nothing.+## Which gbrain call for which lookup++<!-- BEGIN lookup-table -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END lookup-table -->## Available GBrain Toolsdiff --git a/plugin-variants/gbrain-coding/skills/query/SKILL.md b/plugin-variants/gbrain-coding/skills/query/SKILL.mdindex 0ac43a80ee..2d08728462 100644--- a/plugin-variants/gbrain-coding/skills/query/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/query/SKILL.md@@ -71,7 +71,7 @@ This skill guarantees:- List pages in gbrain by type or check backlinks for structural queries- Narrow with filters instead of grepping the brain checkout: `--types '["meeting"]'`,`--match keyword`, `gbrain query "<q>" --since 2026-09-01 --until 2026-09-30`, `--source <id>`.- Copyable examples: "Retrieval: gbrain first" in `skills/conventions/brain-first.md`.+ Every call and flag: "Which gbrain call for which lookup" in `skills/conventions/brain-first.md`.3. **Read top results.** Read the top 3-5 pages from gbrain to get full context.4. **Synthesize answer** with citations. Every claim traces back to a specific page slug.5. **Flag gaps.** If the brain doesn't have info, say "the brain doesn't have information on X" rather than hallucinating. Read the result's notices first (see "When it fails"): a degraded or truncated result is not a gap.diff --git a/plugin-variants/gbrain-daily/skills/conventions/brain-first.md b/plugin-variants/gbrain-daily/skills/conventions/brain-first.mdindex c73679a4fe..b1acc6dda9 100644--- a/plugin-variants/gbrain-daily/skills/conventions/brain-first.md+++ b/plugin-variants/gbrain-daily/skills/conventions/brain-first.md@@ -5,44 +5,31 @@Sub-agents and fresh sessions inherit gbrain tools but not the knowledge ofwhen and how to use them. This file is that knowledge.-## Retrieval: gbrain first--For anything in the brain, search gbrain, then read the page a hit names. Don't-`grep`, `rg` or `cat` the brain checkout, or run SQL over pages and-frontmatter, before gbrain: gbrain reads the index across sources, ranks results,-filters by type, date and source, and returns the slug to read next. Use the-files only when gbrain is unreachable or for an edit not yet synced.--Prefer the gbrain MCP tools (`search`, `query`, `get_page`, `recall`) when your-harness has the server connected: it stays connected, so each call skips the-CLI's startup, which costs seconds per call on a large pooled Postgres brain.-The CLI commands below take the same filters.--```bash-gbrain search "Acme Example" # names, codes, exact phrases-gbrain search '"ZEBRA-42" OR "inventory sync"' --match keyword # every page with any term (instead of grep)-gbrain query "why did the launch move" # questions and concepts-gbrain search "launch" --types '["meeting","person"]' # only these page types-gbrain query "launch" --since 2026-09-01 --until 2026-09-30 # date window (also --since 30d)-gbrain search "launch" --source source-a --limit 5 --json 2>/dev/null | jq -r '.[].slug'-gbrain get companies/acme-example # read the page a hit points to-gbrain recall "Alice Example" # facts saved with remember-gbrain backlinks companies/acme-example --type meeting # pages that link here (instead of grepping a slug)-gbrain timeline companies/acme-example --since 2026-10-01 # dated events on one page-gbrain list --type meeting --limit 50 # enumerate by type or --tag (instead of SQL)-gbrain find 'people/*acme*' # glob, slug prefix or name (instead of ls/find)-gbrain stats --by source,type --since 30d # page counts per source and type (instead of grep -c/SQL)-```--- `--types` takes a JSON array. `--since`/`--until` are `query` flags- (YYYY-MM-DD or 7d/2w/1y) and match each page's effective date: its- frontmatter date, else when it was imported.-- Keyword search matches words, not slugs: search `"Acme Example"`, and use- `backlinks` to find pages linking to `companies/acme-example`.-- Without `--source`, a search reads the resolved source (a notice names it- when it routes); `--source __all__` searches every source.-- Notices and `[AGENT]` blocks go to stderr, so `--json` stdout is clean JSON.- Read a degraded notice before concluding the brain has nothing.+## Which gbrain call for which lookup++<!-- BEGIN lookup-table -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END lookup-table -->## Available GBrain Toolsdiff --git a/plugin-variants/gbrain-daily/skills/query/SKILL.md b/plugin-variants/gbrain-daily/skills/query/SKILL.mdindex 0ac43a80ee..2d08728462 100644--- a/plugin-variants/gbrain-daily/skills/query/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/query/SKILL.md@@ -71,7 +71,7 @@ This skill guarantees:- List pages in gbrain by type or check backlinks for structural queries- Narrow with filters instead of grepping the brain checkout: `--types '["meeting"]'`,`--match keyword`, `gbrain query "<q>" --since 2026-09-01 --until 2026-09-30`, `--source <id>`.- Copyable examples: "Retrieval: gbrain first" in `skills/conventions/brain-first.md`.+ Every call and flag: "Which gbrain call for which lookup" in `skills/conventions/brain-first.md`.3. **Read top results.** Read the top 3-5 pages from gbrain to get full context.4. **Synthesize answer** with citations. Every claim traces back to a specific page slug.5. **Flag gaps.** If the brain doesn't have info, say "the brain doesn't have information on X" rather than hallucinating. Read the result's notices first (see "When it fails"): a degraded or truncated result is not a gap.diff --git a/plugin/skills/brain-ops/SKILL.md b/plugin/skills/brain-ops/SKILL.mdindex ad98da1d90..55b34d62bc 100644--- a/plugin/skills/brain-ops/SKILL.md+++ b/plugin/skills/brain-ops/SKILL.md@@ -134,7 +134,7 @@ Before using ANY external API to research a person, company, or topic:The brain almost always has something. External APIs fill gaps, not start from scratch.Search gbrain before reading, grepping or querying brain files directly; filters(`--types`, `--match keyword`, `query --since/--until`, `--source`, `--json`) are-in the brain-first convention's "Retrieval: gbrain first" block.+in the brain-first convention's "Which gbrain call for which lookup" table.**⚠️ NEVER scope/count a corpus with shallow `ls` — query gbrain or `find`.** Federated sources often carry MULTIPLE coexisting directory conventions — a flat legacy layer AND a date-nested `meetings/YYYY/MM/` layer. A non-recursive `ls dir/*.md` sees only one and undercounts massively. Real example: a shallow `ls` of one source's `meetings/` counted 132 files, almost all the user's, and concluded that WAS the corpus — missing thousands of transcripts nested under `meetings/YYYY/MM/`. To count/scope a brain corpus:- **Best:** `gbrain sources list` (shows per-source indexed page counts) + `gbrain query`. gbrain indexes ALL federated sources correctly; trust its index, not the filesystem.diff --git a/plugin/skills/conventions/brain-first.md b/plugin/skills/conventions/brain-first.mdindex c73679a4fe..b1acc6dda9 100644--- a/plugin/skills/conventions/brain-first.md+++ b/plugin/skills/conventions/brain-first.md@@ -5,44 +5,31 @@Sub-agents and fresh sessions inherit gbrain tools but not the knowledge ofwhen and how to use them. This file is that knowledge.-## Retrieval: gbrain first--For anything in the brain, search gbrain, then read the page a hit names. Don't-`grep`, `rg` or `cat` the brain checkout, or run SQL over pages and-frontmatter, before gbrain: gbrain reads the index across sources, ranks results,-filters by type, date and source, and returns the slug to read next. Use the-files only when gbrain is unreachable or for an edit not yet synced.--Prefer the gbrain MCP tools (`search`, `query`, `get_page`, `recall`) when your-harness has the server connected: it stays connected, so each call skips the-CLI's startup, which costs seconds per call on a large pooled Postgres brain.-The CLI commands below take the same filters.--```bash-gbrain search "Acme Example" # names, codes, exact phrases-gbrain search '"ZEBRA-42" OR "inventory sync"' --match keyword # every page with any term (instead of grep)-gbrain query "why did the launch move" # questions and concepts-gbrain search "launch" --types '["meeting","person"]' # only these page types-gbrain query "launch" --since 2026-09-01 --until 2026-09-30 # date window (also --since 30d)-gbrain search "launch" --source source-a --limit 5 --json 2>/dev/null | jq -r '.[].slug'-gbrain get companies/acme-example # read the page a hit points to-gbrain recall "Alice Example" # facts saved with remember-gbrain backlinks companies/acme-example --type meeting # pages that link here (instead of grepping a slug)-gbrain timeline companies/acme-example --since 2026-10-01 # dated events on one page-gbrain list --type meeting --limit 50 # enumerate by type or --tag (instead of SQL)-gbrain find 'people/*acme*' # glob, slug prefix or name (instead of ls/find)-gbrain stats --by source,type --since 30d # page counts per source and type (instead of grep -c/SQL)-```--- `--types` takes a JSON array. `--since`/`--until` are `query` flags- (YYYY-MM-DD or 7d/2w/1y) and match each page's effective date: its- frontmatter date, else when it was imported.-- Keyword search matches words, not slugs: search `"Acme Example"`, and use- `backlinks` to find pages linking to `companies/acme-example`.-- Without `--source`, a search reads the resolved source (a notice names it- when it routes); `--source __all__` searches every source.-- Notices and `[AGENT]` blocks go to stderr, so `--json` stdout is clean JSON.- Read a degraded notice before concluding the brain has nothing.+## Which gbrain call for which lookup++<!-- BEGIN lookup-table -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END lookup-table -->## Available GBrain Toolsdiff --git a/plugin/skills/query/SKILL.md b/plugin/skills/query/SKILL.mdindex 0ac43a80ee..2d08728462 100644--- a/plugin/skills/query/SKILL.md+++ b/plugin/skills/query/SKILL.md@@ -71,7 +71,7 @@ This skill guarantees:- List pages in gbrain by type or check backlinks for structural queries- Narrow with filters instead of grepping the brain checkout: `--types '["meeting"]'`,`--match keyword`, `gbrain query "<q>" --since 2026-09-01 --until 2026-09-30`, `--source <id>`.- Copyable examples: "Retrieval: gbrain first" in `skills/conventions/brain-first.md`.+ Every call and flag: "Which gbrain call for which lookup" in `skills/conventions/brain-first.md`.3. **Read top results.** Read the top 3-5 pages from gbrain to get full context.4. **Synthesize answer** with citations. Every claim traces back to a specific page slug.5. **Flag gaps.** If the brain doesn't have info, say "the brain doesn't have information on X" rather than hallucinating. Read the result's notices first (see "When it fails"): a degraded or truncated result is not a gap.diff --git a/scripts/build-lookup-table.ts b/scripts/build-lookup-table.tsnew file mode 100644index 0000000000..d927639246--- /dev/null+++ b/scripts/build-lookup-table.ts@@ -0,0 +1,47 @@+#!/usr/bin/env bun+/**+ * The "Which gbrain call for which lookup" table (#7233): written once in+ * skills/conventions/brain-first.md and copied verbatim into the other+ * agent entry points, so every agent sees the same calls with the same flags.+ *+ * bun scripts/build-lookup-table.ts rewrite the copies+ * bun scripts/build-lookup-table.ts --check exit 1 when a copy is stale+ *+ * Source region: `<!-- BEGIN lookup-table -->` .. `<!-- END lookup-table -->`+ * in the brain-first convention. Each copy sits between+ * `<!-- BEGIN GENERATED lookup-table ... -->` and `<!-- END GENERATED lookup-table -->`.+ * The plugin trees copy brain-first.md and RESOLVER.md themselves (regen:all+ * runs this step first); the vendored templates/bootstrap/template-repo/ tree+ * is regenerated from AGENTS.md.template by scripts/generate-template-repo.ts+ * (check-bootstrap-templates.sh diffs it). Wired into regen:all and+ * check:regen-all.+ */+import { readFileSync, writeFileSync } from 'node:fs';+import { join } from 'node:path';++const ROOT = join(import.meta.dir, '..');+const SOURCE = 'skills/conventions/brain-first.md';+const COPIES = ['AGENTS.md', 'INSTALL_FOR_AGENTS.md', 'templates/bootstrap/AGENTS.md.template', 'skills/RESOLVER.md'];++const SOURCE_REGION = /<!-- BEGIN lookup-table -->\n([\s\S]*?)<!-- END lookup-table -->/;+const COPY_REGION = /(<!-- BEGIN GENERATED lookup-table[^>]*-->\n)[\s\S]*?(<!-- END GENERATED lookup-table -->)/;++const source = SOURCE_REGION.exec(readFileSync(join(ROOT, SOURCE), 'utf8'));+if (!source) throw new Error(`${SOURCE}: no <!-- BEGIN lookup-table --> region`);+const table = source[1]!;+const check = process.argv.includes('--check');+const stale: string[] = [];+for (const file of COPIES) {+ const path = join(ROOT, file);+ const text = readFileSync(path, 'utf8');+ if (!COPY_REGION.test(text)) throw new Error(`${file}: no <!-- BEGIN GENERATED lookup-table --> region`);+ const next = text.replace(COPY_REGION, (_m, begin: string, end: string) => `${begin}${table}${end}`);+ if (next === text) continue;+ stale.push(file);+ if (!check) writeFileSync(path, next);+}+if (check && stale.length > 0) {+ console.error(`FAIL: the lookup table copy is stale in ${stale.join(', ')}\nWhy: every copy must match the region in ${SOURCE}.\nFix: bun scripts/build-lookup-table.ts (or bun run regen:all)`);+ process.exit(1);+}+console.log(check ? 'lookup table copies are current' : `lookup table: ${stale.length} file(s) rewritten`);diff --git a/scripts/regen-all.ts b/scripts/regen-all.tsindex a19a19d621..93fadddbdc 100644--- a/scripts/regen-all.ts+++ b/scripts/regen-all.ts@@ -41,6 +41,7 @@ export const ARTIFACTS: Artifact[] = [{ name: 'schema migrations bundle', regen: ['bun', 'run', 'scripts/build-schema-migrations.ts'], check: ['bash', 'scripts/check-schema-migrations-fresh.sh'] },{ name: 'error-code registry docs', regen: ['bun', 'scripts/build-error-codes.ts'], check: ['bun', 'scripts/build-error-codes.ts', '--check'] },{ name: 'agent operator protocol blocks', regen: ['bun', 'scripts/build-agent-protocol.ts'], check: ['bun', 'scripts/build-agent-protocol.ts', '--check'] },+ { name: 'lookup table copies', regen: ['bun', 'scripts/build-lookup-table.ts'], check: ['bun', 'scripts/build-lookup-table.ts', '--check'] },{ name: 'harness adapter reference', regen: ['bun', 'run', 'scripts/build-harness-docs.ts'], check: ['bun', '-e', HARNESS_DOCS_CHECK] },{ name: 'operation manifest', regen: ['bun', 'run', 'scripts/build-operation-manifest.ts'], check: [...BUN_TEST, 'test/operation-manifest.test.ts'] },{ name: 'MCP tool catalog', regen: ['bun', 'run', 'scripts/generate-tool-catalog.ts'], check: ['bash', 'scripts/check-tool-catalog-fresh.sh'] },diff --git a/skills/RESOLVER.md b/skills/RESOLVER.mdindex 1262a27fd6..d209f81d75 100644--- a/skills/RESOLVER.md+++ b/skills/RESOLVER.md@@ -13,6 +13,32 @@ wins; fix the row.[agent operator protocol](./conventions/agent-operator-protocol.md). Read theerror's `code` (fall back to `error`), follow `fix.next`, then run `fix.verify`.+## Which gbrain call for which lookup++<!-- BEGIN GENERATED lookup-table (copied from skills/conventions/brain-first.md by bun run regen:all) -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END GENERATED lookup-table -->+## Memory defaultsPreserve the existing agent's identity and instructions. Ordinary setup addsdiff --git a/skills/brain-ops/SKILL.md b/skills/brain-ops/SKILL.mdindex 3d9f239bcd..f89228b704 100644--- a/skills/brain-ops/SKILL.md+++ b/skills/brain-ops/SKILL.md@@ -133,7 +133,7 @@ Before using ANY external API to research a person, company, or topic:The brain almost always has something. External APIs fill gaps, not start from scratch.Search gbrain before reading, grepping or querying brain files directly; filters(`--types`, `--match keyword`, `query --since/--until`, `--source`, `--json`) are-in the brain-first convention's "Retrieval: gbrain first" block.+in the brain-first convention's "Which gbrain call for which lookup" table.**⚠️ NEVER scope/count a corpus with shallow `ls` — query gbrain or `find`.** Federated sources often carry MULTIPLE coexisting directory conventions — a flat legacy layer AND a date-nested `meetings/YYYY/MM/` layer. A non-recursive `ls dir/*.md` sees only one and undercounts massively. Real example: a shallow `ls` of one source's `meetings/` counted 132 files, almost all the user's, and concluded that WAS the corpus — missing thousands of transcripts nested under `meetings/YYYY/MM/`. To count/scope a brain corpus:- **Best:** `gbrain sources list` (shows per-source indexed page counts) + `gbrain query`. gbrain indexes ALL federated sources correctly; trust its index, not the filesystem.diff --git a/skills/conventions/brain-first.md b/skills/conventions/brain-first.mdindex c73679a4fe..b1acc6dda9 100644--- a/skills/conventions/brain-first.md+++ b/skills/conventions/brain-first.md@@ -5,44 +5,31 @@Sub-agents and fresh sessions inherit gbrain tools but not the knowledge ofwhen and how to use them. This file is that knowledge.-## Retrieval: gbrain first--For anything in the brain, search gbrain, then read the page a hit names. Don't-`grep`, `rg` or `cat` the brain checkout, or run SQL over pages and-frontmatter, before gbrain: gbrain reads the index across sources, ranks results,-filters by type, date and source, and returns the slug to read next. Use the-files only when gbrain is unreachable or for an edit not yet synced.--Prefer the gbrain MCP tools (`search`, `query`, `get_page`, `recall`) when your-harness has the server connected: it stays connected, so each call skips the-CLI's startup, which costs seconds per call on a large pooled Postgres brain.-The CLI commands below take the same filters.--```bash-gbrain search "Acme Example" # names, codes, exact phrases-gbrain search '"ZEBRA-42" OR "inventory sync"' --match keyword # every page with any term (instead of grep)-gbrain query "why did the launch move" # questions and concepts-gbrain search "launch" --types '["meeting","person"]' # only these page types-gbrain query "launch" --since 2026-09-01 --until 2026-09-30 # date window (also --since 30d)-gbrain search "launch" --source source-a --limit 5 --json 2>/dev/null | jq -r '.[].slug'-gbrain get companies/acme-example # read the page a hit points to-gbrain recall "Alice Example" # facts saved with remember-gbrain backlinks companies/acme-example --type meeting # pages that link here (instead of grepping a slug)-gbrain timeline companies/acme-example --since 2026-10-01 # dated events on one page-gbrain list --type meeting --limit 50 # enumerate by type or --tag (instead of SQL)-gbrain find 'people/*acme*' # glob, slug prefix or name (instead of ls/find)-gbrain stats --by source,type --since 30d # page counts per source and type (instead of grep -c/SQL)-```--- `--types` takes a JSON array. `--since`/`--until` are `query` flags- (YYYY-MM-DD or 7d/2w/1y) and match each page's effective date: its- frontmatter date, else when it was imported.-- Keyword search matches words, not slugs: search `"Acme Example"`, and use- `backlinks` to find pages linking to `companies/acme-example`.-- Without `--source`, a search reads the resolved source (a notice names it- when it routes); `--source __all__` searches every source.-- Notices and `[AGENT]` blocks go to stderr, so `--json` stdout is clean JSON.- Read a degraded notice before concluding the brain has nothing.+## Which gbrain call for which lookup++<!-- BEGIN lookup-table -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END lookup-table -->## Available GBrain Toolsdiff --git a/skills/query/SKILL.md b/skills/query/SKILL.mdindex 2125a8a3c9..23df7bc1e4 100644--- a/skills/query/SKILL.md+++ b/skills/query/SKILL.md@@ -70,7 +70,7 @@ This skill guarantees:- List pages in gbrain by type or check backlinks for structural queries- Narrow with filters instead of grepping the brain checkout: `--types '["meeting"]'`,`--match keyword`, `gbrain query "<q>" --since 2026-09-01 --until 2026-09-30`, `--source <id>`.- Copyable examples: "Retrieval: gbrain first" in `skills/conventions/brain-first.md`.+ Every call and flag: "Which gbrain call for which lookup" in `skills/conventions/brain-first.md`.3. **Read top results.** Read the top 3-5 pages from gbrain to get full context.4. **Synthesize answer** with citations. Every claim traces back to a specific page slug.5. **Flag gaps.** If the brain doesn't have info, say "the brain doesn't have information on X" rather than hallucinating. Read the result's notices first (see "When it fails"): a degraded or truncated result is not a gap.diff --git a/skills/skills.lock.json b/skills/skills.lock.jsonindex 75882b0d11..0238d680de 100644--- a/skills/skills.lock.json+++ b/skills/skills.lock.json@@ -1,5 +1,5 @@{- "RESOLVER.md": "d788b96fae6731a9bad8586074e40d6b22d360f5b5a7f7a85cea0ef3bb46cf2d",+ "RESOLVER.md": "b571439d29b499d3dad304c0f4253f4cf3fb04644a0140e1d77ba2506b3a1d09","_AGENT_README.md": "ab51e36e9a0b53f4d0609294b0556444399147834932d9c1acfdc7aa367c70b8","_brain-filing-rules.json": "4e6ecee2d94867d146583d60bf98dccdd9205bb70793af56fe1397a2b258ae0d","_brain-filing-rules.md": "ff42b331bce542d708f97ff0a73ff0fb5664b46ee9b1862a5478b15dc637487e",@@ -20,7 +20,7 @@"brain-ingest-gate/routing-eval.jsonl": "281e94affbb8631ef7ff44203884cce1c03c468b27f893829da1e6e439401a33","brain-link-discipline/SKILL.md": "db2a77319475dd8eb370e9a3bb0eafe81d3b19d2de126113b30df7454dd9a069","brain-link-discipline/routing-eval.jsonl": "0adea4c6d72fdb849c12fe2cad718568b9ab704299b00b093c40c2284faf684c",- "brain-ops/SKILL.md": "2f79c8699ca1316d113fe7c20f21791310f1884e1e276051e26c753510877b05",+ "brain-ops/SKILL.md": "332af1d0a1e66fdaae7bb193c715e91f458dbf3b49a6669b9523948e2243255e","brain-pdf/SKILL.md": "2dfffd2373f00b5f11c1e4b39a75be48e90870201b4c11979d520bd5975dcae4","brain-pdf/routing-eval.jsonl": "119e4fa113ea45783cee4499e63a729fdeecb4d9a45d47497754b4f5b21d0734","brain-taxonomist/SKILL.md": "418fd4cdac3355551c42a70fea4d76e3d9255fe04698358b2c1e89dc666bf11d",@@ -45,7 +45,7 @@"context-audit/SKILL.md": "6d786629d40544ddaab4f4e6e333569d270bcb8b581589dc16fb9f8bcb4f6207","context-audit/routing-eval.jsonl": "fb1832e24cc1b04163a74c5cde72bca53050a66246ca902e1a5f40303f52b5ab","conventions/agent-operator-protocol.md": "d7cfc7e4c84f61392658cbe969058b1e8237b7d44c3ebdeec352569ffddbe001",- "conventions/brain-first.md": "def873060083e03f9e19e11cf92db6f5bd9590c913b5a3693c27cfef0967cec4",+ "conventions/brain-first.md": "ace81498afa0b6828594e9d4857354e365a1ec7752718bb1638db640a021a9f3","conventions/brain-routing.md": "392998d9a109b330c9225af4ca5c8798b0ff02eba4d441c93fdb7c263687d0c6","conventions/calibration.md": "500dc26bd7c8400f50dc4c16fd83f1a588f3e7e68c59050a21fd8a0f69e4d198","conventions/cron-via-minions.md": "badb1cd6cd825d6f1ac0b6b28cc47e5d80facc783a3e59a14146ae901ee0f933",@@ -197,7 +197,7 @@"postgres-adopt/SKILL.md": "8cf801e2e0d29da525a8c4ba275b91e6caffc8aae8e648cbcc8bceaab865c890","postgres-adopt/routing-eval.jsonl": "db91c1fae408a45082979c402c11eff413277ace6cf746297cc86009dcaefe06","publish/SKILL.md": "271bd9ba87279429cd934509071dd032b859d59264038c38829c9af46f15c13b",- "query/SKILL.md": "afe2a88394bb78bb651ebd5434415dfa1a96cbc3c52848e134be16b3e8d36f08",+ "query/SKILL.md": "d777c78f07281a61bbe691d4b1e2d0e66fc51452347412f60881cdec08286045","query/routing-eval.jsonl": "74f5a91e52fabc54e0e9403fa17db87ee26bb7ebb8ae8005148c51142abc62fe","remote-mcp/SKILL.md": "753d4df2c6b8c837d00a9c0593028220bdceb1a83b08b29a1d9b973242b789c5","remote-mcp/routing-eval.jsonl": "7287693135c9fe2d6495d81d22746ddf41b116254db4b6e683dbdee251e08f8e",diff --git a/templates/bootstrap/AGENTS.md.template b/templates/bootstrap/AGENTS.md.templateindex 08afb44bf2..df09d04b64 100644--- a/templates/bootstrap/AGENTS.md.template+++ b/templates/bootstrap/AGENTS.md.template@@ -84,9 +84,31 @@ commitment named in the message, search the brain before answering: `recall` forfacts, `query` for synthesis, `get_page` for the record. If context was alreadyinjected this turn, use it. Hold what you find silently — never narrate retrieval("based on my memory", "I recall"). Never use generic file-grep where a brain tool-exists. From a shell: `gbrain search "<name>"` or `gbrain query "<question>"`, then-`gbrain get <slug>`; `gbrain search '"<term>"' --match keyword` lists every matching-page, and `--types '["meeting"]'`, `query --since 30d` and `--source <id>` narrow it.+exists. Which gbrain call for which lookup:++<!-- BEGIN GENERATED lookup-table (copied from skills/conventions/brain-first.md by bun run regen:all) -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END GENERATED lookup-table -->**Gate 4 — Receipts.** Every factual claim about the record — what someone said,did, decided, or committed to — must be backed by a line retrieved THIS turn anddiff --git a/templates/bootstrap/template-repo/AGENTS.md b/templates/bootstrap/template-repo/AGENTS.mdindex 9fa18542b2..e7b21f2e62 100644--- a/templates/bootstrap/template-repo/AGENTS.md+++ b/templates/bootstrap/template-repo/AGENTS.md@@ -88,9 +88,31 @@ commitment named in the message, search the brain before answering: `recall` forfacts, `query` for synthesis, `get_page` for the record. If context was alreadyinjected this turn, use it. Hold what you find silently — never narrate retrieval("based on my memory", "I recall"). Never use generic file-grep where a brain tool-exists. From a shell: `gbrain search "<name>"` or `gbrain query "<question>"`, then-`gbrain get <slug>`; `gbrain search '"<term>"' --match keyword` lists every matching-page, and `--types '["meeting"]'`, `query --since 30d` and `--source <id>` narrow it.+exists. Which gbrain call for which lookup:++<!-- BEGIN GENERATED lookup-table (copied from skills/conventions/brain-first.md by bun run regen:all) -->+Ask gbrain before you `grep`, `cat`, `ls` or run SQL on the brain checkout: it+reads the index across every source, ranks, filters and names the slug to read+next. With the gbrain MCP server connected, call the tool of the same name+instead of the CLI (one connection, no per-call startup).++| Lookup | CLI | MCP tool |+|---|---|---|+| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` |+| Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` |+| Read a known page | `gbrain get <slug>` | `get_page` |+| Read only the part a search hit points at | `gbrain get <slug> --around-chunk-id <chunk_id>` or `--lines '{"from":1,"count":200}'` | `get_page` |+| What the brain knows about a person or company | `gbrain entity <slug>`, then `gbrain recall "<topic>" --json` | `entity`, `recall` |+| Links, dated events, every page of a type | `gbrain backlinks <slug>`, `gbrain timeline <slug>`, `gbrain list --type T` | `get_backlinks`, `get_timeline`, `list_pages` |+| Save a fact the user stated | `gbrain remember "<fact>" --entity <slug> --content-origin user_said --provenance "<where>"` | `remember` |+| Why a page didn't rank | `gbrain query "<q>" --explain-target <slug>` | `query` |++Parse `--json` output instead of matching the text; notices go to stderr. Take+`chunk_id` from a fresh `search --json` hit (an old one fails `revision_changed`),+and read a degraded notice before concluding the brain has nothing.+<!-- END GENERATED lookup-table -->**Gate 4 — Receipts.** Every factual claim about the record — what someone said,did, decided, or committed to — must be backed by a line retrieved THIS turn and