prjct-cli 3.95.0 → 3.96.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 (173) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/bin/hook-chunks/{agent-identity-45BYQBU2.mjs → agent-identity-DH6DX72X.mjs} +1 -1
  3. package/dist/bin/hook-chunks/{agent-switch-4ZJJWKMD.mjs → agent-switch-I4MTVE56.mjs} +1 -1
  4. package/dist/bin/hook-chunks/{analysis-UGHAG2SK.mjs → analysis-VN7APBHR.mjs} +3 -3
  5. package/dist/bin/hook-chunks/{auto-flush-CXWTU3RF.mjs → auto-flush-DX3FVSQE.mjs} +1 -1
  6. package/dist/bin/hook-chunks/{capture-gate-PS6QUXLX.mjs → capture-gate-MEIQD7ZS.mjs} +1 -1
  7. package/dist/bin/hook-chunks/{chunk-YDBZO6I3.mjs → chunk-22GFTUER.mjs} +1 -1
  8. package/dist/bin/hook-chunks/{chunk-OGIFB3OE.mjs → chunk-33BHU4OM.mjs} +1 -1
  9. package/dist/bin/hook-chunks/{chunk-QL3NYJTW.mjs → chunk-3AHW4XQH.mjs} +1 -1
  10. package/dist/bin/hook-chunks/{chunk-DCSKTMDX.mjs → chunk-3CKNJ5RA.mjs} +1 -1
  11. package/dist/bin/hook-chunks/{chunk-ABJNOG2I.mjs → chunk-3FEXJUO2.mjs} +1 -1
  12. package/dist/bin/hook-chunks/{chunk-22AXWLI6.mjs → chunk-3HGQPUKG.mjs} +1 -1
  13. package/dist/bin/hook-chunks/{chunk-EWOK4VE7.mjs → chunk-3UB6SFRA.mjs} +1 -1
  14. package/dist/bin/hook-chunks/{chunk-OUAVSD47.mjs → chunk-64ZEBHDX.mjs} +1 -1
  15. package/dist/bin/hook-chunks/{chunk-X5W2UYQK.mjs → chunk-7PBWIO4K.mjs} +3 -3
  16. package/dist/bin/hook-chunks/{chunk-QP5USCDX.mjs → chunk-7WO5CEH3.mjs} +1 -1
  17. package/dist/bin/hook-chunks/{chunk-N3L77UNM.mjs → chunk-ADYTBOCZ.mjs} +1 -1
  18. package/dist/bin/hook-chunks/{chunk-RTEEXGEA.mjs → chunk-AORD3YDQ.mjs} +1 -1
  19. package/dist/bin/hook-chunks/{chunk-Z6KVLCMK.mjs → chunk-BKJHD5JI.mjs} +1 -1
  20. package/dist/bin/hook-chunks/{chunk-4NTVXJD7.mjs → chunk-BVK7ZDLX.mjs} +1 -1
  21. package/dist/bin/hook-chunks/{chunk-IGHY4FGS.mjs → chunk-CPR4FPXG.mjs} +1 -1
  22. package/dist/bin/hook-chunks/{chunk-XXRAQZNC.mjs → chunk-D7DQABWO.mjs} +1 -1
  23. package/dist/bin/hook-chunks/{chunk-5H3KJWQS.mjs → chunk-DB226JIV.mjs} +2 -2
  24. package/dist/bin/hook-chunks/{chunk-ZFLIVOFX.mjs → chunk-DCHIPMOG.mjs} +1 -1
  25. package/dist/bin/hook-chunks/{chunk-U4OON3S7.mjs → chunk-E7NA34VQ.mjs} +1 -1
  26. package/dist/bin/hook-chunks/{chunk-PTA7DMLM.mjs → chunk-EGCYDLSO.mjs} +1 -1
  27. package/dist/bin/hook-chunks/{chunk-PP6DANGV.mjs → chunk-EI6VQZOX.mjs} +1 -1
  28. package/dist/bin/hook-chunks/{chunk-5XA5RL5I.mjs → chunk-ETTDRXQ6.mjs} +1 -1
  29. package/dist/bin/hook-chunks/{chunk-FW4MEPTB.mjs → chunk-EXVL2OFE.mjs} +1 -1
  30. package/dist/bin/hook-chunks/{chunk-I26F7TLM.mjs → chunk-FZS3XGEA.mjs} +1 -1
  31. package/dist/bin/hook-chunks/{chunk-IWJG7CZX.mjs → chunk-GSPDJSJ5.mjs} +1 -1
  32. package/dist/bin/hook-chunks/{chunk-S5N2ZZDL.mjs → chunk-H2DGDAQP.mjs} +1 -1
  33. package/dist/bin/hook-chunks/chunk-H5AVBDCH.mjs +8 -0
  34. package/dist/bin/hook-chunks/{chunk-HEDZA6KC.mjs → chunk-HGZQWYBL.mjs} +1 -1
  35. package/dist/bin/hook-chunks/{chunk-GCDLPKOH.mjs → chunk-IJ523YO2.mjs} +1 -1
  36. package/dist/bin/hook-chunks/{chunk-6GAFRIUQ.mjs → chunk-IWUF2LGO.mjs} +1 -1
  37. package/dist/bin/hook-chunks/{chunk-Z4X7JIAP.mjs → chunk-JGZ3QGWX.mjs} +3 -3
  38. package/dist/bin/hook-chunks/{chunk-ROA2AJXY.mjs → chunk-JZDZH6IV.mjs} +1 -1
  39. package/dist/bin/hook-chunks/{chunk-BOBFTVAY.mjs → chunk-KDNUQPAK.mjs} +1 -1
  40. package/dist/bin/hook-chunks/chunk-KV4NXLPT.mjs +11 -0
  41. package/dist/bin/hook-chunks/{chunk-WGWE3CSC.mjs → chunk-LF3S3MYE.mjs} +1 -1
  42. package/dist/bin/hook-chunks/chunk-LQLCYBFF.mjs +36 -0
  43. package/dist/bin/hook-chunks/{chunk-S5ISOGDB.mjs → chunk-LR24AIEW.mjs} +1 -1
  44. package/dist/bin/hook-chunks/{chunk-FXFG6PV6.mjs → chunk-M4YM7Z3F.mjs} +15 -15
  45. package/dist/bin/hook-chunks/{chunk-S6L3FECF.mjs → chunk-MW54MTLB.mjs} +1 -1
  46. package/dist/bin/hook-chunks/{chunk-J5UQVJUW.mjs → chunk-NCLONKOT.mjs} +1 -1
  47. package/dist/bin/hook-chunks/{chunk-QBYHZX33.mjs → chunk-NJ74RHNC.mjs} +1 -1
  48. package/dist/bin/hook-chunks/{chunk-GDESYWTD.mjs → chunk-NLL5AV2G.mjs} +2 -2
  49. package/dist/bin/hook-chunks/{chunk-GLPKMG5A.mjs → chunk-OLQAMCYV.mjs} +10 -10
  50. package/dist/bin/hook-chunks/{chunk-KSSRINDX.mjs → chunk-PPWPUEBH.mjs} +1 -1
  51. package/dist/bin/hook-chunks/chunk-PVCEWFHS.mjs +51 -0
  52. package/dist/bin/hook-chunks/{chunk-PGWFGRX4.mjs → chunk-QOQZHR3E.mjs} +1 -1
  53. package/dist/bin/hook-chunks/{chunk-2UC4DTDO.mjs → chunk-QXCEBAIA.mjs} +1 -1
  54. package/dist/bin/hook-chunks/chunk-RT2DFIWF.mjs +19 -0
  55. package/dist/bin/hook-chunks/{chunk-BDOAQVIF.mjs → chunk-SQW2B7NW.mjs} +1 -1
  56. package/dist/bin/hook-chunks/{chunk-NLKPAJND.mjs → chunk-SWJ7TLBD.mjs} +1 -1
  57. package/dist/bin/hook-chunks/{chunk-GDECEHO5.mjs → chunk-TB57OYGW.mjs} +1 -1
  58. package/dist/bin/hook-chunks/{chunk-4HAKTI36.mjs → chunk-TF6PN7IB.mjs} +1 -1
  59. package/dist/bin/hook-chunks/{chunk-UHVYBU7F.mjs → chunk-TKXOMN4K.mjs} +4 -4
  60. package/dist/bin/hook-chunks/{chunk-G7QQZMAO.mjs → chunk-UMJ5D5I6.mjs} +1 -1
  61. package/dist/bin/hook-chunks/{chunk-UYQC63MC.mjs → chunk-UVATSTRF.mjs} +1 -1
  62. package/dist/bin/hook-chunks/{chunk-BX7VKYA7.mjs → chunk-WJV24WE6.mjs} +1 -1
  63. package/dist/bin/hook-chunks/{chunk-76GDLA3Z.mjs → chunk-WL6PKX3U.mjs} +1 -1
  64. package/dist/bin/hook-chunks/chunk-WUOVBBPC.mjs +11 -0
  65. package/dist/bin/hook-chunks/{chunk-T6ELTQZM.mjs → chunk-XSJ7SPVR.mjs} +1 -1
  66. package/dist/bin/hook-chunks/{chunk-DVDZA63F.mjs → chunk-XV2LJVYB.mjs} +1 -1
  67. package/dist/bin/hook-chunks/{chunk-C4O243NG.mjs → chunk-XYKVWO23.mjs} +1 -1
  68. package/dist/bin/hook-chunks/{chunk-MHNWIB7B.mjs → chunk-Y3RHBU2R.mjs} +2 -2
  69. package/dist/bin/hook-chunks/{chunk-RHKF7EJW.mjs → chunk-Y7MZA2G4.mjs} +1 -1
  70. package/dist/bin/hook-chunks/{chunk-ZOX6OV6X.mjs → chunk-YHOZTAZH.mjs} +1 -1
  71. package/dist/bin/hook-chunks/chunk-YLOK4WRR.mjs +8 -0
  72. package/dist/bin/hook-chunks/{chunk-3WQBTXUC.mjs → chunk-ZJW27EUC.mjs} +1 -1
  73. package/dist/bin/hook-chunks/{chunk-J5UVRZ44.mjs → chunk-ZQI4TJ5C.mjs} +3 -3
  74. package/dist/bin/hook-chunks/chunk-ZYCNW75E.mjs +9 -0
  75. package/dist/bin/hook-chunks/{chunk-PO3QDKTE.mjs → chunk-ZZBNFNMG.mjs} +1 -1
  76. package/dist/bin/hook-chunks/{client-CRXA774S.mjs → client-K3ZA2BLB.mjs} +1 -1
  77. package/dist/bin/hook-chunks/{code-graph-cloud-GTSLO7CD.mjs → code-graph-cloud-XGQF7XYC.mjs} +1 -1
  78. package/dist/bin/hook-chunks/{codex-skill-NUBNPSMF.mjs → codex-skill-6CRFUF3A.mjs} +1 -1
  79. package/dist/bin/hook-chunks/{command-installer-UHSXC3UG.mjs → command-installer-MUHZWDZA.mjs} +1 -1
  80. package/dist/bin/hook-chunks/{config-manager-DX5OOPW5.mjs → config-manager-2JJPCLKC.mjs} +1 -1
  81. package/dist/bin/hook-chunks/{context7-service-GDJ3QICX.mjs → context7-service-NH4BMGSJ.mjs} +1 -1
  82. package/dist/bin/hook-chunks/{custom-workflow-storage-FD47DPA3.mjs → custom-workflow-storage-VBMWLKA7.mjs} +1 -1
  83. package/dist/bin/hook-chunks/cwd-changed-UTD6Y4MS.mjs +8 -0
  84. package/dist/bin/hook-chunks/{database-ZUC7OEZG.mjs → database-ZCP76LMM.mjs} +1 -1
  85. package/dist/bin/hook-chunks/{detect-changes-OJUBWWTU.mjs → detect-changes-5W6EGEZG.mjs} +1 -1
  86. package/dist/bin/hook-chunks/{developer-evolution-WNSTHDAA.mjs → developer-evolution-UTY3CWOK.mjs} +1 -1
  87. package/dist/bin/hook-chunks/{distill-GOGPFQFK.mjs → distill-5TNAM3LY.mjs} +1 -1
  88. package/dist/bin/hook-chunks/{enriched-recall-QF22RIK7.mjs → enriched-recall-6VOIUNLN.mjs} +1 -1
  89. package/dist/bin/hook-chunks/{format-J3X3R225.mjs → format-IIOFTSBF.mjs} +1 -1
  90. package/dist/bin/hook-chunks/{judgment-ledger-storage-FE4HXTHM.mjs → judgment-ledger-storage-7Q7AEEY6.mjs} +1 -1
  91. package/dist/bin/hook-chunks/{judgment-orchestrator-YDJTKNV2.mjs → judgment-orchestrator-AAON4ZJ4.mjs} +1 -1
  92. package/dist/bin/hook-chunks/{judgment-receipt-7A2DXVJA.mjs → judgment-receipt-QLV3MYFT.mjs} +1 -1
  93. package/dist/bin/hook-chunks/{land-cue-SZWJH6XP.mjs → land-cue-57B23PEL.mjs} +1 -1
  94. package/dist/bin/hook-chunks/{land-synthesis-JLYUBKHR.mjs → land-synthesis-ZVPFJERV.mjs} +1 -1
  95. package/dist/bin/hook-chunks/{legacy-crew-sweep-JXYO62UE.mjs → legacy-crew-sweep-GR6HRSHX.mjs} +2 -2
  96. package/dist/bin/hook-chunks/{memory-index-CIYDXN2G.mjs → memory-index-XE2MWKQS.mjs} +1 -1
  97. package/dist/bin/hook-chunks/{notification-UA7RTVHG.mjs → notification-GU2ZJP5K.mjs} +1 -1
  98. package/dist/bin/hook-chunks/{pack-integrity-GZC5NGFN.mjs → pack-integrity-WV5U3AFF.mjs} +1 -1
  99. package/dist/bin/hook-chunks/{pack-manager-AF5F7PRT.mjs → pack-manager-QLFQKP24.mjs} +1 -1
  100. package/dist/bin/hook-chunks/{planning-M3RAOZVB.mjs → planning-VPAX5DZL.mjs} +2 -2
  101. package/dist/bin/hook-chunks/{post-edit-QRDYPZLZ.mjs → post-edit-UXCFSR3Y.mjs} +1 -1
  102. package/dist/bin/hook-chunks/{pre-bash-TWWFVNQ7.mjs → pre-bash-MB4JNNYG.mjs} +1 -1
  103. package/dist/bin/hook-chunks/{pre-commit-PTFF7JIN.mjs → pre-commit-U7TRFKWX.mjs} +1 -1
  104. package/dist/bin/hook-chunks/pre-edit-MDCQXI5F.mjs +11 -0
  105. package/dist/bin/hook-chunks/{pre-package-325ALZKD.mjs → pre-package-A6ZI5R64.mjs} +1 -1
  106. package/dist/bin/hook-chunks/{pre-search-GOHVFAFH.mjs → pre-search-ZZO3LGXJ.mjs} +1 -1
  107. package/dist/bin/hook-chunks/{pre-secrets-MYNM5KI4.mjs → pre-secrets-MWPPZPWK.mjs} +1 -1
  108. package/dist/bin/hook-chunks/{prjct-md-RCB6FWD6.mjs → prjct-md-MS52YLI2.mjs} +1 -1
  109. package/dist/bin/hook-chunks/{project-agent-surfaces-V4P5RTUR.mjs → project-agent-surfaces-6AIW7KL6.mjs} +1 -1
  110. package/dist/bin/hook-chunks/{project-file-inventory-OKIP4LBO.mjs → project-file-inventory-HHURZTMH.mjs} +1 -1
  111. package/dist/bin/hook-chunks/project-memory-UDH56VFP.mjs +8 -0
  112. package/dist/bin/hook-chunks/{project-style-evolution-RPGATIYJ.mjs → project-style-evolution-IJXT2MCP.mjs} +1 -1
  113. package/dist/bin/hook-chunks/prompt-7VZLYONO.mjs +24 -0
  114. package/dist/bin/hook-chunks/{publish-helper-SX7HEV2L.mjs → publish-helper-ZSL27HSX.mjs} +1 -1
  115. package/dist/bin/hook-chunks/{purge-XKHUAB4H.mjs → purge-N2WN6NDB.mjs} +1 -1
  116. package/dist/bin/hook-chunks/retention-RET4P2RO.mjs +8 -0
  117. package/dist/bin/hook-chunks/{sdd-6PF7MBAY.mjs → sdd-PB6WKSLE.mjs} +1 -1
  118. package/dist/bin/hook-chunks/{session-continuity-UEXQDGZE.mjs → session-continuity-BIJXMN44.mjs} +1 -1
  119. package/dist/bin/hook-chunks/session-start-R2VMKW2L.mjs +8 -0
  120. package/dist/bin/hook-chunks/settings-installer-CQKMGMRG.mjs +9 -0
  121. package/dist/bin/hook-chunks/{setup-ZOHG6MGF.mjs → setup-PPIZHVXS.mjs} +3 -3
  122. package/dist/bin/hook-chunks/{shipping-QVGTOO6U.mjs → shipping-C637PCOF.mjs} +4 -4
  123. package/dist/bin/hook-chunks/{skill-index-FGDQVYHM.mjs → skill-index-55I3HLAI.mjs} +1 -1
  124. package/dist/bin/hook-chunks/{spec-context-inference-6Z52BT37.mjs → spec-context-inference-RTTDOZZO.mjs} +1 -1
  125. package/dist/bin/hook-chunks/{spec-service-UAQ5AEXQ.mjs → spec-service-ENLAAMVL.mjs} +2 -2
  126. package/dist/bin/hook-chunks/{spec-task-breakdown-LAXGVLMY.mjs → spec-task-breakdown-RUDEP3AY.mjs} +1 -1
  127. package/dist/bin/hook-chunks/{state-storage-XU35ZYNA.mjs → state-storage-AJUPG7J5.mjs} +1 -1
  128. package/dist/bin/hook-chunks/stop-DPXAWJFN.mjs +16 -0
  129. package/dist/bin/hook-chunks/subagent-start-AFHPXL2S.mjs +8 -0
  130. package/dist/bin/hook-chunks/{subagent-stop-OUG4PR7S.mjs → subagent-stop-5BMV63ML.mjs} +1 -1
  131. package/dist/bin/hook-chunks/{surface-attribution-A6GCGRFM.mjs → surface-attribution-EGIKCVMF.mjs} +1 -1
  132. package/dist/bin/hook-chunks/{symbol-graph-DMPBNBX7.mjs → symbol-graph-MH42JSPX.mjs} +1 -1
  133. package/dist/bin/hook-chunks/{sync-cursor-storage-VVLA3L2U.mjs → sync-cursor-storage-ZB7FGT6D.mjs} +1 -1
  134. package/dist/bin/hook-chunks/{task-orchestration-HFZYWYLR.mjs → task-orchestration-7NGRIISS.mjs} +1 -1
  135. package/dist/bin/hook-chunks/{task-overview-PCUZWL5Q.mjs → task-overview-F3GB77OA.mjs} +1 -1
  136. package/dist/bin/hook-chunks/task-service-FZABHPFV.mjs +8 -0
  137. package/dist/bin/hook-chunks/{tdd-QZL4OSM7.mjs → tdd-TAMBOPN3.mjs} +1 -1
  138. package/dist/bin/hook-chunks/{template-loader-SKXILJLJ.mjs → template-loader-MXOMU4XH.mjs} +1 -1
  139. package/dist/bin/hook-chunks/{usefulness-SZLG6LVC.mjs → usefulness-TBD5EYAL.mjs} +1 -1
  140. package/dist/bin/hook-chunks/{vault-retire-notice-HOXPURNQ.mjs → vault-retire-notice-7XHVNHU6.mjs} +1 -1
  141. package/dist/bin/hook-chunks/{velocity-storage-5J6BAMCW.mjs → velocity-storage-IOCVK2LU.mjs} +1 -1
  142. package/dist/bin/hook-chunks/{weak-model-mode-ZRNKFTFF.mjs → weak-model-mode-BMSPGEQY.mjs} +1 -1
  143. package/dist/bin/hook-chunks/{work-graph-PGYHFLEL.mjs → work-graph-AVAOKY63.mjs} +1 -1
  144. package/dist/bin/hook-chunks/{work-scope-FIB6LBKE.mjs → work-scope-YCS4GTXW.mjs} +1 -1
  145. package/dist/bin/hook-chunks/{workspace-occupancy-3D4OKQRB.mjs → workspace-occupancy-JOBYNNXV.mjs} +1 -1
  146. package/dist/bin/hook-fast-darwin-arm64 +0 -0
  147. package/dist/bin/hook-fast-darwin-x64 +0 -0
  148. package/dist/bin/hook-fast-linux-x64 +0 -0
  149. package/dist/bin/prjct-core.mjs +724 -712
  150. package/dist/bin/prjct-hooks.mjs +3 -3
  151. package/dist/bin/prjct.mjs +21 -8
  152. package/dist/daemon/entry.mjs +617 -603
  153. package/dist/mcp/server.mjs +315 -301
  154. package/package.json +3 -5
  155. package/scripts/install.sh +28 -496
  156. package/dist/bin/hook-chunks/chunk-4KXXDQYI.mjs +0 -11
  157. package/dist/bin/hook-chunks/chunk-BU22R6JX.mjs +0 -9
  158. package/dist/bin/hook-chunks/chunk-CYZ7ST2P.mjs +0 -36
  159. package/dist/bin/hook-chunks/chunk-GPZP7NXL.mjs +0 -11
  160. package/dist/bin/hook-chunks/chunk-KHLYWNHT.mjs +0 -8
  161. package/dist/bin/hook-chunks/chunk-TRMBRDKH.mjs +0 -8
  162. package/dist/bin/hook-chunks/chunk-TXSLON7M.mjs +0 -19
  163. package/dist/bin/hook-chunks/chunk-V2FR2NPL.mjs +0 -43
  164. package/dist/bin/hook-chunks/cwd-changed-EP3UIRK6.mjs +0 -8
  165. package/dist/bin/hook-chunks/pre-edit-PMMWDR2B.mjs +0 -11
  166. package/dist/bin/hook-chunks/project-memory-JK2MXRJB.mjs +0 -8
  167. package/dist/bin/hook-chunks/prompt-DOENKHLQ.mjs +0 -24
  168. package/dist/bin/hook-chunks/retention-C3NQT65W.mjs +0 -8
  169. package/dist/bin/hook-chunks/session-start-B4P7L33E.mjs +0 -8
  170. package/dist/bin/hook-chunks/settings-installer-QDM3GB6J.mjs +0 -9
  171. package/dist/bin/hook-chunks/stop-CFB2H3XC.mjs +0 -16
  172. package/dist/bin/hook-chunks/subagent-start-KFAZZUHS.mjs +0 -8
  173. package/dist/bin/hook-chunks/task-service-PXCDU55T.mjs +0 -8
@@ -0,0 +1,36 @@
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 Tt}from"./chunk-QOQZHR3E.mjs";import{a as bt,b as Pt,c as Ct,d as xt,e as Dt}from"./chunk-TXJT3G53.mjs";import{a as St}from"./chunk-UMJ5D5I6.mjs";import{a as Ze}from"./chunk-JZDZH6IV.mjs";import{a as Xe}from"./chunk-XV2LJVYB.mjs";import{a as et}from"./chunk-YHOZTAZH.mjs";import{a as tt,b as Mt}from"./chunk-Y3RHBU2R.mjs";import{a as wt,b as kt}from"./chunk-NLL5AV2G.mjs";import{d as vt}from"./chunk-UVATSTRF.mjs";import{a as jt,b as At,c as It,d as Et}from"./chunk-LNB2GLYI.mjs";import{a as p}from"./chunk-DYHYDHCW.mjs";import{a as gt}from"./chunk-JR542RI2.mjs";import{b as Y,c as it,d as ct}from"./chunk-CPR4FPXG.mjs";import{a as lt,b as dt,e as ut,f as mt,g as ie,h as pt,i as ft}from"./chunk-3HGQPUKG.mjs";import{a as ht}from"./chunk-ZQI4TJ5C.mjs";import{i as yt}from"./chunk-IWUF2LGO.mjs";import{a as ot}from"./chunk-YLOK4WRR.mjs";import{b as st,c as nt,d as at}from"./chunk-3CKNJ5RA.mjs";import{b as ae}from"./chunk-R4ILCXKE.mjs";import{a as rt}from"./chunk-LR24AIEW.mjs";import{a as oe,b as I}from"./chunk-D7DQABWO.mjs";import{a as Qe}from"./chunk-ETTDRXQ6.mjs";import{c as Ye}from"./chunk-FZS3XGEA.mjs";import{b as Ke}from"./chunk-7WO5CEH3.mjs";import{a as Be,b as qe}from"./chunk-M5E2YOZ4.mjs";import{b as F}from"./chunk-ZZBNFNMG.mjs";import{d as b,e as R,g as K}from"./chunk-TKXOMN4K.mjs";import{d as ne}from"./chunk-KV4NXLPT.mjs";import{b as v,h as se,p as We,r as Ve,u as Tr,v as q,w as Ue}from"./chunk-A6K4H3YT.mjs";import{b as ze,f as Er}from"./chunk-HDSS6UB3.mjs";import{d as He,e as Le,f as Ge,k as N,o as B}from"./chunk-UH4MD3F3.mjs";import{a as Oe,p as Ir}from"./chunk-QWQFF2UG.mjs";import{a as Je}from"./chunk-EXVL2OFE.mjs";import{d as w}from"./chunk-PKDYFXMI.mjs";import{a as M,d as Ne,e as k,f as O}from"./chunk-BUDZL4DW.mjs";import{a as i}from"./chunk-E66B27AL.mjs";function Rt(r,e){let t=[];H("Languages",r.languages,e.languages,t),H("Frameworks",r.frameworks,e.frameworks,t),(r.packageManager??"")!==(e.packageManager??"")&&t.push({field:"Package manager",type:"changed",before:r.packageManager??"(none)",after:e.packageManager??"(none)"}),(r.sourceDir??"")!==(e.sourceDir??"")&&t.push({field:"Source directory",type:"changed",before:r.sourceDir??"(none)",after:e.sourceDir??"(none)"}),(r.testDir??"")!==(e.testDir??"")&&t.push({field:"Test directory",type:"changed",before:r.testDir??"(none)",after:e.testDir??"(none)"}),H("Config files",r.configFiles,e.configFiles,t),r.fileCount!==e.fileCount&&t.push({field:"File count",type:"changed",before:String(r.fileCount),after:String(e.fileCount)});let s=r.patterns.map(c=>c.name),a=e.patterns.map(c=>c.name);H("Patterns",s,a,t);let o=r.antiPatterns.map(c=>c.issue),n=e.antiPatterns.map(c=>c.issue);return H("Anti-patterns",o,n,t),gt(t,r.commitHash??null,e.commitHash??null)}i(Rt,"generateAnalysisDiff");function Cs(r){if(!r.hasChanges)return`## Analysis Diff
9
+
10
+ No changes between runs.`;let e=[];e.push("## Analysis Diff"),(r.beforeCommit||r.afterCommit)&&e.push(`> \`${r.beforeCommit?.substring(0,7)??"(none)"}\` \u2192 \`${r.afterCommit?.substring(0,7)??"(none)"}\``),e.push(""),e.push("| Change | Field | Detail |"),e.push("|--------|-------|--------|");for(let s of r.items){let a=s.type==="added"?"+":s.type==="removed"?"-":"~",o=s.type==="changed"?`${s.before} \u2192 ${s.after}`:s.after??s.before??"";e.push(`| ${a} | ${s.field} | ${o} |`)}e.push("");let t=[];return r.summary.added>0&&t.push(`${r.summary.added} added`),r.summary.removed>0&&t.push(`${r.summary.removed} removed`),r.summary.changed>0&&t.push(`${r.summary.changed} changed`),e.push(`**Summary**: ${t.join(", ")}`),e.join(`
11
+ `)}i(Cs,"formatAnalysisDiffMd");function xs(r){if(!r.hasChanges)return"No changes between analysis runs.";let e=[];(r.beforeCommit||r.afterCommit)&&(e.push(` ${r.beforeCommit?.substring(0,7)??"(none)"} \u2192 ${r.afterCommit?.substring(0,7)??"(none)"}`),e.push(""));for(let t of r.items)t.type==="added"?e.push(` + ${t.field}: ${t.after}`):t.type==="removed"?e.push(` - ${t.field}: ${t.before}`):e.push(` ~ ${t.field}: ${t.before} \u2192 ${t.after}`);return e.join(`
12
+ `)}i(xs,"formatAnalysisDiffText");function H(r,e,t,s){let a=new Set(e),o=new Set(t);for(let n of t)a.has(n)||s.push({field:r,type:"added",after:n});for(let n of e)o.has(n)||s.push({field:r,type:"removed",before:n})}i(H,"diffStringArray");O();B();import ce from"node:fs/promises";import E from"node:path";import{z as g}from"zod";function Q(r,e){let t=r.filter(a=>!a.passed).length,s=r.filter(a=>a.passed).length;return{passed:t===0,checks:r,totalMs:Date.now()-e,failedCount:t,passedCount:s}}i(Q,"summarizeChecks");Er();var Mr=g.enum(["draft","verified","sealed"]),Ft=g.object({severity:g.enum(["low","medium","high"]).optional(),language:g.string().optional(),framework:g.string().optional(),source:g.enum(["baseline","repo","context7","feedback"]).optional(),confidence:g.number().min(0).max(1).optional()}),Rr=g.object({name:g.string(),description:g.string(),location:g.string().optional()}).extend(Ft.shape),Fr=g.object({issue:g.string(),file:g.string(),suggestion:g.string()}).extend(Ft.shape),le=g.object({projectId:g.string(),languages:g.array(g.string()),frameworks:g.array(g.string()),packageManager:g.string().optional(),sourceDir:g.string().optional(),testDir:g.string().optional(),configFiles:g.array(g.string()),fileCount:g.number(),patterns:g.array(Rr),antiPatterns:g.array(Fr),analyzedAt:g.string(),modelMetadata:ze.optional(),status:Mr.default("draft"),commitHash:g.string().optional(),signature:g.string().optional(),sealedAt:g.string().optional(),verifiedAt:g.string().optional()});var _r={TypeScript:[".ts",".tsx",".mts",".cts"],JavaScript:[".js",".jsx",".mjs",".cjs"],Python:[".py",".pyw"],Java:[".java"],Go:[".go"],Rust:[".rs"],Ruby:[".rb"],PHP:[".php"],Swift:[".swift"],Kotlin:[".kt",".kts"],"C++":[".cpp",".cc",".cxx",".hpp",".h"],C:[".c",".h"],"C#":[".cs"],Elixir:[".ex",".exs"],Scala:[".scala"]};async function $r(r,e){let t=Date.now();if(r.frameworks.length===0)return{name:"Framework verification",passed:!0,output:"No frameworks declared (skipped)",durationMs:Date.now()-t};try{let s=E.join(e,"package.json"),a=await ce.readFile(s,"utf-8"),o=JSON.parse(a),n={...o.dependencies,...o.devDependencies},c=[],l=[];for(let d of r.frameworks){let m=d.toLowerCase();Object.keys(n).some(y=>y.toLowerCase().includes(m))?l.push(d):c.push(d)}return c.length===0?{name:"Framework verification",passed:!0,output:`${l.length} framework(s) verified in dependencies`,durationMs:Date.now()-t}:{name:"Framework verification",passed:!1,error:`Frameworks not found in dependencies: ${c.join(", ")}`,durationMs:Date.now()-t}}catch(s){return M(s)?{name:"Framework verification",passed:!1,error:"package.json not found (cannot verify frameworks)",durationMs:Date.now()-t}:{name:"Framework verification",passed:!1,error:`Failed to read package.json: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i($r,"verifyFrameworks");async function Or(r,e){let t=Date.now();if(r.languages.length===0)return{name:"Language verification",passed:!0,output:"No languages declared (skipped)",durationMs:Date.now()-t};try{let s=await Gr(e),a=new Set(s),o=[],n=[];for(let c of r.languages){let l=_r[c];if(!l)continue;l.some(m=>a.has(m))?o.push(c):n.push(c)}return n.length===0?{name:"Language verification",passed:!0,output:`${o.length} language(s) verified with matching files`,durationMs:Date.now()-t}:{name:"Language verification",passed:!1,error:`Languages without matching files: ${n.join(", ")}`,durationMs:Date.now()-t}}catch(s){return{name:"Language verification",passed:!1,error:`Failed to scan project files: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i(Or,"verifyLanguages");async function Nr(r,e){let t=Date.now(),s=r.patterns.filter(n=>n.location);if(s.length===0)return{name:"Pattern location verification",passed:!0,output:"No pattern locations specified (skipped)",durationMs:Date.now()-t};let a=[],o=[];for(let n of s){let c=n.location,l=E.join(e,c);await N(l)?o.push(c):a.push(`${n.name} (${c})`)}return a.length===0?{name:"Pattern location verification",passed:!0,output:`${o.length} pattern location(s) verified`,durationMs:Date.now()-t}:{name:"Pattern location verification",passed:!1,error:`Pattern locations not found: ${a.join(", ")}`,durationMs:Date.now()-t}}i(Nr,"verifyPatternLocations");async function Hr(r,e){let t=Date.now();try{let s=await zr(e),a=r.fileCount,o=.1,n=Math.abs(s-a),c=a*o;return n<=c?{name:"File count verification",passed:!0,output:`File count accurate (declared: ${a}, actual: ${s})`,durationMs:Date.now()-t}:{name:"File count verification",passed:!1,error:`File count mismatch: declared ${a}, actual ${s} (diff: ${n})`,durationMs:Date.now()-t}}catch(s){return{name:"File count verification",passed:!1,error:`Failed to count files: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i(Hr,"verifyFileCount");async function Lr(r,e){let t=Date.now();if(r.antiPatterns.length===0)return{name:"Anti-pattern file verification",passed:!0,output:"No anti-patterns declared (skipped)",durationMs:Date.now()-t};let s=[],a=[];for(let o of r.antiPatterns){let n=E.join(e,o.file);await N(n)?a.push(o.file):s.push(`${o.issue} (${o.file})`)}return s.length===0?{name:"Anti-pattern file verification",passed:!0,output:`${a.length} anti-pattern file(s) verified`,durationMs:Date.now()-t}:{name:"Anti-pattern file verification",passed:!1,error:`Anti-pattern files not found: ${s.join(", ")}`,durationMs:Date.now()-t}}i(Lr,"verifyAntiPatternFiles");async function _t(r,e){let t=Date.now(),s=await Promise.all([$r(r,e),Or(r,e),Nr(r,e),Hr(r,e),Lr(r,e)]);return Q(s,t)}i(_t,"semanticVerify");async function Gr(r){let e=new Set,t=[/node_modules/,/\.git/,/dist/,/build/,/\.next/,/\.turbo/,/coverage/];async function s(a){try{let o=await ce.readdir(a,{withFileTypes:!0});for(let n of o){let c=E.join(a,n.name),l=E.relative(r,c);if(!t.some(d=>d.test(l))){if(n.isDirectory())await s(c);else if(n.isFile()){let d=E.extname(n.name);d&&e.add(d)}}}}catch{}}return i(s,"scanDir"),await s(r),Array.from(e)}i(Gr,"getProjectExtensions");async function zr(r){let e=[/node_modules/,/\.git/,/dist/,/build/,/\.next/,/\.turbo/,/coverage/];async function t(s){try{let a=await ce.readdir(s,{withFileTypes:!0});return(await Promise.all(a.map(async n=>{let c=E.join(s,n.name),l=E.relative(r,c);return e.some(d=>d.test(l))?0:n.isDirectory()?t(c):n.isFile()?1:0}))).reduce((n,c)=>n+c,0)}catch{return 0}}return i(t,"scanDir"),t(r)}i(zr,"countProjectFiles");se();var de=class extends Qe{static{i(this,"AnalysisStorage")}constructor(){super("analysis.json")}getDefault(){return{draft:null,sealed:null,previousSealed:null,lastUpdated:""}}getEventType(e){return`analysis.${e}d`}async saveDraft(e,t){let s={...t,status:"draft"};le.parse(s),await this.update(e,a=>({...a,draft:s,lastUpdated:v()})),this.publishAnalysis(e,s)}publishAnalysis(e,t){Ke({projectId:e,entityType:"analysis",entityId:e,eventType:"upsert",data:{...t,id:e}})}async seal(e){let t=await this.read(e);if(!t.draft)return{success:!1,error:"No draft analysis to seal. Run `p. sync` first."};if(t.draft.status==="sealed")return{success:!1,error:"Draft is already sealed."};let s=this.computeSignature(t.draft),a=v(),o={...t.draft,status:"sealed",signature:s,sealedAt:a};return le.parse(o),await this.write(e,{draft:null,sealed:o,previousSealed:t.sealed,lastUpdated:a}),this.publishAnalysis(e,o),{success:!0,signature:s}}async getSealed(e){return(await this.read(e)).sealed}async getDraft(e){return(await this.read(e)).draft}async getActive(e){let t=await this.read(e);return t.sealed??t.draft}async getStatus(e){let t=await this.read(e);return{hasSealed:t.sealed!==null,hasDraft:t.draft!==null,hasPreviousSealed:t.previousSealed!==null,sealedCommit:t.sealed?.commitHash??null,draftCommit:t.draft?.commitHash??null,previousSealedCommit:t.previousSealed?.commitHash??null,sealedAt:t.sealed?.sealedAt??null}}async rollback(e){let t=await this.read(e);if(!t.previousSealed)return{success:!1,error:"No previous sealed version to rollback to."};let s=v();return await this.write(e,{draft:t.sealed,sealed:t.previousSealed,previousSealed:null,lastUpdated:s}),this.publishAnalysis(e,t.previousSealed),{success:!0,restoredSignature:t.previousSealed.signature}}async diff(e){let t=await this.read(e);return!t.sealed||!t.draft?null:Rt(t.sealed,t.draft)}checkStaleness(e,t){return e?t?e!==t?{isStale:!0,sealedCommit:e,currentCommit:t,message:`Analysis is stale: sealed at ${e}, HEAD is ${t}. Run \`p. sync\` + \`p. seal\` to update.`}:{isStale:!1,sealedCommit:e,currentCommit:t,message:"Analysis is current."}:{isStale:!0,sealedCommit:e,currentCommit:null,message:"Cannot determine current commit. Analysis may be stale."}:{isStale:!1,sealedCommit:null,currentCommit:t,message:"No sealed analysis. Run `p. sync` then `p. seal`."}}async verify(e){let t=await this.read(e);if(!t.sealed)return{valid:!1,message:"No sealed analysis to verify."};if(!t.sealed.signature)return{valid:!1,message:"Sealed analysis has no signature."};let s=this.computeSignature({...t.sealed,signature:void 0,sealedAt:void 0});return s===t.sealed.signature?{valid:!0,message:"Signature verified. Analysis integrity confirmed."}:{valid:!1,message:`Signature mismatch. Expected ${s}, got ${t.sealed.signature}. Analysis may have been modified.`}}async semanticVerify(e,t){let s=await this.read(e),a=s.sealed??s.draft;return a?await _t(a,t):{passed:!1,checks:[{name:"Analysis availability",passed:!1,error:"No analysis available. Run `p. sync` to generate.",durationMs:0}],totalMs:0,failedCount:1,passedCount:0}}computeSignature(e){let t={projectId:e.projectId,languages:e.languages,frameworks:e.frameworks,packageManager:e.packageManager,sourceDir:e.sourceDir,testDir:e.testDir,configFiles:e.configFiles,fileCount:e.fileCount,patterns:e.patterns,antiPatterns:e.antiPatterns,analyzedAt:e.analyzedAt,commitHash:e.commitHash};return Be(JSON.stringify(t))}},X=new de;import ws from"node:fs/promises";import te from"node:path";Tr();Ue();B();import ue from"node:fs/promises";import $t from"node:path";import{gunzipSync as Wr,gzipSync as Vr}from"node:zlib";Ue();K();var Ur="code-graph.json.gz";function Ot(r){return $t.join(q.getGlobalProjectPath(r),Ur)}i(Ot,"artifactPath");async function Jr(r){if(!ie(r))return null;let e=ft(r),t=dt(r),s=pt(r)??{symbolCount:e.length,edgeCount:t.length,fileCount:new Set(e.map(l=>l.file)).size,builtAt:new Date().toISOString()},a={version:1,projectId:r,exportedAt:new Date().toISOString(),meta:s,symbols:e,edges:t},o=Buffer.from(JSON.stringify(a),"utf-8"),n=Vr(o,{level:6}),c=Ot(r);return await ue.mkdir($t.dirname(c),{recursive:!0}),await ue.writeFile(c,n),{path:c,bytes:n.length,symbols:e.length,edges:t.length}}i(Jr,"exportCodeGraphArtifact");async function Br(r){let e=Ot(r),t=await ue.readFile(e).catch(()=>null);if(!t)return{imported:!1,symbols:0,edges:0,reason:"no per-project artifact"};let s=(()=>{try{let o=Wr(t).toString("utf-8");return{payload:JSON.parse(o)}}catch(o){return{error:`corrupt artifact: ${o instanceof Error?o.message:String(o)}`}}})();if("error"in s)return{imported:!1,symbols:0,edges:0,reason:s.error};let a=s.payload;return a.version!==1||!Array.isArray(a.symbols)?{imported:!1,symbols:0,edges:0,reason:"unsupported artifact version"}:a.projectId&&a.projectId!==r?{imported:!1,symbols:0,edges:0,reason:`artifact projectId mismatch (got ${a.projectId}, expected ${r})`}:(lt(r,{symbols:a.symbols,edges:a.edges}),R.setDoc(r,"symbol-graph",{...a.meta,builtAt:a.meta.builtAt??a.exportedAt}),{imported:!0,symbols:a.symbols.length,edges:a.edges.length})}i(Br,"importCodeGraphArtifact");async function Nt(r){if(ie(r))return{bootstrapped:!1,detail:"local index already present"};let e=await Br(r);return e.imported?{bootstrapped:!0,detail:`imported ${e.symbols} symbols / ${e.edges} edges from per-project cache`}:{bootstrapped:!1,detail:e.reason??"import failed"}}i(Nt,"bootstrapCodeGraphFromArtifact");function Ht(r){return r?.cloud?.enabled===!0&&r.cloud.paused!==!0}i(Ht,"shouldAutoUploadCodeGraph");async function Lt(r,e){try{await Jr(r)}catch{}if(e.uploadToCloud)try{await qr(r,e.uploadDependencies)}catch{}}i(Lt,"maybeExportAfterIndex");async function qr(r,e={}){let t=await import("./code-graph-cloud-XGQF7XYC.mjs"),s=(e.buildSnapshot??t.buildCloudCodeGraphSnapshot)(r);if(!t.isUploadableGraph(s))return{uploaded:!1,reason:"no symbol index or empty graph"};try{let o=await(e.upload??(async(n,c)=>{let{default:l}=await import("./sync-client-PIRHMHXL.mjs");return l.uploadCodeGraph(n,c)}))(r,s);return o.ok?{uploaded:!0,nodes:o.nodes??s.nodes.length,links:o.links??s.links.length}:{uploaded:!1,reason:o.reason??"upload failed or unauthenticated",nodes:s.nodes.length,links:s.links.length}}catch(a){return{uploaded:!1,reason:a instanceof Error?a.message:String(a)}}}i(qr,"maybeUploadCodeGraphToCloud");import _ from"node:fs/promises";import Kr from"node:os";import x from"node:path";var me=[{name:"prjct",description:bt,allowedTools:[...Pt],body:i(()=>xt(),"body"),reference:i(()=>Dt(),"reference"),referenceFile:Ct}];function Yr(r){let e=r.userInvocable!==!1;return`---
13
+ description: "${r.description}"
14
+ allowed-tools: [${r.allowedTools.map(t=>`"${t}"`).join(", ")}]
15
+ user-invocable: ${e}
16
+ ---`}i(Yr,"buildFrontmatter");function Qr(r){return`${Yr(r)}
17
+
18
+ ${r.body()}`}i(Qr,"buildSkillContent");function Gt(){return process.env.HOME||Kr.homedir()}i(Gt,"homeDir");function Xr(){return x.join(Gt(),".claude","skills")}i(Xr,"claudeSkillsRoot");function Zr(){let r=Gt();return[x.join(r,".codex","skills"),x.join(r,".gemini","skills"),x.join(r,".gemini","antigravity","global_skills"),x.join(r,".agents","skills")]}i(Zr,"compactSkillRoots");function es(r){return!!(/^# [^\n]+\n[^\n]*\|\s*\d+\s+files\s*\|/m.test(r)||/## Recent Deliveries/m.test(r)||/## Velocity/m.test(r)&&/pts\/sprint/m.test(r))}i(es,"skillBodyHasProjectStamp");var pe=class{static{i(this,"SkillGenerator")}async generateAndInstall(){let e={generated:[],skipped:[]},t=Xr();for(let o of me)try{let n=Qr(o);if(es(n))throw new Error("refusing to install project-stamped skill body (isolation guard)");let c=x.join(t,o.name),l=x.join(c,"SKILL.md");await _.mkdir(c,{recursive:!0}),await _.writeFile(l,n,"utf-8"),o.reference&&o.referenceFile&&await _.writeFile(x.join(c,o.referenceFile),o.reference(),"utf-8"),e.generated.push({name:o.name,path:l})}catch(n){p.debug(`Failed to generate skill ${o.name}`,{error:w(n)}),e.skipped.push({name:o.name,reason:w(n)})}let s=Je();for(let o of Zr())try{let n=x.join(o,"prjct"),c=x.join(n,"SKILL.md");await _.mkdir(n,{recursive:!0}),await _.writeFile(c,s,"utf-8"),e.generated.push({name:"prjct-compact",path:c})}catch(n){p.debug("Compact skill install skipped",{root:o,error:w(n)})}let a=new Set(me.map(o=>o.name));try{let o=await _.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of o)n.isDirectory()&&n.name.startsWith("prjct-")&&!a.has(n.name)&&await _.rm(x.join(t,n.name),{recursive:!0,force:!0}).catch(()=>{})}catch{}return e.generated.length>0&&p.info("Generated portable multi-host skills",{count:e.generated.length,skills:e.generated.map(o=>o.name)}),e}getDefinitions(){return me}},zt=new pe;function fe(){return{branch:"main",commits:0,contributors:0,hasChanges:!1,stagedFiles:[],modifiedFiles:[],untrackedFiles:[],recentCommits:[],weeklyCommits:0}}i(fe,"emptyGitData");function ge(){return{fileCount:0,version:"0.0.0",name:"unknown",ecosystem:"unknown",projectType:"simple",languages:[],frameworks:[]}}i(ge,"emptyStats");function he(){return{install:"npm install",run:"npm run",test:"npm test",build:"npm run build",dev:"npm run dev",lint:"npm run lint",format:"npm run format"}}i(he,"emptyCommands");function ye(){return{hasFrontend:!1,hasBackend:!1,hasDatabase:!1,hasDocker:!1,hasTesting:!1,frontendType:null,frameworks:[]}}i(ye,"emptyStack");function Wt(r,e){let t=[...r.added,...r.modified],s=new Set(t),a=new Set,o=Y(e);if(o)for(let l of t){let d=o.reverse[l];if(d)for(let m of d)s.has(m)||a.add(m)}let n=Array.from(a),c=[...t,...n];return{directlyChanged:t,affectedByImports:n,deleted:r.deleted,allAffected:c}}i(Wt,"propagateChanges");function Vt(r){let e=new Set;for(let t of r){let s=t.toLowerCase();(s.endsWith(".tsx")||s.endsWith(".jsx")||s.endsWith(".css")||s.endsWith(".scss")||s.endsWith(".vue")||s.endsWith(".svelte")||s.includes("/components/")||s.includes("/pages/")||s.includes("/app/"))&&(e.add("frontend"),e.add("uxui")),(s.includes(".test.")||s.includes(".spec.")||s.includes("__tests__")||s.includes("/test/"))&&e.add("testing"),(s.includes("dockerfile")||s.includes("docker-compose")||s.includes(".dockerignore")||s.includes(".github/")||s.includes("ci/")||s.includes("cd/"))&&e.add("devops"),(s.endsWith(".sql")||s.includes("prisma")||s.includes("drizzle")||s.includes("migration")||s.includes("/db/"))&&e.add("database"),(s.endsWith(".ts")||s.endsWith(".js"))&&!s.includes(".test.")&&!s.includes(".spec.")&&!s.endsWith(".d.ts")&&e.add("backend")}return e}i(Vt,"affectedDomains");K();B();import Ut from"node:fs/promises";import ts from"node:path";function rs(r){return typeof Bun<"u"&&Bun.hash?`xxh64:${Bun.hash(r).toString(36)}`:`fnv1a:${([...r].reduce((t,s)=>Math.imul(t^s.charCodeAt(0),16777619),2166136261)>>>0).toString(36)}`}i(rs,"hashContent");async function ss(r,e={}){let t=await He(r,{skipDotfiles:!0,dotfileAllowlist:[".env.example"]}),s=new Map,a=e.changedFilesHint?.length?new Set(e.changedFilesHint):null,o=await Le(t,100,async n=>{try{let c=ts.join(r,n),l=await Ut.stat(c),d=l.mtime.toISOString(),m=e.storedHashes?.get(n),h=a?.has(n)??!1;if(m&&!h&&m.size===l.size&&m.mtime===d&&m.hash)return{path:n,hash:m.hash,size:l.size,mtime:d};let y=await Ut.readFile(c,"utf-8");return{path:n,hash:rs(y),size:l.size,mtime:d}}catch{return null}});for(let n of o)s.set(n.path,n);return s}i(ss,"computeHashes");function ns(r,e){let t=[],s=[],a=[];for(let[n,c]of r){let l=e.get(n);l?l.hash!==c.hash?s.push(n):a.push(n):t.push(n)}let o=[];for(let n of e.keys())r.has(n)||o.push(n);return{added:t,modified:s,deleted:o,unchanged:a}}i(ns,"diffHashes");function Se(r,e){let t=R.getDb(r);t.transaction(()=>{t.prepare("DELETE FROM index_checksums").run();let s=t.prepare("INSERT INTO index_checksums (path, checksum, size, mtime) VALUES (?, ?, ?, ?)");for(let[,a]of e)s.run(a.path,a.hash,a.size,a.mtime)})(),R.setDoc(r,"file-hashes-meta",{fileCount:e.size,builtAt:new Date().toISOString()})}i(Se,"saveHashes");function as(r){let e=new Map;try{let t=R.query(r,"SELECT path, checksum, size, mtime FROM index_checksums");for(let s of t)e.set(s.path,{path:s.path,hash:s.checksum,size:s.size||0,mtime:s.mtime||""})}catch{}return e}i(as,"loadHashes");async function we(r,e,t){let s=as(e),a=await ss(r,{storedHashes:s,changedFilesHint:t});return{diff:ns(a,s),currentHashes:a}}i(we,"detectChanges");function Jt(r){return R.hasDoc(r,"file-hashes-meta")}i(Jt,"hasHashRegistry");O();var os=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]);async function Bt(r){let{projectId:e,projectPath:t,isFullSync:s,changedFilesHint:a}=r,o={shouldRebuildIndexes:!0,changedDomains:new Set,incrementalInfo:void 0,changedSourceFiles:[],deletedSourceFiles:[]};if(!s&&Jt(e)){try{let{diff:n,currentHashes:c}=await we(t,e,a),l=n.added.length+n.modified.length+n.deleted.length,d=(()=>{if(l===0&&!a?.length)return{shouldRebuildIndexes:!1,changedDomains:new Set,incrementalInfo:{isIncremental:!0,filesChanged:0,filesUnchanged:n.unchanged.length,indexesRebuilt:!1,affectedDomains:[]},changedSourceFiles:[],deletedSourceFiles:[]};let m=Wt(n,e),h=Vt(m.allAffected),y=m.allAffected.some(ke);return{shouldRebuildIndexes:y,changedDomains:h,incrementalInfo:{isIncremental:!0,filesChanged:l,filesUnchanged:n.unchanged.length,indexesRebuilt:y,affectedDomains:Array.from(h)},changedSourceFiles:[...n.added,...n.modified].filter(ke),deletedSourceFiles:n.deleted.filter(ke)}})();return l>0&&Se(e,c),d}catch(n){p.debug("Incremental detection failed, falling back to full sync",{error:k(n)})}return o}try{let{currentHashes:n}=await we(t,e,a);Se(e,n)}catch(n){p.debug("Hash computation failed (non-critical)",{error:k(n)})}return o}i(Bt,"detectIncrementalChanges");function ke(r){let e=r.substring(r.lastIndexOf("."));return os.has(e)}i(ke,"isSourceFile");import{z as j}from"zod";var En=j.object({date:j.string(),tokensSaved:j.number(),syncs:j.number(),avgCompressionRate:j.number(),totalDuration:j.number()}),Tn=j.object({agentName:j.string(),usageCount:j.number(),tokensSaved:j.number()}),qt={"claude-opus-4.5":.005,"claude-sonnet-4.5":.003,"claude-haiku-4.5":.001,"claude-opus-4":.015,"claude-sonnet-4":.003,"gpt-4o":.0025,"gemini-pro":.00125,default:.003};function Kt(r,e="default"){let t=qt[e]||qt.default;return r/1e3*t}i(Kt,"estimateCostSaved");function Mn(r){return r<.01?`$${(r*100).toFixed(2)}\xA2`:`$${r.toFixed(2)}`}i(Mn,"formatCost");K();var is=i(r=>({date:r.date,tokensSaved:r.tokens_saved,syncs:r.syncs,avgCompressionRate:r.avg_compression_rate,totalDuration:r.total_duration}),"rowToDaily"),Z=i(r=>{let e=new Date;return e.setDate(e.getDate()-r),e.toISOString().split("T")[0]},"dayCutoff"),ve=class{static{i(this,"MetricsStorage")}async recordSync(e,t){let s=Math.max(0,t.originalSize-t.filteredSize),a=t.originalSize>0?s/t.originalSize:0,o=new Date().toISOString().split("T")[0];if(b.run(e,`INSERT INTO metrics_daily (date, tokens_saved, syncs, avg_compression_rate, total_duration)
19
+ VALUES (?, ?, 1, ?, ?)
20
+ ON CONFLICT(date) DO UPDATE SET
21
+ tokens_saved = metrics_daily.tokens_saved + excluded.tokens_saved,
22
+ avg_compression_rate =
23
+ (metrics_daily.avg_compression_rate * metrics_daily.syncs + excluded.avg_compression_rate)
24
+ / (metrics_daily.syncs + 1),
25
+ syncs = metrics_daily.syncs + 1,
26
+ total_duration = metrics_daily.total_duration + excluded.total_duration`,o,s,a,t.duration),t.agents?.length){let n=Math.floor(s/t.agents.length);for(let c of t.agents)b.run(e,`INSERT INTO metrics_agent_usage (agent_name, usage_count, tokens_saved)
27
+ VALUES (?, 1, ?)
28
+ ON CONFLICT(agent_name) DO UPDATE SET
29
+ usage_count = metrics_agent_usage.usage_count + 1,
30
+ tokens_saved = metrics_agent_usage.tokens_saved + excluded.tokens_saved`,c,n)}}async getSummary(e){let t=b.get(e,`SELECT COALESCE(SUM(tokens_saved), 0) AS tokens,
31
+ COALESCE(SUM(syncs), 0) AS syncs,
32
+ COALESCE(SUM(total_duration), 0) AS duration,
33
+ COALESCE(SUM(avg_compression_rate * syncs), 0) AS weighted_rate
34
+ FROM metrics_daily`),s=t?.syncs??0,a=t?.tokens??0,o=i((m,h)=>b.get(e,h?"SELECT COALESCE(SUM(tokens_saved), 0) AS t FROM metrics_daily WHERE date >= ? AND date < ?":"SELECT COALESCE(SUM(tokens_saved), 0) AS t FROM metrics_daily WHERE date >= ?",...h?[m,h]:[m])?.t??0,"rangeTokens"),n=o(Z(30)),c=o(Z(60),Z(30)),l=c>0?(n-c)/c*100:0,d=b.query(e,"SELECT * FROM metrics_agent_usage ORDER BY usage_count DESC LIMIT 5").map(m=>({agentName:m.agent_name,usageCount:m.usage_count,tokensSaved:m.tokens_saved}));return{totalTokensSaved:a,estimatedCostSaved:Kt(a),compressionRate:s>0?(t?.weighted_rate??0)/s:0,syncCount:s,avgSyncDuration:s>0?(t?.duration??0)/s:0,topAgents:d,last30DaysTokens:n,trend:l}}async getDailyStats(e,t=30){return b.query(e,"SELECT * FROM metrics_daily WHERE date >= ? ORDER BY date ASC",Z(t)).map(is)}async getFirstSyncDate(e){return b.get(e,"SELECT MIN(date) AS d FROM metrics_daily")?.d??""}},Yt=new ve;O();se();import cs from"node:path";function ls(r){return qe(cs.resolve(r))}i(ls,"repoHash");function L(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"")}i(L,"normalizeKey");function ds(r){return ae(r,e=>`${L(e.name)}::${L(e.source)}`)}i(ds,"dedupePatterns");function us(r){return ae(r,e=>`${L(e.issue)}::${L(e.file)}::${L(e.source)}`)}i(us,"dedupeAntiPatterns");var be=class{static{i(this,"PatternExtractor")}async extract(e){let t=ls(e.projectPath),s=[];if(e.context7Verified)for(let l of e.frameworks)s.push({name:`${l} API validation via Context7`,description:`Validate ${l} APIs against current documentation through Context7 before implementation.`,framework:l,source:"context7",confidence:.7});let a=(e.feedback?.patternsDiscovered||[]).map(l=>({name:l,description:`Confirmed during completed tasks: ${l}`,source:"feedback",confidence:.75})),o=(e.feedback?.knownGotchas||[]).map(l=>({issue:l,file:"multiple",suggestion:`Recurring gotcha. Prevent this pattern during implementation: ${l}`,source:"feedback",severity:"medium",confidence:.7})),n=ds([...s,...a]),c=us([...o]);return{patterns:n,antiPatterns:c,repoPathHash:t}}},ms=new be,Qt=ms;var Xt=200;async function Zt(r,e,t){let{bm25Index:s,originalSize:a}=(()=>{try{let d=st(r),m=d?Object.values(d.documents).reduce((h,y)=>h+y.length,0):0;return{bm25Index:d,originalSize:m||e.fileCount*Xt}}catch(d){return p.debug("Could not load BM25 index for metrics",{error:k(d)}),{bm25Index:null,originalSize:e.fileCount*Xt}}})(),o=0,n=a>0?Math.max(0,(a-o)/a):0;try{await Yt.recordSync(r,{originalSize:a,filteredSize:o,duration:t,isWatch:!1})}catch(d){p.debug("Failed to record sync metrics",{error:k(d)})}try{let{velocityStorage:d}=await import("./velocity-storage-IOCVK2LU.mjs");await d.recompute(r)}catch(d){p.debug("Failed to recompute velocity",{error:k(d)})}let c=await import("./developer-evolution-UTY3CWOK.mjs").then(({captureDeveloperSnapshot:d})=>d(r)).catch(d=>(p.debug("Failed to capture dev snapshot",{error:k(d)}),!1)),l={};try{let d=s;d&&(l.bm25Files=d.totalDocs,l.bm25AvgTokens=Math.round(d.avgDocLength),l.bm25VocabSize=Object.keys(d.invertedIndex).length);let m=Y(r);m&&(l.importEdges=m.edgeCount,l.importFiles=m.fileCount);let h=wt(r);h&&(l.cochangeCommits=h.commitsAnalyzed,l.cochangeFiles=h.filesAnalyzed)}catch(d){p.debug("Could not load index stats",{error:k(d)})}return{duration:t,originalSize:a,filteredSize:o,compressionRate:n,indexes:l,developerSnapshotCaptured:c}}i(Zt,"recordSyncMetrics");async function er(r,e,t,s,a,o){try{let n=t.recentCommits[0]?.hash||null,c=await I.getAggregatedFeedback(r).catch(()=>{});try{let{refreshSkillIndex:d}=await import("./skill-index-55I3HLAI.mjs");await d(r,e)}catch{}let l=await Qt.extract({projectId:r,projectPath:e,languages:s.languages,frameworks:Array.from(new Set([...s.frameworks,...a.frameworks])),feedback:c,context7Verified:o});await X.saveDraft(r,{projectId:r,languages:s.languages,frameworks:s.frameworks,configFiles:[],fileCount:s.fileCount,patterns:l.patterns,antiPatterns:l.antiPatterns,analyzedAt:v(),status:"draft",commitHash:n??void 0})}catch(n){p.debug("Failed to save draft analysis (non-critical)",{error:k(n)})}}i(er,"saveDraftAnalysis");async function tr(r){try{let[e,t,s,a,o]=await Promise.all([Xe.archiveOldShipped(r).catch(()=>0),Ze.markDormantIdeas(r).catch(()=>0),et.removeStaleCompleted(r).catch(()=>0),I.archiveStalePausedTasks(r).catch(()=>[]),rt.capEntries(r).catch(()=>0)]),n=e+t+s+a.length+o;if(n>0){p.info("Archived stale data",{shipped:e,dormant:t,staleQueue:s,stalePaused:a.length,memoryCapped:o,total:n});let c=Ye.getStats(r);p.debug("Archive stats",c)}}catch(e){p.debug("Archival failed (non-critical)",{error:k(e)})}}i(tr,"archiveStaleData");var fs=6e4,Pe=class extends Error{static{i(this,"SyncPhaseTimeoutError")}phase;timeoutMs;constructor(e,t){super(`sync phase '${e}' timed out after ${t}ms. Set PRJCT_SYNC_PHASE_TIMEOUT_MS to tune this guard, or run \`prjct sync --full --md\` if incremental state looks stale.`),this.name="SyncPhaseTimeoutError",this.phase=e,this.timeoutMs=t}};function gs(){return Number(process.env.PRJCT_SYNC_PHASE_TIMEOUT_MS)||fs}i(gs,"syncPhaseTimeoutMs");function rr(r,e){let t=gs(),s=(()=>{let a=Promise.withResolvers(),o=setTimeout(()=>a.reject(new Pe(e,t)),t);return{promise:a.promise,cancel:i(()=>clearTimeout(o),"cancel")}})();return Promise.race([r,s.promise]).finally(s.cancel)}i(rr,"withPhaseTimeout");async function sr(r,e,t){let s=Date.now();p.debug("sync phase start",{phase:r});try{let a=await e(),o=Date.now()-s;return p.debug("sync phase done",{phase:r,ms:o}),t?.push({phase:r,ms:o}),a}catch(a){let o=Date.now()-s;throw p.debug("sync phase failed",{phase:r,ms:o,error:w(a)}),t?.push({phase:r,ms:o}),a}}i(sr,"runSyncPhase");function Ce(r,e={}){let t=e.now??Date.now,s=t(),o=(()=>{try{return r().then(()=>({}),n=>({error:n}))}catch(n){return Promise.resolve({error:n})}})().then(n=>{try{e.onComplete?.({totalMs:t()-s,...n})}catch{}});return{async settle(){await o}}}i(Ce,"startPostIndexWork");K();import hs from"node:fs/promises";import ys from"node:path";O();se();O();B();import xe from"node:fs/promises";import ee from"node:path";var De=".prjct/.prjct-state.md",je=class{static{i(this,"LocalStateGenerator")}async generate(e,t){let s=ee.join(e,De);await xe.mkdir(ee.dirname(s),{recursive:!0});let a=this.toMarkdown(t);await xe.writeFile(s,a,"utf-8")}async remove(e){try{await xe.unlink(ee.join(e,De))}catch(t){if(!M(t))throw t}}async exists(e){let t=ee.join(e,De);return N(t)}toMarkdown(e){let t=["<!-- Auto-generated by prjct - DO NOT EDIT -->","<!-- This file provides local state persistence for AI tools -->","","# prjct State",""];if(e.currentTask){let s=e.currentTask;if(t.push("## Current Work Cycle"),t.push(""),t.push(`**${s.description}**`),t.push(""),t.push(`- Started: ${s.startedAt}`),s.linearId&&t.push(`- Linear: ${s.linearId}`),s.branch&&t.push(`- Branch: ${s.branch}`),t.push(`- Status: ${s.status||"active"}`),t.push(""),s.subtasks&&s.subtasks.length>0){t.push("### Subtasks"),t.push(""),s.subtasks.forEach((c,l)=>{let d=c.status==="completed"?"\u2705":c.status==="in_progress"?"\u25B6\uFE0F":"\u23F3",m=l===s.currentSubtaskIndex?" \u2190 **Active**":"";t.push(`${l+1}. ${d} ${c.description}${m}`)}),t.push("");let a=s.subtasks.filter(c=>c.status==="completed").length,o=s.subtasks.length,n=Math.round(a/o*100);t.push(`**Progress**: ${a}/${o} (${n}%)`),t.push("")}}else t.push("*No active work cycle*"),t.push(""),t.push('Start work with `p. work "intent"`'),t.push("");if(e.previousTask){let s=e.previousTask;t.push("---"),t.push(""),t.push("## Previous Work Cycle"),t.push(""),t.push(`**${s.description}**`),t.push(""),t.push(`- Status: ${s.status}`),s.prUrl&&t.push(`- PR: ${s.prUrl}`),t.push("")}return t.push("---"),t.push(`*Last updated: ${e.lastUpdated||new Date().toISOString()}*`),t.push(""),t.join(`
35
+ `)}},nr=new je;var Ss=["storage","context","memory","analysis","config","sync"];async function ar(r){try{await Promise.all(Ss.map(e=>hs.mkdir(ys.join(r,e),{recursive:!0})))}catch(e){throw new Error(Ne(e,r,"project directories"))}}i(ar,"ensureProjectDirectories");async function or(r){let{projectId:e,projectPath:t,cliVersion:s,git:a,stats:o}=r,n=b.getDoc(e,"project")||{},c={...n,projectId:e,repoPath:t,name:o.name,version:o.version,cliVersion:s,techStack:o.frameworks,fileCount:o.fileCount,commitCount:a.commits,stack:o.ecosystem,currentBranch:a.branch,hasUncommittedChanges:a.hasChanges,createdAt:n.createdAt||v(),lastSync:v(),lastSyncCommit:a.recentCommits[0]?.hash||null,lastSyncBranch:a.branch};b.setDoc(e,"project",c)}i(or,"updateProjectDoc");async function ir(r){let{projectId:e,projectPath:t,stats:s,stack:a}=r,n={...await I.read(e)};n.projectId=e,n.stack={language:s.languages[0]||"Unknown",framework:s.frameworks[0]||null},n.domains={hasFrontend:a.hasFrontend,hasBackend:a.hasBackend,hasDatabase:a.hasDatabase,hasTesting:a.hasTesting,hasDocker:a.hasDocker},n.projectType=s.projectType,n.metrics={totalFiles:s.fileCount},n.lastSync=v(),n.lastUpdated=v(),n.context={...n.context||{},lastSession:v(),lastAction:"Synced project",nextAction:'Run `p. work "intent"` to start a work cycle'},await I.write(e,n);try{await nr.remove(t)}catch(c){p.debug("Legacy local state cleanup failed (optional)",{error:k(c)})}}i(ir,"updateStateDoc");function cr(r,e,t){b.appendEvent(r,"sync",{branch:e.branch,uncommitted:e.hasChanges,fileCount:t.fileCount,commitCount:e.commits})}i(cr,"logSyncEvent");import lr from"node:fs/promises";import Ae from"node:path";O();Ir();var dr={async jsonFilesValid(r){let e=Date.now(),t=[],s=Ae.basename(r);try{await I.read(s)}catch(a){M(a)||t.push(`state: ${k(a)}`)}return{name:"State data valid",passed:t.length===0,output:t.length===0?"1 store validated":void 0,error:t.length>0?t.join("; "):void 0,durationMs:Date.now()-e}},async noSensitiveData(r){let e=Date.now(),t=Ae.join(r,"context"),s=[/(?:api[_-]?key|apikey)\s*[:=]\s*['"][^'"]{10,}/i,/(?:password|passwd|pwd)\s*[:=]\s*['"][^'"]{4,}/i,/(?:secret|token)\s*[:=]\s*['"][^'"]{10,}/i],a=[];try{let o=await lr.readdir(t);for(let n of o){if(!n.endsWith(".md"))continue;let c=await lr.readFile(Ae.join(t,n),"utf-8");for(let l of s)if(l.test(c)){a.push(`${n}: potential sensitive data detected`);break}}}catch(o){if(!M(o))return{name:"No sensitive data",passed:!1,error:`Could not scan: ${k(o)}`,durationMs:Date.now()-e}}return{name:"No sensitive data",passed:a.length===0,output:a.length===0?"No sensitive patterns found":void 0,error:a.length>0?a.join("; "):void 0,durationMs:Date.now()-e}}},Ie=class{static{i(this,"SyncVerifier")}async verify(e,t,s){let a=Date.now(),o=[],n=s?.failFast??!1,c=[],l=[dr.jsonFilesValid(t),dr.noSensitiveData(t)];for(let m of l){let h=await m;if(o.push(h),!h.passed&&n){c.push(...s?.checks?.filter(y=>y.enabled!==!1).map(y=>y.name)??[]);break}}if((!n||o.every(m=>m.passed))&&s?.checks)for(let m of s.checks){if(m.enabled===!1){c.push(m.name);continue}let h=await this.runCustomCheck(m,e);if(o.push(h),!h.passed&&n){let y=s.checks.slice(s.checks.indexOf(m)+1);c.push(...y.filter(P=>P.enabled!==!1).map(P=>P.name));break}}return{...Q(o,a),skippedCount:c.length}}async runCustomCheck(e,t){let s=Date.now(),a=e.command||(e.script?`sh ${e.script}`:null);if(!a)return{name:e.name,passed:!1,error:"No command or script specified",durationMs:Date.now()-s};try{let{stdout:o,stderr:n}=await Oe(a,{cwd:t,timeout:3e4});return{name:e.name,passed:!0,output:(o.trim()||n.trim()).slice(0,200)||void 0,durationMs:Date.now()-s}}catch(o){let n=o;return{name:e.name,passed:!1,error:(n.stderr?.trim()||n.message).slice(0,200),durationMs:Date.now()-s}}}},ur=new Ie;var Ee=class{static{i(this,"SyncService")}projectPath;projectId=null;globalPath="";cliVersion="0.0.0";constructor(){this.projectPath=process.cwd()}async sync(e=process.cwd(),t={}){this.projectPath=e;let s=Date.now(),a=[],o=i((l,d)=>sr(l,d,a),"phase"),n={installed:!1,verified:!1,configPath:"",message:""},c=[];try{if(this.projectId=await F.getProjectId(e),!this.projectId)return{success:!1,projectId:"",cliVersion:"",git:fe(),stats:ge(),commands:he(),stack:ye(),context7:{installed:!1,verified:!1},error:"No prjct project. Run p. init first."};if(this.globalPath=q.getGlobalProjectPath(this.projectId),this.cliVersion=await this.getCliVersion(),await ws.rm(te.join(this.globalPath,"agents"),{recursive:!0,force:!0}).catch(()=>{}),(await Ve()).installed){let u=await vt({autoRepair:!0});u.verified||p.warn(`Codex p. router not ready: ${u.message||"verification failed"}`)}await o("mcp-defaults",()=>St({silent:!0,verifyContext7:!1}));let d=await We().catch(()=>null),m=d?.name??"claude";try{Object.assign(n,await o("context7",()=>yt.ensureReady(m)))}catch(u){let f=w(u);p.warn(`Context7 MCP not ready (continuing sync): ${f}`),Object.assign(n,{verified:!1,message:f})}await ar(this.globalPath),process.env.PRJCT_SKIP_CREW_SWEEP!=="1"&&await o("legacy-crew-sweep",async()=>{try{let{legacyCrewSweep:u}=await import("./legacy-crew-sweep-GR6HRSHX.mjs"),f=await u(this.projectPath,this.projectId);(f.checkpointsMigrated||f.teamMigrated||f.checkpointsHandEditWarned||f.teamHandEditWarned||f.ghostDirsPurged.length>0||f.agentFilesRepaired.length>0||f.clientPrjctJunkPurged.length>0||f.errors.length>0)&&p.info("Legacy crew sweep ran",{checkpointsMigrated:f.checkpointsMigrated,teamMigrated:f.teamMigrated,checkpointsHandEditWarned:f.checkpointsHandEditWarned,teamHandEditWarned:f.teamHandEditWarned,ghostDirsPurged:f.ghostDirsPurged,agentFilesRepaired:f.agentFilesRepaired,ghostFilesIngested:f.ghostFilesIngested,clientPrjctJunkPurged:f.clientPrjctJunkPurged,errors:f.errors.length})}catch(u){p.debug("Legacy crew sweep failed (non-critical)",{error:w(u)})}});let[y,P,Re,G]=await o("gather",()=>rr(Promise.all([jt(this.projectPath),At(this.projectPath),It(this.projectPath),Et(this.projectPath)]),"gather")),{shouldRebuildIndexes:fr,changedDomains:bs,incrementalInfo:Fe,changedSourceFiles:z,deletedSourceFiles:W}=await o("incremental",()=>Bt({projectId:this.projectId,projectPath:this.projectPath,isFullSync:t.full===!0,changedFilesHint:t.changedFiles}));try{let{refreshFileInventory:u}=await import("./project-file-inventory-HHURZTMH.mjs");await u(this.projectId,this.projectPath)}catch{}try{await Nt(this.projectId)}catch{}fr&&await o("index",async()=>{try{let u=Fe?.isIncremental&&(z.length>0||W.length>0);await Promise.all([u?at(this.projectPath,this.projectId,z,W):nt(this.projectPath,this.projectId),u?ct(this.projectPath,this.projectId,z,W):it(this.projectPath,this.projectId),u?mt(this.projectPath,this.projectId,z,W):ut(this.projectPath,this.projectId),kt(this.projectPath,this.projectId)]);let f=this.projectId,S=this.projectPath,T=await F.readConfig(S).catch(()=>null),C=Ht(T);c.push(Ce(()=>Lt(f,{uploadToCloud:C}),{onComplete:i(({totalMs:D,error:J})=>{p.debug("sync post-index work settled",{projectId:f,uploadToCloud:C,totalMs:D,...J===void 0?{}:{error:w(J)}})},"onComplete")}))}catch(u){p.debug("File ranking index build failed (non-critical)",{error:w(u)})}});let gr=Date.now();p.debug("sync phase start",{phase:"skills"});let hr=await zt.generateAndInstall().catch(u=>{p.debug("Native skill generation failed (non-critical)",{error:w(u)})});p.debug("sync phase done",{phase:"skills",ms:Date.now()-gr}),await o("update-files",()=>Promise.all([or({projectId:this.projectId,projectPath:this.projectPath,cliVersion:this.cliVersion,git:y,stats:P}),ir({projectId:this.projectId,projectPath:this.projectPath,stats:P,stack:G}),Promise.resolve(cr(this.projectId,y,P)),er(this.projectId,this.projectPath,y,P,G,n.verified)]));let re=await X.getActive(this.projectId),yr={patterns:re?.patterns?.length||0,antiPatterns:re?.antiPatterns?.length||0,criticalAntiPatterns:re?.antiPatterns?.filter(u=>u.severity==="high").length||0},Sr=await(async()=>{try{let{recomputeProjectStyle:u,formatProjectStyleForSync:f}=await import("./project-style-evolution-IJXT2MCP.mjs"),S=await o("project-style",()=>u({projectId:this.projectId,projectPath:this.projectPath,stats:P,stack:G,commands:Re,commitHash:y.recentCommits[0]?.hash??null,source:"sync-mechanical"})),T=f(S),C=S.snapshot.payload.metrics.styleCoverage;return{summary:S.snapshot.summary,evolutionMd:T.evolutionMd,patternCount:S.snapshot.patternCount,antiPatternCount:S.snapshot.antiPatternCount,conventionCount:S.snapshot.conventionCount,styleCoverage:typeof C=="number"?C:Number(C)||0,isFirst:S.isFirst,hasChanges:S.delta.hasChanges}}catch(u){p.debug("Project style recompute failed (non-critical)",{error:w(u)});return}})(),_e=[],V={},U=i((u,f,S)=>{_e.push(Ce(async()=>{S(await o(u,f))},{onComplete:i(({totalMs:T,error:C})=>{p.debug("sync floating phase settled",{phase:u,overlapped:!0,totalMs:T,...C===void 0?{}:{error:w(C)}})},"onComplete")}))},"floatPhase"),wr=Date.now()-s;U("metrics",()=>Zt(this.projectId,P,wr),u=>{V.syncMetrics=u}),U("install-global",async()=>{await ne.installGlobalConfig(d??void 0),await ne.syncCommands(d??void 0)},()=>{}),U("install-agent-surfaces",async()=>{let{detectInstalledAgents:u}=await import("./detection-QRVSNMKL.mjs"),f=await u(this.projectPath).catch(()=>[]);await ht(this.projectPath,{refreshIfAdopted:!0,agents:f})},()=>{}),U("verify",async()=>{try{let u=await F.readConfig(this.projectPath);return await ur.verify(this.projectPath,this.globalPath,u?.verification)}catch(u){p.debug("Verification failed (non-critical)",{error:w(u)});return}},u=>{V.verification=u});let kr=await o("work-cost",()=>Tt(this.projectId));await o("archive",()=>tr(this.projectId));let vr=await o("context-quality",()=>ot(this.projectPath,this.projectId)),br=await o("retention",async()=>{try{let u=await F.readConfig(this.projectPath).catch(()=>null),f=u?.retention?.mode??"apply";if(f==="off")return;let S=f==="dry-run",{applyRetention:T,triageInbox:C}=await import("./retention-RET4P2RO.mjs"),D=T(this.projectId,{dryRun:S,maxArchive:u?.retention?.maxArchive,maxDelete:u?.retention?.maxDelete}),{inboxMerged:J,inboxArchived:xr}=S?{inboxMerged:0,inboxArchived:0}:(()=>{let A=C(this.projectId);return{inboxMerged:A.merged,inboxArchived:A.archived}})(),{runVaultPurge:Dr,vaultHealth:jr}=await import("./purge-N2WN6NDB.mjs"),$=await Dr(this.projectId,{projectPath:this.projectPath,dryRun:S,softDeletedPurgeDays:u?.retention?.softDeletedPurgeDays,archivePruneDays:u?.retention?.archivePruneDays,autoSourceMaxLive:u?.retention?.autoSourceMaxLive}),Ar=jr(this.projectId);return{evaluated:D.evaluated,active:D.active,archive:D.wouldArchive,delete:D.wouldDelete,archived:D.archived,deleted:D.deleted,inboxMerged:J,inboxArchived:xr,dryRun:S,samples:D.samples.map(A=>({id:A.id,type:A.type,verdict:A.verdict,score:A.score,reasons:A.reasons,excess:A.excess})),referenceSize:D.referenceSize,vault:{...Ar,softDeletedPurged:$.softDeletedPurged,orphanEventsPurged:$.orphanEventsPurged,archivesPruned:$.archivesPruned,autoSourceTrimmed:$.autoSourceTrimmed,distilledDiscarded:$.distilledDiscarded,digestsWritten:$.digestsWritten}}}catch(u){p.debug("retention phase failed",{error:w(u)});return}});if(process.env.PRJCT_WORLD_MODEL_REFRESH==="1"||process.env.PRJCT_DRIFT_REFRESH==="1")try{let u=await import("node:os"),{markDriftRefreshApplied:f}=await import("./drift-refresh-TD3PYPJN.mjs"),S=process.env.PRJCT_CLI_HOME?te.resolve(process.env.PRJCT_CLI_HOME):te.join(u.homedir(),".prjct-cli");f(S)}catch{}await Promise.all([...c.map(u=>u.settle()),..._e.map(u=>u.settle())]);let $e=V.syncMetrics,Pr=V.verification,Cr=$e?.developerSnapshotCaptured===!0;return{success:!0,projectId:this.projectId,cliVersion:this.cliVersion,git:y,stats:P,commands:Re,stack:G,context7:{installed:n.installed,verified:n.verified,message:n.message},analysisSummary:yr,contextQuality:vr,retentionDryRun:br,syncMetrics:$e,workCost:kr,verification:Pr,incremental:Fe,projectStyle:Sr,developerSnapshotCaptured:Cr,generatedSkills:hr,phaseTimings:a}}catch(l){return{success:!1,projectId:this.projectId||"",cliVersion:this.cliVersion,git:fe(),stats:ge(),commands:he(),stack:ye(),context7:{installed:n.installed,verified:n.verified,message:n.message},error:w(l)}}}async getCliVersion(){try{let e=te.join(__dirname,"..","..","package.json");return(await Ge(e))?.version||"0.0.0"}catch(e){return p.debug("Failed to read CLI version",{error:w(e)}),"0.0.0"}}},mo=new Ee;import Te from"chalk";var mr={task:"Start new work cycle",done:"Complete current work",pause:"Pause and switch context",resume:"Continue paused task",ship:"Ship the feature",reopen:"Reopen for rework",next:"View task queue",sync:"Analyze project",bug:"Report a bug",idea:"Capture an idea"},ks={task:"work"};function Me(r){return ks[r]??r}i(Me,"publicCommand");var pr={task:"working",done:"completed","done-subtask":"working",pause:"paused",resume:"working",ship:"shipped",reopen:"working",next:"idle",sync:"idle",init:"idle",bug:"working",idea:"idle"};function yo(r,e={}){if(e.quiet)return;let t=pr[r]||"idle",s=oe.getValidCommands(t);if(s.length===0)return;let a=s.map(o=>({cmd:`p. ${Me(o)}`,desc:mr[o]||o}));console.log(Te.dim(`
36
+ Next:`));for(let o of a){let n=Te.cyan(o.cmd.padEnd(12));console.log(Te.dim(` ${n} \u2192 ${o.desc}`))}}i(yo,"showNextSteps");function So(r,e=!1){let t=pr[r]||"idle";return oe.getValidCommands(t).map(a=>({cmd:e?`prjct ${Me(a)} --md`:`p. ${Me(a)}`,desc:mr[a]||a}))}i(So,"getNextSteps");async function vs(r,e={}){let t=await F.getProjectId(r);return t?{ok:!0,value:t}:(e.md?console.log("> No project ID found. Run `prjct init` first."):tt.failWithHint("NO_PROJECT_ID"),{ok:!1,result:{success:!1,error:"No project ID found"}})}i(vs,"requireProjectId");async function Mo(r,e={}){let t=await Mt.ensureInit(r);return t.success?vs(r,e):{ok:!1,result:t}}i(Mo,"requireProject");export{Cs as a,xs as b,X as c,Mn as d,Yt as e,mo as f,yo as g,So as h,Mo as i};
@@ -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 c,e as p,h as l}from"./chunk-UUULLTQV.mjs";import{b as E,c as d}from"./chunk-I26F7TLM.mjs";import{b as m}from"./chunk-PO3QDKTE.mjs";import{e as i,g as R}from"./chunk-UHVYBU7F.mjs";import{a as g}from"./chunk-E66B27AL.mjs";l();R();var y=class{static{g(this,"MemoryService")}async log(t,r,n,o,s){try{let e=s?.projectId??await m.getProjectId(t);return e?{eventId:i.appendEvent(e,`memory.${r}`,{...n,author:o}),projectId:e}:null}catch(e){let a=e instanceof Error?e.message:String(e);if(s?.required)throw new Error(a);return console.error(`Memory log error: ${a}`),null}}async clear(t){try{let r=await m.getProjectId(t);if(!r)return;i.run(r,"DELETE FROM events WHERE type >= ? AND type < ?",...c)}catch(r){console.error(`Memory clear error: ${r instanceof Error?r.message:String(r)}`)}}async getRecentEvents(t,r=100){try{return i.query(t,"SELECT type, data, timestamp FROM events WHERE type >= ? AND type < ? ORDER BY id DESC LIMIT ?",...c,r).reverse().map(o=>{let s=JSON.parse(o.data);return{timestamp:o.timestamp,action:o.type.replace("memory.",""),...s}})}catch(n){return console.error(`Memory read error: ${n instanceof Error?n.message:String(n)}`),[]}}async capEntries(t){try{let n=i.get(t,"SELECT COUNT(*) as cnt FROM events WHERE type >= ? AND type < ? AND NOT (type >= ? AND type < ?)",...c,...p)?.cnt??0;if(n<=E.MEMORY_MAX_ENTRIES)return 0;let o=n-E.MEMORY_MAX_ENTRIES,s=i.query(t,"SELECT id, type, data, timestamp FROM events WHERE type >= ? AND type < ? AND NOT (type >= ? AND type < ?) ORDER BY id ASC LIMIT ?",...c,...p,o);return d.archiveMany(t,s.map((e,a)=>({entityType:"memory_entry",entityId:`memory-${e.timestamp||a}`,entityData:{type:e.type,data:JSON.parse(e.data),timestamp:e.timestamp},summary:e.type.replace("memory.",""),reason:"overflow"}))),i.transaction(t,e=>{let a=e.prepare("DELETE FROM events WHERE id = ?");for(let u of s)a.run(u.id)}),o}catch(r){return console.error(`Memory cap error: ${r instanceof Error?r.message:String(r)}`),0}}},O=new y;export{O as a};
8
+ import{d as c,e as p,h as l}from"./chunk-UUULLTQV.mjs";import{b as E,c as d}from"./chunk-FZS3XGEA.mjs";import{b as m}from"./chunk-ZZBNFNMG.mjs";import{e as i,g as R}from"./chunk-TKXOMN4K.mjs";import{a as g}from"./chunk-E66B27AL.mjs";l();R();var y=class{static{g(this,"MemoryService")}async log(t,r,n,o,s){try{let e=s?.projectId??await m.getProjectId(t);return e?{eventId:i.appendEvent(e,`memory.${r}`,{...n,author:o}),projectId:e}:null}catch(e){let a=e instanceof Error?e.message:String(e);if(s?.required)throw new Error(a);return console.error(`Memory log error: ${a}`),null}}async clear(t){try{let r=await m.getProjectId(t);if(!r)return;i.run(r,"DELETE FROM events WHERE type >= ? AND type < ?",...c)}catch(r){console.error(`Memory clear error: ${r instanceof Error?r.message:String(r)}`)}}async getRecentEvents(t,r=100){try{return i.query(t,"SELECT type, data, timestamp FROM events WHERE type >= ? AND type < ? ORDER BY id DESC LIMIT ?",...c,r).reverse().map(o=>{let s=JSON.parse(o.data);return{timestamp:o.timestamp,action:o.type.replace("memory.",""),...s}})}catch(n){return console.error(`Memory read error: ${n instanceof Error?n.message:String(n)}`),[]}}async capEntries(t){try{let n=i.get(t,"SELECT COUNT(*) as cnt FROM events WHERE type >= ? AND type < ? AND NOT (type >= ? AND type < ?)",...c,...p)?.cnt??0;if(n<=E.MEMORY_MAX_ENTRIES)return 0;let o=n-E.MEMORY_MAX_ENTRIES,s=i.query(t,"SELECT id, type, data, timestamp FROM events WHERE type >= ? AND type < ? AND NOT (type >= ? AND type < ?) ORDER BY id ASC LIMIT ?",...c,...p,o);return d.archiveMany(t,s.map((e,a)=>({entityType:"memory_entry",entityId:`memory-${e.timestamp||a}`,entityData:{type:e.type,data:JSON.parse(e.data),timestamp:e.timestamp},summary:e.type.replace("memory.",""),reason:"overflow"}))),i.transaction(t,e=>{let a=e.prepare("DELETE FROM events WHERE id = ?");for(let u of s)a.run(u.id)}),o}catch(r){return console.error(`Memory cap error: ${r instanceof Error?r.message:String(r)}`),0}}},O=new y;export{O as a};