@blackbelt-technology/pi-dashboard-extension 0.5.3 → 0.6.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 (258) hide show
  1. package/.pi/skills/browser/LICENSE +201 -0
  2. package/.pi/skills/browser/SKILL.md +105 -0
  3. package/.pi/skills/browser/UPSTREAM.md +46 -0
  4. package/.pi/skills/browser/references/electron.md +351 -0
  5. package/.pi/skills/browser/references/web.md +2789 -0
  6. package/.pi/skills/browser/scripts/detect-dashboard.sh +55 -0
  7. package/.pi/skills/doctor/AGENTS.md +27 -0
  8. package/.pi/skills/doctor/SKILL.md +89 -0
  9. package/.pi/skills/doctor/_lib/checks.ts +177 -0
  10. package/.pi/skills/doctor/_lib/derive-tokens.ts +43 -0
  11. package/.pi/skills/doctor/_lib/front-matter.ts +122 -0
  12. package/.pi/skills/doctor/_lib/index.ts +14 -0
  13. package/.pi/skills/doctor/_lib/knowledge-hash.ts +74 -0
  14. package/.pi/skills/doctor/_lib/provenance.ts +50 -0
  15. package/.pi/skills/doctor/_lib/regenerate.ts +100 -0
  16. package/.pi/skills/doctor/_lib/router.ts +155 -0
  17. package/.pi/skills/doctor/_lib/server-tier.ts +62 -0
  18. package/.pi/skills/doctor/modules/build-reload.knowledge.hash +1 -0
  19. package/.pi/skills/doctor/modules/build-reload.md +51 -0
  20. package/.pi/skills/doctor/modules/env-node.knowledge.hash +1 -0
  21. package/.pi/skills/doctor/modules/env-node.md +49 -0
  22. package/.pi/skills/doctor/modules/install-topology.knowledge.hash +1 -0
  23. package/.pi/skills/doctor/modules/install-topology.md +53 -0
  24. package/.pi/skills/doctor/modules/model-resolution.knowledge.hash +1 -0
  25. package/.pi/skills/doctor/modules/model-resolution.md +53 -0
  26. package/.pi/skills/doctor/modules/peers.knowledge.hash +1 -0
  27. package/.pi/skills/doctor/modules/peers.md +57 -0
  28. package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -0
  29. package/.pi/skills/doctor/modules/pi-resolution.md +60 -0
  30. package/.pi/skills/doctor/modules/plugins-bridges.knowledge.hash +1 -0
  31. package/.pi/skills/doctor/modules/plugins-bridges.md +56 -0
  32. package/.pi/skills/pi-dashboard/SKILL.md +68 -0
  33. package/.pi/skills/pi-dashboard/commands/README.md +45 -0
  34. package/.pi/skills/pi-dashboard/commands/dashboard-flow-abort.md +10 -0
  35. package/.pi/skills/pi-dashboard/commands/dashboard-flow-auto.md +10 -0
  36. package/.pi/skills/pi-dashboard/commands/dashboard-git-branches.md +6 -0
  37. package/.pi/skills/pi-dashboard/commands/dashboard-git-init.md +8 -0
  38. package/.pi/skills/pi-dashboard/commands/dashboard-git-stash-pop.md +8 -0
  39. package/.pi/skills/pi-dashboard/commands/dashboard-list-models.md +10 -0
  40. package/.pi/skills/pi-dashboard/commands/dashboard-peer-list.md +6 -0
  41. package/.pi/skills/pi-dashboard/commands/dashboard-peer-scan.md +6 -0
  42. package/.pi/skills/pi-dashboard/commands/dashboard-pin-list.md +5 -0
  43. package/.pi/skills/pi-dashboard/commands/dashboard-proposal-archive.md +6 -0
  44. package/.pi/skills/pi-dashboard/commands/dashboard-proposal-attach.md +10 -0
  45. package/.pi/skills/pi-dashboard/commands/dashboard-proposal-detach.md +10 -0
  46. package/.pi/skills/pi-dashboard/commands/dashboard-server-config.md +5 -0
  47. package/.pi/skills/pi-dashboard/commands/dashboard-server-health.md +6 -0
  48. package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-off.md +6 -0
  49. package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-on.md +6 -0
  50. package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-status.md +6 -0
  51. package/.pi/skills/pi-dashboard/commands/dashboard-session-abort-all.md +14 -0
  52. package/.pi/skills/pi-dashboard/commands/dashboard-session-abort.md +10 -0
  53. package/.pi/skills/pi-dashboard/commands/dashboard-session-diff.md +11 -0
  54. package/.pi/skills/pi-dashboard/commands/dashboard-session-fork.md +10 -0
  55. package/.pi/skills/pi-dashboard/commands/dashboard-session-hide.md +10 -0
  56. package/.pi/skills/pi-dashboard/commands/dashboard-session-info.md +11 -0
  57. package/.pi/skills/pi-dashboard/commands/dashboard-session-kill.md +10 -0
  58. package/.pi/skills/pi-dashboard/commands/dashboard-session-list-active.md +8 -0
  59. package/.pi/skills/pi-dashboard/commands/dashboard-session-list-here.md +8 -0
  60. package/.pi/skills/pi-dashboard/commands/dashboard-session-list.md +6 -0
  61. package/.pi/skills/pi-dashboard/commands/dashboard-session-model.md +10 -0
  62. package/.pi/skills/pi-dashboard/commands/dashboard-session-rename.md +10 -0
  63. package/.pi/skills/pi-dashboard/commands/dashboard-session-resume.md +10 -0
  64. package/.pi/skills/pi-dashboard/commands/dashboard-session-spawn.md +10 -0
  65. package/.pi/skills/pi-dashboard/commands/dashboard-session-tell.md +10 -0
  66. package/.pi/skills/pi-dashboard/commands/dashboard-session-thinking.md +10 -0
  67. package/.pi/skills/pi-dashboard/commands/dashboard-session-unhide.md +10 -0
  68. package/.pi/skills/pi-dashboard/references/api-reference.md +30 -0
  69. package/.pi/skills/pi-dashboard/references/recipes.md +38 -0
  70. package/.pi/skills/pi-dashboard/references/slash-commands.md +71 -0
  71. package/.pi/skills/pi-dashboard/scripts/dashboard-api.sh +6 -0
  72. package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +217 -0
  73. package/.pi/skills/project-init/SKILL.md +279 -0
  74. package/.pi/skills/project-init/dox-doctrine.md +104 -0
  75. package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +111 -0
  76. package/.pi/skills/project-init/profiles/coding/profile.json +5 -0
  77. package/.pi/skills/project-init/profiles/coding/prompts/plan-change.md +5 -0
  78. package/.pi/skills/project-init/profiles/coding/prompts/tdd-loop.md +6 -0
  79. package/.pi/skills/project-init/profiles/coding/settings.json.tmpl +9 -0
  80. package/.pi/skills/project-init/profiles/docs/AGENTS.md.tmpl +37 -0
  81. package/.pi/skills/project-init/profiles/docs/profile.json +4 -0
  82. package/.pi/skills/project-init/profiles/docs/prompts/draft-page.md +5 -0
  83. package/.pi/skills/project-init/profiles/docs/settings.json.tmpl +9 -0
  84. package/package.json +12 -4
  85. package/src/AGENTS.md +56 -0
  86. package/src/__tests__/abort-latch.test.ts +97 -0
  87. package/src/__tests__/agent-settled.test.ts +82 -0
  88. package/src/__tests__/artifact-roots.test.ts +83 -0
  89. package/src/__tests__/ask-user-attachments.test.ts +106 -0
  90. package/src/__tests__/ask-user-tool.test.ts +90 -27
  91. package/src/__tests__/auto-session-namer.test.ts +339 -0
  92. package/src/__tests__/bridge-default-model-apply.test.ts +242 -0
  93. package/src/__tests__/bridge-default-model-gate.test.ts +50 -0
  94. package/src/__tests__/bridge-followup-chat-order.test.ts +215 -0
  95. package/src/__tests__/bridge-followup-multi-entry.test.ts +202 -0
  96. package/src/__tests__/bridge-followup-mutation.test.ts +217 -0
  97. package/src/__tests__/bridge-followup-queue-drain.test.ts +266 -0
  98. package/src/__tests__/bridge-hasui-flip.test.ts +109 -0
  99. package/src/__tests__/bridge-no-queue-mutation.test.ts +112 -0
  100. package/src/__tests__/bridge-plugin-emit-event.test.ts +44 -0
  101. package/src/__tests__/bridge-queue-update-forward.test.ts +77 -0
  102. package/src/__tests__/bridge-shadow-queue-gate.test.ts +299 -0
  103. package/src/__tests__/bridge-shutdown-reset.test.ts +159 -0
  104. package/src/__tests__/bridge-slash-command-routing.test.ts +127 -31
  105. package/src/__tests__/bridge-stop-after-turn.test.ts +72 -0
  106. package/src/__tests__/bridge-system-followup.test.ts +163 -0
  107. package/src/__tests__/bridge-thinking-level-select.test.ts +68 -0
  108. package/src/__tests__/browser-skill-registered.test.ts +84 -0
  109. package/src/__tests__/build-provider-catalogue.test.ts +35 -1
  110. package/src/__tests__/command-handler.test.ts +427 -29
  111. package/src/__tests__/commit-draft.test.ts +100 -0
  112. package/src/__tests__/connection-dropped-frames.test.ts +78 -0
  113. package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +128 -0
  114. package/src/__tests__/cwd-missing-probe.test.ts +82 -0
  115. package/src/__tests__/dashboard-commands-shipped.test.ts +53 -0
  116. package/src/__tests__/dashboard-context-injector.test.ts +190 -0
  117. package/src/__tests__/doctor/checks.test.ts +121 -0
  118. package/src/__tests__/doctor/modules.test.ts +64 -0
  119. package/src/__tests__/doctor/provenance-hash.test.ts +94 -0
  120. package/src/__tests__/doctor/router.test.ts +143 -0
  121. package/src/__tests__/empty-actionable-guard-config.test.ts +32 -0
  122. package/src/__tests__/empty-actionable-guard.test.ts +73 -0
  123. package/src/__tests__/enrich-model-metadata.test.ts +21 -0
  124. package/src/__tests__/extension-slash-command-detection.test.ts +37 -1
  125. package/src/__tests__/filter-enabled-models.test.ts +151 -0
  126. package/src/__tests__/fixtures/turn-actionability-fixtures.ts +69 -0
  127. package/src/__tests__/git-info-status.test.ts +73 -0
  128. package/src/__tests__/git-poll.test.ts +69 -0
  129. package/src/__tests__/markdown-image-inliner.test.ts +37 -0
  130. package/src/__tests__/model-resolve.test.ts +379 -0
  131. package/src/__tests__/pi-version-tracker.test.ts +109 -0
  132. package/src/__tests__/process-scanner.test.ts +112 -22
  133. package/src/__tests__/project-init-detect-stack.test.ts +61 -0
  134. package/src/__tests__/project-init-dox-kb-config.test.ts +53 -0
  135. package/src/__tests__/project-init-profiles.test.ts +84 -0
  136. package/src/__tests__/project-init-scaffold.test.ts +139 -0
  137. package/src/__tests__/project-init-seed-doctrine.test.ts +100 -0
  138. package/src/__tests__/project-trust.test.ts +92 -0
  139. package/src/__tests__/prompt-expander.test.ts +191 -1
  140. package/src/__tests__/provider-register-reload.test.ts +36 -6
  141. package/src/__tests__/provider-register-thinking-levels.test.ts +51 -0
  142. package/src/__tests__/retry-tracker.test.ts +75 -70
  143. package/src/__tests__/role-manager.test.ts +585 -0
  144. package/src/__tests__/role-model-tools-registry-readiness.test.ts +114 -0
  145. package/src/__tests__/role-model-tools.test.ts +229 -0
  146. package/src/__tests__/search-files-completeness.test.ts +111 -0
  147. package/src/__tests__/search-files-ranking.test.ts +168 -0
  148. package/src/__tests__/server-auto-start.test.ts +121 -4
  149. package/src/__tests__/server-launcher-launch.test.ts +24 -6
  150. package/src/__tests__/server-launcher.test.ts +19 -2
  151. package/src/__tests__/session-sync.test.ts +36 -0
  152. package/src/__tests__/source-detector.test.ts +15 -0
  153. package/src/__tests__/subagent-frame-buffer.test.ts +239 -0
  154. package/src/__tests__/tool-result-image-inliner.test.ts +206 -0
  155. package/src/__tests__/tui-prompt-adapter.test.ts +70 -64
  156. package/src/__tests__/turn-actionability.test.ts +86 -0
  157. package/src/__tests__/vcs-info.test.ts +145 -4
  158. package/src/__tests__/visibility-intent.test.ts +43 -0
  159. package/src/abort-latch.ts +55 -0
  160. package/src/abort-latch.ts.AGENTS.md +3 -0
  161. package/src/agent-settled.ts +72 -0
  162. package/src/agent-settled.ts.AGENTS.md +3 -0
  163. package/src/artifact-roots.ts +73 -0
  164. package/src/artifact-roots.ts.AGENTS.md +3 -0
  165. package/src/ask-user-attachments.ts +121 -0
  166. package/src/ask-user-attachments.ts.AGENTS.md +3 -0
  167. package/src/ask-user-tool.ts +56 -58
  168. package/src/ask-user-tool.ts.AGENTS.md +3 -0
  169. package/src/auto-session-namer.ts +334 -0
  170. package/src/auto-session-namer.ts.AGENTS.md +3 -0
  171. package/src/bridge-context.ts +86 -8
  172. package/src/bridge-context.ts.AGENTS.md +3 -0
  173. package/src/bridge-default-model-gate.ts +48 -0
  174. package/src/bridge-default-model-gate.ts.AGENTS.md +3 -0
  175. package/src/bridge.ts +1373 -213
  176. package/src/bridge.ts.AGENTS.md +3 -0
  177. package/src/canvas-tool.ts +107 -0
  178. package/src/command-handler.ts +527 -42
  179. package/src/command-handler.ts.AGENTS.md +3 -0
  180. package/src/commit-draft-agent.ts +114 -0
  181. package/src/commit-draft-agent.ts.AGENTS.md +3 -0
  182. package/src/commit-draft.ts +136 -0
  183. package/src/commit-draft.ts.AGENTS.md +3 -0
  184. package/src/connection.ts +32 -1
  185. package/src/connection.ts.AGENTS.md +3 -0
  186. package/src/dashboard-context-injector.ts +124 -0
  187. package/src/dashboard-context-injector.ts.AGENTS.md +3 -0
  188. package/src/dashboard-default-adapter.ts +5 -0
  189. package/src/dashboard-default-adapter.ts.AGENTS.md +3 -0
  190. package/src/dev-build.ts.AGENTS.md +3 -0
  191. package/src/empty-actionable-guard-config.ts +32 -0
  192. package/src/empty-actionable-guard-config.ts.AGENTS.md +3 -0
  193. package/src/empty-actionable-guard.ts +90 -0
  194. package/src/empty-actionable-guard.ts.AGENTS.md +3 -0
  195. package/src/event-forwarder.ts.AGENTS.md +3 -0
  196. package/src/flow-event-wiring.ts +4 -14
  197. package/src/flow-event-wiring.ts.AGENTS.md +3 -0
  198. package/src/git-link-builder.ts.AGENTS.md +3 -0
  199. package/src/git-poll.ts +38 -0
  200. package/src/git-poll.ts.AGENTS.md +3 -0
  201. package/src/hasui-flip.ts +56 -0
  202. package/src/hasui-flip.ts.AGENTS.md +3 -0
  203. package/src/markdown-image-inliner.ts +45 -2
  204. package/src/markdown-image-inliner.ts.AGENTS.md +3 -0
  205. package/src/model-tracker.ts +145 -19
  206. package/src/model-tracker.ts.AGENTS.md +3 -0
  207. package/src/multiselect-decode.ts.AGENTS.md +3 -0
  208. package/src/multiselect-list.ts.AGENTS.md +3 -0
  209. package/src/multiselect-polyfill.ts.AGENTS.md +3 -0
  210. package/src/process-metrics.ts.AGENTS.md +3 -0
  211. package/src/process-scanner.ts +114 -103
  212. package/src/process-scanner.ts.AGENTS.md +3 -0
  213. package/src/project-init/AGENTS.md +12 -0
  214. package/src/project-init/detect-stack.ts +146 -0
  215. package/src/project-init/dox-kb-config.ts +47 -0
  216. package/src/project-init/profiles.ts +135 -0
  217. package/src/project-init/scaffold.ts +192 -0
  218. package/src/project-init/seed-doctrine.ts +95 -0
  219. package/src/project-trust.ts +63 -0
  220. package/src/project-trust.ts.AGENTS.md +3 -0
  221. package/src/prompt-bus.ts +25 -1
  222. package/src/prompt-bus.ts.AGENTS.md +3 -0
  223. package/src/prompt-expander.ts +238 -37
  224. package/src/prompt-expander.ts.AGENTS.md +3 -0
  225. package/src/provider-register.ts +323 -54
  226. package/src/provider-register.ts.AGENTS.md +3 -0
  227. package/src/retry-tracker.ts +64 -39
  228. package/src/retry-tracker.ts.AGENTS.md +3 -0
  229. package/src/role-manager.ts +436 -0
  230. package/src/role-manager.ts.AGENTS.md +3 -0
  231. package/src/role-model-tools.ts +301 -0
  232. package/src/role-model-tools.ts.AGENTS.md +3 -0
  233. package/src/server-auto-start.ts +59 -23
  234. package/src/server-auto-start.ts.AGENTS.md +3 -0
  235. package/src/server-launcher.ts +56 -16
  236. package/src/server-launcher.ts.AGENTS.md +3 -0
  237. package/src/session-sync.ts +111 -15
  238. package/src/session-sync.ts.AGENTS.md +3 -0
  239. package/src/slash-dispatch.ts +32 -15
  240. package/src/slash-dispatch.ts.AGENTS.md +3 -0
  241. package/src/source-detector.ts +13 -5
  242. package/src/source-detector.ts.AGENTS.md +3 -0
  243. package/src/subagent-frame-buffer.ts +220 -0
  244. package/src/subagent-frame-buffer.ts.AGENTS.md +3 -0
  245. package/src/tool-result-image-inliner.ts +204 -0
  246. package/src/tool-result-image-inliner.ts.AGENTS.md +3 -0
  247. package/src/tui-prompt-adapter.ts +123 -0
  248. package/src/tui-prompt-adapter.ts.AGENTS.md +3 -0
  249. package/src/turn-actionability.ts +117 -0
  250. package/src/turn-actionability.ts.AGENTS.md +3 -0
  251. package/src/ui-modules.ts.AGENTS.md +3 -0
  252. package/src/vcs-info.ts +91 -129
  253. package/src/vcs-info.ts.AGENTS.md +3 -0
  254. package/src/visibility-intent.ts +34 -0
  255. package/src/visibility-intent.ts.AGENTS.md +3 -0
  256. package/src/__tests__/usage-limit-orderer.test.ts +0 -105
  257. package/src/__tests__/vcs-info-jj.test.ts +0 -145
  258. package/src/usage-limit-orderer.ts +0 -76
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Regenerate / drift-check the per-module `<id>.knowledge.hash` sidecars.
3
+ *
4
+ * Usage (from the doctor skill dir):
5
+ * tsx _lib/regenerate.ts --check # report drift for every module
6
+ * tsx _lib/regenerate.ts --write # (re)write every sidecar
7
+ * tsx _lib/regenerate.ts --write <module> # rewrite one module's sidecar
8
+ *
9
+ * `--write` reconciles the DERIVED tables (the hash sidecar). It never edits a
10
+ * module's authored prose — that is proposed for confirmation by the agent
11
+ * running the doctor `--regenerate <module>` flow (SKILL.md).
12
+ *
13
+ * See change: add-modular-doctor-skill (design.md D6, tasks 4.1–4.3).
14
+ */
15
+
16
+ import { existsSync } from "node:fs";
17
+ import path from "node:path";
18
+ import { fileURLToPath } from "node:url";
19
+ import { deriveLiveTokens, MODULE_TOKEN_SOURCES } from "./derive-tokens.js";
20
+ import { checkDrift, computeKnowledgeHash, writeStoredHash } from "./knowledge-hash.js";
21
+
22
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
23
+ const MODULES_DIR = path.join(HERE, "..", "modules");
24
+
25
+ /** Absolute path to a module's hash sidecar. */
26
+ export function hashPathFor(moduleId: string): string {
27
+ return path.join(MODULES_DIR, `${moduleId}.knowledge.hash`);
28
+ }
29
+
30
+ /**
31
+ * Discover the repo root by walking up from `start` until a directory with a
32
+ * `packages/` workspace dir is found. Returns null when none is found (e.g. a
33
+ * published-tarball layout without the monorepo).
34
+ */
35
+ export function findRepoRoot(start: string): string | null {
36
+ let dir = start;
37
+ for (let i = 0; i < 12; i++) {
38
+ // packages/ + a root package.json marks the monorepo root.
39
+ if (existsSync(path.join(dir, "packages")) && existsSync(path.join(dir, "package.json"))) {
40
+ return dir;
41
+ }
42
+ const up = path.dirname(dir);
43
+ if (up === dir) break;
44
+ dir = up;
45
+ }
46
+ return null;
47
+ }
48
+
49
+ export interface RegenReport {
50
+ module: string;
51
+ stored: string | null;
52
+ live: string;
53
+ drifted: boolean;
54
+ }
55
+
56
+ /** Compute drift for every module under `repoRoot`. */
57
+ export function reportDrift(repoRoot: string): RegenReport[] {
58
+ return Object.keys(MODULE_TOKEN_SOURCES)
59
+ .sort()
60
+ .map((id) => {
61
+ const tokens = deriveLiveTokens(repoRoot, id);
62
+ const d = checkDrift(id, tokens, hashPathFor(id));
63
+ return { module: id, stored: d.stored, live: d.live, drifted: d.drifted };
64
+ });
65
+ }
66
+
67
+ /** (Re)write one or all module sidecars from live sources. */
68
+ export function writeHashes(repoRoot: string, only?: string): string[] {
69
+ const ids = only ? [only] : Object.keys(MODULE_TOKEN_SOURCES).sort();
70
+ const written: string[] = [];
71
+ for (const id of ids) {
72
+ const hash = computeKnowledgeHash(deriveLiveTokens(repoRoot, id));
73
+ writeStoredHash(hashPathFor(id), hash);
74
+ written.push(id);
75
+ }
76
+ return written;
77
+ }
78
+
79
+ // CLI entrypoint.
80
+ if (import.meta.url === `file://${process.argv[1]}`) {
81
+ const args = process.argv.slice(2);
82
+ const repoRoot = findRepoRoot(HERE);
83
+ if (!repoRoot) {
84
+ console.error("doctor regenerate: repo root not found (published tarball?)");
85
+ process.exit(2);
86
+ }
87
+ if (args.includes("--write")) {
88
+ const only = args.find((a) => !a.startsWith("--"));
89
+ const written = writeHashes(repoRoot, only);
90
+ console.log(`wrote ${written.length} sidecar(s): ${written.join(", ")}`);
91
+ } else {
92
+ let drift = false;
93
+ for (const r of reportDrift(repoRoot)) {
94
+ const mark = r.drifted ? "DRIFT" : "ok";
95
+ if (r.drifted) drift = true;
96
+ console.log(`${mark.padEnd(6)} ${r.module} stored=${r.stored ?? "-"} live=${r.live}`);
97
+ }
98
+ process.exit(drift ? 1 : 0);
99
+ }
100
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Doctor router — derives its symptom map and sweep DAG from module
3
+ * front-matter, so adding a capability MD auto-registers it with NO router
4
+ * edit. The router owns NO capability knowledge (prevents a second rot
5
+ * surface); everything comes from the modules' `symptoms:`/`depends-on:` keys.
6
+ *
7
+ * See change: add-modular-doctor-skill (design.md D1, spec: Modular router).
8
+ */
9
+
10
+ import { readdirSync, readFileSync } from "node:fs";
11
+ import path from "node:path";
12
+ import { type ModuleFrontMatter, parseFrontMatter } from "./front-matter.js";
13
+
14
+ export interface DoctorModule extends ModuleFrontMatter {
15
+ /** Absolute path to the module MD. */
16
+ file: string;
17
+ }
18
+
19
+ /**
20
+ * Load every capability MD in `modulesDir` (excluding `_`-prefixed helpers)
21
+ * and parse its front-matter into a router catalog entry.
22
+ */
23
+ export function loadModules(modulesDir: string): DoctorModule[] {
24
+ const out: DoctorModule[] = [];
25
+ for (const ent of readdirSync(modulesDir, { withFileTypes: true })) {
26
+ if (!ent.isFile()) continue;
27
+ if (!ent.name.endsWith(".md")) continue;
28
+ if (ent.name.startsWith("_")) continue;
29
+ const file = path.join(modulesDir, ent.name);
30
+ const md = readFileSync(file, "utf8");
31
+ const base = ent.name.replace(/\.md$/, "");
32
+ out.push({ ...parseFrontMatter(md, base), file });
33
+ }
34
+ return out.sort((a, b) => a.name.localeCompare(b.name));
35
+ }
36
+
37
+ /**
38
+ * Build the symptom→module map from each module's `symptoms:` phrases.
39
+ * Later modules do not clobber earlier ones (first declaration wins), keeping
40
+ * routing deterministic under alphabetical load order.
41
+ */
42
+ export function buildSymptomMap(modules: DoctorModule[]): Map<string, string> {
43
+ const map = new Map<string, string>();
44
+ for (const m of modules) {
45
+ for (const phrase of m.symptoms) {
46
+ const key = normalizePhrase(phrase);
47
+ if (key && !map.has(key)) map.set(key, m.name);
48
+ }
49
+ }
50
+ return map;
51
+ }
52
+
53
+ /**
54
+ * Normalise a phrase for matching: lower-case, strip punctuation (so "won't"
55
+ * ≡ "wont"), collapse whitespace. Keeps routing robust to apostrophes and
56
+ * underscores (`waiting_peers`).
57
+ */
58
+ function normalizePhrase(s: string): string {
59
+ return s
60
+ .toLowerCase()
61
+ .replace(/['’]/g, "") // drop apostrophes: won't ≡ wont
62
+ .replace(/[^a-z0-9]+/g, " ")
63
+ .trim();
64
+ }
65
+
66
+ /**
67
+ * Route a free-text symptom phrase to exactly one module id, or null.
68
+ * Matches on whole-phrase equality first, then substring containment in
69
+ * either direction (so "flow won't show" matches a declared "flow won't
70
+ * show up" and vice-versa). Matching is punctuation-insensitive.
71
+ */
72
+ export function routeSymptom(modules: DoctorModule[], phrase: string): string | null {
73
+ const q = normalizePhrase(phrase);
74
+ if (!q) return null;
75
+ const map = buildSymptomMap(modules);
76
+ if (map.has(q)) return map.get(q) ?? null;
77
+ for (const [decl, id] of map) {
78
+ if (q.includes(decl) || decl.includes(q)) return id;
79
+ }
80
+ return null;
81
+ }
82
+
83
+ /**
84
+ * Topologically order modules by their `depends-on:` edges (env → pi → peers
85
+ * → plugins → build → runtime). Ties break alphabetically for determinism.
86
+ * Throws on a dependency cycle.
87
+ */
88
+ export function buildSweepOrder(modules: DoctorModule[]): string[] {
89
+ const byName = new Map(modules.map((m) => [m.name, m]));
90
+ const order: string[] = [];
91
+ const visited = new Set<string>();
92
+ const inStack = new Set<string>();
93
+
94
+ const visit = (name: string) => {
95
+ if (visited.has(name)) return;
96
+ if (inStack.has(name)) {
97
+ throw new Error(`doctor: dependency cycle at module '${name}'`);
98
+ }
99
+ inStack.add(name);
100
+ const mod = byName.get(name);
101
+ const deps = mod ? [...mod.dependsOn].sort() : [];
102
+ for (const d of deps) {
103
+ if (byName.has(d)) visit(d);
104
+ }
105
+ inStack.delete(name);
106
+ visited.add(name);
107
+ order.push(name);
108
+ };
109
+
110
+ for (const m of [...modules].sort((a, b) => a.name.localeCompare(b.name))) {
111
+ visit(m.name);
112
+ }
113
+ return order;
114
+ }
115
+
116
+ export interface SweepStep {
117
+ module: string;
118
+ /** True when a (transitive) dependency failed, so this step is skipped. */
119
+ suppressed: boolean;
120
+ /** The failed dependency that caused suppression (root cause). */
121
+ suppressedBy?: string;
122
+ }
123
+
124
+ /**
125
+ * Plan a full sweep: order modules by dependency, then mark every module whose
126
+ * transitive dependency is in `failed` as suppressed so a lower-layer failure
127
+ * (missing pi) is reported as the root cause and NOT re-reported as a broken
128
+ * bridge. `failed` is the set of module ids known to have failed this run.
129
+ */
130
+ export function planSweep(modules: DoctorModule[], failed: Set<string>): SweepStep[] {
131
+ const byName = new Map(modules.map((m) => [m.name, m]));
132
+ const order = buildSweepOrder(modules);
133
+ // Resolve the transitive dependency that failed, closest root first.
134
+ const rootFailure = new Map<string, string>();
135
+ for (const name of order) {
136
+ const mod = byName.get(name);
137
+ if (!mod) continue;
138
+ for (const dep of mod.dependsOn) {
139
+ if (failed.has(dep)) {
140
+ rootFailure.set(name, dep);
141
+ break;
142
+ }
143
+ if (rootFailure.has(dep)) {
144
+ rootFailure.set(name, rootFailure.get(dep) as string);
145
+ break;
146
+ }
147
+ }
148
+ }
149
+ return order.map((name) => {
150
+ const by = rootFailure.get(name);
151
+ return by
152
+ ? { module: name, suppressed: true, suppressedBy: by }
153
+ : { module: name, suppressed: false };
154
+ });
155
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Server-tier helpers — the additive `/api/*` enrichment tier. These DEGRADE
3
+ * cleanly: when the dashboard server is down every call resolves to
4
+ * `{ ok: false, reason }` instead of throwing, so the file-derived baseline
5
+ * still produces a report. Never a dependency, always a bonus.
6
+ *
7
+ * See change: add-modular-doctor-skill (design.md D4, spec: server enrichment).
8
+ */
9
+
10
+ export type ServerResult<T> =
11
+ | { ok: true; data: T }
12
+ | { ok: false; reason: string };
13
+
14
+ const DEFAULT_TIMEOUT_MS = 1500;
15
+
16
+ async function getJson<T>(url: string, timeoutMs: number): Promise<ServerResult<T>> {
17
+ const controller = new AbortController();
18
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
19
+ try {
20
+ const res = await fetch(url, { signal: controller.signal });
21
+ if (!res.ok) return { ok: false, reason: `HTTP ${res.status}` };
22
+ return { ok: true, data: (await res.json()) as T };
23
+ } catch (err) {
24
+ return { ok: false, reason: err instanceof Error ? err.message : "server unavailable" };
25
+ } finally {
26
+ clearTimeout(timer);
27
+ }
28
+ }
29
+
30
+ export interface HealthLike {
31
+ mode?: string;
32
+ piVersion?: string;
33
+ compatibility?: unknown;
34
+ plugins?: unknown;
35
+ [k: string]: unknown;
36
+ }
37
+
38
+ /** Fetch `/api/health`; `{ ok:false }` when the server is unreachable. */
39
+ export function fetchHealth(
40
+ baseUrl: string,
41
+ timeoutMs = DEFAULT_TIMEOUT_MS,
42
+ ): Promise<ServerResult<HealthLike>> {
43
+ return getJson<HealthLike>(`${baseUrl.replace(/\/$/, "")}/api/health`, timeoutMs);
44
+ }
45
+
46
+ export interface PiCoreVersionsLike {
47
+ installed?: string;
48
+ latest?: string;
49
+ installSource?: string;
50
+ [k: string]: unknown;
51
+ }
52
+
53
+ /** Fetch `/api/pi-core/versions`; `{ ok:false }` when unreachable. */
54
+ export function fetchPiCoreVersions(
55
+ baseUrl: string,
56
+ timeoutMs = DEFAULT_TIMEOUT_MS,
57
+ ): Promise<ServerResult<PiCoreVersionsLike>> {
58
+ return getJson<PiCoreVersionsLike>(
59
+ `${baseUrl.replace(/\/$/, "")}/api/pi-core/versions`,
60
+ timeoutMs,
61
+ );
62
+ }
@@ -0,0 +1 @@
1
+ 4359ca6381742309
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: build-reload
3
+ scope: Detect the three-component rebuild/reload gaps (build / restart / reload).
4
+ symptoms:
5
+ - i built it still broken
6
+ - stale client bundle
7
+ - flows dont render
8
+ - old ui after pull
9
+ - bridge not reloaded
10
+ - changes not showing
11
+ depends-on:
12
+ - install-topology
13
+ derives-from:
14
+ - /api/health mode (server-enriched)
15
+ - dist/client mtime vs client/plugin source mtime (live)
16
+ - packages/extension source mtime vs last reload (live)
17
+ ---
18
+
19
+ ## SCOPE
20
+ Detect the three-component rebuild/reload gaps: stale `dist/client` in
21
+ production, and a bridge that changed but was never reloaded into live sessions.
22
+
23
+ ## KNOWLEDGE
24
+ Three components, three actions (the rebuild matrix):
25
+ - **client → build + restart**: the flows-plugin RENDER code is COMPILED INTO
26
+ the client bundle at build time. Current source with a stale `dist/client` =
27
+ old UI even though the source is fixed.
28
+ - **server/shared → restart**: `POST /api/restart` (jiti runs TS directly, no
29
+ build).
30
+ - **extension/bridge → reload**: `npm run reload` (or a fresh session).
31
+ Building the web client does NOT reload the bridge.
32
+
33
+ Trap: "I built it, still broken" = built the client but never reloaded the
34
+ bridge, or restarted the server but never rebuilt the client.
35
+
36
+ ## CHECKS
37
+ - `/api/health` mode (server-enriched): `production` vs `dev`.
38
+ - Production: compare `dist/client` mtime to the newest client/flows-plugin
39
+ source mtime; dist older → stale bundle.
40
+ - Compare `packages/extension` source mtime to the last reload; newer source →
41
+ reload gap.
42
+
43
+ ## FIX ROUTING
44
+ - stale bundle (production) → `npm run build` + `POST /api/restart`.
45
+ - bridge changed, sessions not reloaded → `npm run reload` or a fresh session.
46
+ - server/shared changed → `POST /api/restart`.
47
+ - **dev mode**: Vite HMR handles the client; only bridge changes need reload.
48
+
49
+ ## DERIVES-FROM
50
+ Server-enriched: `/api/health` mode. Live: `dist/client` mtime, source mtimes.
51
+ Hash sidecar: `build-reload.knowledge.hash`.
@@ -0,0 +1 @@
1
+ 70560582aa8dd3a4
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: env-node
3
+ scope: Node runtime + OS/platform baseline the whole toolchain runs on.
4
+ symptoms:
5
+ - node version
6
+ - unsupported node
7
+ - wrong node
8
+ - electron picks wrong node
9
+ - which node
10
+ depends-on: []
11
+ derives-from:
12
+ - process.version (live)
13
+ - process.platform / os.release() (live)
14
+ - packages/shared/src/node-version.ts (isUsableNodeVersion / isAffectedNode / isOutOfEnginesRange)
15
+ ---
16
+
17
+ ## SCOPE
18
+ Node runtime version, OS, platform, and PATH — the ground layer every other
19
+ module depends on.
20
+
21
+ ## KNOWLEDGE
22
+ Failure modes:
23
+ - Node below the engines floor or in an `isAffectedNode` band → pi/jiti crashes
24
+ or the Fastify server aborts on boot. `node-version.ts` owns the predicates
25
+ (`isUsableNodeVersion`, `isAffectedNode`, `isOutOfEnginesRange`).
26
+ - `which -a node` shows more than one Node; the one on PATH is not the one the
27
+ Electron app or a launched session uses → version skew that looks like a pi
28
+ bug but is a Node bug.
29
+ - A shell rc that mutates PATH only for interactive shells → GUI-launched
30
+ Electron gets a different Node than the terminal.
31
+
32
+ ## CHECKS
33
+ - `node --version` — current runtime.
34
+ - `which -a node && readlink -f "$(which node)"` — every Node on PATH + target.
35
+ - `node -e "console.log(process.platform, process.arch, require('os').release())"`.
36
+ - Feed the version to `isUsableNodeVersion(version)` from
37
+ `@blackbelt-technology/pi-dashboard-shared/node-version.js`; flag when false.
38
+
39
+ ## FIX ROUTING
40
+ - **dev / npm-global**: switch Node (`nvm use <supported>`); reinstall global pi
41
+ under the supported Node.
42
+ - **Electron**: the app bundles its own Node selection — a bad system Node only
43
+ affects CLI-launched sessions; see `docs/electron-bootstrap-flow.md` for the
44
+ Node-bin selection order.
45
+ - **Docker**: rebuild the image; the base image pins Node.
46
+
47
+ ## DERIVES-FROM
48
+ Live: `process.version`, `process.platform`, `os.release()`. Predicates:
49
+ `packages/shared/src/node-version.ts`. Hash sidecar: `env-node.knowledge.hash`.
@@ -0,0 +1 @@
1
+ 73bb9fe440d86c9c
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: install-topology
3
+ scope: Detect the install topology and route fixes to the matching remediation.
4
+ symptoms:
5
+ - how is this installed
6
+ - electron read-only
7
+ - docker install
8
+ - npm global install
9
+ - which topology
10
+ - cant edit bundled files
11
+ depends-on:
12
+ - env-node
13
+ derives-from:
14
+ - process.execPath / resourcesPath (Electron marker, live)
15
+ - /.dockerenv + PI_WORKSPACES env (Docker marker, live)
16
+ - npm root -g (npm-global marker, live)
17
+ - repo .git + package.json workspaces (dev marker, live)
18
+ ---
19
+
20
+ ## SCOPE
21
+ Detect npm-global / Electron bundle / Docker / dev-checkout and route every
22
+ fix to the topology-correct remediation, including the Electron bundle being
23
+ immutable.
24
+
25
+ ## KNOWLEDGE
26
+ The same failure has a different fix per topology. Markers:
27
+ - **Electron bundle**: running under `process.resourcesPath`; server + pi live
28
+ under `Resources/`. The bundle is READ-ONLY — never "just edit" a file there;
29
+ the fix is "update the app".
30
+ - **Docker**: `/.dockerenv` present; `PI_WORKSPACES` mounts; fix = rebuild image
31
+ or edit the mounted workspace, not the container FS.
32
+ - **npm-global**: pi/dashboard under `npm root -g`; fix = `npm i -g` upgrades.
33
+ - **dev checkout**: repo `.git` + workspace `package.json`; fix = local
34
+ `npm install` / `npm run build` / source edits.
35
+
36
+ ## CHECKS
37
+ - Electron: `node -e "console.log(process.resourcesPath || '')"` non-empty, or
38
+ `process.execPath` inside an `.app`/`AppImage`.
39
+ - Docker: `test -f /.dockerenv` and `printenv PI_WORKSPACES`.
40
+ - npm-global: `npm root -g` contains the dashboard/pi package.
41
+ - dev: `git rev-parse --show-toplevel` resolves to a repo with `packages/`.
42
+
43
+ ## FIX ROUTING
44
+ - **Electron** → immutable: direct the user to update/reinstall the app; do NOT
45
+ propose editing bundled files. See `docs/electron-bootstrap-flow.md`.
46
+ - **Docker** → rebuild image (`docker compose up -d --build`) or edit the
47
+ mounted workspace.
48
+ - **npm-global** → `npm i -g <pkg>@<version>`.
49
+ - **dev** → `npm install`, `npm run build`, `POST /api/restart`, `npm run reload`.
50
+
51
+ ## DERIVES-FROM
52
+ Live: `process.resourcesPath`, `/.dockerenv`, `PI_WORKSPACES`, `npm root -g`,
53
+ repo `.git`. Hash sidecar: `install-topology.knowledge.hash`.
@@ -0,0 +1 @@
1
+ 787510c6a3d8d463
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: model-resolution
3
+ scope: Verify model:resolve handler, roles/preset, @role resolvability.
4
+ symptoms:
5
+ - agent model fails at spawn
6
+ - role wont resolve
7
+ - model:resolve missing
8
+ - flow agent model error
9
+ - no models
10
+ - preset not applied
11
+ depends-on:
12
+ - pi-resolution
13
+ - plugins-bridges
14
+ derives-from:
15
+ - packages/extension/src/provider-register.ts (model:resolve handler, live)
16
+ - ~/.pi/agent/providers.json roles + rolePresets + activePreset (live)
17
+ - resolved pi-flows version (model-resolve-aware, live)
18
+ ---
19
+
20
+ ## SCOPE
21
+ Verify the `model:resolve` handler is registered, roles + preset are present,
22
+ every `@role` resolves, and the loaded pi-flows consumes `model:resolve`.
23
+
24
+ ## KNOWLEDGE
25
+ - `provider-register.ts` registers `pi.events.on("model:resolve", …)` (plus the
26
+ deprecated `role:resolve-model` alias). A loaded extension source lacking it
27
+ → roles never resolve.
28
+ - `providers.json` must carry `roles`, `rolePresets`, and an `activePreset`. A
29
+ flow agent whose model is an unresolvable `@role` fails at spawn.
30
+ - pi-flows must be a version that consumes `model:resolve` (the
31
+ `consume-model-resolve-event` / `fix-flow-agent-model-resolution` line). A
32
+ pre-fix pi-flows ignores the handler → agents fall back or fail.
33
+
34
+ ## CHECKS
35
+ - Grep the loaded `provider-register.ts` for `model:resolve` registration.
36
+ - Read `providers.json`: `roles`, `rolePresets`, `activePreset` present?
37
+ - For each `@role` a flow/agent references, resolve it to a concrete
38
+ `provider/model[:thinking]`; flag unresolvable roles.
39
+ - Confirm the resolved pi-flows version (from the `peers` module) is
40
+ model-resolve-aware.
41
+ - Server-enriched: `/api/models` returns the expected catalogue for the active
42
+ preset's provider.
43
+
44
+ ## FIX ROUTING
45
+ - missing handler → load an extension source that registers `model:resolve`
46
+ (dev local or released ≥ the fix); `npm run reload`.
47
+ - unresolvable `@role` → fix `providers.json` roles / activePreset.
48
+ - pre-fix pi-flows → upgrade pi-flows to a model-resolve-aware version (peers
49
+ module remediation).
50
+
51
+ ## DERIVES-FROM
52
+ Live: `provider-register.ts`, `providers.json`, resolved pi-flows version.
53
+ Server-enriched: `/api/models`. Hash sidecar: `model-resolution.knowledge.hash`.
@@ -0,0 +1 @@
1
+ d89614d4d77f7cb6
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: peers
3
+ scope: Probe pi-flows + anthropic-messages via tier-1/tier-2; detect name-skew.
4
+ symptoms:
5
+ - flow engine not found
6
+ - pi-flows missing
7
+ - anthropic peer missing
8
+ - waiting_peers
9
+ - bridge waiting for peers
10
+ - peer not resolving
11
+ depends-on:
12
+ - pi-resolution
13
+ derives-from:
14
+ - packages/flows-anthropic-bridge-plugin/src/peer-probe.ts (tier model, live)
15
+ - ~/.pi/agent/settings.json#packages[] (live)
16
+ - resolved peer package.json name + version (live)
17
+ ---
18
+
19
+ ## SCOPE
20
+ Probe each peer (`pi-flows`, anthropic-messages) via tier-1 then tier-2, report
21
+ the resolving tier, and detect published-name skew after a rescope.
22
+
23
+ ## KNOWLEDGE
24
+ Two resolution tiers (mirrors `peer-probe.ts`):
25
+ - **Tier 1** — `createRequire(cwd+'/_').resolve(spec)`, anchored at the session
26
+ launch cwd. Finds peers only in a `node_modules` ancestor of that cwd.
27
+ - **Tier 2** — `resolvePiPackageEntry(spec)`, walks `packages[]` in user +
28
+ project `settings.json`. Makes an npm/git/local pi-installed peer resolve even
29
+ when tier-1 misses.
30
+
31
+ A peer is PRESENT if tier-1 OR tier-2 resolves it.
32
+
33
+ Name-skew: a published bridge may probe a peer name that no longer resolves
34
+ after a rescope (e.g. legacy `@pi/anthropic-messages` when the live package is
35
+ `@blackbelt-technology/pi-anthropic-messages`). The current package resolves;
36
+ the stale name does not → the shipped bridge version carries a dead name.
37
+
38
+ ## CHECKS
39
+ - `probePeer("pi-flows", { cwd })` — record tier + resolved path + version.
40
+ - Confirm the pi-flows `package.json` name is `@blackbelt-technology/pi-flows`
41
+ (NOT the unrelated unscoped `pi-flows`).
42
+ - `detectNameSkew(["@blackbelt-technology/pi-anthropic-messages", "@pi/anthropic-messages"], { cwd })`
43
+ — `resolvedName` is the live package, `staleNames` the dead aliases.
44
+ - Neither name resolving → the dependent bridge parks in `waiting_peers`; name
45
+ the failed peer + resolver reason.
46
+
47
+ ## FIX ROUTING
48
+ - pi-flows missing → add `@blackbelt-technology/pi-flows` (≥0.3.2 npm or local
49
+ develop) to `packages[]`; respawn the session.
50
+ - anthropic peer missing → add the peer to `packages[]`; ensure the loaded
51
+ bridge probes the NEW name first (load local / ≥ released bridge).
52
+ - name-skew on a published bridge → cut/adopt a bridge release that probes the
53
+ current package name, or load the local bridge source.
54
+
55
+ ## DERIVES-FROM
56
+ Live: `peer-probe.ts` tier model, `settings.json#packages[]`, resolved peer
57
+ `package.json`. Hash sidecar: `peers.knowledge.hash`.
@@ -0,0 +1 @@
1
+ 80194b0764f0c67e
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: pi-resolution
3
+ scope: Enumerate every pi install location, flag divergence + floor violations.
4
+ symptoms:
5
+ - pi version mismatch
6
+ - dashboard piVersion differs
7
+ - two pi versions
8
+ - pi too old
9
+ - which pi
10
+ - session pi differs from server
11
+ depends-on:
12
+ - env-node
13
+ derives-from:
14
+ - which -a pi + readlink (live CLI binary)
15
+ - repo node_modules/@earendil-works/pi-coding-agent/package.json (live)
16
+ - managed ~/.pi-dashboard node_modules (live)
17
+ - createRequire(sessionCwd) resolution (live)
18
+ - packages/server/package.json#piCompatibility.minimum (floor)
19
+ ---
20
+
21
+ ## SCOPE
22
+ Report pi across ALL install locations (CLI, repo `node_modules`, managed,
23
+ nvm-global, per-session-cwd) and flag divergence and floor violations. A single
24
+ version string is never sufficient.
25
+
26
+ ## KNOWLEDGE
27
+ pi resolves from MULTIPLE independent locations that can hold DIFFERENT
28
+ versions. Never assume "pi is one thing":
29
+ - CLI binary (`which -a pi` → `dist/cli.js`) — what a human types.
30
+ - Repo `node_modules/@earendil-works/pi-coding-agent` — what the dashboard
31
+ server + sessions resolve.
32
+ - `packages/server/node_modules/...` if present (usually NONE; server resolves
33
+ via repo root).
34
+ - Managed install / nvm-global copy.
35
+ - Per-session-cwd `createRequire(cwd+'/_').resolve(...)` — what a launched
36
+ session actually loads.
37
+
38
+ Failure modes:
39
+ - Dashboard `/api/health` `piVersion` ≠ the version resolved at the session cwd
40
+ → dashboard and sessions run different pi.
41
+ - Any location below `piCompatibility.minimum` → that consumer fails.
42
+
43
+ ## CHECKS
44
+ - `which -a pi && readlink -f "$(which pi)" && pi --version`.
45
+ - Read version from repo `node_modules/@earendil-works/pi-coding-agent/package.json`.
46
+ - `node -e "console.log(require('module').createRequire(process.cwd()+'/_').resolve('@earendil-works/pi-coding-agent'))"` — session cwd resolution.
47
+ - Use `enumeratePiInstalls({ label: dir })` + `piVersionDivergence()` from
48
+ `_lib/checks.ts`; compare each to `readPiFloor(serverPkgJsonPath)`.
49
+ - Multiple versions are OK **only** if every one ≥ floor.
50
+
51
+ ## FIX ROUTING
52
+ - **dev**: align the repo dep spec + global pi; `npm install` at repo root.
53
+ - **npm-global**: `npm i -g @earendil-works/pi-coding-agent@<≥floor>`.
54
+ - **Electron**: bundled pi is immutable; update the app (see install-topology).
55
+ - **Docker**: rebuild the image with the pinned pi.
56
+
57
+ ## DERIVES-FROM
58
+ Live: CLI binary, repo/managed package.json versions, cwd `createRequire`.
59
+ Floor: `packages/server/package.json#piCompatibility.minimum`. Hash sidecar:
60
+ `pi-resolution.knowledge.hash`.
@@ -0,0 +1 @@
1
+ 4159266b4c9ecb80