prjct-cli 3.94.0 → 3.95.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.
- package/CHANGELOG.md +5 -0
- package/README.md +27 -21
- package/dist/bin/hook-chunks/{agent-switch-2U2LOBGR.mjs → agent-switch-4ZJJWKMD.mjs} +1 -1
- package/dist/bin/hook-chunks/{analysis-N4NYGIG3.mjs → analysis-UGHAG2SK.mjs} +3 -3
- package/dist/bin/hook-chunks/{auth-config-SP4PBALR.mjs → auth-config-JIITQ6GY.mjs} +1 -1
- package/dist/bin/hook-chunks/{auto-flush-BN6L6QHO.mjs → auto-flush-CXWTU3RF.mjs} +1 -1
- package/dist/bin/hook-chunks/{capture-gate-FRF2G3IG.mjs → capture-gate-PS6QUXLX.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-7GNWHWOO.mjs → chunk-22AXWLI6.mjs} +1 -1
- package/dist/bin/hook-chunks/chunk-32RX4YGI.mjs +9 -0
- package/dist/bin/hook-chunks/{chunk-OENWCYLF.mjs → chunk-3WQBTXUC.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-QPRNRLG6.mjs → chunk-4HAKTI36.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-4SKJWNKE.mjs → chunk-4KXXDQYI.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-S7HQQILD.mjs → chunk-4NTVXJD7.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-Y4DUB7UN.mjs → chunk-5H3KJWQS.mjs} +2 -2
- package/dist/bin/hook-chunks/{chunk-INXNK57E.mjs → chunk-5XA5RL5I.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-NBKEOLDH.mjs → chunk-6GAFRIUQ.mjs} +5 -5
- package/dist/bin/hook-chunks/{chunk-Q3Z53QTH.mjs → chunk-76GDLA3Z.mjs} +1 -1
- package/dist/bin/hook-chunks/chunk-A6K4H3YT.mjs +9 -0
- package/dist/bin/hook-chunks/{chunk-6RLCUGGG.mjs → chunk-ABJNOG2I.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-EHEQOF6Z.mjs → chunk-B36LC2JR.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-NCOOKPXX.mjs → chunk-BDOAQVIF.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-PUHX3ECX.mjs → chunk-BOBFTVAY.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-AZYQFRPJ.mjs → chunk-BU22R6JX.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-NHIWYDQD.mjs → chunk-BX7VKYA7.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-7JEKBJAP.mjs → chunk-C4O243NG.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-V2BSS7HW.mjs → chunk-CYZ7ST2P.mjs} +5 -5
- package/dist/bin/hook-chunks/{chunk-JMCMTX6U.mjs → chunk-DCSKTMDX.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-J6TAD3OZ.mjs → chunk-DVDZA63F.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-D6IONKRA.mjs → chunk-EWOK4VE7.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-EQ5KNMLG.mjs → chunk-FW4MEPTB.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-2HB2JHQE.mjs → chunk-FXFG6PV6.mjs} +4 -4
- package/dist/bin/hook-chunks/chunk-G7QQZMAO.mjs +9 -0
- package/dist/bin/hook-chunks/{chunk-EMTCZG5I.mjs → chunk-GCDLPKOH.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-X2AGNDGD.mjs → chunk-GDECEHO5.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-JUZ5LNDI.mjs → chunk-GDESYWTD.mjs} +2 -2
- package/dist/bin/hook-chunks/chunk-GLPKMG5A.mjs +18 -0
- package/dist/bin/hook-chunks/chunk-GPZP7NXL.mjs +11 -0
- package/dist/bin/hook-chunks/{chunk-SDUS2AT7.mjs → chunk-HEDZA6KC.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-5EQLQ7GF.mjs → chunk-I26F7TLM.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-HHIGNKDO.mjs → chunk-IGHY4FGS.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-QYEASMFV.mjs → chunk-IWJG7CZX.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-7O6OMD4X.mjs → chunk-J5UQVJUW.mjs} +1 -1
- package/dist/bin/hook-chunks/chunk-J5UVRZ44.mjs +15 -0
- package/dist/bin/hook-chunks/{chunk-GFY4GY3Z.mjs → chunk-KHLYWNHT.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-C3W2HLJT.mjs → chunk-KSSRINDX.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-4O4D6DV7.mjs → chunk-MHNWIB7B.mjs} +2 -2
- package/dist/bin/hook-chunks/{chunk-3VWBNLBC.mjs → chunk-N3L77UNM.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-IHECXD2M.mjs → chunk-NLKPAJND.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-OIU4Y5WL.mjs → chunk-OC4CYF7V.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-Q3EYM4GJ.mjs → chunk-OGIFB3OE.mjs} +2 -2
- package/dist/bin/hook-chunks/{chunk-AVRNHROK.mjs → chunk-OUAVSD47.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-Y3J7UUMR.mjs → chunk-PGWFGRX4.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-AZHE4VOM.mjs → chunk-PO3QDKTE.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-ZMKTR2IO.mjs → chunk-PP6DANGV.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-MHQTGU45.mjs → chunk-PTA7DMLM.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-HRWXMF7P.mjs → chunk-QBYHZX33.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-HNEKXKOI.mjs → chunk-QL3NYJTW.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-UA4Z5TGG.mjs → chunk-QP5USCDX.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-JPSJWCFD.mjs → chunk-RHKF7EJW.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-66GE3IHX.mjs → chunk-ROA2AJXY.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-TG5CQJD5.mjs → chunk-RTEEXGEA.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-YUKGWWL7.mjs → chunk-S5ISOGDB.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-TKWAFYF7.mjs → chunk-S5N2ZZDL.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-F4T7IAA7.mjs → chunk-S6L3FECF.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-JCYXFHQZ.mjs → chunk-T6ELTQZM.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-NWZEBCTC.mjs → chunk-TXSLON7M.mjs} +2 -2
- package/dist/bin/hook-chunks/{chunk-IKIB42F7.mjs → chunk-U4OON3S7.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-KG7Z6OMK.mjs → chunk-UHVYBU7F.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-NWIQNII6.mjs → chunk-UYQC63MC.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-27XFSCOE.mjs → chunk-V2FR2NPL.mjs} +2 -2
- package/dist/bin/hook-chunks/{chunk-XE4MJNBQ.mjs → chunk-WGWE3CSC.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-MI3JEFON.mjs → chunk-X5W2UYQK.mjs} +2 -2
- package/dist/bin/hook-chunks/{chunk-TYEAIX3X.mjs → chunk-XDBJSJOT.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-6UH244CC.mjs → chunk-XXRAQZNC.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-OZJ6UKKP.mjs → chunk-YDBZO6I3.mjs} +1 -1
- package/dist/bin/hook-chunks/chunk-Z4X7JIAP.mjs +11 -0
- package/dist/bin/hook-chunks/{chunk-FX6VHIKB.mjs → chunk-Z6KVLCMK.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-KOCROTRM.mjs → chunk-ZFLIVOFX.mjs} +1 -1
- package/dist/bin/hook-chunks/{chunk-T2FCU3ZS.mjs → chunk-ZOX6OV6X.mjs} +1 -1
- package/dist/bin/hook-chunks/{client-ERZ5CM3D.mjs → client-CRXA774S.mjs} +3 -3
- package/dist/bin/hook-chunks/{code-graph-cloud-4GRWQSUK.mjs → code-graph-cloud-GTSLO7CD.mjs} +1 -1
- package/dist/bin/hook-chunks/{codex-skill-6DYQMPDJ.mjs → codex-skill-NUBNPSMF.mjs} +1 -1
- package/dist/bin/hook-chunks/{command-installer-MF4KUM3X.mjs → command-installer-UHSXC3UG.mjs} +1 -1
- package/dist/bin/hook-chunks/{config-manager-2VZPHUDG.mjs → config-manager-DX5OOPW5.mjs} +1 -1
- package/dist/bin/hook-chunks/{context7-service-V7CIDF3Q.mjs → context7-service-GDJ3QICX.mjs} +1 -1
- package/dist/bin/hook-chunks/{custom-workflow-storage-UOBQXY42.mjs → custom-workflow-storage-FD47DPA3.mjs} +1 -1
- package/dist/bin/hook-chunks/cwd-changed-EP3UIRK6.mjs +8 -0
- package/dist/bin/hook-chunks/{database-XYKQF3KR.mjs → database-ZUC7OEZG.mjs} +1 -1
- package/dist/bin/hook-chunks/{detect-changes-DFRJOOB3.mjs → detect-changes-OJUBWWTU.mjs} +1 -1
- package/dist/bin/hook-chunks/{developer-evolution-SLC34HUU.mjs → developer-evolution-WNSTHDAA.mjs} +1 -1
- package/dist/bin/hook-chunks/{distill-U2LJGUG3.mjs → distill-GOGPFQFK.mjs} +1 -1
- package/dist/bin/hook-chunks/{editors-config-6XFYIOE6.mjs → editors-config-2CACBNS4.mjs} +1 -1
- package/dist/bin/hook-chunks/{enriched-recall-X6RDNNIE.mjs → enriched-recall-QF22RIK7.mjs} +1 -1
- package/dist/bin/hook-chunks/{format-ALUX4QSI.mjs → format-J3X3R225.mjs} +1 -1
- package/dist/bin/hook-chunks/{judgment-ledger-storage-SCGU3URM.mjs → judgment-ledger-storage-FE4HXTHM.mjs} +1 -1
- package/dist/bin/hook-chunks/{judgment-orchestrator-BYPG65RS.mjs → judgment-orchestrator-YDJTKNV2.mjs} +1 -1
- package/dist/bin/hook-chunks/{judgment-receipt-GWSSCLAB.mjs → judgment-receipt-7A2DXVJA.mjs} +1 -1
- package/dist/bin/hook-chunks/{land-cue-MMISX2BI.mjs → land-cue-SZWJH6XP.mjs} +1 -1
- package/dist/bin/hook-chunks/{land-synthesis-WG5JAS7B.mjs → land-synthesis-JLYUBKHR.mjs} +1 -1
- package/dist/bin/hook-chunks/{legacy-crew-sweep-2WSO5KEB.mjs → legacy-crew-sweep-JXYO62UE.mjs} +2 -2
- package/dist/bin/hook-chunks/{memory-index-QK5QJOFJ.mjs → memory-index-CIYDXN2G.mjs} +1 -1
- package/dist/bin/hook-chunks/{notification-MPVWVV52.mjs → notification-UA7RTVHG.mjs} +1 -1
- package/dist/bin/hook-chunks/{pack-integrity-XRYOROK5.mjs → pack-integrity-GZC5NGFN.mjs} +1 -1
- package/dist/bin/hook-chunks/{pack-manager-WWGQNJDQ.mjs → pack-manager-AF5F7PRT.mjs} +1 -1
- package/dist/bin/hook-chunks/{path-manager-ZR5RAKTK.mjs → path-manager-375HH6TB.mjs} +1 -1
- package/dist/bin/hook-chunks/{planning-S55KBPN2.mjs → planning-M3RAOZVB.mjs} +2 -2
- package/dist/bin/hook-chunks/{post-edit-QMHSZHDN.mjs → post-edit-QRDYPZLZ.mjs} +1 -1
- package/dist/bin/hook-chunks/{pre-bash-RAM6L3G4.mjs → pre-bash-TWWFVNQ7.mjs} +1 -1
- package/dist/bin/hook-chunks/{pre-commit-736ZLMDL.mjs → pre-commit-PTFF7JIN.mjs} +1 -1
- package/dist/bin/hook-chunks/{pre-edit-GZ4QJ2MU.mjs → pre-edit-PMMWDR2B.mjs} +1 -1
- package/dist/bin/hook-chunks/{pre-package-LCIAWWGK.mjs → pre-package-325ALZKD.mjs} +1 -1
- package/dist/bin/hook-chunks/{pre-search-J5EOFMYN.mjs → pre-search-GOHVFAFH.mjs} +1 -1
- package/dist/bin/hook-chunks/{pre-secrets-TSUMTXHH.mjs → pre-secrets-MYNM5KI4.mjs} +1 -1
- package/dist/bin/hook-chunks/{prjct-md-T2DG236Y.mjs → prjct-md-RCB6FWD6.mjs} +1 -1
- package/dist/bin/hook-chunks/{project-agent-surfaces-VRY22I66.mjs → project-agent-surfaces-V4P5RTUR.mjs} +1 -1
- package/dist/bin/hook-chunks/{project-file-inventory-5DEN5VLF.mjs → project-file-inventory-OKIP4LBO.mjs} +1 -1
- package/dist/bin/hook-chunks/{project-memory-KKEMTEMP.mjs → project-memory-JK2MXRJB.mjs} +1 -1
- package/dist/bin/hook-chunks/{project-style-evolution-7MAUSED2.mjs → project-style-evolution-RPGATIYJ.mjs} +1 -1
- package/dist/bin/hook-chunks/prompt-DOENKHLQ.mjs +24 -0
- package/dist/bin/hook-chunks/{publish-helper-G54XQV5K.mjs → publish-helper-SX7HEV2L.mjs} +1 -1
- package/dist/bin/hook-chunks/{purge-MC5LFSAO.mjs → purge-XKHUAB4H.mjs} +1 -1
- package/dist/bin/hook-chunks/{retention-LWETHQX3.mjs → retention-C3NQT65W.mjs} +1 -1
- package/dist/bin/hook-chunks/{sdd-5UCVX43H.mjs → sdd-6PF7MBAY.mjs} +1 -1
- package/dist/bin/hook-chunks/{session-continuity-RKNAJJHR.mjs → session-continuity-UEXQDGZE.mjs} +1 -1
- package/dist/bin/hook-chunks/session-start-B4P7L33E.mjs +8 -0
- package/dist/bin/hook-chunks/{setup-WQRJ6TQL.mjs → setup-ZOHG6MGF.mjs} +3 -3
- package/dist/bin/hook-chunks/{shipping-5D5LTJ3P.mjs → shipping-QVGTOO6U.mjs} +4 -4
- package/dist/bin/hook-chunks/{skill-index-RAVJMC4P.mjs → skill-index-FGDQVYHM.mjs} +1 -1
- package/dist/bin/hook-chunks/{spec-context-inference-7DDSTRTV.mjs → spec-context-inference-6Z52BT37.mjs} +1 -1
- package/dist/bin/hook-chunks/{spec-service-LAO5Z2M5.mjs → spec-service-UAQ5AEXQ.mjs} +2 -2
- package/dist/bin/hook-chunks/{spec-task-breakdown-K3GMQKGH.mjs → spec-task-breakdown-LAXGVLMY.mjs} +1 -1
- package/dist/bin/hook-chunks/{state-storage-EIFGUO7X.mjs → state-storage-XU35ZYNA.mjs} +1 -1
- package/dist/bin/hook-chunks/stop-CFB2H3XC.mjs +16 -0
- package/dist/bin/hook-chunks/subagent-start-KFAZZUHS.mjs +8 -0
- package/dist/bin/hook-chunks/{subagent-stop-RBD2OILE.mjs → subagent-stop-OUG4PR7S.mjs} +1 -1
- package/dist/bin/hook-chunks/{surface-attribution-K37N2NK7.mjs → surface-attribution-A6GCGRFM.mjs} +1 -1
- package/dist/bin/hook-chunks/{symbol-graph-BKQIMFRG.mjs → symbol-graph-DMPBNBX7.mjs} +1 -1
- package/dist/bin/hook-chunks/{sync-client-EGBMWF3J.mjs → sync-client-PIRHMHXL.mjs} +1 -1
- package/dist/bin/hook-chunks/{sync-cursor-storage-E3LMZISA.mjs → sync-cursor-storage-VVLA3L2U.mjs} +1 -1
- package/dist/bin/hook-chunks/{task-orchestration-2ZYE5M6J.mjs → task-orchestration-HFZYWYLR.mjs} +1 -1
- package/dist/bin/hook-chunks/{task-overview-ITY5OSHX.mjs → task-overview-PCUZWL5Q.mjs} +1 -1
- package/dist/bin/hook-chunks/task-service-PXCDU55T.mjs +8 -0
- package/dist/bin/hook-chunks/{tdd-7S55S5C3.mjs → tdd-QZL4OSM7.mjs} +1 -1
- package/dist/bin/hook-chunks/{template-loader-SCM4C2A3.mjs → template-loader-SKXILJLJ.mjs} +1 -1
- package/dist/bin/hook-chunks/{transcript-jsonl-6X4DDD6R.mjs → transcript-jsonl-7W2NOJPZ.mjs} +1 -1
- package/dist/bin/hook-chunks/{usefulness-SCH5ARGV.mjs → usefulness-SZLG6LVC.mjs} +1 -1
- package/dist/bin/hook-chunks/{vault-retire-notice-HT756AND.mjs → vault-retire-notice-HOXPURNQ.mjs} +1 -1
- package/dist/bin/hook-chunks/{velocity-storage-47CF3XWZ.mjs → velocity-storage-5J6BAMCW.mjs} +1 -1
- package/dist/bin/hook-chunks/{weak-model-mode-FLCEQ2BV.mjs → weak-model-mode-ZRNKFTFF.mjs} +1 -1
- package/dist/bin/hook-chunks/{work-graph-JQHVVXIZ.mjs → work-graph-PGYHFLEL.mjs} +1 -1
- package/dist/bin/hook-chunks/work-scope-FIB6LBKE.mjs +8 -0
- package/dist/bin/hook-chunks/{workspace-occupancy-UUW4UGGB.mjs → workspace-occupancy-3D4OKQRB.mjs} +1 -1
- package/dist/bin/hook-fast-darwin-arm64 +0 -0
- package/dist/bin/hook-fast-darwin-x64 +0 -0
- package/dist/bin/hook-fast-linux-x64 +0 -0
- package/dist/bin/prjct-core.mjs +681 -668
- package/dist/bin/prjct-hooks.mjs +1 -1
- package/dist/bin/prjct.mjs +1 -1
- package/dist/daemon/entry.mjs +595 -582
- package/dist/mcp/server.mjs +232 -232
- package/package.json +1 -1
- package/dist/bin/hook-chunks/chunk-DRGI5UHQ.mjs +0 -10
- package/dist/bin/hook-chunks/chunk-JAMSIKDE.mjs +0 -9
- package/dist/bin/hook-chunks/chunk-NUJASVHN.mjs +0 -18
- package/dist/bin/hook-chunks/chunk-PW3KYKVS.mjs +0 -9
- package/dist/bin/hook-chunks/chunk-TFCLMTJ5.mjs +0 -9
- package/dist/bin/hook-chunks/chunk-VWOIUTAX.mjs +0 -15
- package/dist/bin/hook-chunks/chunk-ZJXH76Q5.mjs +0 -11
- package/dist/bin/hook-chunks/cwd-changed-J6O46KS7.mjs +0 -8
- package/dist/bin/hook-chunks/prompt-DVF6V2X2.mjs +0 -22
- package/dist/bin/hook-chunks/session-start-MFMFKUPK.mjs +0 -8
- package/dist/bin/hook-chunks/stop-RYLI4FGF.mjs +0 -16
- package/dist/bin/hook-chunks/subagent-start-CCUPSANT.mjs +0 -8
- package/dist/bin/hook-chunks/task-service-XREJLWEF.mjs +0 -8
- package/dist/bin/hook-chunks/work-scope-CDLSZ4U5.mjs +0 -8
|
@@ -5,17 +5,17 @@ import { dirname as __pathDirname } from 'path';
|
|
|
5
5
|
const require = __createRequire(import.meta.url);
|
|
6
6
|
const __filename = __fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __pathDirname(__filename);
|
|
8
|
-
import{b as jt}from"./chunk-
|
|
8
|
+
import{b as jt}from"./chunk-PGWFGRX4.mjs";import{a as St,b as wt,c as kt,d as vt,e as bt}from"./chunk-TXJT3G53.mjs";import{a as ft}from"./chunk-G7QQZMAO.mjs";import{a as Ke}from"./chunk-ROA2AJXY.mjs";import{a as qe}from"./chunk-DVDZA63F.mjs";import{a as Ye}from"./chunk-ZOX6OV6X.mjs";import{a as Qe,b as At}from"./chunk-MHNWIB7B.mjs";import{a as gt,b as ht}from"./chunk-GDESYWTD.mjs";import{d as yt}from"./chunk-UYQC63MC.mjs";import{a as Pt,b as Ct,c as xt,d as Dt}from"./chunk-LNB2GLYI.mjs";import{a as p}from"./chunk-DYHYDHCW.mjs";import{a as ut}from"./chunk-JR542RI2.mjs";import{b as q,c as st,d as nt}from"./chunk-IGHY4FGS.mjs";import{a as at,b as ot,e as it,f as ct,g as ae,h as lt,i as dt}from"./chunk-22AXWLI6.mjs";import{a as mt}from"./chunk-J5UVRZ44.mjs";import{i as pt}from"./chunk-6GAFRIUQ.mjs";import{a as rt}from"./chunk-KHLYWNHT.mjs";import{b as Ze,c as et,d as tt}from"./chunk-DCSKTMDX.mjs";import{b as se}from"./chunk-R4ILCXKE.mjs";import{a as Xe}from"./chunk-S5ISOGDB.mjs";import{a as ne,b as I}from"./chunk-XXRAQZNC.mjs";import{a as Be}from"./chunk-5XA5RL5I.mjs";import{c as Je}from"./chunk-I26F7TLM.mjs";import{b as Ve}from"./chunk-QP5USCDX.mjs";import{a as We,b as Ue}from"./chunk-M5E2YOZ4.mjs";import{b as M}from"./chunk-PO3QDKTE.mjs";import{d as b,e as T,g as B}from"./chunk-UHVYBU7F.mjs";import{d as re}from"./chunk-4KXXDQYI.mjs";import{b as v,h as te,p as He,r as Le,u as Ar,v as J,w as Ge}from"./chunk-A6K4H3YT.mjs";import{b as Ne,f as jr}from"./chunk-HDSS6UB3.mjs";import{d as _e,e as $e,f as Oe,k as N,o as V}from"./chunk-UH4MD3F3.mjs";import{a as Me,p as Dr}from"./chunk-QWQFF2UG.mjs";import{a as ze}from"./chunk-FW4MEPTB.mjs";import{d as w}from"./chunk-PKDYFXMI.mjs";import{a as R,d as Fe,e as k,f as $}from"./chunk-BUDZL4DW.mjs";import{a as i}from"./chunk-E66B27AL.mjs";function It(r,e){let t=[];H("Languages",r.languages,e.languages,t),H("Frameworks",r.frameworks,e.frameworks,t),(r.packageManager??"")!==(e.packageManager??"")&&t.push({field:"Package manager",type:"changed",before:r.packageManager??"(none)",after:e.packageManager??"(none)"}),(r.sourceDir??"")!==(e.sourceDir??"")&&t.push({field:"Source directory",type:"changed",before:r.sourceDir??"(none)",after:e.sourceDir??"(none)"}),(r.testDir??"")!==(e.testDir??"")&&t.push({field:"Test directory",type:"changed",before:r.testDir??"(none)",after:e.testDir??"(none)"}),H("Config files",r.configFiles,e.configFiles,t),r.fileCount!==e.fileCount&&t.push({field:"File count",type:"changed",before:String(r.fileCount),after:String(e.fileCount)});let s=r.patterns.map(c=>c.name),a=e.patterns.map(c=>c.name);H("Patterns",s,a,t);let o=r.antiPatterns.map(c=>c.issue),n=e.antiPatterns.map(c=>c.issue);return H("Anti-patterns",o,n,t),ut(t,r.commitHash??null,e.commitHash??null)}i(It,"generateAnalysisDiff");function vs(r){if(!r.hasChanges)return`## Analysis Diff
|
|
9
9
|
|
|
10
10
|
No changes between runs.`;let e=[];e.push("## Analysis Diff"),(r.beforeCommit||r.afterCommit)&&e.push(`> \`${r.beforeCommit?.substring(0,7)??"(none)"}\` \u2192 \`${r.afterCommit?.substring(0,7)??"(none)"}\``),e.push(""),e.push("| Change | Field | Detail |"),e.push("|--------|-------|--------|");for(let s of r.items){let a=s.type==="added"?"+":s.type==="removed"?"-":"~",o=s.type==="changed"?`${s.before} \u2192 ${s.after}`:s.after??s.before??"";e.push(`| ${a} | ${s.field} | ${o} |`)}e.push("");let t=[];return r.summary.added>0&&t.push(`${r.summary.added} added`),r.summary.removed>0&&t.push(`${r.summary.removed} removed`),r.summary.changed>0&&t.push(`${r.summary.changed} changed`),e.push(`**Summary**: ${t.join(", ")}`),e.join(`
|
|
11
11
|
`)}i(vs,"formatAnalysisDiffMd");function bs(r){if(!r.hasChanges)return"No changes between analysis runs.";let e=[];(r.beforeCommit||r.afterCommit)&&(e.push(` ${r.beforeCommit?.substring(0,7)??"(none)"} \u2192 ${r.afterCommit?.substring(0,7)??"(none)"}`),e.push(""));for(let t of r.items)t.type==="added"?e.push(` + ${t.field}: ${t.after}`):t.type==="removed"?e.push(` - ${t.field}: ${t.before}`):e.push(` ~ ${t.field}: ${t.before} \u2192 ${t.after}`);return e.join(`
|
|
12
|
-
`)}i(bs,"formatAnalysisDiffText");function H(r,e,t,s){let a=new Set(e),o=new Set(t);for(let n of t)a.has(n)||s.push({field:r,type:"added",after:n});for(let n of e)o.has(n)||s.push({field:r,type:"removed",before:n})}i(H,"diffStringArray");$();V();import oe from"node:fs/promises";import E from"node:path";import{z as f}from"zod";function K(r,e){let t=r.filter(a=>!a.passed).length,s=r.filter(a=>a.passed).length;return{passed:t===0,checks:r,totalMs:Date.now()-e,failedCount:t,passedCount:s}}i(K,"summarizeChecks");jr();var Ir=f.enum(["draft","verified","sealed"]),Et=f.object({severity:f.enum(["low","medium","high"]).optional(),language:f.string().optional(),framework:f.string().optional(),source:f.enum(["baseline","repo","context7","feedback"]).optional(),confidence:f.number().min(0).max(1).optional()}),Er=f.object({name:f.string(),description:f.string(),location:f.string().optional()}).extend(Et.shape),Rr=f.object({issue:f.string(),file:f.string(),suggestion:f.string()}).extend(Et.shape),ie=f.object({projectId:f.string(),languages:f.array(f.string()),frameworks:f.array(f.string()),packageManager:f.string().optional(),sourceDir:f.string().optional(),testDir:f.string().optional(),configFiles:f.array(f.string()),fileCount:f.number(),patterns:f.array(Er),antiPatterns:f.array(Rr),analyzedAt:f.string(),modelMetadata:Ne.optional(),status:Ir.default("draft"),commitHash:f.string().optional(),signature:f.string().optional(),sealedAt:f.string().optional(),verifiedAt:f.string().optional()});var Tr={TypeScript:[".ts",".tsx",".mts",".cts"],JavaScript:[".js",".jsx",".mjs",".cjs"],Python:[".py",".pyw"],Java:[".java"],Go:[".go"],Rust:[".rs"],Ruby:[".rb"],PHP:[".php"],Swift:[".swift"],Kotlin:[".kt",".kts"],"C++":[".cpp",".cc",".cxx",".hpp",".h"],C:[".c",".h"],"C#":[".cs"],Elixir:[".ex",".exs"],Scala:[".scala"]};async function Mr(r,e){let t=Date.now();if(r.frameworks.length===0)return{name:"Framework verification",passed:!0,output:"No frameworks declared (skipped)",durationMs:Date.now()-t};try{let s=E.join(e,"package.json"),a=await oe.readFile(s,"utf-8"),o=JSON.parse(a),n={...o.dependencies,...o.devDependencies},c=[],l=[];for(let d of r.frameworks){let m=d.toLowerCase();Object.keys(n).some(y=>y.toLowerCase().includes(m))?l.push(d):c.push(d)}return c.length===0?{name:"Framework verification",passed:!0,output:`${l.length} framework(s) verified in dependencies`,durationMs:Date.now()-t}:{name:"Framework verification",passed:!1,error:`Frameworks not found in dependencies: ${c.join(", ")}`,durationMs:Date.now()-t}}catch(s){return R(s)?{name:"Framework verification",passed:!1,error:"package.json not found (cannot verify frameworks)",durationMs:Date.now()-t}:{name:"Framework verification",passed:!1,error:`Failed to read package.json: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i(Mr,"verifyFrameworks");async function Fr(r,e){let t=Date.now();if(r.languages.length===0)return{name:"Language verification",passed:!0,output:"No languages declared (skipped)",durationMs:Date.now()-t};try{let s=await Nr(e),a=new Set(s),o=[],n=[];for(let c of r.languages){let l=Tr[c];if(!l)continue;l.some(m=>a.has(m))?o.push(c):n.push(c)}return n.length===0?{name:"Language verification",passed:!0,output:`${o.length} language(s) verified with matching files`,durationMs:Date.now()-t}:{name:"Language verification",passed:!1,error:`Languages without matching files: ${n.join(", ")}`,durationMs:Date.now()-t}}catch(s){return{name:"Language verification",passed:!1,error:`Failed to scan project files: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i(Fr,"verifyLanguages");async function _r(r,e){let t=Date.now(),s=r.patterns.filter(n=>n.location);if(s.length===0)return{name:"Pattern location verification",passed:!0,output:"No pattern locations specified (skipped)",durationMs:Date.now()-t};let a=[],o=[];for(let n of s){let c=n.location,l=E.join(e,c);await N(l)?o.push(c):a.push(`${n.name} (${c})`)}return a.length===0?{name:"Pattern location verification",passed:!0,output:`${o.length} pattern location(s) verified`,durationMs:Date.now()-t}:{name:"Pattern location verification",passed:!1,error:`Pattern locations not found: ${a.join(", ")}`,durationMs:Date.now()-t}}i(_r,"verifyPatternLocations");async function $r(r,e){let t=Date.now();try{let s=await Hr(e),a=r.fileCount,o=.1,n=Math.abs(s-a),c=a*o;return n<=c?{name:"File count verification",passed:!0,output:`File count accurate (declared: ${a}, actual: ${s})`,durationMs:Date.now()-t}:{name:"File count verification",passed:!1,error:`File count mismatch: declared ${a}, actual ${s} (diff: ${n})`,durationMs:Date.now()-t}}catch(s){return{name:"File count verification",passed:!1,error:`Failed to count files: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i($r,"verifyFileCount");async function Or(r,e){let t=Date.now();if(r.antiPatterns.length===0)return{name:"Anti-pattern file verification",passed:!0,output:"No anti-patterns declared (skipped)",durationMs:Date.now()-t};let s=[],a=[];for(let o of r.antiPatterns){let n=E.join(e,o.file);await N(n)?a.push(o.file):s.push(`${o.issue} (${o.file})`)}return s.length===0?{name:"Anti-pattern file verification",passed:!0,output:`${a.length} anti-pattern file(s) verified`,durationMs:Date.now()-t}:{name:"Anti-pattern file verification",passed:!1,error:`Anti-pattern files not found: ${s.join(", ")}`,durationMs:Date.now()-t}}i(Or,"verifyAntiPatternFiles");async function Rt(r,e){let t=Date.now(),s=await Promise.all([Mr(r,e),Fr(r,e),_r(r,e),$r(r,e),Or(r,e)]);return K(s,t)}i(Rt,"semanticVerify");async function Nr(r){let e=new Set,t=[/node_modules/,/\.git/,/dist/,/build/,/\.next/,/\.turbo/,/coverage/];async function s(a){try{let o=await oe.readdir(a,{withFileTypes:!0});for(let n of o){let c=E.join(a,n.name),l=E.relative(r,c);if(!t.some(d=>d.test(l))){if(n.isDirectory())await s(c);else if(n.isFile()){let d=E.extname(n.name);d&&e.add(d)}}}}catch{}}return i(s,"scanDir"),await s(r),Array.from(e)}i(Nr,"getProjectExtensions");async function Hr(r){let e=[/node_modules/,/\.git/,/dist/,/build/,/\.next/,/\.turbo/,/coverage/];async function t(s){try{let a=await oe.readdir(s,{withFileTypes:!0});return(await Promise.all(a.map(async n=>{let c=E.join(s,n.name),l=E.relative(r,c);return e.some(d=>d.test(l))?0:n.isDirectory()?t(c):n.isFile()?1:0}))).reduce((n,c)=>n+c,0)}catch{return 0}}return i(t,"scanDir"),t(r)}i(Hr,"countProjectFiles");te();var ce=class extends Be{static{i(this,"AnalysisStorage")}constructor(){super("analysis.json")}getDefault(){return{draft:null,sealed:null,previousSealed:null,lastUpdated:""}}getEventType(e){return`analysis.${e}d`}async saveDraft(e,t){let s={...t,status:"draft"};ie.parse(s),await this.update(e,a=>({...a,draft:s,lastUpdated:v()})),this.publishAnalysis(e,s)}publishAnalysis(e,t){Ve({projectId:e,entityType:"analysis",entityId:e,eventType:"upsert",data:{...t,id:e}})}async seal(e){let t=await this.read(e);if(!t.draft)return{success:!1,error:"No draft analysis to seal. Run `p. sync` first."};if(t.draft.status==="sealed")return{success:!1,error:"Draft is already sealed."};let s=this.computeSignature(t.draft),a=v(),o={...t.draft,status:"sealed",signature:s,sealedAt:a};return ie.parse(o),await this.write(e,{draft:null,sealed:o,previousSealed:t.sealed,lastUpdated:a}),this.publishAnalysis(e,o),{success:!0,signature:s}}async getSealed(e){return(await this.read(e)).sealed}async getDraft(e){return(await this.read(e)).draft}async getActive(e){let t=await this.read(e);return t.sealed??t.draft}async getStatus(e){let t=await this.read(e);return{hasSealed:t.sealed!==null,hasDraft:t.draft!==null,hasPreviousSealed:t.previousSealed!==null,sealedCommit:t.sealed?.commitHash??null,draftCommit:t.draft?.commitHash??null,previousSealedCommit:t.previousSealed?.commitHash??null,sealedAt:t.sealed?.sealedAt??null}}async rollback(e){let t=await this.read(e);if(!t.previousSealed)return{success:!1,error:"No previous sealed version to rollback to."};let s=v();return await this.write(e,{draft:t.sealed,sealed:t.previousSealed,previousSealed:null,lastUpdated:s}),this.publishAnalysis(e,t.previousSealed),{success:!0,restoredSignature:t.previousSealed.signature}}async diff(e){let t=await this.read(e);return!t.sealed||!t.draft?null:It(t.sealed,t.draft)}checkStaleness(e,t){return e?t?e!==t?{isStale:!0,sealedCommit:e,currentCommit:t,message:`Analysis is stale: sealed at ${e}, HEAD is ${t}. Run \`p. sync\` + \`p. seal\` to update.`}:{isStale:!1,sealedCommit:e,currentCommit:t,message:"Analysis is current."}:{isStale:!0,sealedCommit:e,currentCommit:null,message:"Cannot determine current commit. Analysis may be stale."}:{isStale:!1,sealedCommit:null,currentCommit:t,message:"No sealed analysis. Run `p. sync` then `p. seal`."}}async verify(e){let t=await this.read(e);if(!t.sealed)return{valid:!1,message:"No sealed analysis to verify."};if(!t.sealed.signature)return{valid:!1,message:"Sealed analysis has no signature."};let s=this.computeSignature({...t.sealed,signature:void 0,sealedAt:void 0});return s===t.sealed.signature?{valid:!0,message:"Signature verified. Analysis integrity confirmed."}:{valid:!1,message:`Signature mismatch. Expected ${s}, got ${t.sealed.signature}. Analysis may have been modified.`}}async semanticVerify(e,t){let s=await this.read(e),a=s.sealed??s.draft;return a?await Rt(a,t):{passed:!1,checks:[{name:"Analysis availability",passed:!1,error:"No analysis available. Run `p. sync` to generate.",durationMs:0}],totalMs:0,failedCount:1,passedCount:0}}computeSignature(e){let t={projectId:e.projectId,languages:e.languages,frameworks:e.frameworks,packageManager:e.packageManager,sourceDir:e.sourceDir,testDir:e.testDir,configFiles:e.configFiles,fileCount:e.fileCount,patterns:e.patterns,antiPatterns:e.antiPatterns,analyzedAt:e.analyzedAt,commitHash:e.commitHash};return We(JSON.stringify(t))}},Y=new ce;import hs from"node:fs/promises";import Z from"node:path";Ar();Ge();V();import le from"node:fs/promises";import Tt from"node:path";import{gunzipSync as Lr,gzipSync as Gr}from"node:zlib";Ge();B();var zr="code-graph.json.gz";function Mt(r){return Tt.join(J.getGlobalProjectPath(r),zr)}i(Mt,"artifactPath");async function Wr(r){if(!ae(r))return null;let e=dt(r),t=ot(r),s=lt(r)??{symbolCount:e.length,edgeCount:t.length,fileCount:new Set(e.map(l=>l.file)).size,builtAt:new Date().toISOString()},a={version:1,projectId:r,exportedAt:new Date().toISOString(),meta:s,symbols:e,edges:t},o=Buffer.from(JSON.stringify(a),"utf-8"),n=Gr(o,{level:6}),c=Mt(r);return await le.mkdir(Tt.dirname(c),{recursive:!0}),await le.writeFile(c,n),{path:c,bytes:n.length,symbols:e.length,edges:t.length}}i(Wr,"exportCodeGraphArtifact");async function Ur(r){let e=Mt(r),t=await le.readFile(e).catch(()=>null);if(!t)return{imported:!1,symbols:0,edges:0,reason:"no per-project artifact"};let s=(()=>{try{let o=Lr(t).toString("utf-8");return{payload:JSON.parse(o)}}catch(o){return{error:`corrupt artifact: ${o instanceof Error?o.message:String(o)}`}}})();if("error"in s)return{imported:!1,symbols:0,edges:0,reason:s.error};let a=s.payload;return a.version!==1||!Array.isArray(a.symbols)?{imported:!1,symbols:0,edges:0,reason:"unsupported artifact version"}:a.projectId&&a.projectId!==r?{imported:!1,symbols:0,edges:0,reason:`artifact projectId mismatch (got ${a.projectId}, expected ${r})`}:(at(r,{symbols:a.symbols,edges:a.edges}),T.setDoc(r,"symbol-graph",{...a.meta,builtAt:a.meta.builtAt??a.exportedAt}),{imported:!0,symbols:a.symbols.length,edges:a.edges.length})}i(Ur,"importCodeGraphArtifact");async function Ft(r){if(ae(r))return{bootstrapped:!1,detail:"local index already present"};let e=await Ur(r);return e.imported?{bootstrapped:!0,detail:`imported ${e.symbols} symbols / ${e.edges} edges from per-project cache`}:{bootstrapped:!1,detail:e.reason??"import failed"}}i(Ft,"bootstrapCodeGraphFromArtifact");function _t(r){return r?.cloud?.enabled===!0&&r.cloud.paused!==!0}i(_t,"shouldAutoUploadCodeGraph");async function $t(r,e){try{await Wr(r)}catch{}if(e.uploadToCloud)try{await Vr(r,e.uploadDependencies)}catch{}}i($t,"maybeExportAfterIndex");async function Vr(r,e={}){let t=await import("./code-graph-cloud-4GRWQSUK.mjs"),s=(e.buildSnapshot??t.buildCloudCodeGraphSnapshot)(r);if(!t.isUploadableGraph(s))return{uploaded:!1,reason:"no symbol index or empty graph"};try{let o=await(e.upload??(async(n,c)=>{let{default:l}=await import("./sync-client-EGBMWF3J.mjs");return l.uploadCodeGraph(n,c)}))(r,s);return o.ok?{uploaded:!0,nodes:o.nodes??s.nodes.length,links:o.links??s.links.length}:{uploaded:!1,reason:o.reason??"upload failed or unauthenticated",nodes:s.nodes.length,links:s.links.length}}catch(a){return{uploaded:!1,reason:a instanceof Error?a.message:String(a)}}}i(Vr,"maybeUploadCodeGraphToCloud");import F from"node:fs/promises";import Jr from"node:os";import x from"node:path";var de=[{name:"prjct",description:St,allowedTools:[...wt],body:i(()=>vt(),"body"),reference:i(()=>bt(),"reference"),referenceFile:kt}];function Br(r){let e=r.userInvocable!==!1;return`---
|
|
12
|
+
`)}i(bs,"formatAnalysisDiffText");function H(r,e,t,s){let a=new Set(e),o=new Set(t);for(let n of t)a.has(n)||s.push({field:r,type:"added",after:n});for(let n of e)o.has(n)||s.push({field:r,type:"removed",before:n})}i(H,"diffStringArray");$();V();import oe from"node:fs/promises";import E from"node:path";import{z as f}from"zod";function K(r,e){let t=r.filter(a=>!a.passed).length,s=r.filter(a=>a.passed).length;return{passed:t===0,checks:r,totalMs:Date.now()-e,failedCount:t,passedCount:s}}i(K,"summarizeChecks");jr();var Ir=f.enum(["draft","verified","sealed"]),Et=f.object({severity:f.enum(["low","medium","high"]).optional(),language:f.string().optional(),framework:f.string().optional(),source:f.enum(["baseline","repo","context7","feedback"]).optional(),confidence:f.number().min(0).max(1).optional()}),Er=f.object({name:f.string(),description:f.string(),location:f.string().optional()}).extend(Et.shape),Rr=f.object({issue:f.string(),file:f.string(),suggestion:f.string()}).extend(Et.shape),ie=f.object({projectId:f.string(),languages:f.array(f.string()),frameworks:f.array(f.string()),packageManager:f.string().optional(),sourceDir:f.string().optional(),testDir:f.string().optional(),configFiles:f.array(f.string()),fileCount:f.number(),patterns:f.array(Er),antiPatterns:f.array(Rr),analyzedAt:f.string(),modelMetadata:Ne.optional(),status:Ir.default("draft"),commitHash:f.string().optional(),signature:f.string().optional(),sealedAt:f.string().optional(),verifiedAt:f.string().optional()});var Tr={TypeScript:[".ts",".tsx",".mts",".cts"],JavaScript:[".js",".jsx",".mjs",".cjs"],Python:[".py",".pyw"],Java:[".java"],Go:[".go"],Rust:[".rs"],Ruby:[".rb"],PHP:[".php"],Swift:[".swift"],Kotlin:[".kt",".kts"],"C++":[".cpp",".cc",".cxx",".hpp",".h"],C:[".c",".h"],"C#":[".cs"],Elixir:[".ex",".exs"],Scala:[".scala"]};async function Mr(r,e){let t=Date.now();if(r.frameworks.length===0)return{name:"Framework verification",passed:!0,output:"No frameworks declared (skipped)",durationMs:Date.now()-t};try{let s=E.join(e,"package.json"),a=await oe.readFile(s,"utf-8"),o=JSON.parse(a),n={...o.dependencies,...o.devDependencies},c=[],l=[];for(let d of r.frameworks){let m=d.toLowerCase();Object.keys(n).some(y=>y.toLowerCase().includes(m))?l.push(d):c.push(d)}return c.length===0?{name:"Framework verification",passed:!0,output:`${l.length} framework(s) verified in dependencies`,durationMs:Date.now()-t}:{name:"Framework verification",passed:!1,error:`Frameworks not found in dependencies: ${c.join(", ")}`,durationMs:Date.now()-t}}catch(s){return R(s)?{name:"Framework verification",passed:!1,error:"package.json not found (cannot verify frameworks)",durationMs:Date.now()-t}:{name:"Framework verification",passed:!1,error:`Failed to read package.json: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i(Mr,"verifyFrameworks");async function Fr(r,e){let t=Date.now();if(r.languages.length===0)return{name:"Language verification",passed:!0,output:"No languages declared (skipped)",durationMs:Date.now()-t};try{let s=await Nr(e),a=new Set(s),o=[],n=[];for(let c of r.languages){let l=Tr[c];if(!l)continue;l.some(m=>a.has(m))?o.push(c):n.push(c)}return n.length===0?{name:"Language verification",passed:!0,output:`${o.length} language(s) verified with matching files`,durationMs:Date.now()-t}:{name:"Language verification",passed:!1,error:`Languages without matching files: ${n.join(", ")}`,durationMs:Date.now()-t}}catch(s){return{name:"Language verification",passed:!1,error:`Failed to scan project files: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i(Fr,"verifyLanguages");async function _r(r,e){let t=Date.now(),s=r.patterns.filter(n=>n.location);if(s.length===0)return{name:"Pattern location verification",passed:!0,output:"No pattern locations specified (skipped)",durationMs:Date.now()-t};let a=[],o=[];for(let n of s){let c=n.location,l=E.join(e,c);await N(l)?o.push(c):a.push(`${n.name} (${c})`)}return a.length===0?{name:"Pattern location verification",passed:!0,output:`${o.length} pattern location(s) verified`,durationMs:Date.now()-t}:{name:"Pattern location verification",passed:!1,error:`Pattern locations not found: ${a.join(", ")}`,durationMs:Date.now()-t}}i(_r,"verifyPatternLocations");async function $r(r,e){let t=Date.now();try{let s=await Hr(e),a=r.fileCount,o=.1,n=Math.abs(s-a),c=a*o;return n<=c?{name:"File count verification",passed:!0,output:`File count accurate (declared: ${a}, actual: ${s})`,durationMs:Date.now()-t}:{name:"File count verification",passed:!1,error:`File count mismatch: declared ${a}, actual ${s} (diff: ${n})`,durationMs:Date.now()-t}}catch(s){return{name:"File count verification",passed:!1,error:`Failed to count files: ${s instanceof Error?s.message:"unknown error"}`,durationMs:Date.now()-t}}}i($r,"verifyFileCount");async function Or(r,e){let t=Date.now();if(r.antiPatterns.length===0)return{name:"Anti-pattern file verification",passed:!0,output:"No anti-patterns declared (skipped)",durationMs:Date.now()-t};let s=[],a=[];for(let o of r.antiPatterns){let n=E.join(e,o.file);await N(n)?a.push(o.file):s.push(`${o.issue} (${o.file})`)}return s.length===0?{name:"Anti-pattern file verification",passed:!0,output:`${a.length} anti-pattern file(s) verified`,durationMs:Date.now()-t}:{name:"Anti-pattern file verification",passed:!1,error:`Anti-pattern files not found: ${s.join(", ")}`,durationMs:Date.now()-t}}i(Or,"verifyAntiPatternFiles");async function Rt(r,e){let t=Date.now(),s=await Promise.all([Mr(r,e),Fr(r,e),_r(r,e),$r(r,e),Or(r,e)]);return K(s,t)}i(Rt,"semanticVerify");async function Nr(r){let e=new Set,t=[/node_modules/,/\.git/,/dist/,/build/,/\.next/,/\.turbo/,/coverage/];async function s(a){try{let o=await oe.readdir(a,{withFileTypes:!0});for(let n of o){let c=E.join(a,n.name),l=E.relative(r,c);if(!t.some(d=>d.test(l))){if(n.isDirectory())await s(c);else if(n.isFile()){let d=E.extname(n.name);d&&e.add(d)}}}}catch{}}return i(s,"scanDir"),await s(r),Array.from(e)}i(Nr,"getProjectExtensions");async function Hr(r){let e=[/node_modules/,/\.git/,/dist/,/build/,/\.next/,/\.turbo/,/coverage/];async function t(s){try{let a=await oe.readdir(s,{withFileTypes:!0});return(await Promise.all(a.map(async n=>{let c=E.join(s,n.name),l=E.relative(r,c);return e.some(d=>d.test(l))?0:n.isDirectory()?t(c):n.isFile()?1:0}))).reduce((n,c)=>n+c,0)}catch{return 0}}return i(t,"scanDir"),t(r)}i(Hr,"countProjectFiles");te();var ce=class extends Be{static{i(this,"AnalysisStorage")}constructor(){super("analysis.json")}getDefault(){return{draft:null,sealed:null,previousSealed:null,lastUpdated:""}}getEventType(e){return`analysis.${e}d`}async saveDraft(e,t){let s={...t,status:"draft"};ie.parse(s),await this.update(e,a=>({...a,draft:s,lastUpdated:v()})),this.publishAnalysis(e,s)}publishAnalysis(e,t){Ve({projectId:e,entityType:"analysis",entityId:e,eventType:"upsert",data:{...t,id:e}})}async seal(e){let t=await this.read(e);if(!t.draft)return{success:!1,error:"No draft analysis to seal. Run `p. sync` first."};if(t.draft.status==="sealed")return{success:!1,error:"Draft is already sealed."};let s=this.computeSignature(t.draft),a=v(),o={...t.draft,status:"sealed",signature:s,sealedAt:a};return ie.parse(o),await this.write(e,{draft:null,sealed:o,previousSealed:t.sealed,lastUpdated:a}),this.publishAnalysis(e,o),{success:!0,signature:s}}async getSealed(e){return(await this.read(e)).sealed}async getDraft(e){return(await this.read(e)).draft}async getActive(e){let t=await this.read(e);return t.sealed??t.draft}async getStatus(e){let t=await this.read(e);return{hasSealed:t.sealed!==null,hasDraft:t.draft!==null,hasPreviousSealed:t.previousSealed!==null,sealedCommit:t.sealed?.commitHash??null,draftCommit:t.draft?.commitHash??null,previousSealedCommit:t.previousSealed?.commitHash??null,sealedAt:t.sealed?.sealedAt??null}}async rollback(e){let t=await this.read(e);if(!t.previousSealed)return{success:!1,error:"No previous sealed version to rollback to."};let s=v();return await this.write(e,{draft:t.sealed,sealed:t.previousSealed,previousSealed:null,lastUpdated:s}),this.publishAnalysis(e,t.previousSealed),{success:!0,restoredSignature:t.previousSealed.signature}}async diff(e){let t=await this.read(e);return!t.sealed||!t.draft?null:It(t.sealed,t.draft)}checkStaleness(e,t){return e?t?e!==t?{isStale:!0,sealedCommit:e,currentCommit:t,message:`Analysis is stale: sealed at ${e}, HEAD is ${t}. Run \`p. sync\` + \`p. seal\` to update.`}:{isStale:!1,sealedCommit:e,currentCommit:t,message:"Analysis is current."}:{isStale:!0,sealedCommit:e,currentCommit:null,message:"Cannot determine current commit. Analysis may be stale."}:{isStale:!1,sealedCommit:null,currentCommit:t,message:"No sealed analysis. Run `p. sync` then `p. seal`."}}async verify(e){let t=await this.read(e);if(!t.sealed)return{valid:!1,message:"No sealed analysis to verify."};if(!t.sealed.signature)return{valid:!1,message:"Sealed analysis has no signature."};let s=this.computeSignature({...t.sealed,signature:void 0,sealedAt:void 0});return s===t.sealed.signature?{valid:!0,message:"Signature verified. Analysis integrity confirmed."}:{valid:!1,message:`Signature mismatch. Expected ${s}, got ${t.sealed.signature}. Analysis may have been modified.`}}async semanticVerify(e,t){let s=await this.read(e),a=s.sealed??s.draft;return a?await Rt(a,t):{passed:!1,checks:[{name:"Analysis availability",passed:!1,error:"No analysis available. Run `p. sync` to generate.",durationMs:0}],totalMs:0,failedCount:1,passedCount:0}}computeSignature(e){let t={projectId:e.projectId,languages:e.languages,frameworks:e.frameworks,packageManager:e.packageManager,sourceDir:e.sourceDir,testDir:e.testDir,configFiles:e.configFiles,fileCount:e.fileCount,patterns:e.patterns,antiPatterns:e.antiPatterns,analyzedAt:e.analyzedAt,commitHash:e.commitHash};return We(JSON.stringify(t))}},Y=new ce;import hs from"node:fs/promises";import Z from"node:path";Ar();Ge();V();import le from"node:fs/promises";import Tt from"node:path";import{gunzipSync as Lr,gzipSync as Gr}from"node:zlib";Ge();B();var zr="code-graph.json.gz";function Mt(r){return Tt.join(J.getGlobalProjectPath(r),zr)}i(Mt,"artifactPath");async function Wr(r){if(!ae(r))return null;let e=dt(r),t=ot(r),s=lt(r)??{symbolCount:e.length,edgeCount:t.length,fileCount:new Set(e.map(l=>l.file)).size,builtAt:new Date().toISOString()},a={version:1,projectId:r,exportedAt:new Date().toISOString(),meta:s,symbols:e,edges:t},o=Buffer.from(JSON.stringify(a),"utf-8"),n=Gr(o,{level:6}),c=Mt(r);return await le.mkdir(Tt.dirname(c),{recursive:!0}),await le.writeFile(c,n),{path:c,bytes:n.length,symbols:e.length,edges:t.length}}i(Wr,"exportCodeGraphArtifact");async function Ur(r){let e=Mt(r),t=await le.readFile(e).catch(()=>null);if(!t)return{imported:!1,symbols:0,edges:0,reason:"no per-project artifact"};let s=(()=>{try{let o=Lr(t).toString("utf-8");return{payload:JSON.parse(o)}}catch(o){return{error:`corrupt artifact: ${o instanceof Error?o.message:String(o)}`}}})();if("error"in s)return{imported:!1,symbols:0,edges:0,reason:s.error};let a=s.payload;return a.version!==1||!Array.isArray(a.symbols)?{imported:!1,symbols:0,edges:0,reason:"unsupported artifact version"}:a.projectId&&a.projectId!==r?{imported:!1,symbols:0,edges:0,reason:`artifact projectId mismatch (got ${a.projectId}, expected ${r})`}:(at(r,{symbols:a.symbols,edges:a.edges}),T.setDoc(r,"symbol-graph",{...a.meta,builtAt:a.meta.builtAt??a.exportedAt}),{imported:!0,symbols:a.symbols.length,edges:a.edges.length})}i(Ur,"importCodeGraphArtifact");async function Ft(r){if(ae(r))return{bootstrapped:!1,detail:"local index already present"};let e=await Ur(r);return e.imported?{bootstrapped:!0,detail:`imported ${e.symbols} symbols / ${e.edges} edges from per-project cache`}:{bootstrapped:!1,detail:e.reason??"import failed"}}i(Ft,"bootstrapCodeGraphFromArtifact");function _t(r){return r?.cloud?.enabled===!0&&r.cloud.paused!==!0}i(_t,"shouldAutoUploadCodeGraph");async function $t(r,e){try{await Wr(r)}catch{}if(e.uploadToCloud)try{await Vr(r,e.uploadDependencies)}catch{}}i($t,"maybeExportAfterIndex");async function Vr(r,e={}){let t=await import("./code-graph-cloud-GTSLO7CD.mjs"),s=(e.buildSnapshot??t.buildCloudCodeGraphSnapshot)(r);if(!t.isUploadableGraph(s))return{uploaded:!1,reason:"no symbol index or empty graph"};try{let o=await(e.upload??(async(n,c)=>{let{default:l}=await import("./sync-client-PIRHMHXL.mjs");return l.uploadCodeGraph(n,c)}))(r,s);return o.ok?{uploaded:!0,nodes:o.nodes??s.nodes.length,links:o.links??s.links.length}:{uploaded:!1,reason:o.reason??"upload failed or unauthenticated",nodes:s.nodes.length,links:s.links.length}}catch(a){return{uploaded:!1,reason:a instanceof Error?a.message:String(a)}}}i(Vr,"maybeUploadCodeGraphToCloud");import F from"node:fs/promises";import Jr from"node:os";import C from"node:path";var de=[{name:"prjct",description:St,allowedTools:[...wt],body:i(()=>vt(),"body"),reference:i(()=>bt(),"reference"),referenceFile:kt}];function Br(r){let e=r.userInvocable!==!1;return`---
|
|
13
13
|
description: "${r.description}"
|
|
14
14
|
allowed-tools: [${r.allowedTools.map(t=>`"${t}"`).join(", ")}]
|
|
15
15
|
user-invocable: ${e}
|
|
16
16
|
---`}i(Br,"buildFrontmatter");function qr(r){return`${Br(r)}
|
|
17
17
|
|
|
18
|
-
${r.body()}`}i(qr,"buildSkillContent");function Ot(){return process.env.HOME||Jr.homedir()}i(Ot,"homeDir");function Kr(){return
|
|
18
|
+
${r.body()}`}i(qr,"buildSkillContent");function Ot(){return process.env.HOME||Jr.homedir()}i(Ot,"homeDir");function Kr(){return C.join(Ot(),".claude","skills")}i(Kr,"claudeSkillsRoot");function Yr(){let r=Ot();return[C.join(r,".codex","skills"),C.join(r,".gemini","skills"),C.join(r,".gemini","antigravity","global_skills"),C.join(r,".agents","skills")]}i(Yr,"compactSkillRoots");function Qr(r){return!!(/^# [^\n]+\n[^\n]*\|\s*\d+\s+files\s*\|/m.test(r)||/## Recent Deliveries/m.test(r)||/## Velocity/m.test(r)&&/pts\/sprint/m.test(r))}i(Qr,"skillBodyHasProjectStamp");var ue=class{static{i(this,"SkillGenerator")}async generateAndInstall(){let e={generated:[],skipped:[]},t=Kr();for(let o of de)try{let n=qr(o);if(Qr(n))throw new Error("refusing to install project-stamped skill body (isolation guard)");let c=C.join(t,o.name),l=C.join(c,"SKILL.md");await F.mkdir(c,{recursive:!0}),await F.writeFile(l,n,"utf-8"),o.reference&&o.referenceFile&&await F.writeFile(C.join(c,o.referenceFile),o.reference(),"utf-8"),e.generated.push({name:o.name,path:l})}catch(n){p.debug(`Failed to generate skill ${o.name}`,{error:w(n)}),e.skipped.push({name:o.name,reason:w(n)})}let s=ze();for(let o of Yr())try{let n=C.join(o,"prjct"),c=C.join(n,"SKILL.md");await F.mkdir(n,{recursive:!0}),await F.writeFile(c,s,"utf-8"),e.generated.push({name:"prjct-compact",path:c})}catch(n){p.debug("Compact skill install skipped",{root:o,error:w(n)})}let a=new Set(de.map(o=>o.name));try{let o=await F.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let n of o)n.isDirectory()&&n.name.startsWith("prjct-")&&!a.has(n.name)&&await F.rm(C.join(t,n.name),{recursive:!0,force:!0}).catch(()=>{})}catch{}return e.generated.length>0&&p.info("Generated portable multi-host skills",{count:e.generated.length,skills:e.generated.map(o=>o.name)}),e}getDefinitions(){return de}},Nt=new ue;function me(){return{branch:"main",commits:0,contributors:0,hasChanges:!1,stagedFiles:[],modifiedFiles:[],untrackedFiles:[],recentCommits:[],weeklyCommits:0}}i(me,"emptyGitData");function pe(){return{fileCount:0,version:"0.0.0",name:"unknown",ecosystem:"unknown",projectType:"simple",languages:[],frameworks:[]}}i(pe,"emptyStats");function fe(){return{install:"npm install",run:"npm run",test:"npm test",build:"npm run build",dev:"npm run dev",lint:"npm run lint",format:"npm run format"}}i(fe,"emptyCommands");function ge(){return{hasFrontend:!1,hasBackend:!1,hasDatabase:!1,hasDocker:!1,hasTesting:!1,frontendType:null,frameworks:[]}}i(ge,"emptyStack");function Ht(r,e){let t=[...r.added,...r.modified],s=new Set(t),a=new Set,o=q(e);if(o)for(let l of t){let d=o.reverse[l];if(d)for(let m of d)s.has(m)||a.add(m)}let n=Array.from(a),c=[...t,...n];return{directlyChanged:t,affectedByImports:n,deleted:r.deleted,allAffected:c}}i(Ht,"propagateChanges");function Lt(r){let e=new Set;for(let t of r){let s=t.toLowerCase();(s.endsWith(".tsx")||s.endsWith(".jsx")||s.endsWith(".css")||s.endsWith(".scss")||s.endsWith(".vue")||s.endsWith(".svelte")||s.includes("/components/")||s.includes("/pages/")||s.includes("/app/"))&&(e.add("frontend"),e.add("uxui")),(s.includes(".test.")||s.includes(".spec.")||s.includes("__tests__")||s.includes("/test/"))&&e.add("testing"),(s.includes("dockerfile")||s.includes("docker-compose")||s.includes(".dockerignore")||s.includes(".github/")||s.includes("ci/")||s.includes("cd/"))&&e.add("devops"),(s.endsWith(".sql")||s.includes("prisma")||s.includes("drizzle")||s.includes("migration")||s.includes("/db/"))&&e.add("database"),(s.endsWith(".ts")||s.endsWith(".js"))&&!s.includes(".test.")&&!s.includes(".spec.")&&!s.endsWith(".d.ts")&&e.add("backend")}return e}i(Lt,"affectedDomains");B();V();import Gt from"node:fs/promises";import Xr from"node:path";function Zr(r){return typeof Bun<"u"&&Bun.hash?`xxh64:${Bun.hash(r).toString(36)}`:`fnv1a:${([...r].reduce((t,s)=>Math.imul(t^s.charCodeAt(0),16777619),2166136261)>>>0).toString(36)}`}i(Zr,"hashContent");async function es(r,e={}){let t=await _e(r,{skipDotfiles:!0,dotfileAllowlist:[".env.example"]}),s=new Map,a=e.changedFilesHint?.length?new Set(e.changedFilesHint):null,o=await $e(t,100,async n=>{try{let c=Xr.join(r,n),l=await Gt.stat(c),d=l.mtime.toISOString(),m=e.storedHashes?.get(n),h=a?.has(n)??!1;if(m&&!h&&m.size===l.size&&m.mtime===d&&m.hash)return{path:n,hash:m.hash,size:l.size,mtime:d};let y=await Gt.readFile(c,"utf-8");return{path:n,hash:Zr(y),size:l.size,mtime:d}}catch{return null}});for(let n of o)s.set(n.path,n);return s}i(es,"computeHashes");function ts(r,e){let t=[],s=[],a=[];for(let[n,c]of r){let l=e.get(n);l?l.hash!==c.hash?s.push(n):a.push(n):t.push(n)}let o=[];for(let n of e.keys())r.has(n)||o.push(n);return{added:t,modified:s,deleted:o,unchanged:a}}i(ts,"diffHashes");function he(r,e){let t=T.getDb(r);t.transaction(()=>{t.prepare("DELETE FROM index_checksums").run();let s=t.prepare("INSERT INTO index_checksums (path, checksum, size, mtime) VALUES (?, ?, ?, ?)");for(let[,a]of e)s.run(a.path,a.hash,a.size,a.mtime)})(),T.setDoc(r,"file-hashes-meta",{fileCount:e.size,builtAt:new Date().toISOString()})}i(he,"saveHashes");function rs(r){let e=new Map;try{let t=T.query(r,"SELECT path, checksum, size, mtime FROM index_checksums");for(let s of t)e.set(s.path,{path:s.path,hash:s.checksum,size:s.size||0,mtime:s.mtime||""})}catch{}return e}i(rs,"loadHashes");async function ye(r,e,t){let s=rs(e),a=await es(r,{storedHashes:s,changedFilesHint:t});return{diff:ts(a,s),currentHashes:a}}i(ye,"detectChanges");function zt(r){return T.hasDoc(r,"file-hashes-meta")}i(zt,"hasHashRegistry");$();var ss=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]);async function Wt(r){let{projectId:e,projectPath:t,isFullSync:s,changedFilesHint:a}=r,o={shouldRebuildIndexes:!0,changedDomains:new Set,incrementalInfo:void 0,changedSourceFiles:[],deletedSourceFiles:[]};if(!s&&zt(e)){try{let{diff:n,currentHashes:c}=await ye(t,e,a),l=n.added.length+n.modified.length+n.deleted.length,d=(()=>{if(l===0&&!a?.length)return{shouldRebuildIndexes:!1,changedDomains:new Set,incrementalInfo:{isIncremental:!0,filesChanged:0,filesUnchanged:n.unchanged.length,indexesRebuilt:!1,affectedDomains:[]},changedSourceFiles:[],deletedSourceFiles:[]};let m=Ht(n,e),h=Lt(m.allAffected),y=m.allAffected.some(Se);return{shouldRebuildIndexes:y,changedDomains:h,incrementalInfo:{isIncremental:!0,filesChanged:l,filesUnchanged:n.unchanged.length,indexesRebuilt:y,affectedDomains:Array.from(h)},changedSourceFiles:[...n.added,...n.modified].filter(Se),deletedSourceFiles:n.deleted.filter(Se)}})();return he(e,c),d}catch(n){p.debug("Incremental detection failed, falling back to full sync",{error:k(n)})}return o}try{let{currentHashes:n}=await ye(t,e,a);he(e,n)}catch(n){p.debug("Hash computation failed (non-critical)",{error:k(n)})}return o}i(Wt,"detectIncrementalChanges");function Se(r){let e=r.substring(r.lastIndexOf("."));return ss.has(e)}i(Se,"isSourceFile");import{z as D}from"zod";var jn=D.object({date:D.string(),tokensSaved:D.number(),syncs:D.number(),avgCompressionRate:D.number(),totalDuration:D.number()}),An=D.object({agentName:D.string(),usageCount:D.number(),tokensSaved:D.number()}),Ut={"claude-opus-4.5":.005,"claude-sonnet-4.5":.003,"claude-haiku-4.5":.001,"claude-opus-4":.015,"claude-sonnet-4":.003,"gpt-4o":.0025,"gemini-pro":.00125,default:.003};function Vt(r,e="default"){let t=Ut[e]||Ut.default;return r/1e3*t}i(Vt,"estimateCostSaved");function In(r){return r<.01?`$${(r*100).toFixed(2)}\xA2`:`$${r.toFixed(2)}`}i(In,"formatCost");B();var ns=i(r=>({date:r.date,tokensSaved:r.tokens_saved,syncs:r.syncs,avgCompressionRate:r.avg_compression_rate,totalDuration:r.total_duration}),"rowToDaily"),Q=i(r=>{let e=new Date;return e.setDate(e.getDate()-r),e.toISOString().split("T")[0]},"dayCutoff"),we=class{static{i(this,"MetricsStorage")}async recordSync(e,t){let s=Math.max(0,t.originalSize-t.filteredSize),a=t.originalSize>0?s/t.originalSize:0,o=new Date().toISOString().split("T")[0];if(b.run(e,`INSERT INTO metrics_daily (date, tokens_saved, syncs, avg_compression_rate, total_duration)
|
|
19
19
|
VALUES (?, ?, 1, ?, ?)
|
|
20
20
|
ON CONFLICT(date) DO UPDATE SET
|
|
21
21
|
tokens_saved = metrics_daily.tokens_saved + excluded.tokens_saved,
|
|
@@ -31,6 +31,6 @@ ${r.body()}`}i(qr,"buildSkillContent");function Ot(){return process.env.HOME||Jr
|
|
|
31
31
|
COALESCE(SUM(syncs), 0) AS syncs,
|
|
32
32
|
COALESCE(SUM(total_duration), 0) AS duration,
|
|
33
33
|
COALESCE(SUM(avg_compression_rate * syncs), 0) AS weighted_rate
|
|
34
|
-
FROM metrics_daily`),s=t?.syncs??0,a=t?.tokens??0,o=i((m,h)=>b.get(e,h?"SELECT COALESCE(SUM(tokens_saved), 0) AS t FROM metrics_daily WHERE date >= ? AND date < ?":"SELECT COALESCE(SUM(tokens_saved), 0) AS t FROM metrics_daily WHERE date >= ?",...h?[m,h]:[m])?.t??0,"rangeTokens"),n=o(Q(30)),c=o(Q(60),Q(30)),l=c>0?(n-c)/c*100:0,d=b.query(e,"SELECT * FROM metrics_agent_usage ORDER BY usage_count DESC LIMIT 5").map(m=>({agentName:m.agent_name,usageCount:m.usage_count,tokensSaved:m.tokens_saved}));return{totalTokensSaved:a,estimatedCostSaved:Vt(a),compressionRate:s>0?(t?.weighted_rate??0)/s:0,syncCount:s,avgSyncDuration:s>0?(t?.duration??0)/s:0,topAgents:d,last30DaysTokens:n,trend:l}}async getDailyStats(e,t=30){return b.query(e,"SELECT * FROM metrics_daily WHERE date >= ? ORDER BY date ASC",Q(t)).map(ns)}async getFirstSyncDate(e){return b.get(e,"SELECT MIN(date) AS d FROM metrics_daily")?.d??""}},Jt=new we;$();te();import as from"node:path";function os(r){return Ue(as.resolve(r))}i(os,"repoHash");function L(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"")}i(L,"normalizeKey");function is(r){return se(r,e=>`${L(e.name)}::${L(e.source)}`)}i(is,"dedupePatterns");function cs(r){return se(r,e=>`${L(e.issue)}::${L(e.file)}::${L(e.source)}`)}i(cs,"dedupeAntiPatterns");var ke=class{static{i(this,"PatternExtractor")}async extract(e){let t=os(e.projectPath),s=[];if(e.context7Verified)for(let l of e.frameworks)s.push({name:`${l} API validation via Context7`,description:`Validate ${l} APIs against current documentation through Context7 before implementation.`,framework:l,source:"context7",confidence:.7});let a=(e.feedback?.patternsDiscovered||[]).map(l=>({name:l,description:`Confirmed during completed tasks: ${l}`,source:"feedback",confidence:.75})),o=(e.feedback?.knownGotchas||[]).map(l=>({issue:l,file:"multiple",suggestion:`Recurring gotcha. Prevent this pattern during implementation: ${l}`,source:"feedback",severity:"medium",confidence:.7})),n=is([...s,...a]),c=cs([...o]);return{patterns:n,antiPatterns:c,repoPathHash:t}}},ls=new ke,Bt=ls;var qt=200;async function Kt(r,e,t){let{bm25Index:s,originalSize:a}=(()=>{try{let d=Ze(r),m=d?Object.values(d.documents).reduce((h,y)=>h+y.length,0):0;return{bm25Index:d,originalSize:m||e.fileCount*qt}}catch(d){return p.debug("Could not load BM25 index for metrics",{error:k(d)}),{bm25Index:null,originalSize:e.fileCount*qt}}})(),o=0,n=a>0?Math.max(0,(a-o)/a):0;try{await Jt.recordSync(r,{originalSize:a,filteredSize:o,duration:t,isWatch:!1})}catch(d){p.debug("Failed to record sync metrics",{error:k(d)})}try{let{velocityStorage:d}=await import("./velocity-storage-
|
|
35
|
-
`)}},tr=new Ce;var gs=["storage","context","memory","analysis","config","sync"];async function rr(r){try{await Promise.all(gs.map(e=>ps.mkdir(fs.join(r,e),{recursive:!0})))}catch(e){throw new Error(Fe(e,r,"project directories"))}}i(rr,"ensureProjectDirectories");async function sr(r){let{projectId:e,projectPath:t,cliVersion:s,git:a,stats:o}=r,n=b.getDoc(e,"project")||{},c={...n,projectId:e,repoPath:t,name:o.name,version:o.version,cliVersion:s,techStack:o.frameworks,fileCount:o.fileCount,commitCount:a.commits,stack:o.ecosystem,currentBranch:a.branch,hasUncommittedChanges:a.hasChanges,createdAt:n.createdAt||v(),lastSync:v(),lastSyncCommit:a.recentCommits[0]?.hash||null,lastSyncBranch:a.branch};b.setDoc(e,"project",c)}i(sr,"updateProjectDoc");async function nr(r){let{projectId:e,projectPath:t,stats:s,stack:a}=r,n={...await I.read(e)};n.projectId=e,n.stack={language:s.languages[0]||"Unknown",framework:s.frameworks[0]||null},n.domains={hasFrontend:a.hasFrontend,hasBackend:a.hasBackend,hasDatabase:a.hasDatabase,hasTesting:a.hasTesting,hasDocker:a.hasDocker},n.projectType=s.projectType,n.metrics={totalFiles:s.fileCount},n.lastSync=v(),n.lastUpdated=v(),n.context={...n.context||{},lastSession:v(),lastAction:"Synced project",nextAction:'Run `p. work "intent"` to start a work cycle'},await I.write(e,n);try{await tr.remove(t)}catch(c){p.debug("Legacy local state cleanup failed (optional)",{error:k(c)})}}i(nr,"updateStateDoc");function ar(r,e,t){b.appendEvent(r,"sync",{branch:e.branch,uncommitted:e.hasChanges,fileCount:t.fileCount,commitCount:e.commits})}i(ar,"logSyncEvent");import or from"node:fs/promises";import xe from"node:path";$();Dr();var ir={async jsonFilesValid(r){let e=Date.now(),t=[],s=xe.basename(r);try{await I.read(s)}catch(a){R(a)||t.push(`state: ${k(a)}`)}return{name:"State data valid",passed:t.length===0,output:t.length===0?"1 store validated":void 0,error:t.length>0?t.join("; "):void 0,durationMs:Date.now()-e}},async noSensitiveData(r){let e=Date.now(),t=xe.join(r,"context"),s=[/(?:api[_-]?key|apikey)\s*[:=]\s*['"][^'"]{10,}/i,/(?:password|passwd|pwd)\s*[:=]\s*['"][^'"]{4,}/i,/(?:secret|token)\s*[:=]\s*['"][^'"]{10,}/i],a=[];try{let o=await or.readdir(t);for(let n of o){if(!n.endsWith(".md"))continue;let c=await or.readFile(xe.join(t,n),"utf-8");for(let l of s)if(l.test(c)){a.push(`${n}: potential sensitive data detected`);break}}}catch(o){if(!R(o))return{name:"No sensitive data",passed:!1,error:`Could not scan: ${k(o)}`,durationMs:Date.now()-e}}return{name:"No sensitive data",passed:a.length===0,output:a.length===0?"No sensitive patterns found":void 0,error:a.length>0?a.join("; "):void 0,durationMs:Date.now()-e}}},De=class{static{i(this,"SyncVerifier")}async verify(e,t,s){let a=Date.now(),o=[],n=s?.failFast??!1,c=[],l=[ir.jsonFilesValid(t),ir.noSensitiveData(t)];for(let m of l){let h=await m;if(o.push(h),!h.passed&&n){c.push(...s?.checks?.filter(y=>y.enabled!==!1).map(y=>y.name)??[]);break}}if((!n||o.every(m=>m.passed))&&s?.checks)for(let m of s.checks){if(m.enabled===!1){c.push(m.name);continue}let h=await this.runCustomCheck(m,e);if(o.push(h),!h.passed&&n){let y=s.checks.slice(s.checks.indexOf(m)+1);c.push(...y.filter(P=>P.enabled!==!1).map(P=>P.name));break}}return{...K(o,a),skippedCount:c.length}}async runCustomCheck(e,t){let s=Date.now(),a=e.command||(e.script?`sh ${e.script}`:null);if(!a)return{name:e.name,passed:!1,error:"No command or script specified",durationMs:Date.now()-s};try{let{stdout:o,stderr:n}=await Me(a,{cwd:t,timeout:3e4});return{name:e.name,passed:!0,output:(o.trim()||n.trim()).slice(0,200)||void 0,durationMs:Date.now()-s}}catch(o){let n=o;return{name:e.name,passed:!1,error:(n.stderr?.trim()||n.message).slice(0,200),durationMs:Date.now()-s}}}},cr=new De;var je=class{static{i(this,"SyncService")}projectPath;projectId=null;globalPath="";cliVersion="0.0.0";constructor(){this.projectPath=process.cwd()}async sync(e=process.cwd(),t={}){this.projectPath=e;let s=Date.now(),a=[],o=i((l,d)=>Zt(l,d,a),"phase"),n={installed:!1,verified:!1,configPath:"",message:""},c=[];try{if(this.projectId=await M.getProjectId(e),!this.projectId)return{success:!1,projectId:"",cliVersion:"",git:me(),stats:pe(),commands:fe(),stack:ge(),context7:{installed:!1,verified:!1},error:"No prjct project. Run p. init first."};if(this.globalPath=J.getGlobalProjectPath(this.projectId),this.cliVersion=await this.getCliVersion(),await hs.rm(Z.join(this.globalPath,"agents"),{recursive:!0,force:!0}).catch(()=>{}),(await Le()).installed){let u=await yt({autoRepair:!0});u.verified||p.warn(`Codex p. router not ready: ${u.message||"verification failed"}`)}await o("mcp-defaults",()=>ft({silent:!0,verifyContext7:!1}));let m=(await He().catch(()=>null))?.name??"claude";try{Object.assign(n,await o("context7",()=>pt.ensureReady(m)))}catch(u){let g=w(u);p.warn(`Context7 MCP not ready (continuing sync): ${g}`),Object.assign(n,{verified:!1,message:g})}await rr(this.globalPath),process.env.PRJCT_SKIP_CREW_SWEEP!=="1"&&await o("legacy-crew-sweep",async()=>{try{let{legacyCrewSweep:u}=await import("./legacy-crew-sweep-2WSO5KEB.mjs"),g=await u(this.projectPath,this.projectId);(g.checkpointsMigrated||g.teamMigrated||g.checkpointsHandEditWarned||g.teamHandEditWarned||g.ghostDirsPurged.length>0||g.agentFilesRepaired.length>0||g.clientPrjctJunkPurged.length>0||g.errors.length>0)&&p.info("Legacy crew sweep ran",{checkpointsMigrated:g.checkpointsMigrated,teamMigrated:g.teamMigrated,checkpointsHandEditWarned:g.checkpointsHandEditWarned,teamHandEditWarned:g.teamHandEditWarned,ghostDirsPurged:g.ghostDirsPurged,agentFilesRepaired:g.agentFilesRepaired,ghostFilesIngested:g.ghostFilesIngested,clientPrjctJunkPurged:g.clientPrjctJunkPurged,errors:g.errors.length})}catch(u){p.debug("Legacy crew sweep failed (non-critical)",{error:w(u)})}});let[y,P,Ee,G]=await o("gather",()=>Xt(Promise.all([Pt(this.projectPath),Ct(this.projectPath),xt(this.projectPath),Dt(this.projectPath)]),"gather")),{shouldRebuildIndexes:ur,changedDomains:ws,incrementalInfo:Re,changedSourceFiles:z,deletedSourceFiles:W}=await o("incremental",()=>Wt({projectId:this.projectId,projectPath:this.projectPath,isFullSync:t.full===!0,changedFilesHint:t.changedFiles}));try{let{refreshFileInventory:u}=await import("./project-file-inventory-5DEN5VLF.mjs");await u(this.projectId,this.projectPath)}catch{}try{await Ft(this.projectId)}catch{}ur&&await o("index",async()=>{try{let u=Re?.isIncremental&&(z.length>0||W.length>0);await Promise.all([u?tt(this.projectPath,this.projectId,z,W):et(this.projectPath,this.projectId),u?nt(this.projectPath,this.projectId,z,W):st(this.projectPath,this.projectId),u?ct(this.projectPath,this.projectId,z,W):it(this.projectPath,this.projectId),ht(this.projectPath,this.projectId)]);let g=this.projectId,S=this.projectPath,O=await M.readConfig(S).catch(()=>null),A=_t(O);c.push(er(()=>$t(g,{uploadToCloud:A}),{onComplete:i(({totalMs:C,error:U})=>{p.debug("sync post-index work settled",{projectId:g,uploadToCloud:A,totalMs:C,...U===void 0?{}:{error:w(U)}})},"onComplete")}))}catch(u){p.debug("File ranking index build failed (non-critical)",{error:w(u)})}});let mr=Date.now();p.debug("sync phase start",{phase:"skills"});let pr=await Nt.generateAndInstall().catch(u=>{p.debug("Native skill generation failed (non-critical)",{error:w(u)})});p.debug("sync phase done",{phase:"skills",ms:Date.now()-mr}),await o("update-files",()=>Promise.all([sr({projectId:this.projectId,projectPath:this.projectPath,cliVersion:this.cliVersion,git:y,stats:P}),nr({projectId:this.projectId,projectPath:this.projectPath,stats:P,stack:G}),Promise.resolve(ar(this.projectId,y,P)),Yt(this.projectId,this.projectPath,y,P,G,n.verified)]));let ee=await Y.getActive(this.projectId),fr={patterns:ee?.patterns?.length||0,antiPatterns:ee?.antiPatterns?.length||0,criticalAntiPatterns:ee?.antiPatterns?.filter(u=>u.severity==="high").length||0},gr=Date.now()-s,Te=await o("metrics",()=>Kt(this.projectId,P,gr)),hr=Te.developerSnapshotCaptured===!0,yr=await(async()=>{try{let{recomputeProjectStyle:u,formatProjectStyleForSync:g}=await import("./project-style-evolution-7MAUSED2.mjs"),S=await o("project-style",()=>u({projectId:this.projectId,projectPath:this.projectPath,stats:P,stack:G,commands:Ee,commitHash:y.recentCommits[0]?.hash??null,source:"sync-mechanical"})),O=g(S),A=S.snapshot.payload.metrics.styleCoverage;return{summary:S.snapshot.summary,evolutionMd:O.evolutionMd,patternCount:S.snapshot.patternCount,antiPatternCount:S.snapshot.antiPatternCount,conventionCount:S.snapshot.conventionCount,styleCoverage:typeof A=="number"?A:Number(A)||0,isFirst:S.isFirst,hasChanges:S.delta.hasChanges}}catch(u){p.debug("Project style recompute failed (non-critical)",{error:w(u)});return}})(),Sr=await o("work-cost",()=>jt(this.projectId));await o("archive",()=>Qt(this.projectId));let wr=await o("context-quality",()=>rt(this.projectPath,this.projectId)),kr=await o("retention",async()=>{try{let u=await M.readConfig(this.projectPath).catch(()=>null),g=u?.retention?.mode??"apply";if(g==="off")return;let S=g==="dry-run",{applyRetention:O,triageInbox:A}=await import("./retention-LWETHQX3.mjs"),C=O(this.projectId,{dryRun:S,maxArchive:u?.retention?.maxArchive,maxDelete:u?.retention?.maxDelete}),{inboxMerged:U,inboxArchived:br}=S?{inboxMerged:0,inboxArchived:0}:(()=>{let j=A(this.projectId);return{inboxMerged:j.merged,inboxArchived:j.archived}})(),{runVaultPurge:Pr,vaultHealth:Cr}=await import("./purge-MC5LFSAO.mjs"),_=await Pr(this.projectId,{projectPath:this.projectPath,dryRun:S,softDeletedPurgeDays:u?.retention?.softDeletedPurgeDays,archivePruneDays:u?.retention?.archivePruneDays,autoSourceMaxLive:u?.retention?.autoSourceMaxLive}),xr=Cr(this.projectId);return{evaluated:C.evaluated,active:C.active,archive:C.wouldArchive,delete:C.wouldDelete,archived:C.archived,deleted:C.deleted,inboxMerged:U,inboxArchived:br,dryRun:S,samples:C.samples.map(j=>({id:j.id,type:j.type,verdict:j.verdict,score:j.score,reasons:j.reasons,excess:j.excess})),referenceSize:C.referenceSize,vault:{...xr,softDeletedPurged:_.softDeletedPurged,orphanEventsPurged:_.orphanEventsPurged,archivesPruned:_.archivesPruned,autoSourceTrimmed:_.autoSourceTrimmed,distilledDiscarded:_.distilledDiscarded,digestsWritten:_.digestsWritten}}}catch(u){p.debug("retention phase failed",{error:w(u)});return}});await o("install-global",async()=>{await re.installGlobalConfig(),await re.syncCommands()}),await o("install-agent-surfaces",async()=>{let{detectInstalledAgents:u}=await import("./detection-QRVSNMKL.mjs"),g=await u(this.projectPath).catch(()=>[]);await mt(this.projectPath,{refreshIfAdopted:!0,agents:g})});let vr=await o("verify",async()=>{try{let u=await M.readConfig(this.projectPath);return await cr.verify(this.projectPath,this.globalPath,u?.verification)}catch(u){p.debug("Verification failed (non-critical)",{error:w(u)});return}});if(process.env.PRJCT_WORLD_MODEL_REFRESH==="1"||process.env.PRJCT_DRIFT_REFRESH==="1")try{let u=await import("node:os"),{markDriftRefreshApplied:g}=await import("./drift-refresh-TD3PYPJN.mjs"),S=process.env.PRJCT_CLI_HOME?Z.resolve(process.env.PRJCT_CLI_HOME):Z.join(u.homedir(),".prjct-cli");g(S)}catch{}return await Promise.all(c.map(u=>u.settle())),{success:!0,projectId:this.projectId,cliVersion:this.cliVersion,git:y,stats:P,commands:Ee,stack:G,context7:{installed:n.installed,verified:n.verified,message:n.message},analysisSummary:fr,contextQuality:wr,retentionDryRun:kr,syncMetrics:Te,workCost:Sr,verification:vr,incremental:Re,projectStyle:yr,developerSnapshotCaptured:hr,generatedSkills:pr,phaseTimings:a}}catch(l){return{success:!1,projectId:this.projectId||"",cliVersion:this.cliVersion,git:me(),stats:pe(),commands:fe(),stack:ge(),context7:{installed:n.installed,verified:n.verified,message:n.message},error:w(l)}}}async getCliVersion(){try{let e=Z.join(__dirname,"..","..","package.json");return(await Oe(e))?.version||"0.0.0"}catch(e){return p.debug("Failed to read CLI version",{error:w(e)}),"0.0.0"}}},co=new je;import Ae from"chalk";var lr={task:"Start new work cycle",done:"Complete current work",pause:"Pause and switch context",resume:"Continue paused task",ship:"Ship the feature",reopen:"Reopen for rework",next:"View task queue",sync:"Analyze project",bug:"Report a bug",idea:"Capture an idea"},ys={task:"work"};function Ie(r){return ys[r]??r}i(Ie,"publicCommand");var dr={task:"working",done:"completed","done-subtask":"working",pause:"paused",resume:"working",ship:"shipped",reopen:"working",next:"idle",sync:"idle",init:"idle",bug:"working",idea:"idle"};function fo(r,e={}){if(e.quiet)return;let t=dr[r]||"idle",s=ne.getValidCommands(t);if(s.length===0)return;let a=s.map(o=>({cmd:`p. ${Ie(o)}`,desc:lr[o]||o}));console.log(Ae.dim(`
|
|
34
|
+
FROM metrics_daily`),s=t?.syncs??0,a=t?.tokens??0,o=i((m,h)=>b.get(e,h?"SELECT COALESCE(SUM(tokens_saved), 0) AS t FROM metrics_daily WHERE date >= ? AND date < ?":"SELECT COALESCE(SUM(tokens_saved), 0) AS t FROM metrics_daily WHERE date >= ?",...h?[m,h]:[m])?.t??0,"rangeTokens"),n=o(Q(30)),c=o(Q(60),Q(30)),l=c>0?(n-c)/c*100:0,d=b.query(e,"SELECT * FROM metrics_agent_usage ORDER BY usage_count DESC LIMIT 5").map(m=>({agentName:m.agent_name,usageCount:m.usage_count,tokensSaved:m.tokens_saved}));return{totalTokensSaved:a,estimatedCostSaved:Vt(a),compressionRate:s>0?(t?.weighted_rate??0)/s:0,syncCount:s,avgSyncDuration:s>0?(t?.duration??0)/s:0,topAgents:d,last30DaysTokens:n,trend:l}}async getDailyStats(e,t=30){return b.query(e,"SELECT * FROM metrics_daily WHERE date >= ? ORDER BY date ASC",Q(t)).map(ns)}async getFirstSyncDate(e){return b.get(e,"SELECT MIN(date) AS d FROM metrics_daily")?.d??""}},Jt=new we;$();te();import as from"node:path";function os(r){return Ue(as.resolve(r))}i(os,"repoHash");function L(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"")}i(L,"normalizeKey");function is(r){return se(r,e=>`${L(e.name)}::${L(e.source)}`)}i(is,"dedupePatterns");function cs(r){return se(r,e=>`${L(e.issue)}::${L(e.file)}::${L(e.source)}`)}i(cs,"dedupeAntiPatterns");var ke=class{static{i(this,"PatternExtractor")}async extract(e){let t=os(e.projectPath),s=[];if(e.context7Verified)for(let l of e.frameworks)s.push({name:`${l} API validation via Context7`,description:`Validate ${l} APIs against current documentation through Context7 before implementation.`,framework:l,source:"context7",confidence:.7});let a=(e.feedback?.patternsDiscovered||[]).map(l=>({name:l,description:`Confirmed during completed tasks: ${l}`,source:"feedback",confidence:.75})),o=(e.feedback?.knownGotchas||[]).map(l=>({issue:l,file:"multiple",suggestion:`Recurring gotcha. Prevent this pattern during implementation: ${l}`,source:"feedback",severity:"medium",confidence:.7})),n=is([...s,...a]),c=cs([...o]);return{patterns:n,antiPatterns:c,repoPathHash:t}}},ls=new ke,Bt=ls;var qt=200;async function Kt(r,e,t){let{bm25Index:s,originalSize:a}=(()=>{try{let d=Ze(r),m=d?Object.values(d.documents).reduce((h,y)=>h+y.length,0):0;return{bm25Index:d,originalSize:m||e.fileCount*qt}}catch(d){return p.debug("Could not load BM25 index for metrics",{error:k(d)}),{bm25Index:null,originalSize:e.fileCount*qt}}})(),o=0,n=a>0?Math.max(0,(a-o)/a):0;try{await Jt.recordSync(r,{originalSize:a,filteredSize:o,duration:t,isWatch:!1})}catch(d){p.debug("Failed to record sync metrics",{error:k(d)})}try{let{velocityStorage:d}=await import("./velocity-storage-5J6BAMCW.mjs");await d.recompute(r)}catch(d){p.debug("Failed to recompute velocity",{error:k(d)})}let c=await import("./developer-evolution-WNSTHDAA.mjs").then(({captureDeveloperSnapshot:d})=>d(r)).catch(d=>(p.debug("Failed to capture dev snapshot",{error:k(d)}),!1)),l={};try{let d=s;d&&(l.bm25Files=d.totalDocs,l.bm25AvgTokens=Math.round(d.avgDocLength),l.bm25VocabSize=Object.keys(d.invertedIndex).length);let m=q(r);m&&(l.importEdges=m.edgeCount,l.importFiles=m.fileCount);let h=gt(r);h&&(l.cochangeCommits=h.commitsAnalyzed,l.cochangeFiles=h.filesAnalyzed)}catch(d){p.debug("Could not load index stats",{error:k(d)})}return{duration:t,originalSize:a,filteredSize:o,compressionRate:n,indexes:l,developerSnapshotCaptured:c}}i(Kt,"recordSyncMetrics");async function Yt(r,e,t,s,a,o){try{let n=t.recentCommits[0]?.hash||null,c=await I.getAggregatedFeedback(r).catch(()=>{});try{let{refreshSkillIndex:d}=await import("./skill-index-FGDQVYHM.mjs");await d(r,e)}catch{}let l=await Bt.extract({projectId:r,projectPath:e,languages:s.languages,frameworks:Array.from(new Set([...s.frameworks,...a.frameworks])),feedback:c,context7Verified:o});await Y.saveDraft(r,{projectId:r,languages:s.languages,frameworks:s.frameworks,configFiles:[],fileCount:s.fileCount,patterns:l.patterns,antiPatterns:l.antiPatterns,analyzedAt:v(),status:"draft",commitHash:n??void 0})}catch(n){p.debug("Failed to save draft analysis (non-critical)",{error:k(n)})}}i(Yt,"saveDraftAnalysis");async function Qt(r){try{let[e,t,s,a,o]=await Promise.all([qe.archiveOldShipped(r).catch(()=>0),Ke.markDormantIdeas(r).catch(()=>0),Ye.removeStaleCompleted(r).catch(()=>0),I.archiveStalePausedTasks(r).catch(()=>[]),Xe.capEntries(r).catch(()=>0)]),n=e+t+s+a.length+o;if(n>0){p.info("Archived stale data",{shipped:e,dormant:t,staleQueue:s,stalePaused:a.length,memoryCapped:o,total:n});let c=Je.getStats(r);p.debug("Archive stats",c)}}catch(e){p.debug("Archival failed (non-critical)",{error:k(e)})}}i(Qt,"archiveStaleData");var us=6e4,ve=class extends Error{static{i(this,"SyncPhaseTimeoutError")}phase;timeoutMs;constructor(e,t){super(`sync phase '${e}' timed out after ${t}ms. Set PRJCT_SYNC_PHASE_TIMEOUT_MS to tune this guard, or run \`prjct sync --full --md\` if incremental state looks stale.`),this.name="SyncPhaseTimeoutError",this.phase=e,this.timeoutMs=t}};function ms(){return Number(process.env.PRJCT_SYNC_PHASE_TIMEOUT_MS)||us}i(ms,"syncPhaseTimeoutMs");function Xt(r,e){let t=ms(),s=(()=>{let a=Promise.withResolvers(),o=setTimeout(()=>a.reject(new ve(e,t)),t);return{promise:a.promise,cancel:i(()=>clearTimeout(o),"cancel")}})();return Promise.race([r,s.promise]).finally(s.cancel)}i(Xt,"withPhaseTimeout");async function Zt(r,e,t){let s=Date.now();p.debug("sync phase start",{phase:r});try{let a=await e(),o=Date.now()-s;return p.debug("sync phase done",{phase:r,ms:o}),t?.push({phase:r,ms:o}),a}catch(a){let o=Date.now()-s;throw p.debug("sync phase failed",{phase:r,ms:o,error:w(a)}),t?.push({phase:r,ms:o}),a}}i(Zt,"runSyncPhase");function er(r,e={}){let t=e.now??Date.now,s=t(),o=(()=>{try{return r().then(()=>({}),n=>({error:n}))}catch(n){return Promise.resolve({error:n})}})().then(n=>{try{e.onComplete?.({totalMs:t()-s,...n})}catch{}});return{async settle(){await o}}}i(er,"startPostIndexWork");B();import ps from"node:fs/promises";import fs from"node:path";$();te();$();V();import be from"node:fs/promises";import X from"node:path";var Pe=".prjct/.prjct-state.md",Ce=class{static{i(this,"LocalStateGenerator")}async generate(e,t){let s=X.join(e,Pe);await be.mkdir(X.dirname(s),{recursive:!0});let a=this.toMarkdown(t);await be.writeFile(s,a,"utf-8")}async remove(e){try{await be.unlink(X.join(e,Pe))}catch(t){if(!R(t))throw t}}async exists(e){let t=X.join(e,Pe);return N(t)}toMarkdown(e){let t=["<!-- Auto-generated by prjct - DO NOT EDIT -->","<!-- This file provides local state persistence for AI tools -->","","# prjct State",""];if(e.currentTask){let s=e.currentTask;if(t.push("## Current Work Cycle"),t.push(""),t.push(`**${s.description}**`),t.push(""),t.push(`- Started: ${s.startedAt}`),s.linearId&&t.push(`- Linear: ${s.linearId}`),s.branch&&t.push(`- Branch: ${s.branch}`),t.push(`- Status: ${s.status||"active"}`),t.push(""),s.subtasks&&s.subtasks.length>0){t.push("### Subtasks"),t.push(""),s.subtasks.forEach((c,l)=>{let d=c.status==="completed"?"\u2705":c.status==="in_progress"?"\u25B6\uFE0F":"\u23F3",m=l===s.currentSubtaskIndex?" \u2190 **Active**":"";t.push(`${l+1}. ${d} ${c.description}${m}`)}),t.push("");let a=s.subtasks.filter(c=>c.status==="completed").length,o=s.subtasks.length,n=Math.round(a/o*100);t.push(`**Progress**: ${a}/${o} (${n}%)`),t.push("")}}else t.push("*No active work cycle*"),t.push(""),t.push('Start work with `p. work "intent"`'),t.push("");if(e.previousTask){let s=e.previousTask;t.push("---"),t.push(""),t.push("## Previous Work Cycle"),t.push(""),t.push(`**${s.description}**`),t.push(""),t.push(`- Status: ${s.status}`),s.prUrl&&t.push(`- PR: ${s.prUrl}`),t.push("")}return t.push("---"),t.push(`*Last updated: ${e.lastUpdated||new Date().toISOString()}*`),t.push(""),t.join(`
|
|
35
|
+
`)}},tr=new Ce;var gs=["storage","context","memory","analysis","config","sync"];async function rr(r){try{await Promise.all(gs.map(e=>ps.mkdir(fs.join(r,e),{recursive:!0})))}catch(e){throw new Error(Fe(e,r,"project directories"))}}i(rr,"ensureProjectDirectories");async function sr(r){let{projectId:e,projectPath:t,cliVersion:s,git:a,stats:o}=r,n=b.getDoc(e,"project")||{},c={...n,projectId:e,repoPath:t,name:o.name,version:o.version,cliVersion:s,techStack:o.frameworks,fileCount:o.fileCount,commitCount:a.commits,stack:o.ecosystem,currentBranch:a.branch,hasUncommittedChanges:a.hasChanges,createdAt:n.createdAt||v(),lastSync:v(),lastSyncCommit:a.recentCommits[0]?.hash||null,lastSyncBranch:a.branch};b.setDoc(e,"project",c)}i(sr,"updateProjectDoc");async function nr(r){let{projectId:e,projectPath:t,stats:s,stack:a}=r,n={...await I.read(e)};n.projectId=e,n.stack={language:s.languages[0]||"Unknown",framework:s.frameworks[0]||null},n.domains={hasFrontend:a.hasFrontend,hasBackend:a.hasBackend,hasDatabase:a.hasDatabase,hasTesting:a.hasTesting,hasDocker:a.hasDocker},n.projectType=s.projectType,n.metrics={totalFiles:s.fileCount},n.lastSync=v(),n.lastUpdated=v(),n.context={...n.context||{},lastSession:v(),lastAction:"Synced project",nextAction:'Run `p. work "intent"` to start a work cycle'},await I.write(e,n);try{await tr.remove(t)}catch(c){p.debug("Legacy local state cleanup failed (optional)",{error:k(c)})}}i(nr,"updateStateDoc");function ar(r,e,t){b.appendEvent(r,"sync",{branch:e.branch,uncommitted:e.hasChanges,fileCount:t.fileCount,commitCount:e.commits})}i(ar,"logSyncEvent");import or from"node:fs/promises";import xe from"node:path";$();Dr();var ir={async jsonFilesValid(r){let e=Date.now(),t=[],s=xe.basename(r);try{await I.read(s)}catch(a){R(a)||t.push(`state: ${k(a)}`)}return{name:"State data valid",passed:t.length===0,output:t.length===0?"1 store validated":void 0,error:t.length>0?t.join("; "):void 0,durationMs:Date.now()-e}},async noSensitiveData(r){let e=Date.now(),t=xe.join(r,"context"),s=[/(?:api[_-]?key|apikey)\s*[:=]\s*['"][^'"]{10,}/i,/(?:password|passwd|pwd)\s*[:=]\s*['"][^'"]{4,}/i,/(?:secret|token)\s*[:=]\s*['"][^'"]{10,}/i],a=[];try{let o=await or.readdir(t);for(let n of o){if(!n.endsWith(".md"))continue;let c=await or.readFile(xe.join(t,n),"utf-8");for(let l of s)if(l.test(c)){a.push(`${n}: potential sensitive data detected`);break}}}catch(o){if(!R(o))return{name:"No sensitive data",passed:!1,error:`Could not scan: ${k(o)}`,durationMs:Date.now()-e}}return{name:"No sensitive data",passed:a.length===0,output:a.length===0?"No sensitive patterns found":void 0,error:a.length>0?a.join("; "):void 0,durationMs:Date.now()-e}}},De=class{static{i(this,"SyncVerifier")}async verify(e,t,s){let a=Date.now(),o=[],n=s?.failFast??!1,c=[],l=[ir.jsonFilesValid(t),ir.noSensitiveData(t)];for(let m of l){let h=await m;if(o.push(h),!h.passed&&n){c.push(...s?.checks?.filter(y=>y.enabled!==!1).map(y=>y.name)??[]);break}}if((!n||o.every(m=>m.passed))&&s?.checks)for(let m of s.checks){if(m.enabled===!1){c.push(m.name);continue}let h=await this.runCustomCheck(m,e);if(o.push(h),!h.passed&&n){let y=s.checks.slice(s.checks.indexOf(m)+1);c.push(...y.filter(P=>P.enabled!==!1).map(P=>P.name));break}}return{...K(o,a),skippedCount:c.length}}async runCustomCheck(e,t){let s=Date.now(),a=e.command||(e.script?`sh ${e.script}`:null);if(!a)return{name:e.name,passed:!1,error:"No command or script specified",durationMs:Date.now()-s};try{let{stdout:o,stderr:n}=await Me(a,{cwd:t,timeout:3e4});return{name:e.name,passed:!0,output:(o.trim()||n.trim()).slice(0,200)||void 0,durationMs:Date.now()-s}}catch(o){let n=o;return{name:e.name,passed:!1,error:(n.stderr?.trim()||n.message).slice(0,200),durationMs:Date.now()-s}}}},cr=new De;var je=class{static{i(this,"SyncService")}projectPath;projectId=null;globalPath="";cliVersion="0.0.0";constructor(){this.projectPath=process.cwd()}async sync(e=process.cwd(),t={}){this.projectPath=e;let s=Date.now(),a=[],o=i((l,d)=>Zt(l,d,a),"phase"),n={installed:!1,verified:!1,configPath:"",message:""},c=[];try{if(this.projectId=await M.getProjectId(e),!this.projectId)return{success:!1,projectId:"",cliVersion:"",git:me(),stats:pe(),commands:fe(),stack:ge(),context7:{installed:!1,verified:!1},error:"No prjct project. Run p. init first."};if(this.globalPath=J.getGlobalProjectPath(this.projectId),this.cliVersion=await this.getCliVersion(),await hs.rm(Z.join(this.globalPath,"agents"),{recursive:!0,force:!0}).catch(()=>{}),(await Le()).installed){let u=await yt({autoRepair:!0});u.verified||p.warn(`Codex p. router not ready: ${u.message||"verification failed"}`)}await o("mcp-defaults",()=>ft({silent:!0,verifyContext7:!1}));let m=(await He().catch(()=>null))?.name??"claude";try{Object.assign(n,await o("context7",()=>pt.ensureReady(m)))}catch(u){let g=w(u);p.warn(`Context7 MCP not ready (continuing sync): ${g}`),Object.assign(n,{verified:!1,message:g})}await rr(this.globalPath),process.env.PRJCT_SKIP_CREW_SWEEP!=="1"&&await o("legacy-crew-sweep",async()=>{try{let{legacyCrewSweep:u}=await import("./legacy-crew-sweep-JXYO62UE.mjs"),g=await u(this.projectPath,this.projectId);(g.checkpointsMigrated||g.teamMigrated||g.checkpointsHandEditWarned||g.teamHandEditWarned||g.ghostDirsPurged.length>0||g.agentFilesRepaired.length>0||g.clientPrjctJunkPurged.length>0||g.errors.length>0)&&p.info("Legacy crew sweep ran",{checkpointsMigrated:g.checkpointsMigrated,teamMigrated:g.teamMigrated,checkpointsHandEditWarned:g.checkpointsHandEditWarned,teamHandEditWarned:g.teamHandEditWarned,ghostDirsPurged:g.ghostDirsPurged,agentFilesRepaired:g.agentFilesRepaired,ghostFilesIngested:g.ghostFilesIngested,clientPrjctJunkPurged:g.clientPrjctJunkPurged,errors:g.errors.length})}catch(u){p.debug("Legacy crew sweep failed (non-critical)",{error:w(u)})}});let[y,P,Ee,G]=await o("gather",()=>Xt(Promise.all([Pt(this.projectPath),Ct(this.projectPath),xt(this.projectPath),Dt(this.projectPath)]),"gather")),{shouldRebuildIndexes:ur,changedDomains:ws,incrementalInfo:Re,changedSourceFiles:z,deletedSourceFiles:W}=await o("incremental",()=>Wt({projectId:this.projectId,projectPath:this.projectPath,isFullSync:t.full===!0,changedFilesHint:t.changedFiles}));try{let{refreshFileInventory:u}=await import("./project-file-inventory-OKIP4LBO.mjs");await u(this.projectId,this.projectPath)}catch{}try{await Ft(this.projectId)}catch{}ur&&await o("index",async()=>{try{let u=Re?.isIncremental&&(z.length>0||W.length>0);await Promise.all([u?tt(this.projectPath,this.projectId,z,W):et(this.projectPath,this.projectId),u?nt(this.projectPath,this.projectId,z,W):st(this.projectPath,this.projectId),u?ct(this.projectPath,this.projectId,z,W):it(this.projectPath,this.projectId),ht(this.projectPath,this.projectId)]);let g=this.projectId,S=this.projectPath,O=await M.readConfig(S).catch(()=>null),A=_t(O);c.push(er(()=>$t(g,{uploadToCloud:A}),{onComplete:i(({totalMs:x,error:U})=>{p.debug("sync post-index work settled",{projectId:g,uploadToCloud:A,totalMs:x,...U===void 0?{}:{error:w(U)}})},"onComplete")}))}catch(u){p.debug("File ranking index build failed (non-critical)",{error:w(u)})}});let mr=Date.now();p.debug("sync phase start",{phase:"skills"});let pr=await Nt.generateAndInstall().catch(u=>{p.debug("Native skill generation failed (non-critical)",{error:w(u)})});p.debug("sync phase done",{phase:"skills",ms:Date.now()-mr}),await o("update-files",()=>Promise.all([sr({projectId:this.projectId,projectPath:this.projectPath,cliVersion:this.cliVersion,git:y,stats:P}),nr({projectId:this.projectId,projectPath:this.projectPath,stats:P,stack:G}),Promise.resolve(ar(this.projectId,y,P)),Yt(this.projectId,this.projectPath,y,P,G,n.verified)]));let ee=await Y.getActive(this.projectId),fr={patterns:ee?.patterns?.length||0,antiPatterns:ee?.antiPatterns?.length||0,criticalAntiPatterns:ee?.antiPatterns?.filter(u=>u.severity==="high").length||0},gr=Date.now()-s,Te=await o("metrics",()=>Kt(this.projectId,P,gr)),hr=Te.developerSnapshotCaptured===!0,yr=await(async()=>{try{let{recomputeProjectStyle:u,formatProjectStyleForSync:g}=await import("./project-style-evolution-RPGATIYJ.mjs"),S=await o("project-style",()=>u({projectId:this.projectId,projectPath:this.projectPath,stats:P,stack:G,commands:Ee,commitHash:y.recentCommits[0]?.hash??null,source:"sync-mechanical"})),O=g(S),A=S.snapshot.payload.metrics.styleCoverage;return{summary:S.snapshot.summary,evolutionMd:O.evolutionMd,patternCount:S.snapshot.patternCount,antiPatternCount:S.snapshot.antiPatternCount,conventionCount:S.snapshot.conventionCount,styleCoverage:typeof A=="number"?A:Number(A)||0,isFirst:S.isFirst,hasChanges:S.delta.hasChanges}}catch(u){p.debug("Project style recompute failed (non-critical)",{error:w(u)});return}})(),Sr=await o("work-cost",()=>jt(this.projectId));await o("archive",()=>Qt(this.projectId));let wr=await o("context-quality",()=>rt(this.projectPath,this.projectId)),kr=await o("retention",async()=>{try{let u=await M.readConfig(this.projectPath).catch(()=>null),g=u?.retention?.mode??"apply";if(g==="off")return;let S=g==="dry-run",{applyRetention:O,triageInbox:A}=await import("./retention-C3NQT65W.mjs"),x=O(this.projectId,{dryRun:S,maxArchive:u?.retention?.maxArchive,maxDelete:u?.retention?.maxDelete}),{inboxMerged:U,inboxArchived:br}=S?{inboxMerged:0,inboxArchived:0}:(()=>{let j=A(this.projectId);return{inboxMerged:j.merged,inboxArchived:j.archived}})(),{runVaultPurge:Pr,vaultHealth:Cr}=await import("./purge-XKHUAB4H.mjs"),_=await Pr(this.projectId,{projectPath:this.projectPath,dryRun:S,softDeletedPurgeDays:u?.retention?.softDeletedPurgeDays,archivePruneDays:u?.retention?.archivePruneDays,autoSourceMaxLive:u?.retention?.autoSourceMaxLive}),xr=Cr(this.projectId);return{evaluated:x.evaluated,active:x.active,archive:x.wouldArchive,delete:x.wouldDelete,archived:x.archived,deleted:x.deleted,inboxMerged:U,inboxArchived:br,dryRun:S,samples:x.samples.map(j=>({id:j.id,type:j.type,verdict:j.verdict,score:j.score,reasons:j.reasons,excess:j.excess})),referenceSize:x.referenceSize,vault:{...xr,softDeletedPurged:_.softDeletedPurged,orphanEventsPurged:_.orphanEventsPurged,archivesPruned:_.archivesPruned,autoSourceTrimmed:_.autoSourceTrimmed,distilledDiscarded:_.distilledDiscarded,digestsWritten:_.digestsWritten}}}catch(u){p.debug("retention phase failed",{error:w(u)});return}});await o("install-global",async()=>{await re.installGlobalConfig(),await re.syncCommands()}),await o("install-agent-surfaces",async()=>{let{detectInstalledAgents:u}=await import("./detection-QRVSNMKL.mjs"),g=await u(this.projectPath).catch(()=>[]);await mt(this.projectPath,{refreshIfAdopted:!0,agents:g})});let vr=await o("verify",async()=>{try{let u=await M.readConfig(this.projectPath);return await cr.verify(this.projectPath,this.globalPath,u?.verification)}catch(u){p.debug("Verification failed (non-critical)",{error:w(u)});return}});if(process.env.PRJCT_WORLD_MODEL_REFRESH==="1"||process.env.PRJCT_DRIFT_REFRESH==="1")try{let u=await import("node:os"),{markDriftRefreshApplied:g}=await import("./drift-refresh-TD3PYPJN.mjs"),S=process.env.PRJCT_CLI_HOME?Z.resolve(process.env.PRJCT_CLI_HOME):Z.join(u.homedir(),".prjct-cli");g(S)}catch{}return await Promise.all(c.map(u=>u.settle())),{success:!0,projectId:this.projectId,cliVersion:this.cliVersion,git:y,stats:P,commands:Ee,stack:G,context7:{installed:n.installed,verified:n.verified,message:n.message},analysisSummary:fr,contextQuality:wr,retentionDryRun:kr,syncMetrics:Te,workCost:Sr,verification:vr,incremental:Re,projectStyle:yr,developerSnapshotCaptured:hr,generatedSkills:pr,phaseTimings:a}}catch(l){return{success:!1,projectId:this.projectId||"",cliVersion:this.cliVersion,git:me(),stats:pe(),commands:fe(),stack:ge(),context7:{installed:n.installed,verified:n.verified,message:n.message},error:w(l)}}}async getCliVersion(){try{let e=Z.join(__dirname,"..","..","package.json");return(await Oe(e))?.version||"0.0.0"}catch(e){return p.debug("Failed to read CLI version",{error:w(e)}),"0.0.0"}}},co=new je;import Ae from"chalk";var lr={task:"Start new work cycle",done:"Complete current work",pause:"Pause and switch context",resume:"Continue paused task",ship:"Ship the feature",reopen:"Reopen for rework",next:"View task queue",sync:"Analyze project",bug:"Report a bug",idea:"Capture an idea"},ys={task:"work"};function Ie(r){return ys[r]??r}i(Ie,"publicCommand");var dr={task:"working",done:"completed","done-subtask":"working",pause:"paused",resume:"working",ship:"shipped",reopen:"working",next:"idle",sync:"idle",init:"idle",bug:"working",idea:"idle"};function fo(r,e={}){if(e.quiet)return;let t=dr[r]||"idle",s=ne.getValidCommands(t);if(s.length===0)return;let a=s.map(o=>({cmd:`p. ${Ie(o)}`,desc:lr[o]||o}));console.log(Ae.dim(`
|
|
36
36
|
Next:`));for(let o of a){let n=Ae.cyan(o.cmd.padEnd(12));console.log(Ae.dim(` ${n} \u2192 ${o.desc}`))}}i(fo,"showNextSteps");function go(r,e=!1){let t=dr[r]||"idle";return ne.getValidCommands(t).map(a=>({cmd:e?`prjct ${Ie(a)} --md`:`p. ${Ie(a)}`,desc:lr[a]||a}))}i(go,"getNextSteps");async function Ss(r,e={}){let t=await M.getProjectId(r);return t?{ok:!0,value:t}:(e.md?console.log("> No project ID found. Run `prjct init` first."):Qe.failWithHint("NO_PROJECT_ID"),{ok:!1,result:{success:!1,error:"No project ID found"}})}i(Ss,"requireProjectId");async function Io(r,e={}){let t=await At.ensureInit(r);return t.success?Ss(r,e):{ok:!1,result:t}}i(Io,"requireProject");export{vs as a,bs as b,Y as c,In as d,Jt as e,co as f,fo as g,go as h,Io as i};
|
|
@@ -5,4 +5,4 @@ import { dirname as __pathDirname } from 'path';
|
|
|
5
5
|
const require = __createRequire(import.meta.url);
|
|
6
6
|
const __filename = __fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __pathDirname(__filename);
|
|
8
|
-
import{c as y}from"./chunk-R4ILCXKE.mjs";import{e as g,g as T}from"./chunk-
|
|
8
|
+
import{c as y}from"./chunk-R4ILCXKE.mjs";import{e as g,g as T}from"./chunk-UHVYBU7F.mjs";import{d as b,e as I,o as A}from"./chunk-UH4MD3F3.mjs";import{a as l}from"./chunk-E66B27AL.mjs";import v from"node:fs/promises";import w from"node:path";T();A();var D=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 B(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&&!D.has(i)&&/^[a-z][a-z0-9]*$/.test(i))}l(B,"tokenizeFile");function R(t){return t.split(/\s+/).flatMap(n=>p(n)).filter(n=>n.length>1&&!D.has(n)&&/^[a-z][a-z0-9]*$/.test(n))}l(R,"tokenizeQuery");function x(){return Object.create(null)}l(x,"emptyInvertedIndex");async function C(t){let n=await b(t),e={},o=x(),r=await I(n,50,async c=>{try{let u=await v.readFile(w.join(t,c),"utf-8"),i=B(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(C,"buildIndex");function N(t,n){return Math.log((n-t+.5)/(t+.5)+1)}l(N,"idf");function F(t,n){let e=R(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=N(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)),L=d*(s/f);o.set(c,(o.get(c)||0)+L)}}return y(o)}l(F,"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 P(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(P,"removeDocument");function z(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(z,"addDocument");function q(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(q,"recalculateStats");var m=new Map;function _(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(_,"indexMetadata");function k(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(k,"writeDocumentRows");function W(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))k(r,a,d,c.tokens,o)})}catch{}}l(W,"replacePerFileTables");function $(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&&k(c,u,s,f.tokens,i)}})}catch{}}l($,"updatePerFileTables");function H(t,n){g.setDoc(t,h,_(n)),W(t,n),m.delete(t)}l(H,"saveIndex");function U(t,n,e,o){g.setDoc(t,h,_(n)),$(t,n,e,o),m.delete(t)}l(U,"saveIndexUpdate");function V(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(V,"loadIndexFromPerFileTables");function tt(t){try{return g.get(t,"SELECT key AS k FROM kv_store WHERE key = ? LIMIT 1",h)!=null}catch{return!1}}l(tt,"hasIndex");function O(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=V(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(O,"loadIndex");async function Y(t,n){let e=await C(t);return H(n,e),e}l(Y,"indexProject");async function nt(t,n,e,o=[]){let r=O(n);if(!r)return Y(t,n);let a=new Set([...e,...o]);for(let c of a)P(r,c);let d=await I(e,50,async c=>{try{let u=await v.readFile(w.join(t,c),"utf-8"),i=B(u,c);return{filePath:c,tokens:i}}catch{return null}});for(let{filePath:c,tokens:u}of d)z(r,c,u);return q(r),U(n,r,e,o),r}l(nt,"updateProjectIndex");function et(t,n,e=15){let o=O(t);return o?F(n,o).slice(0,e):[]}l(et,"queryFiles");export{tt as a,O as b,Y as c,nt as d,et as e};
|
|
@@ -5,6 +5,6 @@ import { dirname as __pathDirname } from 'path';
|
|
|
5
5
|
const require = __createRequire(import.meta.url);
|
|
6
6
|
const __filename = __fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __pathDirname(__filename);
|
|
8
|
-
import{a as S}from"./chunk-
|
|
8
|
+
import{a as S}from"./chunk-5XA5RL5I.mjs";import{a as m,b as c,c as g}from"./chunk-I26F7TLM.mjs";import{d as p,g as D}from"./chunk-UHVYBU7F.mjs";import{b as d,c as l,h as b}from"./chunk-A6K4H3YT.mjs";import{a as o}from"./chunk-E66B27AL.mjs";import{z as e}from"zod";var F=e.enum(["feature","fix","improvement","refactor"]),E=e.enum(["pass","warning","fail","skipped"]),_=e.enum(["added","changed","fixed","removed"]),v=e.object({hours:e.number(),minutes:e.number(),totalMinutes:e.number()}),O=e.object({filesChanged:e.number().nullable().optional(),linesAdded:e.number().nullable().optional(),linesRemoved:e.number().nullable().optional(),commits:e.number().nullable().optional()}),A=e.object({description:e.string(),type:_.optional()}),C=e.object({lintStatus:E.nullable().optional(),lintDetails:e.string().optional(),testStatus:E.nullable().optional(),testDetails:e.string().optional()}),T=e.object({hash:e.string().optional(),message:e.string().optional(),branch:e.string().optional()}),I=e.object({id:e.string(),name:e.string(),version:e.string().nullable().optional(),type:F,agent:e.string().optional(),description:e.string().optional(),changes:e.array(A).optional(),codeSnippets:e.array(e.string()).optional(),commit:T.optional(),codeMetrics:O.optional(),qualityMetrics:C.optional(),quantitativeImpact:e.string().optional(),duration:v.optional(),tasksCompleted:e.number().nullable().optional(),shippedAt:e.string(),featureId:e.string().optional()}),y=e.object({shipped:e.array(I),lastUpdated:e.string()});b();D();var f="shipped:backfilled:v1";function r(a){let s={...(()=>{if(!a.data)return{};try{return JSON.parse(a.data)}catch{return{}}})(),id:a.id,name:a.name,shippedAt:a.shipped_at,version:a.version};return a.description!=null&&(s.description=a.description),a.type!=null&&(s.type=a.type),a.duration!=null&&(s.duration=a.duration),s}o(r,"rowToFeature");var u=class extends S{static{o(this,"ShippedStorage")}constructor(){super("shipped.json",y)}getDefault(){return{shipped:[],lastUpdated:""}}getEventType(t){return`shipped.${t}d`}async getAll(t){return p.query(t,"SELECT * FROM shipped_features ORDER BY shipped_at DESC").map(r)}async republishShips(t){if(p.getDoc(t,f))return 0;let s=await this.getAll(t);for(let i of s)await this.publishEvent(t,"shipped_item.created",{id:i.id,shipId:i.id,name:i.name,version:i.version,shippedAt:i.shippedAt});return p.setDoc(t,f,{at:d(),count:s.length}),s.length}async getRecent(t,s=5){return p.query(t,"SELECT * FROM shipped_features ORDER BY shipped_at DESC LIMIT ?",s).map(r)}async addShipped(t,s,i){let n={...s,id:m(),shippedAt:i||d()};if(p.run(t,`INSERT OR IGNORE INTO shipped_features
|
|
9
9
|
(id, name, shipped_at, version, description, type, duration, data)
|
|
10
10
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,n.id,n.name,n.shippedAt,n.version??"",n.description??null,n.type??null,n.duration??null,JSON.stringify(n)).changes===0){let h=p.get(t,"SELECT * FROM shipped_features WHERE name = ? AND version = ? AND shipped_at = ?",n.name,n.version??"",n.shippedAt);return h?r(h):n}return await this.publishEvent(t,"shipped_item.created",{id:n.id,shipId:n.id,name:n.name,version:n.version,shippedAt:n.shippedAt}),n}async getByVersion(t,s){let i=p.get(t,"SELECT * FROM shipped_features WHERE version = ? ORDER BY shipped_at DESC LIMIT 1",s);return i?r(i):void 0}async getCount(t){return p.get(t,"SELECT COUNT(*) AS c FROM shipped_features")?.c??0}async getByDateRange(t,s,i){return p.query(t,"SELECT * FROM shipped_features WHERE shipped_at >= ? AND shipped_at <= ? ORDER BY shipped_at DESC",s.toISOString(),i.toISOString()).map(r)}async getStats(t,s="month"){let i=new Date,n=s==="week"?new Date(i.getTime()-10080*60*1e3):s==="month"?new Date(i.getFullYear(),i.getMonth(),1):new Date(i.getFullYear(),0,1);return{count:(await this.getByDateRange(t,n,i)).length,period:s}}async archiveOldShipped(t){let s=l(c.SHIPPED_RETENTION_DAYS).toISOString(),i=p.query(t,"SELECT * FROM shipped_features WHERE shipped_at < ? ORDER BY shipped_at DESC",s).map(r);return i.length===0?0:(g.archiveMany(t,i.map(n=>({entityType:"shipped",entityId:n.id,entityData:n,summary:`${n.name} v${n.version}`,reason:"age"}))),p.run(t,"DELETE FROM shipped_features WHERE shipped_at < ?",s),await this.publishEvent(t,"shipped.archived",{count:i.length,oldestShippedAt:i[i.length-1]?.shippedAt}),i.length)}},Y=new u;export{Y as a};
|
|
@@ -5,7 +5,7 @@ import { dirname as __pathDirname } from 'path';
|
|
|
5
5
|
const require = __createRequire(import.meta.url);
|
|
6
6
|
const __filename = __fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __pathDirname(__filename);
|
|
8
|
-
import{b as l,c as i,d as k}from"./chunk-
|
|
8
|
+
import{b as l,c as i,d as k}from"./chunk-T6ELTQZM.mjs";import{b as d}from"./chunk-XXRAQZNC.mjs";import{a as o}from"./chunk-E66B27AL.mjs";function u(t,n){let r=t===i?i:t.slice(0,6);return{shortId:r,label:`${r} \xB7 ${n??"(detached)"}`}}o(u,"labelFor");async function b(t,n){let r=await k(n),a=[],p=await d.getTaskSnapshot(t),s=p.currentTask;if(s){let{shortId:e,label:c}=u(i,s.branch);a.push({id:s.id,description:s.description,workspaceId:i,shortId:e,label:c,branch:s.branch,linearId:s.linearId,harness:s.harness,startedAt:s.startedAt,isCurrent:r.workspaceId===i,pipeline:l(t,s.id,i)??void 0})}for(let e of p.activeTasks){if(e.workspaceId===i)continue;let{shortId:c,label:h}=u(e.workspaceId,e.branch);a.push({id:e.id,description:e.description,workspaceId:e.workspaceId,shortId:c,label:h,branch:e.branch,linearId:e.linearId,harness:e.harness,startedAt:e.startedAt,isCurrent:r.workspaceId===e.workspaceId,pipeline:l(t,e.id,e.workspaceId)??void 0})}return a.sort((e,c)=>Number(c.isCurrent)-Number(e.isCurrent)),{current:a.find(e=>e.isCurrent)??null,all:a,mainTaskRaw:s}}o(b,"collectActiveTasks");function T(t){let n=t.isCurrent?"\u2192":" ",r=t.isCurrent?" (this worktree)":"";return`${n} ${t.label} ${t.description}${r}`}o(T,"formatActiveTaskLine");function m(t){if(t.all.length===0)return"No active work cycle.";if(t.all.length===1&&t.current){let r=t.current,a=r.pipeline?`
|
|
9
9
|
Pipeline: ${r.pipeline.station}`:"";return`Active: ${r.description}
|
|
10
10
|
Workspace: ${r.label}${a}`}let n=[`Active work cycles (${t.all.length})`];for(let r of t.all)n.push(T(r));return n.join(`
|
|
11
11
|
`)}o(m,"formatActiveTaskList");export{b as a,T as b,m as c};
|
|
@@ -5,7 +5,7 @@ import { dirname as __pathDirname } from 'path';
|
|
|
5
5
|
const require = __createRequire(import.meta.url);
|
|
6
6
|
const __filename = __fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __pathDirname(__filename);
|
|
8
|
-
import{d as b}from"./chunk-SYHDEUVU.mjs";import{a as j}from"./chunk-GCKILEXJ.mjs";import{c as p,e as A}from"./chunk-
|
|
8
|
+
import{d as b}from"./chunk-SYHDEUVU.mjs";import{a as j}from"./chunk-GCKILEXJ.mjs";import{c as p,e as A}from"./chunk-GCDLPKOH.mjs";import{b as w}from"./chunk-PKDYFXMI.mjs";import{a as e}from"./chunk-E66B27AL.mjs";import g from"node:fs";import H from"node:fs/promises";import m from"node:path";var I=j.join("/"),R="Generated with [p/](https://www.prjct.app/)",P="<!-- prjct:start - DO NOT REMOVE THIS MARKER -->",L="<!-- prjct:end - DO NOT REMOVE THIS MARKER -->",n={rag:"prjct is a RAG-backed project memory harness; do not preload project history.",entrypoint:'Tasks \u2192 `prjct work "\u2026"`. Known cmds (`sync`/`search`/`remember`/\u2026) \u2192 `prjct <cmd>` \u2014 never work-wrap.',pull:"Pull only what surfaces: `prjct search` / `context memory` / `guard` / MCP \u2014 not something to load wholesale.",remember:'Save synthesized memory in English: `prjct remember <decision|learning|gotcha|context> "<text>"`.',kb:`KB (\`${I}\`): \`remember <facet>\` / \`context memory <facet>\` \u2014 on demand, never injected here.`,ship:"Ship only after user OKs: `prjct ship --md`.",loop:"Loop: land; H2+ intent; tip\u2192user SoT; close.",identity:"L0 portable; id=cwd."};function S(){return`${["---","name: prjct","description: prjct work cycles + memory; run prjct verbs, do not preload context.","---","","# prjct","","Run `prjct <cmd> --md` and follow it.","",`- ${n.rag}`,`- ${n.entrypoint}`,`- ${n.pull}`,`- ${n.remember}`,`- ${n.kb}`,`- ${n.ship}`,`- ${n.loop}`,`- ${n.identity}`,"",`Commit footer: \`${R}\``].join(`
|
|
9
9
|
`)}
|
|
10
10
|
`}e(S,"buildCompactSkill");var M=S,_=S;function O(t){return`${["<!-- prjct:start - DO NOT REMOVE THIS MARKER -->","# p/ \u2014 Context layer for AI agents","","Skills auto-activate for: work, intent, ship, sync, guard, remember, search, insights, performance","Other commands: run `prjct <command> --md` and follow CLI output","","Flow: known verbs run as `prjct <cmd> --md` (sync, search, remember, ship, guard, land, prime\u2026).",'`prjct work` is only for task/work cycles \u2014 never wrap a bare verb as work "sync".',"Substantive implementation follows the persisted work-cycle station from `prjct work --md`:","reviewed intent, evidence, tests when required, then code.","Sync analysis: prefer schema v1 JSON via `prjct analysis-save-llm` (markdown = thin notes only).","","Data:","- Persist everything (memories, context, intents) in ENGLISH, whatever language the user speaks",`- ${n.rag}`,`- ${n.entrypoint}`,`- ${n.pull}`,`- Sovereign knowledge base \u2014 ${n.kb}`,`- ${n.remember}`,`- ${n.loop}`,"- On close, save synthesized context; raw quotes, counters, detector rows, and transcript chunks are inputs, not final memory","- prjct remembers and shows the path; the agent decides how to execute with its own native tools","- Treat prjct output as signals, not a prescriptive harness",`- Commit footer: \`${R}\``,"- Path resolution: `.prjct/prjct.config.json` \u2192 `~/.prjct-cli/projects/{projectId}`","- Storage: `prjct` CLI (SQLite internally)","- Worktree hygiene: if working in a git worktree, remove it AFTER its PR merges \u2014 `git worktree remove` from the main worktree; never with uncommitted/unpushed work, never `--force`","",`Crew (opt-in via \`prjct crew install\`): Leader (blue) \xB7 Implementer (purple) \xB7 Reviewer (pink). Subagent dispatch is Claude-Code-only; in ${t}, identify the role you are playing explicitly.`,"","**Auto-managed by prjct-cli** | https://prjct.app","<!-- prjct:end - DO NOT REMOVE THIS MARKER -->"].join(`
|
|
11
11
|
`)}
|