Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: detect submodules structurally and widen the skip list in the nested CLAUDE.md walk (#3866)
[._.]/ Adam Eivy0301cb5d6875
diff --git a/CLAUDE.md b/CLAUDE.mdindex fab142e11d..ba1eda810f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -77,7 +77,7 @@ Client- and server-specific conventions live in nested memory files that load wh- `server/CLAUDE.md` — schema parity, write serialization, peer fan-out in tests, prompt-template migrations- `server/lib/aiToolkit/CLAUDE.md` — the override-consistency contract for the vendored provider/runner/prompt toolkit (self-contained: no imports out to other PortOS modules). PortOS overrides `executeCliRun`/`stopRun`/`isRunActive` and mirrors time-based provider-status recovery on read — read it before editing the runner or provider config.-**Nested files reach API-provider agents too — but the walk is bounded.** Nested `CLAUDE.md` files load on demand in Claude Code, and `getClaudeMdContext()` in `server/services/agentPromptBuilder.js` splices them into the prompts PortOS builds for its own API-provider agents as well (`~/.claude/CLAUDE.md`, then the workspace-root file, then every nested one as its own labeled section). The walk is capped at depth 5 / 10 files and skips dot-dirs, `node_modules/`, `data/`, build output, and `lib/slashdo/`. Two consequences: **a rule that must reach every agent has to sit inside that budget** — if the repo ever exceeds 10 nested files, the overflow is silently dropped, so raise the cap in the same change rather than assuming coverage; and **the root file is the only guaranteed-first slot**, so a rule guarding data loss, a destructive action, privacy, or spend still belongs here when it must outrank a subtree convention (that is why the backup-exclude anchoring rule above sits in root rather than `server/CLAUDE.md`).+**Nested files reach API-provider agents too — but the walk is bounded.** Nested `CLAUDE.md` files load on demand in Claude Code, and `getClaudeMdContext()` in `server/services/agentPromptBuilder.js` splices them into the prompts PortOS builds for its own API-provider agents as well (`~/.claude/CLAUDE.md`, then the workspace-root file, then every nested one as its own labeled section). The walk is capped at depth 5 / 10 files and skips dot-dirs, `node_modules/`, `data/`, build output, and any subdirectory carrying its own `.git` (submodules and vendored checkouts, e.g. `lib/slashdo/`). Two consequences: **a rule that must reach every agent has to sit inside that budget** — if the repo ever exceeds 10 nested files, the overflow is silently dropped, so raise the cap in the same change rather than assuming coverage; and **the root file is the only guaranteed-first slot**, so a rule guarding data loss, a destructive action, privacy, or spend still belongs here when it must outrank a subtree convention (that is why the backup-exclude anchoring rule above sits in root rather than `server/CLAUDE.md`).### Command Palette & Voice Nav — shared backbonediff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex 9df7485688..d97d497f0d 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -123,14 +123,14 @@ const NESTED_CLAUDE_MD_MAX_DEPTH = 5;const NESTED_CLAUDE_MD_MAX_FILES = 10;const NESTED_CLAUDE_MD_MAX_DIRS = 2000;// Dot-directories are skipped wholesale (covers `.git`), so these are the-// non-dot trees that are either vendored, generated, or runtime state.+// non-dot trees that are either vendored, generated, or runtime state. The list+// is deliberately polyglot: an agent workspace is any app PortOS manages, not+// just this repo, so a Rust `target/` or a Go `vendor/` would otherwise burn the+// directory budget on generated files.const NESTED_CLAUDE_MD_SKIP_DIRS = new Set(['node_modules', 'data', 'data.reference', 'dist', 'build', 'coverage',- 'out', 'venv', '__pycache__',+ 'out', 'obj', 'bin', 'target', 'vendor', 'tmp', 'venv', 'Pods', '__pycache__',]);-// Workspace-relative paths skipped by exact match — `lib/slashdo` is a git-// submodule carrying its own CLAUDE.md that is not this project's instructions.-const NESTED_CLAUDE_MD_SKIP_PATHS = new Set(['lib/slashdo']);/*** Collect workspace-relative paths of nested `CLAUDE.md` files (the root one is@@ -152,6 +152,12 @@ async function findNestedClaudeMdFiles(workspaceDir) {const entries = await readdir(dir, { withFileTypes: true }).catch(() => null);if (!entries) return;+ // A nested directory carrying its own `.git` is a submodule or vendored+ // checkout (`lib/slashdo` here) — its CLAUDE.md is that project's+ // instructions, not this workspace's. Detected structurally rather than by+ // an allowlist of paths, which would silently stop matching the moment the+ // workspace root is something other than this repo's root.+ if (depth > 0 && entries.some((entry) => entry.name === '.git')) return;const sorted = [...entries].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));const subdirs = [];@@ -160,7 +166,6 @@ async function findNestedClaudeMdFiles(workspaceDir) {if (entry.isDirectory()) {if (entry.name.startsWith('.')) continue;if (NESTED_CLAUDE_MD_SKIP_DIRS.has(entry.name)) continue;- if (NESTED_CLAUDE_MD_SKIP_PATHS.has(rel)) continue;subdirs.push({ path: join(dir, entry.name), rel });// Symlinked directories are deliberately NOT followed — a link back up// the tree would loop, and the depth cap alone wouldn't make the resultdiff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex 4f9f0cb26a..a9d7485abd 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -2359,7 +2359,9 @@ describe('getClaudeMdContext — nested CLAUDE.md discovery (#3866)', () => {// Ignored trees: each carries a CLAUDE.md that must NOT be spliced.writeClaudeMd('node_modules/some-dep', '# Vendored dep rules');writeClaudeMd('data/cos/worktrees/claim-issue-1', '# Runtime worktree rules');+ // Submodule / vendored checkout — recognized by its own `.git`, not by path.writeClaudeMd('lib/slashdo', '# Submodule rules');+ writeFileSync(join(workspace, 'lib/slashdo/.git'), 'gitdir: ../../.git/modules/slashdo\n');writeClaudeMd('.hidden', '# Dot dir rules');// Past the depth cap (depth 6): a/b/c/d/e/f/CLAUDE.md.writeClaudeMd('a/b/c/d/e/f', '# Too deep rules');@@ -2400,6 +2402,18 @@ describe('getClaudeMdContext — nested CLAUDE.md discovery (#3866)', () => {expect(section).not.toContain('Too deep rules');});+ it('recognizes a submodule by its own .git, not by a hardcoded path', async () => {+ // `lib/slashdo` above is skipped only because it carries a `.git`. A sibling+ // under the same parent, with no `.git`, must still be spliced — otherwise+ // the skip is really matching `lib/` and the structural check is vacuous.+ writeClaudeMd('lib/inhouse', '# In-house lib rules');+ const section = await getClaudeMdContext(workspace);+ expect(section).toContain('### Project Instructions (lib/inhouse/CLAUDE.md)');+ expect(section).toContain('In-house lib rules');+ expect(section).not.toContain('Submodule rules');+ rmSync(join(workspace, 'lib/inhouse'), { recursive: true, force: true });+ });+it('caps the number of nested files spliced', async () => {const capped = mkdtempSync(join(process.env.TMPDIR || '/tmp', 'portos-nested-claudemd-cap-'));mkdirSync(capped, { recursive: true });