prjct-cli 3.88.0 → 3.91.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 (220) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/bin/hook-chunks/agent-identity-45BYQBU2.mjs +8 -0
  3. package/dist/bin/hook-chunks/agent-switch-IQ5KSRKD.mjs +22 -0
  4. package/dist/bin/hook-chunks/analysis-LBYZSJKT.mjs +42 -0
  5. package/dist/bin/hook-chunks/auth-config-WNUARXTJ.mjs +8 -0
  6. package/dist/bin/hook-chunks/auto-flush-GW3FP763.mjs +8 -0
  7. package/dist/bin/hook-chunks/auto-updater-EHRRMCYY.mjs +9 -0
  8. package/dist/bin/hook-chunks/capture-gate-BQCNMHUC.mjs +8 -0
  9. package/dist/bin/hook-chunks/chunk-2NMSEZTQ.mjs +8 -0
  10. package/dist/bin/hook-chunks/chunk-2OU2MKNS.mjs +8 -0
  11. package/dist/bin/hook-chunks/chunk-2UC4DTDO.mjs +9 -0
  12. package/dist/bin/hook-chunks/chunk-3FBCOCPD.mjs +8 -0
  13. package/dist/bin/hook-chunks/chunk-3JUE6MNF.mjs +8 -0
  14. package/dist/bin/hook-chunks/chunk-3LG3ACQV.mjs +8 -0
  15. package/dist/bin/hook-chunks/chunk-3WKDMAS7.mjs +16 -0
  16. package/dist/bin/hook-chunks/chunk-45I2C2UB.mjs +25 -0
  17. package/dist/bin/hook-chunks/chunk-4DDCWMI6.mjs +8 -0
  18. package/dist/bin/hook-chunks/chunk-4KY2EHXS.mjs +9 -0
  19. package/dist/bin/hook-chunks/chunk-4WHS7CO7.mjs +8 -0
  20. package/dist/bin/hook-chunks/chunk-54LH63LM.mjs +7 -0
  21. package/dist/bin/hook-chunks/chunk-5TBQNW2G.mjs +17 -0
  22. package/dist/bin/hook-chunks/chunk-5WAONIPX.mjs +8 -0
  23. package/dist/bin/hook-chunks/chunk-6AFM6WRB.mjs +13 -0
  24. package/dist/bin/hook-chunks/chunk-6EWGHM32.mjs +9 -0
  25. package/dist/bin/hook-chunks/chunk-6IKHMK2U.mjs +10 -0
  26. package/dist/bin/hook-chunks/chunk-75UJIVMO.mjs +10 -0
  27. package/dist/bin/hook-chunks/chunk-7OZDWT6C.mjs +9 -0
  28. package/dist/bin/hook-chunks/chunk-7SI6X3Z7.mjs +8 -0
  29. package/dist/bin/hook-chunks/chunk-A5MUSARI.mjs +9 -0
  30. package/dist/bin/hook-chunks/chunk-A5RNWWTH.mjs +9 -0
  31. package/dist/bin/hook-chunks/chunk-AEYONUUY.mjs +31 -0
  32. package/dist/bin/hook-chunks/chunk-AKIN5WSQ.mjs +9 -0
  33. package/dist/bin/hook-chunks/chunk-AOPJ4Z6O.mjs +8 -0
  34. package/dist/bin/hook-chunks/chunk-AUUWQH3S.mjs +14 -0
  35. package/dist/bin/hook-chunks/chunk-AW25AWN5.mjs +31 -0
  36. package/dist/bin/hook-chunks/chunk-B7GMU46T.mjs +71 -0
  37. package/dist/bin/hook-chunks/chunk-BISPGBNN.mjs +35 -0
  38. package/dist/bin/hook-chunks/chunk-BUDZL4DW.mjs +8 -0
  39. package/dist/bin/hook-chunks/chunk-CE4RCNC7.mjs +8 -0
  40. package/dist/bin/hook-chunks/chunk-CQHPIYNM.mjs +8 -0
  41. package/dist/bin/hook-chunks/chunk-CREPUNOS.mjs +24 -0
  42. package/dist/bin/hook-chunks/chunk-CTWZQ7YI.mjs +8 -0
  43. package/dist/bin/hook-chunks/chunk-D4S3IRD3.mjs +8 -0
  44. package/dist/bin/hook-chunks/chunk-D6KT763C.mjs +9 -0
  45. package/dist/bin/hook-chunks/chunk-D7TRY3CO.mjs +8 -0
  46. package/dist/bin/hook-chunks/chunk-DGQYQSUK.mjs +19 -0
  47. package/dist/bin/hook-chunks/chunk-DMXFGLZE.mjs +21 -0
  48. package/dist/bin/hook-chunks/chunk-DXQMKW2B.mjs +10 -0
  49. package/dist/bin/hook-chunks/chunk-DYHYDHCW.mjs +8 -0
  50. package/dist/bin/hook-chunks/chunk-E66B27AL.mjs +8 -0
  51. package/dist/bin/hook-chunks/chunk-EHBEHLYN.mjs +15 -0
  52. package/dist/bin/hook-chunks/chunk-EM6ZDJAK.mjs +45 -0
  53. package/dist/bin/hook-chunks/chunk-FEH4IPIC.mjs +15 -0
  54. package/dist/bin/hook-chunks/chunk-FGQZ62ZP.mjs +47 -0
  55. package/dist/bin/hook-chunks/chunk-GAOQHD5S.mjs +8 -0
  56. package/dist/bin/hook-chunks/chunk-GCKILEXJ.mjs +8 -0
  57. package/dist/bin/hook-chunks/chunk-GVNMXVVA.mjs +8 -0
  58. package/dist/bin/hook-chunks/chunk-HBLR7BVG.mjs +11 -0
  59. package/dist/bin/hook-chunks/chunk-HDHVBB6Q.mjs +1260 -0
  60. package/dist/bin/hook-chunks/chunk-HDSS6UB3.mjs +8 -0
  61. package/dist/bin/hook-chunks/chunk-HJ4HEI45.mjs +8 -0
  62. package/dist/bin/hook-chunks/chunk-HZIORCPO.mjs +16 -0
  63. package/dist/bin/hook-chunks/chunk-IKUGYUAI.mjs +8 -0
  64. package/dist/bin/hook-chunks/chunk-J6JZ4PQA.mjs +18 -0
  65. package/dist/bin/hook-chunks/chunk-JQE2F2RK.mjs +8 -0
  66. package/dist/bin/hook-chunks/chunk-KEJ5RMAI.mjs +9 -0
  67. package/dist/bin/hook-chunks/chunk-L4COZ7ZH.mjs +13 -0
  68. package/dist/bin/hook-chunks/chunk-LGJUQEAU.mjs +8 -0
  69. package/dist/bin/hook-chunks/chunk-LJLUP4FF.mjs +8 -0
  70. package/dist/bin/hook-chunks/chunk-LLQUB6YR.mjs +11 -0
  71. package/dist/bin/hook-chunks/chunk-LPB3HUJ2.mjs +19 -0
  72. package/dist/bin/hook-chunks/chunk-LT5WSSQO.mjs +8 -0
  73. package/dist/bin/hook-chunks/chunk-LWCHQIJ7.mjs +11 -0
  74. package/dist/bin/hook-chunks/chunk-M3ZOJVPA.mjs +13 -0
  75. package/dist/bin/hook-chunks/chunk-MEQS4VPO.mjs +8 -0
  76. package/dist/bin/hook-chunks/chunk-MXHX44WF.mjs +9 -0
  77. package/dist/bin/hook-chunks/chunk-N5WOHG36.mjs +8 -0
  78. package/dist/bin/hook-chunks/chunk-NJAMZSHM.mjs +26 -0
  79. package/dist/bin/hook-chunks/chunk-NLG2EW6M.mjs +8 -0
  80. package/dist/bin/hook-chunks/chunk-NWY5M34K.mjs +12 -0
  81. package/dist/bin/hook-chunks/chunk-ODWWIFSN.mjs +9 -0
  82. package/dist/bin/hook-chunks/chunk-OIEZAHLC.mjs +16 -0
  83. package/dist/bin/hook-chunks/chunk-PKDYFXMI.mjs +8 -0
  84. package/dist/bin/hook-chunks/chunk-PSP56GGF.mjs +13 -0
  85. package/dist/bin/hook-chunks/chunk-PSSR7LSW.mjs +8 -0
  86. package/dist/bin/hook-chunks/chunk-PW3KYKVS.mjs +9 -0
  87. package/dist/bin/hook-chunks/chunk-PXJKXBTM.mjs +53 -0
  88. package/dist/bin/hook-chunks/chunk-Q5I2UPD6.mjs +9 -0
  89. package/dist/bin/hook-chunks/chunk-QDQ7DTDV.mjs +8 -0
  90. package/dist/bin/hook-chunks/chunk-QSAA6LZF.mjs +8 -0
  91. package/dist/bin/hook-chunks/chunk-QZSJSXJV.mjs +10 -0
  92. package/dist/bin/hook-chunks/chunk-RAHFKGM6.mjs +19 -0
  93. package/dist/bin/hook-chunks/chunk-RJ2BRRMH.mjs +38 -0
  94. package/dist/bin/hook-chunks/chunk-RRWPDRYR.mjs +43 -0
  95. package/dist/bin/hook-chunks/chunk-SJ75V4WG.mjs +9 -0
  96. package/dist/bin/hook-chunks/chunk-SOPRYWUY.mjs +11 -0
  97. package/dist/bin/hook-chunks/chunk-SVZHJZ5T.mjs +9 -0
  98. package/dist/bin/hook-chunks/chunk-SYHDEUVU.mjs +10 -0
  99. package/dist/bin/hook-chunks/chunk-TFGJVT6F.mjs +8 -0
  100. package/dist/bin/hook-chunks/chunk-TPESWBA7.mjs +8 -0
  101. package/dist/bin/hook-chunks/chunk-TRMBRDKH.mjs +8 -0
  102. package/dist/bin/hook-chunks/chunk-TXJT3G53.mjs +10 -0
  103. package/dist/bin/hook-chunks/chunk-UHW35BPE.mjs +18 -0
  104. package/dist/bin/hook-chunks/chunk-UQVJQME2.mjs +8 -0
  105. package/dist/bin/hook-chunks/chunk-UUULLTQV.mjs +8 -0
  106. package/dist/bin/hook-chunks/chunk-V37VTXDW.mjs +10 -0
  107. package/dist/bin/hook-chunks/chunk-W5OWBOLH.mjs +8 -0
  108. package/dist/bin/hook-chunks/chunk-WDGDFXSB.mjs +10 -0
  109. package/dist/bin/hook-chunks/chunk-WUHGODSQ.mjs +8 -0
  110. package/dist/bin/hook-chunks/chunk-X5RDLFPM.mjs +8 -0
  111. package/dist/bin/hook-chunks/chunk-XEFIIDHM.mjs +11 -0
  112. package/dist/bin/hook-chunks/chunk-Y5NQV46G.mjs +9 -0
  113. package/dist/bin/hook-chunks/chunk-YG7KBQYJ.mjs +16 -0
  114. package/dist/bin/hook-chunks/chunk-YJMWY4Y6.mjs +8 -0
  115. package/dist/bin/hook-chunks/chunk-YKMJI6TF.mjs +14 -0
  116. package/dist/bin/hook-chunks/chunk-YUOTOCKK.mjs +103 -0
  117. package/dist/bin/hook-chunks/chunk-ZTZTVBAZ.mjs +12 -0
  118. package/dist/bin/hook-chunks/chunk-ZX2KFQV5.mjs +11 -0
  119. package/dist/bin/hook-chunks/chunk-ZZ65CN5F.mjs +20 -0
  120. package/dist/bin/hook-chunks/client-SKFMAUI5.mjs +10 -0
  121. package/dist/bin/hook-chunks/code-graph-cloud-65GCWNII.mjs +8 -0
  122. package/dist/bin/hook-chunks/codex-skill-7IURPY6B.mjs +8 -0
  123. package/dist/bin/hook-chunks/command-installer-BVHQUSL4.mjs +8 -0
  124. package/dist/bin/hook-chunks/config-manager-KYC7WUOS.mjs +8 -0
  125. package/dist/bin/hook-chunks/content-bound-stamp-72EQVZLP.mjs +10 -0
  126. package/dist/bin/hook-chunks/context-pressure-OUN5PFMN.mjs +8 -0
  127. package/dist/bin/hook-chunks/context7-service-4C6VNJUS.mjs +8 -0
  128. package/dist/bin/hook-chunks/custom-workflow-storage-M77INP6Z.mjs +8 -0
  129. package/dist/bin/hook-chunks/cwd-changed-56X7BNS6.mjs +8 -0
  130. package/dist/bin/hook-chunks/cycle-budget-card-O5WAGNGC.mjs +9 -0
  131. package/dist/bin/hook-chunks/database-SLDTQXWG.mjs +8 -0
  132. package/dist/bin/hook-chunks/delivery-geometry-VHCURJ7E.mjs +8 -0
  133. package/dist/bin/hook-chunks/detect-changes-6N4DCWXQ.mjs +17 -0
  134. package/dist/bin/hook-chunks/detection-MEYHME4X.mjs +8 -0
  135. package/dist/bin/hook-chunks/developer-evolution-R5BXQH6G.mjs +12 -0
  136. package/dist/bin/hook-chunks/discuss-lock-55GER2LR.mjs +8 -0
  137. package/dist/bin/hook-chunks/distill-6C6YIFOE.mjs +8 -0
  138. package/dist/bin/hook-chunks/drift-refresh-TD3PYPJN.mjs +8 -0
  139. package/dist/bin/hook-chunks/editors-config-3N6VREZR.mjs +8 -0
  140. package/dist/bin/hook-chunks/enriched-recall-6ZZNKAJZ.mjs +8 -0
  141. package/dist/bin/hook-chunks/exec-I7XE7NMD.mjs +8 -0
  142. package/dist/bin/hook-chunks/format-YOYMJSLY.mjs +8 -0
  143. package/dist/bin/hook-chunks/git-helpers-6JLP2OJZ.mjs +8 -0
  144. package/dist/bin/hook-chunks/infer-memory-file-PIAZ542H.mjs +8 -0
  145. package/dist/bin/hook-chunks/judgment-ledger-storage-UKROWRVA.mjs +8 -0
  146. package/dist/bin/hook-chunks/judgment-orchestrator-UFGNBTEK.mjs +8 -0
  147. package/dist/bin/hook-chunks/judgment-receipt-2U7D6HS4.mjs +8 -0
  148. package/dist/bin/hook-chunks/land-cue-SS23JBAX.mjs +9 -0
  149. package/dist/bin/hook-chunks/land-synthesis-OATL5BNP.mjs +8 -0
  150. package/dist/bin/hook-chunks/legacy-crew-sweep-NH5EWEXF.mjs +24 -0
  151. package/dist/bin/hook-chunks/memory-index-677MUBCZ.mjs +10 -0
  152. package/dist/bin/hook-chunks/notification-S2IJJ6JW.mjs +8 -0
  153. package/dist/bin/hook-chunks/nyquist-lite-GE7OAFLC.mjs +10 -0
  154. package/dist/bin/hook-chunks/pack-integrity-L3BL7CGO.mjs +10 -0
  155. package/dist/bin/hook-chunks/pack-manager-SU53HCKK.mjs +8 -0
  156. package/dist/bin/hook-chunks/package-legitimacy-HXC4L73B.mjs +8 -0
  157. package/dist/bin/hook-chunks/path-manager-F2HE2GGK.mjs +8 -0
  158. package/dist/bin/hook-chunks/planning-ZYFCFU7N.mjs +9 -0
  159. package/dist/bin/hook-chunks/post-edit-JD7YFEBZ.mjs +8 -0
  160. package/dist/bin/hook-chunks/pr-convention-7UGI7TFA.mjs +8 -0
  161. package/dist/bin/hook-chunks/pre-bash-VIABNO5E.mjs +11 -0
  162. package/dist/bin/hook-chunks/pre-commit-NVQVXHZQ.mjs +8 -0
  163. package/dist/bin/hook-chunks/pre-edit-V4RD45C4.mjs +11 -0
  164. package/dist/bin/hook-chunks/pre-package-KFJZXI5T.mjs +8 -0
  165. package/dist/bin/hook-chunks/pre-search-7KRU5D2O.mjs +9 -0
  166. package/dist/bin/hook-chunks/pre-secrets-IE5NX5X5.mjs +8 -0
  167. package/dist/bin/hook-chunks/precision-classifier-IVVAXE26.mjs +8 -0
  168. package/dist/bin/hook-chunks/precision-judgment-WPTCNTGV.mjs +8 -0
  169. package/dist/bin/hook-chunks/prjct-md-FMCPUMQT.mjs +8 -0
  170. package/dist/bin/hook-chunks/project-agent-surfaces-TD7BHI25.mjs +8 -0
  171. package/dist/bin/hook-chunks/project-file-inventory-ZAPKPKY6.mjs +8 -0
  172. package/dist/bin/hook-chunks/project-memory-ZVZSLPB5.mjs +8 -0
  173. package/dist/bin/hook-chunks/project-style-evolution-7JS75AUP.mjs +8 -0
  174. package/dist/bin/hook-chunks/prompt-S4MMIXH5.mjs +22 -0
  175. package/dist/bin/hook-chunks/publish-helper-I37V4L7U.mjs +8 -0
  176. package/dist/bin/hook-chunks/purge-BDREPWEE.mjs +8 -0
  177. package/dist/bin/hook-chunks/retention-D2MVQLOF.mjs +8 -0
  178. package/dist/bin/hook-chunks/sdd-ZO4DP23G.mjs +10 -0
  179. package/dist/bin/hook-chunks/session-continuity-FNNUMOXB.mjs +11 -0
  180. package/dist/bin/hook-chunks/session-start-HA7IRBFX.mjs +8 -0
  181. package/dist/bin/hook-chunks/settings-installer-QDM3GB6J.mjs +9 -0
  182. package/dist/bin/hook-chunks/setup-7L3NXNRH.mjs +142 -0
  183. package/dist/bin/hook-chunks/shipping-GX4HFYJ3.mjs +13 -0
  184. package/dist/bin/hook-chunks/skill-index-OOVAXHYJ.mjs +12 -0
  185. package/dist/bin/hook-chunks/spec-context-inference-KER2R3F3.mjs +15 -0
  186. package/dist/bin/hook-chunks/spec-service-G3RLCJ2G.mjs +11 -0
  187. package/dist/bin/hook-chunks/spec-task-breakdown-YPJ76OWR.mjs +8 -0
  188. package/dist/bin/hook-chunks/state-storage-KNGP2CQV.mjs +8 -0
  189. package/dist/bin/hook-chunks/stop-HPZCLDPM.mjs +17 -0
  190. package/dist/bin/hook-chunks/subagent-start-7KZUTKV5.mjs +8 -0
  191. package/dist/bin/hook-chunks/subagent-stop-7C72RWGO.mjs +8 -0
  192. package/dist/bin/hook-chunks/surface-attribution-PDYR6DVA.mjs +8 -0
  193. package/dist/bin/hook-chunks/symbol-graph-LZM4RZXZ.mjs +8 -0
  194. package/dist/bin/hook-chunks/sync-analyzer-FKC57RTV.mjs +8 -0
  195. package/dist/bin/hook-chunks/sync-client-DJWOG2ZQ.mjs +8 -0
  196. package/dist/bin/hook-chunks/sync-cursor-storage-2VKG757H.mjs +19 -0
  197. package/dist/bin/hook-chunks/task-orchestration-MLOCR7GA.mjs +8 -0
  198. package/dist/bin/hook-chunks/task-overview-6ZQKJGSH.mjs +8 -0
  199. package/dist/bin/hook-chunks/task-service-RRFG5P7N.mjs +8 -0
  200. package/dist/bin/hook-chunks/tdd-XQUU4C23.mjs +10 -0
  201. package/dist/bin/hook-chunks/template-loader-4QMIMOBY.mjs +8 -0
  202. package/dist/bin/hook-chunks/transcript-jsonl-6X4DDD6R.mjs +8 -0
  203. package/dist/bin/hook-chunks/trust-boundary-ERMDF2C5.mjs +8 -0
  204. package/dist/bin/hook-chunks/usefulness-253CZLNY.mjs +8 -0
  205. package/dist/bin/hook-chunks/vault-retire-notice-GRT3QRLZ.mjs +9 -0
  206. package/dist/bin/hook-chunks/velocity-storage-UPW6TLK6.mjs +8 -0
  207. package/dist/bin/hook-chunks/weak-model-mode-M6D23IIM.mjs +8 -0
  208. package/dist/bin/hook-chunks/work-graph-QJGNBVIP.mjs +49 -0
  209. package/dist/bin/hook-chunks/work-scope-6FG6PSAV.mjs +8 -0
  210. package/dist/bin/hook-chunks/workspace-occupancy-UVIRHY5Z.mjs +8 -0
  211. package/dist/bin/hook-chunks/worktree-service-XGRN5TTE.mjs +12 -0
  212. package/dist/bin/hook-fast-darwin-arm64 +0 -0
  213. package/dist/bin/hook-fast-darwin-x64 +0 -0
  214. package/dist/bin/hook-fast-linux-x64 +0 -0
  215. package/dist/bin/prjct-core.mjs +625 -624
  216. package/dist/bin/prjct-hooks.mjs +3 -2282
  217. package/dist/bin/prjct.mjs +17 -2
  218. package/dist/daemon/entry.mjs +545 -544
  219. package/dist/mcp/server.mjs +196 -195
  220. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [3.91.0] - 2026-08-15
6
+
7
+ ### Added
8
+ - fix hook-fast-native smoke test: wrap expected exit-89 capture in set +e under GHA bash -e -o pipefail
9
+
10
+ ## [3.90.0] - 2026-08-15
11
+
12
+ ### Added
13
+ - ship hook-fast native binaries for every platform: CI matrix compiles darwin arm64/x64 + linux x64 on real runners, release downloads and hard-verifies all targets before publish
14
+
15
+ ## [3.89.0] - 2026-08-15
16
+
17
+ ### Added
18
+ - cut hook latency 55-68%: native hook-fast binary with staged fallback, per-project daemon request lanes, SQLite read dedup, real stdin deadlines on hook paths
19
+
5
20
  ## [3.88.0] - 2026-08-14
6
21
 
7
22
  ### Added
@@ -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{a,b,c,d,e}from"./chunk-TRMBRDKH.mjs";import"./chunk-TPESWBA7.mjs";import"./chunk-E66B27AL.mjs";export{a as KNOWN_AGENTS,b as detectRuntimeAgent,d as normalizeAgentName,c as resolveCallerIdentity,e as sameOwner};
@@ -0,0 +1,22 @@
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 E,b as I}from"./chunk-X5RDLFPM.mjs";import{a as P}from"./chunk-YG7KBQYJ.mjs";import{a as O}from"./chunk-5WAONIPX.mjs";import{a as C}from"./chunk-5TBQNW2G.mjs";import{b as N,c as H,d as L}from"./chunk-TRMBRDKH.mjs";import{h as _}from"./chunk-B7GMU46T.mjs";import"./chunk-LJLUP4FF.mjs";import"./chunk-Q5I2UPD6.mjs";import"./chunk-PSSR7LSW.mjs";import"./chunk-6AFM6WRB.mjs";import{c as D,d as A}from"./chunk-CREPUNOS.mjs";import"./chunk-D7TRY3CO.mjs";import"./chunk-TPESWBA7.mjs";import"./chunk-ODWWIFSN.mjs";import"./chunk-YKMJI6TF.mjs";import"./chunk-LLQUB6YR.mjs";import"./chunk-NLG2EW6M.mjs";import"./chunk-6IKHMK2U.mjs";import"./chunk-QSAA6LZF.mjs";import"./chunk-75UJIVMO.mjs";import"./chunk-QDQ7DTDV.mjs";import"./chunk-2OU2MKNS.mjs";import"./chunk-YJMWY4Y6.mjs";import"./chunk-NJAMZSHM.mjs";import"./chunk-6EWGHM32.mjs";import"./chunk-SJ75V4WG.mjs";import"./chunk-4DDCWMI6.mjs";import"./chunk-A5MUSARI.mjs";import"./chunk-M3ZOJVPA.mjs";import"./chunk-Y5NQV46G.mjs";import"./chunk-DXQMKW2B.mjs";import"./chunk-RRWPDRYR.mjs";import"./chunk-GAOQHD5S.mjs";import"./chunk-UQVJQME2.mjs";import"./chunk-UUULLTQV.mjs";import"./chunk-3FBCOCPD.mjs";import{b as y}from"./chunk-BISPGBNN.mjs";import"./chunk-LT5WSSQO.mjs";import"./chunk-HJ4HEI45.mjs";import{a as x}from"./chunk-3LG3ACQV.mjs";import"./chunk-AOPJ4Z6O.mjs";import"./chunk-AUUWQH3S.mjs";import"./chunk-GVNMXVVA.mjs";import{b as h}from"./chunk-W5OWBOLH.mjs";import"./chunk-MEQS4VPO.mjs";import{d as f,g as v}from"./chunk-HDHVBB6Q.mjs";import"./chunk-CE4RCNC7.mjs";import{b as m,e as V,i as S,k as Y,l as R,r as q}from"./chunk-AKIN5WSQ.mjs";import"./chunk-HDSS6UB3.mjs";import"./chunk-JQE2F2RK.mjs";import"./chunk-WUHGODSQ.mjs";import"./chunk-SVZHJZ5T.mjs";import"./chunk-CTWZQ7YI.mjs";import"./chunk-GCKILEXJ.mjs";import"./chunk-D4S3IRD3.mjs";import"./chunk-PKDYFXMI.mjs";import"./chunk-BUDZL4DW.mjs";import{a}from"./chunk-E66B27AL.mjs";q();import{spawn as X}from"node:child_process";v();V();v();function G(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}a(G,"parseEvidence");function $(t){return{id:t.id,projectId:t.project_id,taskId:t.task_id,taskDescription:t.task_description,fromAgent:t.from_agent,fromIdentity:t.from_identity,toAgent:t.to_agent,reason:t.reason,evidence:G(t.evidence),status:t.status,workspaceId:t.workspace_id,worktreePath:t.worktree_path,branch:t.branch,createdAt:t.created_at,acceptedAt:t.accepted_at,acceptedBy:t.accepted_by,expiresAt:t.expires_at}}a($,"toHandoff");function M(t){let e=new Date;return e.setTime(e.getTime()+Math.max(1,t)*36e5),e.toISOString()}a(M,"expiresAtIso");function W(t){let e=`hand_${x()}`,o=m(),n=t.ttlHours??24,r=t.evidence?JSON.stringify(t.evidence):null;return f.run(t.projectId,`INSERT INTO task_handoffs (
9
+ id, project_id, task_id, task_description, from_agent, from_identity,
10
+ to_agent, reason, evidence, status, workspace_id, worktree_path, branch,
11
+ created_at, accepted_at, accepted_by, expires_at
12
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending', ?, ?, ?, ?, NULL, NULL, ?)`,e,t.projectId,t.taskId,t.taskDescription,t.fromAgent,t.fromIdentity??null,t.toAgent,t.reason,r,t.workspaceId??null,t.worktreePath??null,t.branch??null,o,M(n)),{id:e,projectId:t.projectId,taskId:t.taskId,taskDescription:t.taskDescription,fromAgent:t.fromAgent,fromIdentity:t.fromIdentity??null,toAgent:t.toAgent,reason:t.reason,evidence:t.evidence??null,status:"pending",workspaceId:t.workspaceId??null,worktreePath:t.worktreePath??null,branch:t.branch??null,createdAt:o,acceptedAt:null,acceptedBy:null,expiresAt:M(n)}}a(W,"createHandoff");function U(t,e){let o=f.get(t,"SELECT * FROM task_handoffs WHERE id = ? OR id LIKE ?",e,`${e}%`);return o?$(o):null}a(U,"getHandoff");var j=new Map,Q=60*1e3;function B(t){let e=Date.now(),o=j.get(t)??0;if(e-o<Q)return 0;j.set(t,e);try{f.run(t,`UPDATE task_handoffs SET status = 'expired'
13
+ WHERE status = 'pending' AND expires_at IS NOT NULL AND expires_at < ?`,m())}catch{return 0}return 0}a(B,"expireStaleHandoffs");function w(t,e={}){B(t);let o=e.limit??20,n=[],r=[];e.status&&(n.push("status = ?"),r.push(e.status),e.status==="pending"&&(n.push("(expires_at IS NULL OR expires_at >= ?)"),r.push(m()))),e.toAgent&&(n.push("to_agent = ?"),r.push(e.toAgent));let s=n.length>0?`WHERE ${n.join(" AND ")}`:"";return f.query(t,`SELECT * FROM task_handoffs ${s} ORDER BY created_at DESC LIMIT ?`,...r,o).map($)}a(w,"listHandoffs");function T(t,e){return w(t,{status:"pending",toAgent:e,limit:10})}a(T,"listPendingForAgent");function F(t,e,o){B(t);let n=m();f.run(t,`UPDATE task_handoffs
14
+ SET status = 'accepted', accepted_at = ?, accepted_by = ?
15
+ WHERE (id = ? OR id LIKE ?) AND status = 'pending'
16
+ AND (expires_at IS NULL OR expires_at >= ?)`,n,o,e,`${e}%`,n);let r=f.get(t,"SELECT * FROM task_handoffs WHERE (id = ? OR id LIKE ?) AND status = ? AND accepted_by = ?",e,`${e}%`,"accepted",o);return r?$(r):null}a(F,"acceptHandoff");Y();async function Z(t,e,o,n){let r=await h.readConfig(e).catch(()=>null),s=await _(t,e).catch(()=>null),l=s?.turnCount??0,c=O(r,s),d=C(r,s),i=(()=>{try{return n?f.query(t,`SELECT DISTINCT json_extract(data, '$.file') AS file
17
+ FROM events
18
+ WHERE type = 'memory.post_edit' AND timestamp >= ?
19
+ LIMIT 20`,n).map(g=>g.file).filter(Boolean):[]}catch{return[]}})(),u=(()=>{try{return f.query(t,"SELECT content FROM task_log WHERE task_id = ? ORDER BY id DESC LIMIT 5",o).map(g=>g.content).filter(Boolean)}catch{return[]}})();return{turns:l,files:i,pressure:d.level!=="ok"?d.level:void 0,loopStopped:c.stopped||void 0,journal:u.length>0?u:void 0}}a(Z,"buildEvidence");function tt(t,e,o){let n=t?.trim();if(n)return n.slice(0,500);let r=[`Yielded cycle "${o.slice(0,80)}"`];return e.turns&&e.turns>0&&r.push(`after ${e.turns} turns`),e.loopStopped&&r.push("loop-guard stopped"),e.pressure&&r.push(`context pressure ${e.pressure}`),e.files&&e.files.length>0&&r.push(`files: ${e.files.slice(0,5).join(", ")}`),r.push("\u2014 continue from current branch state; do not restart from zero"),r.join(" ").slice(0,500)}a(tt,"composeReason");function et(t){let e=[t.fromAgent,t.fromIdentity].filter(Boolean).join("/");return[`# prjct handoff \u2192 ${t.toAgent}`,"",`Task: \`${t.taskId}\` \u2014 ${t.taskDescription}`,`From: ${e} \xB7 handoff \`${t.id}\``,`Reason: ${t.reason}`,t.branch?`Branch: \`${t.branch}\``:null,t.worktreePath?`Path: \`${t.worktreePath}\``:null,"","## Accept (target agent)","","```bash",`cd ${t.worktreePath??"."}`,`prjct accept ${t.id} --md`,"```","","Then continue the cycle \u2014 do not start a new `prjct work` for the same intent."].filter(o=>o!==null).join(`
20
+ `)}a(et,"formatResumeCard");function nt(t,e){let o=[t.fromAgent,t.fromIdentity].filter(Boolean).join("/"),n=t.evidence,r=[`# Handoff accepted \u2014 ${t.taskDescription}`,"",`- Task id: \`${t.taskId}\``,`- Handoff: \`${t.id}\``,`- Started by: ${o}`,`- Accepted by: ${e.agent}/${e.identity}`,`- Why yielded: ${t.reason}`];return n?.turns&&r.push(`- Turns spent: ${n.turns}`),n?.pressure&&r.push(`- Context pressure: ${n.pressure}`),n?.files&&n.files.length>0&&r.push(`- Hot files: ${n.files.slice(0,8).map(s=>`\`${s}\``).join(", ")}`),n?.journal&&n.journal.length>0&&r.push("","## Prior journal",...n.journal.map(s=>`- ${s.slice(0,120)}`)),r.push("","## Next","","1. `prjct work --md` \u2014 same cycle is still active (now yours)","2. Read hot files + `prjct guard <file>` before editing","3. Continue implementation \u2014 do **not** restart from zero"),r.join(`
21
+ `)}a(nt,"formatAcceptBrief");async function K(t,e,o){let n=await A(e);if(n.gitError)throw new Error(`git ${n.gitError}: workspace identity unknown \u2014 refusing to update task fields on the main fallback.`);let r=o;n.isMain?await y.updateCurrentTask(t,r):await y.updateWorkspaceTask(t,n.workspaceId,r)}a(K,"rebindTaskOwner");async function It(t,e,o,n={}){let r=L(o);if(!r)return{ok:!1,error:'Usage: prjct switch <agent> [--reason "\u2026"] [--launch]'};let s=await _(t,e);if(!s)return{ok:!1,error:'No active work cycle in this workspace. Start one with `prjct work "<intent>"` first.'};let l=H(s.description),c=s.ownerAgent||l.agent,d=s.ownerIdentity||l.identity,i=await A(e);if(i.gitError)return{ok:!1,error:`git ${i.gitError}: workspace identity unknown \u2014 refusing to switch agents on the main fallback. Re-run when git is healthy.`};let u=await h.readConfig(e).catch(()=>null),k=await Z(t,e,s.id,s.startedAt),g=tt(n.reason,k,s.description),z=u?.multiAgent?.handoffTtlHours??24,p=W({projectId:t,taskId:s.id,taskDescription:s.description,fromAgent:c,fromIdentity:d,toAgent:r,reason:g,evidence:k,workspaceId:i.isMain?D:i.workspaceId,worktreePath:i.worktreePath,branch:i.branch??s.branch,ttlHours:z});await K(t,e,{yieldStatus:"yielded",pendingHandoffId:p.id});try{await P({projectId:t,projectPath:e,cycleDescription:s.description,cycleId:s.id,author:d})}catch{}try{f.appendEvent(t,"task.handoff.yielded",{handoffId:p.id,taskId:s.id,fromAgent:c,toAgent:r,reason:g})}catch{}E(u)==="on"&&await I(`prjct \u2192 ${r}`,`Handoff: ${s.description.slice(0,80)} \u2014 prjct accept ${p.id.slice(0,16)}`);let J=et(p),b=n.launch===!0||u?.multiAgent?.switchLaunch===!0?await rt(r,p,i.worktreePath):{ok:!1,error:void 0};return{ok:!0,handoff:p,resumeCard:J,launched:b.ok,launchError:b.error}}a(It,"switchAgent");async function $t(t,e,o){let n=H(e),r=o?.trim()?[]:T(t,n.agent),s=r.length>0?r:w(t,{status:"pending",limit:5}),l=o?.trim()||s[0]?.id||"";if(!l)return{ok:!1,error:"No pending handoff for this agent. List with `prjct handoffs`."};let c=U(t,l);if(!c)return{ok:!1,error:`Handoff not found: ${l}`};if(c.status!=="pending")return{ok:!1,error:`Handoff ${c.id.slice(0,16)} is already ${c.status}`};let d=`${n.agent}/${n.identity}`,i=F(t,c.id,d);if(!i)return{ok:!1,error:`Claim lost \u2014 ${c.id.slice(0,16)} was taken or expired`};await K(t,e,{ownerAgent:n.agent,ownerIdentity:n.identity,ownerSessionId:n.sessionId,yieldStatus:"active",pendingHandoffId:null});try{f.appendEvent(t,"task.handoff.accepted",{handoffId:i.id,taskId:i.taskId,acceptedBy:d,fromAgent:i.fromAgent})}catch{}return E(await h.readConfig(e).catch(()=>null))==="on"&&await I("prjct handoff accepted",`${d} took over: ${i.taskDescription.slice(0,80)}`),{ok:!0,handoff:i,brief:nt(i,n)}}a($t,"acceptAgentHandoff");function Tt(t,e){let o=e??N(),n=T(t,o),r=n.length>0?n:o==="unknown"?w(t,{status:"pending",limit:2}):[];return r.length===0?null:r.map(s=>`\u2194 Handoff pending for ${s.toAgent}: \`${s.taskId.slice(0,8)}\` \u2014 "${s.reason.slice(0,80)}" \xB7 accept: \`prjct accept ${s.id}\``).join(`
22
+ `)}a(Tt,"formatPendingHandoffCue");async function rt(t,e,o){let s=R[t]?.cliCommand;if(!s)return{ok:!1,error:`No CLI for ${t} \u2014 paste the resume card into that terminal instead.`};if(!await S(s))return{ok:!1,error:`${s} not on PATH`};let c=[`You are accepting a prjct handoff from ${e.fromAgent}.`,`Run: prjct accept ${e.id} --md`,`Then continue task ${e.taskId}: ${e.taskDescription}.`,`Reason yielded: ${e.reason}`,"Do not restart from zero. Work from the current branch state."].join(" ");try{return X(s,[c],{cwd:o,detached:!0,stdio:"ignore",env:{...process.env,PRJCT_AGENT_RUNTIME:t}}).unref(),{ok:!0}}catch(d){return{ok:!1,error:d instanceof Error?d.message:"spawn failed"}}}a(rt,"launchTargetAgent");export{$t as acceptAgentHandoff,Tt as formatPendingHandoffCue,rt as launchTargetAgent,It as switchAgent};
@@ -0,0 +1,42 @@
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 G,b as ye,c as b,d as U,e as q,f as H,g as we,h as ke,i as w}from"./chunk-RJ2BRRMH.mjs";import"./chunk-FGQZ62ZP.mjs";import"./chunk-TXJT3G53.mjs";import"./chunk-A5RNWWTH.mjs";import"./chunk-HZIORCPO.mjs";import"./chunk-WDGDFXSB.mjs";import"./chunk-NWY5M34K.mjs";import"./chunk-B7GMU46T.mjs";import"./chunk-LJLUP4FF.mjs";import"./chunk-Q5I2UPD6.mjs";import{a as y,b as L,c as N,d as ve,e as E,f as R,g as z}from"./chunk-3WKDMAS7.mjs";import{b as me,c as A,d as $e}from"./chunk-PXJKXBTM.mjs";import"./chunk-PSSR7LSW.mjs";import{a as g}from"./chunk-6AFM6WRB.mjs";import"./chunk-CREPUNOS.mjs";import"./chunk-D7TRY3CO.mjs";import"./chunk-TPESWBA7.mjs";import"./chunk-ODWWIFSN.mjs";import"./chunk-YKMJI6TF.mjs";import"./chunk-LLQUB6YR.mjs";import"./chunk-NLG2EW6M.mjs";import"./chunk-6IKHMK2U.mjs";import"./chunk-QSAA6LZF.mjs";import"./chunk-75UJIVMO.mjs";import"./chunk-XEFIIDHM.mjs";import"./chunk-QDQ7DTDV.mjs";import"./chunk-ZTZTVBAZ.mjs";import{a as Se}from"./chunk-DYHYDHCW.mjs";import"./chunk-2OU2MKNS.mjs";import{a as D,b as he,c as K}from"./chunk-7OZDWT6C.mjs";import"./chunk-YJMWY4Y6.mjs";import"./chunk-NJAMZSHM.mjs";import"./chunk-FEH4IPIC.mjs";import"./chunk-EHBEHLYN.mjs";import"./chunk-KEJ5RMAI.mjs";import"./chunk-6EWGHM32.mjs";import"./chunk-J6JZ4PQA.mjs";import"./chunk-LGJUQEAU.mjs";import"./chunk-54LH63LM.mjs";import"./chunk-SJ75V4WG.mjs";import{e as de}from"./chunk-4DDCWMI6.mjs";import{d as pe}from"./chunk-A5MUSARI.mjs";import"./chunk-M3ZOJVPA.mjs";import"./chunk-Y5NQV46G.mjs";import"./chunk-DXQMKW2B.mjs";import{a as fe}from"./chunk-RRWPDRYR.mjs";import"./chunk-GAOQHD5S.mjs";import{a as ge}from"./chunk-UQVJQME2.mjs";import"./chunk-UUULLTQV.mjs";import"./chunk-3FBCOCPD.mjs";import{b as ue}from"./chunk-BISPGBNN.mjs";import"./chunk-LT5WSSQO.mjs";import"./chunk-HJ4HEI45.mjs";import"./chunk-3LG3ACQV.mjs";import"./chunk-AOPJ4Z6O.mjs";import"./chunk-AUUWQH3S.mjs";import"./chunk-GVNMXVVA.mjs";import"./chunk-W5OWBOLH.mjs";import"./chunk-MEQS4VPO.mjs";import{d as _,g as ce}from"./chunk-HDHVBB6Q.mjs";import"./chunk-CE4RCNC7.mjs";import{d as le}from"./chunk-HBLR7BVG.mjs";import{b as I,d as oe,e as X,s as ie,t as Qe}from"./chunk-AKIN5WSQ.mjs";import"./chunk-HDSS6UB3.mjs";import"./chunk-JQE2F2RK.mjs";import"./chunk-WUHGODSQ.mjs";import{j as ae,n as Be}from"./chunk-SVZHJZ5T.mjs";import{a as M,b as ne,o as re}from"./chunk-CTWZQ7YI.mjs";import"./chunk-OIEZAHLC.mjs";import"./chunk-SYHDEUVU.mjs";import"./chunk-GCKILEXJ.mjs";import"./chunk-D4S3IRD3.mjs";import"./chunk-PKDYFXMI.mjs";import{a as k,e as $,f as J}from"./chunk-BUDZL4DW.mjs";import{a as m}from"./chunk-E66B27AL.mjs";J();re();Be();import j from"node:fs/promises";import C from"node:path";var Y=class{static{m(this,"CodebaseAnalyzer")}projectPath=null;init(e=process.cwd()){this.projectPath=e}async readPackageJson(){try{let e=C.join(this.projectPath,"package.json"),t=await j.readFile(e,"utf-8");return JSON.parse(t)}catch(e){if(k(e)||e instanceof SyntaxError)return null;throw e}}async readCargoToml(){try{let e=C.join(this.projectPath,"Cargo.toml");return await j.readFile(e,"utf-8")}catch(e){if(k(e))return null;throw e}}async readRequirements(){try{let e=C.join(this.projectPath,"requirements.txt");return await j.readFile(e,"utf-8")}catch(e){if(k(e))return null;throw e}}async readGoMod(){try{let e=C.join(this.projectPath,"go.mod");return await j.readFile(e,"utf-8")}catch(e){if(k(e))return null;throw e}}async readGemfile(){try{let e=C.join(this.projectPath,"Gemfile");return await j.readFile(e,"utf-8")}catch(e){if(k(e))return null;throw e}}async readMixExs(){try{let e=C.join(this.projectPath,"mix.exs");return await j.readFile(e,"utf-8")}catch(e){if(k(e))return null;throw e}}async readPomXml(){try{let e=C.join(this.projectPath,"pom.xml");return await j.readFile(e,"utf-8")}catch(e){if(k(e))return null;throw e}}async readComposerJson(){try{let e=C.join(this.projectPath,"composer.json"),t=await j.readFile(e,"utf-8");return JSON.parse(t)}catch(e){if(k(e)||e instanceof SyntaxError)return null;throw e}}async readPyprojectToml(){try{let e=C.join(this.projectPath,"pyproject.toml");return await j.readFile(e,"utf-8")}catch(e){if(k(e))return null;throw e}}async getFileExtensions(){try{let{stdout:e}=await M('find . -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/dist/*" ! -path "*/.next/*" | sed "s/.*\\./\\./" | sort | uniq -c | sort -rn',{cwd:this.projectPath}),t={};return e.trim().split(`
9
+ `).filter(Boolean).forEach(o=>{let s=o.trim().match(/^\s*(\d+)\s+(\.\w+)$/);s&&(t[s[2]]=parseInt(s[1],10))}),t}catch{return{}}}async listConfigFiles(){try{let e=await j.readdir(this.projectPath),t=[/^package\.json$/,/^Cargo\.toml$/,/^go\.mod$/,/^requirements\.txt$/,/^Gemfile$/,/^mix\.exs$/,/^pom\.xml$/,/^composer\.json$/,/^pyproject\.toml$/,/^tsconfig.*\.json$/,/^\..*rc(\.json|\.js|\.cjs)?$/,/^Dockerfile$/,/^docker-compose.*\.ya?ml$/,/^\.env.*$/];return e.filter(o=>t.some(s=>s.test(o)))}catch(e){if(k(e))return[];throw e}}async listDirectories(){try{return(await j.readdir(this.projectPath,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).filter(t=>!t.startsWith(".")&&t!=="node_modules")}catch(e){if(k(e))return[];throw e}}async getGitLog(e=50){try{let{stdout:t}=await M(`git log -n ${e} --pretty=format:"%h|%an|%ar|%s"`,{cwd:this.projectPath});return t}catch{return""}}async getGitStats(){try{let{stdout:e}=await M("git rev-list --count HEAD",{cwd:this.projectPath}),{stdout:t}=await M('git log --format="%an" | sort -u | wc -l',{cwd:this.projectPath}),{stdout:o}=await M('git log --reverse --pretty=format:"%ar" | head -1',{cwd:this.projectPath});return{totalCommits:parseInt(e.trim(),10)||0,contributors:parseInt(t.trim(),10)||0,age:o.trim()||"unknown"}}catch{return{totalCommits:0,contributors:0,age:"unknown"}}}async countFiles(){try{let{stdout:e}=await M('find . -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/dist/*" | wc -l',{cwd:this.projectPath});return parseInt(e.trim(),10)||0}catch{return 0}}async fileExists(e){return ae(C.join(this.projectPath,e))}async readFile(e){try{let t=C.join(this.projectPath,e);return await j.readFile(t,"utf-8")}catch(t){if(k(t))return null;throw t}}async findFiles(e){try{let{stdout:t}=await M(`find . -type f -name "${e}" ! -path "*/node_modules/*" ! -path "*/.git/*"`,{cwd:this.projectPath});return t.trim().split(`
10
+ `).filter(Boolean)}catch{return[]}}},We=new Y,S=We;Qe();import je from"node:fs/promises";import Pe from"node:path";var V=800,Z=6,Xe=8,Ke=5;async function ee(r,e,t,o){let[s,i,n,a]=await Promise.all([Ye(r,e,o),Ze(r),et(r),tt(r)]);return{project:{name:o.name,ecosystem:o.ecosystem,languages:o.languages,frameworks:o.frameworks,fileCount:o.fileCount,projectType:o.projectType},git:{branch:t.branch,recentCommits:t.recentCommits.slice(0,Xe).map(u=>({message:u.message,date:u.date})),hasChanges:t.hasChanges,weeklyCommits:t.weeklyCommits},codeSamples:s,existingPatterns:i,taskHistory:n,previousAnalysis:a??void 0}}m(ee,"buildAnalysisPayload");async function Ye(r,e,t){let o=[],s=[...t.frameworks.map(a=>a.toLowerCase()),"config","router","middleware","service","model","schema","database","api","auth"].join(" "),i=de(r,s,Z*2);for(let a of i){if(o.length>=Z)break;try{let u=Pe.join(e,a.path),l=await je.readFile(u,"utf-8");l.length>V*3?o.push({path:a.path,content:`${l.slice(0,V)}
11
+ // ... truncated`,reason:`BM25 score: ${a.score.toFixed(2)} (truncated, ${l.length} chars)`}):o.push({path:a.path,content:l.slice(0,V),reason:`BM25 score: ${a.score.toFixed(2)}`})}catch{}}let n=["package.json","tsconfig.json","src/index.ts","src/main.ts","app.ts"];for(let a of n){if(o.length>=Z)break;if(!o.some(u=>u.path===a))try{let u=Pe.join(e,a),l=await je.readFile(u,"utf-8");o.push({path:a,content:l.slice(0,V),reason:"entry point"})}catch{}}return o}m(Ye,"selectCodeSamples");async function Ze(r){try{let e=await b.getActive(r);return e?{patterns:(e.patterns??[]).map(t=>({name:t.name,description:t.description})),antiPatterns:(e.antiPatterns??[]).map(t=>({issue:t.issue,file:t.file,suggestion:t.suggestion}))}:{patterns:[],antiPatterns:[]}}catch{return{patterns:[],antiPatterns:[]}}}m(Ze,"getExistingPatterns");async function et(r){try{return(await ue.getTaskHistory(r)).slice(0,Ke).map(t=>({description:t.title,status:t.classification,branch:t.branchName}))}catch{return[]}}m(et,"getTaskHistory");function tt(r){try{let e=D.getActiveSummary(r);return Promise.resolve(e)}catch(e){return Se.debug("Failed to get previous LLM analysis summary",{error:e}),Promise.resolve(null)}}m(tt,"getPreviousAnalysisSummary");J();X();ce();J();async function be(r=process.cwd(),e={}){try{let t=await w(r);if(!t.ok)return e.json&&console.log(JSON.stringify({success:!1,error:"No project ID found"})),t.result;let o=t.value,s=await b.seal(o);return e.json?(console.log(JSON.stringify({success:s.success,signature:s.signature,error:s.error})),{success:s.success,error:s.error}):s.success?(g.done("Analysis sealed"),console.log(` Signature: ${s.signature?.substring(0,16)}...`),console.log(""),{success:!0,data:{signature:s.signature}}):(g.fail(s.error||"Seal failed"),{success:!1,error:s.error})}catch(t){let o=$(t);return e.json?console.log(JSON.stringify({success:!1,error:o})):g.fail(o),{success:!1,error:o}}}m(be,"seal");async function Ce(r=process.cwd(),e={}){try{let t=await w(r);if(!t.ok)return e.json&&console.log(JSON.stringify({success:!1,error:"No project ID found"})),t.result;let o=t.value,s=await b.rollback(o);return e.json?(console.log(JSON.stringify({success:s.success,restoredSignature:s.restoredSignature,error:s.error})),{success:s.success,error:s.error}):e.md?s.success?(console.log(y(R("Analysis Rolled Back"),E({"Restored signature":`${s.restoredSignature?.substring(0,16)}...`,Note:"Previous sealed version is now active. Current version moved to draft."}))),{success:!0,data:{restoredSignature:s.restoredSignature}}):(console.log(y("## Rollback Failed",`> ${s.error}`)),{success:!1,error:s.error}):s.success?(g.done("Analysis rolled back to previous sealed version"),console.log(` Restored signature: ${s.restoredSignature?.substring(0,16)}...`),console.log(" Previous sealed version demoted to draft"),console.log(""),{success:!0,data:{restoredSignature:s.restoredSignature}}):(g.fail(s.error||"Rollback failed"),{success:!1,error:s.error})}catch(t){let o=$(t);return e.json?console.log(JSON.stringify({success:!1,error:o})):e.md?console.log(y("## Rollback Failed",`> ${o}`)):g.fail(o),{success:!1,error:o}}}m(Ce,"rollback");async function xe(r=process.cwd(),e={}){if(e.semantic)return te(r,e);try{let t=await w(r);if(!t.ok)return t.result;let o=t.value,s=await b.verify(o);return e.json?(console.log(JSON.stringify(s)),{success:s.valid}):(s.valid?g.done(s.message):g.fail(s.message),console.log(""),{success:s.valid,data:s})}catch(t){let o=$(t);return me(o)}}m(xe,"verify");async function te(r=process.cwd(),e={}){try{let t=await w(r);if(!t.ok)return e.json?console.log(JSON.stringify({success:!1,error:"No project ID found"})):g.fail("No project ID found"),t.result;let o=t.value,s=(()=>{try{return _.getDoc(o,"project")?.repoPath||r}catch{return r}})(),i=await b.semanticVerify(o,s);if(e.json)return console.log(JSON.stringify(i)),{success:i.passed,data:i};console.log(""),i.passed?(g.done("Semantic verification passed"),console.log(` ${i.passedCount}/${i.checks.length} checks passed (${i.totalMs}ms)`)):(g.fail("Semantic verification failed"),console.log(` ${i.failedCount}/${i.checks.length} checks failed`)),console.log(""),console.log("Check Results:");for(let n of i.checks){let a=n.passed?"\u2713":"\u2717",u=n.passed?`${n.output} (${n.durationMs}ms)`:n.error||"Failed";console.log(` ${a} ${n.name}: ${u}`)}return console.log(""),{success:i.passed,data:i}}catch(t){let o=$(t);return e.json?console.log(JSON.stringify({success:!1,error:o})):g.fail(o),{success:!1,error:o}}}m(te,"semanticVerifyCommand");import De from"node:fs/promises";import Re from"node:path";import{z as c}from"zod";var st=c.object({style:c.string(),insights:c.array(c.string()),domains:c.array(c.string())}),nt=c.object({name:c.string(),description:c.string(),locations:c.array(c.string()),confidence:c.number().min(0).max(1),category:c.string()}),rt=c.object({issue:c.string(),reasoning:c.string(),files:c.array(c.string()),suggestion:c.string(),severity:c.enum(["low","medium","high"]),confidence:c.number().min(0).max(1)}),ot=c.object({description:c.string(),area:c.string(),effort:c.enum(["small","medium","large"]),impact:c.string(),priority:c.enum(["low","medium","high"])}),at=c.object({path:c.string(),reason:c.string(),risk:c.string(),severity:c.enum(["low","medium","high"])}),it=c.object({description:c.string(),files:c.array(c.string()),benefit:c.string(),effort:c.enum(["small","medium","large"])}),ct=c.object({category:c.string(),rule:c.string(),example:c.string().optional()}),lt=c.object({build:c.string().optional(),test:c.string().optional(),lint:c.string().optional(),dev:c.string().optional(),format:c.string().optional(),install:c.string().optional()}),ut=c.object({languages:c.array(c.string()),frameworks:c.array(c.string()),packageManager:c.string().optional()}),mt=c.object({version:c.literal(1),commitHash:c.string().nullable(),analyzedAt:c.string(),architecture:st,patterns:c.array(nt),antiPatterns:c.array(rt),techDebt:c.array(ot),riskAreas:c.array(at),refactorSuggestions:c.array(it),projectInsights:c.array(c.string()),conventions:c.array(ct),commands:lt.optional(),stack:ut.optional()});function Ae(r){let e=mt.safeParse(r);return e.success?{ok:!0,value:e.data}:{ok:!1,error:e.error.issues.map(o=>`${o.path.length>0?o.path.join("."):"<root>"}: ${o.message}`).join("; ")}}m(Ae,"parseLlmAnalysis");X();re();async function Le(r,e=process.cwd(),t={}){try{let o=await w(e);if(!o.ok)return o.result;let s=o.value,i=await dt(r,e),n=await pt(i.content,e),a=D.getActive(s),u=!!(a&&he(a)&&K(n)),l=u?gt(a,n):n;D.save(s,l);try{let{recomputeProjectStyle:f}=await import("./project-style-evolution-7JS75AUP.mjs"),{gatherStats:h,detectStack:x,detectCommands:B}=await import("./sync-analyzer-FKC57RTV.mjs"),[T,P,Q]=await Promise.all([h(e),x(e),B(e)]);await f({projectId:s,projectPath:e,stats:T,stack:P,commands:Q,commitHash:l.commitHash,source:"analysis-save"})}catch{}let p=K(l)&&!u;if(t.md){let h=[R(u?"LLM Analysis Notes Merged (house style preserved)":p?"LLM Analysis Notes Saved (thin \u2014 not house style)":"LLM Analysis Saved"),E({Input:i.source,Architecture:l.architecture.style,Patterns:l.patterns.length,"Anti-patterns":l.antiPatterns?.length||0,"Tech debt items":l.techDebt?.length||0,"Risk areas":l.riskAreas?.length||0,Conventions:l.conventions?.length||0,...u?{Merge:"thin notes \u2192 existing rich analysis"}:{},...p?{Kind:"thin markdown/notes"}:{}})];p&&h.push(z("Prefer schema v1 JSON (architecture/patterns/conventions) via `prjct analysis-save-llm <file> --md`. Markdown alone leaves patterns empty and burns a retry loop.")),console.log(y(...h))}else console.log(JSON.stringify({success:!0,message:u?"LLM analysis notes merged into existing rich analysis":p?"LLM analysis thin notes saved (prefer schema v1 JSON for house style)":"LLM analysis saved",input:i.source,mergedNotes:u,thin:p,stats:{patterns:l.patterns.length,antiPatterns:l.antiPatterns?.length||0,techDebt:l.techDebt?.length||0},...p?{tip:"Prefer schema v1 JSON (architecture/patterns/conventions). Markdown alone is thin notes."}:{}}));return{success:!0}}catch(o){return A(o)}}m(Le,"saveLlmAnalysis");function gt(r,e){let t=m((o,s,i)=>{let n=[],a=new Set;for(let u of[...o,...s]){let l=u.toLowerCase();if(!(a.has(l)||!u.trim())&&(a.add(l),n.push(u),n.length>=i))break}return n},"mergeUnique");return{...r,analyzedAt:e.analyzedAt,commitHash:e.commitHash??r.commitHash,projectInsights:t(r.projectInsights??[],e.projectInsights??[],60),architecture:{...r.architecture,insights:t(r.architecture.insights??[],e.architecture.insights??[],24)}}}m(gt,"mergeThinNotesIntoRich");async function dt(r,e){let t=r.trim();if(!t)throw new Error("analysis-save-llm requires analysis text, JSON, or a file path");let o=Re.isAbsolute(t)?t:Re.resolve(e,t);try{if((await De.stat(o)).isFile())return{content:await De.readFile(o,"utf-8"),source:"file"}}catch{}return{content:r,source:"inline"}}m(dt,"resolveAnalysisInput");async function pt(r,e){let t=r.trim();if(!t)throw new Error("analysis-save-llm received an empty analysis");let o=ft(t);if(o.ok){let s=Ae(o.value);return s.ok?s.value:Me(`Structured analysis did not match the legacy schema; preserved as LLM notes.
12
+
13
+ ${JSON.stringify(o.value,null,2)}`,e)}return Me(t,e)}m(pt,"normalizeAnalysis");function ft(r){try{return{ok:!0,value:JSON.parse(r)}}catch{return{ok:!1}}}m(ft,"tryParseJson");async function Me(r,e){let t=ht(r);return{version:1,commitHash:await St(e),analyzedAt:I(),architecture:{style:"unknown",insights:t.slice(0,8),domains:[]},patterns:[],antiPatterns:[],techDebt:[],riskAreas:[],refactorSuggestions:[],projectInsights:t,conventions:[]}}m(Me,"analysisFromText");function ht(r){let e=r.split(/\r?\n/).map(s=>s.replace(/^\s{0,3}#{1,6}\s+/,"").replace(/^\s*[-*]\s+\[[ xX]\]\s+/,"").replace(/^\s*[-*]\s+/,"").replace(/^\s*\d+[.)]\s+/,"").trim()).filter(yt),t=[],o=new Set;for(let s of e){let i=s.toLowerCase();if(!o.has(i)&&(o.add(i),t.push(s),t.length>=40))break}return t.length>0?t:[r.slice(0,2e3)]}m(ht,"textToInsights");function yt(r){if(!r||!/[\p{L}\p{N}]/u.test(r))return!1;let e=r.toLowerCase().replace(/\s+/g," ").trim();return!(["current work","wip","misc","todo","n/a","none","latest","unreleased","changelog"].includes(e)||/^[-=_]{3,}$/.test(e)||/^(added|changed|fixed|removed)$/i.test(e)||/^v?\d+\.\d+\.\d+(?:-[\w.-]+)?$/i.test(e))}m(yt,"isUsefulInsight");async function St(r){try{let{stdout:e}=await ne("git",["rev-parse","HEAD"],{cwd:r});return e.trim()||null}catch{return null}}m(St,"resolveCurrentCommit");async function Ne(r=process.cwd(),e={}){try{let t=await w(r);if(!t.ok)return t.result;let o=t.value,s=D.getActive(o);if(!s)return e.md?console.log(y("## No LLM Analysis","> Run `prjct sync` to generate.")):console.log(JSON.stringify({success:!1,message:"No LLM analysis found"})),{success:!1,message:"No LLM analysis found"};if(e.md){let i=[R(`LLM Analysis (${s.architecture.style})`),""];if(s.architecture.insights.length>0&&i.push(L("Architecture Insights",N(s.architecture.insights.slice(0,5)))),s.patterns.length>0){let n=s.patterns.slice(0,8);i.push(L(`Patterns (${s.patterns.length})`,N(n.map(a=>`**${a.name}** \u2014 ${a.description} (${a.category})`))))}if(s.antiPatterns.length>0){let n=s.antiPatterns.slice(0,5);i.push(L(`Anti-Patterns (${s.antiPatterns.length})`,N(n.map(a=>`[${a.severity}] ${a.issue} \u2014 ${a.suggestion}`))))}if(s.techDebt.length>0){let n=s.techDebt.slice(0,5);i.push(L(`Tech Debt (${s.techDebt.length})`,N(n.map(a=>`[${a.priority}/${a.effort}] ${a.description}`))))}s.conventions.length>0&&i.push(L("Conventions",N(s.conventions.slice(0,5).map(n=>`**${n.category}**: ${n.rule}`)))),console.log(y(...i))}else{let i={...s,patterns:s.patterns.slice(0,10),antiPatterns:s.antiPatterns.slice(0,6),techDebt:s.techDebt.slice(0,6),conventions:s.conventions.slice(0,6)};console.log(JSON.stringify({success:!0,analysis:i}))}return{success:!0,data:s}}catch(t){return A(t)}}m(Ne,"getLlmAnalysis");ce();J();import wt from"node:path";X();async function Te(r,e){let t=Date.now()-e;await le.installGlobalConfig(),g.done(`Synced ${r.stats.name||"project"} (${(t/1e3).toFixed(1)}s)`),console.log("");let o=r.stats.frameworks.length>0?` (${r.stats.frameworks[0]})`:"",s=r.syncMetrics?.indexes,i=[`${r.stats.fileCount} files indexed`,`Stack: ${r.stats.ecosystem}${o} | Branch: ${r.git.branch}`];if(s?.bm25Files){let a=s.bm25Files*(s.bm25AvgTokens||0);i.push(`Index: ${F(a)} tokens | ${s.bm25VocabSize||0} terms | ${s.importEdges||0} imports`)}g.box("Sync Summary",i.join(`
14
+ `));let n=[];if(r.generatedSkills?.generated&&r.generatedSkills.generated.length>0){let a=r.generatedSkills.generated.length,u=a===1?"skill":"skills";n.push(`${a} ${u} generated`)}if(r.context7&&n.push(`Context7: ${r.context7.verified?"verified":`not ready${r.context7.message?` (${r.context7.message})`:""}`}`),r.analysisSummary&&n.push(`Analysis: ${r.analysisSummary.patterns} patterns | ${r.analysisSummary.antiPatterns} anti-patterns (${r.analysisSummary.criticalAntiPatterns} critical)`),r.contextQuality){let a=r.contextQuality,u=a.irrelevantRemoved>0||a.repairEntriesCreated>0?`, repaired ${a.repairEntriesCreated}, removed ${a.irrelevantRemoved}`:"";n.push(`Context quality: ${a.score}/${a.threshold}${a.passed?"":" (needs review)"}${u}`)}if(g.section("Generated"),g.list(n,{bullet:"\u2713"}),console.log(""),r.git.hasChanges&&(g.warn("Uncommitted changes detected"),console.log("")),r.verification){let a=r.verification;if(a.passed){let u=a.checks.map(l=>`${l.name} (${l.durationMs}ms)`);g.section("Verified"),g.list(u,{bullet:"\u2713"})}else{g.section("Verification");let u=a.checks.map(l=>l.passed?`\u2713 ${l.name}`:`\u2717 ${l.name}${l.error?` \u2014 ${l.error}`:""}`);g.list(u),a.skippedCount>0&&g.warn(`${a.skippedCount} check(s) skipped (fail-fast)`)}console.log("")}return we("sync"),{success:!0,data:r,metrics:{elapsed:t,fileCount:r.stats.fileCount}}}m(Te,"showSyncResult");async function Ee(r){try{let e=await ge.getRecentEvents(r,100),t=new Date().toISOString().split("T")[0],o=e.filter(l=>(l.timestamp||l.ts)?.startsWith(t)),s=(()=>{if(o.length<2)return null;let l=o.map(f=>new Date(f.timestamp||f.ts).getTime()).filter(f=>!Number.isNaN(f)).sort((f,h)=>f-h);if(l.length<2)return null;let p=l[l.length-1]-l[0];return oe(p)})(),i=o.filter(l=>l.action==="task_completed").length,n=o.filter(l=>l.action==="feature_shipped").length,a=new Map;for(let l of o)if(l.action==="sync"&&Array.isArray(l.subagents))for(let p of l.subagents)a.set(p,(a.get(p)||0)+1);let u=Array.from(a.entries()).map(([l,p])=>({name:l,count:p})).sort((l,p)=>p.count-l.count);return{sessionDuration:s,tasksCompleted:i,featuresShipped:n,agentsUsed:u}}catch{return{sessionDuration:null,tasksCompleted:0,featuresShipped:0,agentsUsed:[]}}}m(Ee,"getSessionActivity");function F(r){return r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:r.toLocaleString()}m(F,"formatTokens");function se(r){return r<1e3?`${Math.round(r)}ms`:`${(r/1e3).toFixed(1)}s`}m(se,"formatDuration");function Fe(r){if(r.length===0)return"";let e="\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588",t=r.map(s=>s.tokensSaved),o=Math.max(...t,1);return t.map(s=>{let i=Math.min(Math.floor(s/o*(e.length-1)),e.length-1);return e[i]}).join("")}m(Fe,"generateSparkline");function Oe(r,e,t,o,s,i){let n=[];if(n.push(`# ${t} - Stats Dashboard`),n.push(""),n.push(`_Generated: ${new Date().toLocaleString()} | Tracking since: ${o}_`),n.push(""),s){if(n.push("## Today's Activity"),n.push(""),n.push("| Metric | Value |"),n.push("|--------|-------|"),s.sessionDuration&&n.push(`| Duration | ${s.sessionDuration} |`),n.push(`| Tasks completed | ${s.tasksCompleted} |`),n.push(`| Features shipped | ${s.featuresShipped} |`),s.agentsUsed.length>0){let a=s.agentsUsed.slice(0,3).map(u=>`${u.name} (${u.count}\xD7)`).join(", ");n.push(`| Agents used | ${a} |`)}n.push("")}if(i&&(i.decisions>0||i.preferences>0)&&(n.push("## Patterns Learned"),n.push(""),n.push("| Type | Count |"),n.push("|------|-------|"),n.push(`| Decisions | ${i.learnedDecisions} confirmed (${i.decisions} total) |`),n.push(`| Preferences | ${i.preferences} |`),n.push(`| Workflows | ${i.workflows} |`),n.push("")),n.push("## Context Efficiency"),n.push(""),n.push("| Metric | Value |"),n.push("|--------|-------|"),n.push(`| Tokens reduced | ${F(r.totalTokensSaved)} |`),n.push(`| Compression | ${(r.compressionRate*100).toFixed(0)}% |`),n.push(`| Est. cost saved | ${U(r.estimatedCostSaved)} |`),n.push(""),n.push("## Performance"),n.push(""),n.push("| Metric | Value |"),n.push("|--------|-------|"),n.push(`| Syncs | ${r.syncCount} |`),n.push(`| Avg time | ${se(r.avgSyncDuration)} |`),n.push(""),r.topAgents.length>0){n.push("## Agent Usage"),n.push(""),n.push("| Agent | Usage |"),n.push("|-------|-------|");let a=r.topAgents.reduce((u,l)=>u+l.usageCount,0);for(let u of r.topAgents){let l=a>0?(u.usageCount/a*100).toFixed(0):0;n.push(`| ${u.agentName} | ${l}% (${u.usageCount}) |`)}n.push("")}if(n.push("## 30-Day Trend"),n.push(""),n.push(`- Tokens saved: ${F(r.last30DaysTokens)}`),r.trend!==0){let a=r.trend>0?"+":"";n.push(`- Trend: ${a}${r.trend.toFixed(0)}% vs previous period`)}return n.push(""),n.push("---"),n.push(""),n.push("_Generated with [prjct-cli](https://prjct.app)_"),n.join(`
15
+ `)}m(Oe,"generateStatsMarkdown");function Ie(r,e){let t=[];t.push(`# Repository Analysis
16
+ `),t.push(`Generated: ${new Date().toLocaleString()}
17
+ `);let o=wt.basename(e);if(t.push(`## Project: ${o}
18
+ `),t.push(`## Stack Detected
19
+ `),r.packageJson){let n=r.packageJson;if(t.push(`### JavaScript/TypeScript
20
+ `),t.push("- **Package Manager**: npm/yarn/pnpm"),n.dependencies){let a=Object.keys(n.dependencies);a.length>0&&t.push(`- **Dependencies**: ${a.slice(0,10).join(", ")}${a.length>10?` (+${a.length-10} more)`:""}`)}r.hasNextConfig&&t.push("- **Framework**: Next.js detected"),r.hasViteConfig&&t.push("- **Build Tool**: Vite detected"),r.hasTsconfig&&t.push("- **Language**: TypeScript"),t.push("")}r.cargoToml&&(t.push(`### Rust
21
+ `),t.push("- **Package Manager**: Cargo"),t.push(`- **Language**: Rust
22
+ `)),r.goMod&&(t.push(`### Go
23
+ `),t.push("- **Package Manager**: Go modules"),t.push(`- **Language**: Go
24
+ `)),r.requirements&&(t.push(`### Python
25
+ `),t.push("- **Package Manager**: pip"),t.push(`- **Language**: Python
26
+ `));let s=r.directories;t.push(`## Structure
27
+ `),t.push(`- **Total Files**: ${r.fileCount}`),t.push(`- **Directories**: ${s?.slice(0,15).join(", ")||"none"}${(s?.length||0)>15?` (+${(s?.length||0)-15} more)`:""}`),r.hasDockerfile&&t.push("- **Docker**: Detected"),r.hasDockerCompose&&t.push("- **Docker Compose**: Detected"),r.hasReadme&&t.push("- **Documentation**: README.md found"),t.push("");let i=r.gitStats;return t.push(`## Git Statistics
28
+ `),t.push(`- **Total Commits**: ${i?.totalCommits||0}`),t.push(`- **Contributors**: ${i?.contributors||0}`),t.push(`- **Age**: ${i?.age||"unknown"}`),t.push(""),r.gitLog&&(t.push(`## Recent Activity
29
+ `),r.gitLog.split(`
30
+ `).slice(0,5).forEach(a=>{if(a.trim()){let[u,,l,p]=a.split("|");t.push(`- \`${u}\` ${p} (${l})`)}}),t.push("")),t.push(`## Recommendations
31
+ `),t.push("Based on detected stack, consider generating specialized agents using `p. sync`.\n"),t.push(`---
32
+ `),t.push("*This analysis was generated automatically. For updated information, run `p. analyze` again.*\n"),t.join(`
33
+ `)}m(Ie,"generateAnalysisSummary");async function Je(r=process.cwd(),e={}){try{let t=await w(r);if(!t.ok)return t.result;let o=t.value,s=await q.getSummary(o),i=await q.getDailyStats(o,30),n=await Ee(o),a={decisions:0,preferences:0,workflows:0,learnedDecisions:0};if(e.json){let f={session:n,patterns:a,totalTokensSaved:s.totalTokensSaved,estimatedCostSaved:s.estimatedCostSaved,compressionRate:s.compressionRate,syncCount:s.syncCount,avgSyncDuration:s.avgSyncDuration,topAgents:s.topAgents.slice(0,5),last30DaysTokens:s.last30DaysTokens,trend:s.trend,dailyStats:i.slice(0,7)};return console.log(JSON.stringify(f)),{success:!0,data:f}}let u=(()=>{try{return _.getDoc(o,"project")?.name||"Unknown"}catch{return"Unknown"}})(),l=await q.getFirstSyncDate(o),p=l?new Date(l).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"N/A";if(console.log(""),console.log("\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E"),console.log("\u2502 \u{1F4CA} prjct-cli Stats Dashboard \u2502"),console.log(`\u2502 Project: ${u.padEnd(20).slice(0,20)} | Since: ${p.padEnd(12).slice(0,12)} \u2502`),console.log("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F"),console.log(""),console.log("\u{1F3AF} TODAY'S ACTIVITY"),n.sessionDuration&&console.log(` Duration: ${n.sessionDuration}`),console.log(` Tasks completed: ${n.tasksCompleted}`),console.log(` Features shipped: ${n.featuresShipped}`),n.agentsUsed.length>0){let f=n.agentsUsed.slice(0,3).map(h=>`${h.name} (${h.count}\xD7)`).join(", ");console.log(` Agents used: ${f}`)}if(console.log(""),(a.decisions>0||a.preferences>0)&&(console.log("\u{1F9E0} PATTERNS LEARNED"),console.log(` Decisions: ${a.learnedDecisions} confirmed (${a.decisions} total)`),console.log(` Preferences: ${a.preferences} saved`),console.log(` Workflows: ${a.workflows} tracked`),console.log("")),console.log("\u{1F4B0} TOKEN SAVINGS"),console.log(` Total saved: ${F(s.totalTokensSaved)} tokens`),console.log(` Compression: ${(s.compressionRate*100).toFixed(0)}% average reduction`),console.log(` Estimated cost: ${U(s.estimatedCostSaved)} saved`),console.log(""),console.log("\u26A1 PERFORMANCE"),console.log(` Syncs completed: ${s.syncCount.toLocaleString()}`),console.log(` Avg sync time: ${se(s.avgSyncDuration)}`),console.log(""),s.topAgents.length>0){console.log("\u{1F916} AGENT USAGE (all time)");let f=s.topAgents.reduce((h,x)=>h+x.usageCount,0);for(let h of s.topAgents){let x=f>0?(h.usageCount/f*100).toFixed(0):0;console.log(` ${h.agentName.padEnd(12)}: ${x}% (${h.usageCount} uses)`)}console.log("")}if(i.length>0){console.log("\u{1F4C8} TREND (last 30 days)");let f=Fe(i);if(console.log(` ${f} ${F(s.last30DaysTokens)} tokens saved`),s.trend!==0){let h=s.trend>0?"\u2191":"\u2193",x=s.trend>0?"+":"";console.log(` ${h} ${x}${s.trend.toFixed(0)}% vs previous 30 days`)}console.log("")}if(console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log("Export: prjct stats --export > stats.md"),console.log(""),e.export){let f=Oe(s,i,u,p,n,a);return console.log(f),{success:!0,data:{markdown:f}}}return{success:!0,data:{...s,session:n,patterns:a}}}catch(t){return console.error("\u274C Error:",$(t)),A(t)}}m(Je,"stats");async function _e(r=process.cwd(),e={}){try{let t=await w(r);if(!t.ok)return e.json&&console.log(JSON.stringify({success:!1,error:"No project ID found"})),t.result;let o=t.value,s=await b.diff(o);if(!s){let i="Cannot compute diff: need both a sealed and a draft analysis. Run `p. sync` to create a draft.";return e.json?console.log(JSON.stringify({success:!1,error:i})):e.md?console.log(y("## Analysis Diff",`> ${i}`)):g.warn(i),{success:!1,error:i}}if(e.json)return console.log(JSON.stringify({success:!0,...s})),{success:!0,data:s};if(e.md)return console.log(y(G(s))),{success:!0,data:s};if(!s.hasChanges)g.done("No changes between draft and sealed analysis");else{g.section("Analysis Diff"),console.log(ye(s)),console.log("");let i=[];s.summary.added>0&&i.push(`${s.summary.added} added`),s.summary.removed>0&&i.push(`${s.summary.removed} removed`),s.summary.changed>0&&i.push(`${s.summary.changed} changed`),g.done(i.join(", "))}return console.log(""),{success:!0,data:s}}catch(t){let o=$(t);return e.json?console.log(JSON.stringify({success:!1,error:o})):e.md?console.log(y("## Diff Failed",`> ${o}`)):g.fail(o),{success:!1,error:o}}}m(_e,"diff");var Ge=["> Review this project data and save durable notes for future AI agents (architecture, conventions, risks, gotchas).","> **Prefer schema v1 JSON** with: architecture{style,insights,domains}, patterns[], antiPatterns[], techDebt[], riskAreas[], refactorSuggestions[], projectInsights[], conventions[], optional stack/commands. See core/schemas/llm-analysis.ts.","> Markdown alone saves style=unknown and empty patterns (thin notes) \u2014 agents then retry and burn tokens. Use markdown only to append insight bullets when a rich analysis already exists.","> Save path: write the JSON file, then `prjct analysis-save-llm <file> --md`."].join(`
34
+ `),Ue=class extends $e{static{m(this,"AnalysisCommands")}async analyze(e={},t=process.cwd()){try{await this.initializeAgent(),console.log(`\u{1F50D} Analyzing repository...
35
+ `),S.init(t);let o={packageJson:await S.readPackageJson(),cargoToml:await S.readCargoToml(),goMod:await S.readGoMod(),requirements:await S.readRequirements(),directories:await S.listDirectories(),fileCount:await S.countFiles(),gitStats:await S.getGitStats(),gitLog:await S.getGitLog(20),hasDockerfile:await S.fileExists("Dockerfile"),hasDockerCompose:await S.fileExists("docker-compose.yml"),hasReadme:await S.fileExists("README.md"),hasTsconfig:await S.fileExists("tsconfig.json"),hasViteConfig:await S.fileExists("vite.config.ts")||await S.fileExists("vite.config.js"),hasNextConfig:await S.fileExists("next.config.js")||await S.fileExists("next.config.mjs")},s=Ie(o,t);return await this.logToMemory(t,"repository_analyzed",{timestamp:I(),fileCount:o.fileCount,gitCommits:o.gitStats.totalCommits}),console.log(`\u2705 Analysis complete!
36
+ `),console.log(s),console.log(`
37
+ Next steps:`),console.log("\u2022 p. sync \u2192 Generate agents based on stack"),console.log('\u2022 p. work "<intent>" \u2192 Start a work cycle'),{success:!0,summary:s,data:o}}catch(o){return console.error("\u274C Error:",$(o)),A(o)}}async sync(e=process.cwd(),t={}){try{let o=await w(e);if(!o.ok)return o.result;let s=o.value,i=Date.now();if(t.package){let a=await ie.detectMonorepo(e);if(!a.isMonorepo)return{success:!1,error:"Not a monorepo. --package flag only works in monorepos."};let u=a.packages.find(p=>p.name===t.package||p.relativePath===t.package);if(!u){let p=a.packages.map(f=>f.name).join(", ");return{success:!1,error:`Package "${t.package}" not found. Available: ${p}`}}let l=await H.sync(e,{packagePath:u.path,packageName:u.name});return t.json?console.log(JSON.stringify({success:l.success,package:u.name,path:u.relativePath})):t.md?console.log(y(R(`Synced package: ${u.name}`))):g.done(`Synced package: ${u.name}`),{success:l.success}}t.md||g.spin("Syncing project...");let n=await H.sync(e,{full:t.full});if(!n.success)return t.md?console.log(y("## Sync Failed",`> ${n.error||"Unknown error"}`)):g.fail(n.error||"Sync failed"),{success:!1,error:n.error};if(t.md||g.stop(),t.md){let a=Date.now()-i,u=n.generatedSkills?.generated?.length??0,l=await b.diff(s).then(d=>d?.hasChanges?G(d):null).catch(()=>null),p=n.git.recentCommits[0]?.hash??null,h=p&&D.isCurrent(s,p)?null:await ee(s,e,n.git,n.stats).then(d=>["## Analysis Payload",Ge,"### Data","```json",JSON.stringify(d),"```"].join(`
38
+ `)).catch(()=>"### Next: Run `prjct analysis-payload --md` to update project analysis"),x=ke("sync",!0),B=(()=>{try{let d=fe.recall(s,{types:["context"],limit:5}).map(O=>`- ${pe(O)} \`${O.id}\``);return d.length>0?["### Evaluate recent context","Task contexts captured recently \u2014 fold their decisions, patterns and","anti-patterns into the project analysis (and supersede anything now wrong):","",...d].join(`
39
+ `):null}catch{return null}})(),T=n.syncMetrics?.indexes,P={Duration:`${(a/1e3).toFixed(1)}s`,Skills:`${u} generated`,"Files indexed":n.stats.fileCount};if(T?.bm25Files){let d=T.bm25Files*(T.bm25AvgTokens||0);P["Tokens indexed"]=`${Math.round(d/1e3)}K`,P["Import edges"]=T.importEdges||0,P["Co-change commits"]=T.cochangeCommits||0}n.contextQuality&&(P["Context quality"]=`${n.contextQuality.score}/${n.contextQuality.threshold}`+(n.contextQuality.passed?"":" needs review"),P["Context removed"]=n.contextQuality.irrelevantRemoved,P["Context repairs"]=n.contextQuality.repairEntriesCreated);let Q=(()=>{if(!n.retentionDryRun)return null;let d=n.retentionDryRun,O=d.dryRun===!1?"applied":"dry-run",Ve=d.dryRun===!1?` \xB7 acted: ${d.archived??0} archived, ${d.deleted??0} deleted`+(d.inboxMerged||d.inboxArchived?`, inbox ${d.inboxMerged??0} merged/${d.inboxArchived??0} archived`:""):"";if(P[`Retention (${O})`]=`${d.active} active \xB7 ${d.archive} archive \xB7 ${d.delete} delete${Ve}`,d.vault){let v=d.vault,W=d.dryRun===!1?` \xB7 purged: hard\u0394${v.softDeletedPurged??0} distill\u0394${v.distilledDiscarded??0} digests+${v.digestsWritten??0} arch\u0394${v.archivesPruned??0}`:"";P.Vault=`${v.live} live \xB7 soft-del ${v.softDeleted} \xB7 archives ${v.archives} \xB7 auto ${v.autoSourceLive}${W}`}return d.samples.length>0?L(d.dryRun===!1?"Retention (Rho) \u2014 worst excess/score (actions applied)":"Retention (Rho) dry-run \u2014 worst excess/score (nothing removed)",N(d.samples.map(v=>{let W="excess"in v&&typeof v.excess=="number"?` excess=${v.excess.toFixed(2)}`:"";return`\`${v.id}\` [${v.type}] ${v.verdict} (${v.score}${W}) \u2014 ${v.reasons.join(", ")}`}))):null})(),qe=n.projectStyle?.evolutionMd?n.projectStyle.evolutionMd:n.projectStyle?.summary?["## Project style","",n.projectStyle.summary,"",`Coverage: ${n.projectStyle.styleCoverage}/100 \xB7 ${n.projectStyle.patternCount} patterns \xB7 ${n.projectStyle.conventionCount} conventions \xB7 ${n.projectStyle.antiPatternCount} anti-patterns`].join(`
40
+ `):null,He=n.developerSnapshotCaptured?await import("./developer-evolution-R5BXQH6G.mjs").then(({renderDeveloperEvolution:d})=>d(s,4)).catch(()=>`## Developer evolution
41
+
42
+ Weekly developer snapshot captured.`):null,ze=y(R("Sync Complete"),E(P),Q,l,qe,He,n.git.hasChanges?z("Uncommitted changes detected"):null,B,h,ve(x.map(d=>({label:d.desc,command:d.cmd}))));return console.log(ze),{success:!0,data:n,metrics:{elapsed:a,skillCount:u,fileCount:n.stats.fileCount}}}return Te(n,i)}catch(o){return t.md?console.log(y("## Sync Failed",`> ${$(o)}`)):g.fail($(o)),A(o)}}async analysisPayload(e=process.cwd(),t={}){try{let o=await w(e);if(!o.ok)return o.result;let s=o.value,i=await H.sync(e);if(!i.success)return{success:!1,error:i.error||"Failed to gather project data"};let n=i.git.recentCommits[0]?.hash??null;if(n&&D.isCurrent(s,n))return t.md?console.log(y(R("LLM analysis is current"),"> No re-analysis needed.")):console.log(JSON.stringify({success:!0,action:"skip",message:"Analysis is current"})),{success:!0,message:"Analysis is current"};let a=await ee(s,e,i.git,i.stats);return t.md?console.log(y("## Analysis Payload",Ge,"### Data","```json",JSON.stringify(a),"```")):console.log(JSON.stringify({success:!0,payload:a})),{success:!0,data:a}}catch(o){return A(o)}}async saveLlmAnalysis(...e){return Le(...e)}async getLlmAnalysis(...e){return Ne(...e)}async stats(...e){return Je(...e)}async diff(...e){return _e(...e)}async seal(...e){return be(...e)}async rollback(...e){return Ce(...e)}async verify(...e){return xe(...e)}async semanticVerify(...e){return te(...e)}};export{Ue as AnalysisCommands};
@@ -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{a,b,c}from"./chunk-YUOTOCKK.mjs";import"./chunk-AKIN5WSQ.mjs";import"./chunk-HDSS6UB3.mjs";import"./chunk-JQE2F2RK.mjs";import"./chunk-WUHGODSQ.mjs";import"./chunk-SVZHJZ5T.mjs";import"./chunk-CTWZQ7YI.mjs";import"./chunk-BUDZL4DW.mjs";import"./chunk-E66B27AL.mjs";export{a as DEFAULT_API_URL,b as DEFAULT_WEB_URL,c as default};
@@ -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{a as n}from"./chunk-AW25AWN5.mjs";import"./chunk-HZIORCPO.mjs";import"./chunk-WDGDFXSB.mjs";import"./chunk-NWY5M34K.mjs";import"./chunk-LWCHQIJ7.mjs";import"./chunk-UUULLTQV.mjs";import"./chunk-3JUE6MNF.mjs";import"./chunk-3FBCOCPD.mjs";import"./chunk-YUOTOCKK.mjs";import"./chunk-BISPGBNN.mjs";import"./chunk-LT5WSSQO.mjs";import"./chunk-HJ4HEI45.mjs";import"./chunk-3LG3ACQV.mjs";import"./chunk-AOPJ4Z6O.mjs";import"./chunk-AUUWQH3S.mjs";import"./chunk-MEQS4VPO.mjs";import"./chunk-HDHVBB6Q.mjs";import"./chunk-CE4RCNC7.mjs";import"./chunk-AKIN5WSQ.mjs";import"./chunk-HDSS6UB3.mjs";import"./chunk-JQE2F2RK.mjs";import"./chunk-WUHGODSQ.mjs";import"./chunk-SVZHJZ5T.mjs";import"./chunk-CTWZQ7YI.mjs";import"./chunk-BUDZL4DW.mjs";import{a as t}from"./chunk-E66B27AL.mjs";async function c(u,o){try{let e=o??await import("./config-manager-KYC7WUOS.mjs").then(({default:a})=>a.readConfig(u).catch(()=>null));if(!e?.projectId||!e.cloud?.enabled||e.cloud.paused)return{ran:!1};if(!await n.hasAuth())return{ran:!1};let r=await n.sync(e.projectId,{include:e.cloud.include??{}});return{ran:!0,pushed:r.pushed?.count??0,pulled:r.pulled?.count??0,error:r.success?void 0:r.error}}catch{return{ran:!1}}}t(c,"flushIfLinked");export{c as flushIfLinked};
@@ -0,0 +1,9 @@
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 l,b as g}from"./chunk-Y5NQV46G.mjs";import{e as c,f as d}from"./chunk-HDSS6UB3.mjs";import{a as s,b as m}from"./chunk-WUHGODSQ.mjs";import{b as u,o as v}from"./chunk-CTWZQ7YI.mjs";import{a as n}from"./chunk-E66B27AL.mjs";m();d();v();import{execFileSync as y,spawn as j}from"node:child_process";import a from"node:fs";import i from"node:path";m();d();var w="https://registry.npmjs.org/prjct-cli/latest",$=3600*1e3;async function p(){try{let e=new AbortController,t=setTimeout(()=>e.abort(),6e3),r=await fetch(w,{signal:e.signal});if(clearTimeout(t),!r.ok)return null;let f=await r.json();return typeof f.version=="string"?f.version:null}catch{return null}}n(p,"fetchLatestVersion");var S=n(()=>i.join(s(),"state"),"stateDir"),k=n(()=>i.join(S(),"auto-update.log"),"logPath"),h=3600*1e3;function H(e){if(!e||process.env.PRJCT_NO_AUTO_UPDATE==="1"||l("auto-update")!=="on")return;let t=l("auto-update-last-check");if(t&&Date.now()-Date.parse(t)<h)return;g("auto-update-last-check",new Date().toISOString()),j(process.execPath,[process.argv[1],"__internal-auto-update",e],{detached:!0,stdio:"ignore"}).unref()}n(H,"maybeAutoUpdate");async function L(e){try{let t=await p();if(!t)return;if(c(t,e)<=0){o(`current ${e} >= latest ${t}, no-op`);return}let r=b();o(`upgrade available: ${e} \u2192 ${t} (source: ${r})`),await x(r,t),o(`upgrade complete: ${e} \u2192 ${t}`)}catch(t){o(`auto-update failed: ${t.message}`)}}n(L,"runBackgroundCheck");function b(){let e=i.join(s(),"bin","prjct");if(a.existsSync(e))try{if(a.statSync(e).size>1024*1024)return"binary"}catch{}try{let t=y("npm",["root","-g"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(t&&a.existsSync(i.join(t,"prjct-cli")))return"npm"}catch{}try{let t=y("bun",["pm","bin","-g"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(t&&a.existsSync(i.join(t,"prjct")))return"bun"}catch{}return"unknown"}n(b,"detectInstallSource");async function x(e,t){if(e==="binary"){o(`binary install auto-update skipped for ${t}; run the installer manually to upgrade`);return}if(e==="bun"){await u("bun",["install","-g","prjct-cli@latest"],{timeout:12e4});return}if(e==="npm"||e==="unknown"){await u("npm",["install","-g","prjct-cli@latest"],{timeout:12e4});return}}n(x,"applyUpgrade");function o(e){try{a.mkdirSync(S(),{recursive:!0}),a.appendFileSync(k(),`${new Date().toISOString()} ${e}
9
+ `)}catch{}}n(o,"log");var N={fetchLatestVersion:p,detectInstallSource:b,compareSemver:c,THROTTLE_MS:h};export{N as _internal,H as maybeAutoUpdate,L as runBackgroundCheck};
@@ -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{i as a}from"./chunk-IKUGYUAI.mjs";import"./chunk-M3ZOJVPA.mjs";import"./chunk-Y5NQV46G.mjs";import"./chunk-DXQMKW2B.mjs";import"./chunk-DGQYQSUK.mjs";import"./chunk-RRWPDRYR.mjs";import"./chunk-GAOQHD5S.mjs";import"./chunk-UQVJQME2.mjs";import"./chunk-UUULLTQV.mjs";import"./chunk-3LG3ACQV.mjs";import"./chunk-AOPJ4Z6O.mjs";import"./chunk-AUUWQH3S.mjs";import"./chunk-W5OWBOLH.mjs";import"./chunk-MEQS4VPO.mjs";import"./chunk-HDHVBB6Q.mjs";import"./chunk-CE4RCNC7.mjs";import"./chunk-AKIN5WSQ.mjs";import"./chunk-HDSS6UB3.mjs";import"./chunk-JQE2F2RK.mjs";import"./chunk-WUHGODSQ.mjs";import"./chunk-SVZHJZ5T.mjs";import"./chunk-CTWZQ7YI.mjs";import"./chunk-GCKILEXJ.mjs";import"./chunk-D4S3IRD3.mjs";import"./chunk-PKDYFXMI.mjs";import"./chunk-BUDZL4DW.mjs";import"./chunk-E66B27AL.mjs";export{a as captureGate};
@@ -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{j as c,k as r,n as d}from"./chunk-SVZHJZ5T.mjs";import{a as u}from"./chunk-E66B27AL.mjs";d();import p from"node:fs/promises";import l from"node:os";import n from"node:path";var k=[{value:"web-app",title:"Web Application",description:"React, Vue, Angular, Next.js, etc."},{value:"api-backend",title:"API / Backend Service",description:"Express, Hono, FastAPI, etc."},{value:"fullstack",title:"Full-Stack (Monorepo)",description:"Frontend + Backend in one repo"},{value:"cli-tool",title:"CLI Tool",description:"Command-line application"},{value:"library",title:"Library / Package",description:"Reusable npm/pip/cargo package"},{value:"monorepo",title:"Monorepo (Multiple Projects)",description:"Turborepo, Nx, Lerna, etc."}],h=[{value:"claude",title:"Claude Code",description:"Anthropic's Claude in VS Code/CLI"},{value:"cursor",title:"Cursor",description:"AI-first code editor"},{value:"copilot",title:"GitHub Copilot",description:"GitHub's AI pair programmer"},{value:"gemini",title:"Gemini CLI",description:"Google's Gemini in terminal"},{value:"codex",title:"OpenAI Codex",description:"OpenAI's coding agent in terminal"},{value:"opencode",title:"OpenCode",description:"Open-source terminal coding agent"},{value:"pi",title:"Pi",description:"Minimal terminal coding harness (skills + AGENTS.md)"},{value:"qwen-code",title:"Qwen Code",description:"Qwen-family coding runtime"},{value:"goose",title:"Goose",description:"Open-source coding agent with extensions"},{value:"aider",title:"Aider",description:"Terminal pair-programming agent"},{value:"cline",title:"Cline",description:"VS Code coding agent"},{value:"roo-code",title:"Roo Code",description:"VS Code coding agent with MCP"},{value:"continue",title:"Continue",description:"IDE assistant with MCP config"},{value:"kiro",title:"Kiro",description:"Agentic IDE with steering docs"},{value:"zed",title:"Zed",description:"Editor agent with ACP support"}];async function y(t){try{let e=await p.readdir(t);if(e.includes("turbo.json")||e.includes("lerna.json")||e.includes("nx.json"))return"monorepo";if(e.includes("package.json")){let a=n.join(t,"package.json"),s=JSON.parse(await p.readFile(a,"utf-8")),i={...s.dependencies,...s.devDependencies};if(s.bin)return"cli-tool";if(s.main&&!i.react&&!i.vue&&!i.angular&&!i.express&&!i.hono)return"library";if((i.react||i.vue)&&(i.express||i.hono||i.fastify))return"fullstack";if(i.react||i.vue||i["@angular/core"]||i.next||i.nuxt)return"web-app";if(i.express||i.hono||i.fastify||i.koa||i.nestjs)return"api-backend"}return e.includes("pyproject.toml")||e.includes("setup.py")?e.some(s=>["main.py","app.py","server.py"].includes(s))?"api-backend":"library":e.includes("go.mod")?e.includes("main.go")?"cli-tool":"library":e.includes("Cargo.toml")?"cli-tool":"unknown"}catch{return"unknown"}}u(y,"detectProjectType");async function v(t){let e=[];await r(n.join(l.homedir(),".claude"))&&e.push("claude"),await c(n.join(t,".cursorrules"))&&e.push("cursor"),await c(n.join(t,".github","copilot-instructions.md"))&&e.push("copilot"),await r(n.join(l.homedir(),".gemini"))&&e.push("gemini"),await r(n.join(l.homedir(),".gemini","antigravity"))&&e.push("antigravity"),await r(n.join(t,".opencode"))&&e.push("opencode"),(await r(n.join(t,".pi"))||await r(n.join(l.homedir(),".pi")))&&e.push("pi"),await r(n.join(t,".qwen"))&&e.push("qwen-code"),await r(n.join(t,".goose"))&&e.push("goose"),(await c(n.join(t,".aider.conf.yml"))||await c(n.join(t,".aider.conf.yaml")))&&e.push("aider"),(await r(n.join(t,".cline"))||await r(n.join(t,".clinerules"))||await c(n.join(t,".clinerules")))&&e.push("cline"),await r(n.join(t,".roo"))&&e.push("roo-code"),await r(n.join(t,".continue"))&&e.push("continue"),await r(n.join(t,".kiro"))&&e.push("kiro"),await r(n.join(t,".zed"))&&e.push("zed");try{let{execAsync:a}=await import("./exec-I7XE7NMD.mjs");await a("which codex"),e.push("codex")}catch{await r(n.join(l.homedir(),".codex"))&&e.push("codex")}return e}u(v,"detectInstalledAgents");async function x(t){let e={language:"Unknown",technologies:[]};try{let a=await p.readdir(t);if(a.includes("package.json")){let s=n.join(t,"package.json"),i=JSON.parse(await p.readFile(s,"utf-8")),o={...i.dependencies,...i.devDependencies};e.language=o.typescript?"TypeScript":"JavaScript",o.next?e.framework="Next.js":o.nuxt?e.framework="Nuxt":o.react?e.framework="React":o.vue?e.framework="Vue":o["@angular/core"]?e.framework="Angular":o.express?e.framework="Express":o.hono?e.framework="Hono":o.fastify?e.framework="Fastify":(o.nestjs||o["@nestjs/core"])&&(e.framework="NestJS"),o.bun||o["@types/bun"]||i.engines?.bun?e.runtime="Bun":e.runtime="Node.js",a.includes("bun.lockb")?e.packageManager="Bun":a.includes("pnpm-lock.yaml")?e.packageManager="pnpm":a.includes("yarn.lock")?e.packageManager="Yarn":a.includes("package-lock.json")&&(e.packageManager="npm"),(o.prisma||o["@prisma/client"])&&e.technologies.push("Prisma"),(o.drizzle||o["drizzle-orm"])&&e.technologies.push("Drizzle"),o.tailwindcss&&e.technologies.push("Tailwind CSS"),o.zod&&e.technologies.push("Zod"),(o.trpc||o["@trpc/server"])&&e.technologies.push("tRPC")}else a.includes("pyproject.toml")||a.includes("requirements.txt")?e.language="Python":a.includes("go.mod")?e.language="Go":a.includes("Cargo.toml")?e.language="Rust":(a.includes("pom.xml")||a.includes("build.gradle"))&&(e.language="Java");return e}catch{return e}}u(x,"detectStack");export{k as a,h as b,y as c,v as d,x as e};
@@ -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{d as p,g as b}from"./chunk-HDHVBB6Q.mjs";import{d as f,n as S}from"./chunk-SVZHJZ5T.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};
@@ -0,0 +1,9 @@
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 n,b as m}from"./chunk-WUHGODSQ.mjs";import{a as o}from"./chunk-E66B27AL.mjs";m();import c from"node:crypto";import t from"node:path";var i="\\\\.\\pipe\\";function p(e=n()){return t.join(e,"run")}o(p,"getDaemonRunDir");function a(e=process.platform,r=n()){if(e==="win32"){let u=c.createHash("sha1").update(t.resolve(r)).digest("hex").slice(0,16);return`${i}prjct-${u}-daemon`}return t.join(p(r),"daemon.sock")}o(a,"getDaemonSocketPath");function N(e=a()){return e.startsWith(i)}o(N,"isDaemonNamedPipe");var s={runDir:o(()=>p(),"runDir"),socket:o(()=>a(),"socket"),pid:o(()=>t.join(s.runDir(),"daemon.pid"),"pid"),log:o(()=>t.join(s.runDir(),"daemon.log"),"log")},O=480*60*1e3,x=1024*1024,_=3e4,f=600*1e3,D=new Set(["ship","sync","dream","update","upgrade","analyze","init","cloud"]),M=800;function E(e){return e==="hook"?M:D.has(e)?f:_}o(E,"commandRequestTimeoutMs");function R(e){return Buffer.from(`${JSON.stringify(e)}
9
+ `)}o(R,"encodeMessage");export{N as a,s as b,E as c,R as d};
@@ -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{a as t}from"./chunk-E66B27AL.mjs";var n={TOOL_CHECK:5e3,GIT_OPERATION:1e4,GIT_CLONE:6e4,API_REQUEST:3e4,NPM_INSTALL:12e4,WORKFLOW_HOOK:6e4};function o(_){let s=`PRJCT_TIMEOUT_${_}`,e=process.env[s];if(e){let T=Number.parseInt(e,10);if(!Number.isNaN(T)&&T>0)return T}return n[_]}t(o,"getTimeout");var E={SPINNER_MSG:45,DONE_MSG:50,FAIL_MSG:65,WARN_MSG:65,STEP_MSG:35,PROGRESS_TEXT:25,ISSUE_TITLE:50,FALLBACK_TRUNCATE:50,CLEAR_WIDTH:80};export{o as a,E as b};
@@ -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{a as p}from"./chunk-3FBCOCPD.mjs";import{c as h}from"./chunk-YUOTOCKK.mjs";import{a as d}from"./chunk-E66B27AL.mjs";var k={memories:"memories",tasks:"tasks",subtasks:"subtasks",ideas:"ideas",queue_tasks:"queue_tasks",custom_workflows:"custom_workflows",workflow_rules:"workflow_rules",archives:"archives",shipped_items:"shipped_items",shipped_features:"shipped_features",metrics_daily:"metrics_daily",work_cost_snapshots:"work_cost_snapshots",velocity_sprints:"velocity_sprints",analysis:"analysis",specs:"specs",memory:"memories",memory_entry:"memories",task:"tasks",paused_task:"tasks",subtask:"subtasks",idea:"ideas",queue:"queue_tasks",queue_task:"queue_tasks",shipped:"shipped_items",feature:"roadmap_features",workflow:"custom_workflows",workflow_rule:"workflow_rules",metric:"metrics_daily",work_cost_snapshot:"work_cost_snapshots",velocity:"velocity_sprints",spec:"specs",project:"projects",session:"sessions",agent:"agents"};function y(c){if(c)return k[c]}d(y,"toCloudTable");var w={memories:"memories",tasks:"tasks",subtasks:"tasks",queue_tasks:"tasks",ideas:"ideas",shipped_items:"shipped",shipped_features:"shipped",custom_workflows:"workflows",workflow_rules:"workflows",metrics_daily:"metrics",work_cost_snapshots:"metrics",velocity_sprints:"metrics",archives:"archives",analysis:"analysis",specs:"specs"},f={memories:!0,tasks:!0,ideas:!0,shipped:!0,workflows:!0,metrics:!0,archives:!0,user_prompts:!1,agent_sessions:!1,analysis:!0,specs:!0};function T(c,e){let t=w[c];return t?{...f,...e??{}}[t]!==!1:!0}d(T,"isTableIncluded");var v=Object.keys(f);function _(c){return c.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}d(_,"camelToSnake");function E(c){let e={};for(let[t,s]of Object.entries(c))e[_(t)]=s;return e}d(E,"snakeCaseKeys");function R(c,e){let[t,s]=e.type.split("."),r=y(e.entityType)??y(t);if(!r)return null;let i=e.eventType==="delete"||s==="deleted"||s==="archived"||s==="removed"?"delete":"upsert",n=e.data||{},a=E(n),u=e.entityId||(typeof a.id=="string"?a.id:"")||(typeof n.id=="string"?n.id:"")||(typeof a.task_id=="string"?a.task_id:"")||(typeof n.taskId=="string"?n.taskId:"")||(typeof a.entity_id=="string"?a.entity_id:"")||"";u&&a.id==null&&(a.id=u);let l={event_type:i,entity_type:r,entity_id:u,data:{...a,project_id:c},project_id:c};return e.originDeviceId!==void 0&&(l.origin_device_id=e.originDeviceId),e.contentHash!==void 0&&(l.content_hash=e.contentHash),e.revisionCount!==void 0&&(l.revision_count=e.revisionCount),e.timestamp&&(l.ts=e.timestamp),l}d(R,"mapCliEventToWebFormat");function g(c,e){return e.map(t=>R(c,t)).filter(t=>t!==null)}d(g,"mapCliEventsToWebFormat");var m=class{static{d(this,"SyncClient")}retryConfig={maxRetries:3,baseDelayMs:1e3,maxDelayMs:3e4};async pushEvents(e,t){let{apiUrl:s,apiKey:r,deviceId:o}=await this.getAuthHeaders();if(!r)throw this.createError("AUTH_REQUIRED","No API key configured");let i=g(e,t),n=await this.fetchWithRetry(`${s}/sync/batch`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders(r,o)},body:JSON.stringify({projectId:e,events:i})});if(!n.ok)throw await this.parseErrorResponse(n);return await n.json()}async pullEvents(e,t,s){let{apiUrl:r,apiKey:o,deviceId:i}=await this.getAuthHeaders();if(!o)throw this.createError("AUTH_REQUIRED","No API key configured");let n={projectId:e};typeof t=="number"&&t>0&&(n.sinceEventId=t);let a=await this.fetchWithRetry(`${r}/sync/pull`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders(o,i)},body:JSON.stringify(n)});if(!a.ok)throw await this.parseErrorResponse(a);return await a.json()}async getStatus(e){let{apiUrl:t,apiKey:s,deviceId:r}=await this.getAuthHeaders();if(!s)throw this.createError("AUTH_REQUIRED","No API key configured");let o=await this.fetchWithRetry(`${t}/sync/status/${e}`,{method:"GET",headers:{...this.authHeaders(s,r)}});if(!o.ok)throw await this.parseErrorResponse(o);return await o.json()}async linkProject(e,t,s){let{apiUrl:r,apiKey:o,deviceId:i}=await this.getAuthHeaders();if(!o)throw this.createError("AUTH_REQUIRED","No API key configured");let n=await this.fetchWithRetry(`${r}/sync/link`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders(o,i)},body:JSON.stringify({projectId:e,...t?{name:t}:{},...s?{meta:s}:{}})});if(!n.ok)throw await this.parseErrorResponse(n);return await n.json()}async setCloudLifecycle(e,t){try{let{apiUrl:s,apiKey:r,deviceId:o}=await this.getAuthHeaders();return r?(await this.fetchWithRetry(`${s}/sync/projects/${e}/${t}`,{method:"POST",headers:{...this.authHeaders(r,o)}})).ok:!1}catch{return!1}}async uploadCodeGraph(e,t){try{let{apiUrl:s,apiKey:r,deviceId:o}=await this.getAuthHeaders();if(!r)return{ok:!1,reason:"unauthenticated"};let i=await this.fetchWithRetry(`${s}/sync/projects/${e}/code-graph`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders(r,o)},body:JSON.stringify(t)});if(!i.ok)return{ok:!1,reason:await(async()=>{let u=`${i.status} ${i.statusText}`;try{let l=await i.json();return typeof l.detail=="string"?l.detail:l.detail!=null?JSON.stringify(l.detail).slice(0,300):u}catch{return u}})()};let n=await i.json();return{ok:n.ok!==!1,nodes:n.nodes,links:n.links}}catch(s){return{ok:!1,reason:s instanceof Error?s.message:String(s)}}}async publishBenchmark(e,t){let{apiUrl:s,apiKey:r,deviceId:o}=await this.getAuthHeaders();if(!r)throw this.createError("AUTH_REQUIRED","No API key configured");let i=await this.fetchWithRetry(`${s}/benchmarks/evals`,{method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders(r,o)},body:JSON.stringify({projectId:e,...t})});if(!i.ok)throw await this.parseErrorResponse(i);return await i.json()}async testConnection(){let e=new AbortController,t=setTimeout(()=>e.abort(),p("API_REQUEST"));try{let{apiUrl:s,apiKey:r,deviceId:o}=await this.getAuthHeaders();if(!r)return clearTimeout(t),!1;let i=await fetch(`${s}/auth/verify`,{method:"GET",headers:{...this.authHeaders(r,o)},signal:e.signal});return clearTimeout(t),i.status===401||i.status===403?(await h.clearAuth(),!1):i.ok}catch{return clearTimeout(t),!1}}async hasAuth(){return await h.hasAuth()}async getAuthHeaders(){let[e,t,s]=await Promise.all([h.getApiUrl(),h.getApiKey(),h.getDeviceId()]);return{apiUrl:e,apiKey:t,deviceId:s}}authHeaders(e,t){return{"X-Api-Key":e,"X-Device-Id":t}}async fetchWithRetry(e,t,s=0){let r=new AbortController,o=setTimeout(()=>r.abort(),p("API_REQUEST")),i=(t.method??"GET").toUpperCase(),n=i==="GET"||i==="HEAD";try{let a=await fetch(e,{...t,signal:r.signal});if(clearTimeout(o),n&&a.status>=500&&s<this.retryConfig.maxRetries){let u=Math.min(this.retryConfig.baseDelayMs*2**s,this.retryConfig.maxDelayMs);return await this.sleep(u),this.fetchWithRetry(e,t,s+1)}return a}catch(a){if(clearTimeout(o),a instanceof Error&&a.name==="AbortError")throw this.createError("NETWORK_ERROR",`Request timed out. Try increasing PRJCT_TIMEOUT_API_REQUEST (current: ${p("API_REQUEST")}ms)`);if(n&&s<this.retryConfig.maxRetries){let u=Math.min(this.retryConfig.baseDelayMs*2**s,this.retryConfig.maxDelayMs);return await this.sleep(u),this.fetchWithRetry(e,t,s+1)}throw this.createError("NETWORK_ERROR",a instanceof Error?a.message:"Network request failed")}}async parseErrorResponse(e){try{let t=await e.json(),s=t.detail||t.message||t.error||`HTTP ${e.status}`;return e.status===401||e.status===403?(await h.clearAuth(),this.createError("AUTH_REQUIRED",s,e.status)):e.status===402?this.createError("PAYMENT_REQUIRED",s,e.status):this.createError("API_ERROR",s,e.status)}catch{return e.status===401||e.status===403?(await h.clearAuth(),this.createError("AUTH_REQUIRED",`HTTP ${e.status}`,e.status)):this.createError("API_ERROR",`HTTP ${e.status}`,e.status)}}createError(e,t,s){return{code:e,message:t,status:s}}sleep(e){return new Promise(t=>setTimeout(t,e))}},b=new m,j=b;export{y as a,T as b,b as c,j as d};
@@ -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{c as u}from"./chunk-AOPJ4Z6O.mjs";import{d as i,g as T}from"./chunk-HDHVBB6Q.mjs";import{b as y,e as _}from"./chunk-AKIN5WSQ.mjs";import{a as o}from"./chunk-E66B27AL.mjs";import g from"node:crypto";function E(){return g.randomUUID()}o(E,"generateUUID");_();T();function v(d,t,e){return{id:d,entity_type:t.entityType,entity_id:t.entityId,entity_data:JSON.stringify(t.entityData),summary:t.summary??null,reason:t.reason,archived_at:e,created_at:e}}o(v,"archiveSyncPayload");var l={SHIPPED_RETENTION_DAYS:90,IDEA_DORMANT_DAYS:180,QUEUE_COMPLETED_DAYS:7,PAUSED_TASK_DAYS:30,MEMORY_MAX_ENTRIES:500},h=class{static{o(this,"ArchiveStorage")}archive(t,e){let r=E(),n=y();return i.run(t,"INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)",r,e.entityType,e.entityId,JSON.stringify(e.entityData),e.summary??null,n,e.reason),u({projectId:t,entityType:"archives",entityId:r,eventType:"upsert",data:v(r,e,n)}),r}archiveMany(t,e){if(e.length===0)return 0;let r=y(),n=[];i.transaction(t,a=>{let c=a.prepare("INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)");for(let s of e){let p=E();c.run(p,s.entityType,s.entityId,JSON.stringify(s.entityData),s.summary??null,r,s.reason),n.push({id:p,item:s})}});for(let{id:a,item:c}of n)u({projectId:t,entityType:"archives",entityId:a,eventType:"upsert",data:v(a,c,r)});return e.length}getArchived(t,e,r=50){return e?i.query(t,"SELECT * FROM archives WHERE entity_type = ? ORDER BY archived_at DESC LIMIT ?",e,r):i.query(t,"SELECT * FROM archives ORDER BY archived_at DESC LIMIT ?",r)}getStats(t){let e=i.query(t,"SELECT entity_type, COUNT(*) as count FROM archives GROUP BY entity_type"),r={shipped:0,idea:0,queue_task:0,paused_task:0,memory_entry:0,total:0};for(let n of e){let a=n.entity_type;a in r&&(r[a]=n.count),r.total+=n.count}return r}restore(t,e){let r=i.get(t,"SELECT * FROM archives WHERE id = ?",e);return r?(i.run(t,"DELETE FROM archives WHERE id = ?",e),JSON.parse(r.entity_data)):null}pruneOldArchives(t,e){let r=new Date(Date.now()-e*24*60*60*1e3).toISOString(),n=this.getTotalCount(t);i.run(t,"DELETE FROM archives WHERE archived_at < ?",r);let a=this.getTotalCount(t);return n-a}getTotalCount(t){return i.get(t,"SELECT COUNT(*) as count FROM archives")?.count??0}},I=new h;export{E as a,l as b,I as c};
@@ -0,0 +1,16 @@
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 u,e as c}from"./chunk-D4S3IRD3.mjs";import{a as r}from"./chunk-E66B27AL.mjs";c();function g(){return"---"}r(g,"mdHeader");function a(){return`---
9
+ prjct v${u()}`}r(a,"mdFooter");function f(...n){return m(g(),...n.filter(Boolean),a())}r(f,"mdOutput");function d(n,t){let i=`| ${n.join(" | ")} |`,e=`|${n.map(()=>"---").join("|")}|`,o=t.map(s=>`| ${s.join(" | ")} |`);return[i,e,...o].join(`
10
+ `)}r(d,"mdTable");function l(n,t,i=3){return`### ${n}
11
+ ${t}`}r(l,"mdSection");function $(n,t=!1){return n.map((i,e)=>t?`${e+1}. ${i}`:`- ${i}`).join(`
12
+ `)}r($,"mdList");function h(n){let t=["Command","Action"],i=n.map(e=>[`\`${e.command}\``,e.label]);return`### Next
13
+ ${d(t,i)}`}r(h,"mdNextSteps");function x(n){let t=Object.entries(n).filter(([,o])=>o!=null);if(t.length===0)return"";let i=["Metric","Value"],e=t.map(([o,s])=>[o,String(s)]);return d(i,e)}r(x,"mdStats");function b(n,t){return t?`## ${n}
14
+ > ${t}`:`## ${n}`}r(b,"mdDone");function j(n){return`> **WARNING:** ${n}`}r(j,"mdWarn");function m(...n){return n.filter(Boolean).join(`
15
+
16
+ `)}r(m,"mdJoin");export{f as a,l as b,$ as c,h as d,x as e,b as f,j as g};
@@ -0,0 +1,25 @@
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{e as d,g as r}from"./chunk-HDHVBB6Q.mjs";import{a as o}from"./chunk-E66B27AL.mjs";r();function t(e,s=500){let n=e?.replace(/\s+/g," ").trim();return n?n.length<=s?n:`${n.slice(0,s-3)}...`:null}o(t,"cleanText");function i(e){let s=[];return e.agent&&s.push(`agent=${e.agent}`),(e.tokensIn??0)+(e.tokensOut??0)>0&&(s.push(`tokens_in=${Math.round(e.tokensIn??0)}`),s.push(`tokens_out=${Math.round(e.tokensOut??0)}`)),e.filesTouched&&e.filesTouched.length>0&&s.push(`files_touched=${e.filesTouched.length}`),s.length===0?null:s.join(" ")}o(i,"summary");function a(e){if(!e.sessionId)return;let s=new Date().toISOString();try{d.run(e.projectId,`INSERT INTO agent_sessions
9
+ (id, project_id, directory, task_id, goal, started_at, created_at)
10
+ VALUES (?, ?, ?, ?, ?, ?, ?)
11
+ ON CONFLICT(id) DO UPDATE SET
12
+ directory = COALESCE(excluded.directory, agent_sessions.directory),
13
+ task_id = COALESCE(excluded.task_id, agent_sessions.task_id),
14
+ goal = COALESCE(excluded.goal, agent_sessions.goal)`,e.sessionId,e.projectId,t(e.directory),t(e.taskId),t(e.goal),s,s)}catch{}}o(a,"recordAgentSessionStart");function c(e){if(!e.sessionId)return;let s=new Date().toISOString(),n=e.filesTouched&&e.filesTouched.length>0?JSON.stringify(e.filesTouched.slice(0,100)):null;try{d.run(e.projectId,`INSERT INTO agent_sessions
15
+ (id, project_id, directory, task_id, goal, started_at, ended_at, summary, files_touched, runtime, model, created_at)
16
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
17
+ ON CONFLICT(id) DO UPDATE SET
18
+ directory = COALESCE(excluded.directory, agent_sessions.directory),
19
+ task_id = COALESCE(excluded.task_id, agent_sessions.task_id),
20
+ goal = COALESCE(excluded.goal, agent_sessions.goal),
21
+ ended_at = excluded.ended_at,
22
+ summary = COALESCE(excluded.summary, agent_sessions.summary),
23
+ files_touched = COALESCE(excluded.files_touched, agent_sessions.files_touched),
24
+ runtime = excluded.runtime,
25
+ model = CASE WHEN excluded.model = 'unknown' THEN agent_sessions.model ELSE excluded.model END`,e.sessionId,e.projectId,t(e.directory),t(e.taskId),t(e.goal),s,s,i(e),n,t(e.agent,32)??"unknown",t(e.model,120)??"unknown",s)}catch{}}o(c,"recordAgentSessionEnd");export{a,c as b};
@@ -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{e as g,g as A}from"./chunk-HDHVBB6Q.mjs";import{d as b,e as I,n as L}from"./chunk-SVZHJZ5T.mjs";import{a as l}from"./chunk-E66B27AL.mjs";import v from"node:fs/promises";import S from"node:path";A();L();var w=new Set(["the","a","an","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","shall","can","of","in","to","for","with","on","at","from","by","as","or","and","but","if","not","no","so","up","out","this","that","it","its","all","any","import","export","default","const","let","var","function","class","interface","type","return","new","true","false","null","undefined","void","async","await","static","public","private","protected","readonly","string","number","boolean","object","array"]);function p(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[-_./]/g," ").toLowerCase().split(/\s+/).filter(n=>n.length>1)}l(p,"splitIdentifier");function D(t,n){let e=[],o=n.replace(/\.[^.]+$/,"").split(/[/\\]/).filter(Boolean);for(let i of o)e.push(...p(i));let r=[/export\s+(?:async\s+)?function\s+(\w+)/g,/export\s+class\s+(\w+)/g,/export\s+interface\s+(\w+)/g,/export\s+type\s+(\w+)/g,/export\s+(?:const|let|var)\s+(\w+)/g,/export\s+default\s+(?:class|function)\s+(\w+)/g];for(let i of r)for(let s of t.matchAll(i))s[1]&&e.push(...p(s[1]));let a=[/(?:async\s+)?function\s+(\w+)/g,/class\s+(\w+)/g,/interface\s+(\w+)/g,/type\s+(\w+)\s*=/g];for(let i of a)for(let s of t.matchAll(i))s[1]&&e.push(...p(s[1]));let d=/(?:from|import)\s+['"]([^'"]+)['"]/g;for(let i of t.matchAll(d)){let s=i[1];if(s.startsWith(".")||s.startsWith("@/"))e.push(...p(s));else{let f=s.startsWith("@")?s.split("/").slice(0,2).join("/"):s.split("/")[0];e.push(...p(f))}}let c=/\/\/\s*(.+)/g;for(let i of t.matchAll(c)){let s=i[1].toLowerCase().split(/\s+/).filter(f=>f.length>2);e.push(...s)}let u=/\/\*\*?([\s\S]*?)\*\//g;for(let i of t.matchAll(u)){let s=i[1].replace(/@\w+/g,"").replace(/\*/g,"").toLowerCase().split(/\s+/).filter(f=>f.length>2&&/^[a-z]+$/.test(f));e.push(...s)}return e.filter(i=>i.length>1&&!w.has(i)&&/^[a-z][a-z0-9]*$/.test(i))}l(D,"tokenizeFile");function T(t){return t.split(/\s+/).flatMap(n=>p(n)).filter(n=>n.length>1&&!w.has(n)&&/^[a-z][a-z0-9]*$/.test(n))}l(T,"tokenizeQuery");function x(){return Object.create(null)}l(x,"emptyInvertedIndex");async function R(t){let n=await b(t),e={},o=x(),r=await I(n,50,async c=>{try{let u=await v.readFile(S.join(t,c),"utf-8"),i=D(u,c);return i.length>0?{filePath:c,tokens:i}:null}catch{return null}});for(let{filePath:c,tokens:u}of r){e[c]={tokens:u,length:u.length};for(let[i,s]of M(u))o[i]||(o[i]=[]),o[i].push({path:c,tf:s})}let a=r.reduce((c,u)=>c+u.tokens.length,0),d=Object.keys(e).length;return{documents:e,invertedIndex:o,avgDocLength:d>0?a/d:0,totalDocs:d,builtAt:new Date().toISOString()}}l(R,"buildIndex");function C(t,n){return Math.log((n-t+.5)/(t+.5)+1)}l(C,"idf");function N(t,n){let e=T(t);if(e.length===0)return[];let o=new Map;for(let r of e){let a=n.invertedIndex[r];if(!a)continue;let d=C(a.length,n.totalDocs);for(let{path:c,tf:u}of a){let i=n.documents[c];if(!i)continue;let s=u*(1.2+1),f=u+1.2*(1-.75+.75*(i.length/n.avgDocLength)),O=d*(s/f);o.set(c,(o.get(c)||0)+O)}}return Array.from(o.entries()).map(([r,a])=>({path:r,score:a})).sort((r,a)=>a.score-r.score)}l(N,"score");var h="bm25-index";function M(t){let n=new Map;for(let e of t)n.set(e,(n.get(e)||0)+1);return n}l(M,"termFrequencies");function F(t,n){let e=t.documents[n];if(!e)return;delete t.documents[n];let o=new Set(e.tokens),r=o.size>0?o:new Set(Object.keys(t.invertedIndex));for(let a of r){let d=t.invertedIndex[a];if(!d)continue;let c=d.filter(u=>u.path!==n);c.length===0?delete t.invertedIndex[a]:t.invertedIndex[a]=c}}l(F,"removeDocument");function P(t,n,e){if(e.length!==0){t.documents[n]={tokens:e,length:e.length};for(let[o,r]of M(e))t.invertedIndex[o]||(t.invertedIndex[o]=[]),t.invertedIndex[o].push({path:n,tf:r})}}l(P,"addDocument");function z(t){let n=Object.values(t.documents).map(o=>o.length),e=n.reduce((o,r)=>o+r,0);t.totalDocs=n.length,t.avgDocLength=n.length>0?e/n.length:0,t.builtAt=new Date().toISOString()}l(z,"recalculateStats");var m=new Map;function B(t){return{schemaVersion:2,avgDocLength:t.avgDocLength,totalDocs:t.totalDocs,builtAt:t.builtAt,docLengths:Object.fromEntries(Object.entries(t.documents).map(([n,e])=>[n,e.length]))}}l(B,"indexMetadata");function _(t,n,e,o,r){if(o.length!==0){t.run(e,JSON.stringify(o),o.length,r);for(let[a,d]of M(o))n.run(a,e,d)}}l(_,"writeDocumentRows");function q(t,n){try{g.transaction(t,e=>{e.prepare("DELETE FROM bm25_terms").run(),e.prepare("DELETE FROM bm25_documents").run();let o=new Date().toISOString(),r=e.prepare("INSERT INTO bm25_documents (path, tokens, length, updated_at) VALUES (?, ?, ?, ?)"),a=e.prepare("INSERT INTO bm25_terms (token, path, tf) VALUES (?, ?, ?)");for(let[d,c]of Object.entries(n.documents))_(r,a,d,c.tokens,o)})}catch{}}l(q,"replacePerFileTables");function W(t,n,e,o){try{g.transaction(t,r=>{let a=r.prepare("DELETE FROM bm25_terms WHERE path = ?"),d=r.prepare("DELETE FROM bm25_documents WHERE path = ?"),c=r.prepare("INSERT INTO bm25_documents (path, tokens, length, updated_at) VALUES (?, ?, ?, ?)"),u=r.prepare("INSERT INTO bm25_terms (token, path, tf) VALUES (?, ?, ?)"),i=new Date().toISOString();for(let s of new Set([...e,...o]))a.run(s),d.run(s);for(let s of e){let f=n.documents[s];f&&_(c,u,s,f.tokens,i)}})}catch{}}l(W,"updatePerFileTables");function $(t,n){g.setDoc(t,h,B(n)),q(t,n),m.delete(t)}l($,"saveIndex");function H(t,n,e,o){g.setDoc(t,h,B(n)),W(t,n,e,o),m.delete(t)}l(H,"saveIndexUpdate");function U(t,n,e){try{let o=g.query(t,"SELECT path, length FROM bm25_documents ORDER BY path");if(o.length===0){if(e?.totalDocs===0){let s={documents:{},invertedIndex:x(),avgDocLength:0,totalDocs:0,builtAt:e.builtAt};return m.set(t,{index:s,updatedAt:n}),s}return null}let r={},a=x();for(let s of o)r[s.path]={tokens:[],length:s.length};let d=o.reduce((s,f)=>s+f.length,0),c=g.query(t,"SELECT token, path, tf FROM bm25_terms ORDER BY token, path");for(let s of c)a[s.token]||(a[s.token]=[]),a[s.token].push({path:s.path,tf:s.tf});let u=o.length,i={documents:r,invertedIndex:a,avgDocLength:u>0?d/u:0,totalDocs:u,builtAt:e?.builtAt??n};return m.set(t,{index:i,updatedAt:n}),i}catch{return null}}l(U,"loadIndexFromPerFileTables");function J(t){try{return g.get(t,"SELECT key AS k FROM kv_store WHERE key = ? LIMIT 1",h)!=null}catch{return!1}}l(J,"hasIndex");function k(t){let n=g.get(t,"SELECT updated_at FROM kv_store WHERE key = ?",h);if(!n)return m.delete(t),null;let e=m.get(t);if(e&&e.updatedAt===n.updated_at)return e.index;let o=g.getDoc(t,h),r=U(t,n.updated_at,o);if(r)return r;if(!o?.invertedIndex)return null;let a={};for(let[c,u]of Object.entries(o.docLengths))a[c]={tokens:[],length:u};let d={documents:a,invertedIndex:Object.assign(x(),o.invertedIndex),avgDocLength:o.avgDocLength,totalDocs:o.totalDocs,builtAt:o.builtAt};return m.set(t,{index:d,updatedAt:n.updated_at}),d}l(k,"loadIndex");async function V(t,n){let e=await R(t);return $(n,e),e}l(V,"indexProject");async function Q(t,n,e,o=[]){let r=k(n);if(!r)return V(t,n);let a=new Set([...e,...o]);for(let c of a)F(r,c);let d=await I(e,50,async c=>{try{let u=await v.readFile(S.join(t,c),"utf-8"),i=D(u,c);return{filePath:c,tokens:i}}catch{return null}});for(let{filePath:c,tokens:u}of d)P(r,c,u);return z(r),H(n,r,e,o),r}l(Q,"updateProjectIndex");function tt(t,n,e=15){let o=k(t);return o?N(n,o).slice(0,e):[]}l(tt,"queryFiles");export{J as a,k as b,V as c,Q as d,tt as e};
@@ -0,0 +1,9 @@
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}from"./chunk-E66B27AL.mjs";var p=6;function E(e,n=p){let s=[],o=new Set,f=i((r,t,l)=>{let c=h(r);if(!c||c.length<12)return;let u=c.toLowerCase();o.has(u)||(o.add(u),s.push({rule:c,sourceId:t,kind:l}))},"push");for(let r of e.filter(t=>t.type==="feedback")){if(s.length>=n)break;f(r.content,r.id,"preference")}for(let r of e.filter(t=>t.type==="improvement-signal"&&t.tags?.source==="friction-detector")){if(s.length>=n)break;let t=a(r.content)??g(r.content);t&&f(t,r.id,"friction")}return s}i(E,"extractDeveloperRules");function h(e){return e.replace(/\s+/g," ").trim().replace(/^[-*•]\s+/,"")}i(h,"normalizeRule");function a(e){return e.match(/^Next action:\s*(.+)$/im)?.[1]?.trim()||null}i(a,"extractNextAction");function g(e){let n=e.split(`
9
+ `).map(o=>o.trim())[0]??"",s=n.match(/^\[[^\]]+\]\s+Lesson:\s*(.+)$/i);return s?.[1]?s[1].trim():/^\[[^\]]+\]/.test(n)&&n.length>20?n:null}i(g,"extractLesson");export{E as a};
@@ -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{c as r}from"./chunk-L4COZ7ZH.mjs";import{b as t}from"./chunk-SOPRYWUY.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};
@@ -0,0 +1,7 @@
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);
@@ -0,0 +1,17 @@
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}from"./chunk-E66B27AL.mjs";function a(e,r){let n=r?.turnCount??0,o=e?.maxTurnsPerCycle&&e.maxTurnsPerCycle>0?e.maxTurnsPerCycle:15,c=o>0?n/o:0;if(!r||n<=0)return{level:"ok",cue:null,turns:n,limit:o,ratio:0};let s=e?.maxTokensPerCycle??0,l=(r.tokensIn??0)+(r.tokensOut??0),u=s>0?l/s:0,t=Math.max(c,u);return t>=.7?{level:"critical",turns:n,limit:o,ratio:t,cue:`# prjct: context density (high ~${Math.round(t*100)}%)
9
+ Session continues \u2014 do NOT force land/clear just because the cycle is long.
10
+ Protect the window: no broad Grep/Glob thrash, no re-research from zero, pull memory by id (\`prjct context memory mem_N\`), prefer compact format.
11
+ Persist durable signal with \`prjct remember\` / land when YOU choose hygiene \u2014 not as a kill switch.
12
+ Host "Context 100%" is the real window limit; until then keep working with high-signal tools only.`}:t>=.6?{level:"warn",turns:n,limit:o,ratio:t,cue:`# prjct: context density (~${Math.round(t*100)}%)
13
+ Keep the chat \u2014 prefer high-signal tools only:
14
+ 1. Finish the current slice (no new rabbit holes)
15
+ 2. Recall compact / by-id \u2014 do not re-index the tree
16
+ 3. Optional hygiene later: \`prjct land\` then \`prjct prime\` if the HOST context is actually full
17
+ Do not treat this as "session must end".`}:{level:"ok",cue:null,turns:n,limit:o,ratio:t}}i(a,"contextPressureVerdict");function h(e,r){return r?.contextPressure?.hardBlockShip===!0&&e.level==="critical"}i(h,"contextPressureBlocksExpansion");function p(e){return e.level==="critical"?`ctx:${Math.round(e.ratio*100)}% density \u2014 compact tools only`:e.level==="warn"?`ctx:${Math.round(e.ratio*100)}% density \u2014 prefer compact`:""}i(p,"contextPressureStatusLine");function x(e){return e.level==="warn"||e.level==="critical"}i(x,"contextPressureRequiresCompactPath");export{a,h as b,p as c,x as d};
@@ -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{a as r}from"./chunk-E66B27AL.mjs";function p(c,t){let o=c?.maxTurnsPerCycle??0,e=t?.turnCount??0,s=!!t?.turnLimitAcknowledgedAt,n=o>0&&!!t&&e>=o&&!s,i=t?.description??"this cycle",l=n?`\u26D4 prjct hard stop: ${e} turns on cycle "${i}" (limit ${o}). You are looping \u2014 STOP. Re-plan, split it, or ship the slice that already works, then \`prjct status done\`. To consciously continue THIS cycle: \`prjct work --extend\`.`:"";return{stopped:n,turns:e,limit:o,message:l}}r(p,"loopGuardVerdict");export{p as a};
@@ -0,0 +1,13 @@
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}from"./chunk-3FBCOCPD.mjs";import{a as N,b as f}from"./chunk-W5OWBOLH.mjs";import{n as E,r as _,s as T,t as S}from"./chunk-AKIN5WSQ.mjs";import{m as I,n as P}from"./chunk-SVZHJZ5T.mjs";import{a as A}from"./chunk-PKDYFXMI.mjs";import{a as y,e as $,f as O}from"./chunk-BUDZL4DW.mjs";import{a as c}from"./chunk-E66B27AL.mjs";import i from"chalk";_();import m from"chalk";var j=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],x=80,v={name:"prjct",icon:"\u26A1",signature:"\u26A1 prjct",spinner:{frames:j,speed:x},cli:{header:c(()=>`${m.cyan.bold("\u26A1")} ${m.cyan("prjct")}`,"header"),footer:c(()=>m.dim("\u26A1 prjct"),"footer"),spin:c((e,t)=>`${m.cyan("\u26A1")} ${m.cyan("prjct")} ${m.cyan(j[e%10])} ${m.dim(t||"")}`,"spin")},template:{header:"\u26A1 prjct",footer:"\u26A1 prjct"},commitFooter:"Generated with [p/](https://www.prjct.app/)",urls:{website:"https://prjct.app",docs:"https://prjct.app/docs"},getCommitFooter:c((e="claude")=>E(e).commitFooter,"getCommitFooter"),getSignature:c((e="claude")=>E(e).signature,"getSignature")},l=v;var w={NO_PROJECT:{message:"No prjct project found in this directory",hint:"Run 'prjct init' to set up a new project",file:".prjct/prjct.config.json"},NO_PROJECT_ID:{message:"Project ID not found",hint:"Run 'prjct init' or check .prjct/prjct.config.json",file:".prjct/prjct.config.json"},CONFIG_NOT_FOUND:{message:"Configuration file not found",hint:"Run 'prjct init' to create project configuration",file:".prjct/prjct.config.json"},CONFIG_INVALID:{message:"Invalid configuration file",hint:"Check JSON syntax or delete .prjct/ and run init again",file:".prjct/prjct.config.json"},GIT_NOT_FOUND:{message:"Git repository not detected",hint:"Run 'git init' first, then 'prjct init'"},GIT_NO_COMMITS:{message:"No commits in repository",hint:"Make an initial commit before using prjct"},GIT_DIRTY:{message:"Working directory has uncommitted changes",hint:"Commit or stash changes, or use '--force' to override"},GIT_ON_MAIN:{message:"Cannot ship from main/master branch",hint:"Create a feature branch first: git checkout -b feature/your-feature"},GIT_OPERATION_FAILED:{message:"Git operation failed",hint:"Check git status and resolve any conflicts"},GH_NOT_AUTHENTICATED:{message:"GitHub CLI not authenticated",hint:"Run 'gh auth login' to authenticate",docs:"https://cli.github.com/manual/gh_auth_login"},LINEAR_NOT_CONFIGURED:{message:"Linear integration not configured",hint:"Configure the Linear MCP server in your AI client"},LINEAR_API_ERROR:{message:"Linear API error",hint:"Check your API key or network connection"},NO_ACTIVE_TASK:{message:"No active work cycle",hint:`Start work with 'p. work "intent"'`},TASK_ALREADY_ACTIVE:{message:"A work cycle is already in progress",hint:"Use 'p. work' to inspect it or ship when complete"},SYNC_FAILED:{message:"Project sync failed",hint:"Check file permissions and try again"},NOTHING_TO_SHIP:{message:"Nothing to ship",hint:"Make some changes first, then run ship"},PR_CREATE_FAILED:{message:"Failed to create pull request",hint:"Check GitHub auth and remote configuration"},NO_AI_PROVIDER:{message:"No AI provider detected",hint:"Install Claude Code or Gemini CLI, then run 'prjct start'",docs:"https://prjct.app/docs"},PROVIDER_NOT_CONFIGURED:{message:"AI provider not configured for prjct",hint:"Run 'prjct start' to configure your provider"},UNKNOWN_COMMAND:{message:"Unknown command",hint:"Run 'prjct --help' to see available commands"},MISSING_PARAM:{message:"Missing required parameter",hint:"Check command usage below"},UNKNOWN:{message:"An unexpected error occurred",hint:"Check the error details and try again"}};function R(e,t){return{...w[e],...t}}c(R,"getError");var b=l.spinner.speed,L={silent:{maxLines:0,maxCharsPerLine:0,showMetrics:!1},minimal:{maxLines:1,maxCharsPerLine:65,showMetrics:!1},compact:{maxLines:4,maxCharsPerLine:80,showMetrics:!0},verbose:{maxLines:1/0,maxCharsPerLine:1/0,showMetrics:!0}},s={currentTier:"compact",interval:null,frame:0,quietMode:!1};function k(){return L[s.currentTier]}c(k,"getTierConfig");var h={success:i.green("\u2713"),fail:i.red("\u2717"),warn:i.yellow("\u26A0"),info:i.blue("\u2139"),debug:i.dim("\u{1F527}"),bullet:i.dim("\u2022"),arrow:i.dim("\u2192"),check:i.green("\u2713"),cross:i.red("\u2717"),spinner:i.cyan("\u25D0")};var g=c((e,t)=>{if(!process.stdout.isTTY&&!process.stderr.isTTY)return e||"";let r=t??(k().maxCharsPerLine||u.FALLBACK_TRUNCATE);return e&&e.length>r?`${e.slice(0,r-1)}\u2026`:e||""},"truncate");var G=c(()=>process.stdout.isTTY?process.stdout.write(`\r${" ".repeat(u.CLEAR_WIDTH)}\r`):!0,"clear"),D={start(){return s.quietMode||console.log(l.cli.header()),this},end(){return s.quietMode||console.log(l.cli.footer()),this},spin(e){return s.quietMode?this:(this.stop(),process.stdout.isTTY?(s.interval=setInterval(()=>{process.stdout.write(`\r${l.cli.spin(s.frame++,g(e,u.SPINNER_MSG))}`)},b),this):(process.stdout.write(`${l.cli.spin(0,g(e,u.SPINNER_MSG))}
9
+ `),this))},done(e,t){if(this.stop(),!s.quietMode){let r=[];t?.agents!==void 0&&r.push(`${t.agents}a`),t?.reduction!==void 0&&r.push(`${t.reduction}%`),t?.tokens!==void 0&&r.push(`${Math.round(t.tokens)}K`);let o=r.length>0?i.dim(` [${r.join(" | ")}]`):"";console.log(`${h.success} ${g(e,u.DONE_MSG)}${o}`)}return this},fail(e){return this.stop(),console.error(`${h.fail} ${g(e,u.FAIL_MSG)}`),this},failWithHint(e){this.stop();let t=typeof e=="string"?R(e):e;return console.error(),console.error(`${h.fail} ${t.message}`),t.file&&console.error(i.dim(` File: ${t.file}`)),t.hint&&console.error(i.yellow(` \u{1F4A1} ${t.hint}`)),t.docs&&console.error(i.dim(` Docs: ${t.docs}`)),console.error(),this},warn(e){return this.stop(),s.quietMode||console.log(`${h.warn} ${g(e,u.WARN_MSG)}`),this},info(e){return this.stop(),s.quietMode||console.log(`${h.info} ${e}`),this},debug(e){this.stop();let t=process.env.DEBUG==="1"||process.env.DEBUG==="true";return!s.quietMode&&t&&console.log(`${h.debug} ${i.dim(e)}`),this},success(e,t){return this.done(e,t)},list(e,t={}){if(this.stop(),s.quietMode)return this;let r=t.bullet||h.bullet,o=" ".repeat(t.indent||0);for(let n of e)console.log(`${o}${r} ${n}`);return this},table(e,t={}){if(this.stop(),s.quietMode||e.length===0)return this;let r=Object.keys(e[0]),o={};for(let n of r){o[n]=n.length;for(let a of e){let p=String(a[n]??"");p.length>o[n]&&(o[n]=p.length)}}if(t.header!==!1){let n=r.map(a=>a.padEnd(o[a])).join(" ");console.log(i.dim(n)),console.log(i.dim("\u2500".repeat(n.length)))}for(let n of e){let a=r.map(p=>String(n[p]??"").padEnd(o[p])).join(" ");console.log(a)}return this},box(e,t){if(this.stop(),s.quietMode)return this;let r=t.split(`
10
+ `),o=Math.max(e.length,...r.map(a=>a.length)),n="\u2500".repeat(o+2);console.log(i.dim(`\u250C${n}\u2510`)),console.log(`${i.dim("\u2502")} ${i.bold(e.padEnd(o))} ${i.dim("\u2502")}`),console.log(i.dim(`\u251C${n}\u2524`));for(let a of r)console.log(`${i.dim("\u2502")} ${a.padEnd(o)} ${i.dim("\u2502")}`);return console.log(i.dim(`\u2514${n}\u2518`)),this},section(e){return this.stop(),s.quietMode?this:(console.log(`
11
+ ${i.bold(e)}`),console.log(i.dim("\u2500".repeat(e.length))),this)},stop(){return s.interval&&(clearInterval(s.interval),s.interval=null,G()),this},step(e,t,r){if(s.quietMode)return this;this.stop();let o=i.dim(`[${e}/${t}]`);return process.stdout.isTTY?(s.interval=setInterval(()=>{process.stdout.write(`\r${l.cli.spin(s.frame++,`${o} ${g(r,u.STEP_MSG)}`)}`)},b),this):(process.stdout.write(`${l.cli.spin(0,`${o} ${g(r,u.STEP_MSG)}`)}
12
+ `),this)},progress(e,t,r){if(s.quietMode)return this;this.stop();let o=Math.round(e/t*100),n=Math.round(o/10),a=10-n,p=i.cyan("\u2588".repeat(n))+i.dim("\u2591".repeat(a)),d=r?` ${g(r,u.PROGRESS_TEXT)}`:"";return process.stdout.isTTY?(s.interval=setInterval(()=>{process.stdout.write(`\r${l.cli.spin(s.frame++,`[${p}] ${o}%${d}`)}`)},b),this):(process.stdout.write(`${l.cli.spin(0,`[${p}] ${o}%${d}`)}
13
+ `),this)}},M=D;S();O();P();var C=class{static{c(this,"ProjectService")}currentAuthor=null;async ensureInit(t){if(await f.isConfigured(t))return{success:!0};try{let{worktreeService:a}=await import("./worktree-service-XGRN5TTE.mjs");if(await a.detect(t)){let d=await a.getMainWorktree(t);if(d&&d!==t&&await f.isConfigured(d))return await a.setup(t,d),{success:!0}}}catch{}M.spin("initializing project...");let{PlanningCommands:r}=await import("./planning-ZYFCFU7N.mjs"),n=await new r().init(null,t);return n.success?{success:!0}:n}async getProjectId(t){let r=await f.getProjectId(t);if(!r)throw A.notInitialized();return r}async getGlobalPath(t){let r=await this.getProjectId(t);return await T.ensureProjectStructure(r),T.getGlobalProjectPath(r)}async ensureAuthor(){if(this.currentAuthor)return this.currentAuthor;let t=await N();return this.currentAuthor={name:t.name??void 0,email:t.email??void 0,github:t.github??void 0},this.currentAuthor}getCurrentAuthor(){return this.currentAuthor}clearAuthorCache(){this.currentAuthor=null}async isEmptyDirectory(t){try{return(await I(t)).filter(n=>!n.startsWith(".")&&n!=="node_modules"&&n!=="package.json"&&n!=="package-lock.json"&&n!=="README.md").length===0}catch(r){return y(r)||console.error(`Directory check error: ${$(r)}`),!0}}async hasExistingCode(t){try{let r=["src","lib","app","components","pages","api","main.go","main.rs","main.py"];return(await I(t)).some(n=>r.includes(n))}catch(r){return y(r)||console.error(`Code check error: ${$(r)}`),!1}}async isConfigured(t){return await f.isConfigured(t)}async needsMigration(t){return await f.needsMigration(t)}},F=new C,ct=F;export{M as a,F as b,ct as c};
@@ -0,0 +1,9 @@
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{c as d}from"./chunk-AOPJ4Z6O.mjs";import{e as r,g as f}from"./chunk-HDHVBB6Q.mjs";import{a as m}from"./chunk-E66B27AL.mjs";f();var u=class{static{m(this,"CustomWorkflowStorage")}createWorkflow(t,e){let n=new Date().toISOString();r.run(t,`INSERT INTO custom_workflows (name, description, created_at, updated_at, is_builtin, enabled, metadata)
9
+ VALUES (?, ?, ?, ?, 0, 1, ?)`,e.name,e.description??null,n,n,e.metadata?JSON.stringify(e.metadata):null);let o=r.get(t,"SELECT id FROM custom_workflows WHERE name = ?",e.name);if(!o)throw new Error(`Failed to create workflow: ${e.name}`);return d({projectId:t,entityType:"custom_workflows",entityId:String(o.id),eventType:"upsert",data:{id:o.id,name:e.name,description:e.description??null,metadata:e.metadata??null,created_at:n,updated_at:n,is_builtin:0,enabled:1}}),o.id}getWorkflow(t,e){let n=r.get(t,"SELECT * FROM custom_workflows WHERE name = ?",e);return n?this.rowToWorkflow(n):null}getAllWorkflows(t,e=!1){let n=e?"SELECT * FROM custom_workflows ORDER BY is_builtin DESC, name ASC":"SELECT * FROM custom_workflows WHERE enabled = 1 ORDER BY is_builtin DESC, name ASC";return r.query(t,n).map(l=>this.rowToWorkflow(l))}updateWorkflow(t,e,n){if(!this.getWorkflow(t,e))return!1;let l=new Date().toISOString(),s=[],a=[];if(n.description!==void 0&&(s.push("description = ?"),a.push(n.description)),n.enabled!==void 0&&(s.push("enabled = ?"),a.push(n.enabled?1:0)),n.metadata!==void 0&&(s.push("metadata = ?"),a.push(JSON.stringify(n.metadata))),s.length===0)return!1;s.push("updated_at = ?"),a.push(l),a.push(e),r.run(t,`UPDATE custom_workflows SET ${s.join(", ")} WHERE name = ?`,...a);let i=this.getWorkflow(t,e);return i&&d({projectId:t,entityType:"custom_workflows",entityId:String(i.id),eventType:"upsert",data:{id:i.id,name:i.name,description:i.description??null,enabled:i.enabled?1:0,metadata:i.metadata??null,updated_at:l}}),!0}deleteWorkflow(t,e){let n=this.getWorkflow(t,e);if(!n)return!1;if(n.isBuiltin)throw new Error(`Cannot delete built-in workflow: ${e}`);return r.run(t,"UPDATE custom_workflows SET enabled = 0 WHERE name = ?",e),d({projectId:t,entityType:"custom_workflows",entityId:String(n.id),eventType:"delete",data:{id:n.id,name:e}}),!0}isBuiltin(t,e){return this.getWorkflow(t,e)?.isBuiltin??!1}isReservedName(t){let e=["task","done","ship","sync"],n=["add","rm","gate","list","create","delete","run","help","reset","init"];return e.includes(t)||n.includes(t)}isValidName(t){return/^[a-z0-9-]+$/.test(t)}rowToWorkflow(t){return{id:t.id,name:t.name,description:t.description,createdAt:t.created_at,updatedAt:t.updated_at,isBuiltin:t.is_builtin===1,enabled:t.enabled===1,metadata:t.metadata?JSON.parse(t.metadata):null}}},p=new u;export{p as a};