prjct-cli 3.95.0 → 3.97.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 (576) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/bin/prjct.cjs +14 -0
  3. package/dist/bin/core-chunks/agent-HCP5FF77.mjs +31 -0
  4. package/dist/bin/core-chunks/agent-codenames-7N4DU62I.mjs +7 -0
  5. package/dist/bin/core-chunks/agent-identity-4KFRR5OU.mjs +7 -0
  6. package/dist/bin/core-chunks/agent-runtime-registry-3RMVBEV2.mjs +7 -0
  7. package/dist/bin/core-chunks/agent-switch-AVSX6SLY.mjs +7 -0
  8. package/dist/bin/core-chunks/agents-OAQXBGH3.mjs +10 -0
  9. package/dist/bin/core-chunks/ai-provider-RVXK7D7R.mjs +7 -0
  10. package/dist/bin/core-chunks/analysis-3A7ODSSI.mjs +41 -0
  11. package/dist/bin/core-chunks/auth-config-KWLVKHCY.mjs +7 -0
  12. package/dist/bin/core-chunks/auto-flush-EWSVMKQN.mjs +7 -0
  13. package/dist/bin/core-chunks/auto-updater-PKYQRBGQ.mjs +8 -0
  14. package/dist/bin/core-chunks/bin-commands-LLHG2NSY.mjs +21 -0
  15. package/dist/bin/core-chunks/capture-7LQ52T6L.mjs +7 -0
  16. package/dist/bin/core-chunks/capture-gate-M4HM7WAI.mjs +7 -0
  17. package/dist/bin/core-chunks/ceremonies-4OZ3FKRE.mjs +19 -0
  18. package/dist/bin/core-chunks/changelog-CUNVCEL5.mjs +10 -0
  19. package/dist/bin/core-chunks/chunk-225DWS4D.mjs +7 -0
  20. package/dist/bin/core-chunks/chunk-24EN5Y62.mjs +48 -0
  21. package/dist/bin/core-chunks/chunk-2EEMQV7N.mjs +9 -0
  22. package/dist/bin/core-chunks/chunk-2I5PUQWY.mjs +7 -0
  23. package/dist/bin/core-chunks/chunk-2JJM3YMW.mjs +44 -0
  24. package/dist/bin/core-chunks/chunk-2NI4EEK2.mjs +8 -0
  25. package/dist/bin/core-chunks/chunk-2TJRTFIS.mjs +9 -0
  26. package/dist/bin/core-chunks/chunk-2ZPM4Z6W.mjs +17 -0
  27. package/dist/bin/core-chunks/chunk-3FXNIJCS.mjs +8 -0
  28. package/dist/bin/core-chunks/chunk-3JD6KRNJ.mjs +8 -0
  29. package/dist/bin/core-chunks/chunk-3TRXQAU4.mjs +7 -0
  30. package/dist/bin/core-chunks/chunk-3USVY66O.mjs +7 -0
  31. package/dist/bin/core-chunks/chunk-45LKWJ5D.mjs +7 -0
  32. package/dist/bin/core-chunks/chunk-4IE7LRH3.mjs +7 -0
  33. package/dist/bin/core-chunks/chunk-4MR5XSLO.mjs +8 -0
  34. package/dist/bin/core-chunks/chunk-4PPIE6GA.mjs +102 -0
  35. package/dist/bin/core-chunks/chunk-4PRD4EU2.mjs +7 -0
  36. package/dist/bin/core-chunks/chunk-4T7NGLNQ.mjs +16 -0
  37. package/dist/bin/core-chunks/chunk-53ZPEZLU.mjs +8 -0
  38. package/dist/bin/core-chunks/chunk-56FW4P6U.mjs +10 -0
  39. package/dist/bin/core-chunks/chunk-5EF5EOCL.mjs +7 -0
  40. package/dist/bin/core-chunks/chunk-5MN22JFI.mjs +19 -0
  41. package/dist/bin/core-chunks/chunk-5ONMON5L.mjs +13 -0
  42. package/dist/bin/core-chunks/chunk-5UUITMRX.mjs +9 -0
  43. package/dist/bin/core-chunks/chunk-5YLI5V3Q.mjs +8 -0
  44. package/dist/bin/core-chunks/chunk-5YSPND5J.mjs +9 -0
  45. package/dist/bin/core-chunks/chunk-623SNKDH.mjs +7 -0
  46. package/dist/bin/core-chunks/chunk-6AFXUX2M.mjs +9 -0
  47. package/dist/bin/core-chunks/chunk-6FFOWWH2.mjs +17 -0
  48. package/dist/bin/core-chunks/chunk-6FUCOGOW.mjs +7 -0
  49. package/dist/bin/core-chunks/chunk-6OYLZ4NM.mjs +10 -0
  50. package/dist/bin/core-chunks/chunk-6P4GMVUZ.mjs +18 -0
  51. package/dist/bin/core-chunks/chunk-6RT2P22O.mjs +7 -0
  52. package/dist/bin/core-chunks/chunk-6XTLPAPZ.mjs +15 -0
  53. package/dist/bin/core-chunks/chunk-76YMLNLF.mjs +7 -0
  54. package/dist/bin/core-chunks/chunk-7CI4AMVO.mjs +7 -0
  55. package/dist/bin/core-chunks/chunk-7QMBIMEX.mjs +64 -0
  56. package/dist/bin/core-chunks/chunk-7QTE6X4J.mjs +7 -0
  57. package/dist/bin/core-chunks/chunk-7ZHWJSW5.mjs +8 -0
  58. package/dist/bin/core-chunks/chunk-AJTBFIH2.mjs +9 -0
  59. package/dist/bin/core-chunks/chunk-AJXELVNH.mjs +7 -0
  60. package/dist/bin/core-chunks/chunk-ANVCA6LF.mjs +7 -0
  61. package/dist/bin/core-chunks/chunk-AS3LWTQ4.mjs +16 -0
  62. package/dist/bin/core-chunks/chunk-B7AQHL7B.mjs +7 -0
  63. package/dist/bin/core-chunks/chunk-BQKDJ3U6.mjs +8 -0
  64. package/dist/bin/core-chunks/chunk-BSR3XUBD.mjs +24 -0
  65. package/dist/bin/core-chunks/chunk-BTCCUMKI.mjs +12 -0
  66. package/dist/bin/core-chunks/chunk-BTSHD3XJ.mjs +9 -0
  67. package/dist/bin/core-chunks/chunk-C35JQUWD.mjs +8 -0
  68. package/dist/bin/core-chunks/chunk-C7YBUD4K.mjs +10 -0
  69. package/dist/bin/core-chunks/chunk-CDLZLTRY.mjs +10 -0
  70. package/dist/bin/core-chunks/chunk-CEOTHJIY.mjs +10 -0
  71. package/dist/bin/core-chunks/chunk-CFD6CW7T.mjs +46 -0
  72. package/dist/bin/core-chunks/chunk-CKYBGRCF.mjs +8 -0
  73. package/dist/bin/core-chunks/chunk-CNWEQUB7.mjs +7 -0
  74. package/dist/bin/core-chunks/chunk-CUIB6CTG.mjs +20 -0
  75. package/dist/bin/core-chunks/chunk-CWLGRKA7.mjs +6 -0
  76. package/dist/bin/core-chunks/chunk-CXNVDJNN.mjs +7 -0
  77. package/dist/bin/core-chunks/chunk-D62TAZG6.mjs +9 -0
  78. package/dist/bin/core-chunks/chunk-DCVPNFS4.mjs +8 -0
  79. package/dist/bin/core-chunks/chunk-DEYAQEF5.mjs +7 -0
  80. package/dist/bin/core-chunks/chunk-DIEPWXJJ.mjs +7 -0
  81. package/dist/bin/core-chunks/chunk-DMO3ZFUG.mjs +1259 -0
  82. package/dist/bin/core-chunks/chunk-DN46DLU3.mjs +10 -0
  83. package/dist/bin/core-chunks/chunk-DOJPSIMG.mjs +7 -0
  84. package/dist/bin/core-chunks/chunk-DZVOFEM5.mjs +7 -0
  85. package/dist/bin/core-chunks/chunk-E5QQDYBR.mjs +7 -0
  86. package/dist/bin/core-chunks/chunk-E73HSXCX.mjs +7 -0
  87. package/dist/bin/core-chunks/chunk-EFSPBB4S.mjs +8 -0
  88. package/dist/bin/core-chunks/chunk-EHVU2SMR.mjs +34 -0
  89. package/dist/bin/core-chunks/chunk-ESB4ALH2.mjs +7 -0
  90. package/dist/bin/core-chunks/chunk-EZRNQXCC.mjs +7 -0
  91. package/dist/bin/core-chunks/chunk-F2FKQUYE.mjs +19 -0
  92. package/dist/bin/core-chunks/chunk-F7OOBAJO.mjs +30 -0
  93. package/dist/bin/core-chunks/chunk-FATYLG3L.mjs +14 -0
  94. package/dist/bin/core-chunks/chunk-FOWTB762.mjs +7 -0
  95. package/dist/bin/core-chunks/chunk-GDLAQV3Q.mjs +14 -0
  96. package/dist/bin/core-chunks/chunk-GGGDYL4P.mjs +7 -0
  97. package/dist/bin/core-chunks/chunk-GHSRH4GL.mjs +8 -0
  98. package/dist/bin/core-chunks/chunk-GOIBJ7PV.mjs +7 -0
  99. package/dist/bin/core-chunks/chunk-GSNQKBHZ.mjs +11 -0
  100. package/dist/bin/core-chunks/chunk-GTG67Z45.mjs +11 -0
  101. package/dist/bin/core-chunks/chunk-H2KNJUPN.mjs +23 -0
  102. package/dist/bin/core-chunks/chunk-HCPQZRR3.mjs +7 -0
  103. package/dist/bin/core-chunks/chunk-HEXSVBUP.mjs +8 -0
  104. package/dist/bin/core-chunks/chunk-HPCSSJXH.mjs +7 -0
  105. package/dist/bin/core-chunks/chunk-HU5ERAAV.mjs +8 -0
  106. package/dist/bin/core-chunks/chunk-HYIT7MF5.mjs +8 -0
  107. package/dist/bin/core-chunks/chunk-HYMJVHAX.mjs +13 -0
  108. package/dist/bin/core-chunks/chunk-ID2C2S33.mjs +18 -0
  109. package/dist/bin/core-chunks/chunk-ID5KE74L.mjs +7 -0
  110. package/dist/bin/core-chunks/chunk-IFLBZKKK.mjs +14 -0
  111. package/dist/bin/core-chunks/chunk-IMQCXC3R.mjs +30 -0
  112. package/dist/bin/core-chunks/chunk-INJ5WT2D.mjs +7 -0
  113. package/dist/bin/core-chunks/chunk-INM5COWM.mjs +7 -0
  114. package/dist/bin/core-chunks/chunk-IOFCSTGM.mjs +7 -0
  115. package/dist/bin/core-chunks/chunk-IVGWOY3U.mjs +8 -0
  116. package/dist/bin/core-chunks/chunk-J7T5IEFJ.mjs +15 -0
  117. package/dist/bin/core-chunks/chunk-JCWA7NLM.mjs +7 -0
  118. package/dist/bin/core-chunks/chunk-JPMUJY42.mjs +7 -0
  119. package/dist/bin/core-chunks/chunk-JT4RNQ67.mjs +15 -0
  120. package/dist/bin/core-chunks/chunk-K25HGTC3.mjs +10 -0
  121. package/dist/bin/core-chunks/chunk-KIRU4QFX.mjs +7 -0
  122. package/dist/bin/core-chunks/chunk-KKIJAEYU.mjs +7 -0
  123. package/dist/bin/core-chunks/chunk-KPR5TWSN.mjs +7 -0
  124. package/dist/bin/core-chunks/chunk-KUQLXY2P.mjs +11 -0
  125. package/dist/bin/core-chunks/chunk-KWC2PCPC.mjs +10 -0
  126. package/dist/bin/core-chunks/chunk-L4TUXFCL.mjs +7 -0
  127. package/dist/bin/core-chunks/chunk-L5LFLI4R.mjs +7 -0
  128. package/dist/bin/core-chunks/chunk-LZC6NGB6.mjs +50 -0
  129. package/dist/bin/core-chunks/chunk-MCY7OXED.mjs +10 -0
  130. package/dist/bin/core-chunks/chunk-MDONTD7O.mjs +21 -0
  131. package/dist/bin/core-chunks/chunk-MG3YN3AI.mjs +7 -0
  132. package/dist/bin/core-chunks/chunk-MR5XXHRK.mjs +8 -0
  133. package/dist/bin/core-chunks/chunk-MTDCRYLP.mjs +7 -0
  134. package/dist/bin/core-chunks/chunk-MXJKULJY.mjs +9 -0
  135. package/dist/bin/core-chunks/chunk-NINFE7GS.mjs +9 -0
  136. package/dist/bin/core-chunks/chunk-NNOX3UU4.mjs +7 -0
  137. package/dist/bin/core-chunks/chunk-NOHSLOLL.mjs +7 -0
  138. package/dist/bin/core-chunks/chunk-NXUIMC22.mjs +13 -0
  139. package/dist/bin/core-chunks/chunk-NZKUCQZK.mjs +8 -0
  140. package/dist/bin/core-chunks/chunk-O5N6XYPU.mjs +8 -0
  141. package/dist/bin/core-chunks/chunk-OIE3AKKO.mjs +7 -0
  142. package/dist/bin/core-chunks/chunk-OYXQRBVM.mjs +10 -0
  143. package/dist/bin/core-chunks/chunk-P2KU4FFA.mjs +11 -0
  144. package/dist/bin/core-chunks/chunk-P53YMOKR.mjs +7 -0
  145. package/dist/bin/core-chunks/chunk-PIA26GWG.mjs +7 -0
  146. package/dist/bin/core-chunks/chunk-PPERWRFS.mjs +13 -0
  147. package/dist/bin/core-chunks/chunk-PPSVWUXC.mjs +15 -0
  148. package/dist/bin/core-chunks/chunk-PWL3KS7Y.mjs +7 -0
  149. package/dist/bin/core-chunks/chunk-Q3LUL6LL.mjs +7 -0
  150. package/dist/bin/core-chunks/chunk-Q6C27OL7.mjs +7 -0
  151. package/dist/bin/core-chunks/chunk-QAIEAOJF.mjs +7 -0
  152. package/dist/bin/core-chunks/chunk-QLMZW4K7.mjs +7 -0
  153. package/dist/bin/core-chunks/chunk-QZ7T2EYR.mjs +25 -0
  154. package/dist/bin/core-chunks/chunk-R7LLMJDP.mjs +7 -0
  155. package/dist/bin/core-chunks/chunk-RACISWUV.mjs +10 -0
  156. package/dist/bin/core-chunks/chunk-RCIWCKL7.mjs +9 -0
  157. package/dist/bin/core-chunks/chunk-ROOCBUKH.mjs +8 -0
  158. package/dist/bin/core-chunks/chunk-RP7F67ZT.mjs +7 -0
  159. package/dist/bin/core-chunks/chunk-RXXXA7Z6.mjs +7 -0
  160. package/dist/bin/core-chunks/chunk-RXZJB43D.mjs +7 -0
  161. package/dist/bin/core-chunks/chunk-S6FBPXQL.mjs +9 -0
  162. package/dist/bin/core-chunks/chunk-SLYLGDX7.mjs +8 -0
  163. package/dist/bin/core-chunks/chunk-SO3ZPNWT.mjs +7 -0
  164. package/dist/bin/core-chunks/chunk-SRJEX6XF.mjs +12 -0
  165. package/dist/bin/core-chunks/chunk-SROBBOJB.mjs +11 -0
  166. package/dist/bin/core-chunks/chunk-TDTPDVUM.mjs +8 -0
  167. package/dist/bin/core-chunks/chunk-TGNZI4KF.mjs +28 -0
  168. package/dist/bin/core-chunks/chunk-TIBYHZFA.mjs +8 -0
  169. package/dist/bin/core-chunks/chunk-TILUQF6L.mjs +8 -0
  170. package/dist/bin/core-chunks/chunk-TTN2CFZC.mjs +7 -0
  171. package/dist/bin/core-chunks/chunk-U24YKPYX.mjs +7 -0
  172. package/dist/bin/core-chunks/chunk-U55OPVYR.mjs +9 -0
  173. package/dist/bin/core-chunks/chunk-UE3XKXWM.mjs +7 -0
  174. package/dist/bin/core-chunks/chunk-UHXV7MDW.mjs +12 -0
  175. package/dist/bin/core-chunks/chunk-UNNY2IWZ.mjs +9 -0
  176. package/dist/bin/core-chunks/chunk-UT425KVX.mjs +10 -0
  177. package/dist/bin/core-chunks/chunk-UYMZ3NAF.mjs +8 -0
  178. package/dist/bin/core-chunks/chunk-V3Y3G2DE.mjs +8 -0
  179. package/dist/bin/core-chunks/chunk-V5VCXMKO.mjs +52 -0
  180. package/dist/bin/core-chunks/chunk-V6L5PLD7.mjs +18 -0
  181. package/dist/bin/core-chunks/chunk-V7R3L54M.mjs +7 -0
  182. package/dist/bin/core-chunks/chunk-V7VA4EQX.mjs +7 -0
  183. package/dist/bin/core-chunks/chunk-VCSESVZ4.mjs +9 -0
  184. package/dist/bin/core-chunks/chunk-VCYVYFWE.mjs +9 -0
  185. package/dist/bin/core-chunks/chunk-VDXTMAMO.mjs +7 -0
  186. package/dist/bin/core-chunks/chunk-VILH3VYH.mjs +103 -0
  187. package/dist/bin/core-chunks/chunk-VRFYDYQY.mjs +7 -0
  188. package/dist/bin/core-chunks/chunk-VWFVSNQT.mjs +7 -0
  189. package/dist/bin/core-chunks/chunk-WGDE3L33.mjs +7 -0
  190. package/dist/bin/core-chunks/chunk-WP5IU4W4.mjs +7 -0
  191. package/dist/bin/core-chunks/chunk-WSVMQYYU.mjs +12 -0
  192. package/dist/bin/core-chunks/chunk-WTDUJB4I.mjs +8 -0
  193. package/dist/bin/core-chunks/chunk-WZXUFSVT.mjs +25 -0
  194. package/dist/bin/core-chunks/chunk-X35YYOFE.mjs +18 -0
  195. package/dist/bin/core-chunks/chunk-X4FR5S7E.mjs +9 -0
  196. package/dist/bin/core-chunks/chunk-XC6YAP36.mjs +7 -0
  197. package/dist/bin/core-chunks/chunk-XLFEWZRA.mjs +7 -0
  198. package/dist/bin/core-chunks/chunk-XPRLQIVQ.mjs +7 -0
  199. package/dist/bin/core-chunks/chunk-XSZG3CBO.mjs +7 -0
  200. package/dist/bin/core-chunks/chunk-XU3BQPBU.mjs +7 -0
  201. package/dist/bin/core-chunks/chunk-XYDLXF5A.mjs +8 -0
  202. package/dist/bin/core-chunks/chunk-Y5SEUYET.mjs +7 -0
  203. package/dist/bin/core-chunks/chunk-Y7XOKG4O.mjs +7 -0
  204. package/dist/bin/core-chunks/chunk-YEALP3WX.mjs +7 -0
  205. package/dist/bin/core-chunks/chunk-YJOC2JJK.mjs +12 -0
  206. package/dist/bin/core-chunks/chunk-YLYAYRSJ.mjs +8 -0
  207. package/dist/bin/core-chunks/chunk-YOGI4WE6.mjs +8 -0
  208. package/dist/bin/core-chunks/chunk-YQ6HM3YO.mjs +10 -0
  209. package/dist/bin/core-chunks/chunk-YZEO5DZA.mjs +7 -0
  210. package/dist/bin/core-chunks/chunk-ZBBNCCGV.mjs +12 -0
  211. package/dist/bin/core-chunks/chunk-ZHTYSYZC.mjs +7 -0
  212. package/dist/bin/core-chunks/chunk-ZK7BMUMR.mjs +7 -0
  213. package/dist/bin/core-chunks/chunk-ZKJZDOPT.mjs +14 -0
  214. package/dist/bin/core-chunks/chunk-ZQHSJ6FF.mjs +20 -0
  215. package/dist/bin/core-chunks/chunk-ZS7XJUPE.mjs +7 -0
  216. package/dist/bin/core-chunks/chunk-ZXTJLMVZ.mjs +7 -0
  217. package/dist/bin/core-chunks/cleanup-installs-WHXUGAHM.mjs +7 -0
  218. package/dist/bin/core-chunks/client-D43KKUYH.mjs +8 -0
  219. package/dist/bin/core-chunks/closest-command-YYNABM7V.mjs +7 -0
  220. package/dist/bin/core-chunks/cloud-FFUJZLDV.mjs +14 -0
  221. package/dist/bin/core-chunks/code-SU7GCPH6.mjs +12 -0
  222. package/dist/bin/core-chunks/code-graph-cloud-G3WQBICY.mjs +7 -0
  223. package/dist/bin/core-chunks/codex-hooks-GOLMCL2Q.mjs +7 -0
  224. package/dist/bin/core-chunks/codex-mcp-K4X2UIQF.mjs +7 -0
  225. package/dist/bin/core-chunks/codex-skill-3HNVU4T4.mjs +7 -0
  226. package/dist/bin/core-chunks/command-installer-XIQK2G6W.mjs +7 -0
  227. package/dist/bin/core-chunks/config-W3RHV3GK.mjs +8 -0
  228. package/dist/bin/core-chunks/config-manager-QVFHXIKI.mjs +7 -0
  229. package/dist/bin/core-chunks/content-bound-stamp-2PJNI4JC.mjs +7 -0
  230. package/dist/bin/core-chunks/context-4KGTUAC4.mjs +38 -0
  231. package/dist/bin/core-chunks/context-DDHC7VIC.mjs +10 -0
  232. package/dist/bin/core-chunks/context-checkpoint-4CEUPEVG.mjs +27 -0
  233. package/dist/bin/core-chunks/context-pressure-5URQVNBC.mjs +7 -0
  234. package/dist/bin/core-chunks/context-tiers-4S6H22NP.mjs +7 -0
  235. package/dist/bin/core-chunks/context7-service-AZWDYK5Z.mjs +7 -0
  236. package/dist/bin/core-chunks/core-PR5WEQCS.mjs +70 -0
  237. package/dist/bin/core-chunks/crew-JQCG6NS3.mjs +24 -0
  238. package/dist/bin/core-chunks/cursor-hooks-DGDJVAI6.mjs +7 -0
  239. package/dist/bin/core-chunks/custom-workflow-storage-EBEIG54R.mjs +7 -0
  240. package/dist/bin/core-chunks/cwd-changed-ODKZVSPB.mjs +7 -0
  241. package/dist/bin/core-chunks/cycle-budget-card-H37XRAIX.mjs +7 -0
  242. package/dist/bin/core-chunks/daemon-2NQTBFVR.mjs +13 -0
  243. package/dist/bin/core-chunks/database-UU2ZXSD4.mjs +7 -0
  244. package/dist/bin/core-chunks/delivery-geometry-GSJ6LXUC.mjs +7 -0
  245. package/dist/bin/core-chunks/detect-changes-2YIEX7AY.mjs +7 -0
  246. package/dist/bin/core-chunks/detection-KKDZYWVD.mjs +7 -0
  247. package/dist/bin/core-chunks/developer-evolution-AVAXGDKQ.mjs +11 -0
  248. package/dist/bin/core-chunks/developer-profile-MRPBWL2K.mjs +7 -0
  249. package/dist/bin/core-chunks/discuss-lock-CWXKBBYJ.mjs +7 -0
  250. package/dist/bin/core-chunks/distill-MLDZG5RA.mjs +7 -0
  251. package/dist/bin/core-chunks/doctor-heal-ZUZ2RHGY.mjs +7 -0
  252. package/dist/bin/core-chunks/doctor-service-WXLB2FEE.mjs +8 -0
  253. package/dist/bin/core-chunks/drift-refresh-XPJAO2B3.mjs +7 -0
  254. package/dist/bin/core-chunks/dynasty-outcomes-H2O546OL.mjs +11 -0
  255. package/dist/bin/core-chunks/editors-config-ELAQA6RV.mjs +7 -0
  256. package/dist/bin/core-chunks/embeddings-7A5Z5I67.mjs +7 -0
  257. package/dist/bin/core-chunks/enriched-recall-YXK7EIKH.mjs +7 -0
  258. package/dist/bin/core-chunks/eval-4YFUBFLV.mjs +76 -0
  259. package/dist/bin/core-chunks/exec-34V6SJYO.mjs +7 -0
  260. package/dist/bin/core-chunks/file-helper-LLQKU6YF.mjs +7 -0
  261. package/dist/bin/core-chunks/format-5V6GF6JJ.mjs +7 -0
  262. package/dist/bin/core-chunks/gemini-settings-ZTU3VQU3.mjs +7 -0
  263. package/dist/bin/core-chunks/git-context-ZSWE3KWM.mjs +8 -0
  264. package/dist/bin/core-chunks/git-helpers-UC53D4FT.mjs +7 -0
  265. package/dist/bin/core-chunks/grok-mcp-F3SRFMCW.mjs +7 -0
  266. package/dist/bin/core-chunks/grok-plugin-4CE2WUYI.mjs +7 -0
  267. package/dist/bin/core-chunks/grok-skill-GLSBOOKW.mjs +7 -0
  268. package/dist/bin/core-chunks/guard-FJBJ6IAE.mjs +13 -0
  269. package/dist/bin/core-chunks/guards-LFUFKVVH.mjs +7 -0
  270. package/dist/bin/core-chunks/handoff-storage-NGUA4Y2L.mjs +7 -0
  271. package/dist/bin/core-chunks/harness-FN3HASSA.mjs +43 -0
  272. package/dist/bin/core-chunks/health-W2VWME7Z.mjs +11 -0
  273. package/dist/bin/core-chunks/help-I37I3V2R.mjs +14 -0
  274. package/dist/bin/core-chunks/hooks-service-C2P5DRCH.mjs +91 -0
  275. package/dist/bin/core-chunks/infer-memory-file-ATP7PSAQ.mjs +7 -0
  276. package/dist/bin/core-chunks/install-XP4S6HWQ.mjs +9 -0
  277. package/dist/bin/core-chunks/judgment-GJE332LF.mjs +21 -0
  278. package/dist/bin/core-chunks/judgment-ledger-storage-ZTYXPMM4.mjs +7 -0
  279. package/dist/bin/core-chunks/judgment-orchestrator-E3SO3NVE.mjs +7 -0
  280. package/dist/bin/core-chunks/judgment-receipt-WT4EMCAV.mjs +7 -0
  281. package/dist/bin/core-chunks/kimi-hooks-2UEUIKXV.mjs +7 -0
  282. package/dist/bin/core-chunks/kimi-mcp-DJCXZ2JY.mjs +7 -0
  283. package/dist/bin/core-chunks/land-cue-5USQ64MS.mjs +8 -0
  284. package/dist/bin/core-chunks/land-rho-ISNVEPVC.mjs +8 -0
  285. package/dist/bin/core-chunks/land-synthesis-CHARJMUP.mjs +7 -0
  286. package/dist/bin/core-chunks/lean-L53CKZNH.mjs +34 -0
  287. package/dist/bin/core-chunks/legacy-crew-sweep-2TLKJTHI.mjs +23 -0
  288. package/dist/bin/core-chunks/living-context-contract-HZIVBMXX.mjs +7 -0
  289. package/dist/bin/core-chunks/llm-XMH7WTHV.mjs +18 -0
  290. package/dist/bin/core-chunks/mcp-FLVIZBV2.mjs +17 -0
  291. package/dist/bin/core-chunks/memory-dream-EJWI4FJO.mjs +14 -0
  292. package/dist/bin/core-chunks/memory-export-27HTNNFI.mjs +13 -0
  293. package/dist/bin/core-chunks/memory-index-BRZDZ2BY.mjs +7 -0
  294. package/dist/bin/core-chunks/notification-KJ4FQJAW.mjs +7 -0
  295. package/dist/bin/core-chunks/notify-76B7AICZ.mjs +9 -0
  296. package/dist/bin/core-chunks/nyquist-lite-A23B7G4B.mjs +9 -0
  297. package/dist/bin/core-chunks/one-breath-install-LVNIVN6S.mjs +7 -0
  298. package/dist/bin/core-chunks/opencode-mcp-5YSIYDI3.mjs +7 -0
  299. package/dist/bin/core-chunks/output-D27IOQXR.mjs +7 -0
  300. package/dist/bin/core-chunks/pack-integrity-GXN67LJB.mjs +9 -0
  301. package/dist/bin/core-chunks/pack-manager-46SPIPPD.mjs +7 -0
  302. package/dist/bin/core-chunks/package-DCGCOAGQ.mjs +7 -0
  303. package/dist/bin/core-chunks/package-legitimacy-VHHGI4P7.mjs +7 -0
  304. package/dist/bin/core-chunks/path-manager-E5DCU5LP.mjs +7 -0
  305. package/dist/bin/core-chunks/performance-tracker-BFBNR3LY.mjs +7 -0
  306. package/dist/bin/core-chunks/pi-skill-SDHTUK3V.mjs +7 -0
  307. package/dist/bin/core-chunks/planning-S3MYVWH6.mjs +8 -0
  308. package/dist/bin/core-chunks/post-edit-5YSNEMK7.mjs +7 -0
  309. package/dist/bin/core-chunks/pr-convention-37YHTUKM.mjs +7 -0
  310. package/dist/bin/core-chunks/pre-bash-GLDILCRF.mjs +10 -0
  311. package/dist/bin/core-chunks/pre-commit-U6HPPNIC.mjs +7 -0
  312. package/dist/bin/core-chunks/pre-edit-PEYQA6P6.mjs +8 -0
  313. package/dist/bin/core-chunks/pre-package-76JR5GLO.mjs +7 -0
  314. package/dist/bin/core-chunks/pre-search-5EHNUOP3.mjs +8 -0
  315. package/dist/bin/core-chunks/pre-secrets-RJELPDFY.mjs +7 -0
  316. package/dist/bin/core-chunks/precision-classifier-AV75OEVA.mjs +7 -0
  317. package/dist/bin/core-chunks/precision-judgment-MCX4MIIG.mjs +7 -0
  318. package/dist/bin/core-chunks/preferences-BTSYWYUM.mjs +31 -0
  319. package/dist/bin/core-chunks/primitives-IXAYLX7U.mjs +13 -0
  320. package/dist/bin/core-chunks/prjct-md-SUDFWDCS.mjs +7 -0
  321. package/dist/bin/core-chunks/product-KKGJ6MMF.mjs +68 -0
  322. package/dist/bin/core-chunks/project-agent-surfaces-I2CUZUIN.mjs +7 -0
  323. package/dist/bin/core-chunks/project-alignment-ADKW3ZWQ.mjs +17 -0
  324. package/dist/bin/core-chunks/project-file-inventory-XIHHJZUP.mjs +7 -0
  325. package/dist/bin/core-chunks/project-memory-GYLYIJQD.mjs +7 -0
  326. package/dist/bin/core-chunks/project-style-evolution-5W25UPPN.mjs +7 -0
  327. package/dist/bin/core-chunks/prompt-SW5XDRMX.mjs +23 -0
  328. package/dist/bin/core-chunks/protocol-4AJ4J5SI.mjs +7 -0
  329. package/dist/bin/core-chunks/provider-cache-IWVTFLGT.mjs +7 -0
  330. package/dist/bin/core-chunks/provider-status-HQUBKMH5.mjs +7 -0
  331. package/dist/bin/core-chunks/publish-helper-2T2EHM3V.mjs +7 -0
  332. package/dist/bin/core-chunks/purge-5EPJV25P.mjs +7 -0
  333. package/dist/bin/core-chunks/queue-storage-BKH5XX2E.mjs +7 -0
  334. package/dist/bin/core-chunks/registry-LK6IQ5UX.mjs +7 -0
  335. package/dist/bin/core-chunks/reliability-repair-JMPZWDD4.mjs +20 -0
  336. package/dist/bin/core-chunks/removed-verbs-EU3WPRNK.mjs +7 -0
  337. package/dist/bin/core-chunks/retention-S22T3SPT.mjs +7 -0
  338. package/dist/bin/core-chunks/retro-CLKOHAN6.mjs +13 -0
  339. package/dist/bin/core-chunks/review-risk-LLLBKUXT.mjs +12 -0
  340. package/dist/bin/core-chunks/run-recorder-EZQ32M55.mjs +7 -0
  341. package/dist/bin/core-chunks/safe-artifacts-RW5WQUUJ.mjs +9 -0
  342. package/dist/bin/core-chunks/sdd-HE7O6N5S.mjs +9 -0
  343. package/dist/bin/core-chunks/seed-JX7W53E5.mjs +10 -0
  344. package/dist/bin/core-chunks/self-heal-DFUEKNF3.mjs +7 -0
  345. package/dist/bin/core-chunks/session-continuity-BFSW4OL6.mjs +10 -0
  346. package/dist/bin/core-chunks/session-start-HVYUKJL2.mjs +7 -0
  347. package/dist/bin/core-chunks/session-tracker-RG2FBWMS.mjs +7 -0
  348. package/dist/bin/core-chunks/settings-installer-4XHM3HAZ.mjs +7 -0
  349. package/dist/bin/core-chunks/setup-GHS24ER5.mjs +140 -0
  350. package/dist/bin/core-chunks/setup-J4JFYT63.mjs +38 -0
  351. package/dist/bin/core-chunks/shipping-I4D4AVTE.mjs +12 -0
  352. package/dist/bin/core-chunks/signals-digest-V44KYN6Z.mjs +7 -0
  353. package/dist/bin/core-chunks/skill-adherence-MHY4BZL4.mjs +13 -0
  354. package/dist/bin/core-chunks/skill-generator-LKS5BNMY.mjs +7 -0
  355. package/dist/bin/core-chunks/skill-index-L4UWQCQE.mjs +11 -0
  356. package/dist/bin/core-chunks/spec-2XXPLHUZ.mjs +27 -0
  357. package/dist/bin/core-chunks/spec-context-inference-THFMXC7S.mjs +9 -0
  358. package/dist/bin/core-chunks/spec-inventory-2TT7BTFZ.mjs +9 -0
  359. package/dist/bin/core-chunks/spec-service-I23KJKKP.mjs +7 -0
  360. package/dist/bin/core-chunks/spec-task-breakdown-HTG6ME6G.mjs +7 -0
  361. package/dist/bin/core-chunks/state-storage-6CGFWW5D.mjs +7 -0
  362. package/dist/bin/core-chunks/stdin-spill-Y2A6WOOW.mjs +7 -0
  363. package/dist/bin/core-chunks/stop-2H57XCGZ.mjs +15 -0
  364. package/dist/bin/core-chunks/subagent-start-5LPASXOS.mjs +7 -0
  365. package/dist/bin/core-chunks/subagent-stop-ANLSG3KN.mjs +7 -0
  366. package/dist/bin/core-chunks/surface-attribution-WL7S53XX.mjs +7 -0
  367. package/dist/bin/core-chunks/symbol-graph-PCS43SHZ.mjs +7 -0
  368. package/dist/bin/core-chunks/sync-analyzer-M37Q4LE4.mjs +7 -0
  369. package/dist/bin/core-chunks/sync-client-6TAOTJWR.mjs +7 -0
  370. package/dist/bin/core-chunks/sync-cursor-storage-GKO4X2QN.mjs +18 -0
  371. package/dist/bin/core-chunks/task-orchestration-GS4J4KGS.mjs +7 -0
  372. package/dist/bin/core-chunks/task-overview-XSMK7YEN.mjs +7 -0
  373. package/dist/bin/core-chunks/task-service-FK7FC3PE.mjs +7 -0
  374. package/dist/bin/core-chunks/tdd-NQDHU62B.mjs +9 -0
  375. package/dist/bin/core-chunks/team-XZ4Q6UBV.mjs +42 -0
  376. package/dist/bin/core-chunks/template-loader-33OVJ4G5.mjs +7 -0
  377. package/dist/bin/core-chunks/token-backfill-WPXXD5MP.mjs +12 -0
  378. package/dist/bin/core-chunks/token-economics-JZAQJUET.mjs +7 -0
  379. package/dist/bin/core-chunks/transcript-jsonl-OC7TH4Q3.mjs +7 -0
  380. package/dist/bin/core-chunks/trust-boundary-24F662RM.mjs +7 -0
  381. package/dist/bin/core-chunks/uninstall-6NFON7FO.mjs +13 -0
  382. package/dist/bin/core-chunks/update-4IE6SA6M.mjs +11 -0
  383. package/dist/bin/core-chunks/update-checker-FK7MWNWN.mjs +7 -0
  384. package/dist/bin/core-chunks/usefulness-A3GRKFL3.mjs +7 -0
  385. package/dist/bin/core-chunks/user-home-BODIAXR4.mjs +7 -0
  386. package/dist/bin/core-chunks/vault-retire-notice-FDRT7BJG.mjs +8 -0
  387. package/dist/bin/core-chunks/velocity-storage-5T7RYOWH.mjs +7 -0
  388. package/dist/bin/core-chunks/verb-names-QWGYABFH.mjs +7 -0
  389. package/dist/bin/core-chunks/version-252QLBN2.mjs +7 -0
  390. package/dist/bin/core-chunks/watch-service-7ZERG7RC.mjs +9 -0
  391. package/dist/bin/core-chunks/weak-frontier-demo-5C4FR3OA.mjs +7 -0
  392. package/dist/bin/core-chunks/weak-model-mode-DH66XMD2.mjs +7 -0
  393. package/dist/bin/core-chunks/work-graph-JGJWE3AV.mjs +16 -0
  394. package/dist/bin/core-chunks/work-graph-WHMCFN6U.mjs +7 -0
  395. package/dist/bin/core-chunks/work-scope-3LXOEIUX.mjs +7 -0
  396. package/dist/bin/core-chunks/workflow-FGJVLRQ3.mjs +61 -0
  397. package/dist/bin/core-chunks/workflows-reference-UWKRZ6BJ.mjs +7 -0
  398. package/dist/bin/core-chunks/workspace-occupancy-JUXKZBUZ.mjs +7 -0
  399. package/dist/bin/core-chunks/worktree-service-YRRPFU57.mjs +11 -0
  400. package/dist/bin/core-chunks/world-model-impact-RH5WH2B3.mjs +7 -0
  401. package/dist/bin/hook-chunks/{agent-identity-45BYQBU2.mjs → agent-identity-DH6DX72X.mjs} +1 -1
  402. package/dist/bin/hook-chunks/{agent-switch-4ZJJWKMD.mjs → agent-switch-7GOGG4KG.mjs} +1 -1
  403. package/dist/bin/hook-chunks/{analysis-UGHAG2SK.mjs → analysis-UI2JRLJO.mjs} +3 -3
  404. package/dist/bin/hook-chunks/{auto-flush-CXWTU3RF.mjs → auto-flush-JKIXTI2I.mjs} +1 -1
  405. package/dist/bin/hook-chunks/{capture-gate-PS6QUXLX.mjs → capture-gate-DIPHPNIC.mjs} +1 -1
  406. package/dist/bin/hook-chunks/{chunk-YDBZO6I3.mjs → chunk-22GFTUER.mjs} +1 -1
  407. package/dist/bin/hook-chunks/chunk-25OGCQTR.mjs +69 -0
  408. package/dist/bin/hook-chunks/{chunk-DCSKTMDX.mjs → chunk-3CKNJ5RA.mjs} +1 -1
  409. package/dist/bin/hook-chunks/{chunk-ABJNOG2I.mjs → chunk-3FEXJUO2.mjs} +1 -1
  410. package/dist/bin/hook-chunks/{chunk-22AXWLI6.mjs → chunk-3HGQPUKG.mjs} +1 -1
  411. package/dist/bin/hook-chunks/{chunk-GLPKMG5A.mjs → chunk-63P5VOR6.mjs} +10 -10
  412. package/dist/bin/hook-chunks/{chunk-PP6DANGV.mjs → chunk-6LU777GI.mjs} +1 -1
  413. package/dist/bin/hook-chunks/chunk-6NMHVPAI.mjs +35 -0
  414. package/dist/bin/hook-chunks/{chunk-QL3NYJTW.mjs → chunk-6RS7PNAN.mjs} +1 -1
  415. package/dist/bin/hook-chunks/{chunk-PO3QDKTE.mjs → chunk-6WDRJ7J7.mjs} +1 -1
  416. package/dist/bin/hook-chunks/chunk-7PA4KPSR.mjs +51 -0
  417. package/dist/bin/hook-chunks/{chunk-QP5USCDX.mjs → chunk-7WO5CEH3.mjs} +1 -1
  418. package/dist/bin/hook-chunks/{chunk-FW4MEPTB.mjs → chunk-A6LRNS6R.mjs} +1 -1
  419. package/dist/bin/hook-chunks/{chunk-GCDLPKOH.mjs → chunk-AEDB75AK.mjs} +1 -1
  420. package/dist/bin/hook-chunks/chunk-AFGXKRRP.mjs +12 -0
  421. package/dist/bin/hook-chunks/{chunk-WGWE3CSC.mjs → chunk-ANSRNEEI.mjs} +1 -1
  422. package/dist/bin/hook-chunks/{chunk-RTEEXGEA.mjs → chunk-AORD3YDQ.mjs} +1 -1
  423. package/dist/bin/hook-chunks/chunk-B2ZA5ZAO.mjs +8 -0
  424. package/dist/bin/hook-chunks/{chunk-BOBFTVAY.mjs → chunk-B7MHIUFA.mjs} +1 -1
  425. package/dist/bin/hook-chunks/{chunk-Z6KVLCMK.mjs → chunk-BKJHD5JI.mjs} +1 -1
  426. package/dist/bin/hook-chunks/{chunk-4NTVXJD7.mjs → chunk-BVK7ZDLX.mjs} +1 -1
  427. package/dist/bin/hook-chunks/{chunk-IGHY4FGS.mjs → chunk-CPR4FPXG.mjs} +1 -1
  428. package/dist/bin/hook-chunks/{chunk-5XA5RL5I.mjs → chunk-ETTDRXQ6.mjs} +1 -1
  429. package/dist/bin/hook-chunks/chunk-F3PNT2DQ.mjs +19 -0
  430. package/dist/bin/hook-chunks/{chunk-C4O243NG.mjs → chunk-FBEDUKMG.mjs} +1 -1
  431. package/dist/bin/hook-chunks/{chunk-5H3KJWQS.mjs → chunk-GER6HFWV.mjs} +2 -2
  432. package/dist/bin/hook-chunks/{chunk-IWJG7CZX.mjs → chunk-GSPDJSJ5.mjs} +1 -1
  433. package/dist/bin/hook-chunks/chunk-H5AVBDCH.mjs +8 -0
  434. package/dist/bin/hook-chunks/{chunk-HEDZA6KC.mjs → chunk-HGZQWYBL.mjs} +1 -1
  435. package/dist/bin/hook-chunks/{chunk-GDESYWTD.mjs → chunk-HNZ24HIK.mjs} +2 -2
  436. package/dist/bin/hook-chunks/{chunk-S5ISOGDB.mjs → chunk-IDPBMN3Q.mjs} +1 -1
  437. package/dist/bin/hook-chunks/{chunk-PTA7DMLM.mjs → chunk-IFIENAZU.mjs} +1 -1
  438. package/dist/bin/hook-chunks/chunk-IHEOOJJT.mjs +11 -0
  439. package/dist/bin/hook-chunks/{chunk-S5N2ZZDL.mjs → chunk-IL36ER4U.mjs} +1 -1
  440. package/dist/bin/hook-chunks/{chunk-6GAFRIUQ.mjs → chunk-IWUF2LGO.mjs} +1 -1
  441. package/dist/bin/hook-chunks/{chunk-OGIFB3OE.mjs → chunk-JF6DFOQK.mjs} +1 -1
  442. package/dist/bin/hook-chunks/{chunk-Z4X7JIAP.mjs → chunk-JGZ3QGWX.mjs} +3 -3
  443. package/dist/bin/hook-chunks/chunk-KOLXYWOA.mjs +36 -0
  444. package/dist/bin/hook-chunks/{chunk-DVDZA63F.mjs → chunk-MIJZT4ZR.mjs} +1 -1
  445. package/dist/bin/hook-chunks/{chunk-J5UQVJUW.mjs → chunk-NCLONKOT.mjs} +1 -1
  446. package/dist/bin/hook-chunks/{chunk-QBYHZX33.mjs → chunk-NJ74RHNC.mjs} +1 -1
  447. package/dist/bin/hook-chunks/{chunk-NLKPAJND.mjs → chunk-NMB6YSAH.mjs} +1 -1
  448. package/dist/bin/hook-chunks/{chunk-MHNWIB7B.mjs → chunk-NSTXHVTH.mjs} +2 -2
  449. package/dist/bin/hook-chunks/{chunk-N3L77UNM.mjs → chunk-ONGVBXBD.mjs} +1 -1
  450. package/dist/bin/hook-chunks/{chunk-X5W2UYQK.mjs → chunk-PFORBQBF.mjs} +3 -3
  451. package/dist/bin/hook-chunks/{chunk-KSSRINDX.mjs → chunk-PPWPUEBH.mjs} +1 -1
  452. package/dist/bin/hook-chunks/{chunk-76GDLA3Z.mjs → chunk-PQJ64L6U.mjs} +1 -1
  453. package/dist/bin/hook-chunks/{chunk-PGWFGRX4.mjs → chunk-QOQZHR3E.mjs} +1 -1
  454. package/dist/bin/hook-chunks/{chunk-2UC4DTDO.mjs → chunk-QXCEBAIA.mjs} +1 -1
  455. package/dist/bin/hook-chunks/{chunk-I26F7TLM.mjs → chunk-RLKYEL3F.mjs} +1 -1
  456. package/dist/bin/hook-chunks/{chunk-BDOAQVIF.mjs → chunk-SQW2B7NW.mjs} +1 -1
  457. package/dist/bin/hook-chunks/{chunk-4HAKTI36.mjs → chunk-TF6PN7IB.mjs} +1 -1
  458. package/dist/bin/hook-chunks/{chunk-UHVYBU7F.mjs → chunk-TKXOMN4K.mjs} +4 -4
  459. package/dist/bin/hook-chunks/{chunk-BX7VKYA7.mjs → chunk-UBWUQ64A.mjs} +1 -1
  460. package/dist/bin/hook-chunks/{chunk-OUAVSD47.mjs → chunk-UI25YRTY.mjs} +1 -1
  461. package/dist/bin/hook-chunks/{chunk-G7QQZMAO.mjs → chunk-UMJ5D5I6.mjs} +1 -1
  462. package/dist/bin/hook-chunks/{chunk-ZOX6OV6X.mjs → chunk-V6GGH6H5.mjs} +1 -1
  463. package/dist/bin/hook-chunks/chunk-WIA6ORIY.mjs +16 -0
  464. package/dist/bin/hook-chunks/chunk-WUOVBBPC.mjs +11 -0
  465. package/dist/bin/hook-chunks/{chunk-T6ELTQZM.mjs → chunk-XSJ7SPVR.mjs} +1 -1
  466. package/dist/bin/hook-chunks/{chunk-UYQC63MC.mjs → chunk-XXVHUYL7.mjs} +1 -1
  467. package/dist/bin/hook-chunks/{chunk-RHKF7EJW.mjs → chunk-Y7MZA2G4.mjs} +1 -1
  468. package/dist/bin/hook-chunks/{chunk-U4OON3S7.mjs → chunk-Y7RDBMNC.mjs} +1 -1
  469. package/dist/bin/hook-chunks/{chunk-ROA2AJXY.mjs → chunk-YATXTHDL.mjs} +1 -1
  470. package/dist/bin/hook-chunks/{chunk-ZFLIVOFX.mjs → chunk-ZF2EVMY7.mjs} +1 -1
  471. package/dist/bin/hook-chunks/{chunk-S6L3FECF.mjs → chunk-ZH2MF7H7.mjs} +1 -1
  472. package/dist/bin/hook-chunks/{chunk-3WQBTXUC.mjs → chunk-ZJW27EUC.mjs} +1 -1
  473. package/dist/bin/hook-chunks/{chunk-J5UVRZ44.mjs → chunk-ZXON2U5F.mjs} +3 -3
  474. package/dist/bin/hook-chunks/chunk-ZYCNW75E.mjs +9 -0
  475. package/dist/bin/hook-chunks/{client-CRXA774S.mjs → client-K3ZA2BLB.mjs} +1 -1
  476. package/dist/bin/hook-chunks/{code-graph-cloud-GTSLO7CD.mjs → code-graph-cloud-XGQF7XYC.mjs} +1 -1
  477. package/dist/bin/hook-chunks/{codex-skill-NUBNPSMF.mjs → codex-skill-UZZCACMB.mjs} +1 -1
  478. package/dist/bin/hook-chunks/{command-installer-UHSXC3UG.mjs → command-installer-FJ73C2ZW.mjs} +1 -1
  479. package/dist/bin/hook-chunks/{config-manager-DX5OOPW5.mjs → config-manager-XDKOTIJM.mjs} +1 -1
  480. package/dist/bin/hook-chunks/{context7-service-GDJ3QICX.mjs → context7-service-NH4BMGSJ.mjs} +1 -1
  481. package/dist/bin/hook-chunks/{custom-workflow-storage-FD47DPA3.mjs → custom-workflow-storage-VBMWLKA7.mjs} +1 -1
  482. package/dist/bin/hook-chunks/cwd-changed-STP3LH6Y.mjs +8 -0
  483. package/dist/bin/hook-chunks/{database-ZUC7OEZG.mjs → database-ZCP76LMM.mjs} +1 -1
  484. package/dist/bin/hook-chunks/{detect-changes-OJUBWWTU.mjs → detect-changes-5W6EGEZG.mjs} +1 -1
  485. package/dist/bin/hook-chunks/{developer-evolution-WNSTHDAA.mjs → developer-evolution-UTY3CWOK.mjs} +1 -1
  486. package/dist/bin/hook-chunks/{distill-GOGPFQFK.mjs → distill-63BHUJAC.mjs} +1 -1
  487. package/dist/bin/hook-chunks/{enriched-recall-QF22RIK7.mjs → enriched-recall-6F6LBYAB.mjs} +1 -1
  488. package/dist/bin/hook-chunks/{format-J3X3R225.mjs → format-VJ2YQ4XQ.mjs} +1 -1
  489. package/dist/bin/hook-chunks/{judgment-ledger-storage-FE4HXTHM.mjs → judgment-ledger-storage-7Q7AEEY6.mjs} +1 -1
  490. package/dist/bin/hook-chunks/{judgment-orchestrator-YDJTKNV2.mjs → judgment-orchestrator-AAON4ZJ4.mjs} +1 -1
  491. package/dist/bin/hook-chunks/{judgment-receipt-7A2DXVJA.mjs → judgment-receipt-LSJCAYBT.mjs} +1 -1
  492. package/dist/bin/hook-chunks/{land-cue-SZWJH6XP.mjs → land-cue-DEO2AZW4.mjs} +1 -1
  493. package/dist/bin/hook-chunks/{land-synthesis-JLYUBKHR.mjs → land-synthesis-GTMFIGDM.mjs} +1 -1
  494. package/dist/bin/hook-chunks/{legacy-crew-sweep-JXYO62UE.mjs → legacy-crew-sweep-QPKU7ITU.mjs} +2 -2
  495. package/dist/bin/hook-chunks/{memory-index-CIYDXN2G.mjs → memory-index-KCMXQGKX.mjs} +1 -1
  496. package/dist/bin/hook-chunks/{notification-UA7RTVHG.mjs → notification-DX6ZHOUC.mjs} +1 -1
  497. package/dist/bin/hook-chunks/{pack-integrity-GZC5NGFN.mjs → pack-integrity-UMLIB5RQ.mjs} +1 -1
  498. package/dist/bin/hook-chunks/{pack-manager-AF5F7PRT.mjs → pack-manager-YXRK2TJ4.mjs} +1 -1
  499. package/dist/bin/hook-chunks/{planning-M3RAOZVB.mjs → planning-JR7O5MYW.mjs} +2 -2
  500. package/dist/bin/hook-chunks/{post-edit-QRDYPZLZ.mjs → post-edit-IPTVSRVG.mjs} +1 -1
  501. package/dist/bin/hook-chunks/{pre-bash-TWWFVNQ7.mjs → pre-bash-5WWTH36N.mjs} +1 -1
  502. package/dist/bin/hook-chunks/{pre-commit-PTFF7JIN.mjs → pre-commit-KZ5TNTPW.mjs} +1 -1
  503. package/dist/bin/hook-chunks/pre-edit-XHPYBXRU.mjs +11 -0
  504. package/dist/bin/hook-chunks/{pre-package-325ALZKD.mjs → pre-package-U3HDW3SX.mjs} +1 -1
  505. package/dist/bin/hook-chunks/{pre-search-GOHVFAFH.mjs → pre-search-R5CRK66E.mjs} +1 -1
  506. package/dist/bin/hook-chunks/{pre-secrets-MYNM5KI4.mjs → pre-secrets-MWPPZPWK.mjs} +1 -1
  507. package/dist/bin/hook-chunks/{prjct-md-RCB6FWD6.mjs → prjct-md-IBQTJBK7.mjs} +1 -1
  508. package/dist/bin/hook-chunks/{project-agent-surfaces-V4P5RTUR.mjs → project-agent-surfaces-TPZO73ZV.mjs} +1 -1
  509. package/dist/bin/hook-chunks/{project-file-inventory-OKIP4LBO.mjs → project-file-inventory-HHURZTMH.mjs} +1 -1
  510. package/dist/bin/hook-chunks/project-memory-YQLZX5RG.mjs +8 -0
  511. package/dist/bin/hook-chunks/{project-style-evolution-RPGATIYJ.mjs → project-style-evolution-NOFCIIZZ.mjs} +1 -1
  512. package/dist/bin/hook-chunks/prompt-DJWONMTZ.mjs +24 -0
  513. package/dist/bin/hook-chunks/{publish-helper-SX7HEV2L.mjs → publish-helper-ZSL27HSX.mjs} +1 -1
  514. package/dist/bin/hook-chunks/{purge-XKHUAB4H.mjs → purge-5W3K2MZL.mjs} +1 -1
  515. package/dist/bin/hook-chunks/retention-GWJ4AX7I.mjs +8 -0
  516. package/dist/bin/hook-chunks/{sdd-6PF7MBAY.mjs → sdd-GWBRD4KI.mjs} +1 -1
  517. package/dist/bin/hook-chunks/{session-continuity-UEXQDGZE.mjs → session-continuity-VH645RGR.mjs} +1 -1
  518. package/dist/bin/hook-chunks/session-start-4TYTI27B.mjs +8 -0
  519. package/dist/bin/hook-chunks/settings-installer-CQKMGMRG.mjs +9 -0
  520. package/dist/bin/hook-chunks/{setup-ZOHG6MGF.mjs → setup-VF4UHUBX.mjs} +3 -3
  521. package/dist/bin/hook-chunks/{shipping-QVGTOO6U.mjs → shipping-2ULWBGRX.mjs} +4 -4
  522. package/dist/bin/hook-chunks/{skill-index-FGDQVYHM.mjs → skill-index-55I3HLAI.mjs} +1 -1
  523. package/dist/bin/hook-chunks/{spec-context-inference-6Z52BT37.mjs → spec-context-inference-HVENYOIO.mjs} +1 -1
  524. package/dist/bin/hook-chunks/{spec-service-UAQ5AEXQ.mjs → spec-service-4XGQQPGP.mjs} +2 -2
  525. package/dist/bin/hook-chunks/{spec-task-breakdown-LAXGVLMY.mjs → spec-task-breakdown-JXF556UH.mjs} +1 -1
  526. package/dist/bin/hook-chunks/{state-storage-XU35ZYNA.mjs → state-storage-EMWLIFQJ.mjs} +1 -1
  527. package/dist/bin/hook-chunks/stop-NJDYIIXR.mjs +16 -0
  528. package/dist/bin/hook-chunks/subagent-start-2YMGD4SY.mjs +8 -0
  529. package/dist/bin/hook-chunks/{subagent-stop-OUG4PR7S.mjs → subagent-stop-4TZJ2NSJ.mjs} +1 -1
  530. package/dist/bin/hook-chunks/{surface-attribution-A6GCGRFM.mjs → surface-attribution-UNK4J5W2.mjs} +1 -1
  531. package/dist/bin/hook-chunks/{symbol-graph-DMPBNBX7.mjs → symbol-graph-MH42JSPX.mjs} +1 -1
  532. package/dist/bin/hook-chunks/{sync-cursor-storage-VVLA3L2U.mjs → sync-cursor-storage-ZB7FGT6D.mjs} +1 -1
  533. package/dist/bin/hook-chunks/{task-orchestration-HFZYWYLR.mjs → task-orchestration-7NGRIISS.mjs} +1 -1
  534. package/dist/bin/hook-chunks/{task-overview-PCUZWL5Q.mjs → task-overview-P3VRH2FD.mjs} +1 -1
  535. package/dist/bin/hook-chunks/task-service-SPUES5DO.mjs +8 -0
  536. package/dist/bin/hook-chunks/{tdd-QZL4OSM7.mjs → tdd-MYF7I5FS.mjs} +1 -1
  537. package/dist/bin/hook-chunks/{template-loader-SKXILJLJ.mjs → template-loader-4SYVR2UB.mjs} +1 -1
  538. package/dist/bin/hook-chunks/{usefulness-SZLG6LVC.mjs → usefulness-TBD5EYAL.mjs} +1 -1
  539. package/dist/bin/hook-chunks/{vault-retire-notice-HOXPURNQ.mjs → vault-retire-notice-7XHVNHU6.mjs} +1 -1
  540. package/dist/bin/hook-chunks/{velocity-storage-5J6BAMCW.mjs → velocity-storage-IOCVK2LU.mjs} +1 -1
  541. package/dist/bin/hook-chunks/{weak-model-mode-ZRNKFTFF.mjs → weak-model-mode-TYJJT6JJ.mjs} +1 -1
  542. package/dist/bin/hook-chunks/{work-graph-PGYHFLEL.mjs → work-graph-AVAOKY63.mjs} +1 -1
  543. package/dist/bin/hook-chunks/{work-scope-FIB6LBKE.mjs → work-scope-A6XPENFE.mjs} +1 -1
  544. package/dist/bin/hook-chunks/{workspace-occupancy-3D4OKQRB.mjs → workspace-occupancy-3NEAXILW.mjs} +1 -1
  545. package/dist/bin/hook-fast-darwin-arm64 +0 -0
  546. package/dist/bin/hook-fast-darwin-x64 +0 -0
  547. package/dist/bin/hook-fast-linux-x64 +0 -0
  548. package/dist/bin/prjct-core.mjs +9 -3311
  549. package/dist/bin/prjct-hooks.mjs +3 -3
  550. package/dist/bin/prjct.mjs +27 -8
  551. package/dist/daemon/entry.mjs +621 -606
  552. package/dist/mcp/server.mjs +317 -302
  553. package/package.json +5 -6
  554. package/scripts/install.sh +28 -496
  555. package/dist/bin/hook-chunks/chunk-4KXXDQYI.mjs +0 -11
  556. package/dist/bin/hook-chunks/chunk-BU22R6JX.mjs +0 -9
  557. package/dist/bin/hook-chunks/chunk-CYZ7ST2P.mjs +0 -36
  558. package/dist/bin/hook-chunks/chunk-EWOK4VE7.mjs +0 -11
  559. package/dist/bin/hook-chunks/chunk-FXFG6PV6.mjs +0 -69
  560. package/dist/bin/hook-chunks/chunk-GDECEHO5.mjs +0 -16
  561. package/dist/bin/hook-chunks/chunk-GPZP7NXL.mjs +0 -11
  562. package/dist/bin/hook-chunks/chunk-KHLYWNHT.mjs +0 -8
  563. package/dist/bin/hook-chunks/chunk-TRMBRDKH.mjs +0 -8
  564. package/dist/bin/hook-chunks/chunk-TXSLON7M.mjs +0 -19
  565. package/dist/bin/hook-chunks/chunk-V2FR2NPL.mjs +0 -43
  566. package/dist/bin/hook-chunks/chunk-XXRAQZNC.mjs +0 -35
  567. package/dist/bin/hook-chunks/cwd-changed-EP3UIRK6.mjs +0 -8
  568. package/dist/bin/hook-chunks/pre-edit-PMMWDR2B.mjs +0 -11
  569. package/dist/bin/hook-chunks/project-memory-JK2MXRJB.mjs +0 -8
  570. package/dist/bin/hook-chunks/prompt-DOENKHLQ.mjs +0 -24
  571. package/dist/bin/hook-chunks/retention-C3NQT65W.mjs +0 -8
  572. package/dist/bin/hook-chunks/session-start-B4P7L33E.mjs +0 -8
  573. package/dist/bin/hook-chunks/settings-installer-QDM3GB6J.mjs +0 -9
  574. package/dist/bin/hook-chunks/stop-CFB2H3XC.mjs +0 -16
  575. package/dist/bin/hook-chunks/subagent-start-KFAZZUHS.mjs +0 -8
  576. package/dist/bin/hook-chunks/task-service-PXCDU55T.mjs +0 -8
@@ -5,14 +5,14 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{a as z}from"./chunk-QBYHZX33.mjs";import{a as V}from"./chunk-GPZP7NXL.mjs";import{b as W}from"./chunk-2UC4DTDO.mjs";import{a as X,j as L}from"./chunk-BOBFTVAY.mjs";import{a as q}from"./chunk-OGIFB3OE.mjs";import{e as J}from"./chunk-BU22R6JX.mjs";import{c as P}from"./chunk-4HAKTI36.mjs";import{d as H,e as I}from"./chunk-C4O243NG.mjs";import{a as _}from"./chunk-V2FR2NPL.mjs";import{i as b}from"./chunk-Z4X7JIAP.mjs";import{b as E}from"./chunk-PO3QDKTE.mjs";import{d as p,g as K}from"./chunk-UHVYBU7F.mjs";import{b as A,g as M,h as mt,i as G,k as pt,v as Y,w as ht}from"./chunk-A6K4H3YT.mjs";import{d as ft}from"./chunk-JQE2F2RK.mjs";import{e as x,p as ut}from"./chunk-QWQFF2UG.mjs";import{b as T,e as gt}from"./chunk-GCDLPKOH.mjs";import{e as B,f as dt}from"./chunk-BUDZL4DW.mjs";import{a as l}from"./chunk-E66B27AL.mjs";import $ from"node:fs/promises";import at from"node:path";ht();import N from"node:fs";import yt from"node:path";var Z=l(()=>Y.getStatePath(),"stampDir"),Q=l(()=>yt.join(Z(),"installed-version"),"stampPath");function St(){try{return N.readFileSync(Q(),"utf-8").trim()}catch{return null}}l(St,"readStamp");function wt(s){try{N.mkdirSync(Z(),{recursive:!0}),N.writeFileSync(Q(),s,"utf-8")}catch{}}l(wt,"writeStamp");function tt(s){return s?St()===s:!0}l(tt,"isSyncCurrent");async function nt(s){if(s&&process.env.PRJCT_NO_SELF_SYNC!=="1"){try{let{installGlobalConfig:n}=await import("./command-installer-UHSXC3UG.mjs");await n()}catch{}try{await(await import("./settings-installer-QDM3GB6J.mjs")).install()}catch{}try{let{SetupCommands:n}=await import("./setup-ZOHG6MGF.mjs");await new n().installStatusLine()}catch{}wt(s)}}l(nt,"runSelfHeal");K();dt();ut();ft();K();pt();mt();var Ct=50,F=class{static{l(this,"SessionTracker")}currentRow(n){try{return p.get(n,"SELECT * FROM cli_sessions WHERE status = 'active' ORDER BY last_activity DESC LIMIT 1")??null}catch{return null}}isExpired(n){return G(n,18e5)}toSessionData(n,t){return{id:t.id,projectId:n,status:t.status,createdAt:t.created_at,lastActivity:t.last_activity,commands:[],files:[]}}async touch(n){let t=A(),e=this.currentRow(n);if(e&&!this.isExpired(e.last_activity))return p.run(n,"UPDATE cli_sessions SET last_activity = ? WHERE id = ?",t,e.id),this.toSessionData(n,{...e,last_activity:t});e&&p.run(n,"UPDATE cli_sessions SET status = 'expired' WHERE id = ?",e.id);let i=crypto.randomUUID();return p.run(n,"INSERT INTO cli_sessions (id, status, created_at, last_activity) VALUES (?, 'active', ?, ?)",i,t,t),this.toSessionData(n,{id:i,status:"active",created_at:t,last_activity:t})}async trackCommand(n,t,e){let i=this.currentRow(n);if(!i)return;let o=A();try{p.run(n,"INSERT INTO cli_session_commands (session_id, command, timestamp, duration_ms) VALUES (?, ?, ?, ?)",i.id,t,o,Math.round(e)),p.run(n,"UPDATE cli_sessions SET last_activity = ? WHERE id = ?",o,i.id)}catch{}}async getInfo(n){let t=this.currentRow(n);if(!t||this.isExpired(t.last_activity))return{active:!1,id:null,duration:null,idleSince:null,idleMs:0,expiresIn:null,commandCount:0,commands:[],filesRead:0,filesWritten:0};let e=Date.now(),i=new Date(t.created_at).getTime(),o=new Date(t.last_activity).getTime(),c=e-o,a=Math.max(0,18e5-c),r=p.query(n,"SELECT command FROM cli_session_commands WHERE session_id = ? ORDER BY timestamp DESC LIMIT ?",t.id,Ct);return{active:!0,id:t.id,duration:M(e-i),idleSince:t.last_activity,idleMs:c,expiresIn:M(a),commandCount:r.length,commands:r.map(u=>u.command).reverse(),filesRead:0,filesWritten:0}}async expire(n){try{p.run(n,"UPDATE cli_sessions SET status = 'expired' WHERE status = 'active'")}catch{}}async expireIfStale(n){let t=this.currentRow(n);return t&&this.isExpired(t.last_activity)?(p.run(n,"UPDATE cli_sessions SET status = 'expired' WHERE id = ?",t.id),!0):!1}},st=new F;var vt={commitThreshold:10,dayThreshold:3,significantFiles:["package.json","tsconfig.json","Cargo.toml","go.mod","requirements.txt","pyproject.toml",".env.example","docker-compose.yml","Dockerfile"]},O=class{static{l(this,"StalenessChecker")}projectPath;config;constructor(n,t={}){this.projectPath=n,this.config={...vt,...t}}async check(n){let t={isStale:!1,reason:null,lastSyncCommit:null,currentCommit:null,commitsSinceSync:0,daysSinceSync:0,changedFiles:[],significantChanges:[]};try{let e=(()=>{try{return p.getDoc(n,"project")}catch{return null}})();if(!e)return t.isStale=!0,t.reason="No sync history found. Run `prjct sync` to initialize.",t;t.lastSyncCommit=e.lastSyncCommit||null;let i=e.lastSync;if(!t.lastSyncCommit)return t.isStale=!0,t.reason="No sync commit recorded. Run `prjct sync` to track.",t;let c={cwd:this.projectPath,timeoutMs:3e3,maxBuffer:1024*256},a=`${t.lastSyncCommit}..HEAD`,[r,u]=await Promise.all([x(["rev-parse","--short","HEAD"],c),x(["rev-list","--count",a],c)]);if(!r.ok)return t.reason=r.kind==="exit"?"Not a git repository":`git ${r.kind} \u2014 staleness unknown`,t;if(t.currentCommit=r.stdout.trim(),t.lastSyncCommit===t.currentCommit)return t.reason="Context is up to date",t;if(!u.ok)return u.kind==="exit"?(t.isStale=!0,t.reason="Sync commit no longer exists (history changed). Run `prjct sync`."):t.reason=`git ${u.kind} reading history \u2014 staleness unknown. Retry shortly.`,t;if(t.commitsSinceSync=parseInt(u.stdout.trim(),10)||0,i){let y=new Date(i),g=new Date;t.daysSinceSync=Math.floor((g.getTime()-y.getTime())/(1e3*60*60*24))}if(t.commitsSinceSync>0&&t.commitsSinceSync<this.config.commitThreshold){let y=await x(["diff","--name-only",a],c),g=y.ok?y.stdout.trim().split(`
9
- `).filter(Boolean).slice(0,200):[];t.changedFiles=g,t.significantChanges=g.filter(d=>this.config.significantFiles.some(f=>d.endsWith(f)||d.includes(f)))}else t.changedFiles=[],t.significantChanges=[];return t.commitsSinceSync>=this.config.commitThreshold?(t.isStale=!0,t.reason=`${t.commitsSinceSync} commits since last sync (threshold: ${this.config.commitThreshold})`):t.daysSinceSync>=this.config.dayThreshold?(t.isStale=!0,t.reason=`${t.daysSinceSync} days since last sync (threshold: ${this.config.dayThreshold})`):t.significantChanges.length>0?(t.isStale=!0,t.reason=`Significant files changed: ${t.significantChanges.join(", ")}`):t.commitsSinceSync>0?t.reason=`${t.commitsSinceSync} commits since sync (threshold: ${this.config.commitThreshold})`:t.reason="Context is up to date",t}catch(e){return t.reason=`Error checking staleness: ${B(e)}`,t}}formatStatus(n){let t=[];n.isStale?t.push("CLAUDE.md status: \u26A0\uFE0F STALE"):t.push("CLAUDE.md status: \u2713 Fresh");let e=[];if(n.lastSyncCommit&&e.push(`Last sync: ${n.lastSyncCommit}`),n.currentCommit&&e.push(`Current: ${n.currentCommit}`),n.commitsSinceSync>0&&e.push(`Commits since: ${n.commitsSinceSync}`),n.daysSinceSync>0&&e.push(`Days since: ${n.daysSinceSync}`),n.changedFiles.length>0&&e.push(`Files changed: ${n.changedFiles.length}`),e.length>0&&t.push(...it(e)),n.significantChanges.length>0){t.push(""),t.push("Significant changes:");for(let i of n.significantChanges.slice(0,5))t.push(` \u2022 ${i}`);n.significantChanges.length>5&&t.push(` ... and ${n.significantChanges.length-5} more`)}return n.reason&&(t.push(""),t.push(n.reason)),n.isStale&&(t.push(""),t.push("Run `prjct sync` to update context")),t.join(`
8
+ import{a as z}from"./chunk-NJ74RHNC.mjs";import{a as V}from"./chunk-WUOVBBPC.mjs";import{a as X,j as L}from"./chunk-B7MHIUFA.mjs";import{a as q}from"./chunk-JF6DFOQK.mjs";import{e as J}from"./chunk-ZYCNW75E.mjs";import{c as P}from"./chunk-TF6PN7IB.mjs";import{d as H,e as I}from"./chunk-FBEDUKMG.mjs";import{b as k}from"./chunk-7PA4KPSR.mjs";import{i as b}from"./chunk-JGZ3QGWX.mjs";import{c as W}from"./chunk-QXCEBAIA.mjs";import{b as E}from"./chunk-6WDRJ7J7.mjs";import{d as p,g as K}from"./chunk-TKXOMN4K.mjs";import{b as A,g as M,h as mt,i as G,k as pt,v as Y,w as ht}from"./chunk-A6K4H3YT.mjs";import{d as ft}from"./chunk-JQE2F2RK.mjs";import{e as x,p as ut}from"./chunk-QWQFF2UG.mjs";import{b as T,e as gt}from"./chunk-AEDB75AK.mjs";import{e as B,f as dt}from"./chunk-BUDZL4DW.mjs";import{a as l}from"./chunk-E66B27AL.mjs";import $ from"node:fs/promises";import at from"node:path";ht();import N from"node:fs";import yt from"node:path";var Z=l(()=>Y.getStatePath(),"stampDir"),Q=l(()=>yt.join(Z(),"installed-version"),"stampPath");function St(){try{return N.readFileSync(Q(),"utf-8").trim()}catch{return null}}l(St,"readStamp");function wt(i){try{N.mkdirSync(Z(),{recursive:!0}),N.writeFileSync(Q(),i,"utf-8")}catch{}}l(wt,"writeStamp");function tt(i){return i?St()===i:!0}l(tt,"isSyncCurrent");async function nt(i){if(i&&process.env.PRJCT_NO_SELF_SYNC!=="1"){try{let{installGlobalConfig:n}=await import("./command-installer-FJ73C2ZW.mjs");await n()}catch{}try{await(await import("./settings-installer-CQKMGMRG.mjs")).install()}catch{}try{let{SetupCommands:n}=await import("./setup-VF4UHUBX.mjs");await new n().installStatusLine()}catch{}wt(i)}}l(nt,"runSelfHeal");K();dt();ut();ft();K();pt();mt();var Ct=50,F=class{static{l(this,"SessionTracker")}currentRow(n){try{return p.get(n,"SELECT * FROM cli_sessions WHERE status = 'active' ORDER BY last_activity DESC LIMIT 1")??null}catch{return null}}isExpired(n){return G(n,18e5)}toSessionData(n,t){return{id:t.id,projectId:n,status:t.status,createdAt:t.created_at,lastActivity:t.last_activity,commands:[],files:[]}}async touch(n){let t=A(),e=this.currentRow(n);if(e&&!this.isExpired(e.last_activity))return p.run(n,"UPDATE cli_sessions SET last_activity = ? WHERE id = ?",t,e.id),this.toSessionData(n,{...e,last_activity:t});e&&p.run(n,"UPDATE cli_sessions SET status = 'expired' WHERE id = ?",e.id);let s=crypto.randomUUID();return p.run(n,"INSERT INTO cli_sessions (id, status, created_at, last_activity) VALUES (?, 'active', ?, ?)",s,t,t),this.toSessionData(n,{id:s,status:"active",created_at:t,last_activity:t})}async trackCommand(n,t,e){let s=this.currentRow(n);if(!s)return;let o=A();try{p.run(n,"INSERT INTO cli_session_commands (session_id, command, timestamp, duration_ms) VALUES (?, ?, ?, ?)",s.id,t,o,Math.round(e)),p.run(n,"UPDATE cli_sessions SET last_activity = ? WHERE id = ?",o,s.id)}catch{}}async getInfo(n){let t=this.currentRow(n);if(!t||this.isExpired(t.last_activity))return{active:!1,id:null,duration:null,idleSince:null,idleMs:0,expiresIn:null,commandCount:0,commands:[],filesRead:0,filesWritten:0};let e=Date.now(),s=new Date(t.created_at).getTime(),o=new Date(t.last_activity).getTime(),c=e-o,a=Math.max(0,18e5-c),r=p.query(n,"SELECT command FROM cli_session_commands WHERE session_id = ? ORDER BY timestamp DESC LIMIT ?",t.id,Ct);return{active:!0,id:t.id,duration:M(e-s),idleSince:t.last_activity,idleMs:c,expiresIn:M(a),commandCount:r.length,commands:r.map(u=>u.command).reverse(),filesRead:0,filesWritten:0}}async expire(n){try{p.run(n,"UPDATE cli_sessions SET status = 'expired' WHERE status = 'active'")}catch{}}async expireIfStale(n){let t=this.currentRow(n);return t&&this.isExpired(t.last_activity)?(p.run(n,"UPDATE cli_sessions SET status = 'expired' WHERE id = ?",t.id),!0):!1}},st=new F;var vt={commitThreshold:10,dayThreshold:3,significantFiles:["package.json","tsconfig.json","Cargo.toml","go.mod","requirements.txt","pyproject.toml",".env.example","docker-compose.yml","Dockerfile"]},O=class{static{l(this,"StalenessChecker")}projectPath;config;constructor(n,t={}){this.projectPath=n,this.config={...vt,...t}}async check(n){let t={isStale:!1,reason:null,lastSyncCommit:null,currentCommit:null,commitsSinceSync:0,daysSinceSync:0,changedFiles:[],significantChanges:[]};try{let e=(()=>{try{return p.getDoc(n,"project")}catch{return null}})();if(!e)return t.isStale=!0,t.reason="No sync history found. Run `prjct sync` to initialize.",t;t.lastSyncCommit=e.lastSyncCommit||null;let s=e.lastSync;if(!t.lastSyncCommit)return t.isStale=!0,t.reason="No sync commit recorded. Run `prjct sync` to track.",t;let c={cwd:this.projectPath,timeoutMs:3e3,maxBuffer:1024*256},a=`${t.lastSyncCommit}..HEAD`,[r,u]=await Promise.all([x(["rev-parse","--short","HEAD"],c),x(["rev-list","--count",a],c)]);if(!r.ok)return t.reason=r.kind==="exit"?"Not a git repository":`git ${r.kind} \u2014 staleness unknown`,t;if(t.currentCommit=r.stdout.trim(),t.lastSyncCommit===t.currentCommit)return t.reason="Context is up to date",t;if(!u.ok)return u.kind==="exit"?(t.isStale=!0,t.reason="Sync commit no longer exists (history changed). Run `prjct sync`."):t.reason=`git ${u.kind} reading history \u2014 staleness unknown. Retry shortly.`,t;if(t.commitsSinceSync=parseInt(u.stdout.trim(),10)||0,s){let y=new Date(s),g=new Date;t.daysSinceSync=Math.floor((g.getTime()-y.getTime())/(1e3*60*60*24))}if(t.commitsSinceSync>0&&t.commitsSinceSync<this.config.commitThreshold){let y=await x(["diff","--name-only",a],c),g=y.ok?y.stdout.trim().split(`
9
+ `).filter(Boolean).slice(0,200):[];t.changedFiles=g,t.significantChanges=g.filter(d=>this.config.significantFiles.some(f=>d.endsWith(f)||d.includes(f)))}else t.changedFiles=[],t.significantChanges=[];return t.commitsSinceSync>=this.config.commitThreshold?(t.isStale=!0,t.reason=`${t.commitsSinceSync} commits since last sync (threshold: ${this.config.commitThreshold})`):t.daysSinceSync>=this.config.dayThreshold?(t.isStale=!0,t.reason=`${t.daysSinceSync} days since last sync (threshold: ${this.config.dayThreshold})`):t.significantChanges.length>0?(t.isStale=!0,t.reason=`Significant files changed: ${t.significantChanges.join(", ")}`):t.commitsSinceSync>0?t.reason=`${t.commitsSinceSync} commits since sync (threshold: ${this.config.commitThreshold})`:t.reason="Context is up to date",t}catch(e){return t.reason=`Error checking staleness: ${B(e)}`,t}}formatStatus(n){let t=[];n.isStale?t.push("CLAUDE.md status: \u26A0\uFE0F STALE"):t.push("CLAUDE.md status: \u2713 Fresh");let e=[];if(n.lastSyncCommit&&e.push(`Last sync: ${n.lastSyncCommit}`),n.currentCommit&&e.push(`Current: ${n.currentCommit}`),n.commitsSinceSync>0&&e.push(`Commits since: ${n.commitsSinceSync}`),n.daysSinceSync>0&&e.push(`Days since: ${n.daysSinceSync}`),n.changedFiles.length>0&&e.push(`Files changed: ${n.changedFiles.length}`),e.length>0&&t.push(...it(e)),n.significantChanges.length>0){t.push(""),t.push("Significant changes:");for(let s of n.significantChanges.slice(0,5))t.push(` \u2022 ${s}`);n.significantChanges.length>5&&t.push(` ... and ${n.significantChanges.length-5} more`)}return n.reason&&(t.push(""),t.push(n.reason)),n.isStale&&(t.push(""),t.push("Run `prjct sync` to update context")),t.join(`
10
10
  `)}async getSessionInfo(n){return st.getInfo(n)}formatSessionInfo(n){let t=[];if(!n.active)return t.push("Session: \u25CB No active session"),t.join(`
11
- `);t.push(`Session: \u25B6 Active (${n.duration})`);let e=[];if(n.commandCount>0){let i=new Set,o=[];for(let c of n.commands)i.has(c)||(i.add(c),o.push(c));e.push(`Commands: ${o.join(" \u2192 ")} (${n.commandCount} total)`)}return(n.filesRead>0||n.filesWritten>0)&&e.push(`Files: ${n.filesRead} read, ${n.filesWritten} written`),e.push(`Idle: ${n.expiresIn} until timeout`),e.length>0&&t.push(...it(e)),t.join(`
12
- `)}getWarning(n){return n.isStale?n.commitsSinceSync>0?`\u26A0\uFE0F Context stale (${n.commitsSinceSync} commits behind). Run \`prjct sync\``:n.daysSinceSync>0?`\u26A0\uFE0F Context stale (${n.daysSinceSync} days old). Run \`prjct sync\``:"\u26A0\uFE0F Context may be stale. Run `prjct sync`":null}};function it(s){let n=Math.max(...s.map(e=>e.length)),t="\u2500".repeat(n+2);return[`\u250C${t}\u2510`,...s.map(e=>`\u2502 ${e.padEnd(n)} \u2502`),`\u2514${t}\u2518`]}l(it,"boxLines");var rt=l((s,n)=>new O(s,n),"createStalenessChecker");gt();var Et=1600,j=3,_t=4,U={minTeaser:24,maxTeaser:90};async function kt(s,n,t={}){let e=n??await E.readConfig(s);if(!e?.projectId)return null;let i=e.persona,o=t.digest?await(async()=>{try{let{memoryL0IndexForSession:h}=await import("./memory-index-CIYDXN2G.mjs");return h(e.projectId,{rebuildIfStale:!0})||ot(e.projectId)}catch{return ot(e.projectId)}})():null,c=xt(s,e.projectId),a=import("./vault-retire-notice-HOXPURNQ.mjs").then(({vaultRetirementNotice:h})=>h(e,e.projectId)),r=(async()=>{try{let{buildLandCue:h}=await import("./land-cue-SZWJH6XP.mjs");return await h(e.projectId,s,e)}catch{return null}})(),u=(async()=>{try{let{effectiveWeakModelMode:h,weakModelBanner:w}=await import("./weak-model-mode-ZRNKFTFF.mjs");return h(e)==="on"?w():null}catch{return null}})(),C=t.digest?(async()=>{try{let{formatPendingHandoffCue:h}=await import("./agent-switch-4ZJJWKMD.mjs"),w=h(e.projectId);return w?`# prjct: pending handoff
13
- ${w}`:null}catch{return null}})():Promise.resolve(null),y=t.digest?(async()=>{try{let{loadSessionContinuity:h,formatContinuitySessionCue:w}=await import("./session-continuity-UEXQDGZE.mjs");return w(h(e.projectId))}catch{return null}})():Promise.resolve(null),g=Pt(s,e.projectId),[d,f,S,v,k,D,R]=await Promise.all([c,a,r,u,C,y,g]);if(!R&&!i&&!o&&!d&&!f&&!S&&!v&&!k&&!D)return null;let m=["# prjct: project context",""];return R&&m.push(R,""),i&&m.push(It(i),"","> Exposed as state, not prescription. Decide whether any of this matters for the current turn."),o&&(i&&m.push(""),m.push(o)),d&&((i||o)&&m.push(""),m.push(d)),f&&((i||o||d)&&m.push(""),m.push(f)),S&&((i||o||d||f)&&m.push(""),m.push(S)),v&&((i||o||d||f||S)&&m.push(""),m.push(v)),k&&((i||o||d||f||S||v)&&m.push(""),m.push(k)),D&&((i||o||d||f||S||v||k)&&m.push(""),m.push(D)),m.join(`
14
- `)}l(kt,"buildSessionContext");async function xt(s,n){try{let t=rt(s),e=await t.check(n);if(!e.isStale||e.commitsSinceSync<=0)return null;let i=t.getWarning(e);if(!i)return null;try{let c=await import("node:path"),a=await import("node:os"),{maybeDetachDriftRefresh:r,readDriftStamp:u,formatDriftNotice:C,driftStaleResolved:y}=await import("./drift-refresh-TD3PYPJN.mjs"),g=process.env.PRJCT_CLI_HOME?c.resolve(process.env.PRJCT_CLI_HOME):c.join(a.homedir(),".prjct-cli"),d=u(g);if(y(d))return C({warning:i,commitsSinceSync:e.commitsSinceSync,stamp:d,refreshScheduled:!1});let f=r({projectPath:s,cliHome:g,commitsSinceSync:e.commitsSinceSync}),S=u(g);return C({warning:i,commitsSinceSync:e.commitsSinceSync,stamp:S,refreshScheduled:f})}catch{}let o=await(async()=>{try{let{hasSymbolIndex:c,loadMeta:a}=await import("./symbol-graph-DMPBNBX7.mjs");if(!c(n))return" Code graph empty \u2014 `prjct code reindex` (or `prjct sync`) before trace/impact.";if(e.commitsSinceSync<5)return"";let r=a(n);return` Symbol index may lag${r?.builtAt?` (index ${r.builtAt.slice(0,10)})`:""} \u2014 prefer \`prjct code reindex\` after big pulls.`}catch{return""}})();return`**Understanding may be stale:** ${i} \u2014 run \`prjct sync\` before big calls.${o}`}catch{return null}}l(xt,"buildStalenessNotice");function ot(s){let n=(()=>{try{let r=P.rerank(s,_.recall(s,{types:["gotcha","anti-pattern"],limit:j*4})).slice(0,j),u=P.rerank(s,_.recall(s,{types:["decision"],limit:j*4})).slice(0,j);return{gotchas:r,decisions:u}}catch{return null}})();if(!n)return null;let{gotchas:t,decisions:e}=n,i=(()=>{try{let r=_.recall(s,{types:["feedback","improvement-signal"],limit:40,dedupeByKey:!1});return X(r,_t)}catch{return[]}})(),o=L(s,new Set([...t,...e].map(r=>r.id))),c=(()=>{try{let r=q(s);return r?J(r,{maxConventions:4,maxPatterns:3,maxAnti:2}):null}catch{return null}})();if(t.length===0&&e.length===0&&!o&&i.length===0&&!c)return null;let a=["## What this project already knows",""];if(a.push("> Carried across sessions and model updates \u2014 this survived even if your conversation context did not. Apply these; do not re-derive from source."),i.length>0){a.push("","**How this developer works (act as them):**");for(let r of i){let u=r.rule.length>140?`${r.rule.slice(0,139)}\u2026`:r.rule;a.push(`- ${u} \`${r.sourceId}\``)}}if(c){let r=c.replace(/^## How this repo works \(project style\)\n?/,"").trim();r&&a.push("","**How this repo works (match house style):**",r)}if(t.length>0){a.push("","**Traps to avoid:**");for(let r of t)a.push(`- ${I(r,U)}`)}if(e.length>0){a.push("","**Decisions in force:**");for(let r of e)a.push(`- ${I(r,U)}`)}return o&&a.push("","**Keeps being missed:**",`- ${I(o.entry,U)} \u2014 flagged relevant-but-unused ${o.count}\xD7. Apply it or supersede it.`),a.push("","> Resolve any `mem_id` with `prjct search <id>`. Full developer model: MCP `prjct_developer`. Project style: `prjct analysis` / sync evolution."),b(a.join(`
15
- `),Et)}l(ot,"buildKnowledgeDigest");var Tt=500,ct=2;async function un(s){let n=await E.readConfig(s).catch(()=>null);if(!n?.projectId)return null;let t=["# prjct: subagent context"];n.persona?.role&&t.push(`Role in this project: ${n.persona.role}`);try{let{resolveActiveTask:e}=await import("./task-service-PXCDU55T.mjs"),i=await e(n.projectId,s);i&&t.push(`Active work cycle (this worktree): ${i.description}`)}catch{}try{let e=P.rerank(n.projectId,_.recall(n.projectId,{types:["gotcha","anti-pattern"],limit:ct*4})).slice(0,ct);if(e.length>0){t.push("Traps to avoid:");for(let o of e)t.push(`- ${H(o)} \`${o.id}\``)}let i=L(n.projectId,new Set(e.map(o=>o.id)));i&&t.push(`Keeps being missed: ${H(i.entry)} \`${i.entry.id}\``)}catch{}return t.length<=1?null:b(t.join(`
16
- `),Tt)}l(un,"buildSubagentDigest");function It(s){let n=[];return n.push(`## Your role in this project: **${s.role}**`),s.focus&&n.push(`Focus: ${s.focus}`),s.mcps&&s.mcps.length>0&&n.push(`Available MCPs this project expects: ${s.mcps.join(", ")}`),s.packs&&s.packs.length>0&&n.push(`Active packs: ${s.packs.join(", ")}`),n.join(`
17
- `)}l(It,"formatPersona");async function Pt(s,n){try{let t=await import("node:path"),{execFileAsync:e}=await import("./exec-2P5VOBHM.mjs"),i=t.basename(s),o=await(async()=>{try{let{stdout:r}=await e("git",["branch","--show-current"],{cwd:s});return r.trim()}catch{return""}})(),c=n.length>12?`${n.slice(0,8)}\u2026`:n,a=["## Project identity (cwd)",`- **${i}** \xB7 id \`${c}\``];return o&&a.push(`- Branch: \`${o}\``),a.push("- Skill is portable L0 \u2014 if skill text names another project, ignore it; trust this block + `prjct context --md`."),a.join(`
18
- `)}catch{return null}}l(Pt,"buildProjectIdentityLine");function lt(s,n){let t=s.replace(/[^a-zA-Z0-9._-]/g,"_"),e=(n??"unknown").replace(/[^a-zA-Z0-9._-]/g,"_");return at.join(W.runDir(),`kimi-session-${t}-${e}.pending`)}l(lt,"kimiSessionStampPath");async function mn(s,n){let t=lt(s,n),e=await $.readFile(t,"utf-8").catch(()=>null);return e===null?null:(await $.rm(t,{force:!0}).catch(()=>{}),e.trim()==="digest"?"digest":"persona")}l(mn,"consumeKimiSessionInjection");function dn(s=process.cwd(),n){let t=E.readConfig(s).catch(()=>null);return V({event:"SessionStart",projectPath:s,build:l(async(e,i,o)=>{let c=i===s?await t:await E.readConfig(i).catch(()=>null),a=e.source??"startup",r=a==="startup"||a==="clear"||a==="compact";if(o==="kimi"){if(c?.projectId){let u=lt(c.projectId,e.session_id);await $.mkdir(at.dirname(u),{recursive:!0}).then(()=>$.writeFile(u,r?"digest":"persona")).catch(()=>{})}return null}return kt(i,c,{digest:r})},"build"),afterEmit:l(async(e,i)=>{let o=await t;if(o?.projectId){let c=await(async()=>{try{let{collectActiveTasks:a}=await import("./task-overview-PCUZWL5Q.mjs"),r=await a(o.projectId,i);return{taskId:r.current?.id??null,goal:r.current?.description??e.source??null}}catch{return{taskId:null,goal:e.source??null}}})();z({projectId:o.projectId,sessionId:e.session_id,directory:i,taskId:c.taskId,goal:c.goal})}tt(T)||await nt(T).catch(()=>{});try{let{maybeAutoUpdate:c}=await import("./auto-updater-4TIXYSEX.mjs");c(T)}catch{}},"afterEmit")},n)}l(dn,"runSessionStartHook");export{kt as a,un as b,Pt as c,mn as d,dn as e};
11
+ `);t.push(`Session: \u25B6 Active (${n.duration})`);let e=[];if(n.commandCount>0){let s=new Set,o=[];for(let c of n.commands)s.has(c)||(s.add(c),o.push(c));e.push(`Commands: ${o.join(" \u2192 ")} (${n.commandCount} total)`)}return(n.filesRead>0||n.filesWritten>0)&&e.push(`Files: ${n.filesRead} read, ${n.filesWritten} written`),e.push(`Idle: ${n.expiresIn} until timeout`),e.length>0&&t.push(...it(e)),t.join(`
12
+ `)}getWarning(n){return n.isStale?n.commitsSinceSync>0?`\u26A0\uFE0F Context stale (${n.commitsSinceSync} commits behind). Run \`prjct sync\``:n.daysSinceSync>0?`\u26A0\uFE0F Context stale (${n.daysSinceSync} days old). Run \`prjct sync\``:"\u26A0\uFE0F Context may be stale. Run `prjct sync`":null}};function it(i){let n=Math.max(...i.map(e=>e.length)),t="\u2500".repeat(n+2);return[`\u250C${t}\u2510`,...i.map(e=>`\u2502 ${e.padEnd(n)} \u2502`),`\u2514${t}\u2518`]}l(it,"boxLines");var rt=l((i,n)=>new O(i,n),"createStalenessChecker");gt();var Et=1600,j=3,kt=4,U={minTeaser:24,maxTeaser:90};async function _t(i,n,t={}){let e=n??await E.readConfig(i);if(!e?.projectId)return null;let s=e.persona,o=t.digest?await(async()=>{try{let{memoryL0IndexForSession:h}=await import("./memory-index-KCMXQGKX.mjs");return h(e.projectId,{rebuildIfStale:!0})||ot(e.projectId)}catch{return ot(e.projectId)}})():null,c=xt(i,e.projectId),a=import("./vault-retire-notice-7XHVNHU6.mjs").then(({vaultRetirementNotice:h})=>h(e,e.projectId)),r=(async()=>{try{let{buildLandCue:h}=await import("./land-cue-DEO2AZW4.mjs");return await h(e.projectId,i,e)}catch{return null}})(),u=(async()=>{try{let{effectiveWeakModelMode:h,weakModelBanner:w}=await import("./weak-model-mode-TYJJT6JJ.mjs");return h(e)==="on"?w():null}catch{return null}})(),C=t.digest?(async()=>{try{let{formatPendingHandoffCue:h}=await import("./agent-switch-7GOGG4KG.mjs"),w=h(e.projectId);return w?`# prjct: pending handoff
13
+ ${w}`:null}catch{return null}})():Promise.resolve(null),y=t.digest?(async()=>{try{let{loadSessionContinuity:h,formatContinuitySessionCue:w}=await import("./session-continuity-VH645RGR.mjs");return w(h(e.projectId))}catch{return null}})():Promise.resolve(null),g=Pt(i,e.projectId),[d,f,S,v,_,D,R]=await Promise.all([c,a,r,u,C,y,g]);if(!R&&!s&&!o&&!d&&!f&&!S&&!v&&!_&&!D)return null;let m=["# prjct: project context",""];return R&&m.push(R,""),s&&m.push(It(s),"","> Exposed as state, not prescription. Decide whether any of this matters for the current turn."),o&&(s&&m.push(""),m.push(o)),d&&((s||o)&&m.push(""),m.push(d)),f&&((s||o||d)&&m.push(""),m.push(f)),S&&((s||o||d||f)&&m.push(""),m.push(S)),v&&((s||o||d||f||S)&&m.push(""),m.push(v)),_&&((s||o||d||f||S||v)&&m.push(""),m.push(_)),D&&((s||o||d||f||S||v||_)&&m.push(""),m.push(D)),m.join(`
14
+ `)}l(_t,"buildSessionContext");async function xt(i,n){try{let t=rt(i),e=await t.check(n);if(!e.isStale||e.commitsSinceSync<=0)return null;let s=t.getWarning(e);if(!s)return null;try{let c=await import("node:path"),a=await import("node:os"),{maybeDetachDriftRefresh:r,readDriftStamp:u,formatDriftNotice:C,driftStaleResolved:y}=await import("./drift-refresh-TD3PYPJN.mjs"),g=process.env.PRJCT_CLI_HOME?c.resolve(process.env.PRJCT_CLI_HOME):c.join(a.homedir(),".prjct-cli"),d=u(g);if(y(d))return C({warning:s,commitsSinceSync:e.commitsSinceSync,stamp:d,refreshScheduled:!1});let f=r({projectPath:i,cliHome:g,commitsSinceSync:e.commitsSinceSync}),S=u(g);return C({warning:s,commitsSinceSync:e.commitsSinceSync,stamp:S,refreshScheduled:f})}catch{}let o=await(async()=>{try{let{hasSymbolIndex:c,loadMeta:a}=await import("./symbol-graph-MH42JSPX.mjs");if(!c(n))return" Code graph empty \u2014 `prjct code reindex` (or `prjct sync`) before trace/impact.";if(e.commitsSinceSync<5)return"";let r=a(n);return` Symbol index may lag${r?.builtAt?` (index ${r.builtAt.slice(0,10)})`:""} \u2014 prefer \`prjct code reindex\` after big pulls.`}catch{return""}})();return`**Understanding may be stale:** ${s} \u2014 run \`prjct sync\` before big calls.${o}`}catch{return null}}l(xt,"buildStalenessNotice");function ot(i){let n=(()=>{try{let r=P.rerank(i,k.recall(i,{types:["gotcha","anti-pattern"],limit:j*4})).slice(0,j),u=P.rerank(i,k.recall(i,{types:["decision"],limit:j*4})).slice(0,j);return{gotchas:r,decisions:u}}catch{return null}})();if(!n)return null;let{gotchas:t,decisions:e}=n,s=(()=>{try{let r=k.recall(i,{types:["feedback","improvement-signal"],limit:40,dedupeByKey:!1});return X(r,kt)}catch{return[]}})(),o=L(i,new Set([...t,...e].map(r=>r.id))),c=(()=>{try{let r=q(i);return r?J(r,{maxConventions:4,maxPatterns:3,maxAnti:2}):null}catch{return null}})();if(t.length===0&&e.length===0&&!o&&s.length===0&&!c)return null;let a=["## What this project already knows",""];if(a.push("> Carried across sessions and model updates \u2014 this survived even if your conversation context did not. Apply these; do not re-derive from source."),s.length>0){a.push("","**How this developer works (act as them):**");for(let r of s){let u=r.rule.length>140?`${r.rule.slice(0,139)}\u2026`:r.rule;a.push(`- ${u} \`${r.sourceId}\``)}}if(c){let r=c.replace(/^## How this repo works \(project style\)\n?/,"").trim();r&&a.push("","**How this repo works (match house style):**",r)}if(t.length>0){a.push("","**Traps to avoid:**");for(let r of t)a.push(`- ${I(r,U)}`)}if(e.length>0){a.push("","**Decisions in force:**");for(let r of e)a.push(`- ${I(r,U)}`)}return o&&a.push("","**Keeps being missed:**",`- ${I(o.entry,U)} \u2014 flagged relevant-but-unused ${o.count}\xD7. Apply it or supersede it.`),a.push("","> Resolve any `mem_id` with `prjct search <id>`. Full developer model: MCP `prjct_developer`. Project style: `prjct analysis` / sync evolution."),b(a.join(`
15
+ `),Et)}l(ot,"buildKnowledgeDigest");var Tt=500,ct=2;async function un(i){let n=await E.readConfig(i).catch(()=>null);if(!n?.projectId)return null;let t=["# prjct: subagent context"];n.persona?.role&&t.push(`Role in this project: ${n.persona.role}`);try{let{resolveActiveTask:e}=await import("./task-service-SPUES5DO.mjs"),s=await e(n.projectId,i);s&&t.push(`Active work cycle (this worktree): ${s.description}`)}catch{}try{let e=P.rerank(n.projectId,k.recall(n.projectId,{types:["gotcha","anti-pattern"],limit:ct*4})).slice(0,ct);if(e.length>0){t.push("Traps to avoid:");for(let o of e)t.push(`- ${H(o)} \`${o.id}\``)}let s=L(n.projectId,new Set(e.map(o=>o.id)));s&&t.push(`Keeps being missed: ${H(s.entry)} \`${s.entry.id}\``)}catch{}return t.length<=1?null:b(t.join(`
16
+ `),Tt)}l(un,"buildSubagentDigest");function It(i){let n=[];return n.push(`## Your role in this project: **${i.role}**`),i.focus&&n.push(`Focus: ${i.focus}`),i.mcps&&i.mcps.length>0&&n.push(`Available MCPs this project expects: ${i.mcps.join(", ")}`),i.packs&&i.packs.length>0&&n.push(`Active packs: ${i.packs.join(", ")}`),n.join(`
17
+ `)}l(It,"formatPersona");async function Pt(i,n){try{let t=await import("node:path"),{execFileAsync:e}=await import("./exec-2P5VOBHM.mjs"),s=t.basename(i),o=await(async()=>{try{let{stdout:r}=await e("git",["branch","--show-current"],{cwd:i});return r.trim()}catch{return""}})(),c=n.length>12?`${n.slice(0,8)}\u2026`:n,a=["## Project identity (cwd)",`- **${s}** \xB7 id \`${c}\``];return o&&a.push(`- Branch: \`${o}\``),a.push("- Skill is portable L0 \u2014 if skill text names another project, ignore it; trust this block + `prjct context --md`."),a.join(`
18
+ `)}catch{return null}}l(Pt,"buildProjectIdentityLine");function lt(i,n,t="kimi"){let e=i.replace(/[^a-zA-Z0-9._-]/g,"_"),s=(n??`nosession-${t}`).replace(/[^a-zA-Z0-9._-]/g,"_");return at.join(W.runDir(),`kimi-session-${e}-${s}.pending`)}l(lt,"kimiSessionStampPath");async function mn(i,n,t="kimi"){let e=lt(i,n,t),s=await $.readFile(e,"utf-8").catch(()=>null);return s===null?null:(await $.rm(e,{force:!0}).catch(()=>{}),s.trim()==="digest"?"digest":"persona")}l(mn,"consumeKimiSessionInjection");function dn(i=process.cwd(),n){let t=E.readConfig(i).catch(()=>null);return V({event:"SessionStart",projectPath:i,build:l(async(e,s,o)=>{let c=s===i?await t:await E.readConfig(s).catch(()=>null),a=e.source??"startup",r=a==="startup"||a==="clear"||a==="compact";if(o==="kimi"){if(c?.projectId){let u=lt(c.projectId,e.session_id,o);await $.mkdir(at.dirname(u),{recursive:!0}).then(()=>$.writeFile(u,r?"digest":"persona")).catch(()=>{})}return null}return _t(s,c,{digest:r})},"build"),afterEmit:l(async(e,s)=>{let o=await t;if(o?.projectId){let c=await(async()=>{try{let{collectActiveTasks:a}=await import("./task-overview-P3VRH2FD.mjs"),r=await a(o.projectId,s);return{taskId:r.current?.id??null,goal:r.current?.description??e.source??null}}catch{return{taskId:null,goal:e.source??null}}})();z({projectId:o.projectId,sessionId:e.session_id,directory:s,taskId:c.taskId,goal:c.goal})}tt(T)||await nt(T).catch(()=>{});try{let{maybeAutoUpdate:c}=await import("./auto-updater-4TIXYSEX.mjs");c(T)}catch{}},"afterEmit")},n)}l(dn,"runSessionStartHook");export{_t as a,un as b,Pt as c,mn as d,dn as e};
@@ -5,7 +5,7 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{a as p}from"./chunk-V2FR2NPL.mjs";import{d as g,g as M}from"./chunk-UHVYBU7F.mjs";import{a as o}from"./chunk-E66B27AL.mjs";M();var h=300,x=3;function v(t){let e=t?.judgment?.conflictMode;if(e==="off"||e==="advisory"||e==="strict")return e;let n=t?.persona?.packs??[];return n.includes("code-strict")?"strict":n.includes("code")?"advisory":"off"}o(v,"effectiveConflictMode");function N(t){let e={action:"none",memoryIds:[],reason:"",recovery:"",message:""};if(t.mode==="off")return e;let n=new Set(t.overriddenIds??[]),r=t.candidates.filter(c=>c.id&&!n.has(c.id));if(r.length===0)return e;let i=r.filter(c=>c.confidence==="high"),l=r.filter(c=>c.confidence==="low"),s=i[0]??l[0];if(!s)return e;let f=r.map(c=>c.id),u=t.fileLabel?` on \`${t.fileLabel}\``:"",a=`Edit may contradict [${s.type}] ${m(s.content,80)} (\`${s.id}\`)${u}`,d='To supersede: `prjct remember decision "\u2026why supersede\u2026" --tags supersedes:'+s.id+'`. To lift deny for this memory: `prjct remember feedback "override conflict '+s.id+': <why>" --tags conflict:override,memory:'+s.id+"`.";return i.length===0?{action:"warn",memoryIds:f,reason:`Low-confidence preventive signal${u}: ${m(s.content,80)}`,recovery:d,message:y(a,d,f,!1)}:t.mode==="strict"?{action:"deny",memoryIds:i.map(c=>c.id),reason:a,recovery:d,message:_(a,d,i.map(c=>c.id))}:{action:"warn",memoryIds:f,reason:a,recovery:d,message:y(a,d,f,!0)}}o(N,"decisionConflictVerdict");function y(t,e,n,r){return[r?"# prjct: CONFLICT \u2014 decision/gotcha may block this path":"# prjct: heads-up \u2014 weak preventive signal","",t,"",`Memory: ${n.map(l=>`\`${l}\``).join(", ")}`,"",e,"",r?"> Not a soft nudge. Revise the edit or supersede the decision with rationale before proceeding.":"> Apply if it still holds; proceed if not."].join(`
8
+ import{b as p}from"./chunk-7PA4KPSR.mjs";import{d as g,g as M}from"./chunk-TKXOMN4K.mjs";import{a as o}from"./chunk-E66B27AL.mjs";M();var h=300,x=3;function v(t){let e=t?.judgment?.conflictMode;if(e==="off"||e==="advisory"||e==="strict")return e;let n=t?.persona?.packs??[];return n.includes("code-strict")?"strict":n.includes("code")?"advisory":"off"}o(v,"effectiveConflictMode");function N(t){let e={action:"none",memoryIds:[],reason:"",recovery:"",message:""};if(t.mode==="off")return e;let n=new Set(t.overriddenIds??[]),r=t.candidates.filter(c=>c.id&&!n.has(c.id));if(r.length===0)return e;let i=r.filter(c=>c.confidence==="high"),l=r.filter(c=>c.confidence==="low"),s=i[0]??l[0];if(!s)return e;let f=r.map(c=>c.id),u=t.fileLabel?` on \`${t.fileLabel}\``:"",a=`Edit may contradict [${s.type}] ${m(s.content,80)} (\`${s.id}\`)${u}`,d='To supersede: `prjct remember decision "\u2026why supersede\u2026" --tags supersedes:'+s.id+'`. To lift deny for this memory: `prjct remember feedback "override conflict '+s.id+': <why>" --tags conflict:override,memory:'+s.id+"`.";return i.length===0?{action:"warn",memoryIds:f,reason:`Low-confidence preventive signal${u}: ${m(s.content,80)}`,recovery:d,message:y(a,d,f,!1)}:t.mode==="strict"?{action:"deny",memoryIds:i.map(c=>c.id),reason:a,recovery:d,message:_(a,d,i.map(c=>c.id))}:{action:"warn",memoryIds:f,reason:a,recovery:d,message:y(a,d,f,!0)}}o(N,"decisionConflictVerdict");function y(t,e,n,r){return[r?"# prjct: CONFLICT \u2014 decision/gotcha may block this path":"# prjct: heads-up \u2014 weak preventive signal","",t,"",`Memory: ${n.map(l=>`\`${l}\``).join(", ")}`,"",e,"",r?"> Not a soft nudge. Revise the edit or supersede the decision with rationale before proceeding.":"> Apply if it still holds; proceed if not."].join(`
9
9
  `)}o(y,"formatWarnMessage");function _(t,e,n){return[`\u26D4 prjct conflict deny: ${t}`,`Memories: ${n.join(", ")}`,e,"Host will block Edit|Write until override or supersede. Fail-open only on hook errors, not on intentional deny."].join(" ")}o(_,"formatDenyMessage");function E(t){let e=new Set;try{let n=Date.now()-6048e5,r=g.query(t,`SELECT t.value AS value
10
10
  FROM memory_entry_tags t
11
11
  JOIN memory_entries me ON me.id = t.entry_id
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from 'module';
3
+ import { fileURLToPath as __fileURLToPath } from 'url';
4
+ import { dirname as __pathDirname } from 'path';
5
+ const require = __createRequire(import.meta.url);
6
+ const __filename = __fileURLToPath(import.meta.url);
7
+ const __dirname = __pathDirname(__filename);
8
+ import{a as I,b as R}from"./chunk-OUAS3LZ3.mjs";import{a as W}from"./chunk-ETTDRXQ6.mjs";import{a as B,c as y}from"./chunk-RLKYEL3F.mjs";import{d as E,e as b,g as _}from"./chunk-TKXOMN4K.mjs";import{b as d,h as g}from"./chunk-A6K4H3YT.mjs";import{a as c}from"./chunk-E66B27AL.mjs";g();var f={idle:{transitions:["task"],prompt:"prjct work <intent> Start working",description:"No active work cycle"},working:{transitions:["done","pause"],prompt:"prjct status done Complete work | prjct status paused Switch context",description:"Work in progress"},paused:{transitions:["resume","task","ship"],prompt:"prjct status active Continue | prjct work <new> Start different | prjct ship Ship directly",description:"Task paused"},completed:{transitions:["ship","task","pause","reopen"],prompt:"prjct ship Ship it | prjct work <next> Start next | prjct status active Reopen",description:"Task completed"},shipped:{transitions:["task"],prompt:"prjct work <intent> Start new work cycle",description:"Feature shipped"}},S=class{static{c(this,"WorkflowStateMachine")}getCurrentState(t,s){if(s){let n=(t?.activeTasks??[]).find(a=>a.workspaceId===s);return n?this.statusToState(n):"idle"}let e=t?.currentTask;return e?this.statusToState(e):(t?.pausedTasks?.length||0)>0||t?.previousTask?.status==="paused"?"paused":"idle"}statusToState(t){switch((typeof t.status=="string"?t.status:"").toLowerCase()){case"in_progress":case"working":return"working";case"paused":return"paused";case"completed":case"done":return"completed";case"shipped":return"shipped";default:return"working"}}canTransition(t,s){if(f[t].transitions.includes(s))return{valid:!0};let n=this.formatNextSteps(t).join(" | ");return{valid:!1,error:`Cannot transition to '${s}' from '${t}' state`,suggestion:`Valid next steps: ${n}`}}getNextState(t,s){switch(s){case"task":return"working";case"done":return"completed";case"pause":return"paused";case"resume":return"working";case"ship":return"shipped";case"reopen":return"working";default:return t}}getStateInfo(t){return f[t]}getPrompt(t){return f[t].prompt}getValidCommands(t){return f[t].transitions}formatNextSteps(t){return f[t].transitions.map(e=>{switch(e){case"task":return"prjct work <intent> Start new work cycle";case"done":return"prjct status done Complete current work";case"pause":return"prjct status paused Pause and switch context";case"resume":return"prjct status active Continue paused task";case"ship":return"prjct ship Ship the feature";case"reopen":return"prjct status active Reopen completed task";default:return`prjct ${e}`}})}},w=new S;_();g();async function H(r,t,s){let e={pausedCount:0};if(await r.update(t,a=>{if(!a.currentTask)return a;r.validateTransition(a,"pause"),e.pausedTask={...a.currentTask,status:"paused",pausedAt:d(),pauseReason:s};let i=[e.pausedTask,...r.getPausedTasksFromState(a)].slice(0,r.maxPausedTasks);return e.pausedCount=i.length,{...a,currentTask:null,previousTask:null,pausedTasks:i,lastUpdated:d()}}),!e.pausedTask)return null;let n=e.pausedTask;return await r.publish(t,"task.paused",{taskId:n.id,description:n.description,pausedAt:n.pausedAt,reason:s,pausedCount:e.pausedCount}),n}c(H,"pauseTask");async function O(r,t,s){let e={remainingPaused:0};if(await r.update(t,a=>{let i=r.getPausedTasksFromState(a);if(i.length===0)return a;r.validateTransition(a,"resume");let u=s?i.findIndex(x=>x.id===s):0;if(u===-1)return a;let o=i[u],k=i.filter((x,lt)=>lt!==u),{status:p,pausedAt:T,pauseReason:l,...m}=o;return e.currentTask={...m,startedAt:d(),sessionId:o.sessionId??B()},e.remainingPaused=k.length,{...a,currentTask:e.currentTask,previousTask:null,pausedTasks:k,lastUpdated:d()}}),!e.currentTask)return null;let n=e.currentTask;return await r.publish(t,"task.resumed",{taskId:n.id,description:n.description,resumedAt:n.startedAt,remainingPaused:e.remainingPaused}),n}c(O,"resumeTask");async function D(r,t){let s=await r.read(t),e=r.getPausedTasksFromState(s),n=Date.now()-r.stalenessThresholdDays*24*60*60*1e3;return e.filter(a=>new Date(a.pausedAt).getTime()<n)}c(D,"getStalePausedTasks");async function F(r,t){let s=Date.now()-r.stalenessThresholdDays*24*60*60*1e3,e=[];await r.update(t,a=>{let i=r.getPausedTasksFromState(a),u=i.filter(k=>new Date(k.pausedAt).getTime()<s);if(e.push(u),u.length===0)return a;let o=i.filter(k=>new Date(k.pausedAt).getTime()>=s);return{...a,pausedTasks:o,previousTask:null,lastUpdated:d()}});let n=e[0]??[];if(n.length===0)return[];y.archiveMany(t,n.map(a=>({entityType:"paused_task",entityId:a.id,entityData:a,summary:a.description,reason:"staleness"})));for(let a of n)await r.publish(t,"task.archived",{taskId:a.id,description:a.description,pausedAt:a.pausedAt,reason:"staleness"});return n}c(F,"archiveStalePausedTasks");g();_();var Tt=20;function gt(r){let t=(()=>{if(!r.data)return{};try{return JSON.parse(r.data)}catch{return{}}})(),s={taskId:r.id,title:t.title??r.description,classification:r.type??"improvement",startedAt:r.started_at,completedAt:r.completed_at,subtaskCount:t.subtaskCount??0,subtaskSummaries:t.subtaskSummaries??[],outcome:t.outcome??"Task completed",branchName:r.branch??"unknown"};return r.linear_id!=null&&(s.linearId=r.linear_id),t.linearUuid!=null&&(s.linearUuid=t.linearUuid),r.pr_url!=null&&(s.prUrl=r.pr_url),t.feedback&&(s.feedback=t.feedback),t.harness&&(s.harness=t.harness),r.tokens_in&&(s.tokensIn=r.tokens_in),r.tokens_out&&(s.tokensOut=r.tokens_out),s}c(gt,"rowToHistoryEntry");function P(r,t="",...s){try{return E.query(r,`SELECT id, description, type, branch, linear_id, pr_url, started_at, completed_at, tokens_in, tokens_out, data
9
+ FROM tasks
10
+ WHERE status = 'completed' AND completed_at IS NOT NULL ${t}
11
+ ORDER BY completed_at DESC, rowid DESC LIMIT ${Tt}`,...s).map(gt)}catch{return[]}}c(P,"queryHistory");async function N(r,t){await r.update(t,()=>({currentTask:null,previousTask:null,pausedTasks:[],activeTasks:[],lastUpdated:d()}))}c(N,"clearTask");async function U(r,t){let s=await r.read(t),e=r.getPausedTasksFromState(s);return s.currentTask!==null||e.length>0}c(U,"hasTask");async function J(r,t){let s=await r.read(t);return r.getPausedTasksFromState(s)[0]||null}c(J,"getPausedTask");async function L(r,t){let s=await r.read(t);return r.getPausedTasksFromState(s)}c(L,"getAllPausedTasks");async function v(r,t){return P(t)}c(v,"getTaskHistory");async function q(r,t){return P(t)[0]||null}c(q,"getMostRecentTask");async function M(r,t,s){return P(t,"AND type = ?",s)}c(M,"getTaskHistoryByType");async function $(r,t){let e=(await v(r,t)).filter(l=>l.feedback),n=[],a=[],i=[],u=[];for(let l of e){let m=l.feedback;Array.isArray(m.stackConfirmed)&&n.push(...m.stackConfirmed),Array.isArray(m.patternsDiscovered)&&a.push(...m.patternsDiscovered),Array.isArray(m.agentAccuracy)&&i.push(...m.agentAccuracy),Array.isArray(m.issuesEncountered)&&u.push(...m.issuesEncountered)}let o=[...new Set(n)],k=[...new Set(a)],p=new Map;for(let l of u)p.set(l,(p.get(l)||0)+1);let T=[...p.entries()].filter(([l,m])=>m>=2).map(([l])=>l);return{stackConfirmed:o,patternsDiscovered:k,agentAccuracy:i,issuesEncountered:[...new Set(u)],knownGotchas:T}}c($,"getAggregatedFeedback");g();var yt=c(r=>r.filter(t=>t.status==="completed").length,"countCompleted"),j=c(r=>r.filter(t=>t.status==="completed"||t.status==="failed"||t.status==="skipped").length,"countResolved");async function h(r,t,s,e){let n={};return await r.update(t,a=>{if(!a.currentTask?.subtasks)return a;let i=a.currentTask.currentSubtaskIndex||0,u=a.currentTask.subtasks[i];if(!u)return a;let o=[...a.currentTask.subtasks];o[i]=s(u);let k=i+1,p=o.length;k<p&&(o[k]={...o[k],status:"in_progress",startedAt:d()});let T=k<p?o[k]:null,l=e?Q(e(o),p):void 0;return n.value={taskId:a.currentTask.id,current:o[i],next:T,...l?{progress:l}:{}},{...a,currentTask:{...a.currentTask,subtasks:o,currentSubtaskIndex:k<p?k:i,...l?{subtaskProgress:l}:{}},lastUpdated:d()}}),n.value??null}c(h,"mutateCurrentSubtask");function Q(r,t){return{completed:r,total:t,percentage:t>0?Math.round(r/t*100):0}}c(Q,"progressFrom");async function V(r,t,s){let e=await r.update(t,i=>{if(!i.currentTask)return i;let u=s.map((o,k)=>({...o,status:k===0?"in_progress":"pending",startedAt:k===0?d():void 0,dependsOn:o.dependsOn||[]}));return{...i,currentTask:{...i.currentTask,subtasks:u,currentSubtaskIndex:0,subtaskProgress:Q(0,u.length)},lastUpdated:d()}}),n=e.currentTask?.id??null,a=e.currentTask?.subtasks??[];n&&await r.publish(t,"subtasks.created",{taskId:n,subtaskCount:a.length,subtasks:a.map(i=>({id:i.id,description:i.description,domain:i.domain}))})}c(V,"createSubtasks");async function G(r,t,s){let e=I.safeParse(s);if(!e.success){let u=e.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`);throw new Error(`Subtask completion requires handoff data:
12
+ ${u.join(`
13
+ `)}`)}let{output:n,summary:a}=e.data,i=await h(r,t,u=>({...u,status:"completed",completedAt:d(),output:n,summary:a}),yt);return i?(await r.publish(t,"subtask.completed",{taskId:i.taskId,subtaskId:i.current.id,description:i.current.description,output:n,handoff:a.outputForNextAgent,filesChanged:a.filesChanged.length,progress:i.progress}),i.next):null}c(G,"completeSubtask");async function Y(r,t){let s=await r.read(t);if(!s.currentTask?.subtasks)return null;let e=s.currentTask.currentSubtaskIndex||0;return s.currentTask.subtasks[e]||null}c(Y,"getCurrentSubtask");async function z(r,t){let s=await r.read(t);if(!s.currentTask?.subtasks)return null;let e=(s.currentTask.currentSubtaskIndex||0)+1;return s.currentTask.subtasks[e]||null}c(z,"getNextSubtask");async function C(r,t){let s=await r.read(t);if(!s.currentTask?.subtasks)return null;let e=(s.currentTask.currentSubtaskIndex||0)-1;return e<0?null:s.currentTask.subtasks[e]||null}c(C,"getPreviousSubtask");async function K(r,t){let s=await C(r,t);return s?.summary?.outputForNextAgent?{fromSubtask:s.description,outputForNextAgent:s.summary.outputForNextAgent,filesChanged:s.summary.filesChanged,whatWasDone:s.summary.whatWasDone}:null}c(K,"getPreviousHandoff");async function X(r,t){return(await r.read(t)).currentTask?.subtasks||[]}c(X,"getSubtasks");async function Z(r,t){return(await r.read(t)).currentTask?.subtaskProgress||null}c(Z,"getSubtaskProgress");async function tt(r,t){return((await r.read(t)).currentTask?.subtasks?.length||0)>0}c(tt,"hasSubtasks");async function st(r,t){let s=await r.read(t);return s.currentTask?.subtasks?s.currentTask.subtasks.every(e=>e.status==="completed"||e.status==="failed"||e.status==="skipped"):!0}c(st,"areAllSubtasksComplete");async function et(r,t,s){let e=await h(r,t,n=>({...n,status:"failed",completedAt:d(),output:`Failed: ${s}`}),j);return e?(await r.publish(t,"subtask.failed",{taskId:e.taskId,subtaskId:e.current.id,description:e.current.description,error:s}),e.next):null}c(et,"failSubtask");async function rt(r,t,s){let e=await h(r,t,n=>({...n,status:"skipped",completedAt:d(),output:`Skipped: ${s}`,skipReason:s}),j);return e?(await r.publish(t,"subtask.skipped",{taskId:e.taskId,subtaskId:e.current.id,description:e.current.description,reason:s}),e.next):null}c(rt,"skipSubtask");async function at(r,t,s){let e=await h(r,t,n=>({...n,status:"blocked",output:`Blocked: ${s}`,blockReason:s}));return e?(await r.publish(t,"subtask.blocked",{taskId:e.taskId,subtaskId:e.current.id,description:e.current.description,blocker:s}),e.next):null}c(at,"blockSubtask");g();async function nt(r,t,s,e){let n={...s,workspaceId:e,startedAt:d()};return await r.update(t,a=>{if((a.activeTasks||[]).some(i=>i.workspaceId===e))throw new Error("A task is already active in this workspace");return{...a,activeTasks:[...a.activeTasks||[],n],lastUpdated:d()}}),await r.publish(t,"task.started",{taskId:n.id,description:n.description,startedAt:n.startedAt,sessionId:n.sessionId,workspaceId:e}),n}c(nt,"startTaskInWorkspace");async function it(r,t,s){return((await r.read(t)).activeTasks||[]).find(n=>n.workspaceId===s)??null}c(it,"getCurrentTaskForWorkspace");async function ot(r,t,s,e){let a=((await r.read(t)).activeTasks||[]).find(o=>o.workspaceId===s);if(!a)return null;let i=d(),u=[];return await r.update(t,o=>(u.push((o.activeTasks||[]).find(k=>k.workspaceId===s)??a),{...o,activeTasks:(o.activeTasks||[]).filter(k=>k.workspaceId!==s),lastUpdated:i})),r.persistHistoryEntry(t,r.createTaskHistoryEntry(u.at(-1)??a,i,e)),await r.publish(t,"task.completed",{taskId:a.id,description:a.description,startedAt:a.startedAt,completedAt:i,workspaceId:s}),a}c(ot,"completeTaskInWorkspace");async function ut(r,t){return(await r.read(t)).activeTasks||[]}c(ut,"getActiveTasks");async function ct(r,t,s){if(s.size===0)return[];let e=[];await r.update(t,a=>{let i=a.activeTasks||[],u=i.filter(o=>s.has(o.workspaceId));return e.push(u),u.length===0?a:{...a,activeTasks:i.filter(o=>!s.has(o.workspaceId)),lastUpdated:d()}});let n=e[0]??[];if(n.length===0)return[];y.archiveMany(t,n.map(a=>({entityType:"workspace_task",entityId:a.id,entityData:a,summary:a.description,reason:"staleness"})));for(let a of n)await r.publish(t,"task.archived",{taskId:a.id,description:a.description,workspaceId:a.workspaceId,reason:"staleness"});return n}c(ct,"archiveOrphanedWorkspaceTasks");async function kt(r,t){return((await r.read(t)).activeTasks||[]).length}c(kt,"getActiveTaskCount");async function dt(r,t,s,e){let a=((await r.read(t)).activeTasks||[]).find(o=>o.workspaceId===s);if(!a)return null;let i=c(o=>{let k={...o};for(let[p,T]of Object.entries(e))T===null?delete k[p]:T!==void 0&&(k[p]=T);return k.workspaceId=s,k},"merge"),u=[];return await r.update(t,o=>({...o,activeTasks:(o.activeTasks||[]).map(k=>{if(k.workspaceId!==s)return k;let p=i(k);return u.push(p),p}),lastUpdated:d()})),u.at(-1)??a}c(dt,"updateWorkspaceTask");async function pt(r,t,s,e,n){let a=await r.read(t);if(n){if(!(a.activeTasks||[]).some(o=>o.workspaceId===n))return null;let u=[];return await r.update(t,o=>({...o,activeTasks:(o.activeTasks||[]).map(k=>{if(k.workspaceId!==n)return k;let p=(k.tokensIn||0)+s,T=(k.tokensOut||0)+e;return u.push({tokensIn:p,tokensOut:T}),{...k,tokensIn:p,tokensOut:T}}),lastUpdated:d()})),u.at(-1)??null}if(!a.currentTask)return null;let i=[];return await r.update(t,u=>{if(!u.currentTask)return u;let o=(u.currentTask.tokensIn||0)+s,k=(u.currentTask.tokensOut||0)+e;return i.push({tokensIn:o,tokensOut:k}),{...u,currentTask:{...u.currentTask,tokensIn:o,tokensOut:k},lastUpdated:d()}}),i.at(-1)??null}c(pt,"addTokens");var A=class extends W{static{c(this,"StateStorage")}constructor(){super("state.json",R)}getDefault(){return{currentTask:null,previousTask:null,pausedTasks:[],taskHistory:[],activeTasks:[],lastUpdated:""}}getEventType(t){return`state.${t}d`}validateTransition(t,s,e){let n=w.getCurrentState(t,e),a=w.canTransition(n,s);if(!a.valid)throw new Error(`${a.error}. ${a.suggestion||""}`.trim())}async getCurrentTask(t){return(await this.read(t)).currentTask}async getTaskSnapshot(t){let s=await this.read(t);return{currentTask:s.currentTask,activeTasks:s.activeTasks||[]}}async bumpTurnCount(t){let s={count:0,task:null};return await this.update(t,e=>{if(!e.currentTask)return e;let n=(e.currentTask.turnCount??0)+1,a={...e.currentTask,turnCount:n};return s.count=n,s.task=a,{...e,currentTask:a}}),s}async acknowledgeTurnLimit(t,s){let e={ok:!1};return await this.update(t,n=>n.currentTask?(e.ok=!0,{...n,currentTask:{...n.currentTask,turnLimitAcknowledgedAt:s}}):n),e.ok}async getPausedTasks(t){let s=await this.read(t);return this.getPausedTasksFromState(s)}async startTask(t,s){let e={};if(await this.update(t,a=>(this.validateTransition(a,"task"),e.currentTask={...s,startedAt:d()},{...a,currentTask:e.currentTask,lastUpdated:d()})),!e.currentTask)throw new Error("Failed to start task");let n=e.currentTask;return this.mirrorTaskRow(t,n,"in_progress"),await this.publishEvent(t,"task.started",{taskId:n.id,description:n.description,startedAt:n.startedAt,sessionId:n.sessionId}),n}mirrorTaskRow(t,s,e,n={}){try{b.run(t,`INSERT INTO tasks (id, description, type, status, branch, linked_spec_id, session_id, feature_id, started_at, completed_at, paused_at, pause_reason)
14
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
15
+ ON CONFLICT(id) DO UPDATE SET
16
+ description = excluded.description,
17
+ status = excluded.status,
18
+ branch = COALESCE(excluded.branch, tasks.branch),
19
+ linked_spec_id = COALESCE(excluded.linked_spec_id, tasks.linked_spec_id),
20
+ completed_at = COALESCE(excluded.completed_at, tasks.completed_at),
21
+ paused_at = excluded.paused_at,
22
+ pause_reason = excluded.pause_reason`,s.id,s.description,s.type??null,e,s.branch??null,s.linkedSpecId??null,s.sessionId??null,s.featureId??null,s.startedAt??null,n.completedAt??null,n.pausedAt??null,n.pauseReason??null)}catch{}}mirrorHistoryEntry(t,s){try{let e=JSON.stringify({title:s.title,outcome:s.outcome,subtaskCount:s.subtaskCount,subtaskSummaries:s.subtaskSummaries,feedback:s.feedback,harness:s.harness,linearUuid:s.linearUuid});b.run(t,`INSERT INTO tasks (id, description, type, status, branch, linear_id, pr_url, started_at, completed_at, tokens_in, tokens_out, data)
23
+ VALUES (?, ?, ?, 'completed', ?, ?, ?, ?, ?, ?, ?, ?)
24
+ ON CONFLICT(id) DO UPDATE SET
25
+ description = excluded.description,
26
+ type = excluded.type,
27
+ status = 'completed',
28
+ branch = COALESCE(excluded.branch, tasks.branch),
29
+ linear_id = COALESCE(excluded.linear_id, tasks.linear_id),
30
+ started_at = COALESCE(excluded.started_at, tasks.started_at),
31
+ completed_at = excluded.completed_at,
32
+ pr_url = COALESCE(excluded.pr_url, tasks.pr_url),
33
+ tokens_in = CASE WHEN excluded.tokens_in > 0 THEN excluded.tokens_in ELSE tasks.tokens_in END,
34
+ tokens_out = CASE WHEN excluded.tokens_out > 0 THEN excluded.tokens_out ELSE tasks.tokens_out END,
35
+ data = excluded.data`,s.taskId,s.title,s.classification,s.branchName==="unknown"?null:s.branchName,s.linearId??null,s.prUrl??null,s.startedAt,s.completedAt,s.tokensIn??0,s.tokensOut??0,e)}catch{}}async updateCurrentTask(t,s){return(await this.update(t,n=>{if(!n.currentTask)return n;let a={...n.currentTask};for(let[u,o]of Object.entries(s))o===null?delete a[u]:o!==void 0&&(a[u]=o);return{...n,currentTask:a,lastUpdated:d()}})).currentTask}async completeTask(t,s){let e=d(),n={};if(await this.update(t,i=>i.currentTask?(this.validateTransition(i,"done"),n.completedTask=i.currentTask,{...i,currentTask:null,previousTask:null,lastUpdated:e}):i),!n.completedTask)return null;let a=n.completedTask;return this.mirrorTaskRow(t,a,"completed",{completedAt:e}),this.mirrorHistoryEntry(t,this.createTaskHistoryEntry(a,e,s)),await this.publishEvent(t,"task.completed",{taskId:a.id,description:a.description,startedAt:a.startedAt,completedAt:e}),a}createTaskHistoryEntry(t,s,e){let n=(t.subtasks||[]).filter(u=>u.status==="completed"&&u.summary).map(u=>u.summary),a=n.length>0?n.map(u=>u.title).join(", "):"Task completed",i={taskId:t.id,title:t.parentDescription||t.description,classification:t.type||"improvement",startedAt:t.startedAt,completedAt:s,subtaskCount:t.subtasks?.length||0,subtaskSummaries:n,outcome:a,branchName:t.branch||"unknown",linearId:t.linearId,linearUuid:t.linearUuid,prUrl:t.prUrl,harness:t.harness};return e&&(i.feedback=e),t.tokensIn&&(i.tokensIn=t.tokensIn),t.tokensOut&&(i.tokensOut=t.tokensOut),i}maxPausedTasks=5;stalenessThresholdDays=30;lifecycleBackend(){return{read:this.read.bind(this),update:this.update.bind(this),publish:this.publishEvent.bind(this),validateTransition:this.validateTransition.bind(this),getPausedTasksFromState:this.getPausedTasksFromState.bind(this),maxPausedTasks:this.maxPausedTasks,stalenessThresholdDays:this.stalenessThresholdDays}}async pauseTask(t,s){let e=await H(this.lifecycleBackend(),t,s);return e&&this.mirrorTaskRow(t,e,"paused",{pausedAt:e.pausedAt,pauseReason:e.pauseReason}),e}async resumeTask(t,s){let e=await O(this.lifecycleBackend(),t,s);return e&&this.mirrorTaskRow(t,e,"in_progress"),e}getPausedTasksFromState(t){return Array.isArray(t.pausedTasks)&&t.pausedTasks.length>0?t.pausedTasks:t.previousTask?[t.previousTask]:[]}async getStalePausedTasks(t){return D(this.lifecycleBackend(),t)}async archiveStalePausedTasks(t){return F(this.lifecycleBackend(),t)}queryBackend(){return{read:this.read.bind(this),update:this.update.bind(this),getPausedTasksFromState:this.getPausedTasksFromState.bind(this)}}async clearTask(t){return N(this.queryBackend(),t)}async hasTask(t){return U(this.queryBackend(),t)}async getPausedTask(t){return J(this.queryBackend(),t)}async getAllPausedTasks(t){return L(this.queryBackend(),t)}async getTaskHistory(t){return v(this.queryBackend(),t)}async getMostRecentTask(t){return q(this.queryBackend(),t)}async getTaskHistoryByType(t,s){return M(this.queryBackend(),t,s)}async getAggregatedFeedback(t){return $(this.queryBackend(),t)}workspaceBackend(){return{read:this.read.bind(this),update:this.update.bind(this),publish:this.publishEvent.bind(this),createTaskHistoryEntry:this.createTaskHistoryEntry.bind(this),persistHistoryEntry:this.mirrorHistoryEntry.bind(this)}}async startTaskInWorkspace(t,s,e){let n=await this.read(t);this.validateTransition(n,"task",e);let a=await nt(this.workspaceBackend(),t,s,e);return this.mirrorTaskRow(t,a,"in_progress"),a}async getCurrentTaskForWorkspace(t,s){return it(this.workspaceBackend(),t,s)}async completeTaskInWorkspace(t,s,e){let n=await ot(this.workspaceBackend(),t,s,e);return n&&this.mirrorTaskRow(t,n,"completed",{completedAt:d()}),n}async getActiveTasks(t){return ut(this.workspaceBackend(),t)}async archiveOrphanedWorkspaceTasks(t,s){return ct(this.workspaceBackend(),t,s)}async getActiveTaskCount(t){return kt(this.workspaceBackend(),t)}async updateWorkspaceTask(t,s,e){return dt(this.workspaceBackend(),t,s,e)}async addTokens(t,s,e,n){return pt(this.workspaceBackend(),t,s,e,n)}subtaskBackend(){return{read:this.read.bind(this),update:this.update.bind(this),publish:this.publishEvent.bind(this)}}async createSubtasks(t,s){return V(this.subtaskBackend(),t,s)}async completeSubtask(t,s){return G(this.subtaskBackend(),t,s)}async getCurrentSubtask(t){return Y(this.subtaskBackend(),t)}async getNextSubtask(t){return z(this.subtaskBackend(),t)}async getPreviousSubtask(t){return C(this.subtaskBackend(),t)}async getPreviousHandoff(t){return K(this.subtaskBackend(),t)}async getSubtasks(t){return X(this.subtaskBackend(),t)}async getSubtaskProgress(t){return Z(this.subtaskBackend(),t)}async hasSubtasks(t){return tt(this.subtaskBackend(),t)}async areAllSubtasksComplete(t){return st(this.subtaskBackend(),t)}async failSubtask(t,s){return et(this.subtaskBackend(),t,s)}async skipSubtask(t,s){return rt(this.subtaskBackend(),t,s)}async blockSubtask(t,s){return at(this.subtaskBackend(),t,s)}},Lt=new A;export{w as a,Lt as b};
@@ -5,7 +5,7 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{a as f}from"./chunk-HEDZA6KC.mjs";import{a as i}from"./chunk-ZMLA5SKR.mjs";import{a as y}from"./chunk-V2FR2NPL.mjs";import{d as g,g as x}from"./chunk-UHVYBU7F.mjs";import{a}from"./chunk-E66B27AL.mjs";import{execFileSync as S}from"node:child_process";x();var j="land-auto",$="session-close";async function N(t){let o=L(t);if(!o)return{wrote:!1,content:null,reason:"nothing-to-land"};try{return await y.remember(t.projectPath,{type:"context",content:o,tags:{source:j,topic:$,capture:"land-v2",context_schema:"living-v2",synthesis:"deterministic"},provenance:"extracted",projectId:t.projectId}),{wrote:!0,content:o}}catch(r){return{wrote:!1,content:o,reason:`remember-failed: ${r.message}`}}}a(N,"synthesizeLandHandoff");function L(t){let o=t.cycleDescription?.trim()||null,r=f(t.projectId,t.cycleId),u=k(t.projectPath),c=b(t.projectId);if(!o&&r.length===0&&u.length===0&&c.length===0)return null;let e=[];o?e.push(`Session close: Work cycle "${i(o,120)}" still open or just closed.`):e.push("Session close: no open work cycle \u2014 landed repo + capture signals only."),e.push("Context synthesis: Passive land hand-off from durable signals (cycle, journal, commits, auto-captures). Not a model essay."),e.push(`Key data: source=${j}; topic=${$}; capture=land-v2`);let l=[];if(o&&l.push(`cycle="${i(o,100)}"`),r.length>0&&l.push(`journal: ${r.map(s=>i(s,70)).join(" \xB7 ")}`),l.length>0&&e.push(`What happened: ${l.join("; ")}`),r.length>0&&e.push(`Why it mattered: Journal trail shows progression \u2014 ${r.slice(0,2).map(s=>i(s,80)).join(" \xB7 ")}`),c.length>0){let s=c.filter(n=>n.type==="learning"||n.type==="decision"||n.type==="fact").slice(0,4),p=c.filter(n=>n.type==="gotcha"||n.type==="anti-pattern").slice(0,3);s.length>0&&e.push(`Learned this session: ${s.map(n=>`[${n.type}] ${i(n.content,100)}`).join(" \xB7 ")}`),p.length>0&&e.push(`Decision/trap: ${p.map(n=>`[${n.type}] ${i(n.content,100)}`).join(" \xB7 ")}`);let I=new Set([...s,...p]),d=c.filter(n=>!I.has(n)).slice(0,3);d.length>0&&s.length===0&&p.length===0&&e.push(`Decision/trap: ${d.map(n=>`[${n.type}] ${i(n.content,100)}`).join(" \xB7 ")}`)}u.length>0&&e.push(`Outcome: Recent commits: ${u.join("; ")}`),t.author&&e.push(`Who/author: ${t.author}`),t.model&&e.push(`Model: ${t.model}`);let m=t.tokensIn,h=t.tokensOut;if(m!=null||h!=null){let s=(m??0)+(h??0);e.push(`Token usage: in=${m??0} out=${h??0} total=${s} (compound judgment \u2014 not a fresh-window thrash loop)`)}e.push("Feature/domain: session-close"),e.push("Pattern: land auto-synthesis without agent remember"),e.push("Anti-pattern: relying on the model to remember to remember at session end"),e.push("Competitive: next window must `prjct prime` \u2014 act as this developer with SQLite judgment, not re-research from zero (GSD tax).");let w=o!=null?"Finish or pause the open cycle (`prjct status done` / `prjct pause`); next agent should `prjct work --md` or `prjct prime`.":"Next agent: `prjct prime` then pick from `prjct next --md`.";return e.push(`Next implication: ${w}`),e.join(" \xB7 ")}a(L,"buildLandHandoffContent");function k(t){try{return S("git",["log","-5","--oneline","--no-decorate"],{cwd:t,encoding:"utf-8",timeout:3e3,stdio:["ignore","pipe","ignore"]}).split(`
8
+ import{a as f}from"./chunk-HGZQWYBL.mjs";import{a as i}from"./chunk-ZMLA5SKR.mjs";import{b as y}from"./chunk-7PA4KPSR.mjs";import{d as g,g as x}from"./chunk-TKXOMN4K.mjs";import{a}from"./chunk-E66B27AL.mjs";import{execFileSync as S}from"node:child_process";x();var j="land-auto",$="session-close";async function N(t){let o=L(t);if(!o)return{wrote:!1,content:null,reason:"nothing-to-land"};try{return await y.remember(t.projectPath,{type:"context",content:o,tags:{source:j,topic:$,capture:"land-v2",context_schema:"living-v2",synthesis:"deterministic"},provenance:"extracted",projectId:t.projectId}),{wrote:!0,content:o}}catch(r){return{wrote:!1,content:o,reason:`remember-failed: ${r.message}`}}}a(N,"synthesizeLandHandoff");function L(t){let o=t.cycleDescription?.trim()||null,r=f(t.projectId,t.cycleId),u=k(t.projectPath),c=b(t.projectId);if(!o&&r.length===0&&u.length===0&&c.length===0)return null;let e=[];o?e.push(`Session close: Work cycle "${i(o,120)}" still open or just closed.`):e.push("Session close: no open work cycle \u2014 landed repo + capture signals only."),e.push("Context synthesis: Passive land hand-off from durable signals (cycle, journal, commits, auto-captures). Not a model essay."),e.push(`Key data: source=${j}; topic=${$}; capture=land-v2`);let l=[];if(o&&l.push(`cycle="${i(o,100)}"`),r.length>0&&l.push(`journal: ${r.map(s=>i(s,70)).join(" \xB7 ")}`),l.length>0&&e.push(`What happened: ${l.join("; ")}`),r.length>0&&e.push(`Why it mattered: Journal trail shows progression \u2014 ${r.slice(0,2).map(s=>i(s,80)).join(" \xB7 ")}`),c.length>0){let s=c.filter(n=>n.type==="learning"||n.type==="decision"||n.type==="fact").slice(0,4),p=c.filter(n=>n.type==="gotcha"||n.type==="anti-pattern").slice(0,3);s.length>0&&e.push(`Learned this session: ${s.map(n=>`[${n.type}] ${i(n.content,100)}`).join(" \xB7 ")}`),p.length>0&&e.push(`Decision/trap: ${p.map(n=>`[${n.type}] ${i(n.content,100)}`).join(" \xB7 ")}`);let I=new Set([...s,...p]),d=c.filter(n=>!I.has(n)).slice(0,3);d.length>0&&s.length===0&&p.length===0&&e.push(`Decision/trap: ${d.map(n=>`[${n.type}] ${i(n.content,100)}`).join(" \xB7 ")}`)}u.length>0&&e.push(`Outcome: Recent commits: ${u.join("; ")}`),t.author&&e.push(`Who/author: ${t.author}`),t.model&&e.push(`Model: ${t.model}`);let m=t.tokensIn,h=t.tokensOut;if(m!=null||h!=null){let s=(m??0)+(h??0);e.push(`Token usage: in=${m??0} out=${h??0} total=${s} (compound judgment \u2014 not a fresh-window thrash loop)`)}e.push("Feature/domain: session-close"),e.push("Pattern: land auto-synthesis without agent remember"),e.push("Anti-pattern: relying on the model to remember to remember at session end"),e.push("Competitive: next window must `prjct prime` \u2014 act as this developer with SQLite judgment, not re-research from zero (GSD tax).");let w=o!=null?"Finish or pause the open cycle (`prjct status done` / `prjct pause`); next agent should `prjct work --md` or `prjct prime`.":"Next agent: `prjct prime` then pick from `prjct next --md`.";return e.push(`Next implication: ${w}`),e.join(" \xB7 ")}a(L,"buildLandHandoffContent");function k(t){try{return S("git",["log","-5","--oneline","--no-decorate"],{cwd:t,encoding:"utf-8",timeout:3e3,stdio:["ignore","pipe","ignore"]}).split(`
9
9
  `).map(r=>r.trim()).filter(Boolean)}catch{return[]}}a(k,"recentCommits");function b(t){try{return g.query(t,`SELECT me.type, me.content
10
10
  FROM memory_entries me
11
11
  JOIN memory_entry_tags t ON t.entry_id = me.id
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{a as v}from"./chunk-ABJNOG2I.mjs";import{b as u,h as S,v as s,w as $}from"./chunk-A6K4H3YT.mjs";import{g as C,o as j}from"./chunk-UH4MD3F3.mjs";import{a as y,b as P,p as G}from"./chunk-QWQFF2UG.mjs";import{b,e as E}from"./chunk-GCDLPKOH.mjs";import{d as w}from"./chunk-PKDYFXMI.mjs";import{a as f,f as M}from"./chunk-BUDZL4DW.mjs";import{a as c}from"./chunk-E66B27AL.mjs";import h from"node:fs/promises";import W from"node:path";import*as d from"jsonc-parser";G();import k from"node:crypto";var D="6f9b2c1a-3d4e-5f60-8a7b-1c2d3e4f5a6b";function F(r,t=D){let n=Buffer.from(t.replace(/-/g,""),"hex"),i=k.createHash("sha1").update(n).update(r,"utf8").digest().subarray(0,16);i[6]=i[6]&15|80,i[8]=i[8]&63|128;let e=i.toString("hex");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20,32)}`}c(F,"uuidv5");async function N(r){let t=await P("git",["remote","get-url","origin"],{cwd:r}).then(({stdout:i})=>i.trim()||null).catch(()=>null);if(!t)return null;let{provider:n,repoSlug:o}=v(t);return!n||!o?null:`${n}:${o}`.toLowerCase()}c(N,"repoKey");async function x(r){let t=await N(r);return t?F(t):null}c(x,"deriveProjectId");M();S();j();E();G();async function m(r){try{let{stdout:t}=await y(r,{timeout:5e3});return{success:!0,output:t.trim()}}catch{return{success:!1,output:""}}}c(m,"execCommand");async function R(){let r=await m("gh api user --jq .login");if(r.success&&r.output)return r.output;let t=await m("git config --global github.user");return t.success&&t.output?t.output:null}c(R,"detectGitHubUsername");async function T(){let r=await m("git config user.name");return r.success&&r.output?r.output:null}c(T,"detectGitName");async function U(){let r=await m("git config user.email");return r.success&&r.output?r.output:null}c(U,"detectGitEmail");async function A(){let[r,t,n]=await Promise.all([R(),T(),U()]);return{github:r,email:n,name:t||r||"Unknown"}}c(A,"detect");$();function I(r){let t=[],n=d.parse(r,t,{allowTrailingComma:!0,disallowComments:!1});if(t.length>0){let o=t[0];throw new SyntaxError(`JSON parse error at offset ${o.offset}: ${d.printParseErrorCode(o.error)}`)}return n}c(I,"parseJsonc");var l=new Map,p=class{static{c(this,"ConfigManager")}async readConfig(t){let n=s.getLocalConfigPath(t),o=await h.stat(n).catch(()=>null);if(!o)return l.delete(n),null;let i=o.mtimeMs,e=l.get(n);if(e&&e.mtimeMs===i)return e.config;try{let a=await h.readFile(n,"utf-8"),g=I(a);return l.size>32&&l.clear(),l.set(n,{mtimeMs:i,config:g}),g}catch(a){return f(a)?(l.delete(n),null):(console.warn(`Warning: Could not read config at ${t}: ${w(a)}`),null)}}async writeConfig(t,n){let o=s.getLocalConfigPath(t);await C(o,n),l.delete(o)}async readGlobalConfig(t){try{let n=s.getGlobalProjectConfigPath(t),o=await h.readFile(n,"utf-8");return I(o)}catch(n){return f(n)||console.warn(`Warning: Could not read global config for ${t}: ${w(n)}`),null}}async writeGlobalConfig(t,n){let o=s.getGlobalProjectConfigPath(t);await C(o,n)}async ensureGlobalConfig(t){let n=await this.readGlobalConfig(t),o=n??(()=>{let i=u();return{projectId:t,authors:[],version:b,lastSync:i}})();return n||await this.writeGlobalConfig(t,o),o}async createConfig(t,n){let o=await x(t)??s.generateProjectId(t),i=s.getGlobalProjectPath(o),e=s.getDisplayPath(i),a=u(),g={projectId:o,dataPath:e,showMetrics:!0};await this.writeConfig(t,g);let L={projectId:o,authors:[{name:n.name||"Unknown",email:n.email||"",github:n.github||"",firstContribution:a,lastActivity:a}],version:b,created:a,lastSync:a};return await this.writeGlobalConfig(o,L),g}async updateLastSync(t){let n=await this.getProjectId(t),o=await this.readGlobalConfig(n);o&&(o.lastSync=u(),await this.writeGlobalConfig(n,o))}validateConfig(t){return!(!t||!t.projectId||!t.dataPath)}async needsMigration(t){if(!await s.hasLegacyStructure(t))return!1;if(!await s.hasConfig(t))return!0;let i=await this.readConfig(t);if(!i||!i.projectId)return!0;let e=s.getGlobalProjectPath(i.projectId);try{return(await h.readdir(W.join(e,"core"))).length===0}catch(a){return f(a),!0}}async getProjectId(t){let n=await this.readConfig(t);if(n?.projectId)return n.projectId;try{let{worktreeService:o}=await import("./worktree-service-AS7JVBK5.mjs");if(await o.detect(t)){let e=await o.getMainWorktree(t);if(e!==t){let a=await this.readConfig(e);if(a?.projectId)return a.projectId}}}catch{}return""}async findAuthor(t,n){let o=await this.readGlobalConfig(t);return!o||!o.authors?null:o.authors.find(i=>i.github===n)||null}async addAuthor(t,n){let o=await this.ensureGlobalConfig(t);if(o.authors.some(a=>a.github===n.github))return;let e=u();o.authors.push({name:n.name||"Unknown",email:n.email||"",github:n.github||"",firstContribution:e,lastActivity:e}),o.lastSync=e,await this.writeGlobalConfig(t,o)}async updateAuthorActivity(t,n){let o=await this.readGlobalConfig(t);if(!o||!o.authors)return;let i=o.authors.find(e=>e.github===n);i&&(i.lastActivity=u(),o.lastSync=i.lastActivity,await this.writeGlobalConfig(t,o))}async getCurrentAuthor(t){let n=await A(),o=await this.getProjectId(t);return await this.addAuthor(o,{name:n.name??void 0,email:n.email??void 0,github:n.github??void 0}),n.github||n.name||"Unknown"}async isConfigured(t){let n=await this.readConfig(t);return this.validateConfig(n)}async getShowMetrics(t){return(await this.readConfig(t))?.showMetrics??!0}async setShowMetrics(t,n){let o=await this.readConfig(t);o&&(o.showMetrics=n,await this.writeConfig(t,o))}async getConfigWithDefaults(t){let n=await this.readConfig(t);if(n)return n;let o=s.generateProjectId(t);return{projectId:o,dataPath:s.getDisplayPath(s.getGlobalProjectPath(o))}}},H=new p,et=H;export{A as a,et as b};
8
+ import{a as v}from"./chunk-3FEXJUO2.mjs";import{b as u,h as S,v as s,w as $}from"./chunk-A6K4H3YT.mjs";import{g as C,o as j}from"./chunk-UH4MD3F3.mjs";import{a as y,b as P,p as G}from"./chunk-QWQFF2UG.mjs";import{b,e as E}from"./chunk-AEDB75AK.mjs";import{d as w}from"./chunk-PKDYFXMI.mjs";import{a as f,f as M}from"./chunk-BUDZL4DW.mjs";import{a as c}from"./chunk-E66B27AL.mjs";import h from"node:fs/promises";import W from"node:path";import*as d from"jsonc-parser";G();import k from"node:crypto";var D="6f9b2c1a-3d4e-5f60-8a7b-1c2d3e4f5a6b";function F(r,t=D){let n=Buffer.from(t.replace(/-/g,""),"hex"),i=k.createHash("sha1").update(n).update(r,"utf8").digest().subarray(0,16);i[6]=i[6]&15|80,i[8]=i[8]&63|128;let e=i.toString("hex");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20,32)}`}c(F,"uuidv5");async function N(r){let t=await P("git",["remote","get-url","origin"],{cwd:r}).then(({stdout:i})=>i.trim()||null).catch(()=>null);if(!t)return null;let{provider:n,repoSlug:o}=v(t);return!n||!o?null:`${n}:${o}`.toLowerCase()}c(N,"repoKey");async function x(r){let t=await N(r);return t?F(t):null}c(x,"deriveProjectId");M();S();j();E();G();async function m(r){try{let{stdout:t}=await y(r,{timeout:5e3});return{success:!0,output:t.trim()}}catch{return{success:!1,output:""}}}c(m,"execCommand");async function R(){let r=await m("gh api user --jq .login");if(r.success&&r.output)return r.output;let t=await m("git config --global github.user");return t.success&&t.output?t.output:null}c(R,"detectGitHubUsername");async function T(){let r=await m("git config user.name");return r.success&&r.output?r.output:null}c(T,"detectGitName");async function U(){let r=await m("git config user.email");return r.success&&r.output?r.output:null}c(U,"detectGitEmail");async function A(){let[r,t,n]=await Promise.all([R(),T(),U()]);return{github:r,email:n,name:t||r||"Unknown"}}c(A,"detect");$();function I(r){let t=[],n=d.parse(r,t,{allowTrailingComma:!0,disallowComments:!1});if(t.length>0){let o=t[0];throw new SyntaxError(`JSON parse error at offset ${o.offset}: ${d.printParseErrorCode(o.error)}`)}return n}c(I,"parseJsonc");var l=new Map,p=class{static{c(this,"ConfigManager")}async readConfig(t){let n=s.getLocalConfigPath(t),o=await h.stat(n).catch(()=>null);if(!o)return l.delete(n),null;let i=o.mtimeMs,e=l.get(n);if(e&&e.mtimeMs===i)return e.config;try{let a=await h.readFile(n,"utf-8"),g=I(a);return l.size>32&&l.clear(),l.set(n,{mtimeMs:i,config:g}),g}catch(a){return f(a)?(l.delete(n),null):(console.warn(`Warning: Could not read config at ${t}: ${w(a)}`),null)}}async writeConfig(t,n){let o=s.getLocalConfigPath(t);await C(o,n),l.delete(o)}async readGlobalConfig(t){try{let n=s.getGlobalProjectConfigPath(t),o=await h.readFile(n,"utf-8");return I(o)}catch(n){return f(n)||console.warn(`Warning: Could not read global config for ${t}: ${w(n)}`),null}}async writeGlobalConfig(t,n){let o=s.getGlobalProjectConfigPath(t);await C(o,n)}async ensureGlobalConfig(t){let n=await this.readGlobalConfig(t),o=n??(()=>{let i=u();return{projectId:t,authors:[],version:b,lastSync:i}})();return n||await this.writeGlobalConfig(t,o),o}async createConfig(t,n){let o=await x(t)??s.generateProjectId(t),i=s.getGlobalProjectPath(o),e=s.getDisplayPath(i),a=u(),g={projectId:o,dataPath:e,showMetrics:!0};await this.writeConfig(t,g);let L={projectId:o,authors:[{name:n.name||"Unknown",email:n.email||"",github:n.github||"",firstContribution:a,lastActivity:a}],version:b,created:a,lastSync:a};return await this.writeGlobalConfig(o,L),g}async updateLastSync(t){let n=await this.getProjectId(t),o=await this.readGlobalConfig(n);o&&(o.lastSync=u(),await this.writeGlobalConfig(n,o))}validateConfig(t){return!(!t||!t.projectId||!t.dataPath)}async needsMigration(t){if(!await s.hasLegacyStructure(t))return!1;if(!await s.hasConfig(t))return!0;let i=await this.readConfig(t);if(!i||!i.projectId)return!0;let e=s.getGlobalProjectPath(i.projectId);try{return(await h.readdir(W.join(e,"core"))).length===0}catch(a){return f(a),!0}}async getProjectId(t){let n=await this.readConfig(t);if(n?.projectId)return n.projectId;try{let{worktreeService:o}=await import("./worktree-service-AS7JVBK5.mjs");if(await o.detect(t)){let e=await o.getMainWorktree(t);if(e!==t){let a=await this.readConfig(e);if(a?.projectId)return a.projectId}}}catch{}return""}async findAuthor(t,n){let o=await this.readGlobalConfig(t);return!o||!o.authors?null:o.authors.find(i=>i.github===n)||null}async addAuthor(t,n){let o=await this.ensureGlobalConfig(t);if(o.authors.some(a=>a.github===n.github))return;let e=u();o.authors.push({name:n.name||"Unknown",email:n.email||"",github:n.github||"",firstContribution:e,lastActivity:e}),o.lastSync=e,await this.writeGlobalConfig(t,o)}async updateAuthorActivity(t,n){let o=await this.readGlobalConfig(t);if(!o||!o.authors)return;let i=o.authors.find(e=>e.github===n);i&&(i.lastActivity=u(),o.lastSync=i.lastActivity,await this.writeGlobalConfig(t,o))}async getCurrentAuthor(t){let n=await A(),o=await this.getProjectId(t);return await this.addAuthor(o,{name:n.name??void 0,email:n.email??void 0,github:n.github??void 0}),n.github||n.name||"Unknown"}async isConfigured(t){let n=await this.readConfig(t);return this.validateConfig(n)}async getShowMetrics(t){return(await this.readConfig(t))?.showMetrics??!0}async setShowMetrics(t,n){let o=await this.readConfig(t);o&&(o.showMetrics=n,await this.writeConfig(t,o))}async getConfigWithDefaults(t){let n=await this.readConfig(t);if(n)return n;let o=s.generateProjectId(t);return{projectId:o,dataPath:s.getDisplayPath(s.getGlobalProjectPath(o))}}},H=new p,et=H;export{A as a,et as b};
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from 'module';
3
+ import { fileURLToPath as __fileURLToPath } from 'url';
4
+ import { dirname as __pathDirname } from 'path';
5
+ const require = __createRequire(import.meta.url);
6
+ const __filename = __fileURLToPath(import.meta.url);
7
+ const __dirname = __pathDirname(__filename);
8
+ import{a as v}from"./chunk-IDPBMN3Q.mjs";import{a as A,b as N,h as B}from"./chunk-UUULLTQV.mjs";import{a as T}from"./chunk-GAOQHD5S.mjs";import{a as D,b as k,e as u,g as x}from"./chunk-TKXOMN4K.mjs";import{c as S,d as C,e as w,f as O,g as M}from"./chunk-GCKILEXJ.mjs";import{a as _}from"./chunk-E66B27AL.mjs";x();k();B();function U(r){let e=u.get(r,`SELECT
9
+ (SELECT COUNT(*) FROM memory_entries) AS memCount,
10
+ (SELECT MAX(rowid) FROM memory_entries) AS memMaxRowid,
11
+ (SELECT COUNT(deleted_at) FROM memory_entries) AS memDeleted,
12
+ (SELECT MAX(deleted_at) FROM memory_entries) AS memMaxDeleted,
13
+ (SELECT COUNT(*) FROM memory_entry_tags) AS tagCount,
14
+ (SELECT MAX(rowid) FROM memory_entry_tags) AS tagMaxRowid,
15
+ (SELECT COUNT(*) FROM shipped_features) AS shipCount,
16
+ (SELECT MAX(rowid) FROM shipped_features) AS shipMaxRowid`);return e?[e.memCount,e.memMaxRowid??0,e.memDeleted,e.memMaxDeleted??0,e.tagCount,e.tagMaxRowid??0,e.shipCount,e.shipMaxRowid??0].join(":"):"empty"}_(U,"memoryVaultStamp");var L=new Map,H=25,$=4,q=100,I=["supersedes","duplicates","superseded-by"];function b(r,e,t){let n=r.get(e);if(n!==void 0)return n;let i=t();return r.set(e,i),i}_(b,"getOrCreateMapValue");function V(r){try{let e=I.map(()=>"?").join(","),t=u.query(r,`SELECT t.entry_id, t.key, t.value
17
+ FROM memory_entry_tags t
18
+ JOIN memory_entries m ON m.id = t.entry_id
19
+ WHERE m.deleted_at IS NULL
20
+ AND t.is_machine = 0
21
+ AND t.key IN (${e})`,...I),n=new Map;for(let s of t){let c=b(n,s.entry_id,()=>({}));c[s.key]=s.value}let i=[...n.entries()].map(([s,c])=>({id:s,tags:c}));return M(i)}catch{return new Set}}_(V,"collectMirrorSupersededIds");function F(r,e){let t=new Map;if(e.length===0)return t;let n=e.map(()=>"?").join(","),i=u.query(r,`SELECT entry_id, key, value FROM memory_entry_tags WHERE entry_id IN (${n})`,...e);for(let s of i){let c=b(t,s.entry_id,()=>({}));c[s.key]=s.value}return t}_(F,"batchTagsByEntryId");function R(r,e,...t){let n=u.query(r,`SELECT id, type, content, provenance, created_at
22
+ FROM memory_entries
23
+ WHERE deleted_at IS NULL ${e}`,...t);if(n.length===0)return[];let i=F(r,n.map(s=>s.id));return n.map(s=>({id:s.id,type:s.type,content:s.content,tags:i.get(s.id)??{},rememberedAt:new Date(s.created_at).toISOString(),provenance:s.provenance??"declared"}))}_(R,"loadV2Entries");function Y(r,e,t){if(t&&t.length>0){let n=t.map(()=>"?").join(",");return R(r,`AND type IN (${n}) ORDER BY created_at DESC, rowid DESC LIMIT ?`,...t,e)}return R(r,"ORDER BY created_at DESC, rowid DESC LIMIT ?",e)}_(Y,"recallEntriesFromV2");var P={applyTopicSupersession(r,e,t,n){try{let i=u.get(r,`SELECT COUNT(*) AS c FROM memory_entries
24
+ WHERE project_id = ? AND type = ? AND content_hash != ?
25
+ AND (topic_key = ? OR id IN (
26
+ SELECT entry_id FROM memory_entry_tags WHERE key IN ('topic', 'key') AND value = ?
27
+ ))`,r,e,t,n,n)?.c??0;u.run(r,`UPDATE memory_entries SET topic_key = ?, revision_count = ?
28
+ WHERE project_id = ? AND type = ? AND content_hash = ? AND deleted_at IS NULL`,n,i,r,e,t),u.run(r,`UPDATE memory_entries SET deleted_at = ?
29
+ WHERE project_id = ? AND type = ? AND deleted_at IS NULL AND content_hash != ?
30
+ AND (topic_key = ? OR id IN (
31
+ SELECT entry_id FROM memory_entry_tags WHERE key IN ('topic', 'key') AND value = ?
32
+ ))`,Date.now(),r,e,t,n,n)}catch{}},async remember(r,e){let t={...e.tags??{}},n=e.provenance??"declared",i=D(e.content);{let a=await import("./trust-boundary-EX65SUYR.mjs").then(l=>l.evaluateMemoryContent).catch(()=>null);if(a){let l=a(e.content,{force:e.force});if(!l.allow){if(e.requireWrite)throw new Error(l.denyMessage);return}}}let{classifyCapturePrecision:s}=await import("./precision-classifier-IVVAXE26.mjs"),c=s(e.content,e.type,{force:e.force===!0});if(c.action==="refuse"){if(e.requireWrite)throw new Error(`precision refuse (${c.reasonCode}): ${c.reason}`);return}c.action==="demote"&&c.demoteTo&&(t.shape_demoted="true",t.original_type=e.type,t.precision_reason=c.reasonCode),e.force&&(t["precision:force"]="true");let d=c.action==="demote"&&c.demoteTo?c.demoteTo:e.type,m=e.projectId??await(async()=>{try{let{default:a}=await import("./config-manager-XDKOTIJM.mjs");return(await a.readConfig(r))?.projectId}catch{return}})();if(!t.file)try{let{inferMemoryFileTag:a}=await import("./infer-memory-file-PIAZ542H.mjs"),l=m?await(async()=>{try{let{stateStorage:E}=await import("./state-storage-EMWLIFQJ.mjs"),p=(await E.getCurrentTask(m))?.likelyFiles;return Array.isArray(p)?p.map(f=>typeof f=="string"?f:f?.path).filter(f=>typeof f=="string"&&f.length>0):null}catch{return null}})():null,h=a({content:e.content,tags:t,projectPath:r,cycleFiles:l});h&&(t.file=h,t.file_source="inferred")}catch{}let y=t.topic??t.key;if(m){try{if(u.get(m,"SELECT id FROM memory_entries WHERE content_hash = ? AND type = ? AND deleted_at IS NULL LIMIT 1",i,d)){y&&this.applyTopicSupersession(m,d,i,y);return}}catch{}try{let{captureGate:a}=await import("./capture-gate-DIPHPNIC.mjs"),l=a(m,d,e.content,t);if(!l.accept){if(e.requireWrite)throw new Error(`capture refused: ${l.reason}`);return}}catch(a){if(e.requireWrite&&a instanceof Error&&a.message.startsWith("capture refused"))throw a}}let o=await v.log(r,`${A}${d}`,{content:e.content,tags:t,source:e.source,provenance:n,content_hash:i,...m?{project_id:m}:{}},void 0,m||e.requireWrite?{...m?{projectId:m}:{},required:e.requireWrite}:void 0),g=m??o?.projectId;if(g&&y&&o?.eventId!=null&&this.applyTopicSupersession(g,d,i,y),o?.projectId)try{let{usefulnessService:a}=await import("./usefulness-TBD5EYAL.mjs");a.recordReferences(o.projectId,e.content,t),a.recordCorrection(o.projectId,t)}catch{}if(g)try{let{publishCRUD:a}=await import("./publish-helper-ZSL27HSX.mjs"),l=t.spec_id??t.task_id??t.id??e.source??`mem-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await a({projectId:g,entityType:"memories",entityId:l,eventType:"upsert",data:{id:l,type:d,content:e.content,tags:t,source:e.source??null,provenance:n,created_at:new Date().toISOString(),rememberedAt:new Date().toISOString()}})}catch{}},searchFts(r,e,t){if(e.length===0||t<=0)return[];let n=e.map(o=>T(o).replace(/[^a-z0-9-]/gi,"")).filter(o=>o.length>=2);if(n.length===0)return[];let i=n.map(o=>`"${o}"*`).join(" OR "),s=(()=>{try{return u.query(r,`SELECT m.id, m.content, m.type, m.provenance, m.created_at
33
+ FROM memory_entries_fts ft
34
+ JOIN memory_entries m ON m.rowid = ft.rowid
35
+ WHERE memory_entries_fts MATCH ?
36
+ AND m.deleted_at IS NULL
37
+ ORDER BY bm25(memory_entries_fts) ASC, m.created_at DESC
38
+ LIMIT ?`,i,t*2)}catch{return[]}})();if(s.length===0)return[];let c=F(r,s.map(o=>o.id)),d=s.map(o=>({id:o.id,type:o.type??"fact",content:o.content,tags:c.get(o.id)??{},rememberedAt:new Date(o.created_at).toISOString(),provenance:o.provenance??"declared"})),m=V(r);return(m.size>0?d.filter(o=>!m.has(o.id)):d).slice(0,t)},recall(r,e={}){let t=e.limit??H,n=Math.max(t*$,q),i=e.types&&e.types.length>0?new Set(e.types):null,s=i?i.has("shipped"):!0,c=i?[...i].some(p=>p!=="shipped"):!0,d=i?[...i].filter(p=>p!=="shipped"):void 0,m=c?Y(r,n,d):[],y=s?u.query(r,"SELECT id, name, type, shipped_at, data FROM shipped_features ORDER BY shipped_at DESC LIMIT ?",n):[],o=[...m,...y.map(S)],g=i?o.filter(p=>i.has(p.type)):o,a=e.tags?g.filter(p=>w(p,e.tags??{})):g,h=[...e.topic?a.filter(p=>C(p,e.topic)):a].sort((p,f)=>f.rememberedAt.localeCompare(p.rememberedAt)),E=e.dedupeByKey!==!1?O(h):h;return(()=>{if(e.pruneSuperseded===!1)return E;let p=M(E);return p.size>0?E.filter(f=>!p.has(f.id)):E})().slice(0,t)},recallForFile(r,e,t=3,n={}){if(!e)return[];let i=e.split("/").pop()??e,s=_(a=>a.type==="gotcha"||a.type==="red-herring"||a.type==="anti-pattern"||a.tags?.pattern==="recurring-bug","isPreventive"),c=Math.max(t*5,15),d=(()=>{try{return R(r,`AND file IS NOT NULL
39
+ AND (file = ? OR ? LIKE '%/' || file OR file = ? OR file LIKE '%/' || ?)
40
+ ORDER BY created_at DESC, rowid DESC
41
+ LIMIT ?`,e,e,i,i,c).filter(s)}catch{return[]}})(),m=n.preventiveOnly?[]:(()=>{try{return R(r,"AND type = ? ORDER BY created_at DESC, rowid DESC LIMIT 200","context").filter(l=>(l.tags?.files??"").split(",").map(E=>E.trim()).some(E=>E===e||E===i||E.endsWith(`/${i}`)))}catch{return[]}})(),y=[...d,...m],o=M(y);return(o.size>0?y.filter(a=>!o.has(a.id)):y).slice(0,t)},getById(r,e){let t=String(e).trim().match(/^(?:mem[_-])?(\d+)$/i);if(!t)return null;try{return R(r,"AND id = ?",`mem_${t[1]}`)[0]??null}catch{return null}},countByType(r,e){try{return u.get(r,"SELECT COUNT(*) AS n FROM memory_entries WHERE project_id IN (?, 'local') AND type = ? AND deleted_at IS NULL",r,e)?.n??0}catch{return 0}},recallByType(r,e,t){if(t<=0)return[];try{return R(r,"AND type = ? ORDER BY created_at DESC, rowid DESC LIMIT ?",e,t)}catch{return[]}},forget(r,e){let t=String(e).trim().match(/^(?:mem[_-])?(\d+)$/i);if(!t)return!1;let n=Number(t[1]),i=`mem_${n}`,s=(()=>{try{return u.get(r,"SELECT id FROM events WHERE id = ? AND type LIKE ?",n,`${N}%`)?(u.run(r,"DELETE FROM events WHERE id = ?",n),!0):!1}catch{return!1}})();try{u.run(r,"DELETE FROM memory_embeddings WHERE memory_id = ?",i)}catch{}let c=(()=>{try{return u.run(r,"UPDATE memory_entries SET deleted_at = ? WHERE id = ? AND deleted_at IS NULL",Date.now(),i).changes>0}catch{return!1}})();return s||c},expandWithLinks(r,e,t=5){if(e.length===0||t<=0)return[];let n=/\bmem[_-](\d+)\b/g,i=["resolves","relates","supersedes","superseded-by","duplicates","spec"],s=new Set(e.map(d=>d.id)),c=[];for(let d of e){if(c.length>=t)break;let m=new Set;for(let y of i){let o=d.tags?.[y];if(o)for(let g of String(o).matchAll(n))m.add(`mem_${g[1]}`)}for(let y of d.content.matchAll(n))m.add(`mem_${y[1]}`);for(let y of m){if(c.length>=t)break;if(s.has(y))continue;s.add(y);let o=P.getById(r,y);o&&c.push(o)}}return c},unembeddedEntriesForIndex(r,e){try{let t=R(r,`AND type != ?
42
+ AND NOT EXISTS (
43
+ SELECT 1 FROM memory_embeddings me
44
+ WHERE me.memory_id = memory_entries.id AND me.model = ?
45
+ )
46
+ ORDER BY created_at DESC, rowid DESC`,"improvement-signal",e),n=u.query(r,`SELECT s.id, s.name, s.type, s.shipped_at, s.data FROM shipped_features s
47
+ WHERE NOT EXISTS (
48
+ SELECT 1 FROM memory_embeddings me
49
+ WHERE me.memory_id = 'ship_' || s.id AND me.model = ?
50
+ )
51
+ ORDER BY s.shipped_at DESC`,e);return[...t,...n.map(S)]}catch{return[]}},allEntriesForIndex(r){try{let e=U(r),t=L.get(r);if(t&&t.stamp===e)return[...t.entries];let n=R(r,"ORDER BY created_at DESC, rowid DESC"),i=u.query(r,"SELECT id, name, type, shipped_at, data FROM shipped_features ORDER BY shipped_at DESC"),s=[...n,...i.map(S)];return L.set(r,{stamp:e,entries:s}),[...s]}catch{return[]}}};export{U as a,P as b};
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{a as r}from"./chunk-RTEEXGEA.mjs";import{c as d}from"./chunk-M5E2YOZ4.mjs";import{a as i}from"./chunk-E66B27AL.mjs";var u={upsert:"updated",delete:"deleted"},o={value:null};async function p(){if(o.value)return o.value;try{let{default:e}=await import("./auth-config-JIITQ6GY.mjs"),t=e;if(typeof t.getDeviceId=="function"){let n=await t.getDeviceId();return o.value=n,n}return"unknown-device"}catch{return"unknown-device"}}i(p,"resolveDeviceId");async function v(e){try{let t=await p(),n=d(e.data),c={type:`${e.entityType}.${u[e.eventType]}`,path:[e.entityType,e.entityId],data:e.data,timestamp:new Date().toISOString(),projectId:e.projectId,entityType:e.entityType,entityId:e.entityId,eventType:e.eventType,contentHash:n,deviceId:t,originDeviceId:e.originDeviceId??t,revisionCount:e.revisionCount??1};await r.publish(c)}catch{}}i(v,"publishCRUD");function a(e){v(e)}i(a,"publishCRUDSync");export{v as a,a as b};
8
+ import{a as r}from"./chunk-AORD3YDQ.mjs";import{c as d}from"./chunk-M5E2YOZ4.mjs";import{a as i}from"./chunk-E66B27AL.mjs";var u={upsert:"updated",delete:"deleted"},o={value:null};async function p(){if(o.value)return o.value;try{let{default:e}=await import("./auth-config-JIITQ6GY.mjs"),t=e;if(typeof t.getDeviceId=="function"){let n=await t.getDeviceId();return o.value=n,n}return"unknown-device"}catch{return"unknown-device"}}i(p,"resolveDeviceId");async function v(e){try{let t=await p(),n=d(e.data),c={type:`${e.entityType}.${u[e.eventType]}`,path:[e.entityType,e.entityId],data:e.data,timestamp:new Date().toISOString(),projectId:e.projectId,entityType:e.entityType,entityId:e.entityId,eventType:e.eventType,contentHash:n,deviceId:t,originDeviceId:e.originDeviceId??t,revisionCount:e.revisionCount??1};await r.publish(c)}catch{}}i(v,"publishCRUD");function a(e){v(e)}i(a,"publishCRUDSync");export{v as a,a as b};
@@ -5,7 +5,7 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{d as b}from"./chunk-SYHDEUVU.mjs";import{a as j}from"./chunk-GCKILEXJ.mjs";import{c as p,e as A}from"./chunk-GCDLPKOH.mjs";import{b as w}from"./chunk-PKDYFXMI.mjs";import{a as e}from"./chunk-E66B27AL.mjs";import g from"node:fs";import H from"node:fs/promises";import m from"node:path";var I=j.join("/"),R="Generated with [p/](https://www.prjct.app/)",P="<!-- prjct:start - DO NOT REMOVE THIS MARKER -->",L="<!-- prjct:end - DO NOT REMOVE THIS MARKER -->",n={rag:"prjct is a RAG-backed project memory harness; do not preload project history.",entrypoint:'Tasks \u2192 `prjct work "\u2026"`. Known cmds (`sync`/`search`/`remember`/\u2026) \u2192 `prjct <cmd>` \u2014 never work-wrap.',pull:"Pull only what surfaces: `prjct search` / `context memory` / `guard` / MCP \u2014 not something to load wholesale.",remember:'Save synthesized memory in English: `prjct remember <decision|learning|gotcha|context> "<text>"`.',kb:`KB (\`${I}\`): \`remember <facet>\` / \`context memory <facet>\` \u2014 on demand, never injected here.`,ship:"Ship only after user OKs: `prjct ship --md`.",loop:"Loop: land; H2+ intent; tip\u2192user SoT; close.",identity:"L0 portable; id=cwd."};function S(){return`${["---","name: prjct","description: prjct work cycles + memory; run prjct verbs, do not preload context.","---","","# prjct","","Run `prjct <cmd> --md` and follow it.","",`- ${n.rag}`,`- ${n.entrypoint}`,`- ${n.pull}`,`- ${n.remember}`,`- ${n.kb}`,`- ${n.ship}`,`- ${n.loop}`,`- ${n.identity}`,"",`Commit footer: \`${R}\``].join(`
8
+ import{d as b}from"./chunk-SYHDEUVU.mjs";import{a as j}from"./chunk-GCKILEXJ.mjs";import{c as p,e as A}from"./chunk-AEDB75AK.mjs";import{b as w}from"./chunk-PKDYFXMI.mjs";import{a as e}from"./chunk-E66B27AL.mjs";import g from"node:fs";import H from"node:fs/promises";import m from"node:path";var I=j.join("/"),R="Generated with [p/](https://www.prjct.app/)",P="<!-- prjct:start - DO NOT REMOVE THIS MARKER -->",L="<!-- prjct:end - DO NOT REMOVE THIS MARKER -->",n={rag:"prjct is a RAG-backed project memory harness; do not preload project history.",entrypoint:'Tasks \u2192 `prjct work "\u2026"`. Known cmds (`sync`/`search`/`remember`/\u2026) \u2192 `prjct <cmd>` \u2014 never work-wrap.',pull:"Pull only what surfaces: `prjct search` / `context memory` / `guard` / MCP \u2014 not something to load wholesale.",remember:'Save synthesized memory in English: `prjct remember <decision|learning|gotcha|context> "<text>"`.',kb:`KB (\`${I}\`): \`remember <facet>\` / \`context memory <facet>\` \u2014 on demand, never injected here.`,ship:"Ship only after user OKs: `prjct ship --md`.",loop:"Loop: land; H2+ intent; tip\u2192user SoT; close.",identity:"L0 portable; id=cwd."};function S(){return`${["---","name: prjct","description: prjct work cycles + memory; run prjct verbs, do not preload context.","---","","# prjct","","Run `prjct <cmd> --md` and follow it.","",`- ${n.rag}`,`- ${n.entrypoint}`,`- ${n.pull}`,`- ${n.remember}`,`- ${n.kb}`,`- ${n.ship}`,`- ${n.loop}`,`- ${n.identity}`,"",`Commit footer: \`${R}\``].join(`
9
9
  `)}
10
10
  `}e(S,"buildCompactSkill");var M=S,_=S;function O(t){return`${["<!-- prjct:start - DO NOT REMOVE THIS MARKER -->","# p/ \u2014 Context layer for AI agents","","Skills auto-activate for: work, intent, ship, sync, guard, remember, search, insights, performance","Other commands: run `prjct <command> --md` and follow CLI output","","Flow: known verbs run as `prjct <cmd> --md` (sync, search, remember, ship, guard, land, prime\u2026).",'`prjct work` is only for task/work cycles \u2014 never wrap a bare verb as work "sync".',"Substantive implementation follows the persisted work-cycle station from `prjct work --md`:","reviewed intent, evidence, tests when required, then code.","Sync analysis: prefer schema v1 JSON via `prjct analysis-save-llm` (markdown = thin notes only).","","Data:","- Persist everything (memories, context, intents) in ENGLISH, whatever language the user speaks",`- ${n.rag}`,`- ${n.entrypoint}`,`- ${n.pull}`,`- Sovereign knowledge base \u2014 ${n.kb}`,`- ${n.remember}`,`- ${n.loop}`,"- On close, save synthesized context; raw quotes, counters, detector rows, and transcript chunks are inputs, not final memory","- prjct remembers and shows the path; the agent decides how to execute with its own native tools","- Treat prjct output as signals, not a prescriptive harness",`- Commit footer: \`${R}\``,"- Path resolution: `.prjct/prjct.config.json` \u2192 `~/.prjct-cli/projects/{projectId}`","- Storage: `prjct` CLI (SQLite internally)","- Worktree hygiene: if working in a git worktree, remove it AFTER its PR merges \u2014 `git worktree remove` from the main worktree; never with uncommitted/unpushed work, never `--force`","",`Crew (opt-in via \`prjct crew install\`): Leader (blue) \xB7 Implementer (purple) \xB7 Reviewer (pink). Subagent dispatch is Claude-Code-only; in ${t}, identify the role you are playing explicitly.`,"","**Auto-managed by prjct-cli** | https://prjct.app","<!-- prjct:end - DO NOT REMOVE THIS MARKER -->"].join(`
11
11
  `)}
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{e as g,f as l}from"./chunk-BUDZL4DW.mjs";import{a as r,c as u,d as f}from"./chunk-E66B27AL.mjs";var m={};f(m,{PACKAGE_ROOT:()=>d,VERSION:()=>R,getPackageRoot:()=>i,getVersion:()=>p,resetPackageRoot:()=>v});import a from"node:fs";import s from"node:path";function i(){if(n.packageRoot)return n.packageRoot;let o=r((e,t)=>{if(t>=5)return null;let c=s.join(e,"package.json");if(a.existsSync(c))try{if(JSON.parse(a.readFileSync(c,"utf-8")).name==="prjct-cli")return e}catch{}return o(s.dirname(e),t+1)},"findPackageRoot");return n.packageRoot=o(__dirname,0)??s.join(__dirname,"..","..",".."),n.packageRoot}function p(){if(n.version)return n.version;let o="3.95.0";if(o&&/^\d+\.\d+\.\d+/.test(o))return n.version=o,n.version;try{let e=s.join(i(),"package.json"),t=JSON.parse(a.readFileSync(e,"utf-8"));return n.version=t.version,n.version}catch(e){return process.env.PRJCT_DEBUG==="1"&&console.error("Failed to read version from package.json:",g(e)),"0.0.0"}}function v(o){n.packageRoot=o,n.version=null}var n,R,d,P=u(()=>{"use strict";l();n={version:null,packageRoot:null};r(i,"getPackageRoot");r(p,"getVersion");r(v,"resetPackageRoot");R=p(),d=i()});export{p as a,R as b,d as c,m as d,P as e};
8
+ import{e as g,f as l}from"./chunk-BUDZL4DW.mjs";import{a as r,c as u,d as f}from"./chunk-E66B27AL.mjs";var m={};f(m,{PACKAGE_ROOT:()=>d,VERSION:()=>R,getPackageRoot:()=>i,getVersion:()=>p,resetPackageRoot:()=>v});import a from"node:fs";import s from"node:path";function i(){if(n.packageRoot)return n.packageRoot;let o=r((e,t)=>{if(t>=5)return null;let c=s.join(e,"package.json");if(a.existsSync(c))try{if(JSON.parse(a.readFileSync(c,"utf-8")).name==="prjct-cli")return e}catch{}return o(s.dirname(e),t+1)},"findPackageRoot");return n.packageRoot=o(__dirname,0)??s.join(__dirname,"..","..",".."),n.packageRoot}function p(){if(n.version)return n.version;let o="3.97.0";if(o&&/^\d+\.\d+\.\d+/.test(o))return n.version=o,n.version;try{let e=s.join(i(),"package.json"),t=JSON.parse(a.readFileSync(e,"utf-8"));return n.version=t.version,n.version}catch(e){return process.env.PRJCT_DEBUG==="1"&&console.error("Failed to read version from package.json:",g(e)),"0.0.0"}}function v(o){n.packageRoot=o,n.version=null}var n,R,d,P=u(()=>{"use strict";l();n={version:null,packageRoot:null};r(i,"getPackageRoot");r(p,"getVersion");r(v,"resetPackageRoot");R=p(),d=i()});export{p as a,R as b,d as c,m as d,P as e};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from 'module';
3
+ import { fileURLToPath as __fileURLToPath } from 'url';
4
+ import { dirname as __pathDirname } from 'path';
5
+ const require = __createRequire(import.meta.url);
6
+ const __filename = __fileURLToPath(import.meta.url);
7
+ const __dirname = __pathDirname(__filename);
8
+ import{b as u,c as a,d as w}from"./chunk-XSJ7SPVR.mjs";import{b as k}from"./chunk-6NMHVPAI.mjs";import{e as h,p as T}from"./chunk-QWQFF2UG.mjs";import{a as o}from"./chunk-E66B27AL.mjs";T();function f(t,n){let r=t===a?a:t.slice(0,6);return{shortId:r,label:`${r} \xB7 ${n??"(detached)"}`}}o(f,"labelFor");async function m(t,n,r){let i=r.filter(e=>e.worktreePath);if(i.length===0)return r;let c=await h(["worktree","list","--porcelain"],{cwd:n,timeoutMs:2e3});if(!c.ok)return r;let s=new Set(c.stdout.split(`
9
+ `).filter(e=>e.startsWith("worktree ")).map(e=>e.slice(9).trim())),p=i.filter(e=>!s.has(e.worktreePath));if(p.length===0)return r;let d=new Set(p.map(e=>e.workspaceId));return await k.archiveOrphanedWorkspaceTasks(t,d),r.filter(e=>!d.has(e.workspaceId))}o(m,"pruneOrphanedWorkspaceTasks");async function P(t,n){let r=await w(n),i=[],c=await k.getTaskSnapshot(t),s=c.currentTask;if(s){let{shortId:e,label:l}=f(a,s.branch);i.push({id:s.id,description:s.description,workspaceId:a,shortId:e,label:l,branch:s.branch,linearId:s.linearId,harness:s.harness,startedAt:s.startedAt,isCurrent:r.workspaceId===a,pipeline:u(t,s.id,a)??void 0})}let p=await m(t,n,c.activeTasks);for(let e of p){if(e.workspaceId===a)continue;let{shortId:l,label:g}=f(e.workspaceId,e.branch);i.push({id:e.id,description:e.description,workspaceId:e.workspaceId,shortId:l,label:g,branch:e.branch,linearId:e.linearId,harness:e.harness,startedAt:e.startedAt,isCurrent:r.workspaceId===e.workspaceId,pipeline:u(t,e.id,e.workspaceId)??void 0})}return i.sort((e,l)=>Number(l.isCurrent)-Number(e.isCurrent)),{current:i.find(e=>e.isCurrent)??null,all:i,mainTaskRaw:s}}o(P,"collectActiveTasks");function I(t){let n=t.isCurrent?"\u2192":" ",r=t.isCurrent?" (this worktree)":"";return`${n} ${t.label} ${t.description}${r}`}o(I,"formatActiveTaskLine");function W(t){if(t.all.length===0)return"No active work cycle.";if(t.all.length===1&&t.current){let r=t.current,i=r.pipeline?`
10
+ Pipeline: ${r.pipeline.station}`:"";return`Active: ${r.description}
11
+ Workspace: ${r.label}${i}`}let n=[`Active work cycles (${t.all.length})`];for(let r of t.all)n.push(I(r));return n.join(`
12
+ `)}o(W,"formatActiveTaskList");export{P as a,I as b,W as c};
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{c as r,g as o}from"./chunk-GDESYWTD.mjs";import{a as i}from"./chunk-E66B27AL.mjs";var s=8;function g(t,e,n=s){return o(r(t,e,n).files)}i(g,"rankLikelyFiles");function u(t,e){let n=r(t,e,s);return n.files.length===0?null:n.agentBlock||null}i(u,"buildIndexedFileCue");export{g as a,u as b};
8
+ import{c as r,g as o}from"./chunk-HNZ24HIK.mjs";import{a as i}from"./chunk-E66B27AL.mjs";var s=8;function g(t,e,n=s){return o(r(t,e,n).files)}i(g,"rankLikelyFiles");function u(t,e){let n=r(t,e,s);return n.files.length===0?null:n.agentBlock||null}i(u,"buildIndexedFileCue");export{g as a,u as b};
@@ -5,7 +5,7 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{e as r,g as S}from"./chunk-UHVYBU7F.mjs";import{b as o,h as p,v as a,w as _}from"./chunk-A6K4H3YT.mjs";import{f as g,g as l,o as m}from"./chunk-UH4MD3F3.mjs";import{a as s}from"./chunk-E66B27AL.mjs";_();p();S();var c=class{static{s(this,"SyncPendingStorage")}append(n,e){let t=o(),u=JSON.stringify(e);return e.entityType&&e.entityId&&e.contentHash&&r.run(n,`DELETE FROM sync_pending
8
+ import{e as r,g as S}from"./chunk-TKXOMN4K.mjs";import{b as o,h as p,v as a,w as _}from"./chunk-A6K4H3YT.mjs";import{f as g,g as l,o as m}from"./chunk-UH4MD3F3.mjs";import{a as s}from"./chunk-E66B27AL.mjs";_();p();S();var c=class{static{s(this,"SyncPendingStorage")}append(n,e){let t=o(),u=JSON.stringify(e);return e.entityType&&e.entityId&&e.contentHash&&r.run(n,`DELETE FROM sync_pending
9
9
  WHERE project_id = ?
10
10
  AND entity_type = ?
11
11
  AND entity_id = ?
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from 'module';
3
+ import { fileURLToPath as __fileURLToPath } from 'url';
4
+ import { dirname as __pathDirname } from 'path';
5
+ const require = __createRequire(import.meta.url);
6
+ const __filename = __fileURLToPath(import.meta.url);
7
+ const __dirname = __pathDirname(__filename);
8
+ import{b as x}from"./chunk-SJ75V4WG.mjs";import{d as M}from"./chunk-FBEDUKMG.mjs";import{b as f}from"./chunk-7PA4KPSR.mjs";import{a as C}from"./chunk-7WO5CEH3.mjs";import{a as o}from"./chunk-E66B27AL.mjs";var q=new Set(["pattern-detector-auto","pattern-detector-recurring","skill-miss-detector","friction-detector"]);function E(t){if(t.type==="improvement-signal")return!0;let e=t.tags?.source;return e!==void 0&&q.has(e)}o(E,"isSignalEntry");var R=85,S=2;async function K(t,e,n={}){let a=n.threshold??R,d=n.maxIterations??S,i=await import("./retention-GWJ4AX7I.mjs").then(({evaluateRetentionShared:s})=>s(e,Date.now()).byId).catch(()=>null),h=o(async(s,c,g,m)=>{if(s>=d||c.score>=a)return{...c,irrelevantRemoved:g,repairEntriesCreated:m};let r=f.allEntriesForIndex(e),p=r.filter(l=>{if(!w(l))return!1;let b=i?.get(l.id);return!(b&&b.verdict==="active"&&b.score>=70)}),u=I(r)?0:1;u>0&&await f.remember(t,{type:"context",content:_(r,c),tags:{context_schema:"living-v2",synthesis:"model-authored",feature:"context-quality-cleanup",key_data:`quality_score=${c.score}; threshold=${a}; irrelevant=${p.length}`,model:"prjct sync context-quality analyzer",token_usage:"0 deterministic sync tokens",source:"sync-context-quality"},provenance:"inferred",projectId:e});let y=[];for(let l of p)f.forget(e,l.id)&&(y.push(l.id),await C({projectId:e,entityType:"memories",entityId:l.id,eventType:"delete",data:{id:l.id,type:l.type,content:l.content,tags:l.tags,reason:"context-quality-cleanup"}}));let $={...k(e,a),iterations:s+1,irrelevantRemoved:g+y.length,repairEntriesCreated:m+u};return p.length===0&&u===0?$:h(s+1,$,g+y.length,m+u)},"repairIteration");return h(0,k(e,a),0,0)}o(K,"repairContextQuality");function k(t,e=R){let n=f.allEntriesForIndex(t),a=n.filter(r=>r.type==="context"),d=a.filter(v),i=a.filter(r=>!v(r)),h=n.filter(w),s=[],c=[];n.length>0&&d.length===0&&(c.push(35),s.push("missing living-v2 context synthesis")),h.length>0&&(c.push(Math.min(40,h.length*8)),s.push(`${h.length} irrelevant generated entries in active context`)),i.length>0&&(c.push(Math.min(20,i.length*5)),s.push(`${i.length} legacy context entries need cleanup`));let g=d[0];if(g){let r=x(g.content),u=[r.contextSynthesis,r.keyData,r.model,r.tokenUsage,r.nextImplication].filter(y=>!y).length;u>0&&(c.push(u*4),s.push("latest living context is missing structured UI/LLM fields"))}let m=Math.max(0,Math.min(100,100-c.reduce((r,p)=>r+p,0)));return{score:m,threshold:e,passed:m>=e,iterations:0,livingContextCount:d.length,legacyContextCount:i.length,irrelevantRemoved:0,repairEntriesCreated:0,issues:s}}o(k,"evaluateContextQuality");function w(t){return E(t)?!0:t.tags?.source==="sync-context-quality"||t.type!=="context"||v(t)?!1:L(t)}o(w,"isIrrelevantGeneratedContext");function v(t){if(t.tags?.context_schema==="living-v2")return!0;let e=x(t.content);return!!(e.contextSynthesis&&e.keyData)}o(v,"isLivingV2Context");function I(t){return t.some(e=>e.type==="context"&&v(e))}o(I,"hasUsableLivingContext");function L(t){let e=t.content.trim();if(e.length<260||/User pushback:|raw quote|transcript|hot file|skill-miss/i.test(e))return!0;let n=x(e);return[n.whatHappened,n.whyItMattered,n.pattern,n.antiPattern,n.outcome,n.nextImplication].filter(Boolean).length<3}o(L,"isLowValueLegacyContext");function _(t,e){let n=t.filter(i=>!w(i)).filter(i=>["decision","gotcha","learning","context","shipped"].includes(i.type)).slice(0,8),a=n.length>0?n.map(i=>`${i.type}:${M(i)}`).join("; "):"No high-quality prior context survived cleanup.";return["Context synthesis: Sync repaired historical low-quality project context by removing generated telemetry and preserving the useful project knowledge as a living-v2 synthesis. Future agents should trust this synthesized layer over old raw detector rows or legacy context snippets.",`Key data: ${[`quality_score=${e.score}`,`threshold=${e.threshold}`,`legacy_context=${e.legacyContextCount}`,`issues=${e.issues.join("|")||"none"}`].join("; ")}`,"What happened: prjct sync detected that active context quality was below the required threshold and generated a replacement synthesis before deleting irrelevant generated entries.","Why it mattered: Existing users had accumulated low-signal context over time; leaving it active makes the second brain noisy for both the UI and LLM retrieval.","Who/author: prjct sync","Model: prjct sync context-quality analyzer","Token usage: 0 deterministic sync tokens","Sentiment: cleanup required because raw generated context had become product debt","Related files: generated from existing project memory during sync","Feature/domain: context-quality-cleanup","Pattern: Keep structured key data for UI representation and synthesized context for humans/LLMs.","Anti-pattern: Surfacing raw detector rows, hot-file counters, or short legacy snippets as durable project knowledge.","Decision/trap: Generated garbage is hard-deleted from active recall/vault/search; user-authored decisions, gotchas, learnings, and facts are preserved.",`Outcome: Repair synthesis created from surviving highlights: ${a}`,"Next implication: If quality remains below threshold, run full sync/analysis and inspect remaining user-authored entries manually instead of deleting them blindly."].join(" \xB7 ")}o(_,"buildRepairContext");export{K as a,w as b};
@@ -5,7 +5,7 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{c as L}from"./chunk-4HAKTI36.mjs";import{e as g}from"./chunk-C4O243NG.mjs";import{a as m}from"./chunk-V2FR2NPL.mjs";import{d as y,g as R}from"./chunk-UHVYBU7F.mjs";import{b as M,h as j}from"./chunk-A6K4H3YT.mjs";import{b as x}from"./chunk-GCKILEXJ.mjs";import{a as l}from"./chunk-E66B27AL.mjs";R();j();var A=6;function v(e,t=A){let r=[],u=new Set,o=l((s,i,a)=>{let p=D(s);if(!p||p.length<12)return;let c=p.toLowerCase();u.has(c)||(u.add(c),r.push({rule:p,sourceId:i,kind:a}))},"push");for(let s of e.filter(i=>i.type==="feedback")){if(r.length>=t)break;o(s.content,s.id,"preference")}for(let s of e.filter(i=>i.type==="improvement-signal"&&i.tags?.source==="friction-detector")){if(r.length>=t)break;let i=N(s.content)??T(s.content);i&&o(i,s.id,"friction")}return r}l(v,"extractDeveloperRules");function D(e){return e.replace(/\s+/g," ").trim().replace(/^[-*•]\s+/,"")}l(D,"normalizeRule");function N(e){return e.match(/^Next action:\s*(.+)$/im)?.[1]?.trim()||null}l(N,"extractNextAction");function T(e){let t=e.split(`
8
+ import{c as L}from"./chunk-TF6PN7IB.mjs";import{e as g}from"./chunk-FBEDUKMG.mjs";import{b as m}from"./chunk-7PA4KPSR.mjs";import{d as y,g as R}from"./chunk-TKXOMN4K.mjs";import{b as M,h as j}from"./chunk-A6K4H3YT.mjs";import{b as x}from"./chunk-GCKILEXJ.mjs";import{a as l}from"./chunk-E66B27AL.mjs";R();j();var A=6;function v(e,t=A){let r=[],u=new Set,o=l((s,i,a)=>{let p=D(s);if(!p||p.length<12)return;let c=p.toLowerCase();u.has(c)||(u.add(c),r.push({rule:p,sourceId:i,kind:a}))},"push");for(let s of e.filter(i=>i.type==="feedback")){if(r.length>=t)break;o(s.content,s.id,"preference")}for(let s of e.filter(i=>i.type==="improvement-signal"&&i.tags?.source==="friction-detector")){if(r.length>=t)break;let i=N(s.content)??T(s.content);i&&o(i,s.id,"friction")}return r}l(v,"extractDeveloperRules");function D(e){return e.replace(/\s+/g," ").trim().replace(/^[-*•]\s+/,"")}l(D,"normalizeRule");function N(e){return e.match(/^Next action:\s*(.+)$/im)?.[1]?.trim()||null}l(N,"extractNextAction");function T(e){let t=e.split(`
9
9
  `).map(u=>u.trim())[0]??"",r=t.match(/^\[[^\]]+\]\s+Lesson:\s*(.+)$/i);return r?.[1]?r[1].trim():/^\[[^\]]+\]/.test(t)&&t.length>20?t:null}l(T,"extractLesson");var _="memory:l0-index",E=4e3,C=1440*60*1e3,k=3,F=4,P=2,I={minTeaser:20,maxTeaser:80},S=["decision","gotcha","anti-pattern","learning","fact","feedback"];function X(e){try{let t=B(e);return t?(y.setDoc(e.projectId,_,t),t):null}catch{return null}}l(X,"buildAndStoreMemoryL0Index");function B(e){let t=m.allEntriesForIndex(e.projectId).filter(n=>x(n)||n.type==="inbox"||n.type==="improvement-signal");if(t.length===0)return null;let r={};for(let n of t)r[n.type]=(r[n.type]??0)+1;if(t.filter(n=>n.type!=="improvement-signal"&&x(n)).length===0&&(r.inbox??0)===0)return null;let o=["## What this project already knows","","> Carried across sessions and model updates \u2014 this survived even if your conversation context did not. Apply these; do not re-derive from source.","",`_L0 index \xB7 live=${t.length} \xB7 pull L2: \`prjct search\` / \`prjct context memory <topic>\` / \`prjct guard <file>\`_`,""],s=new Set;try{let n=m.recall(e.projectId,{types:["feedback","improvement-signal"],limit:40,dedupeByKey:!1}),d=v(n,F);if(d.length>0){o.push("**How this developer works (act as them):**");for(let f of d){let w=f.rule.length>140?`${f.rule.slice(0,139)}\u2026`:f.rule;o.push(`- ${w} \`${f.sourceId}\``)}o.push("")}}catch{}let i=[{title:"Traps to avoid",types:["gotcha","anti-pattern"],suppressMiss:!0},{title:"Decisions in force",types:["decision"],suppressMiss:!0},{title:"Learnings",types:["learning"]},{title:"Facts",types:["fact"]}];for(let n of i){let d=L.rerank(e.projectId,m.recall(e.projectId,{types:n.types,limit:k*4})).slice(0,k);if(d.length!==0){o.push(`**${n.title}:**`);for(let f of d)o.push(`- ${g(f,I)}`),n.suppressMiss&&s.add(f.id);o.push("")}}let a=O(e.projectId,s);a&&o.push("**Keeps being missed:**",`- ${g(a.entry,I)} \u2014 flagged relevant-but-unused ${a.count}\xD7. Apply it or supersede it.`,"");let p=t.filter(n=>n.type==="inbox").slice(0,3),c=r.inbox??0;if(c>0){o.push(`**Inbox (${c}):**`);for(let n of p)o.push(`- ${g(n,I)}`);c>p.length&&o.push(`- \u2026 +${c-p.length} more`),o.push("",'> Close resolved: `prjct close <id> --reason "\u2026"`. Forget noise: `prjct forget <id>`.',"")}let b=S.filter(n=>(r[n]??0)>0).map(n=>`${n}=${r[n]}`).concat(Object.keys(r).filter(n=>!S.includes(n)&&(r[n]??0)>0).sort().slice(0,8).map(n=>`${n}=${r[n]}`));b.length>0&&o.push(`_Counts: ${b.join(" \xB7 ")}_`,""),o.push("> Resolve any `mem_id` with `prjct search <id>`. Full developer model: MCP `prjct_developer`. Consolidate: `prjct dream`. Never stuff L2 into L0.");let h=o.join(`
10
10
  `),$=h.length>E?`${h.slice(0,E-20).trimEnd()}
11
11
  \u2026(truncated)`:h;return{version:1,builtAt:M(),projectId:e.projectId,live:t.length,byType:r,markdown:$,source:e.source??"manual"}}l(B,"buildMemoryL0Index");function H(e){try{let t=y.getDoc(e,_);return!t||t.version!==1||!t.markdown?null:t}catch{return null}}l(H,"loadMemoryL0Index");function K(e,t=Date.now()){if(!e?.builtAt)return!1;let r=Date.parse(e.builtAt);return Number.isFinite(r)?t-r<=C:!1}l(K,"isMemoryL0IndexFresh");function oe(e,t={}){try{let r=H(e),u=(!r||!K(r))&&t.rebuildIfStale!==!1?X({projectId:e,source:"session-start"}):r;return u?.markdown?.trim()?u.markdown.trim():null}catch{return null}}l(oe,"memoryL0IndexForSession");function O(e,t){try{let r=m.recall(e,{types:["improvement-signal"],tags:{kind:"skill-miss"},limit:50,dedupeByKey:!1}),u=new Map;for(let p of r){let c=p.tags?.relates;c&&u.set(c,(u.get(c)??0)+1)}let o=[...u].sort((p,c)=>c[1]-p[1])[0];if(!o||o[1]<P||t.has(o[0]))return null;let[s,i]=o,a=m.getById(e,s);return a?{entry:a,count:i}:null}catch{return null}}l(O,"findRepeatMissedEntry");export{v as a,_ as b,E as c,C as d,X as e,B as f,H as g,K as h,oe as i,O as j};
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{d as p,g as b}from"./chunk-UHVYBU7F.mjs";import{d as f,o as S}from"./chunk-UH4MD3F3.mjs";import{a as o}from"./chunk-E66B27AL.mjs";b();S();import a from"node:path";var g="file-inventory",m=/^(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|composer\.lock|Cargo\.lock|poetry\.lock|CHANGELOG(\.md)?|LICENSE(\.md)?|\.DS_Store)$/i,x=/(^|\/)(node_modules|dist|build|\.git|coverage|\.next|target|vendor)(\/|$)/i,y=new Set([".png",".jpg",".jpeg",".gif",".webp",".ico",".woff",".woff2",".ttf",".eot",".mp4",".mp3",".zip",".gz",".tar",".wasm",".exe",".dll",".so",".dylib",".bin",".pdf",".ico"]),v={".ts":"TypeScript",".tsx":"TypeScript",".js":"JavaScript",".jsx":"JavaScript",".mjs":"JavaScript",".cjs":"JavaScript",".vue":"Vue",".svelte":"Svelte",".py":"Python",".go":"Go",".rs":"Rust",".java":"Java",".kt":"Kotlin",".kts":"Kotlin",".swift":"Swift",".rb":"Ruby",".php":"PHP",".cs":"C#",".fs":"F#",".cpp":"C++",".cc":"C++",".c":"C",".h":"C/C++",".hpp":"C++",".m":"Objective-C",".mm":"Objective-C++",".scala":"Scala",".clj":"Clojure",".ex":"Elixir",".exs":"Elixir",".erl":"Erlang",".hs":"Haskell",".lua":"Lua",".r":"R",".dart":"Dart",".sql":"SQL",".graphql":"GraphQL",".gql":"GraphQL",".proto":"Protobuf",".md":"Markdown",".mdx":"MDX",".json":"JSON",".yml":"YAML",".yaml":"YAML",".toml":"TOML",".css":"CSS",".scss":"SCSS",".sass":"Sass",".less":"Less",".html":"HTML",".htm":"HTML",".sh":"Shell",".bash":"Shell",".zsh":"Shell",".ps1":"PowerShell",".swiftui":"Swift"};async function h(e,n={}){let t=(await f(e,{skipDotfiles:!0,maxFiles:n.maxFiles??5e4})).filter(l=>{if(x.test(l))return!1;let u=a.basename(l);if(m.test(u))return!1;let c=a.extname(u).toLowerCase();return!!(c&&c!=="."&&!y.has(c))}),r=t.reduce((l,u)=>{let c=a.extname(a.basename(u)).toLowerCase();return l[c]=(l[c]??0)+1,l},Object.create(null)),i=j(r);return{extensions:r,languages:i,fileCount:t.length,builtAt:new Date().toISOString(),projectHint:a.basename(e)}}o(h,"buildFileInventory");function j(e){let n=new Set,s=Object.entries(e).sort((t,r)=>r[1]-t[1]);for(let[t]of s){let r=v[t];r&&n.add(r)}return[...n]}o(j,"languagesFromExtensions");function C(e,n){p.setDoc(e,g,n)}o(C,"saveFileInventory");function d(e){try{return p.getDoc(e,g)}catch{return null}}o(d,"loadFileInventory");async function L(e,n){let s=await h(n);return C(e,s),s}o(L,"refreshFileInventory");function E(e){let n=d(e);return n?.extensions?new Set(Object.keys(n.extensions).map(s=>s.toLowerCase())):new Set}o(E,"inventoryExtensions");function k(e,n,s={}){let t=n.replace(/^\.\//,"").replace(/\\/g,"/").trim();if(!t||x.test(t))return!1;let r=t.split("/").pop()??t;if(m.test(r))return!1;let i=a.extname(r).toLowerCase();return i?!y.has(i):t.includes("/")}o(k,"pathMatchesInventory");function O(e,n){let s=n.replace(/^\.\//,"").replace(/\\/g,"/").trim(),t=s.split("/").pop()??s,r=a.extname(t).toLowerCase();if(!r)return .7;let i=E(e);return i.size===0||i.has(r)?1:.45}o(O,"inventoryPathWeight");function P(e){if(!e||Object.keys(e.extensions).length===0)return"File inventory: empty \u2014 run `prjct sync` to discover languages/extensions.";let n=Object.entries(e.extensions).sort((t,r)=>r[1]-t[1]).slice(0,12).map(([t,r])=>`${t}\xD7${r}`).join(" "),s=e.languages.length>0?e.languages.join(", "):"unknown";return`File inventory: ${e.fileCount} files \xB7 langs: ${s} \xB7 ${n}`}o(P,"formatInventorySummary");export{g as a,h as b,j as c,C as d,d as e,L as f,E as g,k as h,O as i,P as j};
8
+ import{d as p,g as b}from"./chunk-TKXOMN4K.mjs";import{d as f,o as S}from"./chunk-UH4MD3F3.mjs";import{a as o}from"./chunk-E66B27AL.mjs";b();S();import a from"node:path";var g="file-inventory",m=/^(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|composer\.lock|Cargo\.lock|poetry\.lock|CHANGELOG(\.md)?|LICENSE(\.md)?|\.DS_Store)$/i,x=/(^|\/)(node_modules|dist|build|\.git|coverage|\.next|target|vendor)(\/|$)/i,y=new Set([".png",".jpg",".jpeg",".gif",".webp",".ico",".woff",".woff2",".ttf",".eot",".mp4",".mp3",".zip",".gz",".tar",".wasm",".exe",".dll",".so",".dylib",".bin",".pdf",".ico"]),v={".ts":"TypeScript",".tsx":"TypeScript",".js":"JavaScript",".jsx":"JavaScript",".mjs":"JavaScript",".cjs":"JavaScript",".vue":"Vue",".svelte":"Svelte",".py":"Python",".go":"Go",".rs":"Rust",".java":"Java",".kt":"Kotlin",".kts":"Kotlin",".swift":"Swift",".rb":"Ruby",".php":"PHP",".cs":"C#",".fs":"F#",".cpp":"C++",".cc":"C++",".c":"C",".h":"C/C++",".hpp":"C++",".m":"Objective-C",".mm":"Objective-C++",".scala":"Scala",".clj":"Clojure",".ex":"Elixir",".exs":"Elixir",".erl":"Erlang",".hs":"Haskell",".lua":"Lua",".r":"R",".dart":"Dart",".sql":"SQL",".graphql":"GraphQL",".gql":"GraphQL",".proto":"Protobuf",".md":"Markdown",".mdx":"MDX",".json":"JSON",".yml":"YAML",".yaml":"YAML",".toml":"TOML",".css":"CSS",".scss":"SCSS",".sass":"Sass",".less":"Less",".html":"HTML",".htm":"HTML",".sh":"Shell",".bash":"Shell",".zsh":"Shell",".ps1":"PowerShell",".swiftui":"Swift"};async function h(e,n={}){let t=(await f(e,{skipDotfiles:!0,maxFiles:n.maxFiles??5e4})).filter(l=>{if(x.test(l))return!1;let u=a.basename(l);if(m.test(u))return!1;let c=a.extname(u).toLowerCase();return!!(c&&c!=="."&&!y.has(c))}),r=t.reduce((l,u)=>{let c=a.extname(a.basename(u)).toLowerCase();return l[c]=(l[c]??0)+1,l},Object.create(null)),i=j(r);return{extensions:r,languages:i,fileCount:t.length,builtAt:new Date().toISOString(),projectHint:a.basename(e)}}o(h,"buildFileInventory");function j(e){let n=new Set,s=Object.entries(e).sort((t,r)=>r[1]-t[1]);for(let[t]of s){let r=v[t];r&&n.add(r)}return[...n]}o(j,"languagesFromExtensions");function C(e,n){p.setDoc(e,g,n)}o(C,"saveFileInventory");function d(e){try{return p.getDoc(e,g)}catch{return null}}o(d,"loadFileInventory");async function L(e,n){let s=await h(n);return C(e,s),s}o(L,"refreshFileInventory");function E(e){let n=d(e);return n?.extensions?new Set(Object.keys(n.extensions).map(s=>s.toLowerCase())):new Set}o(E,"inventoryExtensions");function k(e,n,s={}){let t=n.replace(/^\.\//,"").replace(/\\/g,"/").trim();if(!t||x.test(t))return!1;let r=t.split("/").pop()??t;if(m.test(r))return!1;let i=a.extname(r).toLowerCase();return i?!y.has(i):t.includes("/")}o(k,"pathMatchesInventory");function O(e,n){let s=n.replace(/^\.\//,"").replace(/\\/g,"/").trim(),t=s.split("/").pop()??s,r=a.extname(t).toLowerCase();if(!r)return .7;let i=E(e);return i.size===0||i.has(r)?1:.45}o(O,"inventoryPathWeight");function P(e){if(!e||Object.keys(e.extensions).length===0)return"File inventory: empty \u2014 run `prjct sync` to discover languages/extensions.";let n=Object.entries(e.extensions).sort((t,r)=>r[1]-t[1]).slice(0,12).map(([t,r])=>`${t}\xD7${r}`).join(" "),s=e.languages.length>0?e.languages.join(", "):"unknown";return`File inventory: ${e.fileCount} files \xB7 langs: ${s} \xB7 ${n}`}o(P,"formatInventorySummary");export{g as a,h as b,j as c,C as d,d as e,L as f,E as g,k as h,O as i,P as j};
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{a as r}from"./chunk-GPZP7NXL.mjs";import{b as t}from"./chunk-XS45K7ZQ.mjs";import{a as e}from"./chunk-E66B27AL.mjs";function u(o){let n=t(o);return n.allow?null:{deny:n.denyMessage}}e(u,"decideSecrets");function l(o=process.cwd(),n){return r({event:"PreToolUse",projectPath:o,decide:e(async c=>{try{return u(c)}catch{return null}},"decide")},n)}e(l,"runPreSecretsHook");var p={decideSecrets:u};export{u as a,l as b,p as c};
8
+ import{a as r}from"./chunk-WUOVBBPC.mjs";import{b as t}from"./chunk-XS45K7ZQ.mjs";import{a as e}from"./chunk-E66B27AL.mjs";function u(o){let n=t(o);return n.allow?null:{deny:n.denyMessage}}e(u,"decideSecrets");function l(o=process.cwd(),n){return r({event:"PreToolUse",projectPath:o,decide:e(async c=>{try{return u(c)}catch{return null}},"decide")},n)}e(l,"runPreSecretsHook");var p={decideSecrets:u};export{u as a,l as b,p as c};
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{e as u,g as C}from"./chunk-UHVYBU7F.mjs";import{a as E,b as _,c as A,d as w,e as v,o as b}from"./chunk-UH4MD3F3.mjs";import{a as c}from"./chunk-E66B27AL.mjs";A();C();b();import I from"node:fs/promises";import d from"node:path";function O(t){let r=new RegExp(_.source,"g");return[...t.matchAll(r)].map(e=>e[1]).filter(e=>e.startsWith(".")||e.startsWith("@/"))}c(O,"extractImportSources");async function R(t,r,e){let n=t.startsWith("@/")?d.join(e,"src",t.slice(2)):d.resolve(d.dirname(d.join(e,r)),t);for(let o of E){let i=n+o;try{if((await I.stat(i)).isFile())return d.relative(e,i)}catch{}}return null}c(R,"resolveImport");async function x(t){let r=await w(t),e={},n={},o=await v(r,50,async i=>{let s=await G(t,i);return s&&s.imports.length>0?s:null});for(let{filePath:i,imports:s}of o){e[i]=s;for(let f of s)n[f]||(n[f]=[]),n[f].push(i)}return{forward:e,reverse:n,fileCount:r.length,edgeCount:o.reduce((i,s)=>i+s.imports.length,0),builtAt:new Date().toISOString()}}c(x,"buildGraph");function B(t,r,e=2){let n=new Set(t),o=new Map,i=[];for(let s of t){let f=r.forward[s]||[],a=r.reverse[s]||[];for(let p of[...f,...a])n.has(p)||i.push({file:p,depth:1})}for(let{file:s,depth:f}of i){if(f>e)continue;let a=1/(f+1),p=o.get(s);if(p){a>p.score&&o.set(s,{score:a,depth:f});continue}if(o.set(s,{score:a,depth:f}),f<e){let g=r.forward[s]||[],y=r.reverse[s]||[];for(let h of[...g,...y])!n.has(h)&&!o.has(h)&&i.push({file:h,depth:f+1})}}return Array.from(o.entries()).map(([s,{score:f,depth:a}])=>({path:s,score:f,depth:a})).sort((s,f)=>f.score-s.score)}c(B,"scoreFromSeeds");var l="import-graph",m=new Map;function D(t){return Object.values(t).reduce((r,e)=>r+e.length,0)}c(D,"countEdges");function T(t,r){let e=t.forward[r]||[];delete t.forward[r];for(let n of e){let o=(t.reverse[n]||[]).filter(i=>i!==r);o.length===0?delete t.reverse[n]:t.reverse[n]=o}}c(T,"removeOutgoingEdges");function P(t,r){let e=t.reverse[r]||[];delete t.reverse[r];let n=[];for(let o of e){let i=(t.forward[o]||[]).filter(s=>s!==r);i.length===0?delete t.forward[o]:t.forward[o]=i,n.push(o)}return n}c(P,"removeIncomingEdges");function M(t,r,e){if(e.length===0)return;let n=Array.from(new Set(e));t.forward[r]=n;for(let o of n)t.reverse[o]||(t.reverse[o]=[]),t.reverse[o].includes(r)||t.reverse[o].push(r)}c(M,"addEdges");async function G(t,r){try{let e=await I.readFile(d.join(t,r),"utf-8"),n=O(e),o=[];for(let i of n){let s=await R(i,r,t);s&&s!==r&&o.push(s)}return{filePath:r,imports:o}}catch{return null}}c(G,"importsForFile");function S(t){return{schemaVersion:2,fileCount:t.fileCount,edgeCount:t.edgeCount,builtAt:t.builtAt}}c(S,"graphMetadata");function F(t,r){try{u.transaction(t,e=>{e.prepare("DELETE FROM import_graph_edges").run();let n=e.prepare("INSERT INTO import_graph_edges (from_path, to_path, sort_order) VALUES (?, ?, ?)");for(let[o,i]of Object.entries(r.forward))for(let[s,f]of i.entries())n.run(o,f,s)})}catch{}}c(F,"replacePerFileEdges");function L(t,r,e,n){try{u.transaction(t,o=>{let i=o.prepare("DELETE FROM import_graph_edges WHERE from_path = ?"),s=o.prepare("INSERT INTO import_graph_edges (from_path, to_path, sort_order) VALUES (?, ?, ?)");for(let f of new Set([...e,...n]))i.run(f);for(let f of e){let a=r.forward[f]||[];for(let[p,g]of a.entries())s.run(f,g,p)}})}catch{}}c(L,"updatePerFileEdges");function N(t,r,e){try{let n=u.query(t,"SELECT from_path, to_path FROM import_graph_edges ORDER BY from_path, sort_order, to_path");if(n.length===0){if(e?.edgeCount===0){let a={forward:{},reverse:{},fileCount:e.fileCount,edgeCount:0,builtAt:e.builtAt};return m.set(t,{graph:a,updatedAt:r}),a}return null}let o={},i={};for(let a of n)o[a.from_path]||(o[a.from_path]=[]),o[a.from_path].push(a.to_path),i[a.to_path]||(i[a.to_path]=[]),i[a.to_path].push(a.from_path);let s=new Set;for(let[a,p]of Object.entries(o)){s.add(a);for(let g of p)s.add(g)}let f={forward:o,reverse:i,fileCount:e?.fileCount??s.size,edgeCount:n.length,builtAt:e?.builtAt??r};return m.set(t,{graph:f,updatedAt:r}),f}catch{return null}}c(N,"loadGraphFromPerFileEdges");function V(t,r){u.setDoc(t,l,S(r)),F(t,r),m.delete(t)}c(V,"saveGraph");function W(t,r,e,n){u.setDoc(t,l,S(r)),L(t,r,e,n),m.delete(t)}c(W,"saveGraphUpdate");function k(t){let r=u.get(t,"SELECT updated_at FROM kv_store WHERE key = ?",l);if(!r)return m.delete(t),null;let e=m.get(t);if(e&&e.updatedAt===r.updated_at)return e.graph;let n=u.getDoc(t,l),o=N(t,r.updated_at,n);if(o)return o;if(!n?.forward||!n?.reverse)return null;let i={forward:n.forward,reverse:n.reverse,fileCount:n.fileCount,edgeCount:n.edgeCount,builtAt:n.builtAt};return m.set(t,{graph:i,updatedAt:r.updated_at}),i}c(k,"loadGraph");async function q(t,r){let e=await x(t);return V(r,e),e}c(q,"indexImports");async function K(t,r,e,n=[]){let o=k(r);if(!o)return q(t,r);let i=new Set([...e,...n]);for(let a of i)T(o,a);let s=new Set;for(let a of n)for(let p of P(o,a))s.add(p);let f=await v(e,50,a=>G(t,a));for(let a of f)M(o,a.filePath,a.imports);return o.edgeCount=D(o.forward),o.builtAt=new Date().toISOString(),W(r,o,[...e,...s],n),o}c(K,"updateImportGraph");export{B as a,k as b,q as c,K as d};
8
+ import{e as u,g as C}from"./chunk-TKXOMN4K.mjs";import{a as E,b as _,c as A,d as w,e as v,o as b}from"./chunk-UH4MD3F3.mjs";import{a as c}from"./chunk-E66B27AL.mjs";A();C();b();import I from"node:fs/promises";import d from"node:path";function O(t){let r=new RegExp(_.source,"g");return[...t.matchAll(r)].map(e=>e[1]).filter(e=>e.startsWith(".")||e.startsWith("@/"))}c(O,"extractImportSources");async function R(t,r,e){let n=t.startsWith("@/")?d.join(e,"src",t.slice(2)):d.resolve(d.dirname(d.join(e,r)),t);for(let o of E){let i=n+o;try{if((await I.stat(i)).isFile())return d.relative(e,i)}catch{}}return null}c(R,"resolveImport");async function x(t){let r=await w(t),e={},n={},o=await v(r,50,async i=>{let s=await G(t,i);return s&&s.imports.length>0?s:null});for(let{filePath:i,imports:s}of o){e[i]=s;for(let f of s)n[f]||(n[f]=[]),n[f].push(i)}return{forward:e,reverse:n,fileCount:r.length,edgeCount:o.reduce((i,s)=>i+s.imports.length,0),builtAt:new Date().toISOString()}}c(x,"buildGraph");function B(t,r,e=2){let n=new Set(t),o=new Map,i=[];for(let s of t){let f=r.forward[s]||[],a=r.reverse[s]||[];for(let p of[...f,...a])n.has(p)||i.push({file:p,depth:1})}for(let{file:s,depth:f}of i){if(f>e)continue;let a=1/(f+1),p=o.get(s);if(p){a>p.score&&o.set(s,{score:a,depth:f});continue}if(o.set(s,{score:a,depth:f}),f<e){let g=r.forward[s]||[],y=r.reverse[s]||[];for(let h of[...g,...y])!n.has(h)&&!o.has(h)&&i.push({file:h,depth:f+1})}}return Array.from(o.entries()).map(([s,{score:f,depth:a}])=>({path:s,score:f,depth:a})).sort((s,f)=>f.score-s.score)}c(B,"scoreFromSeeds");var l="import-graph",m=new Map;function D(t){return Object.values(t).reduce((r,e)=>r+e.length,0)}c(D,"countEdges");function T(t,r){let e=t.forward[r]||[];delete t.forward[r];for(let n of e){let o=(t.reverse[n]||[]).filter(i=>i!==r);o.length===0?delete t.reverse[n]:t.reverse[n]=o}}c(T,"removeOutgoingEdges");function P(t,r){let e=t.reverse[r]||[];delete t.reverse[r];let n=[];for(let o of e){let i=(t.forward[o]||[]).filter(s=>s!==r);i.length===0?delete t.forward[o]:t.forward[o]=i,n.push(o)}return n}c(P,"removeIncomingEdges");function M(t,r,e){if(e.length===0)return;let n=Array.from(new Set(e));t.forward[r]=n;for(let o of n)t.reverse[o]||(t.reverse[o]=[]),t.reverse[o].includes(r)||t.reverse[o].push(r)}c(M,"addEdges");async function G(t,r){try{let e=await I.readFile(d.join(t,r),"utf-8"),n=O(e),o=[];for(let i of n){let s=await R(i,r,t);s&&s!==r&&o.push(s)}return{filePath:r,imports:o}}catch{return null}}c(G,"importsForFile");function S(t){return{schemaVersion:2,fileCount:t.fileCount,edgeCount:t.edgeCount,builtAt:t.builtAt}}c(S,"graphMetadata");function F(t,r){try{u.transaction(t,e=>{e.prepare("DELETE FROM import_graph_edges").run();let n=e.prepare("INSERT INTO import_graph_edges (from_path, to_path, sort_order) VALUES (?, ?, ?)");for(let[o,i]of Object.entries(r.forward))for(let[s,f]of i.entries())n.run(o,f,s)})}catch{}}c(F,"replacePerFileEdges");function L(t,r,e,n){try{u.transaction(t,o=>{let i=o.prepare("DELETE FROM import_graph_edges WHERE from_path = ?"),s=o.prepare("INSERT INTO import_graph_edges (from_path, to_path, sort_order) VALUES (?, ?, ?)");for(let f of new Set([...e,...n]))i.run(f);for(let f of e){let a=r.forward[f]||[];for(let[p,g]of a.entries())s.run(f,g,p)}})}catch{}}c(L,"updatePerFileEdges");function N(t,r,e){try{let n=u.query(t,"SELECT from_path, to_path FROM import_graph_edges ORDER BY from_path, sort_order, to_path");if(n.length===0){if(e?.edgeCount===0){let a={forward:{},reverse:{},fileCount:e.fileCount,edgeCount:0,builtAt:e.builtAt};return m.set(t,{graph:a,updatedAt:r}),a}return null}let o={},i={};for(let a of n)o[a.from_path]||(o[a.from_path]=[]),o[a.from_path].push(a.to_path),i[a.to_path]||(i[a.to_path]=[]),i[a.to_path].push(a.from_path);let s=new Set;for(let[a,p]of Object.entries(o)){s.add(a);for(let g of p)s.add(g)}let f={forward:o,reverse:i,fileCount:e?.fileCount??s.size,edgeCount:n.length,builtAt:e?.builtAt??r};return m.set(t,{graph:f,updatedAt:r}),f}catch{return null}}c(N,"loadGraphFromPerFileEdges");function V(t,r){u.setDoc(t,l,S(r)),F(t,r),m.delete(t)}c(V,"saveGraph");function W(t,r,e,n){u.setDoc(t,l,S(r)),L(t,r,e,n),m.delete(t)}c(W,"saveGraphUpdate");function k(t){let r=u.get(t,"SELECT updated_at FROM kv_store WHERE key = ?",l);if(!r)return m.delete(t),null;let e=m.get(t);if(e&&e.updatedAt===r.updated_at)return e.graph;let n=u.getDoc(t,l),o=N(t,r.updated_at,n);if(o)return o;if(!n?.forward||!n?.reverse)return null;let i={forward:n.forward,reverse:n.reverse,fileCount:n.fileCount,edgeCount:n.edgeCount,builtAt:n.builtAt};return m.set(t,{graph:i,updatedAt:r.updated_at}),i}c(k,"loadGraph");async function q(t,r){let e=await x(t);return V(r,e),e}c(q,"indexImports");async function K(t,r,e,n=[]){let o=k(r);if(!o)return q(t,r);let i=new Set([...e,...n]);for(let a of i)T(o,a);let s=new Set;for(let a of n)for(let p of P(o,a))s.add(p);let f=await v(e,50,a=>G(t,a));for(let a of f)M(o,a.filePath,a.imports);return o.edgeCount=D(o.forward),o.builtAt=new Date().toISOString(),W(r,o,[...e,...s],n),o}c(K,"updateImportGraph");export{B as a,k as b,q as c,K as d};
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
5
5
  const require = __createRequire(import.meta.url);
6
6
  const __filename = __fileURLToPath(import.meta.url);
7
7
  const __dirname = __pathDirname(__filename);
8
- import{a as h}from"./chunk-RTEEXGEA.mjs";import{c as p}from"./chunk-M5E2YOZ4.mjs";import{d as c,g}from"./chunk-UHVYBU7F.mjs";import{b as a,h as m,j as d,k as f}from"./chunk-A6K4H3YT.mjs";import{a as r}from"./chunk-E66B27AL.mjs";f();m();g();function v(i){let[e,t]=i.split(".");return e?{entityType:e.endsWith("s")?e:`${e}s`,eventType:t==="deleted"||t==="archived"||t==="removed"?"delete":"upsert"}:{}}r(v,"deriveEntityShape");function T(i){if(!i||typeof i!="object")return;let e=i;for(let t of["taskId","task_id","id","feature_id","featureId","specId","spec_id"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}r(T,"entityIdOf");var u={value:null};async function w(){if(u.value)return u.value;try{let{default:i}=await import("./auth-config-JIITQ6GY.mjs"),e=i;if(typeof e.getDeviceId=="function"){let t=await e.getDeviceId();return u.value=t,t}return"unknown-device"}catch{return"unknown-device"}}r(w,"_resolveDeviceId");var y=class{static{r(this,"StorageManager")}filename;cache;constructor(e,t){this.filename=e,this.cache=new d({ttl:5e3,maxSize:50})}getStoreKey(){return this.filename.replace(".json","")}async read(e){if(!(process.env.PRJCT_IN_DAEMON==="1")){let n=this.cache.get(e);if(n!==null)return n}try{let n=c.getDoc(e,this.getStoreKey());if(n!==null)return this.cache.set(e,n),n}catch{}return this.getDefault()}async write(e,t){c.setDoc(e,this.getStoreKey(),t),this.cache.set(e,t)}async update(e,t){let n=this.getStoreKey(),s=c.updateDoc(e,n,t,()=>this.getDefault());return this.cache.set(e,s),s}async publishEvent(e,t,n){let s=v(t),o={type:t,path:[this.filename.replace(".json","")],data:n,timestamp:a(),projectId:e,entityType:s.entityType,entityId:T(n),eventType:s.eventType,contentHash:p(n),deviceId:await w(),revisionCount:1};await h.publish(o)}async publishEntityEvent(e,t,n,s){let o=`${t}.${n}`,l={...s,timestamp:a()};await this.publishEvent(e,o,l)}async exists(e){try{return c.hasDoc(e,this.getStoreKey())}catch{return!1}}clearCache(e){e?this.cache.delete(e):this.cache.clear()}getCacheStats(){return this.cache.stats()}};export{y as a};
8
+ import{a as h}from"./chunk-AORD3YDQ.mjs";import{c as p}from"./chunk-M5E2YOZ4.mjs";import{d as c,g}from"./chunk-TKXOMN4K.mjs";import{b as a,h as m,j as d,k as f}from"./chunk-A6K4H3YT.mjs";import{a as r}from"./chunk-E66B27AL.mjs";f();m();g();function v(i){let[e,t]=i.split(".");return e?{entityType:e.endsWith("s")?e:`${e}s`,eventType:t==="deleted"||t==="archived"||t==="removed"?"delete":"upsert"}:{}}r(v,"deriveEntityShape");function T(i){if(!i||typeof i!="object")return;let e=i;for(let t of["taskId","task_id","id","feature_id","featureId","specId","spec_id"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}}r(T,"entityIdOf");var u={value:null};async function w(){if(u.value)return u.value;try{let{default:i}=await import("./auth-config-JIITQ6GY.mjs"),e=i;if(typeof e.getDeviceId=="function"){let t=await e.getDeviceId();return u.value=t,t}return"unknown-device"}catch{return"unknown-device"}}r(w,"_resolveDeviceId");var y=class{static{r(this,"StorageManager")}filename;cache;constructor(e,t){this.filename=e,this.cache=new d({ttl:5e3,maxSize:50})}getStoreKey(){return this.filename.replace(".json","")}async read(e){if(!(process.env.PRJCT_IN_DAEMON==="1")){let n=this.cache.get(e);if(n!==null)return n}try{let n=c.getDoc(e,this.getStoreKey());if(n!==null)return this.cache.set(e,n),n}catch{}return this.getDefault()}async write(e,t){c.setDoc(e,this.getStoreKey(),t),this.cache.set(e,t)}async update(e,t){let n=this.getStoreKey(),s=c.updateDoc(e,n,t,()=>this.getDefault());return this.cache.set(e,s),s}async publishEvent(e,t,n){let s=v(t),o={type:t,path:[this.filename.replace(".json","")],data:n,timestamp:a(),projectId:e,entityType:s.entityType,entityId:T(n),eventType:s.eventType,contentHash:p(n),deviceId:await w(),revisionCount:1};await h.publish(o)}async publishEntityEvent(e,t,n,s){let o=`${t}.${n}`,l={...s,timestamp:a()};await this.publishEvent(e,o,l)}async exists(e){try{return c.hasDoc(e,this.getStoreKey())}catch{return!1}}clearCache(e){e?this.cache.delete(e):this.cache.clear()}getCacheStats(){return this.cache.stats()}};export{y as a};