@blackbelt-technology/pi-dashboard-extension 0.7.0 → 0.9.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 (265) hide show
  1. package/.pi/skills/browser/SKILL.md +84 -29
  2. package/.pi/skills/browser/UPSTREAM.md +13 -1
  3. package/.pi/skills/browser/references/challenge.md +183 -0
  4. package/.pi/skills/browser/references/dashboard-relay.md +150 -0
  5. package/.pi/skills/browser/references/electron.agent.md +57 -0
  6. package/.pi/skills/browser/references/own-browser.md +305 -0
  7. package/.pi/skills/browser/references/web.agent.md +323 -0
  8. package/.pi/skills/browser/scripts/check-panerelay.sh +157 -0
  9. package/.pi/skills/doctor/SKILL.md +4 -9
  10. package/.pi/skills/doctor/_lib/checks.ts +133 -54
  11. package/.pi/skills/doctor/_lib/derive-tokens.ts +5 -0
  12. package/.pi/skills/doctor/modules/apple-tools.knowledge.hash +1 -0
  13. package/.pi/skills/doctor/modules/apple-tools.md +52 -0
  14. package/.pi/skills/doctor/modules/mcp-builtin.knowledge.hash +1 -0
  15. package/.pi/skills/doctor/modules/mcp-builtin.md +61 -0
  16. package/.pi/skills/doctor/modules/oauth-redirect-base.knowledge.hash +1 -0
  17. package/.pi/skills/doctor/modules/oauth-redirect-base.md +71 -0
  18. package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
  19. package/.pi/skills/doctor/modules/pi-resolution.md +21 -1
  20. package/.pi/skills/doctor/modules/plugins-bridges.md +14 -1
  21. package/.pi/skills/pi-dashboard/SKILL.md +10 -3
  22. package/.pi/skills/pi-dashboard/references/api-reference.agent.md +69 -0
  23. package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +4 -4
  24. package/.pi/skills/project-init/SKILL.md +41 -34
  25. package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +0 -23
  26. package/.pi/skills/project-init/profiles/docs/profile.json +1 -1
  27. package/README.md +19 -0
  28. package/agents/DoxTriage.md +80 -0
  29. package/package.json +30 -16
  30. package/src/ask-user-tool.ts +4 -0
  31. package/src/auto-session-namer.ts +486 -70
  32. package/src/autostart-guard.ts +99 -0
  33. package/src/autostart-lock.ts +258 -0
  34. package/src/bridge-activation.ts +26 -0
  35. package/src/bridge-context.ts +106 -23
  36. package/src/bridge-default-model-gate.ts +38 -0
  37. package/src/bridge-polling.ts +148 -0
  38. package/src/bridge-ticket-client.ts +105 -0
  39. package/src/bridge.ts +1760 -350
  40. package/src/canvas-tool.ts +5 -0
  41. package/src/command-handler.ts +392 -71
  42. package/src/connect-target.ts +130 -0
  43. package/src/connection.ts +846 -17
  44. package/src/custom-entry-forward.ts +92 -0
  45. package/src/endpoint-resolution.ts +253 -0
  46. package/src/event-forwarder.ts +42 -0
  47. package/src/extension-identity.ts +59 -0
  48. package/src/flow-event-wiring.ts +125 -3
  49. package/src/followup-buffer.ts +217 -0
  50. package/src/git-dir-watcher.ts +79 -0
  51. package/src/git-poll.ts +45 -12
  52. package/src/git-probe-scheduler.ts +119 -0
  53. package/src/git-tracker.ts +284 -0
  54. package/src/instance-verification.ts +156 -0
  55. package/src/local-token-header.ts +44 -0
  56. package/src/mcp-token-delivery.ts +147 -0
  57. package/src/message-update-coalescer.ts +340 -0
  58. package/src/model-refresh.ts +95 -0
  59. package/src/model-tracker.ts +118 -35
  60. package/src/notify-proxy.ts +36 -0
  61. package/src/path-gate/decide.ts +149 -0
  62. package/src/path-gate/grant-cache.ts +71 -0
  63. package/src/path-gate/grant-link.ts +108 -0
  64. package/src/path-gate/handler.ts +307 -0
  65. package/src/path-gate/index.ts +155 -0
  66. package/src/path-gate/resolve.ts +126 -0
  67. package/src/path-gate/roots.ts +137 -0
  68. package/src/path-gate/suppression.ts +27 -0
  69. package/src/pending-prompt-emitter.ts +59 -0
  70. package/src/pi-env.d.ts +6 -10
  71. package/src/pi-retry-settings.ts +91 -0
  72. package/src/plugin-request-client.ts +114 -0
  73. package/src/poll-cost.ts +40 -0
  74. package/src/pr-status.ts +338 -0
  75. package/src/process-metrics.ts +77 -1
  76. package/src/process-scan-scheduler.ts +137 -0
  77. package/src/process-scanner.ts +226 -247
  78. package/src/project-init/dox-kb-config.ts +3 -0
  79. package/src/project-init/scaffold.ts +1 -4
  80. package/src/project-init/seed-doctrine.ts +23 -60
  81. package/src/prompt-bus.ts +13 -0
  82. package/src/provider-register.ts +92 -21
  83. package/src/remote-registration-gate.ts +102 -0
  84. package/src/retry-tracker.ts +258 -86
  85. package/src/role-manager.ts +38 -91
  86. package/src/role-model-tools.ts +44 -3
  87. package/src/server-auto-start.ts +331 -20
  88. package/src/server-launcher.ts +70 -34
  89. package/src/server-pin-store.ts +92 -0
  90. package/src/session-move.ts +275 -0
  91. package/src/session-sync.ts +75 -20
  92. package/src/slash-dispatch.ts +66 -81
  93. package/src/subagent-fanout-admission.ts +234 -0
  94. package/src/subagent-forward-sites.ts +69 -0
  95. package/src/subagent-frame-buffer.ts +24 -3
  96. package/src/subagent-frame-strip.ts +109 -0
  97. package/src/subagent-saturation.ts +196 -0
  98. package/src/subagent-tick-throttle.ts +250 -0
  99. package/src/terminal-reload.ts +298 -0
  100. package/src/transcript-backfill.ts +151 -0
  101. package/src/transport-diagnostics.ts +76 -0
  102. package/src/tui-prompt-adapter.ts +13 -1
  103. package/src/turn-actionability.ts +20 -0
  104. package/src/ui-stale-guard.ts +58 -0
  105. package/src/usage-drain.ts +167 -0
  106. package/src/vcs-info.ts +261 -63
  107. package/.pi/skills/doctor/AGENTS.md +0 -27
  108. package/.pi/skills/project-init/dox-doctrine.md +0 -104
  109. package/src/AGENTS.md +0 -57
  110. package/src/__tests__/abort-latch.test.ts +0 -97
  111. package/src/__tests__/agent-settled.test.ts +0 -82
  112. package/src/__tests__/artifact-roots.test.ts +0 -83
  113. package/src/__tests__/ask-user-attachments.test.ts +0 -106
  114. package/src/__tests__/ask-user-schema-discriminator.test.ts +0 -141
  115. package/src/__tests__/ask-user-tool.test.ts +0 -571
  116. package/src/__tests__/auto-session-namer.test.ts +0 -339
  117. package/src/__tests__/bridge-default-model-apply.test.ts +0 -242
  118. package/src/__tests__/bridge-default-model-gate.test.ts +0 -50
  119. package/src/__tests__/bridge-entry-id-pi-070.test.ts +0 -174
  120. package/src/__tests__/bridge-followup-chat-order.test.ts +0 -215
  121. package/src/__tests__/bridge-followup-multi-entry.test.ts +0 -202
  122. package/src/__tests__/bridge-followup-mutation.test.ts +0 -217
  123. package/src/__tests__/bridge-followup-queue-drain.test.ts +0 -266
  124. package/src/__tests__/bridge-hasui-flip.test.ts +0 -109
  125. package/src/__tests__/bridge-no-queue-mutation.test.ts +0 -112
  126. package/src/__tests__/bridge-plugin-emit-event.test.ts +0 -44
  127. package/src/__tests__/bridge-queue-update-forward.test.ts +0 -77
  128. package/src/__tests__/bridge-resume-disconnect.test.ts +0 -333
  129. package/src/__tests__/bridge-shadow-queue-gate.test.ts +0 -299
  130. package/src/__tests__/bridge-shutdown-reset.test.ts +0 -159
  131. package/src/__tests__/bridge-slash-command-routing.test.ts +0 -458
  132. package/src/__tests__/bridge-stop-after-turn.test.ts +0 -72
  133. package/src/__tests__/bridge-system-followup.test.ts +0 -163
  134. package/src/__tests__/bridge-thinking-level-select.test.ts +0 -68
  135. package/src/__tests__/browser-skill-registered.test.ts +0 -84
  136. package/src/__tests__/build-provider-catalogue.test.ts +0 -210
  137. package/src/__tests__/command-handler.test.ts +0 -1180
  138. package/src/__tests__/commit-draft.test.ts +0 -100
  139. package/src/__tests__/connection-dropped-frames.test.ts +0 -78
  140. package/src/__tests__/connection-suppress-auto-start.test.ts +0 -97
  141. package/src/__tests__/connection.test.ts +0 -344
  142. package/src/__tests__/credentials-updated.test.ts +0 -26
  143. package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +0 -128
  144. package/src/__tests__/cwd-missing-probe.test.ts +0 -82
  145. package/src/__tests__/dashboard-commands-shipped.test.ts +0 -53
  146. package/src/__tests__/dashboard-context-injector.test.ts +0 -190
  147. package/src/__tests__/dashboard-default-adapter.test.ts +0 -77
  148. package/src/__tests__/dev-build.test.ts +0 -79
  149. package/src/__tests__/doctor/checks.test.ts +0 -121
  150. package/src/__tests__/doctor/modules.test.ts +0 -64
  151. package/src/__tests__/doctor/provenance-hash.test.ts +0 -94
  152. package/src/__tests__/doctor/router.test.ts +0 -143
  153. package/src/__tests__/empty-actionable-guard-config.test.ts +0 -32
  154. package/src/__tests__/empty-actionable-guard.test.ts +0 -73
  155. package/src/__tests__/enrich-model-metadata.test.ts +0 -222
  156. package/src/__tests__/event-forwarder.test.ts +0 -119
  157. package/src/__tests__/extension-slash-command-detection.test.ts +0 -143
  158. package/src/__tests__/filter-enabled-models.test.ts +0 -151
  159. package/src/__tests__/fixtures/turn-actionability-fixtures.ts +0 -69
  160. package/src/__tests__/fork-entryid-timing.test.ts +0 -88
  161. package/src/__tests__/git-info-status.test.ts +0 -73
  162. package/src/__tests__/git-link-builder.test.ts +0 -102
  163. package/src/__tests__/git-poll.test.ts +0 -69
  164. package/src/__tests__/markdown-image-inliner.test.ts +0 -392
  165. package/src/__tests__/model-resolve.test.ts +0 -379
  166. package/src/__tests__/multiselect-dashboard-routing.test.ts +0 -203
  167. package/src/__tests__/multiselect-list.test.ts +0 -137
  168. package/src/__tests__/multiselect-polyfill.test.ts +0 -92
  169. package/src/__tests__/no-session-replacement-calls.test.ts +0 -99
  170. package/src/__tests__/no-tui-multiselect-arm-regression.test.ts +0 -81
  171. package/src/__tests__/openspec-activity-detector.test.ts +0 -337
  172. package/src/__tests__/openspec-cli-shim.test.ts +0 -145
  173. package/src/__tests__/openspec-poller.test.ts +0 -124
  174. package/src/__tests__/pi-version-tracker.test.ts +0 -109
  175. package/src/__tests__/process-metrics.test.ts +0 -47
  176. package/src/__tests__/process-scanner-kill.test.ts +0 -61
  177. package/src/__tests__/process-scanner.test.ts +0 -292
  178. package/src/__tests__/project-init-detect-stack.test.ts +0 -61
  179. package/src/__tests__/project-init-dox-kb-config.test.ts +0 -53
  180. package/src/__tests__/project-init-profiles.test.ts +0 -84
  181. package/src/__tests__/project-init-scaffold.test.ts +0 -139
  182. package/src/__tests__/project-init-seed-doctrine.test.ts +0 -100
  183. package/src/__tests__/project-trust.test.ts +0 -92
  184. package/src/__tests__/prompt-bus-wiring.test.ts +0 -791
  185. package/src/__tests__/prompt-bus.test.ts +0 -513
  186. package/src/__tests__/prompt-expander.test.ts +0 -398
  187. package/src/__tests__/provider-register-native-models.test.ts +0 -182
  188. package/src/__tests__/provider-register-reload.test.ts +0 -498
  189. package/src/__tests__/provider-register-thinking-levels.test.ts +0 -104
  190. package/src/__tests__/retry-tracker.test.ts +0 -152
  191. package/src/__tests__/role-manager.test.ts +0 -585
  192. package/src/__tests__/role-model-tools-registry-readiness.test.ts +0 -114
  193. package/src/__tests__/role-model-tools.test.ts +0 -229
  194. package/src/__tests__/search-files-completeness.test.ts +0 -111
  195. package/src/__tests__/search-files-ranking.test.ts +0 -168
  196. package/src/__tests__/server-auto-start.test.ts +0 -375
  197. package/src/__tests__/server-launcher-launch.test.ts +0 -96
  198. package/src/__tests__/server-launcher.test.ts +0 -101
  199. package/src/__tests__/server-probe.test.ts +0 -25
  200. package/src/__tests__/session-switch.test.ts +0 -139
  201. package/src/__tests__/session-sync.test.ts +0 -243
  202. package/src/__tests__/single-derivation-guard.test.ts +0 -39
  203. package/src/__tests__/source-detector.test.ts +0 -88
  204. package/src/__tests__/stats-extractor.test.ts +0 -92
  205. package/src/__tests__/subagent-frame-buffer.test.ts +0 -239
  206. package/src/__tests__/tool-result-image-inliner.test.ts +0 -206
  207. package/src/__tests__/tui-prompt-adapter.test.ts +0 -213
  208. package/src/__tests__/turn-actionability.test.ts +0 -86
  209. package/src/__tests__/ui-decorators.test.ts +0 -309
  210. package/src/__tests__/ui-modules.test.ts +0 -293
  211. package/src/__tests__/vcs-info.test.ts +0 -265
  212. package/src/__tests__/visibility-intent.test.ts +0 -43
  213. package/src/__tests__/watchdog.test.ts +0 -161
  214. package/src/abort-latch.ts.AGENTS.md +0 -3
  215. package/src/agent-settled.ts +0 -72
  216. package/src/agent-settled.ts.AGENTS.md +0 -3
  217. package/src/artifact-roots.ts.AGENTS.md +0 -3
  218. package/src/ask-user-attachments.ts.AGENTS.md +0 -3
  219. package/src/ask-user-tool.ts.AGENTS.md +0 -3
  220. package/src/auto-session-namer.ts.AGENTS.md +0 -3
  221. package/src/bridge-context.ts.AGENTS.md +0 -3
  222. package/src/bridge-default-model-gate.ts.AGENTS.md +0 -3
  223. package/src/bridge.ts.AGENTS.md +0 -3
  224. package/src/command-handler.ts.AGENTS.md +0 -3
  225. package/src/commit-draft-agent.ts.AGENTS.md +0 -3
  226. package/src/commit-draft.ts.AGENTS.md +0 -3
  227. package/src/connection.ts.AGENTS.md +0 -3
  228. package/src/dashboard-context-injector.ts.AGENTS.md +0 -3
  229. package/src/dashboard-default-adapter.ts.AGENTS.md +0 -3
  230. package/src/dev-build.ts.AGENTS.md +0 -3
  231. package/src/empty-actionable-guard-config.ts.AGENTS.md +0 -3
  232. package/src/empty-actionable-guard.ts.AGENTS.md +0 -3
  233. package/src/event-forwarder.ts.AGENTS.md +0 -3
  234. package/src/flow-event-wiring.ts.AGENTS.md +0 -3
  235. package/src/git-link-builder.ts.AGENTS.md +0 -3
  236. package/src/git-poll.ts.AGENTS.md +0 -3
  237. package/src/hasui-flip.ts.AGENTS.md +0 -3
  238. package/src/markdown-image-inliner.ts.AGENTS.md +0 -3
  239. package/src/model-tracker.ts.AGENTS.md +0 -3
  240. package/src/multiselect-decode.ts.AGENTS.md +0 -3
  241. package/src/multiselect-list.ts.AGENTS.md +0 -3
  242. package/src/multiselect-polyfill.ts.AGENTS.md +0 -3
  243. package/src/openspec-cli-shim.ts.AGENTS.md +0 -7
  244. package/src/process-metrics.ts.AGENTS.md +0 -3
  245. package/src/process-scanner.ts.AGENTS.md +0 -3
  246. package/src/project-init/AGENTS.md +0 -12
  247. package/src/project-trust.ts.AGENTS.md +0 -3
  248. package/src/prompt-bus.ts.AGENTS.md +0 -3
  249. package/src/prompt-expander.ts.AGENTS.md +0 -3
  250. package/src/provider-register.ts.AGENTS.md +0 -3
  251. package/src/retry-tracker.ts.AGENTS.md +0 -3
  252. package/src/role-manager.ts.AGENTS.md +0 -3
  253. package/src/role-model-tools.ts.AGENTS.md +0 -3
  254. package/src/server-auto-start.ts.AGENTS.md +0 -3
  255. package/src/server-launcher.ts.AGENTS.md +0 -3
  256. package/src/session-sync.ts.AGENTS.md +0 -3
  257. package/src/slash-dispatch.ts.AGENTS.md +0 -3
  258. package/src/source-detector.ts.AGENTS.md +0 -3
  259. package/src/subagent-frame-buffer.ts.AGENTS.md +0 -3
  260. package/src/tool-result-image-inliner.ts.AGENTS.md +0 -3
  261. package/src/tui-prompt-adapter.ts.AGENTS.md +0 -3
  262. package/src/turn-actionability.ts.AGENTS.md +0 -3
  263. package/src/ui-modules.ts.AGENTS.md +0 -3
  264. package/src/vcs-info.ts.AGENTS.md +0 -3
  265. package/src/visibility-intent.ts.AGENTS.md +0 -3
package/src/vcs-info.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  /**
2
- * VCS info gathering — detects git branch/remote/PR and worktree state.
2
+ * VCS info gathering — detects git branch/remote and worktree state.
3
3
  * Delegates to shared platform tool modules so there's no inline execSync
4
4
  * and every call benefits from the runner's safety defaults (windowsHide,
5
5
  * timeout, tolerated exit codes).
6
6
  *
7
7
  * See change: platform-command-executor.
8
8
  */
9
+ import { readFileSync, statSync } from "node:fs";
9
10
  import path from "node:path";
10
11
  import * as git from "@blackbelt-technology/pi-dashboard-shared/platform/git.js";
11
- import type { GitStatus, GitWorktreeInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
12
+ import type { GitWorktreeInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
12
13
  import { buildGitLinks, type GitLinks } from "./git-link-builder.js";
14
+ import { incPollCost } from "./poll-cost.js";
13
15
 
14
16
  export interface GitInfo {
15
17
  gitBranch: string;
16
18
  gitBranchUrl?: string;
17
- gitPrNumber?: number;
18
- gitPrUrl?: string;
19
19
  /**
20
20
  * Worktree identity (mainPath, name) when cwd is a git worktree.
21
21
  * Undefined for the main checkout and for any cwd where the rev-parse
@@ -64,83 +64,281 @@ export function detectRemoteUrl(cwd: string): string | undefined {
64
64
  return git.remoteUrlOr({ cwd });
65
65
  }
66
66
 
67
- /** Detect the PR number via gh CLI (best effort). */
68
- export function detectPrNumber(cwd: string): number | undefined {
69
- return git.prNumberOr({ cwd });
70
- }
71
-
72
67
  /**
73
68
  * Detect whether `cwd` is a git worktree (not the main checkout).
74
69
  *
75
- * Uses the canonical signal: `git rev-parse --git-common-dir` resolves
76
- * to a path OUTSIDE `git rev-parse --show-toplevel` when the cwd is a
77
- * worktree (because `--git-common-dir` points back at the main repo's
78
- * `.git/`, while `--show-toplevel` is the worktree's own root).
70
+ * Delegates to the shared checkout-root resolver, whose worktree signal is
71
+ * `--git-dir != --git-common-dir`. The superseded test — "is the common dir
72
+ * outside `--show-toplevel`" — reported a SUBMODULE as a worktree and then
73
+ * derived `mainPath` as the parent of the common dir, i.e. a
74
+ * `…/.git/modules/<name>` path that does not exist.
79
75
  *
80
76
  * Returns `undefined` when:
81
- * - either rev-parse invocation fails (not a repo, git missing,
82
- * permission, etc.),
83
- * - the cwd IS the main checkout (`commonDir` is inside `topLevel`).
77
+ * - a required rev-parse invocation fails (not a repo, git missing, timeout);
78
+ * - the cwd is not a linked worktree — which now covers a submodule, a
79
+ * `--separate-git-dir` checkout, and a bare repository alike;
80
+ * - no main checkout resolves (a worktree of a bare hub has none);
81
+ * - the resolved main checkout is implausible.
84
82
  *
85
- * Resolution is path-prefix based with case-folding on Windows/macOS
86
- * via the shared platform helpers; relative `commonDir` outputs (which
87
- * happen on some git versions when cwd === main repo) are normalised
88
- * to absolute via `path.resolve(cwd, commonDir)`.
83
+ * That last check is this consumer's own obligation: the resolver returns a
84
+ * user-controlled `core.worktree` value verbatim and does not judge it. Being
85
+ * a DISPLAY consumer, the safe response here is to omit the field rather than
86
+ * put a `.git`-internal path on the wire.
87
+ *
88
+ * See change: add-git-checkout-root-resolver.
89
89
  */
90
90
  export function detectWorktree(cwd: string): GitWorktreeInfo | undefined {
91
- const commonDirRaw = git.commonDirOr({ cwd });
92
- const topLevel = git.toplevelOr({ cwd });
93
- if (!commonDirRaw || !topLevel) return undefined;
94
-
95
- // Normalise commonDir: when it's relative (`.git`), resolve against cwd.
96
- // When absolute, leave as-is.
97
- const commonDirAbs = path.isAbsolute(commonDirRaw)
98
- ? commonDirRaw
99
- : path.resolve(cwd, commonDirRaw);
100
-
101
- // Main checkout: commonDir == <toplevel>/.git (or anywhere inside toplevel).
102
- // Worktree: commonDir == <main-repo>/.git, which is NOT inside the
103
- // worktree's toplevel.
104
- const topWithSep = topLevel.endsWith(path.sep) ? topLevel : topLevel + path.sep;
105
- const insideToplevel =
106
- commonDirAbs === topLevel || commonDirAbs.startsWith(topWithSep);
107
- if (insideToplevel) return undefined;
108
-
109
- // `commonDir` for a worktree is `<main-repo>/.git` — the parent dir is
110
- // the main worktree root.
111
- const mainPath = path.dirname(commonDirAbs);
112
- const name = path.basename(cwd);
113
- return { mainPath, name };
91
+ return worktreeFromRoots(git.checkoutRoots({ cwd }));
92
+ }
93
+
94
+ /** Pure worktree-identity derivation from a resolver verdict (see {@link detectWorktree}). */
95
+ export function worktreeFromRoots(roots: git.GitCheckoutRoots | null | undefined): GitWorktreeInfo | undefined {
96
+ if (!roots?.isLinkedWorktree) return undefined;
97
+
98
+ const mainPath = roots.mainCheckout;
99
+ if (!mainPath || git.hasGitPathSegment(mainPath)) return undefined;
100
+
101
+ // `thisCheckout`, not `cwd`: a session can sit in a SUBDIRECTORY of the
102
+ // worktree, and `basename(cwd)` would then label the card with the subdir
103
+ // name. The verdict already carries the worktree root.
104
+ //
105
+ // A LINKED WORKTREE ALWAYS HAS A WORKING TREE, so a null `thisCheckout` here
106
+ // means `--show-toplevel` failed — an inconclusive probe, not a nameless
107
+ // worktree. Falling back to `cwd` would silently reintroduce the subdirectory
108
+ // mislabel for exactly the case we cannot verify, so omit the field instead.
109
+ if (!roots.thisCheckout) return undefined;
110
+ return { mainPath, name: path.basename(roots.thisCheckout) };
114
111
  }
115
112
 
116
113
  /**
117
- * Gather working-tree dirtiness + upstream drift for `cwd` via one
118
- * `git status --porcelain=v2 --branch` call. Returns `undefined` on an
119
- * inconclusive probe (git missing, not a repo, timeout) so the broadcast
120
- * omits the field rather than sending a false all-clean status.
121
- * See change: add-session-uncommitted-indicator-and-commit.
114
+ * Static git facts for a cwd: everything that changes only on a git
115
+ * operation that rewrites the repo layout (remote edit, worktree move/repair,
116
+ * `git init`). Cached per cwd and re-probed on a stamp change, on demand and
117
+ * every 10th tick. See change: optimize-polling-hot-paths (D4).
122
118
  */
123
- export function gatherGitStatus(cwd: string): GitStatus | undefined {
124
- const res = git.gitStatusV2({ cwd });
125
- return res.ok ? res.value : undefined;
119
+ export interface StaticGitFacts {
120
+ remoteUrl?: string;
121
+ roots: git.GitCheckoutRoots | null;
122
+ gitDir?: string;
123
+ /** Existence/type/mtime stamp of `<thisCheckout>/.git` and `gitDir` (or `<cwd>/.git`). */
124
+ dotGitStamp: string;
126
125
  }
127
126
 
128
- /** Gather all git info for a directory. Returns undefined if not a git repo. */
129
- export function gatherGitInfo(cwd: string): GitInfo | undefined {
130
- const branch = detectBranch(cwd);
131
- if (!branch) return undefined;
127
+ /** Injectable stat for the stamp (tests). */
128
+ export type StatFn = (p: string) => { isDirectory(): boolean; mtimeMs: number };
132
129
 
130
+ /**
131
+ * Existence + type for a directory, existence + mtime for a FILE. Directory
132
+ * mtimes are deliberately excluded: they change whenever an entry inside is
133
+ * created/renamed (`index.lock` on every `git add`), which would turn routine
134
+ * git activity into a full facts re-probe. A worktree's `.git` pointer FILE and
135
+ * `<gitDir>/gitdir` are files, so `git worktree repair/move` still shows.
136
+ */
137
+ function statToken(p: string, stat: StatFn): string {
138
+ try {
139
+ const st = stat(p);
140
+ return st.isDirectory() ? "d" : `f${st.mtimeMs}`;
141
+ } catch {
142
+ return "-";
143
+ }
144
+ }
145
+
146
+ /** Cheap (a few `stat`s, no spawn) change detector for worktree identity. */
147
+ export function dotGitStampOf(cwd: string, roots: git.GitCheckoutRoots | null, stat: StatFn = statSync): string {
148
+ if (!roots) return `none:${statToken(path.join(cwd, ".git"), stat)}`;
149
+ const top = roots.thisCheckout ?? cwd;
150
+ const gitDir = roots.gitDir ? statToken(roots.gitDir, stat) : "-";
151
+ const pointer = roots.gitDir ? statToken(path.join(roots.gitDir, "gitdir"), stat) : "-";
152
+ return `${statToken(path.join(top, ".git"), stat)}|${gitDir}|${pointer}`;
153
+ }
154
+
155
+ /** Synchronous facts probe (first evaluation: ~3-5 git spawns, once per cwd). */
156
+ function evaluateFacts(cwd: string): StaticGitFacts {
157
+ const roots = git.checkoutRoots({ cwd }) ?? null;
158
+ incPollCost("pollGitSpawns", 4); // gitDir/commonDir/toplevel + remote (approximate; linked worktrees +2)
133
159
  const remoteUrl = detectRemoteUrl(cwd);
134
- const prNumber = detectPrNumber(cwd);
135
- const gitWorktree = detectWorktree(cwd);
160
+ return { remoteUrl, roots, gitDir: roots?.gitDir, dotGitStamp: dotGitStampOf(cwd, roots) };
161
+ }
162
+
163
+ /** Async twin used for background re-probes; never blocks pi's loop. */
164
+ async function evaluateFactsAsync(cwd: string): Promise<StaticGitFacts> {
165
+ const [roots, remoteUrl] = await Promise.all([
166
+ git.checkoutRootsAsync({ cwd }).catch(() => null),
167
+ git.remoteUrlOrAsync({ cwd }).catch(() => undefined),
168
+ ]);
169
+ incPollCost("pollGitSpawns", 4);
170
+ return { remoteUrl, roots: roots ?? null, gitDir: roots?.gitDir, dotGitStamp: dotGitStampOf(cwd, roots ?? null) };
171
+ }
172
+
173
+ export interface GitFactsDeps {
174
+ evaluate: (cwd: string) => StaticGitFacts;
175
+ evaluateAsync: (cwd: string) => Promise<StaticGitFacts>;
176
+ stamp: (cwd: string, roots: git.GitCheckoutRoots | null) => string;
177
+ }
178
+
179
+ const sameFacts = (a: StaticGitFacts, b: StaticGitFacts) =>
180
+ a.remoteUrl === b.remoteUrl && JSON.stringify(a.roots) === JSON.stringify(b.roots);
181
+
182
+ /** Per-cwd cache of {@link StaticGitFacts}. */
183
+ export class GitFactsCache {
184
+ private readonly map = new Map<string, StaticGitFacts>();
185
+ constructor(
186
+ private readonly deps: GitFactsDeps = { evaluate: evaluateFacts, evaluateAsync: evaluateFactsAsync, stamp: (c, r) => dotGitStampOf(c, r) },
187
+ ) {}
188
+
189
+ /** Synchronous probe + store. */
190
+ evaluate(cwd: string): StaticGitFacts {
191
+ const facts = this.deps.evaluate(cwd);
192
+ this.map.set(cwd, facts);
193
+ return facts;
194
+ }
195
+
196
+ get(cwd: string): StaticGitFacts | undefined {
197
+ return this.map.get(cwd);
198
+ }
199
+
200
+ /** True when the cheap `.git` stamp no longer matches the cached one. */
201
+ stampChanged(cwd: string): boolean {
202
+ const cached = this.map.get(cwd);
203
+ return !!cached && this.deps.stamp(cwd, cached.roots) !== cached.dotGitStamp;
204
+ }
205
+
206
+ /**
207
+ * Async re-probe. The result is committed only when `accept()` (checked AFTER
208
+ * the await) still says the caller's context is current — a session/cwd
209
+ * change that installed fresh facts meanwhile must not be overwritten by an
210
+ * older in-flight probe. Reports whether the facts changed and whether they
211
+ * were committed.
212
+ */
213
+ async reprobe(
214
+ cwd: string,
215
+ accept: () => boolean = () => true,
216
+ ): Promise<{ facts: StaticGitFacts; changed: boolean; committed: boolean }> {
217
+ const facts = await this.deps.evaluateAsync(cwd);
218
+ if (!accept()) return { facts, changed: false, committed: false };
219
+ const before = this.map.get(cwd);
220
+ this.map.set(cwd, facts);
221
+ return { facts, changed: !before || !sameFacts(before, facts), committed: true };
222
+ }
136
223
 
137
- const links: GitLinks = remoteUrl ? buildGitLinks(remoteUrl, branch, prNumber) : {};
224
+ clear(): void {
225
+ this.map.clear();
226
+ }
227
+ }
228
+
229
+ /** Injected reads for {@link createHeadBranchReader}. */
230
+ export interface HeadBranchDeps {
231
+ readFile: (p: string) => string;
232
+ /** mtime of `p`, or 0 when it cannot be statted. */
233
+ mtimeOf: (p: string) => number;
234
+ /** Async CLI branch detection (symbolic name, or git's own short SHA when detached). */
235
+ fallback: (cwd: string) => Promise<string | undefined>;
236
+ }
138
237
 
238
+ const defaultHeadDeps: HeadBranchDeps = {
239
+ readFile: (p) => readFileSync(p, "utf8"),
240
+ mtimeOf: (p) => {
241
+ try {
242
+ return statSync(p).mtimeMs;
243
+ } catch {
244
+ return 0;
245
+ }
246
+ },
247
+ fallback: async (cwd) => {
248
+ incPollCost("pollGitSpawns");
249
+ const ref = await git.currentBranchOrAsync({ cwd });
250
+ if (!ref) return undefined;
251
+ if (ref !== "HEAD") return ref;
252
+ incPollCost("pollGitSpawns");
253
+ return (await git.headShaOrAsync({ cwd, short: true })) ?? "HEAD";
254
+ },
255
+ };
256
+
257
+ export interface HeadBranchReader {
258
+ /**
259
+ * Current branch from `<gitDir>/HEAD` — a pure file read for the common
260
+ * `ref: refs/heads/<name>` case. Anything else (SHA, other ref, unreadable)
261
+ * uses an async CLI fallback memoised per HEAD content; while it is pending
262
+ * the previous value is returned. `undefined` = not resolved yet.
263
+ */
264
+ read(cwd: string, gitDir: string | undefined): string | undefined;
265
+ /** Forget the previous value (cwd/session change). */
266
+ reset(): void;
267
+ }
268
+
269
+ /**
270
+ * See change: optimize-polling-hot-paths (D5). `onResolved` fires when a
271
+ * fallback settles with a value, so the caller can request a probe.
272
+ */
273
+ export function createHeadBranchReader(
274
+ onResolved: () => void = () => {},
275
+ deps: HeadBranchDeps = defaultHeadDeps,
276
+ ): HeadBranchReader {
277
+ const memo = new Map<string, string | undefined>();
278
+ const pending = new Set<string>();
279
+ let last: string | undefined;
139
280
  return {
140
- gitBranch: branch,
141
- gitBranchUrl: links.branchUrl,
142
- gitPrNumber: prNumber,
143
- gitPrUrl: links.prUrl,
144
- gitWorktree,
281
+ read(cwd, gitDir) {
282
+ let key: string;
283
+ if (gitDir) {
284
+ try {
285
+ const content = deps.readFile(path.join(gitDir, "HEAD")).trim();
286
+ const m = content.match(/^ref:\s*refs\/heads\/(.+)$/);
287
+ if (m) {
288
+ last = m[1];
289
+ return last;
290
+ }
291
+ key = `c:${gitDir}:${content}`;
292
+ } catch (e) {
293
+ key = `e:${gitDir}:${(e as NodeJS.ErrnoException)?.code ?? "?"}:${deps.mtimeOf(path.join(gitDir, "HEAD"))}`;
294
+ }
295
+ } else {
296
+ key = `e:nogitdir:${cwd}`;
297
+ }
298
+ if (memo.has(key)) {
299
+ const v = memo.get(key);
300
+ if (v !== undefined) last = v;
301
+ return last;
302
+ }
303
+ if (!pending.has(key)) {
304
+ pending.add(key);
305
+ deps.fallback(cwd).then(
306
+ (v) => {
307
+ pending.delete(key);
308
+ memo.set(key, v);
309
+ if (v !== undefined) onResolved();
310
+ },
311
+ () => {
312
+ pending.delete(key);
313
+ memo.set(key, undefined);
314
+ },
315
+ );
316
+ }
317
+ return last;
318
+ },
319
+ reset() {
320
+ last = undefined;
321
+ memo.clear();
322
+ pending.clear();
323
+ },
145
324
  };
146
325
  }
326
+
327
+ /** Assemble the wire-shaped info from a resolved branch + cached facts. */
328
+ export function gitInfoFrom(branch: string, facts: StaticGitFacts): GitInfo {
329
+ const links: GitLinks = facts.remoteUrl ? buildGitLinks(facts.remoteUrl, branch) : {};
330
+ return { gitBranch: branch, gitBranchUrl: links.branchUrl, gitWorktree: worktreeFromRoots(facts.roots) };
331
+ }
332
+
333
+ /**
334
+ * Gather all git info for a directory SYNCHRONOUSLY (first evaluation only:
335
+ * registration, cwd/session change). Returns undefined if not a git repo.
336
+ * No PR lookup here: PR status is probed asynchronously by `pr-status.ts`.
337
+ * See changes: redesign-composer-session-strip (D5), optimize-polling-hot-paths.
338
+ */
339
+ export function gatherGitInfo(cwd: string): GitInfo | undefined {
340
+ const branch = detectBranch(cwd);
341
+ if (!branch) return undefined;
342
+ incPollCost("pollGitSpawns", 1);
343
+ return gitInfoFrom(branch, evaluateFacts(cwd));
344
+ }
@@ -1,27 +0,0 @@
1
- # DOX — packages/extension/.pi/skills/doctor
2
-
3
- Modular doctor skill. Thin router `SKILL.md` + N self-contained capability MDs
4
- read on demand + shared `_lib` check primitives. Router derives symptom map +
5
- sweep DAG from module front-matter; adding a module MD auto-registers it.
6
- See change: add-modular-doctor-skill.
7
-
8
- | File | Purpose |
9
- |------|---------|
10
- | `SKILL.md` | Thin router. NO capability knowledge. Routes symptom→module, runs named module, or full sweep (env→pi→peers→plugins→build→runtime) with lower-layer short-circuit. Documents two-tier self-update + `--regenerate`. |
11
- | `_lib/index.ts` | Barrel re-exporting all `_lib` primitives. |
12
- | `_lib/front-matter.ts` | Parses module front-matter (`name`/`scope`/`symptoms`/`depends-on`/`derives-from`). `parseFrontMatter`, `extractFrontMatterBlock`. Scalar + block/inline list subset. |
13
- | `_lib/router.ts` | `loadModules`, `buildSymptomMap`, `routeSymptom` (punctuation-insensitive), `buildSweepOrder` (topo-sort by depends-on), `planSweep` (short-circuit: dep failure suppresses dependents). |
14
- | `_lib/checks.ts` | Wraps shared resolver primitives (NO reimpl). `probePeer` (tier-1 createRequire / tier-2 pi packages[]), `detectNameSkew`, `enumeratePiInstalls`, `piVersionDivergence`, `readPiFloor`. |
15
- | `_lib/server-tier.ts` | Additive `/api/*` tier. `fetchHealth`, `fetchPiCoreVersions` — degrade to `{ok:false,reason}` when server down, never throw. |
16
- | `_lib/provenance.ts` | Fact labeller. `fileFact`/`serverFact`/`summariseProvenance` — `serverUnavailable` true when no server-enriched fact. |
17
- | `_lib/knowledge-hash.ts` | Per-module semantic hash. `extractSemanticTokens` (package names + semver, no prose), `computeKnowledgeHash`, `checkDrift`, read/write sidecar. Whitespace-stable; peer rename / floor bump drifts. |
18
- | `_lib/derive-tokens.ts` | `MODULE_TOKEN_SOURCES` maps module→repo-relative derives-from files; `deriveLiveTokens(repoRoot,id)` reads them for the hash. |
19
- | `_lib/regenerate.ts` | CLI: `--check` reports drift, `--write [module]` rewrites sidecars from live sources. Never edits authored prose. `findRepoRoot`, `reportDrift`, `writeHashes`. |
20
- | `modules/env-node.md` | Node version/OS/platform baseline. depends-on: none (root layer). |
21
- | `modules/pi-resolution.md` | Enumerate every pi install (CLI/repo/managed/nvm/cwd), flag divergence + floor violation. depends-on: env-node. |
22
- | `modules/peers.md` | pi-flows + anthropic peer via tier-1/tier-2; detect published-name skew. depends-on: pi-resolution. |
23
- | `modules/plugins-bridges.md` | Bridge `bridgeLoadedFrom`; flag dashboardPluginBridges-only (invisible to pi packages[]); activation status. depends-on: peers. |
24
- | `modules/build-reload.md` | Three-component rebuild/reload gaps (client build / server restart / bridge reload). depends-on: install-topology. |
25
- | `modules/install-topology.md` | Detect npm-global / Electron (immutable) / Docker / dev; topology-specific fix routing. depends-on: env-node. |
26
- | `modules/model-resolution.md` | `model:resolve` handler, roles/preset, `@role` resolvability, pi-flows model-resolve-aware. depends-on: pi-resolution, plugins-bridges. |
27
- | `modules/*.knowledge.hash` | Per-module stored knowledge-hash sidecar (7). Regenerate via `_lib/regenerate.ts --write`. |
@@ -1,104 +0,0 @@
1
- # DOX Doctrine
2
-
3
- Canonical per-directory `AGENTS.md` documentation doctrine. Shipped once with
4
- the `project-init` skill. Adapted from agent0ai/dox, extended with a kb-backed
5
- READ discipline. Retrievable via `kb_search "dox doctrine"`.
6
-
7
- The scaffold seeds ONE block into a project's root `AGENTS.md` when that file
8
- lacks the `<!-- dox-doctrine -->` marker: the WRITE discipline plus one READ
9
- variant (kb-wired or manual). The sections below are delimited so the seeder
10
- can compose the right block.
11
-
12
- <!-- dox:write:start -->
13
- ## Documentation Update Protocol (WRITE discipline)
14
-
15
- Per-directory `AGENTS.md` files form a tree. Each directory `AGENTS.md` is the
16
- per-file record for the files in that directory. The ROOT `AGENTS.md` holds
17
- doctrine + architecture pointers only — never a per-file index.
18
-
19
- **Keep the root lean.** The root `AGENTS.md` loads into every agent turn — every
20
- byte costs tokens on every turn. A verbose root file buries the rules the model
21
- must follow (signal dilution) and measurably degrades adherence; a lean file
22
- keeps doctrine salient. Default assumption: your update does NOT belong in the
23
- root — route it by the table below.
24
-
25
- **Route every doc update by kind:**
26
-
27
- | Kind of update | Goes in |
28
- |---|---|
29
- | New file in a directory, or its per-file detail / change history | Nearest directory `AGENTS.md`. Add a `` \| `<basename>` \| <purpose> \| `` row, path-alphabetical. |
30
- | Data flow, protocol, architecture rationale | `docs/architecture.md` or a `docs/<topic>.md` |
31
- | End-user / developer setup | `README.md` |
32
- | Cross-cutting rule every agent needs every turn (rare) | ROOT `AGENTS.md` |
33
-
34
- **Read before editing (chain walk).** Before editing a file, read the nearest
35
- `AGENTS.md` chain root→leaf so you know the file's recorded purpose, contracts,
36
- and change history. Do not edit blind.
37
-
38
- **Update after editing (closeout pass).** After changing a file, update its row
39
- in the nearest directory `AGENTS.md`: find the file's row, update its purpose in
40
- place; if absent, add it in path-alphabetical order. New directory → scaffold
41
- its `AGENTS.md`. One row per file. The purpose carries a one-line summary, key
42
- exported symbols, contracts/invariants, and `See change: <id>` history.
43
-
44
- **Row style (caveman).** Short declarative fragments. Drop articles. Subject →
45
- verb → object, present tense. One fact per row. Prefer concrete tokens (paths,
46
- symbols, env vars) over prose. Keep identifiers verbatim.
47
-
48
- **Size rule — split an over-large directory `AGENTS.md` file-based.** pi
49
- auto-injects a directory `AGENTS.md` on every turn when cwd sits at/below it, so
50
- an over-large directory `AGENTS.md` (past a byte cap — typically a flat
51
- directory holding many files) is not supported. Split it file-based: a row
52
- exceeding the length threshold promotes to a per-file `<File>.AGENTS.md`
53
- sidecar carrying that file's full detail (including every `See change:`). The
54
- sidecar is pull-only — its name is not `AGENTS.md`, so pi never auto-injects it
55
- — yet it stays search-indexed (`agents` doc_type). The directory `AGENTS.md`
56
- keeps a one-line summary plus a `→ see \`<File>.AGENTS.md\`` pointer. Rows within
57
- the threshold stay verbatim (lossless).
58
- <!-- dox:write:end -->
59
-
60
- <!-- dox:read:kb:start -->
61
- ## Finding docs (READ discipline)
62
-
63
- `kb_*` tools are faster and cheaper than raw search — they return a one-line
64
- purpose + key exports per file, not raw bytes. **This fires on the ACTION, not
65
- the intent** — before you `grep`/`rg` for a symbol, `cat`/read a file to learn
66
- what it does, or chase an import, the kb call goes first. It fires **even
67
- mid-task when you already know the file**; knowing the file does not exempt you.
68
- When your reflex is the left column, run the right column instead:
69
-
70
- | You're about to… | Do this FIRST instead |
71
- |---|---|
72
- | `grep -rn "SymbolName" src/` — find where a fn / type / const lives | `kb_search --doc-type agents "SymbolName"` — tree indexes key exports per file |
73
- | `grep -rn "feature\|topic" src/` — how does X work / where's X handled | `kb_search "feature topic"` |
74
- | `cat` / read a file just to learn its purpose before editing | `kb agents <path>` — one-line purpose + exports + change history |
75
- | chase imports / callers across files | `kb_neighbors <path\|heading>` |
76
- | read one doc section in full | `kb_get <path> <section>` |
77
-
78
- **Fall-through (explicit):** if the kb call returns nothing relevant, `rg` /
79
- source read is allowed — then add the missing directory `AGENTS.md` row per the
80
- WRITE discipline. kb does NOT replace grep; it goes first.
81
- <!-- dox:read:kb:end -->
82
-
83
- <!-- dox:read:manual:start -->
84
- ## Finding docs (READ discipline)
85
-
86
- The directory `AGENTS.md` tree is faster and cheaper than raw search — each row
87
- carries a one-line purpose + key exports per file. **This fires on the ACTION,
88
- not the intent** — before you `grep`/`rg` for a symbol, `cat`/read a file to
89
- learn what it does, or chase an import, consult the tree first. It fires **even
90
- mid-task when you already know the file**; knowing the file does not exempt you.
91
- When your reflex is the left column, do the right column instead:
92
-
93
- | You're about to… | Do this FIRST instead |
94
- |---|---|
95
- | `grep -rn "SymbolName" src/` — find where a fn / type / const lives | read the nearest directory `AGENTS.md`; scan rows for the symbol |
96
- | `grep -rn "feature\|topic" src/` — how does X work / where's X handled | walk the root→nearest `AGENTS.md` chain toward the file's directory |
97
- | `cat` a file just to learn its purpose before editing | read that file's row in its directory `AGENTS.md` (purpose + exports + change history) |
98
- | chase imports / callers across files | follow the `See change:` / pointer references in the nearest `AGENTS.md` |
99
- | read one doc section in full | open the specific `docs/<topic>.md` section |
100
-
101
- **Fall-through (explicit):** if the tree misses, `rg` / source read is allowed —
102
- then add the missing directory `AGENTS.md` row per the WRITE discipline. The tree
103
- goes first.
104
- <!-- dox:read:manual:end -->
package/src/AGENTS.md DELETED
@@ -1,57 +0,0 @@
1
- # DOX — packages/extension/src
2
-
3
- Files in this directory. One row per source file.
4
-
5
- | File | Purpose |
6
- |------|---------|
7
- | `abort-latch.ts` | Pure class `AbortLatch`. Keeps user abort latched so provider backoff (5–60s) outliving 2s persistent-abort… → see `abort-latch.ts.AGENTS.md` |
8
- | `agent-settled.ts` | Bridge `agent_settled` normalization (pure). `nativeAgentSettledSupported(piVersion)` → pi ≥ 0.80.4 emits… → see `agent-settled.ts.AGENTS.md` |
9
- | `artifact-roots.ts` | Artifact-root allowlist for Fix B bridge image inlining. `resolveArtifactRoots({homedir,env,realpathSync})` →… → see `artifact-roots.ts.AGENTS.md` |
10
- | `ask-user-attachments.ts` | Persist image attachments for ask_user input responses. Exports `attachmentDirForSession`,… → see `ask-user-attachments.ts.AGENTS.md` |
11
- | `ask-user-tool.ts` | Register `ask_user` pi tool at `session_start` (avoids static-name conflict). Exports `registerAskUserTool`. → see `ask-user-tool.ts.AGENTS.md` |
12
- | `auto-session-namer.ts` | Automatic session topic-naming (bridge-side). Pure helpers `shouldSkipByPrefilter`, `parseTitle`,… → see `auto-session-namer.ts.AGENTS.md` |
13
- | `bridge-context.ts` | Shared mutable bridge state + pure predicates. Exports `BridgeContext`, `DASHBOARD_NATIVE_COMMANDS`,… → see `bridge-context.ts.AGENTS.md` |
14
- | `bridge-default-model-gate.ts` | Pure predicate `shouldApplyDefaultModel({reason, entryCount, hasModelRegistry, hasDefaultModel})`. → see `bridge-default-model-gate.ts.AGENTS.md` |
15
- | `bridge.ts` | Main bridge extension entry (default export). Connects to dashboard server, forwards pi events via… → see `bridge.ts.AGENTS.md` |
16
- | `command-handler.ts` | Command routing: `!`/`!!` bash, `/compact`, slash commands. → see `command-handler.ts.AGENTS.md` |
17
- | `connection.ts` | WebSocket connection manager with exponential backoff reconnect, message buffering while disconnected,… → see `connection.ts.AGENTS.md` |
18
- | `dashboard-context-injector.ts` | Registers `before_agent_start` handler. Splice-replaces trailing `Current working directory:` line of system… → see `dashboard-context-injector.ts.AGENTS.md` |
19
- | `dashboard-default-adapter.ts` | Built-in last-resort `PromptAdapter` (priority `9999`). Exports `DashboardDefaultAdapter`. → see `dashboard-default-adapter.ts.AGENTS.md` |
20
- | `dev-build.ts` | Dev build-on-reload helper. Exports `runDevBuild`, `DevBuildOptions`. → see `dev-build.ts.AGENTS.md` |
21
- | `empty-actionable-guard-config.ts` | Resolve empty-actionable guard config from env. Exports `resolveGuardConfig(env)` → `{mode,retryCap}`. → see `empty-actionable-guard-config.ts.AGENTS.md` |
22
- | `empty-actionable-guard.ts` | Bounded continue-or-surface decision for empty-actionable turns. → see `empty-actionable-guard.ts.AGENTS.md` |
23
- | `event-forwarder.ts` | Map pi event objects to `event_forward` protocol messages. Exports `mapEventToProtocol`. → see `event-forwarder.ts.AGENTS.md` |
24
- | `flow-event-wiring.ts` | Register pi-flows + pi-subagents event listeners on `pi.events`. → see `flow-event-wiring.ts.AGENTS.md` |
25
- | `git-link-builder.ts` | Parse SSH/HTTPS remote URLs into branch + PR links. Exports `parseRemoteUrl`, `detectPlatform`,… → see `git-link-builder.ts.AGENTS.md` |
26
- | `commit-draft.ts` | Pure AI-draft fallback ladder (no pi-SDK coupling). Exports `draftCommitMessage(deps)` → `{message, source}`,… → see `commit-draft.ts.AGENTS.md` |
27
- | `commit-draft-agent.ts` | pi-SDK-coupled half of AI-draft. Exports `buildSessionContextText(ctx, maxChars)` (compacts… → see `commit-draft-agent.ts.AGENTS.md` |
28
- | `git-poll.ts` | Exports `runGitPollTick(deps)` + `GitPollDeps` interface. Pure git + name/model poll-tick body. → see `git-poll.ts.AGENTS.md` |
29
- | `hasui-flip.ts` | Flip `ctx.hasUI` to `true` after bridge patches `ctx.ui.*`. Exports `flipHasUI`. → see `hasui-flip.ts.AGENTS.md` |
30
- | `markdown-image-inliner.ts` | Bridge helper rewriting assistant `![alt](path)` → `![alt](pi-asset:<hash>)` (SHA-256/16, MIME allowlist, 5… → see `markdown-image-inliner.ts.AGENTS.md` |
31
- | `model-tracker.ts` | Diff-and-send trackers for model / session name / git info / pi version / cwd-missing. → see `model-tracker.ts.AGENTS.md` |
32
- | `multiselect-decode.ts` | Pure helper decoding `PromptResponse` into `string[] | undefined`. → see `multiselect-decode.ts.AGENTS.md` |
33
- | `multiselect-list.ts` | TUI multi-select component implementing pi-tui `ComponentLike`. Exports `MultiSelectList`, `ComponentLike`. → see `multiselect-list.ts.AGENTS.md` |
34
- | `multiselect-polyfill.ts` | Polyfill `ctx.ui.multiselect`. Exports `polyfillMultiselect`, `PolyfillCtx`. → see `multiselect-polyfill.ts.AGENTS.md` |
35
- | `openspec-cli-shim.ts` | Provision bare `openspec` in-session: shim pinned CLI onto `process.env.PATH` at bridge init (fail-soft). Exports `provisionOpenspecCli`,… → see `openspec-cli-shim.ts.AGENTS.md` |
36
- | `process-metrics.ts` | Lightweight process metrics collector for bridge heartbeats. → see `process-metrics.ts.AGENTS.md` |
37
- | `process-scanner.ts` | Detect child processes of a pi session. Exports `getOwnPgid`, `captureChildPgids`, `scanTrackedProcesses`,… → see `process-scanner.ts.AGENTS.md` |
38
- | `project-trust.ts` | `project_trust` auto-decision (pure gate + defensive cwd read). → see `project-trust.ts.AGENTS.md` |
39
- | `prompt-bus.ts` | Prompt dispatch bus — first-response-wins adapter routing + cross-adapter dismissal. → see `prompt-bus.ts.AGENTS.md` |
40
- | `prompt-expander.ts` | Expand prompt templates from disk for dashboard slash commands (`pi.sendUserMessage` skips expansion). → see `prompt-expander.ts.AGENTS.md` |
41
- | `provider-register.ts` | Register custom LLM providers + auto-discovered models from `~/.pi/agent/providers.json`. → see `provider-register.ts.AGENTS.md` |
42
- | `subagent-frame-buffer.ts` | Pure class `SubagentFrameBuffer` + `SUBAGENT_CHANNELS` set. Makes running-subagent timeline reconcilable. → see `subagent-frame-buffer.ts.AGENTS.md` |
43
- | `retry-tracker.ts` | Pure helper class `RetryTracker` synthesizes `auto_retry_start` / `auto_retry_end` by OBSERVING pi's own… → see `retry-tracker.ts.AGENTS.md` |
44
- | `role-manager.ts` | Manages session model roles. Registers six `roles:*` handlers… → see `role-manager.ts.AGENTS.md` |
45
- | `role-model-tools.ts` | Agent-facing tools registered via `pi.registerTool` (capability agent-role-model-tools). → see `role-model-tools.ts.AGENTS.md` |
46
- | `server-auto-start.ts` | Auto-start orchestration: discover dashboard via mDNS → health-check fallback → spawn server process. → see `server-auto-start.ts.AGENTS.md` |
47
- | `server-launcher.ts` | Spawns dashboard server as detached process via shared `launchDashboardServer`. → see `server-launcher.ts.AGENTS.md` |
48
- | `server-probe.ts` | TCP port probe. Exports `isPortOpen(port)` — 1s timeout localhost connect, resolves `true` on connect else `false`. Detects running dashboard server. |
49
- | `session-sync.ts` | Session register/replay/switch lifecycle. Exports `sendStateSync`, `replaySessionEntries`,… → see `session-sync.ts.AGENTS.md` |
50
- | `slash-dispatch.ts` | Extension slash-command dispatch (routing-step 9). Exports `tryDispatchExtensionCommand`, `FeedbackSink`,… → see `slash-dispatch.ts.AGENTS.md` |
51
- | `source-detector.ts` | Detects session source env. Exports `detectSessionSource(hasUI?, sessionFile?)` → `SessionSource`. → see `source-detector.ts.AGENTS.md` |
52
- | `tool-result-image-inliner.ts` | Bridge Fix B tool-result image inliner. On `tool_execution_end` scans result text for absolute image paths… → see `tool-result-image-inliner.ts.AGENTS.md` |
53
- | `tui-prompt-adapter.ts` | Production PromptBus adapter for Pi's TUI. Exports `createTuiPromptAdapter`, `TuiPromptUi`. Presents select/input/confirm/editor via captured unpatched UI; forwards confirm `metadata.message`; no multiselect arm. → see `tui-prompt-adapter.ts.AGENTS.md` |
54
- | `turn-actionability.ts` | Pure provider-agnostic classifier. Exports `classifyTurnActionability(turn)` →… → see `turn-actionability.ts.AGENTS.md` |
55
- | `ui-modules.ts` | Extension UI system bridge side. Exports `refreshUiModules`, `subscribeUiInvalidate`, `handleUiManagement`,… → see `ui-modules.ts.AGENTS.md` |
56
- | `vcs-info.ts` | Gathers git branch/remote/PR/worktree info via shared platform git helpers. → see `vcs-info.ts.AGENTS.md` |
57
- | `visibility-intent.ts` | Resolves `session_register` visibility fields. Exports `resolveVisibilityIntent`,… → see `visibility-intent.ts.AGENTS.md` |