@monoes/monomindcli 2.11.12 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/.claude/skills/mastermind/SKILL.md +1 -15
  2. package/README.md +2 -2
  3. package/dist/src/commands/doctor-env-checks.d.ts +1 -1
  4. package/dist/src/commands/doctor-env-checks.d.ts.map +1 -1
  5. package/dist/src/commands/doctor-env-checks.js +20 -10
  6. package/dist/src/commands/doctor-env-checks.js.map +1 -1
  7. package/dist/src/commands/doctor-monoes-checks.d.ts +1 -0
  8. package/dist/src/commands/doctor-monoes-checks.d.ts.map +1 -1
  9. package/dist/src/commands/doctor-monoes-checks.js +96 -34
  10. package/dist/src/commands/doctor-monoes-checks.js.map +1 -1
  11. package/dist/src/commands/doctor-project-checks.d.ts +19 -0
  12. package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
  13. package/dist/src/commands/doctor-project-checks.js +54 -0
  14. package/dist/src/commands/doctor-project-checks.js.map +1 -1
  15. package/dist/src/commands/doctor.d.ts.map +1 -1
  16. package/dist/src/commands/doctor.js +11 -2
  17. package/dist/src/commands/doctor.js.map +1 -1
  18. package/dist/src/commands/init-upgrade.d.ts.map +1 -1
  19. package/dist/src/commands/init-upgrade.js +1 -1
  20. package/dist/src/commands/init-upgrade.js.map +1 -1
  21. package/dist/src/commands/init.d.ts.map +1 -1
  22. package/dist/src/commands/init.js +12 -0
  23. package/dist/src/commands/init.js.map +1 -1
  24. package/dist/src/commands/org.d.ts.map +1 -1
  25. package/dist/src/commands/org.js +9 -2
  26. package/dist/src/commands/org.js.map +1 -1
  27. package/dist/src/commands/ui.d.ts.map +1 -1
  28. package/dist/src/commands/ui.js +4 -0
  29. package/dist/src/commands/ui.js.map +1 -1
  30. package/dist/src/init/claudemd-generator.d.ts +4 -0
  31. package/dist/src/init/claudemd-generator.d.ts.map +1 -1
  32. package/dist/src/init/claudemd-generator.js +81 -77
  33. package/dist/src/init/claudemd-generator.js.map +1 -1
  34. package/dist/src/init/copy-assets.d.ts.map +1 -1
  35. package/dist/src/init/copy-assets.js +56 -18
  36. package/dist/src/init/copy-assets.js.map +1 -1
  37. package/dist/src/init/executor.d.ts.map +1 -1
  38. package/dist/src/init/executor.js +9 -1
  39. package/dist/src/init/executor.js.map +1 -1
  40. package/dist/src/init/generated-counts.d.ts +8 -0
  41. package/dist/src/init/generated-counts.d.ts.map +1 -0
  42. package/dist/src/init/generated-counts.js +43 -0
  43. package/dist/src/init/generated-counts.js.map +1 -0
  44. package/dist/src/init/mcp-generator.d.ts.map +1 -1
  45. package/dist/src/init/mcp-generator.js +7 -5
  46. package/dist/src/init/mcp-generator.js.map +1 -1
  47. package/dist/src/init/never-commit.d.ts +39 -0
  48. package/dist/src/init/never-commit.d.ts.map +1 -0
  49. package/dist/src/init/never-commit.js +15 -0
  50. package/dist/src/init/never-commit.js.map +1 -0
  51. package/dist/src/init/shared.d.ts +108 -1
  52. package/dist/src/init/shared.d.ts.map +1 -1
  53. package/dist/src/init/shared.js +203 -2
  54. package/dist/src/init/shared.js.map +1 -1
  55. package/dist/src/init/types.d.ts +5 -0
  56. package/dist/src/init/types.d.ts.map +1 -1
  57. package/dist/src/init/upgrade.d.ts.map +1 -1
  58. package/dist/src/init/upgrade.js +62 -10
  59. package/dist/src/init/upgrade.js.map +1 -1
  60. package/dist/src/init/write-capabilities.d.ts.map +1 -1
  61. package/dist/src/init/write-capabilities.js +95 -61
  62. package/dist/src/init/write-capabilities.js.map +1 -1
  63. package/dist/src/init/write-kimicode.d.ts.map +1 -1
  64. package/dist/src/init/write-kimicode.js +13 -9
  65. package/dist/src/init/write-kimicode.js.map +1 -1
  66. package/dist/src/init/write-opencode.d.ts.map +1 -1
  67. package/dist/src/init/write-opencode.js +44 -2
  68. package/dist/src/init/write-opencode.js.map +1 -1
  69. package/dist/src/init/write-runtime-config.d.ts +2 -0
  70. package/dist/src/init/write-runtime-config.d.ts.map +1 -1
  71. package/dist/src/init/write-runtime-config.js +55 -38
  72. package/dist/src/init/write-runtime-config.js.map +1 -1
  73. package/dist/src/mastermind/manifest-data.d.ts.map +1 -1
  74. package/dist/src/mastermind/manifest-data.js +14 -0
  75. package/dist/src/mastermind/manifest-data.js.map +1 -1
  76. package/dist/src/mcp/monoes-mcp-entry.mjs +86 -0
  77. package/dist/src/mcp-tools/guidance-tools.js +1 -1
  78. package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
  79. package/dist/src/mcp-tools/terminal-tools.d.ts.map +1 -1
  80. package/dist/src/mcp-tools/terminal-tools.js +52 -9
  81. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  82. package/dist/src/memory/memory-bridge.d.ts +84 -3
  83. package/dist/src/memory/memory-bridge.d.ts.map +1 -1
  84. package/dist/src/memory/memory-bridge.js +215 -17
  85. package/dist/src/memory/memory-bridge.js.map +1 -1
  86. package/dist/src/orgrt/agent-exec.d.ts.map +1 -1
  87. package/dist/src/orgrt/agent-exec.js +17 -0
  88. package/dist/src/orgrt/agent-exec.js.map +1 -1
  89. package/dist/src/orgrt/agent-runner.d.ts +18 -0
  90. package/dist/src/orgrt/agent-runner.d.ts.map +1 -1
  91. package/dist/src/orgrt/agent-runner.js +20 -1
  92. package/dist/src/orgrt/agent-runner.js.map +1 -1
  93. package/dist/src/orgrt/antigravity-runner.d.ts.map +1 -1
  94. package/dist/src/orgrt/antigravity-runner.js +4 -1
  95. package/dist/src/orgrt/antigravity-runner.js.map +1 -1
  96. package/dist/src/orgrt/codex-runner.d.ts.map +1 -1
  97. package/dist/src/orgrt/codex-runner.js +4 -1
  98. package/dist/src/orgrt/codex-runner.js.map +1 -1
  99. package/dist/src/orgrt/copilot-runner.d.ts.map +1 -1
  100. package/dist/src/orgrt/copilot-runner.js +4 -1
  101. package/dist/src/orgrt/copilot-runner.js.map +1 -1
  102. package/dist/src/orgrt/crush-runner.d.ts.map +1 -1
  103. package/dist/src/orgrt/crush-runner.js +4 -1
  104. package/dist/src/orgrt/crush-runner.js.map +1 -1
  105. package/dist/src/orgrt/forwarder.d.ts.map +1 -1
  106. package/dist/src/orgrt/forwarder.js +5 -0
  107. package/dist/src/orgrt/forwarder.js.map +1 -1
  108. package/dist/src/orgrt/grok-runner.d.ts.map +1 -1
  109. package/dist/src/orgrt/grok-runner.js +4 -1
  110. package/dist/src/orgrt/grok-runner.js.map +1 -1
  111. package/dist/src/orgrt/hermes-runner.d.ts.map +1 -1
  112. package/dist/src/orgrt/hermes-runner.js +4 -1
  113. package/dist/src/orgrt/hermes-runner.js.map +1 -1
  114. package/dist/src/orgrt/kimicode-runner.d.ts.map +1 -1
  115. package/dist/src/orgrt/kimicode-runner.js +4 -1
  116. package/dist/src/orgrt/kimicode-runner.js.map +1 -1
  117. package/dist/src/orgrt/opencode-runner.d.ts.map +1 -1
  118. package/dist/src/orgrt/opencode-runner.js +5 -1
  119. package/dist/src/orgrt/opencode-runner.js.map +1 -1
  120. package/dist/src/orgrt/pi-rpc-runner.d.ts.map +1 -1
  121. package/dist/src/orgrt/pi-rpc-runner.js +9 -1
  122. package/dist/src/orgrt/pi-rpc-runner.js.map +1 -1
  123. package/dist/src/orgrt/pi-runner.d.ts.map +1 -1
  124. package/dist/src/orgrt/pi-runner.js +9 -1
  125. package/dist/src/orgrt/pi-runner.js.map +1 -1
  126. package/dist/src/orgrt/provider.d.ts +14 -0
  127. package/dist/src/orgrt/provider.d.ts.map +1 -1
  128. package/dist/src/orgrt/provider.js +54 -0
  129. package/dist/src/orgrt/provider.js.map +1 -1
  130. package/dist/src/orgrt/qwen-rpc-runner.d.ts.map +1 -1
  131. package/dist/src/orgrt/qwen-rpc-runner.js +4 -1
  132. package/dist/src/orgrt/qwen-rpc-runner.js.map +1 -1
  133. package/dist/src/orgrt/qwen-runner.d.ts.map +1 -1
  134. package/dist/src/orgrt/qwen-runner.js +4 -1
  135. package/dist/src/orgrt/qwen-runner.js.map +1 -1
  136. package/dist/src/orgrt/runner-registry.d.ts.map +1 -1
  137. package/dist/src/orgrt/runner-registry.js +7 -1
  138. package/dist/src/orgrt/runner-registry.js.map +1 -1
  139. package/dist/src/orgrt/tool-providers.d.ts.map +1 -1
  140. package/dist/src/orgrt/tool-providers.js +9 -4
  141. package/dist/src/orgrt/tool-providers.js.map +1 -1
  142. package/dist/src/platform-adapters/renderers/skills.d.ts +0 -6
  143. package/dist/src/platform-adapters/renderers/skills.d.ts.map +1 -1
  144. package/dist/src/platform-adapters/renderers/skills.js +12 -22
  145. package/dist/src/platform-adapters/renderers/skills.js.map +1 -1
  146. package/dist/src/ui/dashboard.html +7 -0
  147. package/dist/src/ui/orgs.html +7 -0
  148. package/dist/src/ui/routes-monoes.mjs +28 -3
  149. package/dist/src/ui/server.mjs +160 -14
  150. package/dist/tsconfig.tsbuildinfo +1 -1
  151. package/package.json +8 -8
@@ -12,18 +12,99 @@
12
12
  export declare function safeParseEmbedding(raw: string | null | undefined): number[] | null;
13
13
  export declare const BRIDGE_EMBEDDING_MODEL = "Alibaba-NLP/gte-modernbert-base";
14
14
  export declare const BRIDGE_EMBEDDING_DIMS = 768;
15
+ export interface ProjectRootResolution {
16
+ root: string;
17
+ /** Why `root` was chosen — for disclosure (doctor, debug logs), not
18
+ * behavior. `explicit-anchor`: MONOMIND_PROJECT_ROOT set and valid.
19
+ * `git`: a `.git` ancestor (any depth) was adopted. `monomind-at-start`:
20
+ * the starting directory itself carries `.monomind` (the user is
21
+ * standing in their own project — always trusted). `monomind-with-marker`:
22
+ * an ancestor's `.monomind` was corroborated by an independent project
23
+ * marker. `start-fallback`: nothing adoptable was found; `root` is
24
+ * `start`. */
25
+ reason: 'explicit-anchor' | 'git' | 'monomind-at-start' | 'monomind-with-marker' | 'start-fallback';
26
+ /** Set only on `start-fallback`: the first bare `.monomind` ancestor that
27
+ * was found but NOT adopted (no independent marker alongside it), so a
28
+ * caller can tell a genuinely ambiguous user why their brain stayed put
29
+ * instead of silently picking a directory that merely looked plausible. */
30
+ ignoredBareMonomind?: string;
31
+ /** Set whenever MONOMIND_PROJECT_ROOT was present in the environment but
32
+ * failed validation — regardless of what `reason`/`root` ended up being,
33
+ * so a typo'd anchor is never silently dropped just because the ordinary
34
+ * walk happened to land somewhere reasonable anyway (o-16 revision 1). */
35
+ invalidAnchor?: {
36
+ value: string;
37
+ problem: string;
38
+ };
39
+ }
40
+ /** The full resolution — root, reason and (when the walk found nothing
41
+ * adoptable) which bare `.monomind` ancestor it ignored. `doctor` uses this
42
+ * to disclose which directory a user's brain is keyed to and why, instead
43
+ * of a plausible-but-silent path (o-16). See `getProjectRoot` for the
44
+ * string-only form the other ~28 call sites use. */
45
+ export declare function getProjectRootResolution(from?: string): ProjectRootResolution;
15
46
  /** The directory that identifies "this project" for every Second Brain store.
16
47
  *
17
48
  * Deliberately NOT the raw cwd: keying on cwd forked the brain per directory —
18
49
  * `doc ingest ./docs` from a package subdir wrote to a different store, and a
19
50
  * different metadata file, than the identical command at the repo root, and
20
51
  * neither could see the other. We walk up to the nearest ancestor carrying a
21
- * `.monomind` or `.git` marker, so every directory inside one project resolves
22
- * to one brain. Nested projects still win (the walk stops at the FIRST marker),
23
- * which keeps worktrees and vendored sub-repos independent.
52
+ * `.git` marker (any depth), or a `.monomind` marker corroborated by an
53
+ * independent project marker, so every directory inside one project resolves
54
+ * to one brain. Nested projects still win (the walk stops at the FIRST
55
+ * eligible marker), which keeps worktrees and vendored sub-repos independent.
56
+ *
57
+ * o-16: a BARE `.monomind` ancestor (no `.git`, no manifest) is NOT adopted.
58
+ * `.monomind` is created by monomind itself as a side effect of running
59
+ * anywhere — it is not independent evidence of a project, and a wrong
60
+ * resolution creates the very marker that would capture every future
61
+ * descendant if it were trusted alone. See `walkToProjectRoot`'s comment for
62
+ * the measured incident this fixes. The starting directory's OWN `.monomind`
63
+ * is still trusted unconditionally — that is the user pointing at their own
64
+ * project — and `.git` at any depth is untouched, so CI/devcontainer repos
65
+ * and subdirectory unification behave exactly as before.
24
66
  *
25
67
  * The walk never crosses the home directory: a dotfiles repo at `~` would
26
68
  * otherwise swallow every loose project underneath it into one shared brain.
69
+ * `MONOMIND_PROJECT_ROOT`, if set AND VALID (absolute, exists, is a
70
+ * directory, is not itself the filesystem root — see `validateAnchor`), is
71
+ * an explicit anchor that skips the walk entirely — the escape hatch for
72
+ * the genuinely ambiguous case (design decision 4 / AC-3c: a real, non-git
73
+ * project whose root has a bare `.monomind` and no manifest has no other
74
+ * way to be found from a subdirectory). An invalid anchor falls through to
75
+ * the walk rather than being adopted OR silently dropped — see
76
+ * `ProjectRootResolution.invalidAnchor`.
77
+ *
78
+ * This is `MONOMIND_PROJECT_ROOT`'s SECOND consumer in this codebase —
79
+ * `mcp-tools/guidance-tools.ts:findProjectRoot()` already reads the same
80
+ * env var, for a DIFFERENT marker (`.claude`, not `.monomind`/`.git`), with
81
+ * a stricter rule: `if (envRoot && existsSync(join(envRoot, '.claude')))`,
82
+ * i.e. it only honors the anchor when `.claude` exists there, silently
83
+ * falling through to its own walk otherwise. After this revision the two
84
+ * converge on ANCHOR HANDLING for the cases that matter most — a typo'd or
85
+ * missing path is rejected by both (this one via `validateAnchor`,
86
+ * guidance-tools' because `.claude` is absent) — but "converge" describes
87
+ * only whether each accepts or rejects the anchor, not the final resolved
88
+ * root: a rejected anchor falls through to each resolver's OWN walk
89
+ * (`walkToProjectRoot` here; guidance-tools' own Strategy 1/2/3 chain
90
+ * there), which can still land on different directories for the same
91
+ * unanchored cwd. Two residual disagreements remain, both legitimate rather
92
+ * than oversights:
93
+ * 1. An anchor that exists and is a real directory but has no `.claude` in
94
+ * it: this function honors it (memory has no reason to require a
95
+ * `.claude` folder — a project's knowledge store isn't gated on whether
96
+ * an agent config lives there), guidance-tools does not (`.claude` is
97
+ * the one thing it's searching FOR, so its absence is a real signal, not
98
+ * noise, for that consumer specifically).
99
+ * 2. A RELATIVE anchor: `validateAnchor` rejects it outright (an anchor
100
+ * that silently depends on cwd defeats the point of an anchor).
101
+ * guidance-tools has no absolute-path check, so `existsSync(join(envRoot,
102
+ * '.claude'))` would resolve a relative `envRoot` against cwd and could
103
+ * accept it — narrower in practice (needs a `.claude` at that resolved
104
+ * location too) but a real gap in the two resolvers' shared assumptions.
105
+ * Reconciling the two resolvers' semantics into one shared rule is a
106
+ * separate, larger question (tracked as o-32), not something this fix
107
+ * should decide as a side effect.
27
108
  *
28
109
  * For anyone who already ran from the project root — the normal case — the
29
110
  * resolved path is identical to before, so their store does not move.
@@ -1 +1 @@
1
- {"version":3,"file":"memory-bridge.d.ts","sourceRoot":"","sources":["../../../src/memory/memory-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA2BH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,EAAE,GAAG,IAAI,CAiBlF;AAID,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AACxE,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAoDzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAE,MAAkD,GAAG,MAAM,CAO/F;AAwBD;;;;wDAIwD;AACxD,wBAAgB,iBAAiB,IAAI,MAAM,CAI1C;AACD,mEAAmE;AACnE,eAAO,MAAM,YAAY,YAAY,CAAC;AAoBtC;+EAC+E;AAC/E,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AA4GD,mFAAmF;AACnF,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAoBD,eAAO,MAAM,qBAAqB,wCAAwC,CAAC;AAE3E,+CAA+C;AAC/C,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAID,wBAAgB,YAAY,IAAI,QAAQ,GAAG,MAAM,GAAG,IAAI,CAEvD;AAKD;;gDAEgD;AAChD,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC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AAG,OAAO,CAAC,GAAG,CAAC,CAMf;AAQD,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAC9C,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,GAAG,CAAC,CAsCf;AAID,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,GAAG,EAAE,CAAC;CAChB,GAAG,OAAO,CAAC,GAAG,CAAC,CA0Bf;AAID,wBAAsB,uBAAuB,CAAC,MAAM,EAAE;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,GAAG,CAAC,CAoBf;AAID,wBAAsB,mBAAmB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAEjF"}
@@ -81,25 +81,137 @@ function capResultContent(content) {
81
81
  // '/x/foo/bar' would both flatten to 'x-foo-bar'). A short readable prefix is
82
82
  // kept purely so the directory name is browsable; only the hash guarantees
83
83
  // uniqueness.
84
+ // o-16: `.git` and `.monomind` are NOT equivalent evidence of a project.
85
+ // `.git` is created by the user, deliberately (`git init`/clone) — "this
86
+ // directory is a repository". `.monomind` is created by monomind ITSELF, as
87
+ // a side effect of running anywhere — "monomind once ran here", and nothing
88
+ // more. Treating a bare `.monomind` ancestor as adoptable is a feedback
89
+ // loop: a wrong resolution creates the very marker that captures every
90
+ // future descendant. Measured against the actual incident:
91
+ // `/home/monoes/mdev-tmp/.monomind` and `/home/monoes/.monomind` both exist,
92
+ // neither has a `.git` or manifest, and neither is a project — both are
93
+ // monomind's own state directories. `INDEPENDENT_PROJECT_MARKERS` (other
94
+ // than `.git`, handled unconditionally) is what makes a `.monomind`
95
+ // ancestor's claim independently checkable.
96
+ const INDEPENDENT_PROJECT_MARKERS = ['package.json', 'pyproject.toml', 'go.mod', 'Cargo.toml'];
97
+ function markerExists(p) {
98
+ try {
99
+ return fs.existsSync(p);
100
+ }
101
+ catch (e) {
102
+ logBridgeError('walkToProjectRoot', e); /* unreadable dir — treat as absent, keep walking */
103
+ return false;
104
+ }
105
+ }
106
+ /** o-16 revision 1 (reviewer MAJOR 1, measured not argued): the anchor used
107
+ * to be trusted unconditionally. Two proven harms: (a) a non-existent path
108
+ * (a typo) was adopted as-is, and `projectDataDir()` hashed it into a
109
+ * fresh, empty store directory — the exact split-store failure this item
110
+ * exists to eliminate, reintroduced by the escape hatch meant to fix it.
111
+ * (b) `MONOMIND_PROJECT_ROOT=/` disabled `getDbPath`'s MCP path-traversal
112
+ * guard entirely: the guard is `path.relative(getProjectRoot(), resolved)`
113
+ * not starting with `..`, and `path.relative('/', anything)` never does.
114
+ * `existsSync` + `isDirectory` alone catch (a) but NOT (b) — `/` exists and
115
+ * is a directory — so the filesystem-root check below is what closes (b)
116
+ * specifically; it is not redundant with the others. An invalid anchor is
117
+ * never silently accepted OR silently dropped: the caller falls through to
118
+ * the ordinary walk, and the fact that an anchor was set and rejected is
119
+ * preserved on the result (`invalidAnchor`) so `doctor` can say exactly
120
+ * what happened instead of the user just seeing an unexplained directory. */
121
+ function validateAnchor(raw) {
122
+ if (!path.isAbsolute(raw))
123
+ return { ok: false, problem: 'not an absolute path' };
124
+ const lexical = path.resolve(raw);
125
+ // o-16 revision 2 (reviewer MAJOR): resolve symlinks BEFORE validating,
126
+ // and return the REAL path, not the lexical one. Without this, a symlink
127
+ // whose real target is '/' (e.g. MONOMIND_PROJECT_ROOT=<tmp>/link-to-root)
128
+ // passes every check below on its lexical form — dirname(lexical) !==
129
+ // lexical, since the link itself sits inside a normal directory — while
130
+ // getDbPath's traversal guard (memory-bridge.ts's realOrResolved(), i.e.
131
+ // fs.realpathSync) resolves the SAME anchor to '/' downstream. Two
132
+ // notions of "the root" in one module: the store gets hashed from the
133
+ // lexical path this function returned, the guard's boundary is computed
134
+ // from the real one, and path.relative('/', anything) never starts with
135
+ // '..' — the exact guard-disabling hole this function exists to close,
136
+ // reopened one indirection away. Validating and returning the SAME (real)
137
+ // path is what makes validation and consumption agree, for any
138
+ // symlinked anchor, not just a literal '/'.
139
+ let real;
140
+ try {
141
+ real = fs.realpathSync(lexical);
142
+ }
143
+ catch {
144
+ return { ok: false, problem: 'does not exist' };
145
+ }
146
+ let stat;
147
+ try {
148
+ stat = fs.statSync(real);
149
+ }
150
+ catch {
151
+ return { ok: false, problem: 'does not exist' };
152
+ }
153
+ if (!stat.isDirectory())
154
+ return { ok: false, problem: 'is not a directory' };
155
+ if (path.dirname(real) === real) {
156
+ return {
157
+ ok: false,
158
+ problem: 'is the filesystem root, which would disable the MCP path-traversal guard',
159
+ };
160
+ }
161
+ return { ok: true, resolved: real };
162
+ }
84
163
  function walkToProjectRoot(start) {
164
+ // Explicit escape hatch: honored ahead of any walk, but only once valid —
165
+ // see validateAnchor's comment for why unconditional trust was wrong.
166
+ const anchorRaw = process.env.MONOMIND_PROJECT_ROOT;
167
+ let invalidAnchor;
168
+ if (anchorRaw) {
169
+ const check = validateAnchor(anchorRaw);
170
+ if (check.ok)
171
+ return { root: check.resolved, reason: 'explicit-anchor' };
172
+ invalidAnchor = { value: anchorRaw, problem: check.problem };
173
+ logBridgeError('walkToProjectRoot', new Error(`MONOMIND_PROJECT_ROOT ignored: "${anchorRaw}" ${check.problem} — falling back to the walk`));
174
+ }
175
+ // Retained from before o-16: protects the dotfiles-repo-at-$HOME case (a
176
+ // `.git` at $HOME must not swallow every loose project underneath it).
177
+ // Insufficient ALONE against the reported incident — that marker sat
178
+ // *inside* $HOME, so the walk reached it long before ever reaching home —
179
+ // which is why it is additive to, not a replacement for, the rule below.
85
180
  const home = path.resolve(os.homedir());
86
181
  let dir = start;
182
+ let ignoredBareMonomind;
183
+ let atStart = true;
87
184
  for (;;) {
88
185
  if (dir === home)
89
186
  break;
90
- try {
91
- if (fs.existsSync(path.join(dir, '.monomind')) || fs.existsSync(path.join(dir, '.git')))
92
- return dir;
93
- }
94
- catch (e) {
95
- logBridgeError('walkToProjectRoot', e); /* unreadable dir — keep walking */
187
+ if (markerExists(path.join(dir, '.git')))
188
+ return { root: dir, reason: 'git', invalidAnchor };
189
+ if (markerExists(path.join(dir, '.monomind'))) {
190
+ if (atStart)
191
+ return { root: dir, reason: 'monomind-at-start', invalidAnchor };
192
+ const corroborated = INDEPENDENT_PROJECT_MARKERS.some((m) => markerExists(path.join(dir, m)));
193
+ if (corroborated)
194
+ return { root: dir, reason: 'monomind-with-marker', invalidAnchor };
195
+ // The nearest marker found doesn't qualify — stop HERE. Continuing
196
+ // past it to adopt some more distant, unrelated ancestor's `.git`
197
+ // would break "nested projects keep their own brain" in a new way:
198
+ // a vendored sub-repo with only a bare `.monomind` would get silently
199
+ // merged into whatever repo happens to sit further up, which the
200
+ // original nearest-marker-wins design specifically existed to
201
+ // prevent. Not adopting is the fallback; walking past is not.
202
+ ignoredBareMonomind = dir;
203
+ break;
96
204
  }
205
+ atStart = false;
97
206
  const parent = path.dirname(dir);
98
207
  if (parent === dir)
99
208
  break;
100
209
  dir = parent;
101
210
  }
102
- return start;
211
+ if (ignoredBareMonomind !== undefined) {
212
+ logBridgeError('walkToProjectRoot', new Error(`bare .monomind ancestor ignored at ${ignoredBareMonomind} (no independent project marker) — using ${start}`));
213
+ }
214
+ return { root: start, reason: 'start-fallback', ignoredBareMonomind, invalidAnchor };
103
215
  }
104
216
  // getBackend() resolves the store path on every store/search, so a bulk ingest
105
217
  // would otherwise repeat the stat walk thousands of times. A project does not
@@ -107,18 +219,88 @@ function walkToProjectRoot(start) {
107
219
  // chdir still re-resolves.
108
220
  let _rootCacheKey;
109
221
  let _rootCacheVal;
222
+ /** The full resolution — root, reason and (when the walk found nothing
223
+ * adoptable) which bare `.monomind` ancestor it ignored. `doctor` uses this
224
+ * to disclose which directory a user's brain is keyed to and why, instead
225
+ * of a plausible-but-silent path (o-16). See `getProjectRoot` for the
226
+ * string-only form the other ~28 call sites use. */
227
+ export function getProjectRootResolution(from = process.env.MONOMIND_CWD || process.cwd()) {
228
+ const start = path.resolve(from);
229
+ // Cache key must cover everything walkToProjectRoot's result depends on,
230
+ // not just `start` — MONOMIND_PROJECT_ROOT short-circuits the walk (o-16),
231
+ // so a cache keyed on `start` alone would replay a stale pre-anchor (or
232
+ // stale different-anchor) result for the same cwd once the env var changes
233
+ // mid-process, silently defeating the escape hatch it's supposed to be.
234
+ const cacheKey = `${start}\n${process.env.MONOMIND_PROJECT_ROOT ?? ''}`;
235
+ if (cacheKey === _rootCacheKey && _rootCacheVal !== undefined)
236
+ return _rootCacheVal;
237
+ const resolved = walkToProjectRoot(start);
238
+ _rootCacheKey = cacheKey;
239
+ _rootCacheVal = resolved;
240
+ return resolved;
241
+ }
110
242
  /** The directory that identifies "this project" for every Second Brain store.
111
243
  *
112
244
  * Deliberately NOT the raw cwd: keying on cwd forked the brain per directory —
113
245
  * `doc ingest ./docs` from a package subdir wrote to a different store, and a
114
246
  * different metadata file, than the identical command at the repo root, and
115
247
  * neither could see the other. We walk up to the nearest ancestor carrying a
116
- * `.monomind` or `.git` marker, so every directory inside one project resolves
117
- * to one brain. Nested projects still win (the walk stops at the FIRST marker),
118
- * which keeps worktrees and vendored sub-repos independent.
248
+ * `.git` marker (any depth), or a `.monomind` marker corroborated by an
249
+ * independent project marker, so every directory inside one project resolves
250
+ * to one brain. Nested projects still win (the walk stops at the FIRST
251
+ * eligible marker), which keeps worktrees and vendored sub-repos independent.
252
+ *
253
+ * o-16: a BARE `.monomind` ancestor (no `.git`, no manifest) is NOT adopted.
254
+ * `.monomind` is created by monomind itself as a side effect of running
255
+ * anywhere — it is not independent evidence of a project, and a wrong
256
+ * resolution creates the very marker that would capture every future
257
+ * descendant if it were trusted alone. See `walkToProjectRoot`'s comment for
258
+ * the measured incident this fixes. The starting directory's OWN `.monomind`
259
+ * is still trusted unconditionally — that is the user pointing at their own
260
+ * project — and `.git` at any depth is untouched, so CI/devcontainer repos
261
+ * and subdirectory unification behave exactly as before.
119
262
  *
120
263
  * The walk never crosses the home directory: a dotfiles repo at `~` would
121
264
  * otherwise swallow every loose project underneath it into one shared brain.
265
+ * `MONOMIND_PROJECT_ROOT`, if set AND VALID (absolute, exists, is a
266
+ * directory, is not itself the filesystem root — see `validateAnchor`), is
267
+ * an explicit anchor that skips the walk entirely — the escape hatch for
268
+ * the genuinely ambiguous case (design decision 4 / AC-3c: a real, non-git
269
+ * project whose root has a bare `.monomind` and no manifest has no other
270
+ * way to be found from a subdirectory). An invalid anchor falls through to
271
+ * the walk rather than being adopted OR silently dropped — see
272
+ * `ProjectRootResolution.invalidAnchor`.
273
+ *
274
+ * This is `MONOMIND_PROJECT_ROOT`'s SECOND consumer in this codebase —
275
+ * `mcp-tools/guidance-tools.ts:findProjectRoot()` already reads the same
276
+ * env var, for a DIFFERENT marker (`.claude`, not `.monomind`/`.git`), with
277
+ * a stricter rule: `if (envRoot && existsSync(join(envRoot, '.claude')))`,
278
+ * i.e. it only honors the anchor when `.claude` exists there, silently
279
+ * falling through to its own walk otherwise. After this revision the two
280
+ * converge on ANCHOR HANDLING for the cases that matter most — a typo'd or
281
+ * missing path is rejected by both (this one via `validateAnchor`,
282
+ * guidance-tools' because `.claude` is absent) — but "converge" describes
283
+ * only whether each accepts or rejects the anchor, not the final resolved
284
+ * root: a rejected anchor falls through to each resolver's OWN walk
285
+ * (`walkToProjectRoot` here; guidance-tools' own Strategy 1/2/3 chain
286
+ * there), which can still land on different directories for the same
287
+ * unanchored cwd. Two residual disagreements remain, both legitimate rather
288
+ * than oversights:
289
+ * 1. An anchor that exists and is a real directory but has no `.claude` in
290
+ * it: this function honors it (memory has no reason to require a
291
+ * `.claude` folder — a project's knowledge store isn't gated on whether
292
+ * an agent config lives there), guidance-tools does not (`.claude` is
293
+ * the one thing it's searching FOR, so its absence is a real signal, not
294
+ * noise, for that consumer specifically).
295
+ * 2. A RELATIVE anchor: `validateAnchor` rejects it outright (an anchor
296
+ * that silently depends on cwd defeats the point of an anchor).
297
+ * guidance-tools has no absolute-path check, so `existsSync(join(envRoot,
298
+ * '.claude'))` would resolve a relative `envRoot` against cwd and could
299
+ * accept it — narrower in practice (needs a `.claude` at that resolved
300
+ * location too) but a real gap in the two resolvers' shared assumptions.
301
+ * Reconciling the two resolvers' semantics into one shared rule is a
302
+ * separate, larger question (tracked as o-32), not something this fix
303
+ * should decide as a side effect.
122
304
  *
123
305
  * For anyone who already ran from the project root — the normal case — the
124
306
  * resolved path is identical to before, so their store does not move.
@@ -130,13 +312,7 @@ let _rootCacheVal;
130
312
  * node builtins only (see the static import in document-pipeline.ts).
131
313
  */
132
314
  export function getProjectRoot(from = process.env.MONOMIND_CWD || process.cwd()) {
133
- const start = path.resolve(from);
134
- if (start === _rootCacheKey && _rootCacheVal !== undefined)
135
- return _rootCacheVal;
136
- const resolved = walkToProjectRoot(start);
137
- _rootCacheKey = start;
138
- _rootCacheVal = resolved;
139
- return resolved;
315
+ return getProjectRootResolution(from).root;
140
316
  }
141
317
  function projectDataDir() {
142
318
  const resolved = path.resolve(getProjectRoot());
@@ -180,6 +356,28 @@ function getDbPath(customPath) {
180
356
  const resolved = realOrResolved(path.resolve(customPath));
181
357
  // Guard against path traversal from MCP inputs: only allow paths inside the
182
358
  // project, the per-project home data dir, or the global brain.
359
+ //
360
+ // STATED LIMIT (o-16 revision 2, corrected in revision 3 — verifier found
361
+ // the first version of this comment named the wrong path): `validateAnchor`
362
+ // resolves a `MONOMIND_PROJECT_ROOT` anchor to its REAL path ONCE via
363
+ // `fs.realpathSync`, and caches THAT REAL PATH STRING in `_rootCacheVal`
364
+ // (see above) — `getProjectRoot()` returns this cached real-path string on
365
+ // every subsequent call in this process; it does not re-read the anchor
366
+ // or re-run `validateAnchor`. So swapping the filesystem entry AT THE
367
+ // ANCHOR PATH after validation does nothing — the anchor itself is never
368
+ // consulted again. The actual gap is one level further in: the line below
369
+ // calls `realOrResolved()` (a fresh `fs.realpathSync`) on that cached
370
+ // REAL-PATH STRING every time `getDbPath` runs. If the filesystem entry
371
+ // AT THAT RESOLVED TARGET (not the anchor) is swapped for a symlink to
372
+ // `/` after validation but before a later call here, this re-resolves to
373
+ // the new real target live, and the guard is bypassed for that call — a
374
+ // TOCTOU gap between a one-time resolution and a re-resolved-every-call
375
+ // consumption of the same path string. NOT defended against: closing it
376
+ // properly means validating and consuming a single resolved handle rather
377
+ // than a path string, which is a real design change and out of scope for
378
+ // this fix. Accepted because it needs filesystem write access at the
379
+ // resolved target's path, timed against a live process — an attacker
380
+ // with that capability already has easier routes than this guard.
183
381
  const relCwd = path.relative(realOrResolved(getProjectRoot()), resolved);
184
382
  const relHome = path.relative(realOrResolved(projectDataDir()), resolved);
185
383
  const relGlobal = path.relative(realOrResolved(getGlobalBrainDir()), resolved);