@phren/cli 0.2.15 → 0.3.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 (392) hide show
  1. package/README.md +2 -2
  2. package/dist/agent-instructions.d.ts +12 -0
  3. package/dist/agent-instructions.js +52 -0
  4. package/dist/bridge/agent-hook-stores.d.ts +32 -0
  5. package/dist/bridge/agent-hook-stores.js +67 -0
  6. package/dist/bridge/agent-hooks.d.ts +195 -2
  7. package/dist/bridge/agent-hooks.js +1049 -38
  8. package/dist/bridge/canary.d.ts +27 -0
  9. package/dist/bridge/canary.js +189 -0
  10. package/dist/bridge/changes.d.ts +57 -0
  11. package/dist/bridge/changes.js +403 -0
  12. package/dist/bridge/client.d.ts +3 -0
  13. package/dist/bridge/client.js +36 -0
  14. package/dist/bridge/code-note.d.ts +23 -0
  15. package/dist/bridge/code-note.js +51 -0
  16. package/dist/bridge/code-routes.d.ts +151 -0
  17. package/dist/bridge/code-routes.js +442 -0
  18. package/dist/bridge/codex-threads.d.ts +27 -0
  19. package/dist/bridge/codex-threads.js +442 -0
  20. package/dist/bridge/command.d.ts +7 -0
  21. package/dist/bridge/command.js +50 -5
  22. package/dist/bridge/computer-names.d.ts +4 -0
  23. package/dist/bridge/computer-names.js +16 -0
  24. package/dist/bridge/computers.d.ts +9 -0
  25. package/dist/bridge/computers.js +111 -0
  26. package/dist/bridge/context.d.ts +14 -0
  27. package/dist/bridge/context.js +149 -0
  28. package/dist/bridge/dispatch-command.d.ts +3 -0
  29. package/dist/bridge/dispatch-command.js +93 -0
  30. package/dist/bridge/dispatch-hosts.d.ts +23 -0
  31. package/dist/bridge/dispatch-hosts.js +25 -0
  32. package/dist/bridge/dispatch-returns.d.ts +125 -0
  33. package/dist/bridge/dispatch-returns.js +283 -0
  34. package/dist/bridge/dispatch-tree.d.ts +54 -0
  35. package/dist/bridge/dispatch-tree.js +198 -0
  36. package/dist/bridge/dispatch.d.ts +210 -0
  37. package/dist/bridge/dispatch.js +286 -0
  38. package/dist/bridge/enroll.d.ts +31 -0
  39. package/dist/bridge/enroll.js +236 -0
  40. package/dist/bridge/fanout-messages.d.ts +74 -0
  41. package/dist/bridge/fanout-messages.js +230 -0
  42. package/dist/bridge/fanouts.d.ts +160 -0
  43. package/dist/bridge/fanouts.js +702 -0
  44. package/dist/bridge/file-range.d.ts +16 -0
  45. package/dist/bridge/file-range.js +90 -0
  46. package/dist/bridge/files.d.ts +20 -0
  47. package/dist/bridge/files.js +54 -0
  48. package/dist/bridge/git-publish.d.ts +23 -0
  49. package/dist/bridge/git-publish.js +145 -0
  50. package/dist/bridge/git-worktrees.d.ts +21 -0
  51. package/dist/bridge/git-worktrees.js +150 -0
  52. package/dist/bridge/git.d.ts +54 -0
  53. package/dist/bridge/git.js +552 -0
  54. package/dist/bridge/grants.d.ts +31 -0
  55. package/dist/bridge/grants.js +181 -0
  56. package/dist/bridge/hand-off.d.ts +79 -0
  57. package/dist/bridge/hand-off.js +151 -0
  58. package/dist/bridge/health.d.ts +128 -0
  59. package/dist/bridge/health.js +260 -0
  60. package/dist/bridge/herdr.d.ts +79 -6
  61. package/dist/bridge/herdr.js +292 -27
  62. package/dist/bridge/hook-main.js +2 -0
  63. package/dist/bridge/install.d.ts +28 -1
  64. package/dist/bridge/install.js +225 -38
  65. package/dist/bridge/launch-worktree.d.ts +21 -0
  66. package/dist/bridge/launch-worktree.js +70 -0
  67. package/dist/bridge/limits.d.ts +20 -0
  68. package/dist/bridge/limits.js +65 -0
  69. package/dist/bridge/locate.d.ts +16 -0
  70. package/dist/bridge/locate.js +75 -0
  71. package/dist/bridge/metrics.d.ts +29 -0
  72. package/dist/bridge/metrics.js +71 -0
  73. package/dist/bridge/model-switch.d.ts +35 -0
  74. package/dist/bridge/model-switch.js +250 -0
  75. package/dist/bridge/models.d.ts +46 -0
  76. package/dist/bridge/models.js +257 -0
  77. package/dist/bridge/opencode-approvals.d.ts +6 -0
  78. package/dist/bridge/opencode-approvals.js +60 -0
  79. package/dist/bridge/pane-text.d.ts +15 -0
  80. package/dist/bridge/pane-text.js +23 -0
  81. package/dist/bridge/peers.d.ts +27 -0
  82. package/dist/bridge/peers.js +130 -0
  83. package/dist/bridge/projects.d.ts +12 -1
  84. package/dist/bridge/projects.js +268 -20
  85. package/dist/bridge/protocol.d.ts +35 -2
  86. package/dist/bridge/protocol.js +61 -7
  87. package/dist/bridge/push.d.ts +83 -0
  88. package/dist/bridge/push.js +199 -0
  89. package/dist/bridge/questions.d.ts +38 -0
  90. package/dist/bridge/questions.js +205 -0
  91. package/dist/bridge/schedule-format.d.ts +103 -0
  92. package/dist/bridge/schedule-format.js +266 -0
  93. package/dist/bridge/schedule-launch.d.ts +11 -0
  94. package/dist/bridge/schedule-launch.js +169 -0
  95. package/dist/bridge/schedule-watch.d.ts +54 -0
  96. package/dist/bridge/schedule-watch.js +255 -0
  97. package/dist/bridge/schedules.d.ts +48 -0
  98. package/dist/bridge/schedules.js +205 -0
  99. package/dist/bridge/server-launch.d.ts +14 -0
  100. package/dist/bridge/server-launch.js +218 -0
  101. package/dist/bridge/server-overview.d.ts +45 -0
  102. package/dist/bridge/server-overview.js +102 -0
  103. package/dist/bridge/server-pane-routes.d.ts +36 -0
  104. package/dist/bridge/server-pane-routes.js +479 -0
  105. package/dist/bridge/server-routes.d.ts +108 -0
  106. package/dist/bridge/server-routes.js +556 -0
  107. package/dist/bridge/server-stream.d.ts +46 -0
  108. package/dist/bridge/server-stream.js +253 -0
  109. package/dist/bridge/server.d.ts +3 -15
  110. package/dist/bridge/server.js +162 -264
  111. package/dist/bridge/session-servers.d.ts +24 -0
  112. package/dist/bridge/session-servers.js +136 -0
  113. package/dist/bridge/side-questions.d.ts +74 -0
  114. package/dist/bridge/side-questions.js +252 -0
  115. package/dist/bridge/simulators.d.ts +28 -0
  116. package/dist/bridge/simulators.js +198 -0
  117. package/dist/bridge/speech-transcribe.d.ts +24 -0
  118. package/dist/bridge/speech-transcribe.js +124 -0
  119. package/dist/bridge/speech.d.ts +35 -0
  120. package/dist/bridge/speech.js +98 -0
  121. package/dist/bridge/steps.d.ts +13 -0
  122. package/dist/bridge/steps.js +222 -0
  123. package/dist/bridge/tab-activity.d.ts +18 -0
  124. package/dist/bridge/tab-activity.js +99 -0
  125. package/dist/bridge/terminal-choice.d.ts +64 -0
  126. package/dist/bridge/terminal-choice.js +281 -0
  127. package/dist/bridge/transcript-claude.d.ts +22 -0
  128. package/dist/bridge/transcript-claude.js +353 -0
  129. package/dist/bridge/transcript-codex.d.ts +30 -0
  130. package/dist/bridge/transcript-codex.js +282 -0
  131. package/dist/bridge/transcript-copilot.d.ts +4 -0
  132. package/dist/bridge/transcript-copilot.js +14 -0
  133. package/dist/bridge/transcript-opencode.d.ts +5 -0
  134. package/dist/bridge/transcript-opencode.js +26 -0
  135. package/dist/bridge/transcript-preview.d.ts +96 -0
  136. package/dist/bridge/transcript-preview.js +491 -0
  137. package/dist/bridge/transcripts.d.ts +81 -4
  138. package/dist/bridge/transcripts.js +332 -67
  139. package/dist/bridge/transport.d.ts +3 -0
  140. package/dist/bridge/transport.js +96 -15
  141. package/dist/bridge/uploads.d.ts +15 -0
  142. package/dist/bridge/uploads.js +44 -2
  143. package/dist/bridge/usage.d.ts +124 -0
  144. package/dist/bridge/usage.js +859 -0
  145. package/dist/bridge-hook.mjs +46545 -21051
  146. package/dist/cli/actions.js +14 -1
  147. package/dist/cli/config-policy.js +25 -0
  148. package/dist/cli/config-proactivity.d.ts +3 -1
  149. package/dist/cli/config-proactivity.js +35 -3
  150. package/dist/cli/config.js +4 -1
  151. package/dist/cli/extract.d.ts +0 -8
  152. package/dist/cli/extract.js +4 -7
  153. package/dist/cli/govern.js +5 -2
  154. package/dist/cli/hooks-globs.js +1 -1
  155. package/dist/cli/hooks.d.ts +1 -1
  156. package/dist/cli/hooks.js +9 -7
  157. package/dist/cli/namespaces-projects.js +12 -6
  158. package/dist/cli/namespaces-store.js +37 -6
  159. package/dist/cli/namespaces-tasks.js +1 -1
  160. package/dist/cli/schedules.d.ts +1 -0
  161. package/dist/cli/schedules.js +164 -0
  162. package/dist/cli/session-background.js +1 -1
  163. package/dist/cli/session-git.d.ts +8 -5
  164. package/dist/cli/session-git.js +45 -120
  165. package/dist/cli/session-start.js +3 -1
  166. package/dist/cli/session-stop.js +19 -8
  167. package/dist/cli/team.js +13 -10
  168. package/dist/cli-handlers.d.ts +1 -1
  169. package/dist/cli-handlers.js +8 -4
  170. package/dist/cli-help.d.ts +5 -4
  171. package/dist/cli-help.js +15 -15
  172. package/dist/cli-registry.d.ts +4 -1
  173. package/dist/cli-registry.js +119 -6
  174. package/dist/content/archive.js +2 -2
  175. package/dist/content/citation.d.ts +11 -0
  176. package/dist/content/citation.js +18 -0
  177. package/dist/content/learning.js +2 -0
  178. package/dist/content/summarize.d.ts +14 -15
  179. package/dist/content/summarize.js +60 -5
  180. package/dist/content/validate.d.ts +17 -4
  181. package/dist/content/validate.js +200 -122
  182. package/dist/core/project-registry.d.ts +26 -0
  183. package/dist/core/project-registry.js +573 -0
  184. package/dist/core/project.js +2 -3
  185. package/dist/data/access.d.ts +16 -1
  186. package/dist/data/access.js +31 -3
  187. package/dist/data/tasks.d.ts +18 -3
  188. package/dist/data/tasks.js +8 -7
  189. package/dist/entrypoint.js +44 -10
  190. package/dist/fanout/adapters/claude.d.ts +2 -0
  191. package/dist/fanout/adapters/claude.js +7 -0
  192. package/dist/fanout/adapters/codex.d.ts +2 -0
  193. package/dist/fanout/adapters/codex.js +9 -0
  194. package/dist/fanout/adapters/opencode.d.ts +4 -0
  195. package/dist/fanout/adapters/opencode.js +9 -0
  196. package/dist/fanout/adapters/types.d.ts +21 -0
  197. package/dist/fanout/adapters/types.js +3 -0
  198. package/dist/fanout/command.d.ts +2 -0
  199. package/dist/fanout/command.js +78 -0
  200. package/dist/fanout/launcher.d.ts +27 -0
  201. package/dist/fanout/launcher.js +156 -0
  202. package/dist/fanout/opencode-serve.d.ts +24 -0
  203. package/dist/fanout/opencode-serve.js +191 -0
  204. package/dist/fanout/picker.d.ts +91 -0
  205. package/dist/fanout/picker.js +51 -0
  206. package/dist/fanout/usage.d.ts +5 -0
  207. package/dist/fanout/usage.js +51 -0
  208. package/dist/fanout/watchdog.d.ts +10 -0
  209. package/dist/fanout/watchdog.js +27 -0
  210. package/dist/filenames.d.ts +9 -0
  211. package/dist/filenames.js +11 -0
  212. package/dist/finding/context.js +4 -22
  213. package/dist/generated/memory-ui-graph.browser.js +525 -419
  214. package/dist/governance/policy-constants.d.ts +11 -0
  215. package/dist/governance/policy-constants.js +9 -0
  216. package/dist/governance/policy.d.ts +5 -8
  217. package/dist/governance/policy.js +11 -8
  218. package/dist/graph-core/camera.d.ts +24 -0
  219. package/dist/graph-core/camera.js +18 -0
  220. package/dist/graph-core/index.d.ts +2 -0
  221. package/dist/graph-core/index.js +2 -0
  222. package/dist/graph-core/labels.d.ts +77 -0
  223. package/dist/graph-core/labels.js +124 -0
  224. package/dist/graph-core/model.d.ts +13 -0
  225. package/dist/graph-core/model.js +33 -0
  226. package/dist/graph-core/types.d.ts +2 -0
  227. package/dist/home-paths.d.ts +7 -0
  228. package/dist/home-paths.js +21 -0
  229. package/dist/hooks.d.ts +3 -15
  230. package/dist/hooks.js +14 -1
  231. package/dist/index.js +24 -2
  232. package/dist/init/guard-globals.d.ts +1 -1
  233. package/dist/init/guard-globals.js +4 -4
  234. package/dist/init/init-configure.js +3 -3
  235. package/dist/init/init-uninstall.js +15 -5
  236. package/dist/init/init-walkthrough.js +1 -1
  237. package/dist/init/init.js +26 -6
  238. package/dist/init/management-preset.d.ts +1 -1
  239. package/dist/init/management-preset.js +2 -2
  240. package/dist/init/preferences.js +1 -1
  241. package/dist/init/self-wiring.js +1 -1
  242. package/dist/init/setup.d.ts +3 -26
  243. package/dist/init/setup.js +68 -593
  244. package/dist/init/shared.js +2 -0
  245. package/dist/init/store-gitignore.d.ts +1 -6
  246. package/dist/init/store-gitignore.js +2 -8
  247. package/dist/init/teardown.d.ts +1 -1
  248. package/dist/init/teardown.js +2 -2
  249. package/dist/link/context-imports.d.ts +15 -0
  250. package/dist/link/context-imports.js +101 -0
  251. package/dist/link/context.js +1 -1
  252. package/dist/link/doctor.d.ts +22 -1
  253. package/dist/link/doctor.js +128 -58
  254. package/dist/link/link.js +29 -61
  255. package/dist/link/refresh.js +2 -2
  256. package/dist/link/skills.js +26 -5
  257. package/dist/machine-identity.d.ts +3 -0
  258. package/dist/machine-identity.js +6 -0
  259. package/dist/mcp/profile.d.ts +2 -19
  260. package/dist/mcp/profile.js +64 -22
  261. package/dist/memory-ui-graph.runtime.js +525 -419
  262. package/dist/modules/code-package.d.ts +16 -0
  263. package/dist/modules/code-package.js +160 -0
  264. package/dist/modules/command.d.ts +2 -0
  265. package/dist/modules/command.js +67 -0
  266. package/dist/modules/config.d.ts +4 -0
  267. package/dist/modules/config.js +70 -0
  268. package/dist/modules/manifest.d.ts +41 -0
  269. package/dist/modules/manifest.js +1 -0
  270. package/dist/modules/provision.d.ts +3 -0
  271. package/dist/modules/provision.js +84 -0
  272. package/dist/modules/registry.d.ts +16 -0
  273. package/dist/modules/registry.js +250 -0
  274. package/dist/modules/runtime.d.ts +15 -0
  275. package/dist/modules/runtime.js +59 -0
  276. package/dist/package-metadata.js +10 -2
  277. package/dist/phren-dotenv.js +4 -2
  278. package/dist/phren-paths.d.ts +3 -2
  279. package/dist/phren-paths.js +4 -5
  280. package/dist/profile-store.js +43 -8
  281. package/dist/project-config.d.ts +19 -1
  282. package/dist/project-config.js +29 -3
  283. package/dist/project-topics.d.ts +1 -0
  284. package/dist/project-topics.js +13 -10
  285. package/dist/provider-adapters.js +1 -4
  286. package/dist/query-correlation.js +6 -6
  287. package/dist/session/artifacts.js +5 -5
  288. package/dist/session/checkpoints.js +5 -0
  289. package/dist/session/utils.d.ts +2 -2
  290. package/dist/session/utils.js +6 -6
  291. package/dist/shared/content.d.ts +1 -1
  292. package/dist/shared/content.js +1 -1
  293. package/dist/shared/data-utils.js +1 -1
  294. package/dist/shared/fragment-graph.d.ts +1 -1
  295. package/dist/shared/fragment-graph.js +5 -5
  296. package/dist/shared/index.js +48 -7
  297. package/dist/shared/retrieval.d.ts +18 -3
  298. package/dist/shared/retrieval.js +101 -12
  299. package/dist/shared/search-fallback.js +4 -6
  300. package/dist/shared/sqljs.d.ts +2 -0
  301. package/dist/shared/sqljs.js +4 -2
  302. package/dist/shared.d.ts +0 -1
  303. package/dist/shared.js +0 -1
  304. package/dist/shell/input.d.ts +1 -5
  305. package/dist/shell/input.js +16 -10
  306. package/dist/shell/palette.d.ts +2 -2
  307. package/dist/shell/palette.js +3 -7
  308. package/dist/shell/render.d.ts +3 -1
  309. package/dist/shell/render.js +4 -4
  310. package/dist/shell/shell.js +4 -1
  311. package/dist/shell/types.d.ts +1 -0
  312. package/dist/shell/types.js +4 -0
  313. package/dist/shell/view.d.ts +0 -4
  314. package/dist/shell/view.js +19 -27
  315. package/dist/skill/registry.js +25 -17
  316. package/dist/skill/state.d.ts +3 -0
  317. package/dist/skill/state.js +13 -7
  318. package/dist/status.js +38 -17
  319. package/dist/store-registry.d.ts +44 -18
  320. package/dist/store-registry.js +169 -60
  321. package/dist/store-weight.d.ts +1 -6
  322. package/dist/store-weight.js +4 -2
  323. package/dist/sync/auth-doctor.d.ts +8 -0
  324. package/dist/sync/auth-doctor.js +27 -0
  325. package/dist/sync/auth.d.ts +27 -0
  326. package/dist/sync/auth.js +114 -0
  327. package/dist/sync/conflict-resolve.d.ts +9 -0
  328. package/dist/sync/conflict-resolve.js +146 -0
  329. package/dist/sync/git-state.d.ts +4 -0
  330. package/dist/sync/git-state.js +49 -0
  331. package/dist/sync/outcome.d.ts +34 -0
  332. package/dist/sync/outcome.js +57 -0
  333. package/dist/sync/pull.d.ts +15 -7
  334. package/dist/sync/pull.js +84 -35
  335. package/dist/sync/store-merge.d.ts +29 -0
  336. package/dist/sync/store-merge.js +137 -0
  337. package/dist/sync/task-merge.d.ts +22 -0
  338. package/dist/sync/task-merge.js +158 -0
  339. package/dist/task/github.js +1 -1
  340. package/dist/task/lifecycle.d.ts +5 -0
  341. package/dist/task/lifecycle.js +67 -23
  342. package/dist/terminal-text.d.ts +5 -0
  343. package/dist/terminal-text.js +11 -0
  344. package/dist/test-global-setup.js +7 -0
  345. package/dist/tool-registry.d.ts +1 -1
  346. package/dist/tool-registry.js +3 -1
  347. package/dist/tools/code.d.ts +3 -0
  348. package/dist/tools/code.js +186 -0
  349. package/dist/tools/config.js +8 -0
  350. package/dist/tools/data.js +14 -7
  351. package/dist/tools/dispatch.d.ts +2 -0
  352. package/dist/tools/dispatch.js +66 -0
  353. package/dist/tools/finding.d.ts +11 -0
  354. package/dist/tools/finding.js +180 -123
  355. package/dist/tools/ops.js +5 -2
  356. package/dist/tools/search.js +21 -8
  357. package/dist/tools/session.js +21 -22
  358. package/dist/tools/tasks.js +8 -2
  359. package/dist/tools/types.d.ts +2 -2
  360. package/dist/tools/types.js +2 -2
  361. package/dist/ui/assets.js +1 -1
  362. package/dist/ui/data.js +14 -15
  363. package/dist/ui/deep-void.d.ts +1 -1
  364. package/dist/ui/deep-void.js +0 -1
  365. package/dist/ui/graph-chrome.d.ts +1 -1
  366. package/dist/ui/graph-chrome.js +51 -0
  367. package/dist/ui/page.js +5 -5
  368. package/dist/ui/scripts.js +67 -30
  369. package/dist/ui/server.js +52 -7
  370. package/dist/update.js +22 -11
  371. package/dist/utils-fts.js +1 -0
  372. package/dist/utils-helpers.d.ts +7 -0
  373. package/dist/utils-helpers.js +17 -0
  374. package/dist/utils.d.ts +1 -1
  375. package/dist/utils.js +1 -1
  376. package/package.json +49 -7
  377. package/plugins/opencode/phren-transcript.js +340 -0
  378. package/starter/README.md +4 -4
  379. package/starter/global/{CLAUDE.md → AGENTS.md} +2 -2
  380. package/starter/global/skills/conductor/SKILL.md +106 -0
  381. package/starter/global/skills/fanout/SKILL.md +20 -0
  382. package/starter/global/skills/phren-discover/SKILL.md +6 -6
  383. package/starter/global/skills/phren-init/SKILL.md +4 -4
  384. package/starter/global/skills/phren-sync/SKILL.md +3 -3
  385. package/starter/templates/frontend/reference/README.md +1 -1
  386. package/starter/templates/library/reference/README.md +1 -1
  387. package/starter/templates/monorepo/reference/README.md +1 -1
  388. package/starter/templates/python-project/reference/README.md +1 -1
  389. /package/starter/templates/frontend/{CLAUDE.md → AGENTS.md} +0 -0
  390. /package/starter/templates/library/{CLAUDE.md → AGENTS.md} +0 -0
  391. /package/starter/templates/monorepo/{CLAUDE.md → AGENTS.md} +0 -0
  392. /package/starter/templates/python-project/{CLAUDE.md → AGENTS.md} +0 -0
@@ -113,7 +113,7 @@ export function scheduleBackgroundMaintenance(phrenPathLocal, project) {
113
113
  spawnArgs.push(project);
114
114
  // Keep this log under .runtime/ (gitignored), matching background-sync.log.
115
115
  // Writing it under .config/ makes it a tracked file that diverges per machine
116
- // and breaks the Stop-hook pull-rebase.
116
+ // and breaks the Stop-hook fetch and merge.
117
117
  const logPath = runtimeFile(phrenPathLocal, "background-maintenance.log");
118
118
  const logFd = fs.openSync(logPath, "a");
119
119
  fs.writeSync(logFd, `[${new Date().toISOString()}] spawn ${process.execPath} ${spawnArgs.join(" ")}\n`);
@@ -1,3 +1,5 @@
1
+ import { type RunStoreGit } from "../sync/store-merge.js";
2
+ import { type AheadBehind } from "../sync/outcome.js";
1
3
  export interface GitContext {
2
4
  branch: string;
3
5
  changedFiles: Set<string>;
@@ -12,8 +14,8 @@ export declare function runBestEffortGit(args: string[], cwd: string): Promise<{
12
14
  * True when local HEAD and the tracking branch share no common ancestor.
13
15
  *
14
16
  * This is what happens when a store's remote is re-initialized: every
15
- * `pull --rebase` fails, the rebase is aborted, and the next commit re-enters
16
- * the same loop forever. A generic "pull failed" sends the user chasing
17
+ * an ordinary pull cannot reconcile it, and the next commit re-enters the
18
+ * same loop forever. A generic "pull failed" sends the user chasing
17
19
  * network problems, so it is worth naming — no retry will ever fix it.
18
20
  *
19
21
  * Returns false when there is no upstream, or when git cannot answer; callers
@@ -25,13 +27,14 @@ export declare function hasUnrelatedHistories(cwd: string): Promise<boolean>;
25
27
  * list (notably `.runtime/`, secrets, build output) is skipped on session-stop
26
28
  * and `push_changes`.
27
29
  */
28
- export declare const TEAM_STORE_PATHSPECS: readonly ["*/journal/*", "*/tasks.md", "*/truths.md", "*/FINDINGS.md", "*/FINDINGS.md.bak", "*/summary.md", "*/review.md", "*/CLAUDE.md", "*/topic-config.json", "*/phren.project.yaml", "*/reference/**", "*/skills/**", "*/notes/**", ".phren-team.yaml"];
30
+ export declare const TEAM_STORE_PATHSPECS: readonly ["*/journal/*", "*/tasks.md", "*/truths.md", "*/FINDINGS.md", "*/FINDINGS.md.bak", "*/summary.md", "*/review.md", "*/AGENTS.md", "*/topic-config.json", "*/phren.project.yaml", "*/reference/**", "*/skills/**", "*/notes/**", ".phren-team.yaml"];
29
31
  export declare function countUnsyncedCommits(cwd: string): Promise<number>;
30
- /** Startup pulls share the store's Git lock and clean up only rebases they started. */
31
- export declare function pullAtSessionStart(cwd: string): Promise<{
32
+ /** Startup pulls share the store's Git lock and never rewrite local commits. */
33
+ export declare function pullAtSessionStart(cwd: string, git?: RunStoreGit, now?: number): Promise<{
32
34
  ok: boolean;
33
35
  output?: string;
34
36
  error?: string;
37
+ counts?: AheadBehind;
35
38
  }>;
36
39
  export declare function recoverPushConflict(cwd: string): Promise<{
37
40
  ok: boolean;
@@ -3,14 +3,15 @@
3
3
  * Extracted from hooks-session.ts for modularity.
4
4
  */
5
5
  import { execFileSync } from "child_process";
6
- import * as fs from "fs";
7
6
  import * as path from "path";
8
- import { EXEC_TIMEOUT_MS, debugLog, errorMessage, } from "./hooks-context.js";
9
- import { runGit } from "../utils.js";
10
- import { isTaskFileName } from "../data/tasks.js";
7
+ import { EXEC_TIMEOUT_MS, debugLog } from "../shared.js";
8
+ import { errorMessage, runGit } from "../utils.js";
9
+ import { nonInteractiveGitEnv } from "../utils-helpers.js";
11
10
  import { withFileLock } from "../governance/locks.js";
12
11
  import { runtimeFile } from "../phren-paths.js";
13
- import { autoMergeConflicts, mergeTask, mergeFindings, } from "../shared/content.js";
12
+ import { mergeStoreUpstream } from "../sync/store-merge.js";
13
+ import { aheadBehind, logSyncOutcome } from "../sync/outcome.js";
14
+ import { activeStoreAuthFailure, authBackoffActive, isGitAuthFailure, storeAuthDetail, withStoreAuthBackoff } from "../sync/auth.js";
14
15
  export function getGitContext(cwd) {
15
16
  if (!cwd)
16
17
  return null;
@@ -42,7 +43,7 @@ function shouldRetryGitCommand(args) {
42
43
  const cmd = args[0] || "";
43
44
  return cmd === "push" || cmd === "pull" || cmd === "fetch";
44
45
  }
45
- export async function runBestEffortGit(args, cwd) {
46
+ async function runBestEffortGitCommand(args, cwd) {
46
47
  const retries = shouldRetryGitCommand(args) ? 2 : 0;
47
48
  for (let attempt = 0; attempt <= retries; attempt++) {
48
49
  try {
@@ -51,27 +52,32 @@ export async function runBestEffortGit(args, cwd) {
51
52
  encoding: "utf8",
52
53
  stdio: ["ignore", "pipe", "pipe"],
53
54
  timeout: EXEC_TIMEOUT_MS,
55
+ env: nonInteractiveGitEnv(),
54
56
  }).trim();
55
57
  return { ok: true, output };
56
58
  }
57
59
  catch (err) {
58
60
  const message = errorMessage(err);
59
- if (attempt < retries && isTransientGitError(message)) {
61
+ if (attempt < retries && !isGitAuthFailure(message) && isTransientGitError(message)) {
60
62
  const delayMs = 500 * (attempt + 1);
61
63
  await new Promise((resolve) => setTimeout(resolve, delayMs));
62
64
  continue;
63
65
  }
64
- return { ok: false, error: message };
66
+ return { ok: false, output: "", error: message };
65
67
  }
66
68
  }
67
- return { ok: false, error: "git command failed" };
69
+ return { ok: false, output: "", error: "git command failed" };
70
+ }
71
+ const guardedSessionGit = withStoreAuthBackoff((cwd, args) => runBestEffortGitCommand(args, cwd));
72
+ export async function runBestEffortGit(args, cwd) {
73
+ return guardedSessionGit(cwd, args);
68
74
  }
69
75
  /**
70
76
  * True when local HEAD and the tracking branch share no common ancestor.
71
77
  *
72
78
  * This is what happens when a store's remote is re-initialized: every
73
- * `pull --rebase` fails, the rebase is aborted, and the next commit re-enters
74
- * the same loop forever. A generic "pull failed" sends the user chasing
79
+ * an ordinary pull cannot reconcile it, and the next commit re-enters the
80
+ * same loop forever. A generic "pull failed" sends the user chasing
75
81
  * network problems, so it is worth naming — no retry will ever fix it.
76
82
  *
77
83
  * Returns false when there is no upstream, or when git cannot answer; callers
@@ -105,7 +111,7 @@ export const TEAM_STORE_PATHSPECS = [
105
111
  "*/FINDINGS.md.bak",
106
112
  "*/summary.md",
107
113
  "*/review.md",
108
- "*/CLAUDE.md",
114
+ "*/AGENTS.md",
109
115
  "*/topic-config.json",
110
116
  "*/phren.project.yaml",
111
117
  "*/reference/**",
@@ -128,127 +134,46 @@ export async function countUnsyncedCommits(cwd) {
128
134
  const parsed = Number.parseInt(ahead.output.trim(), 10);
129
135
  return Number.isNaN(parsed) ? 0 : parsed;
130
136
  }
131
- /** Startup pulls share the store's Git lock and clean up only rebases they started. */
132
- export async function pullAtSessionStart(cwd) {
137
+ const runSessionStoreGit = async (cwd, args) => {
138
+ const result = await runBestEffortGitCommand(args, cwd);
139
+ return { ok: result.ok, output: result.output ?? "", error: result.error };
140
+ };
141
+ /** Startup pulls share the store's Git lock and never rewrite local commits. */
142
+ export async function pullAtSessionStart(cwd, git = runSessionStoreGit, now = Date.now()) {
143
+ const result = await pullAtSessionStartUnlogged(cwd, git, now);
144
+ const counts = await aheadBehind(cwd, git);
145
+ logSyncOutcome(cwd, "session-start-pull", { ok: result.ok, detail: result.ok ? result.output : result.error, counts });
146
+ return counts ? { ...result, counts } : result;
147
+ }
148
+ async function pullAtSessionStartUnlogged(cwd, git, now) {
133
149
  try {
134
150
  return await withFileLock(runtimeFile(cwd, "git-op"), async () => {
135
- const gitDir = await runBestEffortGit(["rev-parse", "--absolute-git-dir"], cwd);
136
- if (!gitDir.ok || !gitDir.output)
137
- return { ok: false, error: gitDir.error || "Cannot locate Git directory." };
138
- const rebasing = () => ["rebase-merge", "rebase-apply"].some((name) => fs.existsSync(path.join(gitDir.output, name)));
139
- if (rebasing() || ["MERGE_HEAD", "CHERRY_PICK_HEAD", "REVERT_HEAD", "sequencer"].some((name) => fs.existsSync(path.join(gitDir.output, name)))) {
140
- return { ok: false, error: "Store already has a Git operation in progress; session-start pull deferred." };
141
- }
142
- const result = await runBestEffortGit(["pull", "--rebase", "--quiet"], cwd);
143
- if (!result.ok && rebasing()) {
144
- const abort = await runBestEffortGit(["rebase", "--abort"], cwd);
145
- if (!abort.ok)
146
- return { ok: false, error: `${result.error}; rebase cleanup failed: ${abort.error}` };
147
- }
148
- return result;
151
+ const auth = activeStoreAuthFailure(cwd);
152
+ if (authBackoffActive(auth, now))
153
+ return { ok: false, error: storeAuthDetail(auth) };
154
+ const result = await mergeStoreUpstream(cwd, {
155
+ git: withStoreAuthBackoff(git, () => now),
156
+ commitMessage: "auto-save phren (session start)",
157
+ });
158
+ return result.status === "updated" || result.status === "unchanged"
159
+ ? { ok: true, output: result.detail }
160
+ : { ok: false, error: result.detail };
149
161
  });
150
162
  }
151
163
  catch (err) {
152
164
  return { ok: false, error: errorMessage(err) };
153
165
  }
154
166
  }
155
- // ── Merge helpers ───────────────────────────────────────────────────────────
156
- function isMergeableMarkdown(relPath) {
157
- const filename = path.basename(relPath).toLowerCase();
158
- return filename === "findings.md" || isTaskFileName(filename);
159
- }
160
- async function snapshotLocalMergeableFiles(cwd) {
161
- const upstream = await runBestEffortGit(["rev-parse", "--abbrev-ref", "@{upstream}"], cwd);
162
- if (!upstream.ok || !upstream.output)
163
- return new Map();
164
- const changed = await runBestEffortGit(["diff", "--name-only", `${upstream.output.trim()}..HEAD`], cwd);
165
- if (!changed.ok || !changed.output)
166
- return new Map();
167
- const snapshots = new Map();
168
- for (const relPath of changed.output.split("\n").map((line) => line.trim()).filter(Boolean)) {
169
- if (!isMergeableMarkdown(relPath))
170
- continue;
171
- const fullPath = path.join(cwd, relPath);
172
- if (!fs.existsSync(fullPath))
173
- continue;
174
- snapshots.set(relPath, fs.readFileSync(fullPath, "utf8"));
175
- }
176
- return snapshots;
177
- }
178
- async function reconcileMergeableFiles(cwd, snapshots) {
179
- let changedAny = false;
180
- for (const [relPath, localBeforePull] of snapshots.entries()) {
181
- const fullPath = path.join(cwd, relPath);
182
- if (!fs.existsSync(fullPath))
183
- continue;
184
- const current = fs.readFileSync(fullPath, "utf8");
185
- const filename = path.basename(relPath).toLowerCase();
186
- const merged = filename === "findings.md"
187
- ? mergeFindings(current, localBeforePull)
188
- : mergeTask(current, localBeforePull);
189
- if (merged === current)
190
- continue;
191
- fs.writeFileSync(fullPath, merged);
192
- changedAny = true;
193
- }
194
- if (!changedAny)
195
- return false;
196
- const add = await runBestEffortGit(["add", "--", ...snapshots.keys()], cwd);
197
- if (!add.ok)
198
- return false;
199
- const commit = await runBestEffortGit(["commit", "-m", "auto-merge markdown recovery"], cwd);
200
- return commit.ok;
201
- }
202
167
  export async function recoverPushConflict(cwd) {
203
- const localSnapshots = await snapshotLocalMergeableFiles(cwd);
204
- const pull = await runBestEffortGit(["pull", "--rebase", "--quiet"], cwd);
205
- if (pull.ok) {
206
- const reconciled = await reconcileMergeableFiles(cwd, localSnapshots);
207
- const retryPush = await runBestEffortGit(["push"], cwd);
208
- return {
209
- ok: retryPush.ok,
210
- detail: retryPush.ok
211
- ? (reconciled ? "commit pushed after pull --rebase and markdown reconciliation" : "commit pushed after pull --rebase")
212
- : (retryPush.error || "push failed after pull --rebase"),
213
- pullStatus: "ok",
214
- pullDetail: pull.output || "pull --rebase ok",
215
- };
216
- }
217
- const conflicted = await runBestEffortGit(["diff", "--name-only", "--diff-filter=U"], cwd);
218
- const conflictedOutput = conflicted.output?.trim() || "";
219
- if (!conflicted.ok || !conflictedOutput) {
220
- await runBestEffortGit(["rebase", "--abort"], cwd);
221
- return {
222
- ok: false,
223
- detail: pull.error || "pull --rebase failed",
224
- pullStatus: "error",
225
- pullDetail: pull.error || "pull --rebase failed",
226
- };
227
- }
228
- if (!autoMergeConflicts(cwd)) {
229
- await runBestEffortGit(["rebase", "--abort"], cwd);
230
- return {
231
- ok: false,
232
- detail: `rebase conflicts require manual resolution: ${conflictedOutput}`,
233
- pullStatus: "error",
234
- pullDetail: `rebase conflicts require manual resolution: ${conflictedOutput}`,
235
- };
236
- }
237
- const continued = await runBestEffortGit(["-c", "core.editor=true", "rebase", "--continue"], cwd);
238
- if (!continued.ok) {
239
- await runBestEffortGit(["rebase", "--abort"], cwd);
240
- return {
241
- ok: false,
242
- detail: continued.error || "rebase --continue failed",
243
- pullStatus: "error",
244
- pullDetail: continued.error || "rebase --continue failed",
245
- };
168
+ const merged = await mergeStoreUpstream(cwd, { git: withStoreAuthBackoff(runSessionStoreGit), commitLocalWrites: false });
169
+ if (merged.status !== "updated" && merged.status !== "unchanged") {
170
+ return { ok: false, detail: merged.detail, pullStatus: "error", pullDetail: merged.detail };
246
171
  }
247
172
  const retryPush = await runBestEffortGit(["push"], cwd);
248
173
  return {
249
174
  ok: retryPush.ok,
250
- detail: retryPush.ok ? "commit pushed after auto-merge recovery" : (retryPush.error || "push failed after auto-merge recovery"),
175
+ detail: retryPush.ok ? "commit pushed after merging remote changes" : (retryPush.error || "push failed after merging remote changes"),
251
176
  pullStatus: "ok",
252
- pullDetail: "pull --rebase recovered via auto-merge",
177
+ pullDetail: merged.detail,
253
178
  };
254
179
  }
@@ -1,3 +1,4 @@
1
+ import { moduleEnabled } from "../modules/runtime.js";
1
2
  /**
2
3
  * Session start hook handler and onboarding notices.
3
4
  * Extracted from hooks-session.ts for modularity.
@@ -25,7 +26,7 @@ function projectHasBootstrapSignals(phrenPath, project) {
25
26
  return true;
26
27
  }
27
28
  const tasksPath = path.join(projectDir, TASKS_FILENAME);
28
- if (fs.existsSync(tasksPath)) {
29
+ if (moduleEnabled(path.dirname(projectDir), "tasks") && fs.existsSync(tasksPath)) {
29
30
  const tasks = fs.readFileSync(tasksPath, "utf8");
30
31
  if (/^-\s+\[(?: |x|X)\]/m.test(tasks))
31
32
  return true;
@@ -171,6 +172,7 @@ export async function handleHookSessionStart() {
171
172
  lastPullDetail: pull.ok ? (pull.output || "pull ok") : (pull.error || "pull failed"),
172
173
  lastSuccessfulPullAt: pull.ok && hasRemote ? startedAt : undefined,
173
174
  unsyncedCommits,
175
+ ...("counts" in pull && pull.counts ? pull.counts : {}),
174
176
  },
175
177
  });
176
178
  appendAuditLog(phrenPath, "hook_session_start", `pull=${hasRemote ? (pull.ok ? "ok" : "fail") : "skipped-local"} doctor=${doctor.ok ? "ok" : "issues"} maintenance=${maintenanceScheduled ? "scheduled" : "skipped"}`);
@@ -12,6 +12,8 @@ import { assessSyncOutage, getRuntimeHealth, } from "../shared/governance.js";
12
12
  import { resolveSubprocessArgs, scheduleBackgroundSync, } from "./session-background.js";
13
13
  import { spawnDetachedChild } from "../shared/process.js";
14
14
  import { resolveManagementCapabilities } from "../init/management-preset.js";
15
+ import { aheadBehind, logSyncOutcome } from "../sync/outcome.js";
16
+ import { storeCommitMessage } from "../machine-identity.js";
15
17
  // ── Utility ─────────────────────────────────────────────────────────────────
16
18
  /** Read JSON from stdin if it's not a TTY. Returns null if stdin is a TTY or parsing fails. */
17
19
  function readStdinJson() {
@@ -140,7 +142,7 @@ function warnIfSyncDegraded(phrenPath) {
140
142
  "<phren-notice>",
141
143
  assessment.summary,
142
144
  `Your findings and tasks are safe on disk in ${phrenPath}, but they are not reaching the remote.`,
143
- `Diagnose with: phren status (then: cd ${phrenPath} && git pull --rebase)`,
145
+ `Diagnose with: phren status (then: phren store sync)`,
144
146
  "<phren-notice>",
145
147
  "",
146
148
  ].join("\n"));
@@ -422,7 +424,7 @@ export async function handleHookStop() {
422
424
  }
423
425
  }
424
426
  }
425
- const commit = add.ok ? await runBestEffortGit(["commit", "-m", commitMsg], phrenPath) : { ok: false, error: add.error };
427
+ const commit = add.ok ? await runBestEffortGit(["commit", "-m", storeCommitMessage(commitMsg)], phrenPath) : { ok: false, error: add.error };
426
428
  if (!add.ok || !commit.ok) {
427
429
  finalizeTaskSession({
428
430
  phrenPath,
@@ -507,29 +509,34 @@ export async function handleBackgroundSync() {
507
509
  try {
508
510
  await withFileLock(runtimeFile(phrenPathLocal, "git-op"), async () => {
509
511
  const previousSync = getRuntimeHealth(phrenPathLocal).lastSync;
510
- const record = (autoSaveStatus, patch, detail) => {
512
+ const record = async (autoSaveStatus, patch, detail) => {
513
+ // Ahead/behind make a failure actionable: "behind 140" is a different fix from "ahead 23".
514
+ const counts = await aheadBehind(phrenPathLocal, (cwd, args) => runBestEffortGit(args, cwd));
511
515
  updateRuntimeHealth(phrenPathLocal, {
512
516
  lastAutoSave: { at: now, status: autoSaveStatus, detail },
513
- lastSync: nextSyncStatus(previousSync, patch, now),
517
+ lastSync: { ...nextSyncStatus(previousSync, patch, now), ...(counts ?? {}) },
514
518
  });
515
519
  appendAuditLog(phrenPathLocal, "background_sync", `status=${patch.lastPushStatus} detail=${JSON.stringify(detail)}`);
520
+ logSyncOutcome(phrenPathLocal, "background-sync", {
521
+ ok: autoSaveStatus !== "sync-failed", detail: `${patch.lastPushStatus}: ${detail}`, counts,
522
+ });
516
523
  };
517
524
  const remotes = await runBestEffortGit(["remote"], phrenPathLocal);
518
525
  if (!remotes.ok || !remotes.output) {
519
526
  const unsyncedCommits = await countUnsyncedCommits(phrenPathLocal);
520
527
  const detail = "background sync skipped; no remote configured";
521
- record("saved-local", { lastPushAt: now, lastPushStatus: "saved-local", lastPushDetail: detail, unsyncedCommits }, detail);
528
+ await record("saved-local", { lastPushAt: now, lastPushStatus: "saved-local", lastPushDetail: detail, unsyncedCommits }, detail);
522
529
  return;
523
530
  }
524
531
  const push = await runBestEffortGit(["push"], phrenPathLocal);
525
532
  if (push.ok) {
526
533
  const detail = "commit pushed by background sync";
527
- record("saved-pushed", { lastPushAt: now, lastPushStatus: "saved-pushed", lastPushDetail: detail, unsyncedCommits: 0 }, detail);
534
+ await record("saved-pushed", { lastPushAt: now, lastPushStatus: "saved-pushed", lastPushDetail: detail, unsyncedCommits: 0 }, detail);
528
535
  return;
529
536
  }
530
537
  const recovered = await recoverPushConflict(phrenPathLocal);
531
538
  if (recovered.ok) {
532
- record("saved-pushed", {
539
+ await record("saved-pushed", {
533
540
  lastPushAt: now,
534
541
  lastPushStatus: "saved-pushed",
535
542
  lastPushDetail: recovered.detail,
@@ -554,7 +561,7 @@ export async function handleBackgroundSync() {
554
561
  ? `local and remote histories are unrelated (no merge base) — the remote was most likely re-initialized. ` +
555
562
  `Reconcile manually: cd ${phrenPathLocal} && git fetch && git log --oneline origin/HEAD`
556
563
  : (recovered.detail || push.error || "background sync push failed");
557
- record("sync-failed", {
564
+ await record("sync-failed", {
558
565
  lastPushAt: now,
559
566
  lastPushStatus: pushStatus,
560
567
  lastPushDetail: failDetail,
@@ -565,6 +572,10 @@ export async function handleBackgroundSync() {
565
572
  }, failDetail);
566
573
  });
567
574
  }
575
+ catch (err) {
576
+ logSyncOutcome(phrenPathLocal, "background-sync", { ok: false, detail: errorMessage(err) });
577
+ throw err;
578
+ }
568
579
  finally {
569
580
  try {
570
581
  fs.unlinkSync(lockPath);
package/dist/cli/team.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { nonInteractiveGitEnv } from "../utils-helpers.js";
1
2
  /**
2
3
  * Team store CLI commands: init, join, add-project.
3
4
  * Creates and manages shared phren stores for team collaboration.
@@ -6,19 +7,13 @@ import * as fs from "fs";
6
7
  import * as path from "path";
7
8
  import { execFileSync } from "child_process";
8
9
  import { getPhrenPath } from "../shared.js";
10
+ import { atomicWriteText } from "../phren-paths.js";
9
11
  import { FINDINGS_FILENAME } from "../data/access.js";
10
12
  import { TASKS_FILENAME } from "../data/tasks.js";
11
13
  import { isValidProjectName, getOptionValue, getPositionalArgs } from "../utils.js";
12
14
  import { addProjectToProfile, resolveActiveProfile } from "../profile-store.js";
13
15
  import { addStoreToRegistry, findStoreByName, generateStoreId, readTeamBootstrap, updateStoreProjects, } from "../store-registry.js";
14
16
  const EXEC_TIMEOUT_MS = 30_000;
15
- function atomicWriteText(filePath, content) {
16
- const dir = path.dirname(filePath);
17
- fs.mkdirSync(dir, { recursive: true });
18
- const tmp = filePath + ".tmp." + process.pid;
19
- fs.writeFileSync(tmp, content);
20
- fs.renameSync(tmp, filePath);
21
- }
22
17
  // ── phren team init <name> [--remote <url>] [--description <desc>] ──────────
23
18
  async function handleTeamInit(args) {
24
19
  const phrenPath = getPhrenPath();
@@ -64,17 +59,19 @@ async function handleTeamInit(args) {
64
59
  // Create global directory with starter files
65
60
  const globalDir = path.join(storePath, "global");
66
61
  fs.mkdirSync(globalDir, { recursive: true });
67
- atomicWriteText(path.join(globalDir, "CLAUDE.md"), `# ${name} Team Store\n\nShared knowledge for the ${name} team.\n`);
62
+ atomicWriteText(path.join(globalDir, "AGENTS.md"), `# ${name} Team Store\n\nShared knowledge for the ${name} team.\n`);
68
63
  atomicWriteText(path.join(globalDir, FINDINGS_FILENAME), `# global findings\n`);
69
64
  // Initialize git repo
70
65
  execFileSync("git", ["init"], {
66
+ env: nonInteractiveGitEnv(),
71
67
  cwd: storePath,
72
68
  stdio: "pipe",
73
69
  timeout: EXEC_TIMEOUT_MS,
74
70
  });
75
71
  // Initial commit
76
- execFileSync("git", ["add", "-A"], { cwd: storePath, stdio: "pipe", timeout: EXEC_TIMEOUT_MS });
72
+ execFileSync("git", ["add", "-A"], { env: nonInteractiveGitEnv(), cwd: storePath, stdio: "pipe", timeout: EXEC_TIMEOUT_MS });
77
73
  execFileSync("git", ["commit", "-m", "phren: initialize team store"], {
74
+ env: nonInteractiveGitEnv(),
78
75
  cwd: storePath,
79
76
  stdio: "pipe",
80
77
  timeout: EXEC_TIMEOUT_MS,
@@ -82,12 +79,14 @@ async function handleTeamInit(args) {
82
79
  // Add remote if provided
83
80
  if (remote) {
84
81
  execFileSync("git", ["remote", "add", "origin", remote], {
82
+ env: nonInteractiveGitEnv(),
85
83
  cwd: storePath,
86
84
  stdio: "pipe",
87
85
  timeout: EXEC_TIMEOUT_MS,
88
86
  });
89
87
  try {
90
88
  execFileSync("git", ["push", "-u", "origin", "main"], {
89
+ env: nonInteractiveGitEnv(),
91
90
  cwd: storePath,
92
91
  stdio: "pipe",
93
92
  timeout: EXEC_TIMEOUT_MS,
@@ -98,6 +97,7 @@ async function handleTeamInit(args) {
98
97
  // Try HEAD branch name
99
98
  try {
100
99
  execFileSync("git", ["push", "-u", "origin", "HEAD"], {
100
+ env: nonInteractiveGitEnv(),
101
101
  cwd: storePath,
102
102
  stdio: "pipe",
103
103
  timeout: EXEC_TIMEOUT_MS,
@@ -109,7 +109,7 @@ async function handleTeamInit(args) {
109
109
  }
110
110
  }
111
111
  }
112
- // Register in primary store's stores.yaml
112
+ // Attach it on this machine only (.runtime/attached-stores.yaml)
113
113
  const entry = {
114
114
  id: generateStoreId(),
115
115
  name,
@@ -123,6 +123,7 @@ async function handleTeamInit(args) {
123
123
  console.log(` Path: ${storePath}`);
124
124
  console.log(` Role: team`);
125
125
  console.log(` ID: ${entry.id}`);
126
+ console.log(` Attached on this machine only. Run phren team join on each other machine that should use it.`);
126
127
  if (!remote) {
127
128
  console.log(`\nNext: add a remote and push`);
128
129
  console.log(` cd ${storePath}`);
@@ -166,6 +167,7 @@ async function handleTeamJoin(args) {
166
167
  console.log(`Cloning ${remote}...`);
167
168
  fs.mkdirSync(storesDir, { recursive: true });
168
169
  execFileSync("git", ["clone", "--", remote, storePath], {
170
+ env: nonInteractiveGitEnv(),
169
171
  stdio: "inherit",
170
172
  timeout: 60_000,
171
173
  });
@@ -186,6 +188,7 @@ async function handleTeamJoin(args) {
186
188
  console.log(` Path: ${storePath}`);
187
189
  console.log(` Role: ${finalRole}`);
188
190
  console.log(` ID: ${entry.id}`);
191
+ console.log(` Attached on this machine only. Run phren team join on each other machine that should use it.`);
189
192
  if (bootstrap?.description) {
190
193
  console.log(` Description: ${bootstrap.description}`);
191
194
  }
@@ -16,4 +16,4 @@ export declare function runMcpModeCommand(args: string[]): Promise<number>;
16
16
  export declare function runHooksModeCommand(args: string[]): Promise<number>;
17
17
  export declare function runPresetCommand(args: string[]): Promise<number>;
18
18
  export declare function runSnippetCommand(_args: string[]): Promise<number>;
19
- export declare function runLinkRemovedNotice(_args: string[]): Promise<number>;
19
+ export declare function runLinkRemovedNotice(args: string[]): Promise<number>;
@@ -9,7 +9,8 @@
9
9
  */
10
10
  import * as fs from "fs";
11
11
  import * as path from "path";
12
- import { defaultPhrenPath, findPhrenPath, isInstallMode, parseProactivityLevel, } from "./shared.js";
12
+ import { defaultPhrenPath, findPhrenPath, isInstallMode, } from "./shared.js";
13
+ import { parseProactivityLevel } from "./proactivity.js";
13
14
  import { errorMessage, getOptionValue, getPositionalArgs } from "./utils.js";
14
15
  import { addProjectFromPath } from "./core/project.js";
15
16
  import { PROJECT_OWNERSHIP_MODES, getProjectOwnershipDefault, parseProjectOwnershipMode, } from "./project-config.js";
@@ -238,7 +239,10 @@ export async function runSnippetCommand(_args) {
238
239
  return 1;
239
240
  }
240
241
  }
241
- export async function runLinkRemovedNotice(_args) {
242
- console.error("`phren link` has been removed. Use `phren init` instead.");
243
- return 1;
242
+ export async function runLinkRemovedNotice(args) {
243
+ if (args.length) {
244
+ console.error("The old `phren link` option interface has been removed. Use `phren init` instead.");
245
+ return 1;
246
+ }
247
+ return runInitCommand(args);
244
248
  }
@@ -1,6 +1,7 @@
1
+ import type { ModuleSnapshot } from "./modules/runtime.js";
1
2
  import { type Topic } from "./cli-registry.js";
2
- export declare function formatCheatSheet(): string;
3
- export declare function formatTopic(topic: Topic): string;
3
+ export declare function formatCheatSheet(snapshot?: ModuleSnapshot): string;
4
+ export declare function formatTopic(topic: Topic, snapshot?: ModuleSnapshot): string;
4
5
  export declare function formatDocTopic(name: string): string | null;
5
- export declare function formatCommand(name: string): string | null;
6
- export declare function formatFullHelp(): string;
6
+ export declare function formatCommand(name: string, snapshot?: ModuleSnapshot): string | null;
7
+ export declare function formatFullHelp(snapshot?: ModuleSnapshot): string;
package/dist/cli-help.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Help formatters. Pure functions over the command registry.
2
- import { REGISTRY, TOPIC_ORDER, DOC_TOPICS, lookupCommand, } from "./cli-registry.js";
2
+ import { commandsForModules, TOPIC_ORDER, DOC_TOPICS, lookupCommand, } from "./cli-registry.js";
3
3
  const TOPIC_TITLES = {
4
4
  core: "Core commands",
5
5
  projects: "Projects",
@@ -19,11 +19,11 @@ function pad(usage, summary) {
19
19
  const gap = Math.max(2, ALIGN_COL - text.length);
20
20
  return text + " ".repeat(gap) + summary;
21
21
  }
22
- function visibleCommands() {
23
- return REGISTRY.filter((c) => !c.hidden);
22
+ function visibleCommands(snapshot) {
23
+ return commandsForModules(snapshot).filter((c) => !c.hidden);
24
24
  }
25
- function commandsInTopic(topic) {
26
- return visibleCommands().filter((c) => c.topic === topic);
25
+ function commandsInTopic(topic, snapshot) {
26
+ return visibleCommands(snapshot).filter((c) => c.topic === topic);
27
27
  }
28
28
  function renderCommandLine(cmd) {
29
29
  return pad(cmd.usage, cmd.summary);
@@ -44,12 +44,12 @@ function renderCommandWithSubs(cmd) {
44
44
  return lines;
45
45
  }
46
46
  // ── Cheat sheet (phren --help) ───────────────────────────────────────────────
47
- export function formatCheatSheet() {
47
+ export function formatCheatSheet(snapshot) {
48
48
  const lines = [];
49
49
  lines.push("phren - persistent memory for AI agents");
50
50
  lines.push("");
51
51
  lines.push(pad("phren", "Interactive memory shell"));
52
- for (const cmd of visibleCommands()) {
52
+ for (const cmd of visibleCommands(snapshot)) {
53
53
  if (!cmd.featured)
54
54
  continue;
55
55
  lines.push(renderCheatSheetLine(cmd));
@@ -64,8 +64,8 @@ export function formatCheatSheet() {
64
64
  return lines.join("\n");
65
65
  }
66
66
  // ── Topic help (phren help <topic>) ──────────────────────────────────────────
67
- export function formatTopic(topic) {
68
- const cmds = commandsInTopic(topic);
67
+ export function formatTopic(topic, snapshot) {
68
+ const cmds = commandsInTopic(topic, snapshot);
69
69
  const lines = [];
70
70
  lines.push(`${TOPIC_TITLES[topic]}:`);
71
71
  for (const cmd of cmds) {
@@ -81,8 +81,8 @@ export function formatDocTopic(name) {
81
81
  return DOC_TOPICS[name] ?? null;
82
82
  }
83
83
  // ── Single command (phren <name> --help / phren help <name>) ─────────────────
84
- export function formatCommand(name) {
85
- const cmd = lookupCommand(name);
84
+ export function formatCommand(name, snapshot) {
85
+ const cmd = lookupCommand(name, snapshot);
86
86
  if (!cmd)
87
87
  return null;
88
88
  const lines = [];
@@ -99,23 +99,23 @@ export function formatCommand(name) {
99
99
  return lines.join("\n");
100
100
  }
101
101
  // ── Full help (phren help all) ───────────────────────────────────────────────
102
- export function formatFullHelp() {
102
+ export function formatFullHelp(snapshot) {
103
103
  const lines = [];
104
104
  lines.push("phren - persistent knowledge for your agents");
105
105
  lines.push("");
106
106
  lines.push("Usage:");
107
107
  lines.push(pad("phren", "Interactive shell"));
108
- for (const cmd of visibleCommands()) {
108
+ for (const cmd of visibleCommands(snapshot)) {
109
109
  if (!cmd.featured)
110
110
  continue;
111
111
  lines.push(renderCheatSheetLine(cmd));
112
112
  }
113
113
  lines.push("");
114
114
  for (const topic of TOPIC_ORDER) {
115
- const cmds = commandsInTopic(topic);
115
+ const cmds = commandsInTopic(topic, snapshot);
116
116
  if (!cmds.length)
117
117
  continue;
118
- lines.push(formatTopic(topic));
118
+ lines.push(formatTopic(topic, snapshot));
119
119
  }
120
120
  for (const [docName, body] of Object.entries(DOC_TOPICS)) {
121
121
  lines.push(`${docName.charAt(0).toUpperCase()}${docName.slice(1)} reference:`);
@@ -1,3 +1,4 @@
1
+ import type { ModuleSnapshot } from "./modules/runtime.js";
1
2
  /**
2
3
  * Command registry - single source of truth for help generation and dispatch.
3
4
  *
@@ -38,8 +39,10 @@ export interface Command {
38
39
  export declare const ENV_HELP = "Environment variables:\n PHREN_PATH Override phren directory (default: ~/.phren)\n PHREN_PROFILE Active profile name\n PHREN_DEBUG Enable debug logging (set to 1)\n PHREN_PULL_INTERVAL_SECONDS Remote check interval in seconds (default: off; 0 disables)\n\n Embeddings:\n PHREN_OLLAMA_URL Ollama base URL (default: http://localhost:11434, 'off' to disable)\n PHREN_EMBEDDING_API_URL OpenAI-compatible /embeddings endpoint\n PHREN_EMBEDDING_API_KEY API key for embedding endpoint\n PHREN_EMBEDDING_MODEL Embedding model (default: nomic-embed-text)\n\n Context injection:\n PHREN_CONTEXT_TOKEN_BUDGET Max tokens injected per prompt (default: 550)\n PHREN_MAX_INJECT_TOKENS Hard cap on total injected tokens (default: 2000)\n PHREN_HOOK_TIMEOUT_MS Hook subprocess timeout in ms (default: 14000)\n\n Feature flags:\n PHREN_FEATURE_AGENTS=1 Show running coding agents on the graph\n PHREN_FEATURE_TOOL_HOOK=0 Skip the PostToolUse subprocess (perf)\n PHREN_FEATURE_AUTO_EXTRACT=0 Disable auto memory extraction\n PHREN_FEATURE_AUTO_CAPTURE=1 Extract insights from conversations\n PHREN_FEATURE_SEMANTIC_DEDUP=1 LLM-based dedup on add_finding\n PHREN_FEATURE_HYBRID_SEARCH=0 Disable TF-IDF cosine fallback\n\n Run 'phren help all' to see everything.\n";
39
40
  export declare const DOC_TOPICS: Record<string, string>;
40
41
  export declare const REGISTRY: Command[];
41
- export declare function lookupCommand(name: string): Command | undefined;
42
+ export declare function lookupCommand(name: string, snapshot?: ModuleSnapshot): Command | undefined;
42
43
  /** Topic IDs available to `phren help <topic>`, including doc topics and `all`. */
43
44
  export declare function helpTopicNames(): string[];
44
45
  /** Topic IDs that are command groups (excludes doc topics and `all`). */
45
46
  export declare function commandTopics(): readonly Topic[];
47
+ export declare function disabledCommand(command: string, snapshot: ModuleSnapshot): string | undefined;
48
+ export declare function commandsForModules(snapshot?: ModuleSnapshot): Command[];