@tekmidian/pai 0.42.5 → 0.42.6

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 (292) hide show
  1. package/ARCHITECTURE.md +9 -9
  2. package/README.md +26 -8
  3. package/dist/{aibroker-client-BP74gGwD.mjs → aibroker-client-Bn9SnGMa.mjs} +3 -3
  4. package/dist/{aibroker-client-BP74gGwD.mjs.map → aibroker-client-Bn9SnGMa.mjs.map} +1 -1
  5. package/dist/{aibroker-client-C6m71p6O.mjs → aibroker-client-D5NT0S1N.mjs} +1 -1
  6. package/dist/{auto-route-_5zzJz5q.mjs → auto-route-CcD0OWWB.mjs} +4 -4
  7. package/dist/{auto-route-_5zzJz5q.mjs.map → auto-route-CcD0OWWB.mjs.map} +1 -1
  8. package/dist/{chain-DTII7xeL.mjs → chain-BbcfP77K.mjs} +5 -4
  9. package/dist/{chain-DTII7xeL.mjs.map → chain-BbcfP77K.mjs.map} +1 -1
  10. package/dist/cli/index.mjs +23 -21
  11. package/dist/cli/index.mjs.map +1 -1
  12. package/dist/cli/program.d.mts.map +1 -1
  13. package/dist/cli/program.mjs +23 -21
  14. package/dist/{clusters-j0ZuNYp9.mjs → clusters-Cw_P6lO-.mjs} +2 -2
  15. package/dist/{clusters-j0ZuNYp9.mjs.map → clusters-Cw_P6lO-.mjs.map} +1 -1
  16. package/dist/{config-B64vFg14.mjs → config-DCu8THKi.mjs} +41 -9
  17. package/dist/{config-B64vFg14.mjs.map → config-DCu8THKi.mjs.map} +1 -1
  18. package/dist/config-DeqFqa1N.mjs +3 -0
  19. package/dist/config-DxMZjpvY.mjs +1289 -0
  20. package/dist/config-DxMZjpvY.mjs.map +1 -0
  21. package/dist/context-handover-cache-B9NKSjwR.mjs +3242 -0
  22. package/dist/context-handover-cache-B9NKSjwR.mjs.map +1 -0
  23. package/dist/daemon/index.mjs +23 -22
  24. package/dist/daemon/index.mjs.map +1 -1
  25. package/dist/daemon-BNjbVsQU.mjs +24 -0
  26. package/dist/{daemon-B8N1egl0.mjs → daemon-BppziPi6.mjs} +52 -38
  27. package/dist/daemon-BppziPi6.mjs.map +1 -0
  28. package/dist/daemon-mcp/index.mjs +144 -117
  29. package/dist/daemon-mcp/index.mjs.map +1 -1
  30. package/dist/db-BOBfewFH.mjs +3 -0
  31. package/dist/{db-a1ixZQjr.mjs → db-DJ8rk0VM.mjs} +15 -6
  32. package/dist/{db-a1ixZQjr.mjs.map → db-DJ8rk0VM.mjs.map} +1 -1
  33. package/dist/db-DbY2O8QO.mjs +3 -0
  34. package/dist/{db-Ca5qfsMC.mjs → db-Ddns80yf.mjs} +15 -6
  35. package/dist/{db-Ca5qfsMC.mjs.map → db-Ddns80yf.mjs.map} +1 -1
  36. package/dist/{detect-CdaA48EI.mjs → detect-Bf2z-oKB.mjs} +1 -1
  37. package/dist/{detect-CdaA48EI.mjs.map → detect-Bf2z-oKB.mjs.map} +1 -1
  38. package/dist/detector-CkwkXuGh.mjs +5 -0
  39. package/dist/{detector-C73Nxm94.mjs → detector-DWXkeTlk.mjs} +2 -2
  40. package/dist/{detector-C73Nxm94.mjs.map → detector-DWXkeTlk.mjs.map} +1 -1
  41. package/dist/{embeddings-CEBGrzwu.mjs → embeddings-ClqKtLZ8.mjs} +1 -1
  42. package/dist/{embeddings-DOLZnT1X.mjs → embeddings-DvRKcQyt.mjs} +1 -1
  43. package/dist/{embeddings-DOLZnT1X.mjs.map → embeddings-DvRKcQyt.mjs.map} +1 -1
  44. package/dist/factory-47Qf_df7.mjs +3 -0
  45. package/dist/{factory-DEb9NmHJ.mjs → factory-DNYAqjH0.mjs} +8 -8
  46. package/dist/{factory-DEb9NmHJ.mjs.map → factory-DNYAqjH0.mjs.map} +1 -1
  47. package/dist/{fallback-oJl3BaIN.mjs → fallback-Cwt4hmh5.mjs} +182 -122
  48. package/dist/fallback-Cwt4hmh5.mjs.map +1 -0
  49. package/dist/{helpers-IjZkXBhj.mjs → helpers-crDEr6S2.mjs} +1 -1
  50. package/dist/{helpers-IjZkXBhj.mjs.map → helpers-crDEr6S2.mjs.map} +1 -1
  51. package/dist/hooks/capture-all-events.mjs +117 -34
  52. package/dist/hooks/capture-all-events.mjs.map +4 -4
  53. package/dist/hooks/capture-session-summary.mjs +110 -33
  54. package/dist/hooks/capture-session-summary.mjs.map +4 -4
  55. package/dist/hooks/capture-tool-output.mjs +105 -28
  56. package/dist/hooks/capture-tool-output.mjs.map +4 -4
  57. package/dist/hooks/cleanup-session-files.mjs +54 -13
  58. package/dist/hooks/cleanup-session-files.mjs.map +2 -2
  59. package/dist/hooks/context-compression-hook.mjs +7565 -122
  60. package/dist/hooks/context-compression-hook.mjs.map +4 -4
  61. package/dist/hooks/initialize-session.mjs +55 -14
  62. package/dist/hooks/initialize-session.mjs.map +2 -2
  63. package/dist/hooks/inject-observations.mjs +79 -18
  64. package/dist/hooks/inject-observations.mjs.map +3 -3
  65. package/dist/hooks/load-core-context.mjs +55 -14
  66. package/dist/hooks/load-core-context.mjs.map +2 -2
  67. package/dist/hooks/load-project-context.mjs +185 -103
  68. package/dist/hooks/load-project-context.mjs.map +4 -4
  69. package/dist/hooks/mcp-deferred-gate.mjs +54 -13
  70. package/dist/hooks/mcp-deferred-gate.mjs.map +2 -2
  71. package/dist/hooks/mcp-deferred-reminder.mjs +9 -0
  72. package/dist/hooks/mcp-deferred-reminder.mjs.map +3 -3
  73. package/dist/hooks/observe.mjs +54 -13
  74. package/dist/hooks/observe.mjs.map +2 -2
  75. package/dist/hooks/post-compact-inject.mjs +7419 -16
  76. package/dist/hooks/post-compact-inject.mjs.map +4 -4
  77. package/dist/hooks/route-agents-to-worker.mjs +7778 -171
  78. package/dist/hooks/route-agents-to-worker.mjs.map +4 -4
  79. package/dist/hooks/route-edits-to-worker.mjs +90 -0
  80. package/dist/hooks/route-edits-to-worker.mjs.map +7 -0
  81. package/dist/hooks/security-validator.mjs +147 -6
  82. package/dist/hooks/security-validator.mjs.map +4 -4
  83. package/dist/hooks/session-commands.mjs +9 -0
  84. package/dist/hooks/session-commands.mjs.map +3 -3
  85. package/dist/hooks/stop-hook.mjs +182 -105
  86. package/dist/hooks/stop-hook.mjs.map +4 -4
  87. package/dist/hooks/subagent-stop-hook.mjs +3 -0
  88. package/dist/hooks/subagent-stop-hook.mjs.map +1 -1
  89. package/dist/hooks/sync-todo-to-md.mjs +54 -13
  90. package/dist/hooks/sync-todo-to-md.mjs.map +2 -2
  91. package/dist/hooks/update-tab-on-action.mjs +3 -0
  92. package/dist/hooks/update-tab-on-action.mjs.map +1 -1
  93. package/dist/hooks/update-tab-titles.mjs +3 -0
  94. package/dist/hooks/update-tab-titles.mjs.map +1 -1
  95. package/dist/hooks/whisper-reinject.mjs +3 -0
  96. package/dist/hooks/whisper-reinject.mjs.map +1 -1
  97. package/dist/hooks/whisper-rules.mjs +134 -29
  98. package/dist/hooks/whisper-rules.mjs.map +4 -4
  99. package/dist/hooks/worker-proxy.mjs +7737 -117
  100. package/dist/hooks/worker-proxy.mjs.map +4 -4
  101. package/dist/hooks/worker-status-line.mjs +7791 -144
  102. package/dist/hooks/worker-status-line.mjs.map +4 -4
  103. package/dist/hooks/worker-supervision.mjs +7721 -115
  104. package/dist/hooks/worker-supervision.mjs.map +4 -4
  105. package/dist/index.d.mts +4 -2
  106. package/dist/index.d.mts.map +1 -1
  107. package/dist/index.mjs +10 -10
  108. package/dist/{indexer-backend-BPTzKFZU.mjs → indexer-backend-CdvCJCkD.mjs} +3 -3
  109. package/dist/{indexer-backend-BPTzKFZU.mjs.map → indexer-backend-CdvCJCkD.mjs.map} +1 -1
  110. package/dist/{ipc-client-BmypMNYk.mjs → ipc-client-C6NryMMb.mjs} +2 -2
  111. package/dist/{ipc-client-BmypMNYk.mjs.map → ipc-client-C6NryMMb.mjs.map} +1 -1
  112. package/dist/{kg-entity-r8duqhi9.mjs → kg-entity-BSjM5xZh.mjs} +1 -1
  113. package/dist/{kg-entity-r8duqhi9.mjs.map → kg-entity-BSjM5xZh.mjs.map} +1 -1
  114. package/dist/{latent-ideas-CtSca4qG.mjs → latent-ideas-BfL4nCQ3.mjs} +4 -4
  115. package/dist/{latent-ideas-CtSca4qG.mjs.map → latent-ideas-BfL4nCQ3.mjs.map} +1 -1
  116. package/dist/{link-boost-Bucnz3n8.mjs → link-boost-C5PaNdzm.mjs} +1 -1
  117. package/dist/{link-boost-Bucnz3n8.mjs.map → link-boost-C5PaNdzm.mjs.map} +1 -1
  118. package/dist/main-resolver-CnfnWa8C.mjs +7 -0
  119. package/dist/{main-resolver-DnkxPYkr.mjs → main-resolver-DvYu9jbl.mjs} +21 -11
  120. package/dist/main-resolver-DvYu9jbl.mjs.map +1 -0
  121. package/dist/{migrate-Cjzeefn9.mjs → migrate-CfERwXhY.mjs} +2 -2
  122. package/dist/{migrate-Cjzeefn9.mjs.map → migrate-CfERwXhY.mjs.map} +1 -1
  123. package/dist/{neighborhood-CM7Jgb51.mjs → neighborhood-CETR_P4y.mjs} +2 -2
  124. package/dist/{neighborhood-CM7Jgb51.mjs.map → neighborhood-CETR_P4y.mjs.map} +1 -1
  125. package/dist/{note-context-DCwE2A-M.mjs → note-context-DCcRWBoN.mjs} +1 -1
  126. package/dist/{note-context-DCwE2A-M.mjs.map → note-context-DCcRWBoN.mjs.map} +1 -1
  127. package/dist/pai-home-ChAOupZc.mjs +164 -0
  128. package/dist/pai-home-ChAOupZc.mjs.map +1 -0
  129. package/dist/{pai-marker-CHtbJMwJ.mjs → pai-marker-B20KqhA8.mjs} +1 -1
  130. package/dist/{pai-marker-CHtbJMwJ.mjs.map → pai-marker-B20KqhA8.mjs.map} +1 -1
  131. package/dist/{planner-D5Ui7DAm.mjs → planner-pXRc-8yt.mjs} +7 -6
  132. package/dist/{planner-D5Ui7DAm.mjs.map → planner-pXRc-8yt.mjs.map} +1 -1
  133. package/dist/{postgres-CtOzfoQU.mjs → postgres-CUSXWgTG.mjs} +2 -2
  134. package/dist/{postgres-CtOzfoQU.mjs.map → postgres-CUSXWgTG.mjs.map} +1 -1
  135. package/dist/{program-zpoYnJGz.mjs → program-LLNPpxlj.mjs} +8308 -6065
  136. package/dist/program-LLNPpxlj.mjs.map +1 -0
  137. package/dist/query-feedback-C7rSfiXU.mjs +3 -0
  138. package/dist/{query-feedback-Dqz-HC__.mjs → query-feedback-CYyOGi3y.mjs} +20 -6
  139. package/dist/query-feedback-CYyOGi3y.mjs.map +1 -0
  140. package/dist/{reranker-CwTCNsgA.mjs → reranker-B5qUTamW.mjs} +1 -1
  141. package/dist/{reranker-xPm04PXx.mjs → reranker-HHmhZk6v.mjs} +1 -1
  142. package/dist/{reranker-xPm04PXx.mjs.map → reranker-HHmhZk6v.mjs.map} +1 -1
  143. package/dist/router-CremHKTI.mjs +3 -0
  144. package/dist/{router-DD6D4j31.mjs → router-DBAZfE7X.mjs} +2 -2
  145. package/dist/{router-DD6D4j31.mjs.map → router-DBAZfE7X.mjs.map} +1 -1
  146. package/dist/{run-D7K5UALn.mjs → run-DDdT9teG.mjs} +530 -210
  147. package/dist/run-DDdT9teG.mjs.map +1 -0
  148. package/dist/{runtime-paths-rni52zHX.mjs → runtime-paths-B0P1TvUr.mjs} +1 -1
  149. package/dist/{runtime-paths-rni52zHX.mjs.map → runtime-paths-B0P1TvUr.mjs.map} +1 -1
  150. package/dist/{search-Rpk1cSBC.mjs → search-B69cQwDB.mjs} +3 -3
  151. package/dist/{search-Rpk1cSBC.mjs.map → search-B69cQwDB.mjs.map} +1 -1
  152. package/dist/{search-CfPpJAWQ.mjs → search-fb-5ovj4.mjs} +2 -2
  153. package/dist/{server-D4vAieF4.mjs → server-Ch99xt5K.mjs} +15 -14
  154. package/dist/server-Ch99xt5K.mjs.map +1 -0
  155. package/dist/skills/Advisor/SKILL.md +3 -3
  156. package/dist/skills/Providers/SKILL.md +30 -0
  157. package/dist/skills/Reconstruct/SKILL.md +1 -1
  158. package/dist/skills/VaultContext/SKILL.md +1 -1
  159. package/dist/skills/Whisper/SKILL.md +3 -3
  160. package/dist/skills/Worker/SKILL.md +1 -1
  161. package/dist/{sources-CS43CpuS.mjs → sources-KBGEA_E6.mjs} +2 -2
  162. package/dist/{sources-CS43CpuS.mjs.map → sources-KBGEA_E6.mjs.map} +1 -1
  163. package/dist/{sqlite-Cq3gJcq9.mjs → sqlite-By6r2YhZ.mjs} +3 -3
  164. package/dist/{sqlite-Cq3gJcq9.mjs.map → sqlite-By6r2YhZ.mjs.map} +1 -1
  165. package/dist/{state-CY6I-Hnc.mjs → state-DnYGRmS7.mjs} +1 -1
  166. package/dist/{state-BRdB-Bf1.mjs → state-PJrgfDLW.mjs} +1 -1
  167. package/dist/{state-BRdB-Bf1.mjs.map → state-PJrgfDLW.mjs.map} +1 -1
  168. package/dist/{stop-words-Hfu8u22w.mjs → stop-words-BaMEGVeY.mjs} +1 -1
  169. package/dist/{stop-words-Hfu8u22w.mjs.map → stop-words-BaMEGVeY.mjs.map} +1 -1
  170. package/dist/{sync-BWbe8JTg.mjs → sync-Btcb6xA4.mjs} +3 -3
  171. package/dist/{sync-BWbe8JTg.mjs.map → sync-Btcb6xA4.mjs.map} +1 -1
  172. package/dist/{themes-B7h9YDiy.mjs → themes-BVoAnLZj.mjs} +3 -3
  173. package/dist/{themes-B7h9YDiy.mjs.map → themes-BVoAnLZj.mjs.map} +1 -1
  174. package/dist/{tools-BW3NLMPk.mjs → tools-BradfQk7.mjs} +4 -3
  175. package/dist/{tools-LlzcV_eK.mjs → tools-UrSHIe29.mjs} +30 -233
  176. package/dist/tools-UrSHIe29.mjs.map +1 -0
  177. package/dist/{trace-u4hT-pLD.mjs → trace-Cy8quQTm.mjs} +1 -1
  178. package/dist/{trace-u4hT-pLD.mjs.map → trace-Cy8quQTm.mjs.map} +1 -1
  179. package/dist/{utils-DhMex3Ox.mjs → utils-BD8g8oSf.mjs} +1 -1
  180. package/dist/{utils-9Err2RBW.mjs → utils-CJymHkYm.mjs} +1 -1
  181. package/dist/{utils-9Err2RBW.mjs.map → utils-CJymHkYm.mjs.map} +1 -1
  182. package/dist/{vault-indexer-mata9S7b.mjs → vault-indexer-C5i-OAyr.mjs} +2 -2
  183. package/dist/{vault-indexer-mata9S7b.mjs.map → vault-indexer-C5i-OAyr.mjs.map} +1 -1
  184. package/dist/wakeup-TnGjJY3I.mjs +218 -0
  185. package/dist/wakeup-TnGjJY3I.mjs.map +1 -0
  186. package/dist/work-queue-worker-BA5IDBwQ.mjs +567 -0
  187. package/dist/work-queue-worker-BA5IDBwQ.mjs.map +1 -0
  188. package/dist/work-queue-worker-DLM2wlqM.mjs +14 -0
  189. package/dist/{zettelkasten-F0D_XfQ4.mjs → zettelkasten-BBjA7GcP.mjs} +4 -4
  190. package/dist/{zettelkasten-F0D_XfQ4.mjs.map → zettelkasten-BBjA7GcP.mjs.map} +1 -1
  191. package/docs/commands/README.md +30 -3
  192. package/docs/commands/audit.md +88 -0
  193. package/docs/commands/backup.md +2 -2
  194. package/docs/commands/clear-names.md +1 -1
  195. package/docs/commands/config.md +59 -0
  196. package/docs/commands/daemon.md +1 -1
  197. package/docs/commands/db.md +1 -1
  198. package/docs/commands/end.md +1 -1
  199. package/docs/commands/help.md +1 -1
  200. package/docs/commands/identity.md +1 -1
  201. package/docs/commands/kg.md +1 -1
  202. package/docs/commands/launch.md +45 -0
  203. package/docs/commands/mcp.md +1 -1
  204. package/docs/commands/memory.md +3 -3
  205. package/docs/commands/notify.md +1 -1
  206. package/docs/commands/observation.md +1 -1
  207. package/docs/commands/obsidian.md +1 -1
  208. package/docs/commands/pause.md +1 -1
  209. package/docs/commands/project.md +46 -1
  210. package/docs/commands/projects.md +46 -1
  211. package/docs/commands/registry.md +1 -1
  212. package/docs/commands/restore.md +1 -1
  213. package/docs/commands/session.md +1 -1
  214. package/docs/commands/sessions.md +1 -1
  215. package/docs/commands/setup.md +1 -1
  216. package/docs/commands/shell-init.md +1 -1
  217. package/docs/commands/skill.md +1 -1
  218. package/docs/commands/task.md +1 -1
  219. package/docs/commands/topic.md +1 -1
  220. package/docs/commands/update.md +1 -1
  221. package/docs/commands/worker.md +95 -6
  222. package/docs/commands/zettel.md +1 -1
  223. package/docs/provider-abstraction.md +1 -1
  224. package/docs/provider-independence-details.md +8 -5
  225. package/docs/task-bus.md +1 -1
  226. package/docs/worker.md +136 -83
  227. package/docs/workers-config.md +446 -0
  228. package/package.json +4 -2
  229. package/scripts/build-hooks.mjs +56 -3
  230. package/src/hooks/pre-compact.sh +5 -2
  231. package/src/hooks/session-stop.sh +29 -4
  232. package/src/hooks/ts/capture-all-events.ts +3 -3
  233. package/src/hooks/ts/lib/advisor-budget.test.ts +98 -0
  234. package/src/hooks/ts/lib/advisor-budget.ts +90 -0
  235. package/src/hooks/ts/lib/agent-gate.test.ts +101 -0
  236. package/src/hooks/ts/lib/agent-gate.ts +112 -0
  237. package/src/hooks/ts/lib/context-fill.ts +2 -2
  238. package/src/hooks/ts/lib/edit-gate.test.ts +52 -0
  239. package/src/hooks/ts/lib/edit-gate.ts +51 -0
  240. package/src/hooks/ts/lib/mcp-deferred-reminder.test.ts +8 -0
  241. package/src/hooks/ts/lib/pai-paths.test.ts +93 -0
  242. package/src/hooks/ts/lib/pai-paths.ts +168 -24
  243. package/src/hooks/ts/lib/project-utils/index.ts +1 -0
  244. package/src/hooks/ts/lib/project-utils/paths.ts +5 -4
  245. package/src/hooks/ts/lib/project-utils.ts +1 -0
  246. package/src/hooks/ts/post-tool-use/capture-tool-output.ts +2 -2
  247. package/src/hooks/ts/pre-compact/context-compression-hook.ts +1 -1
  248. package/src/hooks/ts/pre-tool-use/route-agents-to-worker.ts +46 -99
  249. package/src/hooks/ts/pre-tool-use/route-edits-to-worker.test.ts +47 -0
  250. package/src/hooks/ts/pre-tool-use/route-edits-to-worker.ts +96 -0
  251. package/src/hooks/ts/pre-tool-use/security-validator.ts +2 -1
  252. package/src/hooks/ts/session-end/capture-session-summary.ts +4 -4
  253. package/src/hooks/ts/session-start/initialize-session.ts +3 -3
  254. package/src/hooks/ts/session-start/inject-observations.test.ts +56 -0
  255. package/src/hooks/ts/session-start/inject-observations.ts +28 -8
  256. package/src/hooks/ts/session-start/load-core-context.ts +4 -4
  257. package/src/hooks/ts/session-start/load-project-context.ts +2 -2
  258. package/src/hooks/ts/session-start/mcp-deferred-reminder.ts +2 -0
  259. package/src/hooks/ts/session-start/session-commands.ts +4 -0
  260. package/src/hooks/ts/session-start/session-start-worker-guard.test.ts +36 -0
  261. package/src/hooks/ts/stop/stop-hook.ts +6 -11
  262. package/src/hooks/ts/user-prompt/whisper-rules.test.ts +49 -0
  263. package/src/hooks/ts/user-prompt/whisper-rules.ts +88 -47
  264. package/statusline-command.sh +277 -116
  265. package/templates/agent-prefs.example.md +8 -8
  266. package/templates/claude-md.template.md +1 -1
  267. package/templates/voices.example.json +3 -3
  268. package/dist/config-C_ErGddD.mjs +0 -3
  269. package/dist/config-_lQI_W08.mjs +0 -640
  270. package/dist/config-_lQI_W08.mjs.map +0 -1
  271. package/dist/context-handover-cache-pNFdBNrU.mjs +0 -1548
  272. package/dist/context-handover-cache-pNFdBNrU.mjs.map +0 -1
  273. package/dist/daemon-B8N1egl0.mjs.map +0 -1
  274. package/dist/daemon-DHfyoTlk.mjs +0 -23
  275. package/dist/db-O-cyAPfS.mjs +0 -3
  276. package/dist/db-XEwJbuGO.mjs +0 -3
  277. package/dist/detector-C-7KRi42.mjs +0 -5
  278. package/dist/factory-Dbo8yNPi.mjs +0 -3
  279. package/dist/fallback-oJl3BaIN.mjs.map +0 -1
  280. package/dist/main-resolver-BAfOMppW.mjs +0 -7
  281. package/dist/main-resolver-DnkxPYkr.mjs.map +0 -1
  282. package/dist/program-zpoYnJGz.mjs.map +0 -1
  283. package/dist/query-feedback-DGoVRaWD.mjs +0 -3
  284. package/dist/query-feedback-Dqz-HC__.mjs.map +0 -1
  285. package/dist/router-BTIGZR2_.mjs +0 -3
  286. package/dist/run-D7K5UALn.mjs.map +0 -1
  287. package/dist/server-D4vAieF4.mjs.map +0 -1
  288. package/dist/tools-LlzcV_eK.mjs.map +0 -1
  289. package/dist/work-queue-worker-AEmfVE0F.mjs +0 -14
  290. package/dist/work-queue-worker-DIT-VLSh.mjs +0 -2136
  291. package/dist/work-queue-worker-DIT-VLSh.mjs.map +0 -1
  292. /package/dist/{indexer-D7MvSQPY.mjs → indexer-C5Le7XE7.mjs} +0 -0
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire as __paiCreateRequire } from 'node:module';
3
+ const require = __paiCreateRequire(import.meta.url);
4
+ if (!process.env.PAI_QUIET_NOTICES) process.env.PAI_QUIET_NOTICES = '1';
2
5
 
3
6
  // src/hooks/ts/lib/worker-session.ts
4
7
  function isWorkerSession(env = process.env) {
@@ -6,18 +9,18 @@ function isWorkerSession(env = process.env) {
6
9
  }
7
10
 
8
11
  // src/hooks/ts/session-start/load-project-context.ts
9
- import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
10
- import { join as join6, basename as basename4, dirname, resolve as resolve2 } from "path";
11
- import { homedir as homedir4 } from "os";
12
+ import { existsSync as existsSync7, readFileSync as readFileSync6 } from "fs";
13
+ import { join as join7, basename as basename4, dirname as dirname2, resolve as resolve2 } from "path";
14
+ import { homedir as homedir5 } from "os";
12
15
  import { execSync } from "child_process";
13
16
 
14
17
  // src/memory/wakeup.ts
15
18
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
16
19
  import { join, basename } from "node:path";
17
20
  import { homedir } from "node:os";
18
- var L1_TOKEN_BUDGET = 800;
21
+ var L1_TOKEN_BUDGET = 300;
19
22
  var L1_CHAR_BUDGET = L1_TOKEN_BUDGET * 4;
20
- var L1_MAX_NOTES = 10;
23
+ var L1_MAX_NOTES = 3;
21
24
  var EXTRACT_SECTIONS = [
22
25
  "Work Done",
23
26
  "Key Decisions",
@@ -96,7 +99,10 @@ function findSessionNotes(notesDir) {
96
99
  });
97
100
  return result;
98
101
  }
99
- function extractKeyLines(content, maxChars) {
102
+ function normalizeLine(line) {
103
+ return line.replace(/^(- \[[ x]\] |- |\* |\d+\.\s)/, "").trim().replace(/\s+/g, " ");
104
+ }
105
+ function extractKeyLines(content, maxChars, seen = /* @__PURE__ */ new Set()) {
100
106
  const lines = content.split("\n");
101
107
  const selected = [];
102
108
  let inTargetSection = false;
@@ -126,7 +132,10 @@ function extractKeyLines(content, maxChars) {
126
132
  const trimmed = line.trim();
127
133
  if (!trimmed || trimmed.startsWith("<!--") || trimmed === "---") continue;
128
134
  if (trimmed.startsWith("- ") || trimmed.startsWith("* ") || trimmed.match(/^\d+\./) || trimmed.startsWith("**")) {
135
+ const normalized = normalizeLine(trimmed);
136
+ if (seen.has(normalized)) continue;
129
137
  if (charCount + trimmed.length + 1 > maxChars) break;
138
+ seen.add(normalized);
130
139
  selected.push(trimmed);
131
140
  charCount += trimmed.length + 1;
132
141
  }
@@ -140,6 +149,7 @@ function buildL1EssentialStory(rootPath, tokenBudget = L1_TOKEN_BUDGET) {
140
149
  const noteFiles = findSessionNotes(notesDir).slice(0, L1_MAX_NOTES);
141
150
  if (noteFiles.length === 0) return "";
142
151
  const sections = [];
152
+ const seen = /* @__PURE__ */ new Set();
143
153
  let remaining = charBudget;
144
154
  for (const noteFile of noteFiles) {
145
155
  if (remaining <= 50) break;
@@ -154,7 +164,7 @@ function buildL1EssentialStory(rootPath, tokenBudget = L1_TOKEN_BUDGET) {
154
164
  const dateLabel = titleMatch ? titleMatch[1] : "";
155
165
  const titleLabel = titleMatch ? titleMatch[2] : name.replace(/^\d+ - /, "").replace(/\.md$/, "");
156
166
  const perNoteChars = Math.min(remaining, Math.floor(charBudget / noteFiles.length) + 200);
157
- const extracted = extractKeyLines(content, perNoteChars);
167
+ const extracted = extractKeyLines(content, perNoteChars, seen);
158
168
  if (!extracted) continue;
159
169
  const noteBlock = `[${dateLabel} - ${titleLabel}]
160
170
  ${extracted}`;
@@ -318,23 +328,49 @@ function extractMarkedBody(lines) {
318
328
  }
319
329
  var AUTHORED_GRACE_MS = 60 * 60 * 1e3;
320
330
 
321
- // src/hooks/ts/lib/project-utils/paths.ts
322
- import { existsSync as existsSync3, mkdirSync, readdirSync as readdirSync2, linkSync, copyFileSync } from "fs";
323
- import { join as join3, basename as basename2 } from "path";
331
+ // src/hooks/ts/lib/pai-paths.ts
332
+ import { homedir as homedir3 } from "os";
333
+ import { resolve, join as join3 } from "path";
334
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
335
+
336
+ // src/config/pai-home.ts
337
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, copyFileSync, renameSync, readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
338
+ import { homedir as homedir2 } from "node:os";
339
+ import { join as join2, dirname } from "node:path";
340
+ function paiHomeDir() {
341
+ return process.env.PAI_HOME || join2(homedir2(), ".claude", "pai");
342
+ }
343
+ function paiHomePath(...segments) {
344
+ return join2(paiHomeDir(), ...segments);
345
+ }
346
+ var noticesPrinted = /* @__PURE__ */ new Set();
347
+ function resolvePaiFile(newPath, oldCandidates, migrateHint) {
348
+ if (existsSync2(newPath)) return newPath;
349
+ for (const old of oldCandidates) {
350
+ if (existsSync2(old)) {
351
+ if (!noticesPrinted.has(newPath)) {
352
+ noticesPrinted.add(newPath);
353
+ process.stderr.write(
354
+ `pai: ${old} is at an old location \u2014 run \`${migrateHint}\` to move it to ${newPath}
355
+ `
356
+ );
357
+ }
358
+ return old;
359
+ }
360
+ }
361
+ return newPath;
362
+ }
324
363
 
325
364
  // src/hooks/ts/lib/pai-paths.ts
326
- import { homedir as homedir2 } from "os";
327
- import { resolve, join as join2 } from "path";
328
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
329
365
  function loadEnvFile() {
330
366
  const possiblePaths = [
331
- resolve(process.env.PAI_DIR || "", ".env"),
332
- resolve(homedir2(), ".claude", ".env")
367
+ resolve(process.env.ADAPTER_DIR || process.env.PAI_DIR || "", ".env"),
368
+ resolve(homedir3(), ".claude", ".env")
333
369
  ];
334
370
  for (const envPath of possiblePaths) {
335
- if (existsSync2(envPath)) {
371
+ if (existsSync3(envPath)) {
336
372
  try {
337
- const content = readFileSync2(envPath, "utf-8");
373
+ const content = readFileSync3(envPath, "utf-8");
338
374
  for (const line of content.split("\n")) {
339
375
  const trimmed = line.trim();
340
376
  if (!trimmed || trimmed.startsWith("#")) continue;
@@ -345,8 +381,8 @@ function loadEnvFile() {
345
381
  if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
346
382
  value = value.slice(1, -1);
347
383
  }
348
- value = value.replace(/\$HOME/g, homedir2());
349
- value = value.replace(/^~(?=\/|$)/, homedir2());
384
+ value = value.replace(/\$HOME/g, homedir3());
385
+ value = value.replace(/^~(?=\/|$)/, homedir3());
350
386
  if (process.env[key] === void 0) {
351
387
  process.env[key] = value;
352
388
  }
@@ -359,29 +395,75 @@ function loadEnvFile() {
359
395
  }
360
396
  }
361
397
  loadEnvFile();
362
- var PAI_DIR = process.env.PAI_DIR ? resolve(process.env.PAI_DIR) : resolve(homedir2(), ".claude");
363
- var HOOKS_DIR = join2(PAI_DIR, "Hooks");
364
- var SKILLS_DIR = join2(PAI_DIR, "Skills");
365
- var AGENTS_DIR = join2(PAI_DIR, "Agents");
366
- var HISTORY_DIR = join2(PAI_DIR, "History");
367
- var COMMANDS_DIR = join2(PAI_DIR, "Commands");
398
+ function defaultAdapterDir() {
399
+ return resolve(homedir3(), ".claude");
400
+ }
401
+ function suppressDeprecationNotices() {
402
+ if (process.env.PAI_QUIET_NOTICES === "1") return true;
403
+ const idx = process.argv.indexOf("--output-format");
404
+ return idx !== -1 && process.argv[idx + 1] === "json";
405
+ }
406
+ function warnPaiDirDeprecatedOnce(message) {
407
+ const g = globalThis;
408
+ if (g.__paiDirNoticePrinted || suppressDeprecationNotices()) return;
409
+ g.__paiDirNoticePrinted = true;
410
+ process.stderr.write(`pai: ${message}
411
+ `);
412
+ }
413
+ function resolveAdapterDir() {
414
+ if (process.env.ADAPTER_DIR) {
415
+ const adapterDir = resolve(process.env.ADAPTER_DIR);
416
+ if (process.env.PAI_DIR) {
417
+ const paiDir = resolve(process.env.PAI_DIR);
418
+ if (paiDir !== adapterDir) {
419
+ warnPaiDirDeprecatedOnce(
420
+ `ADAPTER_DIR (${adapterDir}) and PAI_DIR (${paiDir}) are both set and differ \u2014 ADAPTER_DIR wins. PAI_DIR still works for one release.`
421
+ );
422
+ }
423
+ }
424
+ return adapterDir;
425
+ }
426
+ if (process.env.PAI_DIR) {
427
+ const paiDir = resolve(process.env.PAI_DIR);
428
+ if (paiDir !== defaultAdapterDir()) {
429
+ warnPaiDirDeprecatedOnce(
430
+ "PAI_DIR is deprecated \u2014 use ADAPTER_DIR for the harness adapter root (~/.claude). PAI_DIR still works for one release."
431
+ );
432
+ }
433
+ return paiDir;
434
+ }
435
+ return defaultAdapterDir();
436
+ }
437
+ var ADAPTER_DIR = resolveAdapterDir();
438
+ var HOOKS_DIR = join3(ADAPTER_DIR, "Hooks");
439
+ var SKILLS_DIR = join3(ADAPTER_DIR, "Skills");
440
+ var AGENTS_DIR = join3(ADAPTER_DIR, "Agents");
441
+ var COMMANDS_DIR = join3(ADAPTER_DIR, "Commands");
368
442
  function validatePAIStructure() {
369
- if (!existsSync2(PAI_DIR)) {
370
- console.error(`PAI_DIR does not exist: ${PAI_DIR}`);
371
- console.error(` Expected ~/.claude or set PAI_DIR environment variable`);
443
+ if (!existsSync3(ADAPTER_DIR)) {
444
+ console.error(`ADAPTER_DIR does not exist: ${ADAPTER_DIR}`);
445
+ console.error(` Expected ~/.claude or set ADAPTER_DIR environment variable`);
372
446
  process.exit(1);
373
447
  }
374
- if (!existsSync2(HOOKS_DIR)) {
448
+ if (!existsSync3(HOOKS_DIR)) {
375
449
  console.error(`PAI hooks directory not found: ${HOOKS_DIR}`);
376
- console.error(` Your PAI_DIR may be misconfigured`);
377
- console.error(` Current PAI_DIR: ${PAI_DIR}`);
450
+ console.error(` Your ADAPTER_DIR may be misconfigured`);
451
+ console.error(` Current ADAPTER_DIR: ${ADAPTER_DIR}`);
378
452
  process.exit(1);
379
453
  }
380
454
  }
381
455
  validatePAIStructure();
456
+ function oldSessionRoutingPath() {
457
+ return join3(ADAPTER_DIR, "session-routing.json");
458
+ }
459
+ function sessionRoutingPath() {
460
+ return resolvePaiFile(paiHomePath("session-routing.json"), [oldSessionRoutingPath()], "pai config migrate --history");
461
+ }
382
462
 
383
463
  // src/hooks/ts/lib/project-utils/paths.ts
384
- var PROJECTS_DIR = join3(PAI_DIR, "projects");
464
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync as readdirSync3, linkSync, copyFileSync as copyFileSync2 } from "fs";
465
+ import { join as join4, basename as basename2 } from "path";
466
+ var PROJECTS_DIR = join4(ADAPTER_DIR, "projects");
385
467
  var PROBE_CWD_PATTERNS = [
386
468
  "/CodexBar/ClaudeProbe",
387
469
  "/ClaudeProbe"
@@ -395,56 +477,56 @@ function encodePath(path) {
395
477
  }
396
478
  function getProjectDir(cwd) {
397
479
  const encoded = encodePath(cwd);
398
- return join3(PROJECTS_DIR, encoded);
480
+ return join4(PROJECTS_DIR, encoded);
399
481
  }
400
482
  function getNotesDir(cwd) {
401
- return join3(getProjectDir(cwd), "Notes");
483
+ return join4(getProjectDir(cwd), "Notes");
402
484
  }
403
485
  function findNotesDir(cwd) {
404
486
  const cwdBasename = basename2(cwd).toLowerCase();
405
- if (cwdBasename === "notes" && existsSync3(cwd)) {
487
+ if (cwdBasename === "notes" && existsSync4(cwd)) {
406
488
  return { path: cwd, isLocal: true };
407
489
  }
408
490
  const localPaths = [
409
- join3(cwd, "Notes"),
410
- join3(cwd, "notes"),
411
- join3(cwd, ".claude", "Notes")
491
+ join4(cwd, "Notes"),
492
+ join4(cwd, "notes"),
493
+ join4(cwd, ".claude", "Notes")
412
494
  ];
413
495
  for (const path of localPaths) {
414
- if (existsSync3(path)) {
496
+ if (existsSync4(path)) {
415
497
  return { path, isLocal: true };
416
498
  }
417
499
  }
418
500
  return { path: getNotesDir(cwd), isLocal: false };
419
501
  }
420
502
  function getSessionsDirFromProjectDir(projectDir) {
421
- return join3(projectDir, "sessions");
503
+ return join4(projectDir, "sessions");
422
504
  }
423
505
  function ensureSessionsDirFromProjectDir(projectDir) {
424
506
  const sessionsDir = getSessionsDirFromProjectDir(projectDir);
425
- if (!existsSync3(sessionsDir)) {
426
- mkdirSync(sessionsDir, { recursive: true });
507
+ if (!existsSync4(sessionsDir)) {
508
+ mkdirSync2(sessionsDir, { recursive: true });
427
509
  console.error(`Created sessions directory: ${sessionsDir}`);
428
510
  }
429
511
  return sessionsDir;
430
512
  }
431
513
  function archiveSessionFilesToSessionsDir(projectDir, excludeFile, silent = false) {
432
514
  const sessionsDir = ensureSessionsDirFromProjectDir(projectDir);
433
- if (!existsSync3(projectDir)) return 0;
434
- const files = readdirSync2(projectDir);
515
+ if (!existsSync4(projectDir)) return 0;
516
+ const files = readdirSync3(projectDir);
435
517
  let archivedCount = 0;
436
518
  for (const file of files) {
437
519
  if (!file.endsWith(".jsonl") || file === excludeFile) continue;
438
- const sourcePath = join3(projectDir, file);
439
- const destPath = join3(sessionsDir, file);
440
- if (existsSync3(destPath)) continue;
520
+ const sourcePath = join4(projectDir, file);
521
+ const destPath = join4(sessionsDir, file);
522
+ if (existsSync4(destPath)) continue;
441
523
  try {
442
524
  linkSync(sourcePath, destPath);
443
525
  if (!silent) console.error(`Archived ${file} \u2192 sessions/ (still resumable)`);
444
526
  archivedCount++;
445
527
  } catch (error) {
446
528
  try {
447
- copyFileSync(sourcePath, destPath);
529
+ copyFileSync2(sourcePath, destPath);
448
530
  if (!silent) console.error(`Copied ${file} \u2192 sessions/ (hardlink unavailable)`);
449
531
  archivedCount++;
450
532
  } catch {
@@ -456,41 +538,41 @@ function archiveSessionFilesToSessionsDir(projectDir, excludeFile, silent = fals
456
538
  }
457
539
  function findTodoPath(cwd) {
458
540
  const localPaths = [
459
- join3(cwd, "TODO.md"),
460
- join3(cwd, "notes", "TODO.md"),
461
- join3(cwd, "Notes", "TODO.md"),
462
- join3(cwd, ".claude", "TODO.md")
541
+ join4(cwd, "TODO.md"),
542
+ join4(cwd, "notes", "TODO.md"),
543
+ join4(cwd, "Notes", "TODO.md"),
544
+ join4(cwd, ".claude", "TODO.md")
463
545
  ];
464
546
  for (const path of localPaths) {
465
- if (existsSync3(path)) return path;
547
+ if (existsSync4(path)) return path;
466
548
  }
467
- return join3(getNotesDir(cwd), "TODO.md");
549
+ return join4(getNotesDir(cwd), "TODO.md");
468
550
  }
469
551
  function findAllClaudeMdPaths(cwd) {
470
552
  const foundPaths = [];
471
553
  const localPaths = [
472
- join3(cwd, ".claude", "CLAUDE.md"),
473
- join3(cwd, "CLAUDE.md"),
474
- join3(cwd, "Notes", "CLAUDE.md"),
475
- join3(cwd, "notes", "CLAUDE.md"),
476
- join3(cwd, "Prompts", "CLAUDE.md"),
477
- join3(cwd, "prompts", "CLAUDE.md")
554
+ join4(cwd, ".claude", "CLAUDE.md"),
555
+ join4(cwd, "CLAUDE.md"),
556
+ join4(cwd, "Notes", "CLAUDE.md"),
557
+ join4(cwd, "notes", "CLAUDE.md"),
558
+ join4(cwd, "Prompts", "CLAUDE.md"),
559
+ join4(cwd, "prompts", "CLAUDE.md")
478
560
  ];
479
561
  for (const path of localPaths) {
480
- if (existsSync3(path)) foundPaths.push(path);
562
+ if (existsSync4(path)) foundPaths.push(path);
481
563
  }
482
564
  return foundPaths;
483
565
  }
484
566
 
485
567
  // src/hooks/ts/lib/project-utils/notify.ts
486
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
487
- import { join as join4 } from "path";
488
- import { homedir as homedir3 } from "os";
568
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
569
+ import { join as join5 } from "path";
570
+ import { homedir as homedir4 } from "os";
489
571
  function isWhatsAppEnabled() {
490
572
  try {
491
- const settingsPath = join4(homedir3(), ".claude", "settings.json");
492
- if (!existsSync4(settingsPath)) return false;
493
- const settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
573
+ const settingsPath = join5(homedir4(), ".claude", "settings.json");
574
+ if (!existsSync5(settingsPath)) return false;
575
+ const settings = JSON.parse(readFileSync4(settingsPath, "utf-8"));
494
576
  const enabled = settings.enabledMcpjsonServers || [];
495
577
  return enabled.includes("aibroker") || enabled.includes("whazaa") || enabled.includes("telex");
496
578
  } catch {
@@ -535,21 +617,21 @@ async function sendNtfyNotification(message, retries = 2) {
535
617
  }
536
618
 
537
619
  // src/hooks/ts/lib/project-utils/session-notes.ts
538
- import { existsSync as existsSync5, mkdirSync as mkdirSync2, readdirSync as readdirSync3, readFileSync as readFileSync4, writeFileSync, renameSync } from "fs";
539
- import { join as join5, basename as basename3 } from "path";
620
+ import { existsSync as existsSync6, mkdirSync as mkdirSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, writeFileSync, renameSync as renameSync2 } from "fs";
621
+ import { join as join6, basename as basename3 } from "path";
540
622
  function getMonthDir(notesDir) {
541
623
  const now = /* @__PURE__ */ new Date();
542
624
  const year = String(now.getFullYear());
543
625
  const month = String(now.getMonth() + 1).padStart(2, "0");
544
- const monthDir = join5(notesDir, year, month);
545
- if (!existsSync5(monthDir)) {
546
- mkdirSync2(monthDir, { recursive: true });
626
+ const monthDir = join6(notesDir, year, month);
627
+ if (!existsSync6(monthDir)) {
628
+ mkdirSync3(monthDir, { recursive: true });
547
629
  }
548
630
  return monthDir;
549
631
  }
550
632
  function getNextNoteNumber(notesDir) {
551
633
  const monthDir = getMonthDir(notesDir);
552
- const files = readdirSync3(monthDir).filter((f) => f.match(/^\d{3,4}[\s_-]/)).sort();
634
+ const files = readdirSync4(monthDir).filter((f) => f.match(/^\d{3,4}[\s_-]/)).sort();
553
635
  if (files.length === 0) return "0001";
554
636
  let maxNumber = 0;
555
637
  for (const file of files) {
@@ -562,27 +644,27 @@ function getNextNoteNumber(notesDir) {
562
644
  return String(maxNumber + 1).padStart(4, "0");
563
645
  }
564
646
  function getCurrentNotePath(notesDir) {
565
- if (!existsSync5(notesDir)) return null;
647
+ if (!existsSync6(notesDir)) return null;
566
648
  const findLatestIn = (dir) => {
567
- if (!existsSync5(dir)) return null;
568
- const files = readdirSync3(dir).filter((f) => f.match(/^\d{3,4}[\s_-].*\.md$/)).sort((a, b) => {
649
+ if (!existsSync6(dir)) return null;
650
+ const files = readdirSync4(dir).filter((f) => f.match(/^\d{3,4}[\s_-].*\.md$/)).sort((a, b) => {
569
651
  const numA = parseInt(a.match(/^(\d+)/)?.[1] || "0", 10);
570
652
  const numB = parseInt(b.match(/^(\d+)/)?.[1] || "0", 10);
571
653
  return numA - numB;
572
654
  });
573
655
  if (files.length === 0) return null;
574
- return join5(dir, files[files.length - 1]);
656
+ return join6(dir, files[files.length - 1]);
575
657
  };
576
658
  const now = /* @__PURE__ */ new Date();
577
659
  const year = String(now.getFullYear());
578
660
  const month = String(now.getMonth() + 1).padStart(2, "0");
579
- const currentMonthDir = join5(notesDir, year, month);
661
+ const currentMonthDir = join6(notesDir, year, month);
580
662
  const found = findLatestIn(currentMonthDir);
581
663
  if (found) return found;
582
664
  const prevDate = new Date(now.getFullYear(), now.getMonth() - 1, 1);
583
665
  const prevYear = String(prevDate.getFullYear());
584
666
  const prevMonth = String(prevDate.getMonth() + 1).padStart(2, "0");
585
- const prevMonthDir = join5(notesDir, prevYear, prevMonth);
667
+ const prevMonthDir = join6(notesDir, prevYear, prevMonth);
586
668
  const prevFound = findLatestIn(prevMonthDir);
587
669
  if (prevFound) return prevFound;
588
670
  return findLatestIn(notesDir);
@@ -592,7 +674,7 @@ function createSessionNote(notesDir, description) {
592
674
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
593
675
  const monthDir = getMonthDir(notesDir);
594
676
  const filename = `${noteNumber} - ${date} - New Session.md`;
595
- const filepath = join5(monthDir, filename);
677
+ const filepath = join6(monthDir, filename);
596
678
  const content = `# Session ${noteNumber}: ${description}
597
679
 
598
680
  **Date:** ${date}
@@ -630,16 +712,16 @@ function findPaiBinary() {
630
712
  `${process.env.HOME}/.local/bin/pai`
631
713
  ];
632
714
  for (const p of fallbacks) {
633
- if (existsSync6(p)) return p;
715
+ if (existsSync7(p)) return p;
634
716
  }
635
717
  }
636
718
  return "pai";
637
719
  }
638
720
  function getRoutedNotesPath() {
639
- const routingFile = join6(PAI_DIR, "session-routing.json");
640
- if (!existsSync6(routingFile)) return null;
721
+ const routingFile = sessionRoutingPath();
722
+ if (!existsSync7(routingFile)) return null;
641
723
  try {
642
- const routing = JSON.parse(readFileSync5(routingFile, "utf-8"));
724
+ const routing = JSON.parse(readFileSync6(routingFile, "utf-8"));
643
725
  const active = routing?.active_session;
644
726
  if (active?.notes_path) {
645
727
  return active.notes_path;
@@ -664,16 +746,16 @@ var PROJECT_SIGNALS = [
664
746
  "CMakeLists.txt",
665
747
  "tsconfig.json",
666
748
  "CLAUDE.md",
667
- join6("Notes", "PAI.md")
749
+ join7("Notes", "PAI.md")
668
750
  ];
669
751
  function hasProjectSignals(dir) {
670
752
  for (const signal of PROJECT_SIGNALS) {
671
- if (existsSync6(join6(dir, signal))) return true;
753
+ if (existsSync7(join7(dir, signal))) return true;
672
754
  }
673
755
  return false;
674
756
  }
675
757
  function isGuardedPath(dir) {
676
- const home = homedir4();
758
+ const home = homedir5();
677
759
  const resolved = resolve2(dir);
678
760
  if (resolved === home) return true;
679
761
  const parts = resolved.split("/").filter(Boolean);
@@ -707,7 +789,7 @@ async function main() {
707
789
  const cwd = hookInput?.cwd || process.cwd();
708
790
  let projectName = basename4(cwd);
709
791
  if (projectName.toLowerCase() === "notes") {
710
- projectName = basename4(dirname(cwd));
792
+ projectName = basename4(dirname2(cwd));
711
793
  }
712
794
  console.error(`Working directory: ${cwd}`);
713
795
  console.error(`Project: ${projectName}`);
@@ -723,7 +805,7 @@ async function main() {
723
805
  for (const path of claudeMdPaths) {
724
806
  console.error(` - ${path}`);
725
807
  try {
726
- const content = readFileSync5(path, "utf-8");
808
+ const content = readFileSync6(path, "utf-8");
727
809
  claudeMdContents.push({ path, content });
728
810
  console.error(` Read ${content.length} chars`);
729
811
  } catch (error) {
@@ -737,9 +819,9 @@ async function main() {
737
819
  const routedPath = getRoutedNotesPath();
738
820
  let notesDir;
739
821
  if (routedPath) {
740
- const { mkdirSync: mkdirSync3 } = await import("fs");
741
- if (!existsSync6(routedPath)) {
742
- mkdirSync3(routedPath, { recursive: true });
822
+ const { mkdirSync: mkdirSync4 } = await import("fs");
823
+ if (!existsSync7(routedPath)) {
824
+ mkdirSync4(routedPath, { recursive: true });
743
825
  console.error(`Created routed Notes: ${routedPath}`);
744
826
  } else {
745
827
  console.error(`Notes directory: ${routedPath} (routed via pai route)`);
@@ -751,9 +833,9 @@ async function main() {
751
833
  notesDir = notesInfo.path;
752
834
  console.error(`Notes directory: ${notesDir} (local)`);
753
835
  } else {
754
- if (!existsSync6(notesInfo.path)) {
755
- const { mkdirSync: mkdirSync3 } = await import("fs");
756
- mkdirSync3(notesInfo.path, { recursive: true });
836
+ if (!existsSync7(notesInfo.path)) {
837
+ const { mkdirSync: mkdirSync4 } = await import("fs");
838
+ mkdirSync4(notesInfo.path, { recursive: true });
757
839
  console.error(`Created central Notes: ${notesInfo.path}`);
758
840
  } else {
759
841
  console.error(`Notes directory: ${notesInfo.path} (central)`);
@@ -762,7 +844,7 @@ async function main() {
762
844
  }
763
845
  }
764
846
  const projectDir = getProjectDir(cwd);
765
- if (existsSync6(projectDir)) {
847
+ if (existsSync7(projectDir)) {
766
848
  try {
767
849
  const own = hookInput?.session_id ? `${hookInput.session_id}.jsonl` : void 0;
768
850
  archiveSessionFilesToSessionsDir(projectDir, own, true);
@@ -771,11 +853,11 @@ async function main() {
771
853
  }
772
854
  }
773
855
  const todoPath = findTodoPath(cwd);
774
- const hasTodo = existsSync6(todoPath);
856
+ const hasTodo = existsSync7(todoPath);
775
857
  if (hasTodo) {
776
858
  console.error(`TODO.md: ${todoPath}`);
777
859
  } else {
778
- const newTodoPath = join6(notesDir, "TODO.md");
860
+ const newTodoPath = join7(notesDir, "TODO.md");
779
861
  const { writeFileSync: writeFileSync2 } = await import("fs");
780
862
  writeFileSync2(newTodoPath, `# TODO
781
863
 
@@ -802,7 +884,7 @@ async function main() {
802
884
  console.error(`
803
885
  Using existing session note: ${basename4(activeNotePath)}`);
804
886
  try {
805
- const content = readFileSync5(activeNotePath, "utf-8");
887
+ const content = readFileSync6(activeNotePath, "utf-8");
806
888
  const lines = content.split("\n").slice(0, 12);
807
889
  console.error("--- Current Note Preview ---");
808
890
  for (const line of lines) {
@@ -813,9 +895,9 @@ Using existing session note: ${basename4(activeNotePath)}`);
813
895
  }
814
896
  }
815
897
  }
816
- if (existsSync6(todoPath)) {
898
+ if (existsSync7(todoPath)) {
817
899
  try {
818
- const todoContent = readFileSync5(todoPath, "utf-8");
900
+ const todoContent = readFileSync6(todoPath, "utf-8");
819
901
  const todoLines = todoContent.split("\n").filter((l) => l.includes("[ ]")).slice(0, 5);
820
902
  if (todoLines.length > 0) {
821
903
  console.error("\nOpen TODOs:");
@@ -926,9 +1008,9 @@ Session Commands:
926
1008
  </system-reminder>
927
1009
  `;
928
1010
  console.log(reminder);
929
- if (existsSync6(todoPath)) {
1011
+ if (existsSync7(todoPath)) {
930
1012
  try {
931
- const checkpoint = readContinueCheckpoint(readFileSync5(todoPath, "utf-8"));
1013
+ const checkpoint = readContinueCheckpoint(readFileSync6(todoPath, "utf-8"));
932
1014
  if (checkpoint) {
933
1015
  const from = checkpoint.meta?.session ? `
934
1016
  From session: ${checkpoint.meta.session}` : "";