Skip to content

feat(sync): GBRAIN_NO_PRUNE_DIRS — un-prune a content dir (e.g. an ops/ KB)#2259

Open
donogeme wants to merge 1 commit into
garrytan:masterfrom
donogeme:feat/no-prune-dirs
Open

feat(sync): GBRAIN_NO_PRUNE_DIRS — un-prune a content dir (e.g. an ops/ KB)#2259
donogeme wants to merge 1 commit into
garrytan:masterfrom
donogeme:feat/no-prune-dirs

Conversation

@donogeme

Copy link
Copy Markdown

What

Adds GBRAIN_NO_PRUNE_DIRS (comma-separated env var) that removes directory names from PRUNE_DIR_NAMES at walk time, so a brain can sync a tree whose top-level name happens to collide with a pruned name.

Why

PRUNE_DIR_NAMES = {node_modules, .raw, ops} is hardcoded. ops in particular is a semantic prune ("operations, not knowledge") — great for repos that use ops/ for throwaway operational files. But some brains use ops/ as a genuine knowledge base (e.g. ops/_kb/{compliance,finance,partners,...}). For them, the entire tree is silently invisible to search with no opt-out — a single hardcoded name decides it.

This gives an escape hatch without changing any default: set GBRAIN_NO_PRUNE_DIRS=ops and that tree syncs.

Behavior

  • Comma-separated; trims whitespace, drops empties/dupes.
  • Only un-prunes names in PRUNE_DIR_NAMES (and the *.raw suffix rule).
  • Dot-prefixed dirs (.git, .obsidian, …) and git submodules stay pruned regardless — those are never content.
  • Unset/empty = exactly today's behavior. Purely additive, no default change.
  • Routes through pruneDir, so every walker (sync, extract, transcript-discovery) honors it consistently.

Example

GBRAIN_NO_PRUNE_DIRS=ops gbrain sync --all

Tests

test/sync-no-prune-dirs.test.ts — parser contract + prune/un-prune matrix (ops un-pruned, node_modules still pruned, dot-dirs always pruned). bun run typecheck clean.

Context

Env-var form mirrors the existing GBRAIN_SOURCE/GBRAIN_SOURCES convention. Happy to reshape as a sync.* config key instead if you'd prefer config-driven over env.

PRUNE_DIR_NAMES (node_modules, .raw, ops) is hardcoded. A brain that legitimately
uses one of those names as a content tree — e.g. an `ops/` knowledge base rather
than throwaway operational files — has no way to sync it. GBRAIN_NO_PRUNE_DIRS
(comma-separated) removes names from the prune set. Dot-dirs + git submodules stay
pruned regardless. Pinned by test/sync-no-prune-dirs.test.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant