Skip to content

Commit fb9f807

Browse files
author
nobody
committed
feat(sync-gbrain): default to --strategy auto (code + markdown)
The /sync-gbrain skill previously ran 'gbrain sync --strategy code' for the code-stage walk, silently skipping every markdown file in the repo. For code repos with non-trivial docs (READMEs aside — those are still skipped by gbrain's own hard-coded list), this meant guides, ADRs, design docs, and architectural notes never reached the brain. Switch the page-creating walk in the code stage to --strategy auto so a single sync pass indexes both code AND markdown. Full-mode behavior is preserved: after the walk, --full still runs 'gbrain reindex-code --yes' to force chunker-version re-embed of code pages (upstream garrytan#1639/garrytan#1642's walk+reindex split, kept intact). Three call sites updated: the dry-run summary string, the spawnGbrain walk call, and the walk's error-summary message. Doc block at top of file and the inline comment block above the walk are updated to describe the new behavior. sync-gbrain/SKILL.md.tmpl's architecture note ('native code surfaces ... gbrain sync --strategy auto') is updated to match; generated SKILL.md files regenerated via 'bun run gen:skill-docs --host all' (all 9 hosts + Claude default). Personal fork only — not pushed upstream.
1 parent 61c9a20 commit fb9f807

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

bin/gstack-gbrain-sync.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
*
55
* Orchestrates three storage tiers per plan §"Storage tiering":
66
*
7-
* 1. Code (current repo) → `gbrain sources add` (idempotent via
8-
* lib/gbrain-sources.ts) + `gbrain sync
9-
* --strategy code` (incremental) or
10-
* `gbrain reindex-code --yes` (--full).
11-
* NEVER `gbrain import` (markdown only).
7+
* 1. Code + markdown (current repo) → `gbrain sources add` (idempotent
8+
* via lib/gbrain-sources.ts) + `gbrain
9+
* sync --strategy auto` (incremental;
10+
* walks code AND markdown in one pass).
11+
* --full additionally runs `gbrain
12+
* reindex-code --yes` after the walk
13+
* to force chunker-version re-embed of
14+
* code pages. NEVER `gbrain import`
15+
* (transcript pipeline).
1216
* 2. Transcripts + curated memory → gstack-memory-ingest (typed put_page)
1317
* 3. Curated artifacts to git → gstack-brain-sync (existing pipeline)
1418
*
@@ -631,7 +635,7 @@ async function runCodeImport(args: CliArgs): Promise<StageResult> {
631635
ran: false,
632636
ok: true,
633637
duration_ms: 0,
634-
summary: `would: gbrain sources add ${sourceId} --path ${root} --federated; gbrain sync --strategy code --source ${sourceId}; gbrain sources attach ${sourceId}`,
638+
summary: `would: gbrain sources add ${sourceId} --path ${root} --federated; gbrain sync --strategy auto --source ${sourceId}; gbrain sources attach ${sourceId}`,
635639
detail: { source_id: sourceId, source_path: root, status: "skipped" },
636640
};
637641
}
@@ -713,14 +717,15 @@ async function runCodeImport(args: CliArgs): Promise<StageResult> {
713717
// run that called reindex-code alone found nothing ("No code pages to
714718
// reindex"), finished in ~1s, and left the code index permanently empty
715719
// while still reporting OK. The page-creating walk is `sync --strategy
716-
// code`, so --full must run it FIRST, then reindex-code, to honor the
717-
// documented "full walk + reindex" contract for both fresh and populated
718-
// sources.
720+
// auto` (which walks code AND markdown — formerly `--strategy code`, now
721+
// `auto` so we index repo docs too), so --full must run it FIRST, then
722+
// reindex-code, to honor the documented "full walk + reindex" contract
723+
// for both fresh and populated sources.
719724
const codeTimeoutMs = resolveStageTimeoutMs(
720725
process.env.GSTACK_SYNC_CODE_TIMEOUT_MS,
721726
"GSTACK_SYNC_CODE_TIMEOUT_MS",
722727
);
723-
const walkResult = spawnGbrain(["sync", "--strategy", "code", "--source", sourceId], {
728+
const walkResult = spawnGbrain(["sync", "--strategy", "auto", "--source", sourceId], {
724729
stdio: args.quiet ? ["ignore", "ignore", "ignore"] : ["ignore", "inherit", "inherit"],
725730
timeout: codeTimeoutMs,
726731
baseEnv: gbrainEnv,
@@ -732,7 +737,7 @@ async function runCodeImport(args: CliArgs): Promise<StageResult> {
732737
ran: true,
733738
ok: false,
734739
duration_ms: Date.now() - t0,
735-
summary: `gbrain sync --strategy code --source ${sourceId} exited ${walkResult.status}`,
740+
summary: `gbrain sync --strategy auto --source ${sourceId} exited ${walkResult.status}`,
736741
detail: { source_id: sourceId, source_path: root, status: "failed" },
737742
};
738743
}

sync-gbrain/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ guidance in CLAUDE.md so the coding agent knows when to prefer `gbrain`
755755
search over Grep.
756756

757757
**Architecture (post-codex review):** This skill uses gbrain v0.20.0+'s
758-
**native code surfaces** (`gbrain sources add`, `gbrain sync --strategy code`,
758+
**native code surfaces** (`gbrain sources add`, `gbrain sync --strategy auto`,
759759
`gbrain reindex-code`, `gbrain code-def/code-refs/code-callers/code-callees`).
760760
It does NOT use `gbrain import` (that path is for markdown directories).
761761
It does NOT touch `~/.gstack/` indexing (the existing `gstack-gbrain-source-wireup`

sync-gbrain/SKILL.md.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ guidance in CLAUDE.md so the coding agent knows when to prefer `gbrain`
3535
search over Grep.
3636

3737
**Architecture (post-codex review):** This skill uses gbrain v0.20.0+'s
38-
**native code surfaces** (`gbrain sources add`, `gbrain sync --strategy code`,
38+
**native code surfaces** (`gbrain sources add`, `gbrain sync --strategy auto`,
3939
`gbrain reindex-code`, `gbrain code-def/code-refs/code-callers/code-callees`).
4040
It does NOT use `gbrain import` (that path is for markdown directories).
4141
It does NOT touch `~/.gstack/` indexing (the existing `gstack-gbrain-source-wireup`

0 commit comments

Comments
 (0)