@tekmidian/pai 0.64.0 → 0.65.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 (180) hide show
  1. package/README.md +19 -5
  2. package/dist/{aibroker-client-BpfuGPe5.mjs → aibroker-client-B8c42Lh8.mjs} +1 -1
  3. package/dist/{aibroker-client-DRld7g6z.mjs → aibroker-client-C5Fw7DNz.mjs} +10 -4
  4. package/dist/{aibroker-client-DRld7g6z.mjs.map → aibroker-client-C5Fw7DNz.mjs.map} +1 -1
  5. package/dist/{async-CY_cd_8j.mjs → async-CNn36gm4.mjs} +2 -2
  6. package/dist/{async-CY_cd_8j.mjs.map → async-CNn36gm4.mjs.map} +1 -1
  7. package/dist/{auto-route-CPlam4iv.mjs → auto-route-sLMU-NnM.mjs} +2 -2
  8. package/dist/{auto-route-CPlam4iv.mjs.map → auto-route-sLMU-NnM.mjs.map} +1 -1
  9. package/dist/{chain-o-g8AgE3.mjs → chain-C8QO8gwj.mjs} +4 -4
  10. package/dist/{chain-o-g8AgE3.mjs.map → chain-C8QO8gwj.mjs.map} +1 -1
  11. package/dist/cli/index.mjs +19 -19
  12. package/dist/cli/program.d.mts.map +1 -1
  13. package/dist/cli/program.mjs +19 -19
  14. package/dist/{clusters-DsMf20PP.mjs → clusters-PgIUYT_v.mjs} +1 -1
  15. package/dist/{clusters-DsMf20PP.mjs.map → clusters-PgIUYT_v.mjs.map} +1 -1
  16. package/dist/{config-2wkz744W.mjs → config-BbLFD7Uf.mjs} +3 -3
  17. package/dist/{config-2wkz744W.mjs.map → config-BbLFD7Uf.mjs.map} +1 -1
  18. package/dist/{config-CUTg6VDq.mjs → config-YinjgXEJ.mjs} +1 -1
  19. package/dist/{context-handover-cache-BOpjLsKe.mjs → context-handover-cache-mGxq2-8f.mjs} +11 -29
  20. package/dist/context-handover-cache-mGxq2-8f.mjs.map +1 -0
  21. package/dist/daemon/index.mjs +16 -16
  22. package/dist/daemon-CX9JomIJ.mjs +19 -0
  23. package/dist/{daemon-BYieXduQ.mjs → daemon-D2r1AQqE.mjs} +30 -30
  24. package/dist/{daemon-BYieXduQ.mjs.map → daemon-D2r1AQqE.mjs.map} +1 -1
  25. package/dist/daemon-mcp/index.mjs +17 -17
  26. package/dist/daemon-mcp/index.mjs.map +1 -1
  27. package/dist/detector-C3Q7mxQU.mjs +3 -0
  28. package/dist/{detector-BAlmrLQ0.mjs → detector-CIHEXKsV.mjs} +1 -1
  29. package/dist/{detector-BAlmrLQ0.mjs.map → detector-CIHEXKsV.mjs.map} +1 -1
  30. package/dist/{embeddings-DK9XfQic.mjs → embeddings-BbNVXa_0.mjs} +1 -1
  31. package/dist/{embeddings-DK9XfQic.mjs.map → embeddings-BbNVXa_0.mjs.map} +1 -1
  32. package/dist/{embeddings-Xg8XLf2K.mjs → embeddings-CDfM63uC.mjs} +1 -1
  33. package/dist/{factory-BMK0tC1b.mjs → factory-CaswxuJ0.mjs} +1 -1
  34. package/dist/{factory-C4We3xR_.mjs → factory-y36qGegI.mjs} +13 -13
  35. package/dist/{factory-C4We3xR_.mjs.map → factory-y36qGegI.mjs.map} +1 -1
  36. package/dist/{fallback-ECiqCuh6.mjs → fallback-CWDQYmJi.mjs} +1205 -1204
  37. package/dist/fallback-CWDQYmJi.mjs.map +1 -0
  38. package/dist/{federation-db-CUgy0WYs.mjs → federation-db-BTyoufBh.mjs} +2 -2
  39. package/dist/{federation-db-CUgy0WYs.mjs.map → federation-db-BTyoufBh.mjs.map} +1 -1
  40. package/dist/federation-db-HfIFc7FG.mjs +3 -0
  41. package/dist/hooks/block-sleep-poll.mjs +36 -11
  42. package/dist/hooks/block-sleep-poll.mjs.map +2 -2
  43. package/dist/hooks/capture-all-events.mjs +3 -17
  44. package/dist/hooks/capture-all-events.mjs.map +3 -3
  45. package/dist/hooks/capture-session-summary.mjs +3 -17
  46. package/dist/hooks/capture-session-summary.mjs.map +3 -3
  47. package/dist/hooks/capture-tool-output.mjs +3 -17
  48. package/dist/hooks/capture-tool-output.mjs.map +3 -3
  49. package/dist/hooks/cleanup-session-files.mjs +3 -17
  50. package/dist/hooks/cleanup-session-files.mjs.map +2 -2
  51. package/dist/hooks/context-compression-hook.mjs +3 -17
  52. package/dist/hooks/context-compression-hook.mjs.map +3 -3
  53. package/dist/hooks/initialize-session.mjs +3 -17
  54. package/dist/hooks/initialize-session.mjs.map +2 -2
  55. package/dist/hooks/inject-observations.mjs +3 -17
  56. package/dist/hooks/inject-observations.mjs.map +2 -2
  57. package/dist/hooks/load-core-context.mjs +4 -22
  58. package/dist/hooks/load-core-context.mjs.map +2 -2
  59. package/dist/hooks/load-project-context.mjs +3 -17
  60. package/dist/hooks/load-project-context.mjs.map +3 -3
  61. package/dist/hooks/mcp-deferred-gate.mjs +3 -17
  62. package/dist/hooks/mcp-deferred-gate.mjs.map +2 -2
  63. package/dist/hooks/observe.mjs +3 -17
  64. package/dist/hooks/observe.mjs.map +2 -2
  65. package/dist/hooks/security-validator.mjs +3 -17
  66. package/dist/hooks/security-validator.mjs.map +3 -3
  67. package/dist/hooks/stop-hook.mjs +3 -17
  68. package/dist/hooks/stop-hook.mjs.map +3 -3
  69. package/dist/hooks/sync-todo-to-md.mjs +3 -17
  70. package/dist/hooks/sync-todo-to-md.mjs.map +2 -2
  71. package/dist/hooks/worker-guard.mjs.map +2 -2
  72. package/dist/hooks/worker-status-line.mjs +4 -4
  73. package/dist/hooks/worker-status-line.mjs.map +2 -2
  74. package/dist/{indexer-backend-CJ0RGgMz.mjs → indexer-backend-Cnc7Tf5C.mjs} +2 -2
  75. package/dist/{ipc-client-EhWY8XL0.mjs → ipc-client-D16Xw6Uo.mjs} +2 -2
  76. package/dist/{ipc-client-EhWY8XL0.mjs.map → ipc-client-D16Xw6Uo.mjs.map} +1 -1
  77. package/dist/{kg-entity-1uqCnk4u.mjs → kg-entity-COTUj1ZC.mjs} +1 -1
  78. package/dist/{kg-entity-1uqCnk4u.mjs.map → kg-entity-COTUj1ZC.mjs.map} +1 -1
  79. package/dist/{latent-ideas-CSuKfiq3.mjs → latent-ideas-ByvMjVcb.mjs} +3 -3
  80. package/dist/{latent-ideas-CSuKfiq3.mjs.map → latent-ideas-ByvMjVcb.mjs.map} +1 -1
  81. package/dist/{link-boost-BtjzfE3c.mjs → link-boost-UiE-uooT.mjs} +1 -1
  82. package/dist/{link-boost-BtjzfE3c.mjs.map → link-boost-UiE-uooT.mjs.map} +1 -1
  83. package/dist/{main-resolver-DyOrwNYw.mjs → main-resolver-CDe7DCso.mjs} +6 -6
  84. package/dist/{main-resolver-DyOrwNYw.mjs.map → main-resolver-CDe7DCso.mjs.map} +1 -1
  85. package/dist/main-resolver-DI-A7lSO.mjs +7 -0
  86. package/dist/merge-2gqRPFu2.mjs +3 -0
  87. package/dist/{merge-D58n_-LZ.mjs → merge-DgU9OgZy.mjs} +1 -1
  88. package/dist/{merge-D58n_-LZ.mjs.map → merge-DgU9OgZy.mjs.map} +1 -1
  89. package/dist/module-paths-DdRzbkUI.mjs +44 -0
  90. package/dist/module-paths-DdRzbkUI.mjs.map +1 -0
  91. package/dist/{neighborhood-DNuRelRB.mjs → neighborhood-CvRHlqdR.mjs} +2 -2
  92. package/dist/{neighborhood-DNuRelRB.mjs.map → neighborhood-CvRHlqdR.mjs.map} +1 -1
  93. package/dist/{note-context-D9JZ4-7o.mjs → note-context-BrbfUIoP.mjs} +1 -1
  94. package/dist/{note-context-D9JZ4-7o.mjs.map → note-context-BrbfUIoP.mjs.map} +1 -1
  95. package/dist/{pai-home-UncxWxlX.mjs → pai-home-Cm9rcJgX.mjs} +1 -1
  96. package/dist/{pai-home-UncxWxlX.mjs.map → pai-home-Cm9rcJgX.mjs.map} +1 -1
  97. package/dist/{planner-DgC3oSvb.mjs → planner-8-shIa8t.mjs} +7 -7
  98. package/dist/{planner-DgC3oSvb.mjs.map → planner-8-shIa8t.mjs.map} +1 -1
  99. package/dist/{postgres-CcsRKir-.mjs → postgres-DYtZg7J7.mjs} +5 -13
  100. package/dist/{postgres-CcsRKir-.mjs.map → postgres-DYtZg7J7.mjs.map} +1 -1
  101. package/dist/{program-JhF2GgJY.mjs → program-DiktbiWa.mjs} +225 -245
  102. package/dist/program-DiktbiWa.mjs.map +1 -0
  103. package/dist/{query-feedback-BPa0dISE.mjs → query-feedback-BIaZTTFO.mjs} +2 -2
  104. package/dist/{query-feedback-BPa0dISE.mjs.map → query-feedback-BIaZTTFO.mjs.map} +1 -1
  105. package/dist/query-feedback-B_iigYj-.mjs +3 -0
  106. package/dist/{registry-db-DCzdI4sC.mjs → registry-db-C7voqML9.mjs} +2 -2
  107. package/dist/{registry-db-DCzdI4sC.mjs.map → registry-db-C7voqML9.mjs.map} +1 -1
  108. package/dist/registry-db-JHPhA8vF.mjs +3 -0
  109. package/dist/{registry-postgres-BUnkHKYs.mjs → registry-postgres-DSrkxqfF.mjs} +2 -2
  110. package/dist/{registry-postgres-BUnkHKYs.mjs.map → registry-postgres-DSrkxqfF.mjs.map} +1 -1
  111. package/dist/{registry-sqlite-CKYNwkUv.mjs → registry-sqlite-B2436JgX.mjs} +2 -2
  112. package/dist/{registry-sqlite-CKYNwkUv.mjs.map → registry-sqlite-B2436JgX.mjs.map} +1 -1
  113. package/dist/router-S6C5BxzZ.mjs +3 -0
  114. package/dist/{router-CGZATlvm.mjs → router-aqLMvNMg.mjs} +1 -1
  115. package/dist/{router-CGZATlvm.mjs.map → router-aqLMvNMg.mjs.map} +1 -1
  116. package/dist/{run-W2rV_9j0.mjs → run-DUZRSnIT.mjs} +120 -42
  117. package/dist/run-DUZRSnIT.mjs.map +1 -0
  118. package/dist/{run-env-Br4Bc7Vz.mjs → run-env-BHWnXqle.mjs} +3 -3
  119. package/dist/{run-env-Br4Bc7Vz.mjs.map → run-env-BHWnXqle.mjs.map} +1 -1
  120. package/dist/{runtime-paths-QGQJAekd.mjs → runtime-paths-CHTg3ywb.mjs} +1 -1
  121. package/dist/{runtime-paths-QGQJAekd.mjs.map → runtime-paths-CHTg3ywb.mjs.map} +1 -1
  122. package/dist/{server-B71rem4q.mjs → server-DlL1QI2k.mjs} +4 -5
  123. package/dist/server-DlL1QI2k.mjs.map +1 -0
  124. package/dist/{session-keepalive-Dgil9hjw.mjs → session-keepalive-CZUwp5IQ.mjs} +7 -7
  125. package/dist/{session-keepalive-Dgil9hjw.mjs.map → session-keepalive-CZUwp5IQ.mjs.map} +1 -1
  126. package/dist/skills/Art/SKILL.md +1 -1
  127. package/dist/skills/Observability/SKILL.md +4 -4
  128. package/dist/skills/Research/SKILL.md +1 -1
  129. package/dist/{sources-LcGptLA-.mjs → sources-DX4ElmrE.mjs} +1 -1
  130. package/dist/{sources-LcGptLA-.mjs.map → sources-DX4ElmrE.mjs.map} +1 -1
  131. package/dist/{sqlite-CAJcw2zL.mjs → sqlite-BrEu3avy.mjs} +3 -3
  132. package/dist/{sqlite-CAJcw2zL.mjs.map → sqlite-BrEu3avy.mjs.map} +1 -1
  133. package/dist/{state-S9wlKarB.mjs → state-DW8zdweW.mjs} +1 -1
  134. package/dist/{state-CHltNjXI.mjs → state-HyjqTihC.mjs} +1 -1
  135. package/dist/{state-CHltNjXI.mjs.map → state-HyjqTihC.mjs.map} +1 -1
  136. package/dist/{themes-D1FQFthd.mjs → themes-BgqahYVM.mjs} +2 -2
  137. package/dist/{themes-D1FQFthd.mjs.map → themes-BgqahYVM.mjs.map} +1 -1
  138. package/dist/{tools-BW7OXf-N.mjs → tools-BbqQIHPe.mjs} +4 -4
  139. package/dist/{tools-BFC-113F.mjs → tools-gMGDIpJ9.mjs} +18 -18
  140. package/dist/{tools-BFC-113F.mjs.map → tools-gMGDIpJ9.mjs.map} +1 -1
  141. package/dist/{trace-IDKK1VFs.mjs → trace-CmAB7iJZ.mjs} +1 -1
  142. package/dist/{trace-IDKK1VFs.mjs.map → trace-CmAB7iJZ.mjs.map} +1 -1
  143. package/dist/{vault-indexer-y6YC2-mh.mjs → vault-indexer-Ddq51X20.mjs} +1 -1
  144. package/dist/{vault-indexer-y6YC2-mh.mjs.map → vault-indexer-Ddq51X20.mjs.map} +1 -1
  145. package/dist/{wakeup-CNZQZzsY.mjs → wakeup-CZw88uXf.mjs} +3 -3
  146. package/dist/{wakeup-CNZQZzsY.mjs.map → wakeup-CZw88uXf.mjs.map} +1 -1
  147. package/dist/{work-queue-worker-Dy5FT2ak.mjs → work-queue-worker-DCzfH0d1.mjs} +4 -4
  148. package/dist/{work-queue-worker-Dy5FT2ak.mjs.map → work-queue-worker-DCzfH0d1.mjs.map} +1 -1
  149. package/dist/work-queue-worker-Taba_vcA.mjs +11 -0
  150. package/dist/{zettelkasten-Dx-63BEk.mjs → zettelkasten-Dwj67e4p.mjs} +4 -4
  151. package/dist/{zettelkasten-Dx-63BEk.mjs.map → zettelkasten-Dwj67e4p.mjs.map} +1 -1
  152. package/docker/docker-compose.yml +39 -0
  153. package/docs/commands/README.md +3 -3
  154. package/docs/commands/config.md +3 -3
  155. package/docs/commands/setup.md +9 -2
  156. package/docs/commands/worker.md +2 -2
  157. package/package.json +3 -2
  158. package/scripts/build-hooks.mjs +6 -6
  159. package/src/hooks/ts/lib/pai-paths-case.test.ts +12 -0
  160. package/src/hooks/ts/lib/pai-paths-import.test.ts +25 -0
  161. package/src/hooks/ts/lib/pai-paths.ts +5 -28
  162. package/src/hooks/ts/lib/sleep-poll-gate.test.ts +17 -1
  163. package/src/hooks/ts/lib/sleep-poll-gate.ts +21 -9
  164. package/src/hooks/ts/session-start/load-core-context.ts +2 -6
  165. package/src/hooks/ts/session-start/session-start-worker-guard.test.ts +24 -1
  166. package/dist/context-handover-cache-BOpjLsKe.mjs.map +0 -1
  167. package/dist/daemon-q3xjHwa4.mjs +0 -19
  168. package/dist/detector-C-YmZsOi.mjs +0 -3
  169. package/dist/fallback-ECiqCuh6.mjs.map +0 -1
  170. package/dist/federation-db-BZ8PyxFe.mjs +0 -3
  171. package/dist/main-resolver-vN09bkXv.mjs +0 -7
  172. package/dist/merge-CXGz5wXz.mjs +0 -3
  173. package/dist/program-JhF2GgJY.mjs.map +0 -1
  174. package/dist/query-feedback-BPHFFSu1.mjs +0 -3
  175. package/dist/registry-db-Hphlj3H4.mjs +0 -3
  176. package/dist/router-CoA8Uy1m.mjs +0 -3
  177. package/dist/run-W2rV_9j0.mjs.map +0 -1
  178. package/dist/server-B71rem4q.mjs.map +0 -1
  179. package/dist/work-queue-worker-CkShUa0z.mjs +0 -11
  180. /package/dist/{indexer-backend-DotpxHJd.mjs → indexer-backend-isSLg6yE.mjs} +0 -0
@@ -3,26 +3,27 @@ import { a as slugify$1, i as parseSessionFilename } from "./migrate-BD7D8EEh.mj
3
3
  import { n as ensurePaiMarker } from "./pai-marker-D1MMswkz.mjs";
4
4
  import { t as STOP_WORDS } from "./stop-words-BdQuaE9K.mjs";
5
5
  import { t as applyRecencyBoost } from "./search-BOSphCJ1.mjs";
6
- import { a as getStorageBackend, i as getRegistryBackend, r as createStorageBackend, s as humanDuration } from "./factory-C4We3xR_.mjs";
7
- import { a as formatDetectionJson, i as formatDetection, n as migrateIdentityFile, r as detectProject } from "./wakeup-CNZQZzsY.mjs";
8
- import { B as claudeProjectsDir, C as findLatestNote, H as scanTranscriptFolders, I as resolveHome, L as saveScanConfig, M as cmdScan, N as loadScanConfig, P as migrateScanConfig, R as upsertProject, S as applyContinue, T as readBodyFile, U as transcriptFiles, V as findMovedProjects, d as migrateWorkQueue, g as migrateSummaryCooldowns, t as readContextHandoverCache, v as extractAndStoreTriples, w as findNotesDir$1, x as appendCheckpointToNote, z as upsertSession } from "./context-handover-cache-BOpjLsKe.mjs";
9
- import { a as paiHomePath, i as paiHomeDir, n as migratePaiDir, o as resolvePaiFile, r as migratePaiFile, t as PaiFileMigrationError } from "./pai-home-UncxWxlX.mjs";
10
- import { b as OWNER_LABEL_PREFIX, c as migrateConfigFile, d as readMainConfigRaw, f as writeMainConfigRaw, h as resolvedMainConfigPath, l as paiConfigFilePath, m as migrateMainConfigToYaml, n as CONFIG_FILE$2, o as expandHome, p as MainConfigError, s as loadConfig, t as CONFIG_DIR, u as paiConfigYamlFilePath, v as readJsonStrict, x as UNROUTED, y as writeJsonAtomic } from "./config-2wkz744W.mjs";
11
- import { a as schedulerLogPath, i as paiSocketPath, n as daemonLogPath, r as daemonPidPath } from "./runtime-paths-QGQJAekd.mjs";
12
- import { B as contextWindowFromModelId, C as nativeAnthropicProvider, E as readWorkersSection, F as parseWorkersYamlDocument, I as relocateWorkersYaml, L as workersYamlLegacyNotice, M as inlineWorkersYamlKeys, N as migrateWorkersToYaml, P as needsWorkersYamlRelocation, R as workersYamlPath, S as maskKey, V as stripModelVariant, b as isModelCapability, f as PROVIDER_TAGS, j as initWorkersYaml, m as WorkersConfigError, r as ANTHROPIC_NATIVE, t as buildRunEnv, u as MODEL_CAPABILITIES, v as expandHome$1, y as getProviderOrNative, z as DEFAULT_CONTEXT_WINDOW } from "./run-env-Br4Bc7Vz.mjs";
13
- import { $ as expandMcpNames, B as loadStatuses, C as discardWorker, D as uncommittedPaths, E as mergeWorker, G as setWorkerLabel, J as parseRunnerArgs, K as waitForTerminalStatus, L as isChatPane, Q as describeMcp, R as isLive, T as git, U as ownsPid, W as saveStatus, X as pinNotices, Z as projectLaunchConfig, a as parseWorkerReport, d as checkPaneForWorker, f as openFollowPane, h as markControlsHeld, i as usageContextTokens, j as UNLABELED, k as appendLedger, l as sayToWorker, m as clickrControlsArgv, n as runWorker, p as openPaneForWorker, q as longInlinePromptHint, r as testProvider, s as handoffFromInside, w as gcWorktrees, z as loadStatus } from "./run-W2rV_9j0.mjs";
14
- import { t as MergeError } from "./merge-D58n_-LZ.mjs";
15
- import { n as oldFederationPath, t as federationDbPath } from "./federation-db-CUgy0WYs.mjs";
16
- import { r as registryDbPath, t as oldRegistryPath } from "./registry-db-DCzdI4sC.mjs";
17
- import { i as indexProjectWithBackend } from "./async-CY_cd_8j.mjs";
18
- import { t as PaiClient } from "./ipc-client-EhWY8XL0.mjs";
19
- import { A as getConfigValueOp, C as psOutput, D as resolveSpecPath, E as readSpecPrompt, M as setConfigValueOp, N as unsetConfigValueOp, O as MainConfigOpsError, S as followWorkers, T as statusLineOutput, _ as setWorkersEnabled, a as addProvider, b as updateProvider, c as describeModels, d as removeProvider, f as resolveProviderName, g as setProviderModel, h as setProviderEnabled, i as fallbackStatusText, j as listConfigOp, k as formatConfigGetOutput, l as describeProviders, m as setClass, n as fallbackOn, o as classTargetText, p as setCapabilityPreference, r as fallbackStatus, s as describeCapabilities, t as fallbackOff, u as modelPrefsText, v as unsetCapabilityPreference, w as replayOutput, x as useProvider, y as unsetClass } from "./fallback-ECiqCuh6.mjs";
20
- import { _ as resolveSessionByNameOrId, a as buildDeduped, c as hasConversation, d as providerResumePlan, f as restoreTopLevel, g as migrateSessionScanCache, h as fmtAge$1, l as launchInDir, m as printExitDir, o as normalizeName$2, p as resumeArgvText, s as renderDedupedSessions, t as cmdMain, u as launchPrompt, v as scanCacheFilePath, y as scanSessions } from "./main-resolver-DyOrwNYw.mjs";
21
- import { n as queriesDirPath, t as migrateQueriesDir } from "./query-feedback-BPa0dISE.mjs";
22
- import { _ as statusPath, h as ledgerPath, m as eventsPath, n as ensureProxyRunning, p as ensureNoMcpConfig, r as stopProxy, t as DEFAULT_PROXY_PORT, v as workersLogDir } from "./server-B71rem4q.mjs";
23
- import { i as sendToSession, n as fetchLiveSessions, r as revealItermSession, t as callAiBroker } from "./aibroker-client-DRld7g6z.mjs";
24
- import { a as totalUsageTokens, i as parseSessionUsage, r as sessionKeepaliveLedgerSummary, t as loadSessionKeepaliveState } from "./session-keepalive-Dgil9hjw.mjs";
25
- import { t as runChain } from "./chain-o-g8AgE3.mjs";
6
+ import { n as resolveFromModule, t as packageRoot } from "./module-paths-DdRzbkUI.mjs";
7
+ import { a as getStorageBackend, i as getRegistryBackend, r as createStorageBackend, s as humanDuration } from "./factory-y36qGegI.mjs";
8
+ import { a as formatDetectionJson, i as formatDetection, n as migrateIdentityFile, r as detectProject } from "./wakeup-CZw88uXf.mjs";
9
+ import { B as claudeProjectsDir, C as findLatestNote, H as scanTranscriptFolders, I as resolveHome, L as saveScanConfig, M as cmdScan, N as loadScanConfig, P as migrateScanConfig, R as upsertProject, S as applyContinue, T as readBodyFile, U as transcriptFiles, V as findMovedProjects, d as migrateWorkQueue, g as migrateSummaryCooldowns, t as readContextHandoverCache, v as extractAndStoreTriples, w as findNotesDir$1, x as appendCheckpointToNote, z as upsertSession } from "./context-handover-cache-mGxq2-8f.mjs";
10
+ import { a as paiHomePath, i as paiHomeDir, n as migratePaiDir, o as resolvePaiFile, r as migratePaiFile, t as PaiFileMigrationError } from "./pai-home-Cm9rcJgX.mjs";
11
+ import { b as OWNER_LABEL_PREFIX, c as migrateConfigFile, d as readMainConfigRaw, f as writeMainConfigRaw, h as resolvedMainConfigPath, l as paiConfigFilePath, m as migrateMainConfigToYaml, n as CONFIG_FILE$2, o as expandHome, p as MainConfigError, s as loadConfig, t as CONFIG_DIR, u as paiConfigYamlFilePath, v as readJsonStrict, x as UNROUTED, y as writeJsonAtomic } from "./config-BbLFD7Uf.mjs";
12
+ import { a as schedulerLogPath, i as paiSocketPath, n as daemonLogPath, r as daemonPidPath } from "./runtime-paths-CHTg3ywb.mjs";
13
+ import { B as contextWindowFromModelId, C as nativeAnthropicProvider, E as readWorkersSection, F as parseWorkersYamlDocument, I as relocateWorkersYaml, L as workersYamlLegacyNotice, M as inlineWorkersYamlKeys, N as migrateWorkersToYaml, P as needsWorkersYamlRelocation, R as workersYamlPath, S as maskKey, V as stripModelVariant, b as isModelCapability, f as PROVIDER_TAGS, j as initWorkersYaml, m as WorkersConfigError, r as ANTHROPIC_NATIVE, t as buildRunEnv, u as MODEL_CAPABILITIES, v as expandHome$1, y as getProviderOrNative, z as DEFAULT_CONTEXT_WINDOW } from "./run-env-BHWnXqle.mjs";
14
+ import { $ as expandMcpNames, B as loadStatuses, C as discardWorker, D as uncommittedPaths, E as mergeWorker, G as setWorkerLabel, J as parseRunnerArgs, K as waitForTerminalStatus, L as isChatPane, Q as describeMcp, R as isLive, T as git, U as ownsPid, W as saveStatus, X as pinNotices, Z as projectLaunchConfig, a as parseWorkerReport, d as checkPaneForWorker, f as openFollowPane, h as markControlsHeld, i as usageContextTokens, j as UNLABELED, k as appendLedger, l as sayToWorker, m as clickrControlsArgv, n as runWorker, p as openPaneForWorker, q as longInlinePromptHint, r as testProvider, s as handoffFromInside, w as gcWorktrees, z as loadStatus } from "./run-DUZRSnIT.mjs";
15
+ import { t as MergeError } from "./merge-DgU9OgZy.mjs";
16
+ import { n as oldFederationPath, t as federationDbPath } from "./federation-db-BTyoufBh.mjs";
17
+ import { r as registryDbPath, t as oldRegistryPath } from "./registry-db-C7voqML9.mjs";
18
+ import { i as indexProjectWithBackend } from "./async-CNn36gm4.mjs";
19
+ import { t as PaiClient } from "./ipc-client-D16Xw6Uo.mjs";
20
+ import { A as getConfigValueOp, C as setWorkersEnabled, D as useProvider, E as updateProvider, M as setConfigValueOp, N as unsetConfigValueOp, O as MainConfigOpsError, S as setProviderModel, T as unsetClass, _ as removeProvider, a as followWorkers, b as setClass, c as statusLineOutput, d as addProvider, f as classTargetText, g as modelPrefsText, h as describeProviders, i as fallbackStatusText, j as listConfigOp, k as formatConfigGetOutput, l as readSpecPrompt, m as describeModels, n as fallbackOn, o as psOutput, p as describeCapabilities, r as fallbackStatus, s as replayOutput, t as fallbackOff, u as resolveSpecPath, v as resolveProviderName, w as unsetCapabilityPreference, x as setProviderEnabled, y as setCapabilityPreference } from "./fallback-CWDQYmJi.mjs";
21
+ import { _ as resolveSessionByNameOrId, a as buildDeduped, c as hasConversation, d as providerResumePlan, f as restoreTopLevel, g as migrateSessionScanCache, h as fmtAge$1, l as launchInDir, m as printExitDir, o as normalizeName$2, p as resumeArgvText, s as renderDedupedSessions, t as cmdMain, u as launchPrompt, v as scanCacheFilePath, y as scanSessions } from "./main-resolver-CDe7DCso.mjs";
22
+ import { n as queriesDirPath, t as migrateQueriesDir } from "./query-feedback-BIaZTTFO.mjs";
23
+ import { _ as statusPath, h as ledgerPath, m as eventsPath, n as ensureProxyRunning, p as ensureNoMcpConfig, r as stopProxy, t as DEFAULT_PROXY_PORT, v as workersLogDir } from "./server-DlL1QI2k.mjs";
24
+ import { i as sendToSession, n as fetchLiveSessions, r as revealItermSession, t as callAiBroker } from "./aibroker-client-C5Fw7DNz.mjs";
25
+ import { a as totalUsageTokens, i as parseSessionUsage, r as sessionKeepaliveLedgerSummary, t as loadSessionKeepaliveState } from "./session-keepalive-CZUwp5IQ.mjs";
26
+ import { t as runChain } from "./chain-C8QO8gwj.mjs";
26
27
  import { appendFileSync, chmodSync, closeSync, copyFileSync, cpSync, createReadStream, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
27
28
  import { homedir, platform, tmpdir, userInfo } from "node:os";
28
29
  import { basename, dirname, join, relative, resolve, sep } from "node:path";
@@ -161,7 +162,7 @@ async function cmdPromote(opts) {
161
162
  console.error(dim$1(` Pick a durable location for the new project.`));
162
163
  process.exit(1);
163
164
  }
164
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
165
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
165
166
  const registryBackend = await getRegistryBackend();
166
167
  const encodedDir = encodeDir(targetPath);
167
168
  if (await registryBackend.getProjectBySlug(slug) ?? await registryBackend.getProjectByRootPath(targetPath) ?? await registryBackend.getProjectByEncodedDir(encodedDir)) {
@@ -2045,7 +2046,7 @@ async function cmdUnregister(slug, opts = {}) {
2045
2046
  //#region src/cli/commands/project/projects-index.ts
2046
2047
  function registerProjectsCommands(projectsCmd) {
2047
2048
  projectsCmd.command("list", { isDefault: true }).description("Show the unified deduped listing (same as `pai`).\nUse --all to include cold / zero-session / archived projects.").option("--all", "Show all entries including cold / zero-session / archived projects").option("-n, --n <count>", "Max rows to show", "20").action(async (opts) => {
2048
- const { cmdMain } = await import("./main-resolver-vN09bkXv.mjs");
2049
+ const { cmdMain } = await import("./main-resolver-DI-A7lSO.mjs");
2049
2050
  await cmdMain(void 0, void 0, opts);
2050
2051
  });
2051
2052
  projectsCmd.command("list-raw").description("Raw registry listing with slug, path, status, last_active columns").option("--all", "Include archived projects (default: active only)").option("--status <status>", "Filter by status: active | archived").option("--tag <tag>", "Filter by tag").option("--type <type>", "Filter by type").action(async (opts) => {
@@ -2911,7 +2912,7 @@ const DEFAULT_PAGE_SIZE = 500;
2911
2912
  async function runEmbed(backend, projectId, projectSlug, batchSize = 50, pageSize = DEFAULT_PAGE_SIZE) {
2912
2913
  const label = projectSlug ? `project ${projectSlug}` : "all projects";
2913
2914
  console.log(dim$1(`Generating embeddings for ${label} (this may take a while on first run)...`));
2914
- const { generateEmbeddings, serializeEmbedding } = await import("./embeddings-Xg8XLf2K.mjs");
2915
+ const { generateEmbeddings, serializeEmbedding } = await import("./embeddings-CDfM63uC.mjs");
2915
2916
  const { chunks: totalEstimate } = projectId !== void 0 ? await backend.getProjectStats(projectId) : await backend.getStats();
2916
2917
  let done = 0;
2917
2918
  let after = null;
@@ -3075,7 +3076,7 @@ function registerSearchCommand(memoryCmd) {
3075
3076
  let results;
3076
3077
  if (mode === "keyword") results = await backend.searchKeyword(query, searchOpts);
3077
3078
  else {
3078
- const { generateEmbedding } = await import("./embeddings-Xg8XLf2K.mjs");
3079
+ const { generateEmbedding } = await import("./embeddings-CDfM63uC.mjs");
3079
3080
  console.log(dim$1("Generating query embedding..."));
3080
3081
  const queryEmbedding = await generateEmbedding(query, true);
3081
3082
  if (mode === "semantic") results = await backend.searchSemantic(queryEmbedding, searchOpts);
@@ -3260,9 +3261,9 @@ function registerStatsCommands(memoryCmd) {
3260
3261
  //#region src/cli/commands/memory/sources-cmd.ts
3261
3262
  function registerSourcesCommand(memoryCmd) {
3262
3263
  memoryCmd.command("sources").description("Show what the indexer has taken in: composition by source, which roots\ncontent enters from, the heaviest single files, and how many chunks are\nrewritten per day (which distinguishes a finite backlog from a treadmill).").option("--limit <n>", "Rows per section (default 8)", "8").action(async (opts) => {
3263
- const { createStorageBackend } = await import("./factory-BMK0tC1b.mjs");
3264
- const { loadConfig } = await import("./config-CUTg6VDq.mjs");
3265
- const { cmdMemorySources } = await import("./sources-LcGptLA-.mjs");
3264
+ const { createStorageBackend } = await import("./factory-CaswxuJ0.mjs");
3265
+ const { loadConfig } = await import("./config-YinjgXEJ.mjs");
3266
+ const { cmdMemorySources } = await import("./sources-DX4ElmrE.mjs");
3266
3267
  let backend;
3267
3268
  try {
3268
3269
  backend = await createStorageBackend(loadConfig());
@@ -3962,8 +3963,8 @@ async function escalate(task, headline, detail, state, now, opts) {
3962
3963
  state.alarmedAt[task.id] = now;
3963
3964
  let delivered = false;
3964
3965
  try {
3965
- const { routeNotification } = await import("./router-CoA8Uy1m.mjs");
3966
- const { loadConfig } = await import("./config-CUTg6VDq.mjs");
3966
+ const { routeNotification } = await import("./router-S6C5BxzZ.mjs");
3967
+ const { loadConfig } = await import("./config-YinjgXEJ.mjs");
3967
3968
  delivered = (await routeNotification({
3968
3969
  event: "error",
3969
3970
  title: `PAI: ${headline}`,
@@ -3998,7 +3999,7 @@ async function escalate(task, headline, detail, state, now, opts) {
3998
3999
  async function alertParked(task, reason) {
3999
4000
  const text = `PAI parked "${task.title}" (${task.id}) — the scheduler will not retry it.\nReason: ${reason}\nTo release it: fix the cause, then move the due date — due_string, natural language only (e.g. "tomorrow 9am").`;
4000
4001
  try {
4001
- const { callAiBroker } = await import("./aibroker-client-BpfuGPe5.mjs");
4002
+ const { callAiBroker } = await import("./aibroker-client-B8c42Lh8.mjs");
4002
4003
  await callAiBroker("pailot_send", { text }, 8e3);
4003
4004
  } catch (e) {
4004
4005
  console.error(`[pai-poller] parked-task alert not delivered to PAILot (${e instanceof Error ? e.message : String(e)}): ${text}`);
@@ -5703,18 +5704,18 @@ function registerObsidianCommands(obsidianCmd) {
5703
5704
  /**
5704
5705
  * adapter-content.ts — PAI_HOME/agents and PAI_HOME/commands: the operator's
5705
5706
  * authored Agent/Command .md content, made PAI-owned with an adapter symlink
5706
- * back at ~/.claude/Agents and ~/.claude/Commands so Claude Code still loads
5707
+ * back at ~/.claude/agents and ~/.claude/commands so Claude Code still loads
5707
5708
  * them from its fixed harness paths (confirmed empirically: Claude Code
5708
5709
  * follows a directory symlink for .claude/agents/ — see docs/workers-config.md,
5709
- * "Where PAI lives"). Unlike Hooks/Skills (individual files symlinked by the
5710
+ * "Where PAI lives"). Unlike Hooks/skills (individual files symlinked by the
5710
5711
  * build's --sync step), these were real, un-owned files with no PAI copy to
5711
5712
  * symlink from — this module is what gives them one.
5712
5713
  */
5713
5714
  function oldAgentsDir() {
5714
- return join(homedir(), ".claude", "Agents");
5715
+ return join(homedir(), ".claude", "agents");
5715
5716
  }
5716
5717
  function oldCommandsDir() {
5717
- return join(homedir(), ".claude", "Commands");
5718
+ return join(homedir(), ".claude", "commands");
5718
5719
  }
5719
5720
  function migrateContentDirWithSymlink(newDir, oldDir, opts = {}) {
5720
5721
  if (existsSync(oldDir) && lstatSync(oldDir).isSymbolicLink()) return {
@@ -5748,11 +5749,11 @@ function migrateContentDirWithSymlink(newDir, oldDir, opts = {}) {
5748
5749
  };
5749
5750
  }
5750
5751
  }
5751
- /** Move ~/.claude/Agents/*.md into PAI_HOME/agents/, then symlink it back. */
5752
+ /** Move ~/.claude/agents/*.md into PAI_HOME/agents/, then symlink it back. */
5752
5753
  function migrateAgentsDir(opts = {}) {
5753
5754
  return migrateContentDirWithSymlink(paiHomePath("agents"), oldAgentsDir(), opts);
5754
5755
  }
5755
- /** Move ~/.claude/Commands/*.md into PAI_HOME/commands/, then symlink it back. */
5756
+ /** Move ~/.claude/commands/*.md into PAI_HOME/commands/, then symlink it back. */
5756
5757
  function migrateCommandsDir(opts = {}) {
5757
5758
  return migrateContentDirWithSymlink(paiHomePath("commands"), oldCommandsDir(), opts);
5758
5759
  }
@@ -6227,8 +6228,8 @@ function registerConfigCommands(configCmd) {
6227
6228
  console.log(` scheduler-state.json: ${STATE_FILE}`);
6228
6229
  console.log(` identity.txt: ${paiHomePath("identity.txt")} (L0 wake-up identity, optional)`);
6229
6230
  console.log(` registry-scan.json: ${paiHomePath("registry-scan.json")}`);
6230
- console.log(` agents/: ${paiHomePath("agents")} (~/.claude/Agents symlinks here after migrate)`);
6231
- console.log(` commands/: ${paiHomePath("commands")} (~/.claude/Commands symlinks here after migrate)`);
6231
+ console.log(` agents/: ${paiHomePath("agents")} (~/.claude/agents symlinks here after migrate)`);
6232
+ console.log(` commands/: ${paiHomePath("commands")} (~/.claude/commands symlinks here after migrate)`);
6232
6233
  });
6233
6234
  configCmd.command("yaml").description("Convert config.json → config.yaml (and voices.json → voices.yaml), with a short\n # comment above every top-level section and any \"_comment\"/\"_...Note\" JSON-\n workaround key re-attached as a real comment. Verifies the generated YAML\n re-parses to the exact same data before writing anything; the JSON is then\n renamed to <name>.migrated-<YYYY-MM-DD> (never deleted). Every writer keeps\n working unmodified afterwards — see docs/config.md.").option("--dry-run", "Print the plan without writing anything").option("--force", "Regenerate config.yaml (or voices.yaml) even if it already exists").action((opts) => {
6234
6235
  let hadError = false;
@@ -6289,7 +6290,7 @@ function registerConfigCommands(configCmd) {
6289
6290
  process.exitCode = 1;
6290
6291
  }
6291
6292
  });
6292
- configCmd.command("migrate").description("Move config.json, workers.yaml, whisper-rules.md, advisor-mode.json, session-state/,\nsession-scan-cache.json, queries/, summary-cooldowns.json, work-queue.json,\nkg-backfill-state.json, voices.json, the orphaned legacy federation database,\nthe legacy registry database, the legacy live federation database, ~/.pai/backups/,\n~/.pai/obsidian-vault/, ~/.pai/scheduler-state.json, and ~/.claude/Agents/,\n~/.claude/Commands/ into PAI_HOME.\nThe registry and federation databases each get an extra WAL checkpoint and PRAGMA\nintegrity_check (sqlite3 CLI, if present) on top of the byte-identical copy.\nbackups/ is copied and sha256-verified file-by-file into\nbackups/legacy-pai-backups/ rather than merged in place. Agents/ and Commands/ each\nget a symlink left at the old ~/.claude path once their content has moved, so\nClaude Code still finds them at its fixed harness paths.\nEach file is copied, verified byte-identical, then the old file is renamed to\n<name>.migrated-<YYYYMMDD> (never deleted); directories move their contents, then\nthe emptied old directory is renamed the same way. Idempotent — entries already at\nthe new location, or with nothing old to migrate, are skipped.").option("--dry-run", "Print the plan without writing anything").option("--logs", "Also move ~/.claude/logs/workers into PAI_HOME: an atomic rename plus a\n symlink left at the old path, so any worker still writing there\n keeps landing in the new directory (falls back to copy+verify\n across volumes, refusing while a worker is RUNNING — see\n `pai worker ps` — only in that fallback case)").option("--history", "Also move ~/.claude/History/, agent-sessions.json, session-routing.json\n and history/security/security-events.jsonl into PAI_HOME. These are\n written by hooks on EVERY session's every turn, not just spawned\n workers — refuses while any worker other than the interactive\n session is RUNNING (see `pai worker ps`), but that guard cannot see\n OTHER interactive `claude` sessions on this machine. Confirm none\n are active (`ps aux | grep claude`, `aibroker sessions list`) before\n passing this flag.").action((opts) => {
6293
+ configCmd.command("migrate").description("Move config.json, workers.yaml, whisper-rules.md, advisor-mode.json, session-state/,\nsession-scan-cache.json, queries/, summary-cooldowns.json, work-queue.json,\nkg-backfill-state.json, voices.json, the orphaned legacy federation database,\nthe legacy registry database, the legacy live federation database, ~/.pai/backups/,\n~/.pai/obsidian-vault/, ~/.pai/scheduler-state.json, and ~/.claude/agents/,\n~/.claude/commands/ into PAI_HOME.\nThe registry and federation databases each get an extra WAL checkpoint and PRAGMA\nintegrity_check (sqlite3 CLI, if present) on top of the byte-identical copy.\nbackups/ is copied and sha256-verified file-by-file into\nbackups/legacy-pai-backups/ rather than merged in place. agents/ and commands/ each\nget a symlink left at the old ~/.claude path once their content has moved, so\nClaude Code still finds them at its fixed harness paths.\nEach file is copied, verified byte-identical, then the old file is renamed to\n<name>.migrated-<YYYYMMDD> (never deleted); directories move their contents, then\nthe emptied old directory is renamed the same way. Idempotent — entries already at\nthe new location, or with nothing old to migrate, are skipped.").option("--dry-run", "Print the plan without writing anything").option("--logs", "Also move ~/.claude/logs/workers into PAI_HOME: an atomic rename plus a\n symlink left at the old path, so any worker still writing there\n keeps landing in the new directory (falls back to copy+verify\n across volumes, refusing while a worker is RUNNING — see\n `pai worker ps` — only in that fallback case)").option("--history", "Also move ~/.claude/History/, agent-sessions.json, session-routing.json\n and history/security/security-events.jsonl into PAI_HOME. These are\n written by hooks on EVERY session's every turn, not just spawned\n workers — refuses while any worker other than the interactive\n session is RUNNING (see `pai worker ps`), but that guard cannot see\n OTHER interactive `claude` sessions on this machine. Confirm none\n are active (`ps aux | grep claude`, `aibroker sessions list`) before\n passing this flag.").action((opts) => {
6293
6294
  const dryRun = !!opts.dryRun;
6294
6295
  let hadError = false;
6295
6296
  const report = (label, fn) => {
@@ -6379,8 +6380,8 @@ function registerConfigCommands(configCmd) {
6379
6380
  console.error(err(` ${label}: `) + (e instanceof Error ? e.message : String(e)));
6380
6381
  }
6381
6382
  };
6382
- reportContentDir("Agents/", () => migrateAgentsDir({ dryRun }));
6383
- reportContentDir("Commands/", () => migrateCommandsDir({ dryRun }));
6383
+ reportContentDir("agents/", () => migrateAgentsDir({ dryRun }));
6384
+ reportContentDir("commands/", () => migrateCommandsDir({ dryRun }));
6384
6385
  if (opts.logs) try {
6385
6386
  const { workers } = readWorkersSection();
6386
6387
  const r = migrateWorkerLogs(expandHome$1(workers.logDir), paiHomePath("logs", "workers"), { dryRun });
@@ -6493,19 +6494,13 @@ function writeClaudeJson(data) {
6493
6494
 
6494
6495
  //#endregion
6495
6496
  //#region src/cli/commands/mcp.ts
6496
- /**
6497
- * Resolve the absolute path to a built MCP entry point.
6498
- *
6499
- * tsdown bundles all CLI commands into a single dist/cli/index.mjs file, so
6500
- * import.meta.url always resolves to dist/cli/index.mjs at runtime.
6501
- * From dist/cli/ we go up one level to dist/ and then into the entry.
6502
- */
6503
- function distDir() {
6504
- return join(dirname(fileURLToPath(import.meta.url)), "..");
6497
+ /** Absolute path of a built entry under dist/ (chunk depth varies, so walk up — see module-paths). */
6498
+ function distEntry(entry) {
6499
+ return resolveFromModule(import.meta.url, `dist/${entry}`);
6505
6500
  }
6506
6501
  const SERVERS = [{
6507
6502
  name: "pai",
6508
- entry: "mcp/index.mjs",
6503
+ entry: "daemon-mcp/index.mjs",
6509
6504
  label: "PAI MCP server",
6510
6505
  tools: "memory_search, memory_get, memory_outline, project_info, project_list, session_list, registry_search"
6511
6506
  }];
@@ -6515,7 +6510,7 @@ function cmdInstall$1() {
6515
6510
  const servers = config.mcpServers;
6516
6511
  let changed = false;
6517
6512
  for (const spec of SERVERS) {
6518
- const bin = join(distDir(), spec.entry);
6513
+ const bin = distEntry(spec.entry);
6519
6514
  if (spec.name in servers) {
6520
6515
  console.log(warn$1(`${spec.label} is already registered in ~/.claude.json as "${spec.name}".`));
6521
6516
  console.log(dim$1(` Entry: ${JSON.stringify(servers[spec.name])}`));
@@ -6556,7 +6551,7 @@ function cmdStatus$2() {
6556
6551
  console.log();
6557
6552
  let allReady = true;
6558
6553
  for (const spec of SERVERS) {
6559
- const bin = join(distDir(), spec.entry);
6554
+ const bin = distEntry(spec.entry);
6560
6555
  const registered = spec.name in servers;
6561
6556
  const binExists = existsSync(bin);
6562
6557
  if (registered) {
@@ -6587,37 +6582,21 @@ function registerMcpCommands(mcpCmd) {
6587
6582
  }
6588
6583
 
6589
6584
  //#endregion
6590
- //#region src/module-paths.ts
6585
+ //#region src/service-manager.ts
6591
6586
  /**
6592
- * module-paths.ts — locate a file relative to the package root from a running module.
6587
+ * service-manager.ts — the one guard in front of every launchctl / systemctl call.
6593
6588
  *
6594
- * tsdown bundles shared code into chunks emitted directly under dist/ (e.g.
6595
- * dist/program-*.mjs) rather than always alongside the entry that needs them
6596
- * (dist/cli/index.mjs, dist/daemon/index.mjs, ...). A fixed "../daemon/index.mjs"
6597
- * relative to import.meta.url assumes one specific chunk depth and silently
6598
- * resolves to the wrong file — or a file under the source tree instead of
6599
- * dist — whenever the bundler's chunking changes. Walking up from the running
6600
- * module's own directory until `dir/rel` exists is depth-independent, and works
6601
- * whether `rel` lives under dist/ (built entries) or is a sibling of dist/ at
6602
- * the package root (files excluded from the bundle, like docker/migrate-sqlite.ts).
6589
+ * Unit and plist files land under $HOME, but launchctl and systemctl --user act
6590
+ * on the real account's session whatever HOME says. Run under a foreign HOME
6591
+ * (a temp dir, a test, a sandbox) they rewire the live service to that HOME's
6592
+ * files. So when HOME is not the account home the files are still written and
6593
+ * the service manager is left alone.
6603
6594
  */
6604
- /**
6605
- * Resolve `rel` by walking up from the directory containing `moduleUrl`,
6606
- * returning the first `dir/rel` that exists on disk.
6607
- *
6608
- * Throws rather than returning a guessed path, so a caller writing a service
6609
- * file or spawning a process fails loudly instead of pointing at nothing.
6610
- */
6611
- function resolveFromModule(moduleUrl, rel, maxLevels = 8) {
6612
- let dir = dirname(fileURLToPath(moduleUrl));
6613
- for (let i = 0; i < maxLevels; i++) {
6614
- const candidate = join(dir, rel);
6615
- if (existsSync(candidate)) return candidate;
6616
- const parent = dirname(dir);
6617
- if (parent === dir) break;
6618
- dir = parent;
6619
- }
6620
- throw new Error(`cannot locate "${rel}" above ${dirname(fileURLToPath(moduleUrl))} — is the project built? (bun run build)`);
6595
+ /** True when it is safe to call launchctl/systemctl; otherwise prints why not and how to finish by hand. */
6596
+ function serviceManagerAllowed(manualCommand) {
6597
+ if (homedir() === userInfo().homedir) return true;
6598
+ console.log(` service not (re)loaded because HOME is not the account home; as the real user run: ${manualCommand}`);
6599
+ return false;
6621
6600
  }
6622
6601
 
6623
6602
  //#endregion
@@ -6689,6 +6668,10 @@ const DAEMON_LOG = daemonLogPath();
6689
6668
  const SYSTEMD_UNIT_NAME = "pai-daemon.service";
6690
6669
  const SYSTEMD_USER_DIR = join(HOME$1, ".config", "systemd", "user");
6691
6670
  const SYSTEMD_UNIT_PATH = join(SYSTEMD_USER_DIR, SYSTEMD_UNIT_NAME);
6671
+ /** Service name `daemon install` registers on this platform: systemd unit on Linux, launchd label elsewhere. */
6672
+ function daemonServiceName(plat = process.platform) {
6673
+ return plat === "linux" ? SYSTEMD_UNIT_NAME : PLIST_LABEL;
6674
+ }
6692
6675
  /**
6693
6676
  * Resolve the absolute path to the built daemon entry point.
6694
6677
  * tsdown may emit this module's own chunk directly under dist/ rather than
@@ -6807,6 +6790,7 @@ async function cmdStatus$1() {
6807
6790
  }
6808
6791
  }
6809
6792
  function cmdRestart() {
6793
+ if (!serviceManagerAllowed("pai daemon restart")) return;
6810
6794
  if (process.platform === "linux") {
6811
6795
  const result = spawnSync("systemctl", [
6812
6796
  "--user",
@@ -6862,6 +6846,7 @@ function installServiceDarwin(daemonBin) {
6862
6846
  process.exitCode = 1;
6863
6847
  return false;
6864
6848
  }
6849
+ if (!serviceManagerAllowed(`launchctl load ${PLIST_PATH$1}`)) return true;
6865
6850
  try {
6866
6851
  spawnSync("launchctl", ["unload", PLIST_PATH$1], { encoding: "utf8" });
6867
6852
  const loadResult = spawnSync("launchctl", ["load", PLIST_PATH$1], { encoding: "utf8" });
@@ -6884,6 +6869,7 @@ function installServiceLinux(daemonBin) {
6884
6869
  process.exitCode = 1;
6885
6870
  return false;
6886
6871
  }
6872
+ if (!serviceManagerAllowed(`systemctl --user daemon-reload && systemctl --user enable --now ${SYSTEMD_UNIT_NAME}`)) return true;
6887
6873
  spawnSync("systemctl", ["--user", "daemon-reload"], { encoding: "utf8" });
6888
6874
  const enableResult = spawnSync("systemctl", [
6889
6875
  "--user",
@@ -6949,7 +6935,7 @@ function cmdInstall() {
6949
6935
  }
6950
6936
  function uninstallServiceDarwin() {
6951
6937
  if (existsSync(PLIST_PATH$1)) {
6952
- try {
6938
+ if (serviceManagerAllowed(`launchctl unload ${PLIST_PATH$1}`)) try {
6953
6939
  spawnSync("launchctl", ["unload", PLIST_PATH$1], { encoding: "utf8" });
6954
6940
  console.log(ok$1(" Unloaded launchd plist."));
6955
6941
  } catch {
@@ -6965,20 +6951,23 @@ function uninstallServiceDarwin() {
6965
6951
  }
6966
6952
  function uninstallServiceLinux() {
6967
6953
  if (existsSync(SYSTEMD_UNIT_PATH)) {
6968
- spawnSync("systemctl", [
6969
- "--user",
6970
- "disable",
6971
- "--now",
6972
- SYSTEMD_UNIT_NAME
6973
- ], { encoding: "utf8" });
6974
- console.log(ok$1(" Disabled and stopped via systemd."));
6954
+ const managed = serviceManagerAllowed(`systemctl --user disable --now ${SYSTEMD_UNIT_NAME}`);
6955
+ if (managed) {
6956
+ spawnSync("systemctl", [
6957
+ "--user",
6958
+ "disable",
6959
+ "--now",
6960
+ SYSTEMD_UNIT_NAME
6961
+ ], { encoding: "utf8" });
6962
+ console.log(ok$1(" Disabled and stopped via systemd."));
6963
+ }
6975
6964
  try {
6976
6965
  unlinkSync(SYSTEMD_UNIT_PATH);
6977
6966
  console.log(ok$1(` Removed unit: ${SYSTEMD_UNIT_PATH}`));
6978
6967
  } catch (e) {
6979
6968
  console.log(warn$1(` Could not remove unit: ${e}`));
6980
6969
  }
6981
- spawnSync("systemctl", ["--user", "daemon-reload"], { encoding: "utf8" });
6970
+ if (managed) spawnSync("systemctl", ["--user", "daemon-reload"], { encoding: "utf8" });
6982
6971
  } else console.log(dim$1(" No systemd unit found."));
6983
6972
  }
6984
6973
  function cmdUninstall() {
@@ -7086,8 +7075,8 @@ function cmdLogs(opts) {
7086
7075
  }
7087
7076
  function registerDaemonCommands(daemonCmd) {
7088
7077
  daemonCmd.command("serve").description("Start the PAI daemon in the foreground").action(async () => {
7089
- const { serve } = await import("./daemon-q3xjHwa4.mjs");
7090
- const { loadConfig: lc, ensureConfigDir } = await import("./config-CUTg6VDq.mjs");
7078
+ const { serve } = await import("./daemon-CX9JomIJ.mjs");
7079
+ const { loadConfig: lc, ensureConfigDir } = await import("./config-YinjgXEJ.mjs");
7091
7080
  ensureConfigDir();
7092
7081
  await serve(lc());
7093
7082
  });
@@ -7433,7 +7422,19 @@ function createRl() {
7433
7422
  });
7434
7423
  return rl;
7435
7424
  }
7436
- async function prompt$1(rl, question) {
7425
+ /** Unattended-mode switches (`pai setup --yes --storage …`), set once by the command. */
7426
+ const setupOptions = { yes: false };
7427
+ /**
7428
+ * The one place every wizard question passes through. Under --yes it answers
7429
+ * `defaultValue` without touching stdin; a question with no default cannot be
7430
+ * answered unattended, so it fails naming the flag instead of returning "".
7431
+ */
7432
+ async function prompt$1(rl, question, defaultValue) {
7433
+ if (setupOptions.yes) {
7434
+ if (defaultValue === void 0) throw new Error(`"${question.trim()}" has no default; cannot answer it with --yes. Run without --yes, or skip the feature that asks it.`);
7435
+ console.log(chalk.dim(` ${question.trim()} -> ${defaultValue || "(default)"}`));
7436
+ return defaultValue;
7437
+ }
7437
7438
  return new Promise((resolve) => {
7438
7439
  rl.question(question, (answer) => {
7439
7440
  resolve(answer.trim());
@@ -7451,7 +7452,7 @@ async function promptMenu(rl, options, defaultIdx = 0) {
7451
7452
  }
7452
7453
  line$1();
7453
7454
  while (true) {
7454
- const answer = await prompt$1(rl, chalk.bold(` Enter number [1-${options.length}] (default: ${defaultIdx + 1}): `));
7455
+ const answer = await prompt$1(rl, chalk.bold(` Enter number [1-${options.length}] (default: ${defaultIdx + 1}): `), "");
7455
7456
  if (answer === "") return defaultIdx;
7456
7457
  const n = parseInt(answer, 10);
7457
7458
  if (!isNaN(n) && n >= 1 && n <= options.length) return n - 1;
@@ -7461,7 +7462,7 @@ async function promptMenu(rl, options, defaultIdx = 0) {
7461
7462
  /** Prompt for a yes/no answer. Returns true for yes. */
7462
7463
  async function promptYesNo(rl, question, defaultYes = true) {
7463
7464
  const hint = defaultYes ? "[Y/n]" : "[y/N]";
7464
- const answer = await prompt$1(rl, ` ${question} ${chalk.dim(hint)}: `);
7465
+ const answer = await prompt$1(rl, ` ${question} ${chalk.dim(hint)}: `, "");
7465
7466
  if (answer === "") return defaultYes;
7466
7467
  return answer.toLowerCase().startsWith("y");
7467
7468
  }
@@ -7498,13 +7499,7 @@ function hasDocker() {
7498
7499
  }
7499
7500
  }
7500
7501
  function getDockerDir() {
7501
- const candidates = [
7502
- join(process.cwd(), "docker"),
7503
- join(homedir(), "dev", "ai", "PAI", "docker"),
7504
- join("/", "usr", "local", "lib", "node_modules", "@tekmidian", "pai", "docker")
7505
- ];
7506
- for (const candidate of candidates) if (existsSync(join(candidate, "docker-compose.yml"))) return candidate;
7507
- return join(process.cwd(), "docker");
7502
+ return join(packageRoot(import.meta.url), "docker");
7508
7503
  }
7509
7504
  async function testPostgresConnection(connectionString) {
7510
7505
  try {
@@ -7518,64 +7513,24 @@ async function testPostgresConnection(connectionString) {
7518
7513
  }
7519
7514
  }
7520
7515
  function getTemplatesDir$1() {
7521
- const candidates = [
7522
- join(process.cwd(), "templates"),
7523
- join(homedir(), "dev", "ai", "PAI", "templates"),
7524
- join("/", "usr", "local", "lib", "node_modules", "@tekmidian", "pai", "templates")
7525
- ];
7526
- for (const candidate of candidates) if (existsSync(join(candidate, "claude-md.template.md"))) return candidate;
7527
- return join(process.cwd(), "templates");
7516
+ return join(packageRoot(import.meta.url), "templates");
7528
7517
  }
7529
7518
  function getHooksDir() {
7530
- const candidates = [
7531
- join(process.cwd(), "src", "hooks"),
7532
- join(homedir(), "dev", "ai", "PAI", "src", "hooks"),
7533
- join("/", "usr", "local", "lib", "node_modules", "@tekmidian", "pai", "src", "hooks")
7534
- ];
7535
- for (const candidate of candidates) if (existsSync(join(candidate, "session-stop.sh"))) return candidate;
7536
- return join(process.cwd(), "src", "hooks");
7519
+ return join(packageRoot(import.meta.url), "src", "hooks");
7537
7520
  }
7538
7521
  function getDistHooksDir() {
7539
- const moduleDir = new URL(".", import.meta.url).pathname;
7540
- const fromModule = join(moduleDir, "..", "..", "hooks");
7541
- const candidates = [
7542
- fromModule,
7543
- join(process.cwd(), "dist", "hooks"),
7544
- join(homedir(), "dev", "ai", "PAI", "dist", "hooks"),
7545
- join("/", "usr", "local", "lib", "node_modules", "@tekmidian", "pai", "dist", "hooks")
7546
- ];
7547
- for (const candidate of candidates) if (existsSync(join(candidate, "stop-hook.mjs"))) return candidate;
7548
- return fromModule;
7522
+ return join(getDistDir(), "hooks");
7549
7523
  }
7550
7524
  function getDistDir() {
7551
- const moduleDir = new URL(".", import.meta.url).pathname;
7552
- const fromModule = join(moduleDir, "..", "..", "..");
7553
- const candidates = [
7554
- fromModule,
7555
- join(process.cwd(), "dist"),
7556
- join(homedir(), "dev", "ai", "PAI", "dist"),
7557
- join("/", "usr", "local", "lib", "node_modules", "@tekmidian", "pai", "dist")
7558
- ];
7559
- for (const candidate of candidates) if (existsSync(join(candidate, "skills"))) return candidate;
7560
- return fromModule;
7525
+ return join(packageRoot(import.meta.url), "dist");
7561
7526
  }
7562
7527
  function getStatuslineScript() {
7563
- const candidates = [
7564
- join(process.cwd(), "statusline-command.sh"),
7565
- join(homedir(), "dev", "ai", "PAI", "statusline-command.sh"),
7566
- join("/", "usr", "local", "lib", "node_modules", "@tekmidian", "pai", "statusline-command.sh")
7567
- ];
7568
- for (const candidate of candidates) if (existsSync(candidate)) return candidate;
7569
- return null;
7528
+ const p = join(packageRoot(import.meta.url), "statusline-command.sh");
7529
+ return existsSync(p) ? p : null;
7570
7530
  }
7571
7531
  function getTabColorScript() {
7572
- const candidates = [
7573
- join(process.cwd(), "tab-color-command.sh"),
7574
- join(homedir(), "dev", "ai", "PAI", "tab-color-command.sh"),
7575
- join("/", "usr", "local", "lib", "node_modules", "@tekmidian", "pai", "tab-color-command.sh")
7576
- ];
7577
- for (const candidate of candidates) if (existsSync(candidate)) return candidate;
7578
- return null;
7532
+ const p = join(packageRoot(import.meta.url), "tab-color-command.sh");
7533
+ return existsSync(p) ? p : null;
7579
7534
  }
7580
7535
 
7581
7536
  //#endregion
@@ -7661,13 +7616,14 @@ async function stepStorage(rl) {
7661
7616
  line$1();
7662
7617
  line$1(" Choose how PAI stores your indexed knowledge:");
7663
7618
  line$1();
7664
- if (await promptMenu(rl, [{
7619
+ const forced = setupOptions.storage ?? (setupOptions.yes ? await testPostgresConnection("postgresql://pai:pai@localhost:5432/pai") ? "postgres" : "sqlite" : void 0);
7620
+ if ((forced ? forced === "sqlite" ? 1 : 0 : await promptMenu(rl, [{
7665
7621
  label: "PostgreSQL with pgvector",
7666
7622
  description: "Best for large collections, semantic search, and production use. Requires Docker or a Postgres server."
7667
7623
  }, {
7668
7624
  label: "SQLite",
7669
7625
  description: "Simple, no dependencies, zero configuration. Good for trying PAI out. Keyword search only."
7670
- }]) === 1) {
7626
+ }])) === 1) {
7671
7627
  line$1();
7672
7628
  console.log(c.ok("SQLite selected. No additional setup needed."));
7673
7629
  return { storageBackend: "sqlite" };
@@ -7701,7 +7657,7 @@ async function stepStorage(rl) {
7701
7657
  line$1(" Enter your PostgreSQL connection details:");
7702
7658
  line$1();
7703
7659
  if (await promptYesNo(rl, "Use a full connection string? (e.g. postgresql://user:pass@host:5432/dbname)", true)) {
7704
- const connStr = await prompt$1(rl, chalk.bold(" Connection string: "));
7660
+ const connStr = await prompt$1(rl, chalk.bold(" Connection string: "), "");
7705
7661
  if (connStr) {
7706
7662
  console.log(c.dim(" Testing connection..."));
7707
7663
  if (await testPostgresConnection(connStr)) console.log(c.ok("Connection successful!"));
@@ -7712,10 +7668,10 @@ async function stepStorage(rl) {
7712
7668
  };
7713
7669
  }
7714
7670
  }
7715
- const host = await prompt$1(rl, chalk.bold(" Host [localhost]: ")) || "localhost";
7716
- const portStr = await prompt$1(rl, chalk.bold(" Port [5432]: ")) || "5432";
7717
- const database = await prompt$1(rl, chalk.bold(" Database [pai]: ")) || "pai";
7718
- const connStr = `postgresql://${await prompt$1(rl, chalk.bold(" User [pai]: ")) || "pai"}:${await prompt$1(rl, chalk.bold(" Password [pai]: ")) || "pai"}@${host}:${portStr}/${database}`;
7671
+ const host = await prompt$1(rl, chalk.bold(" Host [localhost]: "), "") || "localhost";
7672
+ const portStr = await prompt$1(rl, chalk.bold(" Port [5432]: "), "") || "5432";
7673
+ const database = await prompt$1(rl, chalk.bold(" Database [pai]: "), "") || "pai";
7674
+ const connStr = `postgresql://${await prompt$1(rl, chalk.bold(" User [pai]: "), "") || "pai"}:${await prompt$1(rl, chalk.bold(" Password [pai]: "), "") || "pai"}@${host}:${portStr}/${database}`;
7719
7675
  console.log(c.dim(` Connection string: ${connStr}`));
7720
7676
  console.log(c.dim(" Testing connection..."));
7721
7677
  if (await testPostgresConnection(connStr)) console.log(c.ok("Connection successful!"));
@@ -8072,7 +8028,8 @@ async function stepHooks(rl) {
8072
8028
  installLink(join(hooksDir, "session-autosave.sh"), join(hooksTarget, "pai-session-autosave.sh"), "pai-session-autosave.sh");
8073
8029
  if (statuslineSrc) installLink(statuslineSrc, join(claudeDir, "statusline-command.sh"), "statusline-command.sh");
8074
8030
  else console.log(c.warn(" statusline-command.sh not found — skipping statusline."));
8075
- if (tabColorSrc) installLink(tabColorSrc, join(claudeDir, "tab-color-command.sh"), "tab-color-command.sh");
8031
+ if (platform() !== "darwin") console.log(c.dim(" Skipping tab-color-command.sh (iTerm2 only)."));
8032
+ else if (tabColorSrc) installLink(tabColorSrc, join(claudeDir, "tab-color-command.sh"), "tab-color-command.sh");
8076
8033
  else console.log(c.warn(" tab-color-command.sh not found — skipping tab color."));
8077
8034
  return anyInstalled;
8078
8035
  }
@@ -8356,7 +8313,7 @@ async function stepDaName(rl) {
8356
8313
  line$1(" Choose a name for your AI assistant. This name appears in tab titles");
8357
8314
  line$1(" and session notes when hooks are active.");
8358
8315
  line$1();
8359
- const daName = await prompt$1(rl, chalk.bold(" Assistant name [PAI]: ")) || "PAI";
8316
+ const daName = await prompt$1(rl, chalk.bold(" Assistant name [PAI]: "), "") || "PAI";
8360
8317
  line$1();
8361
8318
  console.log(c.ok(`Assistant name set to: ${daName}`));
8362
8319
  return daName;
@@ -8536,16 +8493,23 @@ async function stepSettings(rl, daName) {
8536
8493
 
8537
8494
  //#endregion
8538
8495
  //#region src/cli/commands/setup/steps/11-daemon.ts
8539
- /** Step 9: PAI daemon installation via launchd plist. */
8496
+ /** Step 9: PAI daemon installation (launchd plist on macOS, systemd user unit on Linux). */
8540
8497
  async function stepDaemon(rl) {
8541
8498
  section("Step 9: Daemon Install");
8542
8499
  line$1();
8543
8500
  line$1(" The PAI daemon indexes your projects every 5 minutes in the background.");
8544
8501
  line$1();
8545
- if (existsSync(join(homedir(), "Library", "LaunchAgents", "com.pai.pai-daemon.plist"))) {
8546
- console.log(c.dim(" PAI daemon plist already installed."));
8502
+ const linux = platform() === "linux";
8503
+ if (linux && !existsSync("/run/systemd/system")) {
8504
+ console.log(c.dim(" systemd is not running here (container?). Skipping service install; start the daemon with: pai daemon serve"));
8505
+ return false;
8506
+ }
8507
+ const plistPath = linux ? join(homedir(), ".config", "systemd", "user", "pai-daemon.service") : join(homedir(), "Library", "LaunchAgents", "com.pai.pai-daemon.plist");
8508
+ const unit = linux ? "systemd user unit" : "launchd plist";
8509
+ if (existsSync(plistPath)) {
8510
+ console.log(c.dim(` PAI daemon ${unit} already installed.`));
8547
8511
  line$1();
8548
- if (!await promptYesNo(rl, "Reinstall the PAI daemon launchd plist?", false)) {
8512
+ if (!await promptYesNo(rl, `Reinstall the PAI daemon ${unit}?`, false)) {
8549
8513
  console.log(c.dim(" Keeping existing daemon installation."));
8550
8514
  return false;
8551
8515
  }
@@ -8558,7 +8522,7 @@ async function stepDaemon(rl) {
8558
8522
  console.log(c.warn(" Daemon install failed. Run manually: pai daemon install"));
8559
8523
  return false;
8560
8524
  }
8561
- console.log(c.ok("Daemon installed as com.pai.pai-daemon."));
8525
+ console.log(c.ok(`Daemon installed as ${daemonServiceName()}.`));
8562
8526
  return true;
8563
8527
  }
8564
8528
 
@@ -8674,7 +8638,7 @@ async function stepInitialIndex(rl) {
8674
8638
  //#endregion
8675
8639
  //#region src/cli/commands/setup/steps/15-verify.ts
8676
8640
  /** Step 13: Setup summary — displays all configuration choices made during setup. */
8677
- function stepSummary(configUpdates, claudeMdGenerated, paiSkillInstalled, aiSteeringRulesInstalled, skillStubsInstalled, hooksInstalled, tsHooksInstalled, settingsPatched, daName, daemonInstalled, mcpRegistered) {
8641
+ function stepSummary(configUpdates, claudeMdGenerated, paiSkillInstalled, aiSteeringRulesInstalled, skillStubsInstalled, hooksInstalled, tsHooksInstalled, settingsPatched, daName, daemonInstalled, mcpRegistered, plat = process.platform) {
8678
8642
  section("Setup Complete");
8679
8643
  line$1();
8680
8644
  console.log(chalk.green(" PAI Knowledge OS is configured!"));
@@ -8693,7 +8657,7 @@ function stepSummary(configUpdates, claudeMdGenerated, paiSkillInstalled, aiStee
8693
8657
  console.log(chalk.dim(" Hooks (TS): ") + chalk.cyan(tsHooksInstalled ? "14 .mjs hooks installed to ~/.claude/Hooks/" : "(unchanged)"));
8694
8658
  console.log(chalk.dim(" Assistant name: ") + chalk.cyan(daName));
8695
8659
  console.log(chalk.dim(" Settings: ") + chalk.cyan(settingsPatched ? "env vars, hooks, permissions, flags (patched)" : "(unchanged)"));
8696
- console.log(chalk.dim(" Daemon: ") + chalk.cyan(daemonInstalled ? "com.pai.pai-daemon (installed)" : "(unchanged)"));
8660
+ console.log(chalk.dim(" Daemon: ") + chalk.cyan(daemonInstalled ? `${daemonServiceName(plat)} (installed)` : "(not installed by setup)"));
8697
8661
  console.log(chalk.dim(" MCP: ") + chalk.cyan(mcpRegistered ? "registered in ~/.claude.json" : "(unchanged)"));
8698
8662
  line$1();
8699
8663
  console.log(chalk.bold.yellow(" → RESTART Claude Code to activate all changes."));
@@ -9565,7 +9529,9 @@ function installShims(lines) {
9565
9529
  lines.push(`${name}: shim already current`);
9566
9530
  continue;
9567
9531
  }
9568
- writeFileSync(path, shim(name, pai), {
9532
+ const body = shim(name, pai);
9533
+ mkdirSync(LOCAL_BIN, { recursive: true });
9534
+ writeFileSync(path, body, {
9569
9535
  encoding: "utf8",
9570
9536
  mode: 493
9571
9537
  });
@@ -9610,46 +9576,42 @@ async function stepWorkers(rl) {
9610
9576
  return { workers: current };
9611
9577
  }
9612
9578
  line$1();
9613
- line$1(" PAI can run every subagent (worker) on a provider you configure —");
9614
- line$1(" a non-Anthropic endpoint via its Anthropic-compatible API.");
9579
+ line$1(" PAI can run every subagent (worker) on a provider: the built-in");
9580
+ line$1(" `anthropic` one (your logged-in claude CLI, Max plan, no API key) or any");
9581
+ line$1(" Anthropic-compatible endpoint you add later.");
9615
9582
  line$1();
9616
9583
  line$1(" `pai worker run` is the runner; ps / follow / replay watch the runs;");
9617
- line$1(" the Agent tool is denied and rewritten to it once providers exist.");
9584
+ line$1(" the Agent tool is denied and rewritten to it while workers are on.");
9618
9585
  line$1();
9619
- line$1(" PAI works fully without this — Agent subagents then just run as before.");
9620
- line$1();
9621
- if (!await promptYesNo(rl, "Configure a worker provider now?", false)) {
9586
+ if (!await promptYesNo(rl, "Turn workers on now with the built-in anthropic provider?", true)) {
9622
9587
  line$1();
9623
- console.log(c.ok("Skipping worker providers."));
9624
- console.log(c.dim(" Add later: pai worker providers add <name> … — see docs/worker.md"));
9588
+ console.log(c.ok("Skipping workers."));
9589
+ console.log(c.dim(" Later: pai worker on (other providers: pai worker providers add <name> … — see docs/worker.md)"));
9625
9590
  return { workers: {
9626
9591
  enabled: false,
9627
9592
  providers: {},
9628
9593
  classes: {}
9629
9594
  } };
9630
9595
  }
9631
- line$1();
9632
- line$1(" Add the provider after setup finishes (this step only prepares the");
9633
- line$1(" wiring — shims, hook registration, log dir):");
9634
- line$1();
9635
- line$1(c.dim(" pai worker providers add glm \\"));
9636
- line$1(c.dim(" --base-url https://api.example.com/api/anthropic \\"));
9637
- line$1(c.dim(" --key-file ~/.config/example/api_key \\"));
9638
- line$1(c.dim(" --model example-4.7 --fast-model example-4.7-flash"));
9639
- line$1();
9640
- line$1(" The first provider turns workers on and seeds the classes.");
9641
- line$1();
9596
+ setWorkersEnabled(true);
9642
9597
  const r = installWorkers();
9643
9598
  for (const l of r.lines) line$1(` ${l}`);
9644
- return { workers: {
9645
- enabled: false,
9646
- providers: {},
9647
- classes: {}
9648
- } };
9599
+ const { workers } = readWorkersSection();
9600
+ console.log(c.ok("Workers on — provider: anthropic (built-in, no API key written)."));
9601
+ for (const l of describeProviders(workers)) line$1(c.dim(` ${l}`));
9602
+ return {};
9649
9603
  }
9650
9604
 
9651
9605
  //#endregion
9652
9606
  //#region src/cli/commands/setup/index.ts
9607
+ /** Runs one wizard step; a throw is re-raised naming the step so unattended runs say where they died. */
9608
+ async function step$1(name, fn) {
9609
+ try {
9610
+ return await fn();
9611
+ } catch (e) {
9612
+ throw new Error(`setup step "${name}" failed: ${e instanceof Error ? e.message : String(e)}`);
9613
+ }
9614
+ }
9653
9615
  async function runSetup() {
9654
9616
  const rl = createRl();
9655
9617
  try {
@@ -9669,22 +9631,22 @@ async function runSetup() {
9669
9631
  }
9670
9632
  stepWelcome();
9671
9633
  line$1();
9672
- await prompt$1(rl, chalk.dim(" Press Enter to begin setup..."));
9673
- const storageConfig = await stepStorage(rl);
9674
- const embeddingConfig = await stepEmbedding(rl);
9675
- const claudeMdGenerated = await stepClaudeMd(rl);
9676
- const paiSkillInstalled = await stepPaiSkill(rl);
9677
- const aiSteeringRulesInstalled = await stepAiSteeringRules(rl);
9678
- const skillStubsInstalled = await stepSkillStubs(rl);
9679
- const hooksInstalled = await stepHooks(rl);
9680
- const tsHooksInstalled = await stepTsHooks(rl);
9681
- const daName = await stepDaName(rl);
9682
- const settingsPatched = await stepSettings(rl, daName);
9683
- const daemonInstalled = await stepDaemon(rl);
9684
- const mcpRegistered = await stepMcp(rl);
9685
- await stepDirectories(rl);
9686
- const taskConfig = await stepTaskBus(rl);
9687
- const workersConfig = await stepWorkers(rl);
9634
+ await prompt$1(rl, chalk.dim(" Press Enter to begin setup..."), "");
9635
+ const storageConfig = await step$1("stepStorage", () => stepStorage(rl));
9636
+ const embeddingConfig = await step$1("stepEmbedding", () => stepEmbedding(rl));
9637
+ const claudeMdGenerated = await step$1("stepClaudeMd", () => stepClaudeMd(rl));
9638
+ const paiSkillInstalled = await step$1("stepPaiSkill", () => stepPaiSkill(rl));
9639
+ const aiSteeringRulesInstalled = await step$1("stepAiSteeringRules", () => stepAiSteeringRules(rl));
9640
+ const skillStubsInstalled = await step$1("stepSkillStubs", () => stepSkillStubs(rl));
9641
+ const hooksInstalled = await step$1("stepHooks", () => stepHooks(rl));
9642
+ const tsHooksInstalled = await step$1("stepTsHooks", () => stepTsHooks(rl));
9643
+ const daName = await step$1("stepDaName", () => stepDaName(rl));
9644
+ const settingsPatched = await step$1("stepSettings", () => stepSettings(rl, daName));
9645
+ const daemonInstalled = await step$1("stepDaemon", () => stepDaemon(rl));
9646
+ const mcpRegistered = await step$1("stepMcp", () => stepMcp(rl));
9647
+ await step$1("stepDirectories", () => stepDirectories(rl));
9648
+ const taskConfig = await step$1("stepTaskBus", () => stepTaskBus(rl));
9649
+ const workersConfig = await step$1("stepWorkers", () => stepWorkers(rl));
9688
9650
  const allUpdates = {
9689
9651
  ...storageConfig,
9690
9652
  ...embeddingConfig,
@@ -9694,15 +9656,27 @@ async function runSetup() {
9694
9656
  mergeConfig(allUpdates);
9695
9657
  line$1();
9696
9658
  console.log(chalk.green(" Configuration saved."));
9697
- await stepInitialIndex(rl);
9659
+ await step$1("stepInitialIndex", () => stepInitialIndex(rl));
9698
9660
  stepSummary(allUpdates, claudeMdGenerated, paiSkillInstalled, aiSteeringRulesInstalled, skillStubsInstalled, hooksInstalled, tsHooksInstalled, settingsPatched, daName, daemonInstalled, mcpRegistered);
9699
9661
  } finally {
9700
9662
  rl.close();
9701
9663
  }
9702
9664
  }
9703
9665
  function registerSetupCommand(program) {
9704
- program.command("setup").alias("install").description("Interactive setup wizard — configure storage, embeddings, agent config, and indexing").action(async () => {
9705
- await runSetup();
9666
+ program.command("setup").alias("install").description("Setup wizard — configure storage, embeddings, agent config, and indexing (--yes for unattended)").option("-y, --yes", "Unattended: take every default, read no input").option("--storage <backend>", "Storage backend: sqlite | postgres (default under --yes: sqlite unless local Postgres answers)").action(async (opts) => {
9667
+ if (opts.storage && opts.storage !== "sqlite" && opts.storage !== "postgres") {
9668
+ console.error(`pai setup: --storage must be sqlite or postgres, got "${opts.storage}"`);
9669
+ process.exitCode = 1;
9670
+ return;
9671
+ }
9672
+ setupOptions.yes = opts.yes === true;
9673
+ setupOptions.storage = opts.storage;
9674
+ try {
9675
+ await runSetup();
9676
+ } catch (e) {
9677
+ console.error(chalk.red(`pai setup: ${e instanceof Error ? e.message : String(e)}`));
9678
+ process.exitCode = 1;
9679
+ }
9706
9680
  });
9707
9681
  }
9708
9682
 
@@ -9728,7 +9702,7 @@ async function cmdExplore(note, opts) {
9728
9702
  const depth = parseInt(opts.depth ?? "3", 10);
9729
9703
  const direction = opts.direction ?? "both";
9730
9704
  const mode = opts.mode ?? "all";
9731
- const { zettelExplore } = await import("./zettelkasten-Dx-63BEk.mjs");
9705
+ const { zettelExplore } = await import("./zettelkasten-Dwj67e4p.mjs");
9732
9706
  const result = await zettelExplore(await getFedBackend(), {
9733
9707
  startNote: note,
9734
9708
  depth,
@@ -9793,7 +9767,7 @@ async function cmdHealth(opts) {
9793
9767
  const projectPath = opts.project;
9794
9768
  const recentDays = parseInt(opts.days ?? "30", 10);
9795
9769
  const includeTypes = opts.include ? opts.include.split(",").map((s) => s.trim()) : void 0;
9796
- const { zettelHealth } = await import("./zettelkasten-Dx-63BEk.mjs");
9770
+ const { zettelHealth } = await import("./zettelkasten-Dwj67e4p.mjs");
9797
9771
  const result = await zettelHealth(await getFedBackend(), {
9798
9772
  scope,
9799
9773
  projectPath,
@@ -9864,7 +9838,7 @@ async function cmdSurprise(note, opts) {
9864
9838
  const limit = parseInt(opts.limit ?? "10", 10);
9865
9839
  const minSimilarity = parseFloat(opts.minSimilarity ?? "0.3");
9866
9840
  const minGraphDistance = parseInt(opts.minDistance ?? "3", 10);
9867
- const { zettelSurprise } = await import("./zettelkasten-Dx-63BEk.mjs");
9841
+ const { zettelSurprise } = await import("./zettelkasten-Dwj67e4p.mjs");
9868
9842
  const backend = await getFedBackend();
9869
9843
  console.log();
9870
9844
  console.log(header(" PAI Zettel Surprise"));
@@ -9919,7 +9893,7 @@ async function cmdSuggest(note, opts) {
9919
9893
  const vaultProjectId = parseInt(opts.vaultProjectId, 10);
9920
9894
  const limit = parseInt(opts.limit ?? "5", 10);
9921
9895
  const excludeLinked = opts.excludeLinked !== false;
9922
- const { zettelSuggest } = await import("./zettelkasten-Dx-63BEk.mjs");
9896
+ const { zettelSuggest } = await import("./zettelkasten-Dwj67e4p.mjs");
9923
9897
  const backend = await getFedBackend();
9924
9898
  console.log();
9925
9899
  console.log(header(" PAI Zettel Suggest"));
@@ -9972,7 +9946,7 @@ async function cmdConverse(question, opts) {
9972
9946
  const vaultProjectId = parseInt(opts.vaultProjectId, 10);
9973
9947
  const depth = parseInt(opts.depth ?? "2", 10);
9974
9948
  const limit = parseInt(opts.limit ?? "15", 10);
9975
- const { zettelConverse } = await import("./zettelkasten-Dx-63BEk.mjs");
9949
+ const { zettelConverse } = await import("./zettelkasten-Dwj67e4p.mjs");
9976
9950
  const backend = await getFedBackend();
9977
9951
  console.log();
9978
9952
  console.log(header(" PAI Zettel Converse"));
@@ -10035,7 +10009,7 @@ async function cmdThemes(opts) {
10035
10009
  const minClusterSize = parseInt(opts.minSize ?? "3", 10);
10036
10010
  const maxThemes = parseInt(opts.maxThemes ?? "10", 10);
10037
10011
  const similarityThreshold = parseFloat(opts.threshold ?? "0.65");
10038
- const { zettelThemes } = await import("./zettelkasten-Dx-63BEk.mjs");
10012
+ const { zettelThemes } = await import("./zettelkasten-Dwj67e4p.mjs");
10039
10013
  const backend = await getFedBackend();
10040
10014
  console.log();
10041
10015
  console.log(header(" PAI Zettel Themes"));
@@ -10414,7 +10388,7 @@ function defaultFileSet(cwd) {
10414
10388
  join(cwd, "CLAUDE.md"),
10415
10389
  join(cwd, ".claude", "CLAUDE.md"),
10416
10390
  ...parentClaudeMdFiles(dirname(cwd)),
10417
- join(homedir(), ".claude", "Skills", "CORE", "SKILL.md"),
10391
+ join(homedir(), ".claude", "skills", "CORE", "SKILL.md"),
10418
10392
  whisperRulesPath(),
10419
10393
  join(homedir(), ".claude", "projects", encodeDir(cwd), "memory", "MEMORY.md")
10420
10394
  ];
@@ -13861,7 +13835,7 @@ function capture(cmd, cwd) {
13861
13835
  * package root where package.json lives.
13862
13836
  */
13863
13837
  function getPaiSrcDir() {
13864
- return join(dirname(fileURLToPath(import.meta.url)), "../..");
13838
+ return packageRoot(import.meta.url);
13865
13839
  }
13866
13840
  /**
13867
13841
  * Locate the templates directory relative to the installed package.
@@ -14577,6 +14551,12 @@ function installSchedule(intervalSecs = DEFAULT_INTERVAL_SECS) {
14577
14551
  };
14578
14552
  if (!existsSync(LAUNCH_AGENTS)) mkdirSync(LAUNCH_AGENTS, { recursive: true });
14579
14553
  writeFileSync(SCHEDULE_PLIST, generateSchedulePlist(intervalSecs, cliPath()), "utf8");
14554
+ if (!serviceManagerAllowed(`launchctl load ${SCHEDULE_PLIST}`)) return {
14555
+ plistPath: SCHEDULE_PLIST,
14556
+ intervalSecs,
14557
+ loaded: false,
14558
+ message: "Plist written; not loaded (HOME is not the account home)."
14559
+ };
14580
14560
  spawnSync("launchctl", ["unload", SCHEDULE_PLIST], { encoding: "utf8" });
14581
14561
  const load = spawnSync("launchctl", ["load", SCHEDULE_PLIST], { encoding: "utf8" });
14582
14562
  return {
@@ -14588,7 +14568,7 @@ function installSchedule(intervalSecs = DEFAULT_INTERVAL_SECS) {
14588
14568
  }
14589
14569
  function uninstallSchedule() {
14590
14570
  if (!existsSync(SCHEDULE_PLIST)) return "Scheduler is not installed.";
14591
- spawnSync("launchctl", ["unload", SCHEDULE_PLIST], { encoding: "utf8" });
14571
+ if (serviceManagerAllowed(`launchctl unload ${SCHEDULE_PLIST}`)) spawnSync("launchctl", ["unload", SCHEDULE_PLIST], { encoding: "utf8" });
14592
14572
  unlinkSync(SCHEDULE_PLIST);
14593
14573
  return "Scheduler uninstalled.";
14594
14574
  }
@@ -16104,7 +16084,7 @@ async function migrateToPostgres(opts = {}) {
16104
16084
  const dump = pgDump(container, pgConfig, dumpPath);
16105
16085
  if (!dump.ok) return refused(dump.reason, dryRun);
16106
16086
  }
16107
- const { PostgresBackend } = await import("./postgres-CcsRKir-.mjs");
16087
+ const { PostgresBackend } = await import("./postgres-DYtZg7J7.mjs");
16108
16088
  await PostgresBackend.ensureDatabase(pgConfig);
16109
16089
  const sqlite = new BetterSqlite3(sqliteFederationPath, { readonly: true });
16110
16090
  const registrySqlite = sqliteRegistryPath === sqliteFederationPath ? sqlite : new BetterSqlite3(sqliteRegistryPath, { readonly: true });
@@ -16675,7 +16655,7 @@ async function getSessionTags(registryBackend, sessionId) {
16675
16655
  * Session CRUD commands: list, info, rename, slug, tag, route, active, auto-route.
16676
16656
  */
16677
16657
  async function cmdList(projectSlug, opts) {
16678
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
16658
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
16679
16659
  const registryBackend = await getRegistryBackend();
16680
16660
  const limit = parseInt(opts.limit ?? "20", 10);
16681
16661
  let project;
@@ -16740,7 +16720,7 @@ async function cmdList(projectSlug, opts) {
16740
16720
  console.log(dim$1(` ${rows.length} session(s) shown (limit: ${limit})`));
16741
16721
  }
16742
16722
  async function cmdInfo(projectSlug, sessionNumber) {
16743
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
16723
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
16744
16724
  const registryBackend = await getRegistryBackend();
16745
16725
  const project = await getProject$1(registryBackend, projectSlug);
16746
16726
  if (!project) {
@@ -16764,7 +16744,7 @@ async function cmdInfo(projectSlug, sessionNumber) {
16764
16744
  console.log();
16765
16745
  }
16766
16746
  async function cmdRename(projectSlug, numberOrLatest, newSlug) {
16767
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
16747
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
16768
16748
  await cmdRenameWith(await getRegistryBackend(), projectSlug, numberOrLatest, newSlug);
16769
16749
  }
16770
16750
  async function cmdRenameWith(registryBackend, projectSlug, numberOrLatest, newSlug) {
@@ -16827,7 +16807,7 @@ async function cmdRenameWith(registryBackend, projectSlug, numberOrLatest, newSl
16827
16807
  console.log();
16828
16808
  }
16829
16809
  async function cmdSlug(projectSlug, numberOrLatest, opts) {
16830
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
16810
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
16831
16811
  const registryBackend = await getRegistryBackend();
16832
16812
  const project = await getProject$1(registryBackend, projectSlug);
16833
16813
  if (!project) {
@@ -16857,7 +16837,7 @@ async function cmdSlug(projectSlug, numberOrLatest, opts) {
16857
16837
  }
16858
16838
  }
16859
16839
  async function cmdTag(projectSlug, sessionNumber, rawTags) {
16860
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
16840
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
16861
16841
  const registryBackend = await getRegistryBackend();
16862
16842
  const project = await getProject$1(registryBackend, projectSlug);
16863
16843
  if (!project) {
@@ -16897,7 +16877,7 @@ async function cmdTag(projectSlug, sessionNumber, rawTags) {
16897
16877
  console.log();
16898
16878
  }
16899
16879
  async function cmdRoute(projectSlug, sessionNumber, targetProjectSlug, opts) {
16900
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
16880
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
16901
16881
  const registryBackend = await getRegistryBackend();
16902
16882
  const project = await getProject$1(registryBackend, projectSlug);
16903
16883
  if (!project) {
@@ -16939,7 +16919,7 @@ async function cmdRoute(projectSlug, sessionNumber, targetProjectSlug, opts) {
16939
16919
  console.log();
16940
16920
  }
16941
16921
  async function cmdActive(opts) {
16942
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
16922
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
16943
16923
  const registryBackend = await getRegistryBackend();
16944
16924
  const minutes = parseInt(opts.minutes ?? "60", 10);
16945
16925
  const cutoff = Date.now() - minutes * 60 * 1e3;
@@ -17026,9 +17006,9 @@ async function cmdActive(opts) {
17026
17006
  ], rows));
17027
17007
  }
17028
17008
  async function cmdAutoRoute(opts) {
17029
- const { autoRoute, formatAutoRouteJson } = await import("./auto-route-CPlam4iv.mjs");
17030
- const { getRegistryBackend, createStorageBackend } = await import("./factory-BMK0tC1b.mjs");
17031
- const { loadConfig } = await import("./config-CUTg6VDq.mjs");
17009
+ const { autoRoute, formatAutoRouteJson } = await import("./auto-route-sLMU-NnM.mjs");
17010
+ const { getRegistryBackend, createStorageBackend } = await import("./factory-CaswxuJ0.mjs");
17011
+ const { loadConfig } = await import("./config-YinjgXEJ.mjs");
17032
17012
  const config = loadConfig();
17033
17013
  const registryBackend = await getRegistryBackend();
17034
17014
  const federation = await createStorageBackend(config);
@@ -17264,7 +17244,7 @@ async function cmdPause(opts) {
17264
17244
  process.exitCode = 1;
17265
17245
  return;
17266
17246
  }
17267
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
17247
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
17268
17248
  const registryBackend = await getRegistryBackend();
17269
17249
  const cwd = process.cwd();
17270
17250
  const project = await resolveProjectByCwd(registryBackend, cwd);
@@ -17659,7 +17639,7 @@ function buildStopBody(project, sessionId) {
17659
17639
  }
17660
17640
  }
17661
17641
  async function cmdHandover(projectSlug, numberOrLatest, sessionId) {
17662
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
17642
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
17663
17643
  const registryBackend = await getRegistryBackend();
17664
17644
  let project;
17665
17645
  if (projectSlug) {
@@ -17955,7 +17935,7 @@ function touchSentinel(rootPath) {
17955
17935
  async function cmdAutosave(opts) {
17956
17936
  const minGap = parseInt(opts.minGap ?? String(DEFAULT_MIN_GAP), 10);
17957
17937
  const cwd = process.cwd();
17958
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
17938
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
17959
17939
  const registryBackend = await getRegistryBackend();
17960
17940
  const project = await resolveProjectByCwd(registryBackend, cwd);
17961
17941
  if (!project) return;
@@ -19341,7 +19321,7 @@ function registerWorkerCommands(workerCmd) {
19341
19321
  process.exitCode = code ?? 1;
19342
19322
  });
19343
19323
  });
19344
- workerCmd.command("pane [id]").description("Open the follow pane for a worker (or one shared pane for this session)").option("--check", "Only report whether the pane is open, plus the profile file's path, font, and the hosting window's bounds").action(async (id, opts) => {
19324
+ workerCmd.command("pane [id]").description("Open the follow pane for a worker (tmux split when $TMUX is set, else iTerm2 on macOS, else prints the follow command)").option("--check", "Only report whether the pane is open, plus the profile file's path, font, and the hosting window's bounds").action(async (id, opts) => {
19345
19325
  try {
19346
19326
  const { workers } = readWorkersSection();
19347
19327
  const logDir = currentLogDir();
@@ -20349,8 +20329,8 @@ async function analyzeProject(registryBackend, project) {
20349
20329
  async function countVectorDbPaths(oldPaths) {
20350
20330
  if (oldPaths.length === 0) return 0;
20351
20331
  try {
20352
- const { loadConfig } = await import("./config-CUTg6VDq.mjs");
20353
- const { createStorageBackend } = await import("./factory-BMK0tC1b.mjs");
20332
+ const { loadConfig } = await import("./config-YinjgXEJ.mjs");
20333
+ const { createStorageBackend } = await import("./factory-CaswxuJ0.mjs");
20354
20334
  const config = loadConfig();
20355
20335
  if (config.storageBackend !== "postgres") return 0;
20356
20336
  const backend = await createStorageBackend(config);
@@ -20367,8 +20347,8 @@ async function countVectorDbPaths(oldPaths) {
20367
20347
  async function updateVectorDbPaths(moves) {
20368
20348
  if (moves.length === 0) return 0;
20369
20349
  try {
20370
- const { loadConfig } = await import("./config-CUTg6VDq.mjs");
20371
- const { createStorageBackend } = await import("./factory-BMK0tC1b.mjs");
20350
+ const { loadConfig } = await import("./config-YinjgXEJ.mjs");
20351
+ const { createStorageBackend } = await import("./factory-CaswxuJ0.mjs");
20372
20352
  const config = loadConfig();
20373
20353
  if (config.storageBackend !== "postgres") return 0;
20374
20354
  const backend = await createStorageBackend(config);
@@ -20455,7 +20435,7 @@ async function displayDryRun(plans) {
20455
20435
  console.log();
20456
20436
  }
20457
20437
  async function executeCleanup(plans, skipReindex) {
20458
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
20438
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
20459
20439
  const registryBackend = await getRegistryBackend();
20460
20440
  let deleted = 0;
20461
20441
  let renamed = 0;
@@ -20652,7 +20632,7 @@ async function executeCleanup(plans, skipReindex) {
20652
20632
  //#region src/cli/commands/session-cleanup/index.ts
20653
20633
  function registerSessionCleanupCommand(sessionCmd) {
20654
20634
  sessionCmd.command("cleanup [project-slug]").description("Clean up session notes: delete empties, auto-name unnamed, move into YYYY/MM/ hierarchy, renumber").option("--execute", "Actually perform the cleanup (default is dry-run)").option("--no-renumber", "Skip renumbering sessions after deletions").option("--no-reindex", "Skip triggering memory re-index after moves").action(async (projectSlug, opts) => {
20655
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
20635
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
20656
20636
  const registryBackend = await getRegistryBackend();
20657
20637
  const dryRun = !opts.execute;
20658
20638
  const skipReindex = opts.reindex === false;
@@ -20722,7 +20702,7 @@ function finalizeNote(notePath) {
20722
20702
  }
20723
20703
  async function cmdEnd(opts) {
20724
20704
  await cmdPause(opts);
20725
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
20705
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
20726
20706
  const registryBackend = await getRegistryBackend();
20727
20707
  const cwd = process.cwd();
20728
20708
  const project = await registryBackend.findProjectByCwdPrefix(cwd);
@@ -21170,7 +21150,7 @@ async function cmdFind(query, opts) {
21170
21150
  */
21171
21151
  async function getProjects(includeArchived) {
21172
21152
  try {
21173
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
21153
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
21174
21154
  const rows = await (await getRegistryBackend()).listProjectsWithSessionStats();
21175
21155
  return includeArchived ? rows : rows.filter((p) => p.status === "active");
21176
21156
  } catch {
@@ -21644,7 +21624,7 @@ async function cmdPick(opts = {}) {
21644
21624
  const onRemove = async (rec) => {
21645
21625
  if (!rec.slug) return false;
21646
21626
  try {
21647
- const { getRegistryBackend } = await import("./factory-BMK0tC1b.mjs");
21627
+ const { getRegistryBackend } = await import("./factory-CaswxuJ0.mjs");
21648
21628
  const registryBackend = await getRegistryBackend();
21649
21629
  const project = await registryBackend.getProjectBySlug(rec.slug);
21650
21630
  if (!project || project.status !== "active") return false;
@@ -21704,7 +21684,7 @@ async function cmdPick(opts = {}) {
21704
21684
  */
21705
21685
  function getVersion() {
21706
21686
  try {
21707
- const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "../../package.json");
21687
+ const pkgPath = resolveFromModule(import.meta.url, "package.json");
21708
21688
  return JSON.parse(readFileSync(pkgPath, "utf8")).version ?? "0.0.0";
21709
21689
  } catch {
21710
21690
  return "0.0.0";
@@ -21929,4 +21909,4 @@ claude() {
21929
21909
 
21930
21910
  //#endregion
21931
21911
  export { drainStdio as n, buildProgram as t };
21932
- //# sourceMappingURL=program-JhF2GgJY.mjs.map
21912
+ //# sourceMappingURL=program-DiktbiWa.mjs.map