@unbrained/pm-cli 2026.8.4 → 2026.8.5
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +39 -13
- package/dist/cli/error-guidance.js +4 -4
- package/dist/cli/register-structured-mutation.d.ts +2 -0
- package/dist/cli/register-structured-mutation.js +124 -12
- package/dist/cli-bundle/bundle-manifest.json +407 -407
- package/dist/cli-bundle/chunks/append-VXXGOXSG.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-QVO3VTA4.js → chunk-2WFXWAYX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NM5G7RLU.js → chunk-3FTILRJ2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VH2EAGUG.js → chunk-42E7YPLG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RB65T4RX.js → chunk-43HQQI6S.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-J4EPW4GT.js → chunk-45G53IU4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PQXEB7W4.js → chunk-4VN6GS4U.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-4YUBDMQM.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-D2MBVMVE.js → chunk-54FNT7U2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NRDKVOUE.js → chunk-5ZBOIPGP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3XZYTRPC.js → chunk-6MSQJOTG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GOICHIX4.js → chunk-7A5OT5J2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HTYC76A4.js → chunk-7C4PTJG6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BKMZTZYL.js → chunk-A62CYISG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5H47J5FG.js → chunk-BPELKUQD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HE3DZFN4.js → chunk-BXQLRKWF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BLINBTMX.js → chunk-CSI3WS5I.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KH4GVBMC.js → chunk-DXDREUXT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KIKLF2W4.js → chunk-E2RKBKWB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-377OOXUF.js → chunk-EGJ4JTUG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SULWTPQO.js → chunk-FPBQHMFT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V5K52PYW.js → chunk-GE4KCSZP.js} +35 -35
- package/dist/cli-bundle/chunks/{chunk-NPUJ7OLK.js → chunk-HNFD72UK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QMWUL66F.js → chunk-HWRRMBJO.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-L3AZOELJ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-CGY5I2GO.js → chunk-LKDGK44W.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-LN2WFEU4.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZSH4GNBH.js → chunk-M72BKL5Q.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HQ2WU7OY.js → chunk-MHK6LIWE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-H6FITE7D.js → chunk-NE5VRDAI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NY4T3JWN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-DCJ6CM6F.js → chunk-OMXVBQ2N.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-OPVH7SKD.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-CU5ENFNP.js → chunk-OTHLDSFP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NH35JNK5.js → chunk-PMXJEU3F.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SVDH5CHC.js → chunk-Q35VBGOQ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-5PZGZMPG.js → chunk-R546TPDE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q5F6OI7C.js → chunk-RKAVWO3O.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JMKVCQSE.js → chunk-SSF4PIUR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PA5XRN2A.js → chunk-UN66FZRO.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FQ4EFFDU.js → chunk-UP7DTVMD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NFF3JAQR.js → chunk-UZBWIUYD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2POYGY53.js → chunk-V3774P7D.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-B5ZLCD5Z.js → chunk-V3EUXXOF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6S7I3UKV.js → chunk-VCKLFEUN.js} +19 -19
- package/dist/cli-bundle/chunks/{chunk-PYYPQLHC.js → chunk-VN5VITU3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WRL4KNDL.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-UJHUR3LZ.js → chunk-XCEZYMNI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JDPKBV5P.js → chunk-YEWNL576.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OB7TRZ2G.js → chunk-YSO3YFZ4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UVZREFZU.js → chunk-ZYHOB3SN.js} +2 -2
- package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +2 -0
- package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +2 -0
- package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +2 -0
- package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +2 -0
- package/dist/cli-bundle/chunks/{create-RLLCBCXM.js → create-XLKTXTUF.js} +2 -2
- package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +2 -0
- package/dist/cli-bundle/chunks/{deps-J4ONTF4X.js → deps-ITTY3GIC.js} +2 -2
- package/dist/cli-bundle/chunks/{docs-YL2DJ4WD.js → docs-W4OSRTYR.js} +2 -2
- package/dist/cli-bundle/chunks/{files-NGNAIYKK.js → files-EOK4AZI4.js} +2 -2
- package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +2 -0
- package/dist/cli-bundle/chunks/{history-compact-HW62K5XP.js → history-compact-7UGTMLL3.js} +2 -2
- package/dist/cli-bundle/chunks/{history-redact-HVBKUJOW.js → history-redact-4DZRMD6Z.js} +2 -2
- package/dist/cli-bundle/chunks/{history-repair-OPNBH5JJ.js → history-repair-UPOSZW5R.js} +2 -2
- package/dist/cli-bundle/chunks/{learnings-F36PZXT6.js → learnings-GMRNCBS3.js} +2 -2
- package/dist/cli-bundle/chunks/{profile-N3XMWBM7.js → profile-2MUUMHRE.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-BKGHBI7Y.js → register-list-query-LR3SQ5ZF.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-SUOHFVWM.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-ARRRKOVN.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-KWV6UD77.js → register-setup-O6AYP6NP.js} +2 -2
- package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +2 -0
- package/dist/cli-bundle/chunks/{schema-4PJQMGUY.js → schema-FJ4EA3XF.js} +2 -2
- package/dist/cli-bundle/chunks/update-YHV52CSS.js +2 -0
- package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-7J5TUBUJ.js +153 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ONIX2KKW.js → chunk-A7BJ5SS6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-B7LJWAZE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QM2BIVK7.js → chunk-BIMTMOS7.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-BOGRY7M6.js → chunk-FGKY4MBE.js} +10 -10
- package/dist/cli-bundle/focused-chunks/chunk-G6ETT4QK.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-C2QSL62X.js → chunk-GJ2TG2CW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RO5BQFG3.js → chunk-IPWSFADF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UFCPSWIL.js → chunk-MJ7HWSFK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2VIIXOAD.js → chunk-N5XU5UVK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-PG2RIZBX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OYTK4VNH.js → chunk-PIMMYG7Q.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-K37BB4JL.js → chunk-QVHKCI4T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SQXVGHMH.js → chunk-RUR5I3TK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SV3O7TSH.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-L6A4NVQC.js → chunk-UIL2M2NA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WVGJAD7L.js → chunk-VLYOEYML.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-W7BJEWHX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DQ4PLKEE.js → chunk-WEM2E2PE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WVIVUWVL.js +5 -0
- package/dist/cli-bundle/focused-chunks/chunk-Y4LDYLLT.js +2 -0
- package/dist/cli-bundle/main.js +4 -4
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +28 -28
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +1 -1
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +1 -1
- package/dist/core/extensions/loader.js +5 -2
- package/dist/core/item/item-format.js +14 -20
- package/dist/core/shared/constants.js +3 -2
- package/dist/core/store/item-store.js +2 -2
- package/dist/core/store/settings.js +2 -2
- package/dist/mcp/server.js +12 -6
- package/dist/mcp/tool-definitions.js +14 -7
- package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +18 -18
- package/dist/sdk/cli-contracts/agent-output-contracts.js +51 -23
- package/dist/sdk/cli-contracts/commander-mutation-options.js +26 -2
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +28 -2
- package/dist/sdk/cli-contracts/registration-helpers.js +4 -2
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +10 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +20 -5
- package/dist/sdk/cli-contracts/tool-schema.js +4 -2
- package/dist/sdk/cli-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts.js +4 -4
- package/dist/sdk/cli-program.js +3 -3
- package/dist/sdk/contracts.d.ts +1 -0
- package/dist/sdk/contracts.js +3 -2
- package/dist/sdk/dependency-provenance.d.ts +2 -0
- package/dist/sdk/dependency-provenance.js +7 -3
- package/dist/sdk/error-code-catalog.d.ts +23 -0
- package/dist/sdk/error-code-catalog.js +25 -5
- package/dist/sdk/generated-error-code-catalog.js +499 -3
- package/dist/sdk/graph/governance.js +3 -3
- package/dist/sdk/graph/remediation.js +3 -3
- package/dist/sdk/graph/run.js +4 -8
- package/dist/sdk/index.d.ts +2 -1
- package/dist/sdk/index.js +4 -3
- package/dist/sdk/item-transaction.d.ts +51 -6
- package/dist/sdk/item-transaction.js +132 -22
- package/dist/sdk/lifecycle/create.d.ts +4 -0
- package/dist/sdk/lifecycle/create.js +26 -10
- package/dist/sdk/lifecycle-policy.d.ts +9 -0
- package/dist/sdk/lifecycle-policy.js +22 -9
- package/dist/sdk/merge/driver.js +6 -3
- package/dist/sdk/output-contracts.d.ts +67 -0
- package/dist/sdk/output-contracts.js +173 -0
- package/dist/sdk/package-import-adapters.js +2 -2
- package/dist/sdk/structured-mutations.d.ts +23 -0
- package/dist/sdk/structured-mutations.js +219 -10
- package/dist/sdk/workspace-snapshot.js +58 -12
- package/dist/sdk/workspace.js +30 -4
- package/docs/COMMANDS.md +40 -10
- package/docs/EXTENSIONS.md +1 -1
- package/docs/MERGE_SAFETY.md +2 -0
- package/docs/PR_REVIEW_LOOP.md +10 -4
- package/docs/README.md +22 -22
- package/docs/RELEASING.md +3 -3
- package/docs/SCRIPTING.md +32 -9
- package/docs/SDK.md +91 -11
- package/docs/SELF_DESCRIBING_CONTEXT_CONTRACTS.md +13 -0
- package/docs/TESTING.md +25 -0
- package/docs/examples/sdk-contract-consumer/README.md +11 -1
- package/docs/examples/sdk-contract-consumer/package.json +2 -1
- package/docs/examples/sdk-contract-consumer/parse-receipt.mjs +22 -0
- package/marketplace.json +2 -2
- package/package.json +3 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +292 -14
- package/dist/cli-bundle/chunks/append-DHBRLHHS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-2INN52SU.js +0 -8
- package/dist/cli-bundle/chunks/chunk-6RSK4IFN.js +0 -20
- package/dist/cli-bundle/chunks/chunk-ASJJKA57.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IYAVULRN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-RRQBHQOV.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XBLOD5TZ.js +0 -2
- package/dist/cli-bundle/chunks/close-VLHNN6YB.js +0 -2
- package/dist/cli-bundle/chunks/close-many-LSJNZKU6.js +0 -2
- package/dist/cli-bundle/chunks/comments-AAIA6A6X.js +0 -2
- package/dist/cli-bundle/chunks/copy-Z7YMLEHN.js +0 -2
- package/dist/cli-bundle/chunks/delete-KNOHHQJM.js +0 -2
- package/dist/cli-bundle/chunks/focus-LFRCGALV.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-GU3DCECN.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-PTWH727R.js +0 -2
- package/dist/cli-bundle/chunks/restore-4HZSLILR.js +0 -2
- package/dist/cli-bundle/chunks/update-E6LPS5IV.js +0 -2
- package/dist/cli-bundle/chunks/update-many-OSIC6KRO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-5MTKO7TV.js +0 -153
- package/dist/cli-bundle/focused-chunks/chunk-6GIZK7VQ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-AOP2WIZZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CL75YW32.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-E7OFMWGT.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-I5F5UK3Q.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-T5TSY36R.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-VT6BF2IX.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as Ke,c as Cr,d as Xe}from"./chunk-B5ZLCD5Z.js";import{B as Lr,C as Nr,D as Mr,E as Dr,F as jr,H as Gr,M as Kr,V as ln,W as pn,X as un,Z as Xr,b as en,c as Jo,d as Be,f as gr,ha as Zr,ia as Qr,ja as ei,k as yr,l as Re,m as br,n as wr,o as vr,p as kr,q as Sr,w as Je,x as $r,y as Fr,z as Pr}from"./chunk-6RSK4IFN.js";import{a as sn}from"./chunk-KH4GVBMC.js";import{a as Ho}from"./chunk-J4EPW4GT.js";import{r as Ur,s as qr,t as zr,u as Hr}from"./chunk-5PZGZMPG.js";import{a as Qo}from"./chunk-HQ2WU7OY.js";import{b as Er,c as an,d as cn}from"./chunk-NFF3JAQR.js";import{a as xr}from"./chunk-DCJ6CM6F.js";import{a as er}from"./chunk-NM5G7RLU.js";import{a as Vr,c as Br,d as Wr}from"./chunk-QVO3VTA4.js";import{a as Xo}from"./chunk-2POYGY53.js";import{a as Vo,c as Bo,e as Wo,g as Yo}from"./chunk-D2MBVMVE.js";import{a as nn}from"./chunk-CU5ENFNP.js";import{a as on}from"./chunk-GOICHIX4.js";import{a as fe}from"./chunk-PYYPQLHC.js";import{a as hr,b as Ar}from"./chunk-HTYC76A4.js";import{h as Ie,o as Ye,u as Ir}from"./chunk-377OOXUF.js";import{F as nr,I as sr,J as or,L as rr,M as ir,N as ar,O as cr,P as mr,Q as dr,R as lr,S as pr,T as ur,U as fr,V as _r,b as qo,p as tr}from"./chunk-6S7I3UKV.js";import{D as mn,F as Rr,G as Tr,Z as Jr,b as Uo,e as Xt,g as Zo,m as rn}from"./chunk-SVDH5CHC.js";import{h as zo,ja as Zt,oa as Qt}from"./chunk-3XZYTRPC.js";import{n as Yr}from"./chunk-CGY5I2GO.js";import{p as Or,r as dn}from"./chunk-2INN52SU.js";import{b as ro,c as io,o as ao}from"./chunk-ASJJKA57.js";import{P as Ae}from"./chunk-QMWUL66F.js";import{a as Ko}from"./chunk-BLINBTMX.js";import{a as tn}from"./chunk-NPUJ7OLK.js";import{c as We}from"./chunk-NH35JNK5.js";import{u as Kt}from"./chunk-Q5F6OI7C.js";import{b as Go}from"./chunk-RB65T4RX.js";import{i as jo}from"./chunk-UVZREFZU.js";import{$ as bo,A as ho,Ba as No,Ca as Ve,Da as Mo,Ea as Do,Ha as S,S as go,T as yo,ba as wo,c as co,e as mo,f as He,g as lo,ia as vo,ja as ko,la as So,m as po,na as xo,oa as Eo,pa as Ao,qa as Io,ra as Ro,sa as Co,ta as To,u as uo,ua as Oo,v as fo,va as $o,wa as Fo,x as _o,xa as Po,ya as Lo}from"./chunk-JDPKBV5P.js";import{Ba as oo,C as Vt,E as Bt,I as Ws,J as Ys,K as Js,L as Ks,M as Xs,O as Zs,P as Qs,Q as eo,R as Ee,S as to,T as ze,U as no,V as Wt,W as Yt,X as so,e as Os,f as $s,x as Hs,y as Vs}from"./chunk-BKMZTZYL.js";import{a as zs}from"./chunk-NRDKVOUE.js";import{a as Jt}from"./chunk-A6KGKEWT.js";import{a as Ut}from"./chunk-VH2EAGUG.js";import{$ as ys,A as _,Bb as C,Be as Us,C as u,Da as ee,E as gs,Ea as bs,Ec as Ge,Gd as J,If as Bs,Jf as qt,Kf as zt,La as $,N as ke,Nc as re,Oa as U,Pc as Lt,Qc as Fs,Qf as Ht,R as k,Ra as xt,Sd as Ps,T as De,Ud as Ls,Vb as Et,Wb as At,Xb as It,Xd as Ns,Xe as jt,Ye as Gt,Zb as Is,aa as yt,ad as Nt,b as G,ca as bt,cd as Mt,ce as Ms,d as Q,dc as Rs,dd as Ue,ec as Rt,f as gt,fc as Ct,g as ps,gc as Tt,gd as qe,gf as qs,hc as Ot,hd as Se,hf as xe,ib as je,ic as $t,id as Dt,jc as Ft,je as Ds,k as us,kc as Pt,kf as ie,l as fs,lb as pe,lc as q,m as _s,me as ue,n as hs,qe as js,sa as wt,sb as ws,ta as vt,tb as vs,ua as kt,ub as ks,uc as oe,va as St,vb as Ss,wb as xs,xb as Es,yb as As,yc as Cs,yf as D,zc as Ts,zd as V,ze as Gs}from"./chunk-V5K52PYW.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bb16b445-3bd4-520d-becf-c55621bfa186")}catch{}})();var mp=ps,dp=us,lp=hs,pp=fs,up=_s;function ti(e,t,n,s){let o=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),r=n.has(o);return{long:t,...s?{short:s}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:r?"string":"boolean",...r?{value_name:e.value_name??"value"}:{}}}function ni(e,t=[]){let n=new Set(t.flatMap(o=>o.keys)),s=[];for(let o of co(e.map(r=>({...r})))){s.push(ti(o,o.flag,n,o.short));for(let r of o.aliases??[])s.push(ti(o,r,n))}return s}var fp=ni(He,ro),xa=ni(Ve,io);import{AsyncLocalStorage as pl}from"node:async_hooks";import ua from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="27dd77f6-e53d-55b7-be15-db0e60eaec4e")}catch{}})();function si(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ea(e){return e.brief===!0?"brief":typeof e.fields=="string"&&e.fields.trim().length>0||Array.isArray(e.fields)&&e.fields.length>0?"fields":e.compact===!0?"compact":"full"}function fn(e,t){let n=Ea(t),s=n==="brief"?n:si(e.projection)&&typeof e.projection.mode=="string"?e.projection.mode:n;return{...e,query_summary:{filters:si(e.filters)?e.filters:{},projection:s}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b9eae1a3-3eb6-5415-86c3-a8e8e1fedd1f")}catch{}})();function oi(e){return e.map(t=>({key:t.key,optionName:Fs(t),metadataKey:t.metadata_key,type:t.type,commands:[...t.commands],repeatable:t.repeatable,requiredOnCreate:t.required_on_create,...t.description?{description:t.description}:{}}))}function ri(e){return e.map(t=>({command:t.command,action:t.action,arguments:t.arguments.map(n=>({name:n.name,required:n.required===!0,variadic:n.variadic===!0,description:n.description})),description:t.description,tier:t.tier??"standard"}))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7c898a52-eba4-5626-8207-5ffefd4990ba")}catch{}})();var Aa=50,te=new Map;function _n(){te.clear()}function ii(e,t){let n=te.get(e);if(n!==void 0)return n;if(te.size>=Aa){let o=te.keys().next().value;te.delete(o)}let s=t().catch(o=>{throw te.get(e)===s&&te.delete(e),o});return te.set(e,s),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6f62939a-7b99-5687-93ae-834e0032f1d5")}catch{}})();var Ia={"list-all":{action:"list",options:{excludeTerminal:!1}},"list-draft":{action:"list",options:{status:"draft",excludeTerminal:!1}},"list-open":{action:"list",options:{status:"open",excludeTerminal:!1}},"list-in-progress":{action:"list",options:{status:"in_progress",excludeTerminal:!1}},"list-blocked":{action:"list",options:{status:"blocked",excludeTerminal:!1}},"list-closed":{action:"list",options:{status:"closed",excludeTerminal:!1}},"list-canceled":{action:"list",options:{status:"canceled",excludeTerminal:!1}}};function ai(e){return Object.fromEntries(Gs.map(t=>[`${e}-${t}`,{action:e,options:{[t==="adopt-all"?"adoptAll":t]:!0,...e==="package"?{vocabulary:"package"}:{}}}]))}var hn={ctx:{action:"context"},...Ia,...ai("extension"),...ai("package")};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="41012e87-ed61-56b2-8505-8f786b3952b2")}catch{}})();var ci="PmCliError";function Ra(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=_.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function Ca(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new u(e,Ra(t.exitCode??_.USAGE),t.context??{});return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function gn(e){if(!(e instanceof Error)||e.name!==ci)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)}import{constants as Ce}from"node:fs";import{lstat as mi,mkdir as bn,open as di}from"node:fs/promises";import K from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c53bb1b7-12b9-5370-a85b-cdd8bef57936")}catch{}})();function yn(e,t){if(typeof e!="string"||e.trim().length===0)throw new TypeError(`Relationship event ${t} must be non-empty`);return e.trim()}function wn(e,t){let n=t.require(e.kind),s=n.direction==="undirected"?[e.source,e.target].sort().join("\0"):`${e.source}\0${e.target}`;return`${n.kind}\0${s}`}function Ta(e){return Object.freeze({...e,...e.payload===void 0?{}:{payload:Object.freeze(structuredClone(e.payload))}})}function Oa(e,t,n,s){let o=n.require(e.kind),r=s.outgoingOne.get(`${o.kind}\0${e.source}`);if(r!==void 0&&r!==t)throw new TypeError(`Relationship outgoing cardinality exceeded for ${o.kind}`);let i=s.incomingOne.get(`${o.kind}\0${e.target}`);if(i!==void 0&&i!==t)throw new TypeError(`Relationship incoming cardinality exceeded for ${o.kind}`);let a=wn(e,n),c=s.identities.get(a);if(c!==void 0&&c!==t)throw new TypeError(`Relationship edge already active: ${a}`)}function $a(e){let t=new Map;for(let n of e)n.action==="remove"?t.delete(n.relationshipId):t.set(n.relationshipId,n.edge);return t}function Fa(e,t,n){if(e.expectedVersion!==void 0&&e.expectedVersion!==t)throw new TypeError(`Relationship event version conflict: expected ${e.expectedVersion}, current ${t}`);let s=yn(e.eventId,"eventId");if(n.has(s))throw new TypeError(`Relationship event already exists: ${s}`);if(e.action!=="add"&&e.action!=="remove"&&e.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${e.action}`);if(!Number.isFinite(Date.parse(e.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:s,relationshipId:yn(e.relationshipId,"relationshipId"),author:yn(e.author,"author"),timestamp:new Date(e.timestamp).toISOString()}}function Pa(e,t,n,s,o,r){let i=n.has(t);if(e.action==="add"&&i)throw new TypeError(`Relationship is already active: ${t}`);if(e.action!=="add"&&!i)throw new TypeError(`Relationship is not active: ${t}`);if(e.action==="remove")return;if(!e.edge)throw new TypeError(`Relationship ${e.action} event requires an edge`);let a=typeof e.edge.source=="string"?e.edge.source.trim():"",c=typeof e.edge.target=="string"?e.edge.target.trim():"";if(!s.has(a)||!s.has(c))throw new TypeError(`Relationship endpoint not found: ${a} -> ${c}`);let d=new pe([a,c],[e.edge],o).edges()[0];return Oa(d,t,o,r),Ta(d)}var Te=class{#t;#n;#s=[];#r=new Set;#e=new Map;#o={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(t,n={}){this.#t=new Set([...t].filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean)),this.#n=n.registry??je()}get version(){return this.#s.length}events(){return Object.freeze([...this.#s])}*stream(t={}){let n=t.fromVersion??1,s=t.toVersion??this.version,o=t.batchSize??100;if(!Number.isInteger(n)||n<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(s)||s<0||s>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${s}`);if(!Number.isInteger(o)||o<1)throw new TypeError("Relationship event stream batchSize must be positive");if(n>s+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let r=n-1;r<s;r+=o)yield Object.freeze(this.#s.slice(r,Math.min(r+o,s)))}project(t,n,s={}){if(typeof n!="function")throw new TypeError("Relationship event projection requires a reducer");let o=t,r=0,i;for(let a of this.stream({...s,batchSize:256}))for(let c of a)o=n(o,c),r+=1,i=c;return Object.freeze({state:o,version:i?.sequence??Math.max(0,(s.fromVersion??1)-1),processed:r,...i===void 0?{}:{asOf:i.timestamp}})}#i(t,n){let s=this.#n.require(n.kind);this.#o.identities.set(wn(n,this.#n),t),s.outgoing==="one"&&this.#o.outgoingOne.set(`${s.kind}\0${n.source}`,t),s.incoming==="one"&&this.#o.incomingOne.set(`${s.kind}\0${n.target}`,t)}#a(t){let n=this.#n.require(t.kind);this.#o.identities.delete(wn(t,this.#n)),n.outgoing==="one"&&this.#o.outgoingOne.delete(`${n.kind}\0${t.source}`),n.incoming==="one"&&this.#o.incomingOne.delete(`${n.kind}\0${t.target}`)}append(t){let n=Fa(t,this.version,this.#r),s=this.#e.get(n.relationshipId),o=Pa(t,n.relationshipId,this.#e,this.#t,this.#n,this.#o),r=Object.freeze({eventId:n.eventId,relationshipId:n.relationshipId,action:t.action,...o===void 0?{}:{edge:o},author:n.author,timestamp:n.timestamp,...t.reason?.trim()?{reason:t.reason.trim()}:{},sequence:this.version+1});return this.#s.push(r),this.#r.add(n.eventId),s&&this.#a(s),t.action==="remove"?this.#e.delete(n.relationshipId):(this.#e.set(n.relationshipId,o),this.#i(n.relationshipId,o)),r}snapshot(t={}){if(t.atVersion!==void 0&&t.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let n;if(t.atTimestamp!==void 0){let r=Date.parse(t.atTimestamp);if(!Number.isFinite(r))throw new TypeError("Relationship snapshot timestamp must be valid");n=this.#s.filter(i=>Date.parse(i.timestamp)<=r)}else{let r=t.atVersion??this.version;if(!Number.isInteger(r)||r<0||r>this.version)throw new TypeError(`Relationship snapshot version out of range: ${r}`);n=this.#s.slice(0,r)}let s=$a(n),o=new pe(this.#t,s.values(),this.#n);return Object.freeze({version:n.at(-1)?.sequence??0,...n.at(-1)?{asOf:n.at(-1).timestamp}:{},edges:o.edges(),graph:o})}page(t){if(!Number.isInteger(t.limit)||t.limit<1)throw new TypeError("Relationship event page limit must be positive");let n=Ps("relationship-events",{order:"append-sequence"}),s=t.cursor===void 0?this.version:Number(Ls(t.cursor,n).snapshot);if(!Number.isSafeInteger(s)||s<0||s>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let o=Ns(this.#s.slice(0,s),{cursor:t.cursor,fingerprint:n,limit:t.limit,readId:r=>r.eventId,snapshot:String(s)});return{version:s,events:o.rows,hasMore:o.has_more,...o.next_cursor?{nextCursor:o.next_cursor}:{}}}},La="relationship-event-store",li=Ce.O_NOFOLLOW;function Ze(e){return ie(e,La,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function ae(e,t="relationships/events.jsonl"){let n=K.resolve(e),s=K.resolve(n,t),o=K.relative(n,s);if(o.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(o===".."||o.startsWith(`..${K.sep}`)||K.isAbsolute(o))throw new TypeError("Relationship event path must stay within the tracker root");if(await bn(n,{recursive:!0}),(await mi(n)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let i=n;for(let a of o.split(K.sep)){i=K.join(i,a);try{if((await mi(i)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(c){if(c.code==="ENOENT")break;throw c}}return s}async function Qe(e,t,n){let s=new Te(t,{registry:n}),o,r;try{r=await di(e,Ce.O_RDONLY|li),o=await r.readFile("utf8")}catch(a){if(a.code==="ENOENT")return{log:s,raw:""};throw a}finally{await r?.close()}let i=o.split(`
|
|
1
|
+
import{b as Ke,c as Cr,d as Xe}from"./chunk-V3EUXXOF.js";import{B as Lr,C as Nr,D as Mr,E as Dr,F as jr,H as Gr,M as Kr,aa as ln,b as en,ba as pn,c as Jo,ca as un,d as Be,ea as Xr,f as gr,k as yr,l as Re,m as br,n as wr,o as vr,oa as Zr,p as kr,pa as Qr,q as Sr,qa as ei,w as Je,x as $r,y as Fr,z as Pr}from"./chunk-WRL4KNDL.js";import{a as sn}from"./chunk-DXDREUXT.js";import{a as Ho}from"./chunk-45G53IU4.js";import{r as Ur,s as qr,t as zr,u as Hr}from"./chunk-R546TPDE.js";import{a as Qo}from"./chunk-MHK6LIWE.js";import{b as Er,c as an,d as cn}from"./chunk-UZBWIUYD.js";import{a as xr}from"./chunk-OMXVBQ2N.js";import{a as er}from"./chunk-3FTILRJ2.js";import{a as Vr,c as Br,d as Wr}from"./chunk-2WFXWAYX.js";import{a as Xo}from"./chunk-V3774P7D.js";import{a as Vo,c as Bo,e as Wo,g as Yo}from"./chunk-54FNT7U2.js";import{a as nn}from"./chunk-OTHLDSFP.js";import{a as on}from"./chunk-7A5OT5J2.js";import{a as fe}from"./chunk-VN5VITU3.js";import{a as hr,b as Ar}from"./chunk-7C4PTJG6.js";import{h as Ie,o as Ye,u as Ir}from"./chunk-EGJ4JTUG.js";import{F as nr,I as sr,J as or,L as rr,M as ir,N as ar,O as cr,P as mr,Q as dr,R as lr,S as pr,T as ur,U as fr,V as _r,b as qo,p as tr}from"./chunk-VCKLFEUN.js";import{D as mn,F as Rr,G as Tr,Z as Jr,b as Uo,e as Xt,g as Zo,m as rn}from"./chunk-Q35VBGOQ.js";import{h as zo,ja as Zt,oa as Qt}from"./chunk-6MSQJOTG.js";import{n as Yr}from"./chunk-LKDGK44W.js";import{p as Or,r as dn}from"./chunk-OPVH7SKD.js";import{b as ro,c as io,o as ao}from"./chunk-LN2WFEU4.js";import{P as Ae}from"./chunk-HWRRMBJO.js";import{a as Ko}from"./chunk-CSI3WS5I.js";import{a as tn}from"./chunk-HNFD72UK.js";import{c as We}from"./chunk-PMXJEU3F.js";import{u as Kt}from"./chunk-RKAVWO3O.js";import{b as Go}from"./chunk-43HQQI6S.js";import{i as jo}from"./chunk-ZYHOB3SN.js";import{$ as bo,A as ho,Ca as No,Da as Ve,Ea as Mo,Fa as Do,Ia as S,S as go,T as yo,ba as wo,c as co,e as mo,f as He,g as lo,ia as vo,ja as ko,la as So,m as po,oa as xo,pa as Eo,qa as Ao,ra as Io,sa as Ro,ta as Co,u as uo,ua as To,v as fo,va as Oo,wa as $o,x as _o,xa as Fo,ya as Po,za as Lo}from"./chunk-YEWNL576.js";import{Ba as oo,C as Vt,E as Bt,I as Ws,J as Ys,K as Js,L as Ks,M as Xs,O as Zs,P as Qs,Q as eo,R as Ee,S as to,T as ze,U as no,V as Wt,W as Yt,X as so,e as Os,f as $s,x as Hs,y as Vs}from"./chunk-A62CYISG.js";import{a as zs}from"./chunk-5ZBOIPGP.js";import{a as Jt}from"./chunk-A6KGKEWT.js";import{a as Ut}from"./chunk-42E7YPLG.js";import{$ as ys,A as _,Af as D,Bb as C,Be as Us,C as u,Da as ee,E as gs,Ea as bs,Ec as Ge,Gd as J,Kf as Bs,La as $,Lf as qt,Mf as zt,N as ke,Nc as re,Oa as U,Pc as Lt,Qc as Fs,R as k,Ra as xt,Sd as Ps,Sf as Ht,T as De,Ud as Ls,Vb as Et,Wb as At,Xb as It,Xd as Ns,Zb as Is,Ze as jt,_e as Gt,aa as yt,ad as Nt,b as G,ca as bt,cd as Mt,ce as Ms,d as Q,dc as Rs,dd as Ue,ec as Rt,f as gt,fc as Ct,g as ps,gc as Tt,gd as qe,hc as Ot,hd as Se,ib as je,ic as $t,id as Dt,if as qs,jc as Ft,je as Ds,jf as xe,k as us,kc as Pt,l as fs,lb as pe,lc as q,m as _s,me as ue,mf as ie,n as hs,qe as js,sa as wt,sb as ws,ta as vt,tb as vs,ua as kt,ub as ks,uc as oe,va as St,vb as Ss,wb as xs,xb as Es,yb as As,yc as Cs,zc as Ts,zd as V,ze as Gs}from"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bb16b445-3bd4-520d-becf-c55621bfa186")}catch{}})();var mp=ps,dp=us,lp=hs,pp=fs,up=_s;function ti(e,t,n,s){let o=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),r=n.has(o);return{long:t,...s?{short:s}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:r?"string":"boolean",...r?{value_name:e.value_name??"value"}:{}}}function ni(e,t=[]){let n=new Set(t.flatMap(o=>o.keys)),s=[];for(let o of co(e.map(r=>({...r})))){s.push(ti(o,o.flag,n,o.short));for(let r of o.aliases??[])s.push(ti(o,r,n))}return s}var fp=ni(He,ro),xa=ni(Ve,io);import{AsyncLocalStorage as pl}from"node:async_hooks";import ua from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="27dd77f6-e53d-55b7-be15-db0e60eaec4e")}catch{}})();function si(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ea(e){return e.brief===!0?"brief":typeof e.fields=="string"&&e.fields.trim().length>0||Array.isArray(e.fields)&&e.fields.length>0?"fields":e.compact===!0?"compact":"full"}function fn(e,t){let n=Ea(t),s=n==="brief"?n:si(e.projection)&&typeof e.projection.mode=="string"?e.projection.mode:n;return{...e,query_summary:{filters:si(e.filters)?e.filters:{},projection:s}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b9eae1a3-3eb6-5415-86c3-a8e8e1fedd1f")}catch{}})();function oi(e){return e.map(t=>({key:t.key,optionName:Fs(t),metadataKey:t.metadata_key,type:t.type,commands:[...t.commands],repeatable:t.repeatable,requiredOnCreate:t.required_on_create,...t.description?{description:t.description}:{}}))}function ri(e){return e.map(t=>({command:t.command,action:t.action,arguments:t.arguments.map(n=>({name:n.name,required:n.required===!0,variadic:n.variadic===!0,description:n.description})),description:t.description,tier:t.tier??"standard"}))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7c898a52-eba4-5626-8207-5ffefd4990ba")}catch{}})();var Aa=50,te=new Map;function _n(){te.clear()}function ii(e,t){let n=te.get(e);if(n!==void 0)return n;if(te.size>=Aa){let o=te.keys().next().value;te.delete(o)}let s=t().catch(o=>{throw te.get(e)===s&&te.delete(e),o});return te.set(e,s),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6f62939a-7b99-5687-93ae-834e0032f1d5")}catch{}})();var Ia={"list-all":{action:"list",options:{excludeTerminal:!1}},"list-draft":{action:"list",options:{status:"draft",excludeTerminal:!1}},"list-open":{action:"list",options:{status:"open",excludeTerminal:!1}},"list-in-progress":{action:"list",options:{status:"in_progress",excludeTerminal:!1}},"list-blocked":{action:"list",options:{status:"blocked",excludeTerminal:!1}},"list-closed":{action:"list",options:{status:"closed",excludeTerminal:!1}},"list-canceled":{action:"list",options:{status:"canceled",excludeTerminal:!1}}};function ai(e){return Object.fromEntries(Gs.map(t=>[`${e}-${t}`,{action:e,options:{[t==="adopt-all"?"adoptAll":t]:!0,...e==="package"?{vocabulary:"package"}:{}}}]))}var hn={ctx:{action:"context"},...Ia,...ai("extension"),...ai("package")};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="41012e87-ed61-56b2-8505-8f786b3952b2")}catch{}})();var ci="PmCliError";function Ra(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=_.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function Ca(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new u(e,Ra(t.exitCode??_.USAGE),t.context??{});return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function gn(e){if(!(e instanceof Error)||e.name!==ci)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)}import{constants as Ce}from"node:fs";import{lstat as mi,mkdir as bn,open as di}from"node:fs/promises";import K from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c53bb1b7-12b9-5370-a85b-cdd8bef57936")}catch{}})();function yn(e,t){if(typeof e!="string"||e.trim().length===0)throw new TypeError(`Relationship event ${t} must be non-empty`);return e.trim()}function wn(e,t){let n=t.require(e.kind),s=n.direction==="undirected"?[e.source,e.target].sort().join("\0"):`${e.source}\0${e.target}`;return`${n.kind}\0${s}`}function Ta(e){return Object.freeze({...e,...e.payload===void 0?{}:{payload:Object.freeze(structuredClone(e.payload))}})}function Oa(e,t,n,s){let o=n.require(e.kind),r=s.outgoingOne.get(`${o.kind}\0${e.source}`);if(r!==void 0&&r!==t)throw new TypeError(`Relationship outgoing cardinality exceeded for ${o.kind}`);let i=s.incomingOne.get(`${o.kind}\0${e.target}`);if(i!==void 0&&i!==t)throw new TypeError(`Relationship incoming cardinality exceeded for ${o.kind}`);let a=wn(e,n),c=s.identities.get(a);if(c!==void 0&&c!==t)throw new TypeError(`Relationship edge already active: ${a}`)}function $a(e){let t=new Map;for(let n of e)n.action==="remove"?t.delete(n.relationshipId):t.set(n.relationshipId,n.edge);return t}function Fa(e,t,n){if(e.expectedVersion!==void 0&&e.expectedVersion!==t)throw new TypeError(`Relationship event version conflict: expected ${e.expectedVersion}, current ${t}`);let s=yn(e.eventId,"eventId");if(n.has(s))throw new TypeError(`Relationship event already exists: ${s}`);if(e.action!=="add"&&e.action!=="remove"&&e.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${e.action}`);if(!Number.isFinite(Date.parse(e.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:s,relationshipId:yn(e.relationshipId,"relationshipId"),author:yn(e.author,"author"),timestamp:new Date(e.timestamp).toISOString()}}function Pa(e,t,n,s,o,r){let i=n.has(t);if(e.action==="add"&&i)throw new TypeError(`Relationship is already active: ${t}`);if(e.action!=="add"&&!i)throw new TypeError(`Relationship is not active: ${t}`);if(e.action==="remove")return;if(!e.edge)throw new TypeError(`Relationship ${e.action} event requires an edge`);let a=typeof e.edge.source=="string"?e.edge.source.trim():"",c=typeof e.edge.target=="string"?e.edge.target.trim():"";if(!s.has(a)||!s.has(c))throw new TypeError(`Relationship endpoint not found: ${a} -> ${c}`);let d=new pe([a,c],[e.edge],o).edges()[0];return Oa(d,t,o,r),Ta(d)}var Te=class{#t;#n;#s=[];#r=new Set;#e=new Map;#o={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(t,n={}){this.#t=new Set([...t].filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean)),this.#n=n.registry??je()}get version(){return this.#s.length}events(){return Object.freeze([...this.#s])}*stream(t={}){let n=t.fromVersion??1,s=t.toVersion??this.version,o=t.batchSize??100;if(!Number.isInteger(n)||n<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(s)||s<0||s>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${s}`);if(!Number.isInteger(o)||o<1)throw new TypeError("Relationship event stream batchSize must be positive");if(n>s+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let r=n-1;r<s;r+=o)yield Object.freeze(this.#s.slice(r,Math.min(r+o,s)))}project(t,n,s={}){if(typeof n!="function")throw new TypeError("Relationship event projection requires a reducer");let o=t,r=0,i;for(let a of this.stream({...s,batchSize:256}))for(let c of a)o=n(o,c),r+=1,i=c;return Object.freeze({state:o,version:i?.sequence??Math.max(0,(s.fromVersion??1)-1),processed:r,...i===void 0?{}:{asOf:i.timestamp}})}#i(t,n){let s=this.#n.require(n.kind);this.#o.identities.set(wn(n,this.#n),t),s.outgoing==="one"&&this.#o.outgoingOne.set(`${s.kind}\0${n.source}`,t),s.incoming==="one"&&this.#o.incomingOne.set(`${s.kind}\0${n.target}`,t)}#a(t){let n=this.#n.require(t.kind);this.#o.identities.delete(wn(t,this.#n)),n.outgoing==="one"&&this.#o.outgoingOne.delete(`${n.kind}\0${t.source}`),n.incoming==="one"&&this.#o.incomingOne.delete(`${n.kind}\0${t.target}`)}append(t){let n=Fa(t,this.version,this.#r),s=this.#e.get(n.relationshipId),o=Pa(t,n.relationshipId,this.#e,this.#t,this.#n,this.#o),r=Object.freeze({eventId:n.eventId,relationshipId:n.relationshipId,action:t.action,...o===void 0?{}:{edge:o},author:n.author,timestamp:n.timestamp,...t.reason?.trim()?{reason:t.reason.trim()}:{},sequence:this.version+1});return this.#s.push(r),this.#r.add(n.eventId),s&&this.#a(s),t.action==="remove"?this.#e.delete(n.relationshipId):(this.#e.set(n.relationshipId,o),this.#i(n.relationshipId,o)),r}snapshot(t={}){if(t.atVersion!==void 0&&t.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let n;if(t.atTimestamp!==void 0){let r=Date.parse(t.atTimestamp);if(!Number.isFinite(r))throw new TypeError("Relationship snapshot timestamp must be valid");n=this.#s.filter(i=>Date.parse(i.timestamp)<=r)}else{let r=t.atVersion??this.version;if(!Number.isInteger(r)||r<0||r>this.version)throw new TypeError(`Relationship snapshot version out of range: ${r}`);n=this.#s.slice(0,r)}let s=$a(n),o=new pe(this.#t,s.values(),this.#n);return Object.freeze({version:n.at(-1)?.sequence??0,...n.at(-1)?{asOf:n.at(-1).timestamp}:{},edges:o.edges(),graph:o})}page(t){if(!Number.isInteger(t.limit)||t.limit<1)throw new TypeError("Relationship event page limit must be positive");let n=Ps("relationship-events",{order:"append-sequence"}),s=t.cursor===void 0?this.version:Number(Ls(t.cursor,n).snapshot);if(!Number.isSafeInteger(s)||s<0||s>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let o=Ns(this.#s.slice(0,s),{cursor:t.cursor,fingerprint:n,limit:t.limit,readId:r=>r.eventId,snapshot:String(s)});return{version:s,events:o.rows,hasMore:o.has_more,...o.next_cursor?{nextCursor:o.next_cursor}:{}}}},La="relationship-event-store",li=Ce.O_NOFOLLOW;function Ze(e){return ie(e,La,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function ae(e,t="relationships/events.jsonl"){let n=K.resolve(e),s=K.resolve(n,t),o=K.relative(n,s);if(o.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(o===".."||o.startsWith(`..${K.sep}`)||K.isAbsolute(o))throw new TypeError("Relationship event path must stay within the tracker root");if(await bn(n,{recursive:!0}),(await mi(n)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let i=n;for(let a of o.split(K.sep)){i=K.join(i,a);try{if((await mi(i)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(c){if(c.code==="ENOENT")break;throw c}}return s}async function Qe(e,t,n){let s=new Te(t,{registry:n}),o,r;try{r=await di(e,Ce.O_RDONLY|li),o=await r.readFile("utf8")}catch(a){if(a.code==="ENOENT")return{log:s,raw:""};throw a}finally{await r?.close()}let i=o.split(`
|
|
2
2
|
`);for(let a=0;a<i.length;a+=1){let c=i[a].trim();if(!c)continue;let d;try{d=JSON.parse(c)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${a+1}`)}if(d.sequence!==s.version+1)throw new TypeError(`Invalid relationship event sequence at line ${a+1}`);s.append({eventId:d.eventId,relationshipId:d.relationshipId,action:d.action,...d.edge===void 0?{}:{edge:d.edge},author:d.author,timestamp:d.timestamp,...d.reason===void 0?{}:{reason:d.reason},expectedVersion:s.version})}return{log:s,raw:o}}function Na(e,t,n,s){let o=Date.parse(t.timestamp),r;return t.action!=="remove"&&t.edge!==void 0&&(r=new pe(n,[t.edge],s).edges()[0]),e.eventId===t.eventId.trim()&&e.relationshipId===t.relationshipId.trim()&&e.action===t.action&&e.author===t.author.trim()&&Number.isFinite(o)&&e.timestamp===new Date(o).toISOString()&&e.reason===(t.reason?.trim()||void 0)&&C(e.edge)===C(r)}var et=class e{#t;#n;#s;#r;#e;constructor(t,n,s,o){this.#t=t.pmRoot,this.#n=n,this.#s=t.registry,this.#r=s,this.#e=o}static async open(t){let n=Object.freeze([...t.nodes]),s=await ae(t.pmRoot,t.relativePath),o=await Ze(t.pmRoot);try{await ae(t.pmRoot,s);let{log:r}=await Qe(s,n,t.registry);return new e(t,n,s,r)}finally{await o()}}get path(){return this.#r}async currentVersion(){return this.#e=await this.#o(),this.#e.version}async append(t){let n=await Ze(this.#t);try{let s=await ae(this.#t,this.#r),{log:o}=await Qe(s,this.#n,this.#s),r=o.append(t);await bn(K.dirname(s),{recursive:!0}),await ae(this.#t,s);let i=await di(s,Ce.O_APPEND|Ce.O_CREAT|Ce.O_WRONLY|li);try{await i.appendFile(`${JSON.stringify(r)}
|
|
3
3
|
`,"utf8")}finally{await i.close()}return this.#e=o,r}finally{await n()}}async appendBatch(t,n={}){let s=await Ze(this.#t);try{let o=await ae(this.#t,this.#r),{log:r,raw:i}=await Qe(o,this.#n,this.#s),a=r.version,c=new Map(r.events().map(l=>[l.eventId,l])),d=[],m=[];for(let l of t){let f=l.eventId.trim(),g=c.get(f);if(g!==void 0){if(n.existingEventPolicy==="skip_identical"&&Na(g,l,this.#n,this.#s)){m.push(g.eventId);continue}if(n.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${f}`)}let w=r.append(l);c.set(w.eventId,w),d.push(w)}if(d.length>0){let l=i.length===0||i.endsWith(`
|
|
4
4
|
`)?i:`${i}
|
|
@@ -7,7 +7,7 @@ import{b as Ke,c as Cr,d as Xe}from"./chunk-B5ZLCD5Z.js";import{B as Lr,C as Nr,
|
|
|
7
7
|
`)}return this.#e=r,Object.freeze({version_before:a,version_after:r.version,appended:Object.freeze(d),skipped_event_ids:Object.freeze(m)})}finally{await s()}}async snapshot(t={}){return this.#e=await this.#o(),this.#e.snapshot(t)}async page(t){return this.#e=await this.#o(),this.#e.page(t)}async*stream(t={}){this.#e=await this.#o(),yield*this.#e.stream(t)}async project(t,n,s={}){return this.#e=await this.#o(),this.#e.project(t,n,s)}async#o(){let t=await Ze(this.#t);try{let n=await ae(this.#t,this.#r);return(await Qe(n,this.#n,this.#s)).log}finally{await t()}}};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ff13ec2a-64a8-5512-973f-5447be945978")}catch{}})();function vn(e){let t=je();for(let n of e)t.register(n);return t}function pi(e,t){return{client:t,isItemNotFoundError:n=>gn(n)&&n.exitCode===_.NOT_FOUND,getItemAt:(n,s)=>Go(n,s,{pmRoot:e}),openRelationshipEventStore:n=>et.open({pmRoot:e,nodes:n.nodes,registry:vn(n.definitions),...n.relativePath===void 0?{}:{relativePath:n.relativePath}}),createRelationshipGraph:n=>new pe(n.nodes,n.edges,vn(n.definitions)),analyzeRelationshipImpact:(n,s,o)=>Uo(n,s,o),validateRelationshipEvents:n=>{let s=new Te(n.nodes,{registry:vn(n.definitions)});return n.events.map(o=>s.append({...o,expectedVersion:s.version}))},commitWorkspaceTransaction:n=>qo({...n,pmRoot:e})}}import{readFile as Ma}from"node:fs/promises";import Da from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="55ecd7ff-0047-5fd1-9f6f-f45602fce1bb")}catch{}})();var kn="context-intents.json";function Oe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ja(e,t,n){if(!Oe(e))throw new TypeError(`${t} context intent at index ${String(n)} must be an object`);let s=e.included_field_groups;if(typeof e.command!="string"||typeof e.intent!="string"||typeof e.description!="string"||!Array.isArray(s)||!s.every(o=>typeof o=="string")||typeof e.token_budget!="number")throw new TypeError(`${t} context intent at index ${String(n)} has an invalid contract shape`);return{command:e.command,intent:e.intent,description:e.description,included_field_groups:s,token_budget:e.token_budget}}function ui(e,t){let n=Array.isArray(e)?e:Oe(e)&&Array.isArray(e.intents)?e.intents:void 0;if(!n)throw new TypeError(`${t} context intents must be an array or an object with an intents array`);return n.map((s,o)=>ja(s,t,o))}async function Ga(e){let t=Da.join(e,kn),n;try{n=await Ma(t,"utf8")}catch(o){if(Oe(o)&&typeof o.code=="string"&&o.code==="ENOENT")return[];throw o}let s;try{s=JSON.parse(n)}catch(o){let r=o instanceof Error?o.message:String(o);throw new TypeError(`Invalid ${kn}: ${r}`,{cause:o})}return ui(s,kn)}function Ua(e){if(!Oe(e))return;let t=e.contextIntents??e.context_intents;if(t!==void 0)return t;let n=e.default;return Oe(n)?n.contextIntents??n.context_intents:void 0}function qa(e){return e.flatMap(t=>{let n=Ua(t.module);return n===void 0?[]:ui(n,`package ${t.name}`)})}async function za(e){let t=await Ga(e.pmRoot),n=qa(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function Sn(e,t){let n=await za(e);return await Ds(n,t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="973fe868-d08e-5a45-83c5-b7ecb959f680")}catch{}})();function Ha(e){if(e===void 0)return;if(e.trim().length===0)throw new u("--add-json must contain a JSON value",_.USAGE,{code:"structured_event_json_empty"});let t;try{t=JSON.parse(e)}catch{throw new u("--add-json must be valid JSON",_.USAGE,{code:"structured_event_json_invalid"})}return t}function Va(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.type;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}function Ba(e){if(e===void 0)return;let t=Date.parse(e);if(!Number.isFinite(t))throw new u("--since must be a valid ISO timestamp",_.USAGE,{code:"structured_event_since_invalid"});return t}async function fi(e,t,n){let s=Ha(t.addJson),o=[t.add!==void 0,t.stdin===!0,t.file!==void 0,t.edit!==void 0,t.delete!==void 0].includes(!0);if(s!==void 0&&o)throw new u("--add-json cannot be combined with text, edit, delete, stdin, or file inputs",_.USAGE,{code:"structured_event_input_conflict"});let r=s===void 0?void 0:C(s),i=[t.since,t.eventType].some(w=>w!==void 0),a=Ba(t.since),c=zs(t.limit),d=await Yo(e,{...t,...i?{limit:void 0}:{},includeMeta:[t.includeMeta===!0,i].includes(!0)},n,{input:await Wo(r===void 0?t:{add:r},"note"),collectionKey:"notes",op:"note_add",editOp:"note_edit",deleteOp:"note_delete",parseText:w=>Bo(w),createEntry:w=>s===void 0?w:{...w,format:"json",data:s,event_type:Va(s)},bypassOwnershipConflict:!![t.edit===void 0,t.delete===void 0,t.ownershipAppendBypass===!0].every(Boolean),conflictGuidance:{required:"For an approved append-only handoff on another owner's item, use the package-provided ownership bypass before considering --force.",examples:['pm notes pm-a1b2 --add "review note" --author "reviewer" --force'],nextSteps:["Use an installed package's narrow append-only ownership bypass when available.","Use --force only when an ownership override is explicitly approved."]}}),m=t.eventType?.trim(),l=d.notes.filter(w=>{let b=[w.format==="json",w.data!==void 0].every(Boolean),v=[a===void 0,Date.parse(w.created_at)>=(a??Number.POSITIVE_INFINITY)].includes(!0),h=[!m,w.event_type===m].includes(!0);return[!i,[b,v,h].every(Boolean)].includes(!0)}),f=i?Vo(l,c):l,g=f.filter(w=>w.format==="json").length;return{...d,notes:f,count:f.length,...i?{total_count:l.length,returned_count:f.length,has_more:f.length<l.length,...c===void 0?{}:{limit:c},structured_event_count:g}:t.includeMeta===!0?{structured_event_count:g}:{}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d4b9caa3-59eb-5747-ba76-49f786c5010e")}catch{}})();var Zp=["create","show","add-step","update-step","complete-step","block-step","reorder-step","remove-step","link","unlink","decision","discovery","validation","resume","approve","materialize"],_i=["brief","standard","deep"],yi="plan-step-",Cn="draft",Rn=["bug-investigation","feature-implementation","refactoring-sprint"],hi={"bug-investigation":[{title:"Reproduce the bug",body:"Capture exact steps, inputs, and the observed vs expected behavior."},{title:"Locate the root cause",body:"Trace the failure to the responsible code path with evidence."},{title:"Write a failing test",body:"Add a regression test that fails for the current bug."},{title:"Implement the fix",body:"Apply the minimal change that makes the failing test pass."},{title:"Verify and document",body:"Run the full suite and record the resolution and verification."}],"feature-implementation":[{title:"Clarify requirements & acceptance criteria",body:"Confirm scope, edge cases, and done-conditions."},{title:"Design the approach",body:"Decide the data model, interfaces, and integration points."},{title:"Implement the change",body:"Build the feature behind the agreed design."},{title:"Add tests",body:"Cover the new behavior and its edge cases."},{title:"Update docs & changelog",body:"Document the feature and surface it to users."}],"refactoring-sprint":[{title:"Map the current structure & risks",body:"Inventory the code to change and its blast radius."},{title:"Add characterization tests",body:"Lock in current behavior before refactoring."},{title:"Refactor incrementally",body:"Apply small, reversible steps keeping tests green."},{title:"Verify behavior is unchanged",body:"Run the full suite and compare against the baseline."},{title:"Clean up & document",body:"Remove dead code and record the new structure."}]};function Wa(e){let t=e.trim().toLowerCase(),n=Object.prototype.hasOwnProperty.call(hi,t)?hi[t]:void 0;if(!n)throw new u(`Unknown plan template "${e}". Allowed: ${Rn.join(", ")}`,_.USAGE,{code:"unknown_plan_template",examples:[`pm plan create --title "Fix login crash" --template ${Rn[0]}`]});return n.map(s=>({...s}))}function Ya(e,t){return t>0?Math.round(e/t*100):0}function bi(e){return(Array.isArray(e)?e:e==null?[]:[e]).filter(n=>n!=null).map(n=>(typeof n=="string"?n:String(n)).trim()).filter(n=>n.length>0)}function j(e){return Array.isArray(e)?e.flatMap(t=>Jt(t,{unique:!1})):typeof e=="string"&&e.trim().length>0?Jt(e,{unique:!1}):[]}function F(e){return Array.isArray(e)?e.map(t=>t.trim()).filter(Boolean):typeof e=="string"&&e.trim().length>0?[e.trim()]:[]}function wi(e,t=Cn){if(e===void 0)return t;let n=e.trim().toLowerCase(),s=wt.find(o=>o===n);if(!s)throw new u(`Invalid plan mode "${e}". Allowed: ${wt.join(", ")}`,_.USAGE);return s}function Tn(e,t="pending"){if(e===void 0)return t;let n=e.trim().toLowerCase(),s=vt.find(o=>o===n);if(!s)throw new u(`Invalid step status "${e}". Allowed: ${vt.join(", ")}`,_.USAGE);return s}function vi(e,t="related"){if(e===void 0)return t;let n=e.trim().toLowerCase(),s=St.find(o=>o===n);if(!s)throw new u(`Invalid step link kind "${e}". Allowed: ${St.join(", ")}`,_.USAGE);return s}function Ja(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t.length===0)return;let n=kt.find(s=>s===t);if(!n)throw new u(`Invalid plan harness "${e}". Allowed: ${kt.join(", ")}`,_.USAGE);return n}function Ka(e){if(e===void 0)return"brief";let t=e.trim().toLowerCase(),n=_i.find(s=>s===t);if(!n)throw new u(`Invalid --depth "${e}". Allowed: ${_i.join(", ")}`,_.USAGE);return n}function Xa(e){if(e===void 0)return null;let t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new u("Plan --fields requires a comma-separated list of plan field names",_.USAGE);return t}var xn=new Set(["id","title","status","mode","scope","harness","parent","resume_context","steps_summary","current_step","blocked_steps","steps","decisions","discoveries","validation","linked_items"]);function Za(e,t){let n=e,s={},o=[];for(let r of t){let i=r.startsWith("plan.")?r.slice(5):r;if(i.length!==0){if(!xn.has(i)){o.push(r);continue}Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}}if(o.length>0)throw new u(`Unknown Plan --fields value(s): ${o.join(", ")}`,_.USAGE,{nextSteps:[`Use --fields ${[...xn].join(",")}`,"Run pm plan show <id> --depth brief for compact default fields."],recovery:{provided_fields:o,suggested_retry:`pm plan show <id> --fields ${[...xn].join(",")}`}});return s}function On(e,t){let n={};for(let s of e.split(",")){let o=s.trim();if(o.length===0)continue;let r=o.indexOf("=");if(r<=0)throw new u(`Invalid ${t} entry "${o}"; expected key=value`,_.USAGE,{code:"malformed_plan_step_evidence",required:`${t} entries must use comma-separated key=value fields.`,why:"Structured Plan evidence must be validated before it is persisted.",examples:['--file "path=src/index.ts,scope=project,note=implementation"','--test "command=pnpm test,note=regression"','--doc "path=docs/PLAN.md,scope=project"']});n[o.slice(0,r).trim().toLowerCase()]=o.slice(r+1).trim()}return n}function $n(e){let t=On(e,"--file");if(!t.path)throw new u("--file requires path=<value>",_.USAGE,{code:"malformed_plan_step_evidence",required:"--file requires a non-empty path field.",why:"Plan file evidence needs a stable path for later verification."});let n={path:t.path};return(t.scope==="global"||t.scope==="project")&&(n.scope=t.scope),t.note&&(n.note=t.note),n}function Fn(e){let t=On(e,"--test");if(!t.command&&!t.path)throw new u("--test requires at least command=<value> or path=<value>",_.USAGE,{code:"malformed_plan_step_evidence",required:"--test requires a command or path field.",why:"Plan test evidence must identify something runnable or inspectable."});let n={};return t.command&&(n.command=t.command),t.path&&(n.path=t.path),t.note&&(n.note=t.note),n}function Pn(e){let t=On(e,"--doc");if(!t.path)throw new u("--doc requires path=<value>",_.USAGE,{code:"malformed_plan_step_evidence",required:"--doc requires a non-empty path field.",why:"Plan documentation evidence needs a stable path for later verification."});let n={path:t.path};return(t.scope==="global"||t.scope==="project")&&(n.scope=t.scope),t.note&&(n.note=t.note),n}function Qa(e){let t={total:e.length,pending:0,in_progress:0,blocked:0,completed:0,skipped:0,superseded:0,completion_pct:0};for(let n of e)t[n.status]+=1;return t.completion_pct=Ya(t.completed,t.total),t}function ec(e){let t=new Set(e.map(n=>n.id));for(let n=e.length+1;n<e.length+1024;n+=1){let s=`${yi}${String(n).padStart(3,"0")}`;if(!t.has(s))return s}throw new u("Could not allocate step id (limit reached)",_.GENERIC_FAILURE)}function _e(e,t){let n=t.trim();if(n.length===0)throw new u("Step reference cannot be empty",_.USAGE);let s=e.find(o=>o.id===n);if(s)return s;if(/^\d+$/.test(n)){let o=Number.parseInt(n,10),r=e.find(i=>i.order===o);if(r)return r}throw new u(`Step "${t}" not found in plan`,_.NOT_FOUND)}function gi(e){if(e.status==="completed")return{reason:"already_completed"};let t=(e.linked_items??[]).find(n=>n.kind==="implements");if(t)return{reason:"already_materialized",existing_id:t.id}}function tc(e,t){let n=t.filter(i=>i.trim().toLowerCase()==="all"),s=[],o=[];if(n.length>0){if(t.length>n.length)throw new u("pm plan materialize --steps all cannot be combined with other step refs",_.USAGE);for(let i of e.slice().sort((a,c)=>a.order-c.order)){let a=gi(i);if(a){o.push({from_step:i.id,...a});continue}s.push(i)}return{targets:s,skipped:o}}let r=new Set;for(let i of t){let a=_e(e,i);if(r.has(a.id))continue;r.add(a.id);let c=gi(a);if(c){o.push({from_step:a.id,...c});continue}s.push(a)}return{targets:s,skipped:o}}function nc(e,t){let n=e==="decision"?t.decisionText:e==="discovery"?t.discoveryText:t.validationText,s=e==="decision"?t.decision:e==="discovery"?t.discovery:t.validation;return n?.trim()||s?.trim()||void 0}function sc(e){return e.find(t=>t.status==="in_progress")??e.find(t=>t.status==="pending")}function oc(e){return e.filter(t=>t.status==="blocked").map(t=>({id:t.id,order:t.order,title:t.title,blocked_reason:t.blocked_reason}))}function L(e,t="brief"){let n=(e.plan_steps??[]).slice().sort((i,a)=>i.order-a.order),s=Qa(n),o=sc(n),r={id:e.id,title:e.title,status:e.status,mode:e.plan_mode??Cn,scope:e.plan_scope,harness:e.plan_harness,parent:e.parent,resume_context:e.plan_resume_context,steps_summary:s,current_step:o?{id:o.id,order:o.order,title:o.title,status:o.status}:void 0,blocked_steps:oc(n),linked_items:(e.dependencies??[]).map(i=>({id:i.id,kind:i.kind}))};return(t==="standard"||t==="deep")&&(r.steps=n),t==="deep"&&(r.decisions=e.plan_decisions??[],r.discoveries=e.plan_discoveries??[],r.validation=e.plan_validation??[]),r}function N(e,t){let n=[];return t.steps_summary.total===0&&n.push(`pm plan add-step ${e} --step-title "First step"`),t.current_step&&n.push(`pm plan update-step ${e} ${t.current_step.id} --step-status in_progress`,`pm plan complete-step ${e} ${t.current_step.id} --step-evidence "..."`),t.steps_summary.blocked>0&&n.push(`pm plan show ${e} --depth standard`),(t.mode==="draft"||t.mode==="research")&&n.push(`pm plan approve ${e} --message "ready to execute"`),t.steps_summary.completed===t.steps_summary.total&&t.steps_summary.total>0&&n.push(`pm close ${e} "plan complete"`),n}function ki(e){if((e.type??"").trim().toLowerCase()!=="plan")throw new u(`Item ${e.id} is type ${e.type}; pm plan commands require type=Plan. Use pm plan create or pm create --type Plan first.`,_.USAGE,{code:"wrong_item_type",required:"Use pm plan commands only with items whose type is Plan.",why:"Plan commands read and mutate Plan-specific step, decision, discovery, and validation fields.",examples:[`pm get ${e.id} --depth brief`,'pm plan create --title "Execution plan" --scope "<goal>"']})}async function rc(e){let t=$(process.cwd(),e.path);if(!await G(U(t)))throw new u(`Tracker is not initialized at ${t}. Run pm init first.`,_.NOT_FOUND);let n=await D(t);return{pmRoot:t,settings:n}}async function Si(e,t){let n=ee(e.settings,q()),s=await qt(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,n.type_to_folder);if(!s)throw new u(`Plan ${t} not found`,_.NOT_FOUND);let o=await zt(s,{schema:e.settings.schema});return ki(o.document.metadata),{document:o.document,itemId:s.id}}function ic(e){let t=[];e.parent&&t.push(`id=${e.parent.trim()},kind=parent`);for(let n of j(e.related))t.push(`id=${n},kind=related`);for(let n of j(e.blocks))t.push(`id=${n},kind=blocks`);for(let n of j(e.blockedBy))t.push(`id=${n},kind=blocked_by`);return t.length>0?t:void 0}function ac(e){let t=e.validationText?.trim(),n=e.validationCommand?.trim(),s=e.validationExpected?.trim();if(!(!t&&!n&&!s))return{text:t||n||"Validation check",command:n||void 0,expected:s||void 0}}function cc(e){return!!e.stepBody?.trim()||!!e.stepOwner?.trim()||!!e.stepStatus?.trim()||!!e.stepEvidence?.trim()||!!e.stepBlockedReason?.trim()||!!e.stepReplacement?.trim()||j(e.dependsOn).length>0||j(e.link).length>0}function mc(e){let t=e.stepTitle?.trim()||void 0,n=bi(e.step),s=e.template?.trim()?Wa(e.template):[];return{repeatedStepTitles:n,stepTitleFlag:t,stepTitles:[...t?[t]:[],...n,...s.map(o=>o.title)],templateSteps:s}}function dc(e,t){if((e.stepTitleFlag||e.repeatedStepTitles.length>0)&&e.templateSteps.length>0)throw new u("pm plan create --template cannot be combined with --step-title or --step; choose one step seeding source",_.USAGE,{code:"ambiguous_option_combination",examples:[`pm plan create --title "Fix login crash" --template ${Rn[0]}`,'pm plan create --title "Custom plan" --step "Read the code" --step "Write the fix"']});if(e.stepTitles.length>1&&t)throw new u("pm plan create per-step options apply to a single initial step; with multiple --step values create the plan first, then refine steps individually",_.USAGE,{code:"ambiguous_option_combination",examples:['pm plan create --title "Execution plan" --step "Read the code" --step "Write the fix"','pm plan update-step <plan-id> plan-step-001 --step-body "Inspect retry path"']})}function lc(e,t){let n=Tn(e.stepStatus,"pending"),s=Ln(e,"depends_on"),o=F(e.file).map($n),r=F(e.test).map(Fn),i=F(e.doc).map(Pn),a=k();return{id:"plan-step-001",order:1,title:t,body:e.stepBody?.trim()||void 0,status:n,owner:e.stepOwner?.trim()||void 0,evidence:e.stepEvidence?.trim()||void 0,blocked_reason:n==="blocked"?e.stepBlockedReason?.trim()||"":void 0,linked_items:s.length>0?s:void 0,files:o.length>0?o:void 0,tests:r.length>0?r:void 0,docs:i.length>0?i:void 0,created_at:a,updated_at:a,completed_at:n==="completed"?a:void 0}}function pc(e){let t=mc(e),n=cc(e);if(dc(t,n),t.stepTitles.length===0)return{steps:[],hasPerStepDetailOptions:n};if(t.stepTitles.length===1)return{steps:[lc(e,t.stepTitles[0])],hasPerStepDetailOptions:n};let s=k();return{steps:t.stepTitles.map((o,r)=>({id:`${yi}${String(r+1).padStart(3,"0")}`,order:r+1,title:o,body:t.templateSteps[r]?.body,status:"pending",created_at:s,updated_at:s})),hasPerStepDetailOptions:n}}async function uc(e,t,n){let s=e.title?.trim();if(!s)throw new u("pm plan create requires --title",_.USAGE,{code:"missing_required_option",examples:['pm plan create --title "Refactor lock retry" --scope pm-a1b2']});let o=wi(e.mode,Cn),r=Ja(e.harness),i=e.fromSearch?.trim(),a=ac(e),{steps:c,hasPerStepDetailOptions:d}=pc(e);if(c.length===0&&d)throw new u("pm plan create step options require --step-title (or a single --step)",_.USAGE,{code:"missing_required_option",examples:['pm plan create --title "Execution plan" --step-title "Read the code"']});let m=e.description?.trim()??e.scope?.trim()??s,l=e.claim?V(e.author,n.settings.author_default):e.assignee?.trim()||void 0,f={...e,title:s,description:m,type:"Plan",template:void 0,file:F(e.file),test:F(e.test),doc:F(e.doc),field:F(e.field),assignee:l,blockedBy:void 0,dep:ic(e),message:e.message??(i?`plan create (search: ${i})`:"plan create")},g=await Ae(f,t),w=await Ht({pmRoot:n.pmRoot,settings:n.settings,id:g.item.id,op:"plan_create_metadata",author:V(e.author,n.settings.author_default),message:"seed plan metadata",mutate(v){let h=["plan_mode"];v.metadata.plan_mode=o,r&&(v.metadata.plan_harness=r,h.push("plan_harness"));let A=e.scope?.trim();A&&(v.metadata.plan_scope=A,h.push("plan_scope"));let R=e.resumeContext?.trim();return R&&(v.metadata.plan_resume_context=R,h.push("plan_resume_context")),v.metadata.plan_steps=c,h.push("plan_steps"),a&&(v.metadata.plan_validation=[...v.metadata.plan_validation??[],a],h.push("plan_validation")),l&&(v.metadata.assignee=l,h.push("assignee")),{changedFields:h}}}),b=L(w.item,"brief");return{action:"create",plan:b,step:c[0],next_actions:N(g.item.id,b),warnings:[...g.warnings],generated_at:k()}}async function fc(e,t,n){let s=Ka(t.depth),o=Xa(t.fields),{document:r,itemId:i}=await Si(n,e),a=L(r.metadata,o===null?s:"deep");return{action:"show",plan:o===null?a:Za(a,o),next_actions:N(i,a),warnings:[],generated_at:k()}}function _c(e,t){let n=new Map(Object.entries(t).filter(([s])=>s.startsWith("plan_")).map(([s,o])=>[s,JSON.stringify(o)]));return[...new Set([...e.keys(),...n.keys()])].filter(s=>e.get(s)!==n.get(s))}async function B(e){let t=V(e.options.author,e.ctx.settings.author_default),n,s=await Ht({pmRoot:e.ctx.pmRoot,settings:e.ctx.settings,id:e.id,op:e.op,author:t,message:e.options.message??e.message,force:e.options.force,mutate(o){ki(o.metadata);let r=re(e.ctx.settings.schema);if(Mt(o.metadata.status,r)||oo(o.metadata.plan_mode))throw new u(`Plan ${o.metadata.id} is terminal (status=${o.metadata.status}, plan_mode=${o.metadata.plan_mode??"unset"}) and cannot be mutated.`,_.CONFLICT,{code:"terminal_plan_mutation",required:"Create or reopen a non-terminal Plan before changing its execution context or steps.",why:"Terminal Plan history is immutable execution evidence."});let i=(o.metadata.plan_steps??[]).slice(),a=new Map(Object.entries(o.metadata).filter(([l])=>l.startsWith("plan_")).map(([l,f])=>[l,JSON.stringify(f)])),c=e.mutator(i,o);n=c.resultStep;let d=i.slice().sort((l,f)=>l.order-f.order).map((l,f)=>({...l,order:f+1}));o.metadata.plan_steps=d;let m=_c(a,o.metadata);return m.length===0&&c.changedSteps.length===0?{changedFields:[]}:{changedFields:m.length>0?m:["plan_steps"]}}});return{document:{metadata:s.item,body:s.body},resultStep:n,itemId:s.item.id}}async function hc(e,t,n){let s=t.stepTitle?.trim();if(!s)throw new u("pm plan add-step requires --step-title",_.USAGE);let o=Tn(t.stepStatus,"pending"),r=t.allowMultipleActive===!0,{document:i,resultStep:a,itemId:c}=await B({id:e,options:t,ctx:n,op:"plan_add_step",message:`plan add-step "${s}"`,mutator(m){let l=m.length+1;xi(m,void 0,o,r);let f=gc(m,t,{order:l,title:s,status:o});return m.push(f),{changedSteps:[f.id],resultStep:f}}}),d=L(i.metadata,"standard");return{action:"add-step",plan:d,step:a,next_actions:N(c,d),warnings:[],generated_at:k()}}function xi(e,t,n,s){if(n!=="in_progress"||s)return;let o=e.find(r=>r.id!==t&&r.status==="in_progress");if(o)throw new u(`Plan already has step ${o.id} in_progress. Pass --allow-multiple-active or update that step first.`,_.CONFLICT)}function gc(e,t,n){let s=Ln(t,"depends_on"),o=F(t.file).map($n),r=F(t.test).map(Fn),i=F(t.doc).map(Pn),a=k();return{id:ec(e),order:n.order,title:n.title,body:t.stepBody?.trim()||void 0,status:n.status,owner:t.stepOwner?.trim()||void 0,evidence:t.stepEvidence?.trim()||void 0,blocked_reason:n.status==="blocked"?t.stepBlockedReason?.trim()||"":void 0,linked_items:s.length>0?s:void 0,files:o.length>0?o:void 0,tests:r.length>0?r:void 0,docs:i.length>0?i:void 0,created_at:a,updated_at:a,completed_at:n.status==="completed"?a:void 0}}function Ln(e,t){let n=j(e.dependsOn).map(m=>({id:m,kind:t})),s=j(e.related).map(m=>({id:m,kind:"related"})),o=j(e.blocks).map(m=>({id:m,kind:"blocks"})),r=j(e.blockedBy).map(m=>({id:m,kind:"blocked_by"})),i=j(e.link),a=vi(e.linkKind,t),c=e.linkNote?.trim(),d=i.map(m=>{let l={id:m,kind:a};return c&&(l.note=c),l});return[...n,...s,...o,...r,...d]}async function En(e,t,n,s){let{document:o,resultStep:r,itemId:i}=await B({id:e,options:t,ctx:n,op:s.op,message:t.message??`${s.op} ${s.stepRef}`,mutator(c,d){let m=_e(c,s.stepRef),l=k(),f=s.finalStatus??Tn(t.stepStatus,m.status),g=t.allowMultipleActive===!0||s.allowMultipleActive===!0;return xi(c,m.status==="in_progress"?m.id:void 0,f,g),yc(m,t,f,l),d.metadata.updated_at=l,{changedSteps:[m.id],resultStep:m}}}),a=L(o.metadata,"standard");return{action:s.op==="plan_complete_step"?"complete-step":s.op==="plan_block_step"?"block-step":"update-step",plan:a,step:r,next_actions:N(i,a),warnings:[],generated_at:k()}}function yc(e,t,n,s){bc(e,t,n),wc(e,t),e.status=n,e.updated_at=s,vc(e,n,s)}function bc(e,t,n){if(!(n!=="blocked"||t.stepBlockedReason?.trim()||e.blocked_reason))throw new u("Blocking a step requires --step-blocked-reason or an already-recorded blocked_reason.",_.USAGE)}function wc(e,t){let n=t.stepTitle?.trim();n&&(e.title=n),t.stepBody!==void 0&&(e.body=t.stepBody.trim()||void 0),t.stepOwner!==void 0&&(e.owner=t.stepOwner.trim()||void 0),t.stepEvidence!==void 0&&(e.evidence=t.stepEvidence.trim()||void 0),t.stepBlockedReason!==void 0&&(e.blocked_reason=t.stepBlockedReason.trim()||void 0),t.stepReplacement!==void 0&&(e.superseded_by=t.stepReplacement.trim()||void 0);let s=F(t.file).map($n),o=F(t.test).map(Fn),r=F(t.doc).map(Pn);s.length>0&&(e.files=An(e.files,s)),o.length>0&&(e.tests=An(e.tests,o)),r.length>0&&(e.docs=An(e.docs,r))}function An(e,t){let n=[...e??[]],s=new Set(n.map(o=>JSON.stringify(o)));for(let o of t){let r=JSON.stringify(o);s.has(r)||(s.add(r),n.push(o))}return n}function vc(e,t,n){if(t==="completed"&&!e.completed_at){e.completed_at=n;return}t!=="completed"&&(e.completed_at=void 0)}async function kc(e,t,n,s,o){let{document:r,itemId:i}=await B({id:e,options:t,ctx:n,op:"plan_reorder_step",message:t.message??`plan reorder-step ${s} -> ${o}`,mutator(c){let d=_e(c,s),m=c.filter(f=>f.id!==d.id),l=Math.max(1,Math.min(o,m.length+1));return m.splice(l-1,0,d),m.forEach((f,g)=>{f.order=g+1,f.updated_at=k()}),c.length=0,c.push(...m),{changedSteps:[d.id],resultStep:d}}}),a=L(r.metadata,"standard");return{action:"reorder-step",plan:a,next_actions:N(i,a),warnings:[],generated_at:k()}}async function Sc(e,t,n,s){let{document:o,itemId:r}=await B({id:e,options:t,ctx:n,op:"plan_remove_step",message:t.message??`plan remove-step ${s}`,mutator(a){let c=_e(a,s),d=a.filter(m=>m.id!==c.id);return d.forEach((m,l)=>{m.order=l+1}),a.length=0,a.push(...d),{changedSteps:[c.id]}}}),i=L(o.metadata,"standard");return{action:"remove-step",plan:i,next_actions:N(r,i),warnings:[],generated_at:k()}}async function xc(e,t,n,s){let o=Ln(t,vi(t.linkKind,"related"));if(o.length===0)throw new u("pm plan link requires at least one --link/--related/--blocks/--blocked-by/--depends-on id",_.USAGE);let r=t.promoteToItemDep===!0,{document:i,itemId:a,resultStep:c}=await B({id:e,options:t,ctx:n,op:"plan_link_step",message:t.message??`plan link ${s}`,mutator(m,l){let f=_e(m,s),g=f.linked_items??[],w=v=>`${v.kind}:${v.id}`,b=new Set(g.map(w));for(let v of o){let h=w(v);b.has(h)||(g.push(v),b.add(h))}if(f.linked_items=g,f.updated_at=k(),r){let v=l.metadata.dependencies??[],h=R=>`${R.kind}:${R.id}`,A=new Set(v.map(h));for(let R of o){let z=R.kind==="depends_on"?"blocked_by":R.kind,H={id:R.id,kind:z,created_at:k(),author:V(t.author,n.settings.author_default)};A.has(h(H))||(v.push(H),A.add(h(H)))}l.metadata.dependencies=v}return{changedSteps:[f.id],resultStep:f}}}),d=L(i.metadata,"standard");return{action:"link",plan:d,step:c,next_actions:N(a,d),warnings:[],generated_at:k()}}async function Ec(e,t,n,s){let o=j(t.link);if(o.length===0)throw new u("pm plan unlink requires --link <id> to remove",_.USAGE);let{document:r,itemId:i,resultStep:a}=await B({id:e,options:t,ctx:n,op:"plan_unlink_step",message:t.message??`plan unlink ${s}`,mutator(d){let m=_e(d,s),l=(m.linked_items??[]).filter(f=>!o.includes(f.id));return m.linked_items=l.length>0?l:void 0,m.updated_at=k(),{changedSteps:[m.id],resultStep:m}}}),c=L(r.metadata,"standard");return{action:"unlink",plan:c,step:a,next_actions:N(i,c),warnings:[],generated_at:k()}}async function In(e,t,n,s){let o=nc(s,t);if(!o){let d=`--${s}-text`,m=`--${s}`;throw new u(`pm plan ${s} requires ${d}`,_.USAGE,{code:"missing_required_option",examples:[`pm plan ${s} <plan-id> ${d} "..."`,`pm plan ${s} <plan-id> ${m} "..."`],recovery:{suggested_retry:`pm plan ${s} <plan-id> ${d} <value>`}})}let r=V(t.author,n.settings.author_default),{document:i,itemId:a}=await B({id:e,options:t,ctx:n,op:`plan_append_${s}`,message:t.message??`plan ${s} append`,mutator(d,m){let l=k();if(s==="decision"){let g=m.metadata.plan_decisions??[];return g.push({ts:l,author:r,decision:o,rationale:t.decisionRationale?.trim()||void 0,evidence:t.decisionEvidence?.trim()||void 0}),m.metadata.plan_decisions=g,{changedSteps:[]}}if(s==="discovery"){let g=m.metadata.plan_discoveries??[];return g.push({ts:l,author:r,text:o}),m.metadata.plan_discoveries=g,{changedSteps:[]}}let f=m.metadata.plan_validation??[];return f.push({text:o,command:t.validationCommand?.trim()||void 0,expected:t.validationExpected?.trim()||void 0}),m.metadata.plan_validation=f,{changedSteps:[]}}}),c=L(i.metadata,"deep");return{action:s,plan:c,next_actions:N(a,c),warnings:[],generated_at:k()}}async function Ac(e,t,n){let s=t.resumeContext?.trim();if(!s)throw new u("pm plan resume requires --resume-context <text>",_.USAGE);let{document:o,itemId:r}=await B({id:e,options:t,ctx:n,op:"plan_resume",message:t.message??"plan resume context update",mutator(a,c){c.metadata.plan_resume_context=s;let d=t.scope?.trim();return d&&(c.metadata.plan_scope=d),{changedSteps:[]}}}),i=L(o.metadata,"brief");return{action:"resume",plan:i,next_actions:N(r,i),warnings:[],generated_at:k()}}async function Ic(e,t,n){let s=wi(t.mode??"approved","approved"),{document:o,itemId:r}=await B({id:e,options:t,ctx:n,op:"plan_approve",message:t.message??`plan approve mode=${s}`,mutator(a,c){c.metadata.plan_mode=s;let d=t.scope?.trim();return d&&(c.metadata.plan_scope=d),{changedSteps:[]}}}),i=L(o.metadata,"brief");return{action:"approve",plan:i,next_actions:N(r,i),warnings:[],generated_at:k()}}function Ei(e){return e.map(t=>`plan_materialize_skipped:${t.from_step}:${t.reason}${t.existing_id?`:${t.existing_id}`:""}`)}function Rc(e,t){let n=L(e.document.metadata,"standard");return{action:"materialize",plan:n,materialized:[],materialize_skipped:t,next_actions:N(e.itemId,n),warnings:Ei(t),generated_at:k()}}function Cc(e,t,n){let s=[`id=${e},kind=parent`,`id=${t},kind=discovered_from`];for(let o of n.linked_items??[]){let r=o.kind==="blocked_by"||o.kind==="blocks"||o.kind==="related"||o.kind==="discovered_from"?o.kind:"related";s.push(`id=${o.id},kind=${r}`)}return s}async function Tc(e){let t=[],n={},s=new Set(["title","description","type","parent","tags","author","message","dep"]);for(let o of F(e.options.field)){let r=o.indexOf("=");if(r<=0)throw new u(`Invalid --field entry "${o}"; expected name=value`,_.USAGE);let i=o.slice(0,r).trim(),a=o.slice(r+1).trim();if(i.length===0)throw new u(`Invalid --field entry "${o}"; expected name=value`,_.USAGE);let c=i.trim().replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(Boolean).map(f=>f.toLowerCase());if(c.length===0)throw new u(`Invalid --field entry "${o}"; expected name=value`,_.USAGE);let[d,...m]=c,l=`${d}${m.map(f=>`${f.slice(0,1).toUpperCase()}${f.slice(1)}`).join("")}`;if(s.has(l))throw new u(`Invalid --field entry "${o}"; "${l}" is reserved by materialize and cannot be overridden`,_.USAGE);n[l]=a}for(let o of e.targets){let r=await Ae({...n,title:o.title,description:o.body?.trim()||o.title,type:e.resolvedTypeName,parent:e.parent,tags:e.tags,author:e.options.author,message:e.options.message??`materialized from plan ${e.planItemId} step ${o.id}`,dep:Cc(e.parent,e.planItemId,o)},{path:e.pmRoot});t.push({id:r.item.id,title:r.item.title,type:e.resolvedTypeName,parent:r.item.parent,tags:r.item.tags??[],from_step:o.id})}return t}function Oc(e,t,n){for(let s of t){let o=n.find(a=>a.from_step===s.id);if(!o)continue;let r=e.find(a=>a.id===s.id);if(!r)continue;let i=r.linked_items??[];i.push({id:o.id,kind:"implements",note:`materialized as ${o.type}`}),r.linked_items=i,r.updated_at=k()}}async function $c(e,t,n){let s=j(t.steps);if(s.length===0)throw new u("pm plan materialize requires --steps <ids|orders|all>",_.USAGE);let o=t.materializeType?.trim()||"Task",r=ee(n.settings,q()),i=bs(o,r);if(!i)throw new u(`Invalid --materialize-type "${o}"`,_.USAGE);let a=t.materializeParent?.trim()||e,c=t.materializeTags,d=await Si(n,e),m=(d.document.metadata.plan_steps??[]).slice(),{targets:l,skipped:f}=tc(m,s);if(l.length===0){if(f.length>0)return Rc(d,f);throw new u("No matching plan steps found for --steps",_.NOT_FOUND)}let g=await Tc({targets:l,parent:a,planItemId:d.itemId,resolvedTypeName:i,tags:c,options:t,pmRoot:n.pmRoot}),{document:w,itemId:b}=await B({id:e,options:t,ctx:n,op:"plan_materialize",message:t.message??`plan materialize ${s.join(",")}`,mutator(h){return Oc(h,l,g),{changedSteps:l.map(A=>A.id)}}}),v=L(w.metadata,"standard");return{action:"materialize",plan:v,materialized:g,...f.length>0?{materialize_skipped:f}:{},next_actions:N(b,v),warnings:Ei(f),generated_at:k()}}function Fc(e){if(e.subcommand==="create")return e;let t=bi(e.options.step);if(t.length>1)throw new u(`pm plan ${e.subcommand} accepts a single --step/--step-title value (repeated --step seeds ordered steps only on pm plan create)`,_.USAGE);return t.length===1&&!e.options.stepTitle?.trim()?{...e,options:{...e.options,stepTitle:t[0]}}:e}function X(e,t){if(!e.id)throw new u(`pm plan ${t} requires a plan id`,_.USAGE);return e.id}function ce(e,t){let n=X(e,t);if(!e.stepRef)throw new u(`pm plan ${t} requires <plan-id> <step>`,_.USAGE);return{id:n,stepRef:e.stepRef}}function Pc(e){let t=ce(e,"reorder-step");if(e.reorderTo===void 0)throw new u("pm plan reorder-step requires <plan-id> <step> <new-order>",_.USAGE);return{...t,reorderTo:e.reorderTo}}var Lc={create:(e,t)=>uc(e.options,e.global,t),show:(e,t)=>fc(X(e,"show"),e.options,t),"add-step":(e,t)=>hc(X(e,"add-step"),e.options,t),"update-step":(e,t)=>{let n=ce(e,"update-step");return En(n.id,e.options,t,{stepRef:n.stepRef,op:"plan_update_step"})},"complete-step":(e,t)=>{let n=ce(e,"complete-step");return En(n.id,e.options,t,{stepRef:n.stepRef,finalStatus:"completed",op:"plan_complete_step"})},"block-step":(e,t)=>{let n=ce(e,"block-step");return En(n.id,e.options,t,{stepRef:n.stepRef,finalStatus:"blocked",op:"plan_block_step"})},"reorder-step":(e,t)=>{let n=Pc(e);return kc(n.id,e.options,t,n.stepRef,n.reorderTo)},"remove-step":(e,t)=>{let n=ce(e,"remove-step");return Sc(n.id,e.options,t,n.stepRef)},link:(e,t)=>{let n=ce(e,"link");return xc(n.id,e.options,t,n.stepRef)},unlink:(e,t)=>{let n=ce(e,"unlink");return Ec(n.id,e.options,t,n.stepRef)},decision:(e,t)=>In(X(e,"decision"),e.options,t,"decision"),discovery:(e,t)=>In(X(e,"discovery"),e.options,t,"discovery"),validation:(e,t)=>In(X(e,"validation"),e.options,t,"validation"),resume:(e,t)=>Ac(X(e,"resume"),e.options,t),approve:(e,t)=>Ic(X(e,"approve"),e.options,t),materialize:(e,t)=>$c(X(e,"materialize"),e.options,t)};function Nc(e){let t=Lc[e];if(!t)throw new u(`Unknown pm plan subcommand "${e}"`,_.USAGE);return t}async function Ai(e){let t=await rc(e.global),n=Fc(e);return Nc(n.subcommand)(n,t)}import{readFile as Wc,writeFile as Yc}from"node:fs/promises";import Jc from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="582576df-8dbe-5f93-890b-5d872669dfe8")}catch{}})();function Nn(e,t){let n=Ue(e);if(n)throw new u(`History merge input (${t}) contains unresolved conflict markers at line ${n.line}. Merge drivers must receive clean per-side versions.`,_.GENERIC_FAILURE);let s=[];for(let[o,r]of e.split(/\r?\n/).entries()){let i=r.trim();if(i)try{let a=JSON.parse(i);if(typeof a!="object"||a===null||Array.isArray(a))throw new TypeError("history entry must be an object");s.push(a)}catch{throw new u(`History merge input (${t}) contains invalid JSON at line ${o+1}.`,_.GENERIC_FAILURE)}}return s}function ne(e){return C({ts:e.ts,author:e.author,op:e.op,patch:e.patch,message:e.message??null})}function Mc(e,t){let n=Math.min(e.length,t.length),s=0;for(;s<n&&ne(e[s])===ne(t[s]);)s+=1;return s}function Ii(e,t,n){Nn(e,"base");let s=Nn(t,"ours"),o=Nn(n,"theirs"),r=Mc(s,o);if(r===s.length&&r===o.length)return{merged:xe(s),strategy:"identical",common_entries:r,entries_from_ours:0,entries_from_theirs:0,entries_total:s.length,reanchored:!1};if(r===o.length)return{merged:xe(s),strategy:"fast_forward_ours",common_entries:r,entries_from_ours:s.length-r,entries_from_theirs:0,entries_total:s.length,reanchored:!1};if(r===s.length)return{merged:xe(o),strategy:"fast_forward_theirs",common_entries:r,entries_from_ours:0,entries_from_theirs:o.length-r,entries_total:o.length,reanchored:!1};let i=s.slice(r),a=new Set(i.map(ne)),c=o.slice(r).filter(l=>!a.has(ne(l))),d=[...i,...c].sort((l,f)=>{let g=De(l.ts,f.ts);if(g!==0)return g;let w=a.has(ne(l)),b=a.has(ne(f));return w!==b?Number(b)-Number(w):ne(l).localeCompare(ne(f))}),m=qs([...s.slice(0,r),...d]);return{merged:xe(m.entries),strategy:"union_reanchor",common_entries:r,entries_from_ours:i.length,entries_from_theirs:c.length,entries_total:m.entries.length,reanchored:!0}}function Mn(e,t){let n=Ue(e);if(n)throw new u(`Relationship merge input (${t}) contains unresolved conflict markers at line ${n.line}. Merge drivers must receive clean per-side versions.`,_.GENERIC_FAILURE);let s=[];for(let[o,r]of e.split(/\r?\n/).entries()){let i=r.trim();if(!i)continue;let a;try{a=JSON.parse(i)}catch{throw new u(`Relationship merge input (${t}) contains invalid JSON at line ${o+1}.`,_.GENERIC_FAILURE)}if(typeof a!="object"||a===null||Array.isArray(a)||typeof a.eventId!="string"||typeof a.sequence!="number")throw new u(`Relationship merge input (${t}) line ${o+1} is not a relationship event (eventId + sequence required).`,_.GENERIC_FAILURE);s.push(a)}return s}function tt(e){return e.length===0?"":`${e.map(t=>JSON.stringify(t)).join(`
|
|
8
8
|
`)}
|
|
9
9
|
`}function Dc(e){return e.map((t,n)=>({...t,sequence:n+1}))}function Ri(e,t,n){Mn(e,"base");let s=Mn(t,"ours"),o=Mn(n,"theirs"),r=Math.min(s.length,o.length),i=0;for(;i<r&&s[i].eventId===o[i].eventId;)i+=1;if(i===s.length&&i===o.length)return{merged:tt(s),strategy:"identical",common_entries:i,entries_from_ours:0,entries_from_theirs:0,entries_total:s.length,reanchored:!1};if(i===o.length)return{merged:tt(s),strategy:"fast_forward_ours",common_entries:i,entries_from_ours:s.length-i,entries_from_theirs:0,entries_total:s.length,reanchored:!1};if(i===s.length)return{merged:tt(o),strategy:"fast_forward_theirs",common_entries:i,entries_from_ours:0,entries_from_theirs:o.length-i,entries_total:o.length,reanchored:!1};let a=s.slice(i),c=new Set(a.map(f=>f.eventId)),d=o.slice(i).filter(f=>!c.has(f.eventId)),m=[...a,...d].sort((f,g)=>{if(f.timestamp!==void 0&&g.timestamp!==void 0){let v=De(f.timestamp,g.timestamp);if(v!==0)return v}else{if(f.timestamp===void 0&&g.timestamp!==void 0)return 1;if(f.timestamp!==void 0)return-1}let w=c.has(f.eventId),b=c.has(g.eventId);return w!==b?Number(b)-Number(w):0}),l=Dc([...s.slice(0,i),...m]);return{merged:tt(l),strategy:"union_reanchor",common_entries:i,entries_from_ours:a.length,entries_from_theirs:d.length,entries_total:l.length,reanchored:!0}}var jc=["tags","dependencies","comments","notes","learnings","files","tests","test_runs","docs","reminders","events"],Gc=["updated_at"];function me(e,t){return C(e??null)===C(t??null)}function Uc(e,t,n){let s=m=>Array.isArray(m)?m:[],o=new Set(s(e).map(m=>C(m))),r=s(t),i=new Set(r.map(m=>C(m))),a=s(n),c=new Set(a.map(m=>C(m))),d=r.filter(m=>{let l=C(m);return!o.has(l)||c.has(l)});for(let m of a){let l=C(m);!i.has(l)&&!o.has(l)&&d.push(m)}return d}function qc(e,t){return De(String(e),String(t))>=0?e:t}function qn(e,t,n,s){return me(t,n)?{value:t,from_theirs:!1,conflict:!1}:me(e,t)?{value:n,from_theirs:!0,conflict:!1}:me(e,n)?{value:t,from_theirs:!1,conflict:!1}:{value:s==="theirs"?n:t,from_theirs:s==="theirs",conflict:!0}}function Dn(e){return{...e.metadata}}function jn(e,t,n){try{return Dt(qe(e,n),n)}catch(s){throw new u(`Item merge input (${t}) is not a readable item document: ${String(s)}`,_.GENERIC_FAILURE)}}function zc(e,t,n,s){let o=new Set(jc),r=new Set(Gc),i=[...new Set([...Object.keys(t),...Object.keys(n)])].sort((c,d)=>c.localeCompare(d)),a={merged:{},conflictFields:[],fieldsFromTheirs:[],unionFields:[],conflictDecisions:[]};for(let c of i){let d=e[c],m=t[c],l=n[c];if(o.has(c)){let g=Uc(d,m,l);a.merged[c]=g,me(g,m)||a.unionFields.push(c);continue}if(r.has(c)){a.merged[c]=qc(m,l);continue}let f=qn(d,m,l,s);f.value!==void 0&&(a.merged[c]=f.value),f.conflict?(a.conflictFields.push(c),a.conflictDecisions.push({field:c,base:d,ours:m,theirs:l,retained:f.value,discarded:s==="theirs"?m:l})):f.from_theirs&&a.fieldsFromTheirs.push(c)}return a}function Ci(e,t,n,s={}){let o=s.preferred??"ours",r=e.trim().length>0,i=jn(t,"ours",s),a=jn(n,"theirs",s),c=r?jn(e,"base",s):i,d=r?Dn(c):{},m=Dn(i),l=Dn(a),{merged:f,conflictFields:g,fieldsFromTheirs:w,unionFields:b,conflictDecisions:v}=zc(d,m,l,o),h=qn(r?c.body:"",i.body,a.body,o);return h.conflict?(g.push("body"),v.push({field:"body",base:r?c.body:"",ours:i.body,theirs:a.body,retained:h.value,discarded:o==="theirs"?i.body:a.body})):h.from_theirs&&w.push("body"),{merged:Se({metadata:f,body:h.value},s),conflict_fields:g,fields_from_theirs:w,union_fields:b,conflict_decisions:v,preferred:o}}function Gn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Un(e,t){let n=Ue(e);if(n)throw new u(`JSON merge input (${t}) contains unresolved conflict markers at line ${n.line}.`,_.GENERIC_FAILURE);if(e.trim().length!==0)try{return JSON.parse(e)}catch{throw new u(`JSON merge input (${t}) is not valid JSON.`,_.GENERIC_FAILURE)}}function Hc(e,t,n){if(!Array.isArray(e)||!Array.isArray(t)||!Array.isArray(n))return null;let s=d=>{let m=new Map;for(let l of d){let f=C(l);m.set(f,(m.get(f)??0)+1)}return m},o=s(e),r=s(t),i=s(n);for(let[d,m]of o)if((r.get(d)??0)<m||(i.get(d)??0)<m)return null;let a=new Map(r),c=[];for(let d of n){let m=C(d),l=a.get(m)??0;l>0?a.set(m,l-1):c.push(d)}return{merged:[...t,...c],acceptedTheirs:c.length>0}}function Vc(e,t,n,s,o,r,i){if(!Gn(t)||!Gn(n))return null;let a=Gn(e)?e:{},c={},d=[...new Set([...Object.keys(t),...Object.keys(n)])].sort((m,l)=>m.localeCompare(l));for(let m of d){let l=o.length>0?`${o}.${m}`:m,f=Bc(a,t,n,m,s,l,r,i);f!==void 0&&(c[m]=f)}return c}function Ti(e,t,n,s,o,r,i){if(me(t,n))return t;let a=Hc(e,t,n);if(a!==null)return a.acceptedTheirs&&i.push(o),a.merged;let c=Vc(e,t,n,s,o,r,i);if(c!==null)return c;let d=qn(e,t,n,s);return d.conflict?r.push(o):d.from_theirs&&i.push(o),d.value}function Bc(e,t,n,s,o,r,i,a){let c=Object.prototype.hasOwnProperty.call(t,s),d=Object.prototype.hasOwnProperty.call(n,s),m=Object.prototype.hasOwnProperty.call(e,s);if(c&&d)return Ti(e[s],t[s],n[s],o,r,i,a);if(c){if(m&&me(e[s],t[s])){a.push(r);return}return m?(i.push(r),o==="theirs"?void 0:t[s]):t[s]}if(!(m&&me(e[s],n[s])))return m?(i.push(r),o==="theirs"?n[s]:void 0):(a.push(r),n[s])}function Oi(e,t,n,s={}){let o=s.preferred??"ours",r=Un(e,"base"),i=Un(t,"ours"),a=Un(n,"theirs"),c=[],d=[],m=Ti(r,i,a,o,"",c,d);return{merged:`${JSON.stringify(m??null,null,2)}
|
|
10
|
-
`,conflict_paths:c,paths_from_theirs:d,preferred:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9426a3fa-19bd-598f-90f6-df26a03bd9eb")}catch{}})();var $i=["item","history","relationship","json"];function Kc(e){let t=e.trim().toLowerCase();if($i.includes(t))return t;throw new u(`Unknown merge artifact "${e}". Supported values: ${$i.join(", ")}.`,_.USAGE)}function Xc(e){if(e===void 0)return"ours";let t=e.trim().toLowerCase();if(t==="ours"||t==="theirs")return t;throw new u(`Unknown --prefer value "${e}". Supported values: ours, theirs.`,_.USAGE)}async function zn(e,t){try{return await Wc(e,"utf8")}catch{throw new u(`Cannot read merge ${t} file at ${e}.`,_.NOT_FOUND)}}async function Zc(e){let t=$(process.cwd(),e.path);return await G(U(t))?D(t):null}function Qc(e,t){return e.endsWith(".md")?"json_markdown":e.endsWith(".toon")?"toon":t?.item_format??"toon"}async function Fi(e,t){let n=Kc(e.artifact),s=Xc(e.prefer),o=Jc.resolve(e.outputPath??e.oursPath),[r,i,a]=await Promise.all([zn(e.basePath,"base"),zn(e.oursPath,"ours"),zn(e.theirsPath,"theirs")]),c,d,m=[],l={};if(n==="history"){let g=Ii(r,i,a);c=g.merged,l.history={strategy:g.strategy,common_entries:g.common_entries,entries_from_ours:g.entries_from_ours,entries_from_theirs:g.entries_from_theirs,entries_total:g.entries_total,reanchored:g.reanchored}}else if(n==="relationship"){let g=Ri(r,i,a);c=g.merged,l.relationship={strategy:g.strategy,common_entries:g.common_entries,entries_from_ours:g.entries_from_ours,entries_from_theirs:g.entries_from_theirs,entries_total:g.entries_total,reanchored:g.reanchored}}else if(n==="item"){let g=await Zc(t),w=Ci(r,i,a,{format:Qc(e.itemPath??o,g),schema:g?.schema,extensionFieldNames:Ge(q()),preferred:s});c=w.merged,m.push(...w.conflict_fields),l.item={fields_from_theirs:w.fields_from_theirs,union_fields:w.union_fields},e.itemPath!==void 0&&(d={cwd:process.cwd(),itemPath:e.itemPath,preferred:s,fieldsFromTheirs:w.fields_from_theirs,unionFields:w.union_fields,decisions:w.conflict_decisions})}else{let g=Oi(r,i,a,{preferred:s});c=g.merged,m.push(...g.conflict_paths),l.json={paths_from_theirs:g.paths_from_theirs}}if(await Yc(o,c,"utf8"),d!==void 0){let g=await br(d);g!==null&&(l.receipt=Re(g))}let f=[];return m.length>0&&f.push(`Both branches changed ${m.join(", ")}; the ${s} value was kept. Review the merged file, re-apply the losing change if needed, then "git add" it.`),n==="history"&&l.history?.reanchored&&f.push('The merged history chain was re-anchored. Run "pm validate --check-history-drift" and "pm history-repair --all" after the merge to reconcile item state with merged history.'),{ok:m.length===0,artifact:n,output_path:o,preferred:s,conflicts:m,...l,guidance:f,generated_at:k()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b2f34565-7664-5612-815d-949b8b1d4f90")}catch{}})();async function Pi(e,t){let n=e.dryRun===!0,s=await wr(process.cwd()),o=s.reduce((b,v)=>((b[v.item_id]??=[]).push(v),b),{}),r=Object.fromEntries(Object.entries(o).map(([b,v])=>[b,{merge:{receipts:v.map(Re)}}])),i=await Xe({dryRun:n,author:e.author??t.author,message:e.message??"post-merge reconciliation of field-aware tracker history",force:e.force,auditOperation:"merge_reconcile",auditContextById:r},t),a=new Set(i.streams.map(b=>b.id)),c=Object.keys(o).filter(b=>!a.has(b));(await Promise.allSettled(c.map(b=>Ke(b,{dryRun:n,author:e.author??t.author,message:e.message??"record field-aware branch merge provenance",force:e.force,auditOperation:"merge_reconcile",auditContext:r[b],forceAuditEntry:!0},t)))).forEach((b,v)=>{let h=c[v];if(b.status==="fulfilled"){let A=b.value.changed?"repaired":"skipped_clean";i.streams.push({id:h,outcome:A,entries_rehashed:b.value.history.entries_rehashed,entries_patch_repaired:b.value.history.entries_patch_repaired,reconciled_with_item:b.value.history.reconciled_with_item,warnings:b.value.warnings}),i.totals[A]+=1}else i.streams.push({id:h,outcome:"failed",error:b.reason instanceof Error?b.reason.message:String(b.reason)}),i.totals.failed+=1});let m=0;!n&&i.totals.failed===0&&(await Promise.all(s.map(b=>vr(process.cwd(),b))),m=s.length);let l=await Je({checkHistoryDrift:!0,checkStorageIntegrity:!0},t),f=l.checks.every(b=>b.status==="ok"),g=i.totals.failed===0&&f,w=n?["Review repair.streams, then rerun pm merge reconcile without --dry-run to apply audited repairs.","No Git hook is installed automatically; invoke this command from an explicit post-merge hook only when your repository policy opts in."]:g?["Reconciliation is complete; commit changed history streams with the merge result.","Rerun pm merge reconcile --dry-run after future tracker-data merges as a non-mutating integrity check."]:["Reconciliation remains incomplete; inspect repair failures and non-green validation checks before retrying.","Do not commit repaired history streams as reconciled until pm merge reconcile returns ok=true."];return{ok:g,dry_run:n,repair:i,receipts:{pending_before:s.length,reconciled:m,summaries:s.map(Re)},validation:l,guidance:w,generated_at:l.generated_at}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be34ba04-504d-5c5a-90a7-22abb1142211")}catch{}})();function p(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n:void 0}function x(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0?n:void 0:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function Vn(e,t){let n=e[t];return typeof n=="string"?n:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function $e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function O(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new u(`${t} must be a finite integer.`,_.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let n=Number(e);if(!Number.isInteger(n))throw new u(`${t} must be a finite integer.`,_.USAGE);return n}}function st(e){let t=p(e,"outputFormat");return{json:!0,quiet:!0,author:p(e,"author"),path:p(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:p(e,"outputInclude"),outputLimit:x(e,"outputLimit"),outputBudget:x(e,"outputBudget"),outputFormat:t==="json"||t==="toon"?t:void 0}}var em=new Set(["tags","blockedBy","blocked_by","skills","fields"]),tm=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),nm=new Set(["files","files-discover","docs","test","test-all"]),sm=new Set(["claim","release","start-task","pause-task","close-task"]),om={list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt"],append:["body"]},rm=["outputInclude","outputLimit","outputBudget","outputFormat"];function ot(e,t){let n={},s=t!==void 0&&nm.has(t),o=t==="files"||t==="files-discover"||t==="docs";for(let[r,i]of Object.entries(e)){if(Array.isArray(i)&&em.has(r)){n[r]=i.join(",");continue}if(r==="note"&&o){n[r]=i;continue}if(typeof i=="string"&&tm.has(r)){n[r]=[i];continue}if(typeof i=="string"&&s&&(r==="add"||r==="remove")){n[r]=[i];continue}n[r]=i}return n}function Bn(e,t){let n=ke(e.options),s={},o=c=>{n[c]!==void 0||e[c]===void 0||(s[c]=e[c])};for(let c of om[t??""]??[])o(c);for(let c of rm)o(c);let r=ot({...s,...n},t),i=p(e,"author"),a=t!==void 0&&sm.has(t)?p(e,"assignee")??p(r,"assignee"):void 0;return i&&r.author===void 0?{...r,author:i}:a&&r.author===void 0?{...r,author:a}:r}function rt(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function Wn(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function se(e){let t=[],n=!0;for(let s of e.trim().toLowerCase()){if(s>="a"&&s<="z"||s>="0"&&s<="9"){t.push(s),n=!1;continue}n||(t.push("-"),n=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function Yn(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function P(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function Jn(e,t){let n=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),s={};for(let[r,i]of Object.entries(e))n.has(r)||(s[r]=i);let o={...s,...t};return delete o.args,o}function W(e,t){return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:{...t}}}function Fe(e){return{type:x(e,"filterType"),tag:x(e,"filterTag"),priority:x(e,"filterPriority"),deadlineBefore:x(e,"filterDeadlineBefore"),deadlineAfter:x(e,"filterDeadlineAfter"),updatedAfter:x(e,"filterUpdatedAfter"),updatedBefore:x(e,"filterUpdatedBefore"),createdAfter:x(e,"filterCreatedAfter"),createdBefore:x(e,"filterCreatedBefore"),ids:Vn(e,"ids"),assignee:x(e,"filterAssignee"),assigneeFilter:x(e,"filterAssigneeFilter")??x(e,"filterAssignee_filter"),parent:x(e,"filterParent"),sprint:x(e,"filterSprint"),release:x(e,"filterRelease"),limit:x(e,"limit"),offset:x(e,"offset")}}function Hn(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return P(e)}function nt(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function Ni(e){let t=Hn(e.kind),n=Hn(e.exemptIsolate),s=Hn(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:nt(e.maxDepth),limit:nt(e.limit),after:p(e,"after"),direction:p(e,"direction"),maxPaths:nt(e.maxPaths),sample:nt(e.sample),...n===void 0?{}:{exemptIsolate:n},...s===void 0?{}:{exemptIsolateType:s},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function Kn(e){return{status:p(e,"filterStatus"),list:$e(e.list)?dn(e.list):Fe(e),reason:p(e,"reason"),resolution:p(e,"resolution"),expectedResult:p(e,"expectedResult")??p(e,"expected_result")??p(e,"expected"),actualResult:p(e,"actualResult")??p(e,"actual_result")??p(e,"actual"),validateClose:p(e,"validateClose")??p(e,"validate_close"),author:p(e,"author"),message:p(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:p(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var im=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function Li(e){let t={};for(let[n,s]of Object.entries(e))im.has(n)||(t[n]=s);return it(t)}function it(e){let t=ot(e,"update-many");for(let n of ao)for(let s of n.keys){let o=t[s];typeof o=="number"&&Number.isFinite(o)&&(t[s]=String(o))}return Or(t)}function Xn(e){if($e(e.list)||$e(e.update)){let t=$e(e.update)?e.update:Li(e);return{status:x(e,"filterStatus"),list:$e(e.list)?dn(e.list):Fe(e),update:it(t),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:p(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}return{status:x(e,"filterStatus"),list:Fe(e),update:Li(e),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:p(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8cd69db-ec70-560f-a8c2-2d8d4be75459")}catch{}})();function Pe(e){return{...e.args,...e.options}}function Z(e,t){let n=p(e,t);if(n!==void 0)return n;throw new u(`Missing required parameter: ${t}`,_.USAGE)}function he(e){return typeof e=="string"?[e]:P(e)}function Mi(e){return Rr(Pe(e),e.global)}function Di(e){let t=Pe(e);return Tr({cwd:p(t,"cwd"),pmRoot:p(t,"path"),since:p(t,"since"),type:he(t.type),author:he(t.author),item:he(t.item),limit:t.limit===void 0?void 0:O(t.limit,"limit"),full:t.full===!0,...t.provenance===void 0?{}:{provenance:t.provenance===!0},...t.provenanceSummary===void 0?{}:{provenanceSummary:t.provenanceSummary===!0},...t.harness===void 0?{}:{harness:he(t.harness)},...t.agentInstance===void 0?{}:{agentInstance:he(t.agentInstance)},...t.provenanceFilter===void 0?{}:{provenanceFilter:he(t.provenanceFilter)}})}function ji(e){let t=Pe(e),n=Z(t,"subcommand");if(n==="install")return tr({dryRun:t.dryRun===!0},e.global);if(n==="reconcile")return Pi({dryRun:t.dryRun===!0,author:p(t,"author"),message:p(t,"message"),force:t.force===!0},e.global);if(n==="report")return kr({includeReconciled:t.includeReconciled===!0,cwd:p(t,"cwd")});if(n==="driver")return Fi({artifact:Z(t,"artifact"),basePath:Z(t,"basePath"),oursPath:Z(t,"oursPath"),theirsPath:Z(t,"theirsPath"),outputPath:p(t,"outputPath")??p(t,"output"),itemPath:p(t,"itemPath"),prefer:p(t,"prefer")},e.global);throw new u(`Unknown merge subcommand "${n}".`,_.USAGE,{code:"unknown_subcommand"})}function Gi(e){let t=Pe(e),n=Z(t,"subcommand");if(n!=="snapshot")throw new u(`Unknown workspace subcommand "${n}".`,_.USAGE,{code:"unknown_subcommand"});let s=p(t,"snapshotAction")??Z(t,"snapshot_action"),o=$(process.cwd(),e.global.path);if(s==="create")return Lr(o,{name:p(t,"name")});if(s==="list")return Mr(o);let r=Z(t,"target");if(s==="inspect")return Nr(o,r);if(s==="delete")return Gr(o,r);if(s==="restore")return t.dryRun===!0?Dr(o,r):jr(o,r,{force:t.force===!0,author:p(t,"author"),message:p(t,"message"),lockTtlSeconds:O(t.lockTtlSeconds,"lockTtlSeconds"),lockWaitMs:O(t.lockWaitMs,"lockWaitMs")});throw new u(`Unknown workspace snapshot action "${s}".`,_.USAGE,{code:"unknown_subcommand"})}function at(e){let t=Pe(e),n=Z(t,"title");return e.action==="meet"?$r(n,t,e.global):e.action==="event"?Fr(n,t,e.global):Pr(n,t,e.global)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f762b5e6-8224-531f-9dd1-f71dc18c3ddf")}catch{}})();function Ui(e){let t=e.options.all===!0,n=e.id??p(e.options,"id");return Cr(n,t),t?Xe(e.options,e.global):Ke(n,e.options,e.global)}function qi(e){let t=e.options.ids,n=Array.isArray(t)?t.map(String).filter(d=>d.trim().length>0):typeof t=="string"?t.split(",").map(d=>d.trim()).filter(Boolean):void 0,s=O(e.options.allOver??e.options.all_over,"history-compact allOver"),o=O(e.options.minEntries??e.options.min_entries,"history-compact minEntries"),r=p(e.options,"scope"),i=[];e.options.closed===!0&&i.push("closed"),(e.options.allStreams===!0||e.options.all_streams===!0)&&i.push("all-streams"),(r==="closed"||r==="all-streams")&&i.push(r);let a=[...new Set(i)];if(a.length>1)throw new u("history-compact: closed and all-streams scopes are mutually exclusive.",_.USAGE);let c=a[0];return Br(e.id,{ids:n,allOver:s,scope:c}),e.id!==void 0?Vr(e.id,{before:p(e.options,"before"),dryRun:e.options.dryRun===!0||e.options.dry_run===!0,author:p(e.options,"author"),message:p(e.options,"message"),force:e.force},e.global):Wr({ids:n,scope:c,allOver:s,minEntries:o,dryRun:e.options.dryRun===!0||e.options.dry_run===!0,author:p(e.options,"author"),message:p(e.options,"message"),force:e.force},e.global)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2643d11d-befc-5a87-8bec-760951eec4d0")}catch{}})();var am=new Set(["true","1","yes","on"]),cm=new Set(["false","0","no","off"]);function mm(e,t,n=[]){let s=[t,...n];for(let o of s){let r=e[o];if(typeof r=="string"&&r.trim().length>0)return r.trim()}}function dm(e,t,n=[]){let s=[t,...n];for(let o of s){let r=e[o];if(r!==void 0){if(typeof r=="boolean")return r;if(typeof r=="string"){let i=r.trim().toLowerCase();if(am.has(i))return!0;if(cm.has(i))return!1}}}}function lm(e,t,n=[]){for(let s of[t,...n]){let o=e[s],i=(typeof o=="string"?o.split(","):Array.isArray(o)?o.flatMap(a=>typeof a=="string"?a.split(","):[]):[]).map(a=>a.trim()).filter(a=>a.length>0);if(i.length>0)return i}return[]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="03e4257c-7d89-531b-adb0-664e77e7da18")}catch{}})();function T(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function pm(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}}function um(e){if(typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=4)return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);if(Number.isInteger(t)&&t>=0&&t<=4)return t}return 2}function fm(e){if(Array.isArray(e)){let t=e.filter(n=>typeof n=="string").map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(t)).sort((n,s)=>n.localeCompare(s))}return typeof e=="string"?Ut(e):[]}function _m(e){let t=T(e);if(t){let n=Nt(t);if(n)return n}return"open"}function Qn(e){if(typeof e=="number"&&Number.isInteger(e))return e;if(typeof e!="string"||e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)?t:void 0}function zi(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e===1?!0:e===0?!1:void 0;if(typeof e!="string")return;let t=e.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:void 0}function ge(e){if(!Array.isArray(e))return;let t=e.map(n=>T(n)).filter(n=>n!==void 0);return t.length>0?t:void 0}function Zn(e){return Bi(e,T)}function Hi(e){return Bi(e,Yi)}function hm(e,t){if(typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=100)return e;let n=T(e)?.toLowerCase();if(!n)return;let s=n==="med"?"medium":n;if(t.some(r=>r===s))return s;let o=Number(s);return Number.isInteger(o)&&o>=0&&o<=100?o:void 0}function Vi(e,t){let n=T(e)?.toLowerCase();if(!n)return;let s=n==="med"?"medium":n;return t.includes(s)?s:void 0}function es(e){return T(e)?.toLowerCase()==="global"?"global":"project"}function gm(e,t){let n=ts(e,t.allowScalar===!0);if(!n)return;let s=n.map(o=>km(o,t)).filter(o=>o!==void 0);return s.length>0?s:void 0}function ym(e,t={}){return Wi(e,t,(n,s)=>({path:n,scope:es(s?.scope),note:T(s?.note)}))}function bm(e,t={}){return Wi(e,t,(n,s)=>({path:n,scope:es(s?.scope),note:T(s?.note)}))}function wm(e,t={}){let n=ts(e,t.allowScalar===!0);if(!n)return;let s=n.map(o=>Em(o,t)).filter(o=>o!==void 0);return s.length>0?s:void 0}function vm(e,t){return V(e,t)}function mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ts(e,t){return Array.isArray(e)?e:t?[e]:void 0}function ct(e,t){for(let n of t){let s=T(e[n]);if(s)return s}}function Bi(e,t){if(!mt(e))return;let n=Object.entries(e).map(([s,o])=>[s.trim(),t(o)]).filter(s=>s[0].length>0&&s[1]!==void 0);return n.length>0?Object.fromEntries(n):void 0}function km(e,t){if(typeof e=="string")return Sm(e,t);if(!mt(e))return;let n=ct(e,t.textKeys??["text"]);if(!n)return;let s=t.createdAtKey??"created_at",o=t.authorKey??"author";return{created_at:(t.toIsoString?t.toIsoString(e[s]):T(e[s]))??t.fallbackCreatedAt,author:T(e[o])??t.fallbackAuthor,text:n}}function Sm(e,t){let n=T(e);return n?{created_at:t.fallbackCreatedAt,author:t.fallbackAuthor,text:n}:void 0}function Wi(e,t,n){let s=ts(e,t.allowScalar===!0);if(!s)return;let o=t.pathKeys??["path"],r=s.map(i=>xm(i,o,n)).filter(i=>i!==void 0);return r.length>0?r:void 0}function xm(e,t,n){if(typeof e=="string"){let o=T(e);return o?n(o):void 0}if(!mt(e))return;let s=ct(e,t);return s?n(s,e):void 0}function Em(e,t){if(typeof e=="string"){let o=T(e);return o?{command:o,scope:"project"}:void 0}if(!mt(e))return;let n=ct(e,t.commandKeys??["command"]),s=ct(e,t.pathKeys??["path"]);if(!(!n&&(t.requireCommand===!0||!s)))return{...n?{command:n}:{},...s?{path:s}:{},scope:es(e.scope),timeout_seconds:Am(e.timeout_seconds,t),note:T(e.note),...t.includeExtendedAssertions===!0?Im(e):{}}}function Am(e,t){let n=t.integerTimeout===!0?Qn(e):Yi(e);if(n===void 0)return;let s=t.timeoutMinimum??0;return t.timeoutExclusiveMinimum===!0?n>s?n:void 0:n>=s?n:void 0}function Yi(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string"||e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Im(e){return{pm_context_mode:Vi(e.pm_context_mode,["schema","tracker","auto"]),env_set:Zn(e.env_set),env_clear:ge(e.env_clear),shared_host_safe:zi(e.shared_host_safe),assert_stdout_contains:ge(e.assert_stdout_contains),assert_stdout_regex:ge(e.assert_stdout_regex),assert_stderr_contains:ge(e.assert_stderr_contains),assert_stderr_regex:ge(e.assert_stderr_regex),assert_stdout_min_lines:Qn(e.assert_stdout_min_lines),assert_json_field_equals:Zn(e.assert_json_field_equals),assert_json_field_gte:Hi(e.assert_json_field_gte)}}async function Rm(e){if(!await G(U(e)))throw new u(`Tracker is not initialized at ${e}. Run pm init first.`,_.NOT_FOUND)}function Ji(){return{metadata:{},body:""}}async function Cm(e){let{pmRoot:t,id:n,itemPath:s,document:o,author:r,message:i,settings:a,conflictWarningPrefix:c}=e,d=xt(t,n),m=Ji();try{let l=await ie(t,n,a.locks.ttl_seconds,r,!1,a.governance.force_required_for_stale_lock,a.locks.wait_ms);try{await Q(s,Se(o,{format:"toon"}));try{let f=jt({nowIso:k(),author:r,op:"import",before:m,after:o,message:i});return await Gt(d,f),{committed:!0,writeWarnings:[...await oe({path:s,scope:"project",op:"import",item_id:o.metadata.id,item_type:o.metadata.type,before:m,after:o,changed_fields:["imported"]}),...await oe({path:d,scope:"project",op:"import:history",item_id:o.metadata.id,item_type:o.metadata.type,before:m,after:o,changed_fields:["imported"]})]}}catch(f){throw await gt(s),f}}finally{await l()}}catch(l){if(l instanceof u&&l.exitCode===_.CONFLICT)return{committed:!1,conflictWarning:`${c}:${n}`};throw l}}import{readFile as Om}from"node:fs/promises";import $m from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3911e4fb-a9b3-5732-8b45-c484a121dffb")}catch{}})();function Tm(e){return e.trim().toLowerCase().replaceAll("_","-")}var ss=[{id:"quickstart",aliases:["start","getting-started","bootstrap"],title:"Quickstart",summary:"Initialize a tracker and run the shortest safe plan -> execute -> close loop.",intent:"Use this when a human or agent needs to start productive work quickly with minimal context load.",commands:["pm init","pm context --limit 10","pm list-open --limit 20",'pm create --create-mode progressive --title "..." --description "..." --type Task',"pm claim <ID>","pm update <ID> --status in_progress",'pm close <ID> "<reason with evidence>" --validate-close warn'],workflows:[{name:"Start Session Safely",goal:"Bootstrap without mutating unrelated state.",prompt:"You are bootstrapping pm work. Use a token-efficient context snapshot first, then select one open item, claim it, and only then mutate.",commands:["pm context --limit 10","pm list-open --limit 20","pm claim <ID>"]}],docs:[{path:"README.md",purpose:"High-level project and install entrypoint."},{path:"docs/QUICKSTART.md",purpose:"Short setup and first-command walkthrough."},{path:"docs/COMMANDS.md",purpose:"Task-oriented command recipes."}],related:["commands","workflows","release"]},{id:"commands",aliases:["cli","operations","reference"],title:"CLI Command Routing",summary:"Find the right command family quickly and use command-scoped help/contracts output.",intent:"Use this when selecting command paths, flags, and output formats for implementation or automation.",commands:["pm --help","pm <command> --help","pm <command> --help --explain","pm contracts --command <command> --flags-only","pm contracts --command <command> --availability-only --runtime-only","pm completion <bash|zsh|fish>"],workflows:[{name:"Flag Discovery",goal:"Resolve command flags deterministically before mutations.",prompt:"You are preparing to run a command. Use help and contracts surfaces to verify required/optional flags before execution.",commands:["pm <command> --help --explain","pm contracts --command <command> --flags-only"]}],docs:[{path:"docs/COMMANDS.md",purpose:"Command grouping and examples."},{path:"docs/CONFIGURATION.md",purpose:"Project/global settings and policy controls."},{path:"docs/TESTING.md",purpose:"Linked-test orchestration and safety guidance."}],related:["quickstart","workflows","sdk","extensions"]},{id:"workflows",aliases:["developer","maintainer","agent"],title:"Developer and Agent Workflows",summary:"Apply canonical claim -> execute -> verify -> close workflows with append-only evidence.",intent:"Use this for day-to-day coding-agent execution loops and handoff-safe updates.",commands:["pm claim <ID>","pm update <ID> --status in_progress","pm files <ID> --add ...","pm test <ID> --add ...",'pm comments <ID> "..."',"pm validate --check-resolution --check-history-drift","pm release <ID>"],workflows:[{name:"Execution Loop",goal:"Keep code, tests, and tracker evidence synchronized.",prompt:"You are implementing a scoped change. Claim first, link files/tests/docs as you go, append evidence comments, and close only after validation.",commands:["pm claim <ID>","pm update <ID> --status in_progress","pm files <ID> --add path=<file>,scope=project","pm test <ID> --run --progress",'pm close <ID> "<evidence>" --validate-close warn']}],docs:[{path:"AGENTS.md",purpose:"Repository operating rules and required workflow."},{path:"docs/AGENT_GUIDE.md",purpose:"Agent-oriented usage and context strategy."},{path:"docs/TESTING.md",purpose:"Sandbox-safe test execution rules."}],related:["quickstart","commands","skills"]},{id:"sdk",aliases:["api","typescript-sdk"],title:"SDK and Integrations",summary:"Use the published SDK surface for extension authoring and contract-safe integrations.",intent:"Use this when building or reviewing programmatic integrations against @unbrained/pm-cli/sdk.",commands:["pm contracts --schema-only","pm contracts --command extension --flags-only","pm contracts --runtime-only --availability-only"],workflows:[{name:"Integration Contract Check",goal:"Confirm action schemas and runtime availability before coding.",prompt:"You are wiring an integration. Capture schema + runtime availability first, then map your adapter payload fields to contract keys.",commands:["pm contracts --schema-only","pm contracts --availability-only --runtime-only","pm contracts --command <command> --flags-only"]}],docs:[{path:"docs/SDK.md",purpose:"Public SDK exports and extension authoring references."},{path:"docs/ARCHITECTURE.md",purpose:"Core runtime composition and extension load flow."}],related:["extensions","commands"]},{id:"extensions",aliases:["plugins","extension-authoring","packages","package-authoring"],title:"Packages and Extensions",summary:"Install, author, and diagnose packages/extensions with deterministic lifecycle controls.",intent:"Use this for package management, extension capability registration, and runtime diagnostics.",commands:["pm install <target> --project","pm upgrade --dry-run","pm package explore --project","pm package manage --detail summary","pm package doctor --detail deep","pm package activate <target> --project","pm package deactivate <target> --project"],workflows:[{name:"Lifecycle Triage",goal:"Diagnose extension state before forceful lifecycle actions.",prompt:"You are debugging package behavior. Inspect managed state first, then run doctor diagnostics, then apply install/adopt/activate actions.",commands:["pm package explore --project","pm package manage --detail summary","pm package doctor --detail deep","pm upgrade --packages-only --dry-run"]}],docs:[{path:"docs/EXTENSIONS.md",purpose:"Capability model and lifecycle command usage."},{path:"docs/examples/starter-extension/README.md",purpose:"Starter extension scaffold and local development path."},{path:"docs/SDK.md",purpose:"SDK contracts used by extension implementations."}],related:["sdk","commands","skills"]},{id:"skills",aliases:["agent-skills","agentskills"],title:"Agent Skills",summary:"Skill bundles for developer, user, extensions, and sdk workflows aligned to the current CLI.",intent:"Use this when an agent needs reproducible prompts/workflows with strict compatibility metadata.",commands:["pm guide skills --depth deep","pm contracts --command guide --flags-only","pm validate --check-command-references"],workflows:[{name:"Skill Selection",goal:"Pick the narrowest compatible skill first to minimize context usage.",prompt:"Select a pm skill based on the task intent, then execute only the workflow section needed for the current change.",commands:["pm guide skills","pm guide skills --depth deep"]}],docs:[{path:"docs/AGENT_GUIDE.md",purpose:"Agent-first usage and context model."},{path:"docs/README.md",purpose:"Documentation routing with progressive disclosure."},{path:".agents/skills/README.md",purpose:"Agent skills index and routing overview."},{path:".agents/skills/pm-developer/SKILL.md",purpose:"Developer-oriented pm skill workflow."},{path:".agents/skills/pm-user/SKILL.md",purpose:"User/operator pm skill workflow."},{path:".agents/skills/pm-extensions/SKILL.md",purpose:"Extension-focused pm skill workflow."},{path:".agents/skills/pm-sdk/SKILL.md",purpose:"SDK integration pm skill workflow."}],related:["workflows","harnesses","commands"]},{id:"harnesses",aliases:["compatibility","agent-compatibility"],title:"Agent Harness Compatibility",summary:"Cross-harness compatibility guidance for docs routing.",intent:"Use this when adapting pm docs and SDK contracts for an external automation harness.",commands:["pm guide skills","pm guide commands","pm contracts --runtime-only --availability-only"],workflows:[{name:"Harness Mapping",goal:"Route each harness to the same canonical skill/docs sources.",prompt:"Map harness-specific entrypoints to the same pm guide topics and .agents/skills workflows without adding runtime harness-specific code.",commands:["pm guide harnesses --depth standard","pm guide skills --depth deep"]}],docs:[{path:"docs/AGENT_GUIDE.md",purpose:"Agent context and output-mode conventions."},{path:"docs/README.md",purpose:"Single-source documentation routing entrypoint."},{path:".agents/skills/HARNESS_COMPATIBILITY.md",purpose:"Harness compatibility matrix and usage notes."}],related:["skills","workflows"]},{id:"release",aliases:["gates","ship","release-readiness"],title:"Release and Staleness Gates",summary:"Run release gates and docs/skills freshness checks before publishing.",intent:"Use this when validating release readiness and preventing docs/skills drift.",commands:["pnpm build","pnpm test:coverage","pnpm quality:static","node scripts/release/run-gates.mjs --telemetry-mode best-effort","pnpm security:scan"],workflows:[{name:"Pre-Release Gate Sweep",goal:"Ensure code, docs, and skills are all green before publish.",prompt:"Run release gates in deterministic order and treat docs/skills freshness failures as release blockers.",commands:["pnpm build","pnpm test:coverage","node scripts/release/run-gates.mjs --telemetry-mode best-effort"]}],docs:[{path:"docs/RELEASING.md",purpose:"Release flow and safety checks."},{path:"CHANGELOG.md",purpose:"Versioned release history and unreleased notes."},{path:"scripts/release/run-gates.mjs",purpose:"Source of truth for release gate ordering."}],related:["commands","skills","workflows"]}],ns=new Map;for(let e of ss){ns.set(e.id,e);for(let t of e.aliases)ns.set(t,e)}function Ki(){return ss.map(e=>({...e,aliases:[...e.aliases],commands:[...e.commands],workflows:e.workflows.map(t=>({...t,commands:[...t.commands]})),docs:e.docs.map(t=>({...t})),related:[...e.related]}))}function dt(){return ss.map(e=>e.id)}function Xi(e){if(!e)return null;let t=Tm(e);return t?ns.get(t)??null:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9376fbdf-c942-5fa6-9252-92125ae44e73")}catch{}})();var Fm=["markdown","toon","json"],Pm=["brief","standard","deep"];function Lm(e){if(!e)return;let t=e.trim().toLowerCase();if(!Fm.includes(t))throw new u("Guide format must be one of markdown|toon|json",_.USAGE);return t}function Nm(e,t){let n=Lm(e.format);if(t.json&&n&&n!=="json")throw new u("Cannot combine --json with --format markdown|toon",_.USAGE);return t.json?"json":n??"toon"}function Mm(e){if(!e)return"brief";let t=e.trim().toLowerCase();if(!Pm.includes(t))throw new u("Guide depth must be one of brief|standard|deep",_.USAGE);return t}function Dm(){return ys(process.env,"PM_CLI_PACKAGE_ROOT",import.meta.url,["..","..",".."])}function Zi(e){return e.replaceAll(`\r
|
|
10
|
+
`,conflict_paths:c,paths_from_theirs:d,preferred:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="182fee45-4de8-502d-8aec-84b5b8e4aecb")}catch{}})();var $i=["item","history","relationship","json"];function Kc(e){let t=e.trim().toLowerCase();if($i.includes(t))return t;throw new u(`Unknown merge artifact "${e}". Supported values: ${$i.join(", ")}.`,_.USAGE)}function Xc(e){if(e===void 0)return"ours";let t=e.trim().toLowerCase();if(t==="ours"||t==="theirs")return t;throw new u(`Unknown --prefer value "${e}". Supported values: ours, theirs.`,_.USAGE)}async function zn(e,t){try{return await Wc(e,"utf8")}catch{throw new u(`Cannot read merge ${t} file at ${e}.`,_.NOT_FOUND)}}async function Zc(e){let t=$(process.cwd(),e.path);return await G(U(t))?D(t):null}function Qc(e,t){return e.endsWith(".md")?"json_markdown":e.endsWith(".toon")?"toon":t?.item_format??"toon"}async function Fi(e,t){let n=Kc(e.artifact),s=Xc(e.prefer),o=Jc.resolve(e.outputPath??e.oursPath),[r,i,a]=await Promise.all([zn(e.basePath,"base"),zn(e.oursPath,"ours"),zn(e.theirsPath,"theirs")]),c,d,m=[],l={};if(n==="history"){let g=Ii(r,i,a);c=g.merged,l.history={strategy:g.strategy,common_entries:g.common_entries,entries_from_ours:g.entries_from_ours,entries_from_theirs:g.entries_from_theirs,entries_total:g.entries_total,reanchored:g.reanchored}}else if(n==="relationship"){let g=Ri(r,i,a);c=g.merged,l.relationship={strategy:g.strategy,common_entries:g.common_entries,entries_from_ours:g.entries_from_ours,entries_from_theirs:g.entries_from_theirs,entries_total:g.entries_total,reanchored:g.reanchored}}else if(n==="item"){let g=await Zc(t),w=Ci(r,i,a,{format:Qc(e.itemPath??o,g),schema:g?.schema,extensionFieldNames:Ge(q()),preferred:s});c=w.merged,m.push(...w.conflict_fields),l.item={fields_from_theirs:w.fields_from_theirs,union_fields:w.union_fields},e.itemPath!==void 0&&(d={cwd:process.cwd(),itemPath:e.itemPath,preferred:s,fieldsFromTheirs:w.fields_from_theirs,unionFields:w.union_fields,decisions:w.conflict_decisions})}else{let g=Oi(r,i,a,{preferred:s});c=g.merged,m.push(...g.conflict_paths),l.json={paths_from_theirs:g.paths_from_theirs}}if(await Yc(o,c,"utf8"),d!==void 0){let g=await br(d);g!==null&&(l.receipt=Re(g))}let f=[];if(m.length>0){let g=l.receipt===void 0?'Run "pm merge report" to inspect clone-local merge evidence.':`Run "pm merge report" and correlate receipt ${l.receipt.receipt_id} with item ${l.receipt.item_id}; clone-local discarded values are never copied into this result.`;f.push(`Both branches changed ${m.join(", ")}; the ${s} value was kept. ${g} Review the merged file, re-apply the losing change if needed, then "git add" it.`)}return n==="history"&&l.history?.reanchored&&f.push('The merged history chain was re-anchored. Run "pm validate --check-history-drift" and "pm history-repair --all" after the merge to reconcile item state with merged history.'),{ok:m.length===0,artifact:n,output_path:o,preferred:s,conflicts:m,...l,guidance:f,generated_at:k()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b2f34565-7664-5612-815d-949b8b1d4f90")}catch{}})();async function Pi(e,t){let n=e.dryRun===!0,s=await wr(process.cwd()),o=s.reduce((b,v)=>((b[v.item_id]??=[]).push(v),b),{}),r=Object.fromEntries(Object.entries(o).map(([b,v])=>[b,{merge:{receipts:v.map(Re)}}])),i=await Xe({dryRun:n,author:e.author??t.author,message:e.message??"post-merge reconciliation of field-aware tracker history",force:e.force,auditOperation:"merge_reconcile",auditContextById:r},t),a=new Set(i.streams.map(b=>b.id)),c=Object.keys(o).filter(b=>!a.has(b));(await Promise.allSettled(c.map(b=>Ke(b,{dryRun:n,author:e.author??t.author,message:e.message??"record field-aware branch merge provenance",force:e.force,auditOperation:"merge_reconcile",auditContext:r[b],forceAuditEntry:!0},t)))).forEach((b,v)=>{let h=c[v];if(b.status==="fulfilled"){let A=b.value.changed?"repaired":"skipped_clean";i.streams.push({id:h,outcome:A,entries_rehashed:b.value.history.entries_rehashed,entries_patch_repaired:b.value.history.entries_patch_repaired,reconciled_with_item:b.value.history.reconciled_with_item,warnings:b.value.warnings}),i.totals[A]+=1}else i.streams.push({id:h,outcome:"failed",error:b.reason instanceof Error?b.reason.message:String(b.reason)}),i.totals.failed+=1});let m=0;!n&&i.totals.failed===0&&(await Promise.all(s.map(b=>vr(process.cwd(),b))),m=s.length);let l=await Je({checkHistoryDrift:!0,checkStorageIntegrity:!0},t),f=l.checks.every(b=>b.status==="ok"),g=i.totals.failed===0&&f,w=n?["Review repair.streams, then rerun pm merge reconcile without --dry-run to apply audited repairs.","No Git hook is installed automatically; invoke this command from an explicit post-merge hook only when your repository policy opts in."]:g?["Reconciliation is complete; commit changed history streams with the merge result.","Rerun pm merge reconcile --dry-run after future tracker-data merges as a non-mutating integrity check."]:["Reconciliation remains incomplete; inspect repair failures and non-green validation checks before retrying.","Do not commit repaired history streams as reconciled until pm merge reconcile returns ok=true."];return{ok:g,dry_run:n,repair:i,receipts:{pending_before:s.length,reconciled:m,summaries:s.map(Re)},validation:l,guidance:w,generated_at:l.generated_at}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be34ba04-504d-5c5a-90a7-22abb1142211")}catch{}})();function p(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n:void 0}function x(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0?n:void 0:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function Vn(e,t){let n=e[t];return typeof n=="string"?n:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function $e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function O(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new u(`${t} must be a finite integer.`,_.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let n=Number(e);if(!Number.isInteger(n))throw new u(`${t} must be a finite integer.`,_.USAGE);return n}}function st(e){let t=p(e,"outputFormat");return{json:!0,quiet:!0,author:p(e,"author"),path:p(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:p(e,"outputInclude"),outputLimit:x(e,"outputLimit"),outputBudget:x(e,"outputBudget"),outputFormat:t==="json"||t==="toon"?t:void 0}}var em=new Set(["tags","blockedBy","blocked_by","skills","fields"]),tm=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),nm=new Set(["files","files-discover","docs","test","test-all"]),sm=new Set(["claim","release","start-task","pause-task","close-task"]),om={list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt"],append:["body"]},rm=["outputInclude","outputLimit","outputBudget","outputFormat"];function ot(e,t){let n={},s=t!==void 0&&nm.has(t),o=t==="files"||t==="files-discover"||t==="docs";for(let[r,i]of Object.entries(e)){if(Array.isArray(i)&&em.has(r)){n[r]=i.join(",");continue}if(r==="note"&&o){n[r]=i;continue}if(typeof i=="string"&&tm.has(r)){n[r]=[i];continue}if(typeof i=="string"&&s&&(r==="add"||r==="remove")){n[r]=[i];continue}n[r]=i}return n}function Bn(e,t){let n=ke(e.options),s={},o=c=>{n[c]!==void 0||e[c]===void 0||(s[c]=e[c])};for(let c of om[t??""]??[])o(c);for(let c of rm)o(c);let r=ot({...s,...n},t),i=p(e,"author"),a=t!==void 0&&sm.has(t)?p(e,"assignee")??p(r,"assignee"):void 0;return i&&r.author===void 0?{...r,author:i}:a&&r.author===void 0?{...r,author:a}:r}function rt(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function Wn(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function se(e){let t=[],n=!0;for(let s of e.trim().toLowerCase()){if(s>="a"&&s<="z"||s>="0"&&s<="9"){t.push(s),n=!1;continue}n||(t.push("-"),n=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function Yn(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function P(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function Jn(e,t){let n=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),s={};for(let[r,i]of Object.entries(e))n.has(r)||(s[r]=i);let o={...s,...t};return delete o.args,o}function W(e,t){return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:{...t}}}function Fe(e){return{type:x(e,"filterType"),tag:x(e,"filterTag"),priority:x(e,"filterPriority"),deadlineBefore:x(e,"filterDeadlineBefore"),deadlineAfter:x(e,"filterDeadlineAfter"),updatedAfter:x(e,"filterUpdatedAfter"),updatedBefore:x(e,"filterUpdatedBefore"),createdAfter:x(e,"filterCreatedAfter"),createdBefore:x(e,"filterCreatedBefore"),ids:Vn(e,"ids"),assignee:x(e,"filterAssignee"),assigneeFilter:x(e,"filterAssigneeFilter")??x(e,"filterAssignee_filter"),parent:x(e,"filterParent"),sprint:x(e,"filterSprint"),release:x(e,"filterRelease"),limit:x(e,"limit"),offset:x(e,"offset")}}function Hn(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return P(e)}function nt(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function Ni(e){let t=Hn(e.kind),n=Hn(e.exemptIsolate),s=Hn(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:nt(e.maxDepth),limit:nt(e.limit),after:p(e,"after"),direction:p(e,"direction"),maxPaths:nt(e.maxPaths),sample:nt(e.sample),...n===void 0?{}:{exemptIsolate:n},...s===void 0?{}:{exemptIsolateType:s},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function Kn(e){return{status:p(e,"filterStatus"),list:$e(e.list)?dn(e.list):Fe(e),reason:p(e,"reason"),resolution:p(e,"resolution"),expectedResult:p(e,"expectedResult")??p(e,"expected_result")??p(e,"expected"),actualResult:p(e,"actualResult")??p(e,"actual_result")??p(e,"actual"),validateClose:p(e,"validateClose")??p(e,"validate_close"),author:p(e,"author"),message:p(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:p(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var im=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function Li(e){let t={};for(let[n,s]of Object.entries(e))im.has(n)||(t[n]=s);return it(t)}function it(e){let t=ot(e,"update-many");for(let n of ao)for(let s of n.keys){let o=t[s];typeof o=="number"&&Number.isFinite(o)&&(t[s]=String(o))}return Or(t)}function Xn(e){if($e(e.list)||$e(e.update)){let t=$e(e.update)?e.update:Li(e);return{status:x(e,"filterStatus"),list:$e(e.list)?dn(e.list):Fe(e),update:it(t),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:p(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}return{status:x(e,"filterStatus"),list:Fe(e),update:Li(e),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:p(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f8cd69db-ec70-560f-a8c2-2d8d4be75459")}catch{}})();function Pe(e){return{...e.args,...e.options}}function Z(e,t){let n=p(e,t);if(n!==void 0)return n;throw new u(`Missing required parameter: ${t}`,_.USAGE)}function he(e){return typeof e=="string"?[e]:P(e)}function Mi(e){return Rr(Pe(e),e.global)}function Di(e){let t=Pe(e);return Tr({cwd:p(t,"cwd"),pmRoot:p(t,"path"),since:p(t,"since"),type:he(t.type),author:he(t.author),item:he(t.item),limit:t.limit===void 0?void 0:O(t.limit,"limit"),full:t.full===!0,...t.provenance===void 0?{}:{provenance:t.provenance===!0},...t.provenanceSummary===void 0?{}:{provenanceSummary:t.provenanceSummary===!0},...t.harness===void 0?{}:{harness:he(t.harness)},...t.agentInstance===void 0?{}:{agentInstance:he(t.agentInstance)},...t.provenanceFilter===void 0?{}:{provenanceFilter:he(t.provenanceFilter)}})}function ji(e){let t=Pe(e),n=Z(t,"subcommand");if(n==="install")return tr({dryRun:t.dryRun===!0},e.global);if(n==="reconcile")return Pi({dryRun:t.dryRun===!0,author:p(t,"author"),message:p(t,"message"),force:t.force===!0},e.global);if(n==="report")return kr({includeReconciled:t.includeReconciled===!0,cwd:p(t,"cwd")});if(n==="driver")return Fi({artifact:Z(t,"artifact"),basePath:Z(t,"basePath"),oursPath:Z(t,"oursPath"),theirsPath:Z(t,"theirsPath"),outputPath:p(t,"outputPath")??p(t,"output"),itemPath:p(t,"itemPath"),prefer:p(t,"prefer")},e.global);throw new u(`Unknown merge subcommand "${n}".`,_.USAGE,{code:"unknown_subcommand"})}function Gi(e){let t=Pe(e),n=Z(t,"subcommand");if(n!=="snapshot")throw new u(`Unknown workspace subcommand "${n}".`,_.USAGE,{code:"unknown_subcommand"});let s=p(t,"snapshotAction")??Z(t,"snapshot_action"),o=$(process.cwd(),e.global.path);if(s==="create")return Lr(o,{name:p(t,"name")});if(s==="list")return Mr(o);let r=Z(t,"target");if(s==="inspect")return Nr(o,r);if(s==="delete")return Gr(o,r);if(s==="restore")return t.dryRun===!0?Dr(o,r):jr(o,r,{force:t.force===!0,author:p(t,"author"),message:p(t,"message"),lockTtlSeconds:O(t.lockTtlSeconds,"lockTtlSeconds"),lockWaitMs:O(t.lockWaitMs,"lockWaitMs")});throw new u(`Unknown workspace snapshot action "${s}".`,_.USAGE,{code:"unknown_subcommand"})}function at(e){let t=Pe(e),n=Z(t,"title");return e.action==="meet"?$r(n,t,e.global):e.action==="event"?Fr(n,t,e.global):Pr(n,t,e.global)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f762b5e6-8224-531f-9dd1-f71dc18c3ddf")}catch{}})();function Ui(e){let t=e.options.all===!0,n=e.id??p(e.options,"id");return Cr(n,t),t?Xe(e.options,e.global):Ke(n,e.options,e.global)}function qi(e){let t=e.options.ids,n=Array.isArray(t)?t.map(String).filter(d=>d.trim().length>0):typeof t=="string"?t.split(",").map(d=>d.trim()).filter(Boolean):void 0,s=O(e.options.allOver??e.options.all_over,"history-compact allOver"),o=O(e.options.minEntries??e.options.min_entries,"history-compact minEntries"),r=p(e.options,"scope"),i=[];e.options.closed===!0&&i.push("closed"),(e.options.allStreams===!0||e.options.all_streams===!0)&&i.push("all-streams"),(r==="closed"||r==="all-streams")&&i.push(r);let a=[...new Set(i)];if(a.length>1)throw new u("history-compact: closed and all-streams scopes are mutually exclusive.",_.USAGE);let c=a[0];return Br(e.id,{ids:n,allOver:s,scope:c}),e.id!==void 0?Vr(e.id,{before:p(e.options,"before"),dryRun:e.options.dryRun===!0||e.options.dry_run===!0,author:p(e.options,"author"),message:p(e.options,"message"),force:e.force},e.global):Wr({ids:n,scope:c,allOver:s,minEntries:o,dryRun:e.options.dryRun===!0||e.options.dry_run===!0,author:p(e.options,"author"),message:p(e.options,"message"),force:e.force},e.global)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2643d11d-befc-5a87-8bec-760951eec4d0")}catch{}})();var am=new Set(["true","1","yes","on"]),cm=new Set(["false","0","no","off"]);function mm(e,t,n=[]){let s=[t,...n];for(let o of s){let r=e[o];if(typeof r=="string"&&r.trim().length>0)return r.trim()}}function dm(e,t,n=[]){let s=[t,...n];for(let o of s){let r=e[o];if(r!==void 0){if(typeof r=="boolean")return r;if(typeof r=="string"){let i=r.trim().toLowerCase();if(am.has(i))return!0;if(cm.has(i))return!1}}}}function lm(e,t,n=[]){for(let s of[t,...n]){let o=e[s],i=(typeof o=="string"?o.split(","):Array.isArray(o)?o.flatMap(a=>typeof a=="string"?a.split(","):[]):[]).map(a=>a.trim()).filter(a=>a.length>0);if(i.length>0)return i}return[]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c2567f6a-cd1c-56b5-a93d-41e92ed574bf")}catch{}})();function T(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function pm(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}}function um(e){if(typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=4)return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);if(Number.isInteger(t)&&t>=0&&t<=4)return t}return 2}function fm(e){if(Array.isArray(e)){let t=e.filter(n=>typeof n=="string").map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(t)).sort((n,s)=>n.localeCompare(s))}return typeof e=="string"?Ut(e):[]}function _m(e){let t=T(e);if(t){let n=Nt(t);if(n)return n}return"open"}function Qn(e){if(typeof e=="number"&&Number.isInteger(e))return e;if(typeof e!="string"||e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)?t:void 0}function zi(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e===1?!0:e===0?!1:void 0;if(typeof e!="string")return;let t=e.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:void 0}function ge(e){if(!Array.isArray(e))return;let t=e.map(n=>T(n)).filter(n=>n!==void 0);return t.length>0?t:void 0}function Zn(e){return Bi(e,T)}function Hi(e){return Bi(e,Yi)}function hm(e,t){if(typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=100)return e;let n=T(e)?.toLowerCase();if(!n)return;let s=n==="med"?"medium":n;if(t.some(r=>r===s))return s;let o=Number(s);return Number.isInteger(o)&&o>=0&&o<=100?o:void 0}function Vi(e,t){let n=T(e)?.toLowerCase();if(!n)return;let s=n==="med"?"medium":n;return t.includes(s)?s:void 0}function es(e){return T(e)?.toLowerCase()==="global"?"global":"project"}function gm(e,t){let n=ts(e,t.allowScalar===!0);if(!n)return;let s=n.map(o=>km(o,t)).filter(o=>o!==void 0);return s.length>0?s:void 0}function ym(e,t={}){return Wi(e,t,(n,s)=>({path:n,scope:es(s?.scope),note:T(s?.note)}))}function bm(e,t={}){return Wi(e,t,(n,s)=>({path:n,scope:es(s?.scope),note:T(s?.note)}))}function wm(e,t={}){let n=ts(e,t.allowScalar===!0);if(!n)return;let s=n.map(o=>Em(o,t)).filter(o=>o!==void 0);return s.length>0?s:void 0}function vm(e,t){return V(e,t)}function mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ts(e,t){return Array.isArray(e)?e:t?[e]:void 0}function ct(e,t){for(let n of t){let s=T(e[n]);if(s)return s}}function Bi(e,t){if(!mt(e))return;let n=Object.entries(e).map(([s,o])=>[s.trim(),t(o)]).filter(s=>s[0].length>0&&s[1]!==void 0);return n.length>0?Object.fromEntries(n):void 0}function km(e,t){if(typeof e=="string")return Sm(e,t);if(!mt(e))return;let n=ct(e,t.textKeys??["text"]);if(!n)return;let s=t.createdAtKey??"created_at",o=t.authorKey??"author";return{created_at:(t.toIsoString?t.toIsoString(e[s]):T(e[s]))??t.fallbackCreatedAt,author:T(e[o])??t.fallbackAuthor,text:n}}function Sm(e,t){let n=T(e);return n?{created_at:t.fallbackCreatedAt,author:t.fallbackAuthor,text:n}:void 0}function Wi(e,t,n){let s=ts(e,t.allowScalar===!0);if(!s)return;let o=t.pathKeys??["path"],r=s.map(i=>xm(i,o,n)).filter(i=>i!==void 0);return r.length>0?r:void 0}function xm(e,t,n){if(typeof e=="string"){let o=T(e);return o?n(o):void 0}if(!mt(e))return;let s=ct(e,t);return s?n(s,e):void 0}function Em(e,t){if(typeof e=="string"){let o=T(e);return o?{command:o,scope:"project"}:void 0}if(!mt(e))return;let n=ct(e,t.commandKeys??["command"]),s=ct(e,t.pathKeys??["path"]);if(!(!n&&(t.requireCommand===!0||!s)))return{...n?{command:n}:{},...s?{path:s}:{},scope:es(e.scope),timeout_seconds:Am(e.timeout_seconds,t),note:T(e.note),...t.includeExtendedAssertions===!0?Im(e):{}}}function Am(e,t){let n=t.integerTimeout===!0?Qn(e):Yi(e);if(n===void 0)return;let s=t.timeoutMinimum??0;return t.timeoutExclusiveMinimum===!0?n>s?n:void 0:n>=s?n:void 0}function Yi(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string"||e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Im(e){return{pm_context_mode:Vi(e.pm_context_mode,["schema","tracker","auto"]),env_set:Zn(e.env_set),env_clear:ge(e.env_clear),shared_host_safe:zi(e.shared_host_safe),assert_stdout_contains:ge(e.assert_stdout_contains),assert_stdout_regex:ge(e.assert_stdout_regex),assert_stderr_contains:ge(e.assert_stderr_contains),assert_stderr_regex:ge(e.assert_stderr_regex),assert_stdout_min_lines:Qn(e.assert_stdout_min_lines),assert_json_field_equals:Zn(e.assert_json_field_equals),assert_json_field_gte:Hi(e.assert_json_field_gte)}}async function Rm(e){if(!await G(U(e)))throw new u(`Tracker is not initialized at ${e}. Run pm init first.`,_.NOT_FOUND)}function Ji(){return{metadata:{},body:""}}async function Cm(e){let{pmRoot:t,id:n,itemPath:s,document:o,author:r,message:i,settings:a,conflictWarningPrefix:c}=e,d=xt(t,n),m=Ji();try{let l=await ie(t,n,a.locks.ttl_seconds,r,!1,a.governance.force_required_for_stale_lock,a.locks.wait_ms);try{await Q(s,Se(o,{format:"toon"}));try{let f=jt({nowIso:k(),author:r,op:"import",before:m,after:o,message:i});return await Gt(d,f),{committed:!0,writeWarnings:[...await oe({path:s,scope:"project",op:"import",item_id:o.metadata.id,item_type:o.metadata.type,before:m,after:o,changed_fields:["imported"]}),...await oe({path:d,scope:"project",op:"import:history",item_id:o.metadata.id,item_type:o.metadata.type,before:m,after:o,changed_fields:["imported"]})]}}catch(f){throw await gt(s),f}}finally{await l()}}catch(l){if(l instanceof u&&l.exitCode===_.CONFLICT)return{committed:!1,conflictWarning:`${c}:${n}`};throw l}}import{readFile as Om}from"node:fs/promises";import $m from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3911e4fb-a9b3-5732-8b45-c484a121dffb")}catch{}})();function Tm(e){return e.trim().toLowerCase().replaceAll("_","-")}var ss=[{id:"quickstart",aliases:["start","getting-started","bootstrap"],title:"Quickstart",summary:"Initialize a tracker and run the shortest safe plan -> execute -> close loop.",intent:"Use this when a human or agent needs to start productive work quickly with minimal context load.",commands:["pm init","pm context --limit 10","pm list-open --limit 20",'pm create --create-mode progressive --title "..." --description "..." --type Task',"pm claim <ID>","pm update <ID> --status in_progress",'pm close <ID> "<reason with evidence>" --validate-close warn'],workflows:[{name:"Start Session Safely",goal:"Bootstrap without mutating unrelated state.",prompt:"You are bootstrapping pm work. Use a token-efficient context snapshot first, then select one open item, claim it, and only then mutate.",commands:["pm context --limit 10","pm list-open --limit 20","pm claim <ID>"]}],docs:[{path:"README.md",purpose:"High-level project and install entrypoint."},{path:"docs/QUICKSTART.md",purpose:"Short setup and first-command walkthrough."},{path:"docs/COMMANDS.md",purpose:"Task-oriented command recipes."}],related:["commands","workflows","release"]},{id:"commands",aliases:["cli","operations","reference"],title:"CLI Command Routing",summary:"Find the right command family quickly and use command-scoped help/contracts output.",intent:"Use this when selecting command paths, flags, and output formats for implementation or automation.",commands:["pm --help","pm <command> --help","pm <command> --help --explain","pm contracts --command <command> --flags-only","pm contracts --command <command> --availability-only --runtime-only","pm completion <bash|zsh|fish>"],workflows:[{name:"Flag Discovery",goal:"Resolve command flags deterministically before mutations.",prompt:"You are preparing to run a command. Use help and contracts surfaces to verify required/optional flags before execution.",commands:["pm <command> --help --explain","pm contracts --command <command> --flags-only"]}],docs:[{path:"docs/COMMANDS.md",purpose:"Command grouping and examples."},{path:"docs/CONFIGURATION.md",purpose:"Project/global settings and policy controls."},{path:"docs/TESTING.md",purpose:"Linked-test orchestration and safety guidance."}],related:["quickstart","workflows","sdk","extensions"]},{id:"workflows",aliases:["developer","maintainer","agent"],title:"Developer and Agent Workflows",summary:"Apply canonical claim -> execute -> verify -> close workflows with append-only evidence.",intent:"Use this for day-to-day coding-agent execution loops and handoff-safe updates.",commands:["pm claim <ID>","pm update <ID> --status in_progress","pm files <ID> --add ...","pm test <ID> --add ...",'pm comments <ID> "..."',"pm validate --check-resolution --check-history-drift","pm release <ID>"],workflows:[{name:"Execution Loop",goal:"Keep code, tests, and tracker evidence synchronized.",prompt:"You are implementing a scoped change. Claim first, link files/tests/docs as you go, append evidence comments, and close only after validation.",commands:["pm claim <ID>","pm update <ID> --status in_progress","pm files <ID> --add path=<file>,scope=project","pm test <ID> --run --progress",'pm close <ID> "<evidence>" --validate-close warn']}],docs:[{path:"AGENTS.md",purpose:"Repository operating rules and required workflow."},{path:"docs/AGENT_GUIDE.md",purpose:"Agent-oriented usage and context strategy."},{path:"docs/TESTING.md",purpose:"Sandbox-safe test execution rules."}],related:["quickstart","commands","skills"]},{id:"sdk",aliases:["api","typescript-sdk"],title:"SDK and Integrations",summary:"Use the published SDK surface for extension authoring and contract-safe integrations.",intent:"Use this when building or reviewing programmatic integrations against @unbrained/pm-cli/sdk.",commands:["pm contracts --schema-only","pm contracts --command extension --flags-only","pm contracts --runtime-only --availability-only"],workflows:[{name:"Integration Contract Check",goal:"Confirm action schemas and runtime availability before coding.",prompt:"You are wiring an integration. Capture schema + runtime availability first, then map your adapter payload fields to contract keys.",commands:["pm contracts --schema-only","pm contracts --availability-only --runtime-only","pm contracts --command <command> --flags-only"]}],docs:[{path:"docs/SDK.md",purpose:"Public SDK exports and extension authoring references."},{path:"docs/ARCHITECTURE.md",purpose:"Core runtime composition and extension load flow."}],related:["extensions","commands"]},{id:"extensions",aliases:["plugins","extension-authoring","packages","package-authoring"],title:"Packages and Extensions",summary:"Install, author, and diagnose packages/extensions with deterministic lifecycle controls.",intent:"Use this for package management, extension capability registration, and runtime diagnostics.",commands:["pm install <target> --project","pm upgrade --dry-run","pm package explore --project","pm package manage --detail summary","pm package doctor --detail deep","pm package activate <target> --project","pm package deactivate <target> --project"],workflows:[{name:"Lifecycle Triage",goal:"Diagnose extension state before forceful lifecycle actions.",prompt:"You are debugging package behavior. Inspect managed state first, then run doctor diagnostics, then apply install/adopt/activate actions.",commands:["pm package explore --project","pm package manage --detail summary","pm package doctor --detail deep","pm upgrade --packages-only --dry-run"]}],docs:[{path:"docs/EXTENSIONS.md",purpose:"Capability model and lifecycle command usage."},{path:"docs/examples/starter-extension/README.md",purpose:"Starter extension scaffold and local development path."},{path:"docs/SDK.md",purpose:"SDK contracts used by extension implementations."}],related:["sdk","commands","skills"]},{id:"skills",aliases:["agent-skills","agentskills"],title:"Agent Skills",summary:"Skill bundles for developer, user, extensions, and sdk workflows aligned to the current CLI.",intent:"Use this when an agent needs reproducible prompts/workflows with strict compatibility metadata.",commands:["pm guide skills --depth deep","pm contracts --command guide --flags-only","pm validate --check-command-references"],workflows:[{name:"Skill Selection",goal:"Pick the narrowest compatible skill first to minimize context usage.",prompt:"Select a pm skill based on the task intent, then execute only the workflow section needed for the current change.",commands:["pm guide skills","pm guide skills --depth deep"]}],docs:[{path:"docs/AGENT_GUIDE.md",purpose:"Agent-first usage and context model."},{path:"docs/README.md",purpose:"Documentation routing with progressive disclosure."},{path:".agents/skills/README.md",purpose:"Agent skills index and routing overview."},{path:".agents/skills/pm-developer/SKILL.md",purpose:"Developer-oriented pm skill workflow."},{path:".agents/skills/pm-user/SKILL.md",purpose:"User/operator pm skill workflow."},{path:".agents/skills/pm-extensions/SKILL.md",purpose:"Extension-focused pm skill workflow."},{path:".agents/skills/pm-sdk/SKILL.md",purpose:"SDK integration pm skill workflow."}],related:["workflows","harnesses","commands"]},{id:"harnesses",aliases:["compatibility","agent-compatibility"],title:"Agent Harness Compatibility",summary:"Cross-harness compatibility guidance for docs routing.",intent:"Use this when adapting pm docs and SDK contracts for an external automation harness.",commands:["pm guide skills","pm guide commands","pm contracts --runtime-only --availability-only"],workflows:[{name:"Harness Mapping",goal:"Route each harness to the same canonical skill/docs sources.",prompt:"Map harness-specific entrypoints to the same pm guide topics and .agents/skills workflows without adding runtime harness-specific code.",commands:["pm guide harnesses --depth standard","pm guide skills --depth deep"]}],docs:[{path:"docs/AGENT_GUIDE.md",purpose:"Agent context and output-mode conventions."},{path:"docs/README.md",purpose:"Single-source documentation routing entrypoint."},{path:".agents/skills/HARNESS_COMPATIBILITY.md",purpose:"Harness compatibility matrix and usage notes."}],related:["skills","workflows"]},{id:"release",aliases:["gates","ship","release-readiness"],title:"Release and Staleness Gates",summary:"Run release gates and docs/skills freshness checks before publishing.",intent:"Use this when validating release readiness and preventing docs/skills drift.",commands:["pnpm build","pnpm test:coverage","pnpm quality:static","node scripts/release/run-gates.mjs --telemetry-mode best-effort","pnpm security:scan"],workflows:[{name:"Pre-Release Gate Sweep",goal:"Ensure code, docs, and skills are all green before publish.",prompt:"Run release gates in deterministic order and treat docs/skills freshness failures as release blockers.",commands:["pnpm build","pnpm test:coverage","node scripts/release/run-gates.mjs --telemetry-mode best-effort"]}],docs:[{path:"docs/RELEASING.md",purpose:"Release flow and safety checks."},{path:"CHANGELOG.md",purpose:"Versioned release history and unreleased notes."},{path:"scripts/release/run-gates.mjs",purpose:"Source of truth for release gate ordering."}],related:["commands","skills","workflows"]}],ns=new Map;for(let e of ss){ns.set(e.id,e);for(let t of e.aliases)ns.set(t,e)}function Ki(){return ss.map(e=>({...e,aliases:[...e.aliases],commands:[...e.commands],workflows:e.workflows.map(t=>({...t,commands:[...t.commands]})),docs:e.docs.map(t=>({...t})),related:[...e.related]}))}function dt(){return ss.map(e=>e.id)}function Xi(e){if(!e)return null;let t=Tm(e);return t?ns.get(t)??null:null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9376fbdf-c942-5fa6-9252-92125ae44e73")}catch{}})();var Fm=["markdown","toon","json"],Pm=["brief","standard","deep"];function Lm(e){if(!e)return;let t=e.trim().toLowerCase();if(!Fm.includes(t))throw new u("Guide format must be one of markdown|toon|json",_.USAGE);return t}function Nm(e,t){let n=Lm(e.format);if(t.json&&n&&n!=="json")throw new u("Cannot combine --json with --format markdown|toon",_.USAGE);return t.json?"json":n??"toon"}function Mm(e){if(!e)return"brief";let t=e.trim().toLowerCase();if(!Pm.includes(t))throw new u("Guide depth must be one of brief|standard|deep",_.USAGE);return t}function Dm(){return ys(process.env,"PM_CLI_PACKAGE_ROOT",import.meta.url,["..","..",".."])}function Zi(e){return e.replaceAll(`\r
|
|
11
11
|
`,`
|
|
12
12
|
`)}function jm(e,t,n){let o=Zi(e).split(`
|
|
13
13
|
`),i=o.slice(0,t).join(`
|
|
@@ -2002,4 +2002,4 @@ end`}var jd={bash:'Add to ~/.bashrc or ~/.bash_profile: eval "$(pm completion ba
|
|
|
2002
2002
|
`);I(e.progressEnabled,"writing keyword artifacts"),await Q(t,`${JSON.stringify(e.manifest,null,2)}
|
|
2003
2003
|
`),await Q(n,`${o}
|
|
2004
2004
|
`);let r=[];if(e.mode!=="keyword")try{I(e.progressEnabled,"writing vectorization status ledger"),await so(e.pmRoot,e.vectorizationLedgerEntries,e.vectorizationEmbeddingMetadata)}catch(i){r.push(`search_vectorization_status_ledger_write_failed:${i instanceof Error?i.message:String(i)}`)}return r}async function ll(e,t){let n=Hd(e.mode),s=zd(e),o=e.full===!0;I(s,`start mode=${n}`);let r=$(process.cwd(),t.path);if(!await G(U(r)))throw new u(`Tracker is not initialized at ${r}. Run pm init first.`,_.NOT_FOUND);let i=Hs(await D(r)).settings,a=null;try{a=await ie(r,Vs,i.locks.ttl_seconds,V(void 0,"pm-reindex"),!1,i.governance.force_required_for_stale_lock,i.locks.wait_ms)}catch(c){throw c instanceof u&&c.exitCode===_.CONFLICT?new u("Another pm reindex run is already active for this project. Wait for it to finish before starting a new keyword, semantic, or hybrid reindex.",_.CONFLICT,{code:"reindex_already_running",type:"urn:pm-cli:error:reindex_already_running",why:"Semantic reindex can be expensive and duplicate runs compete for the same local embedding model and vector store.",nextSteps:["Check active pm reindex processes before starting another reindex.","Rerun with --progress when you need non-interactive visibility."]}):c}try{let c=Wd(i),d=Yd(i),m=el({requestedMode:n,pmRoot:r,settings:i,extensionEmbedding:c,extensionVectorAdapter:d}),l=n;I(s,"loading item corpus");let f=await tl({pmRoot:r,settings:i}),g=f.warnings,{documentCandidates:w,metadataDocuments:b}=f;I(s,`loaded_items=${b.length}`);let v=k(),h=Qd(l,v,b),A=Ne.join(r,cs),R=Ne.join(r,ms),z=l==="keyword"?await ls(r,w,i.schema,g):b,H=[],Me={},_t=null,ve=Zd(l);if(l==="keyword"&&await nl({pmRoot:r,settings:i,forceFullSemantic:o,extensionEmbedding:c,reindexWarnings:g}),l!=="keyword"){let ht=await ml({pmRoot:r,settings:i,requestedMode:n,activeEmbeddingProvider:m.activeEmbeddingProvider,activeVectorStore:m.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:d,documentCandidates:w,metadataDocuments:b,documentsForKeywordArtifacts:z,forceFullSemantic:o,reindexWarnings:g,semanticWarnings:H,semanticSummary:ve,progressEnabled:s});z=ht.documentsForKeywordArtifacts,Me=ht.vectorizationLedgerEntries,_t=ht.vectorizationEmbeddingMetadata}let ka=await dl({pmRoot:r,mode:l,manifest:h,documentsForKeywordArtifacts:z,settings:i,vectorizationLedgerEntries:Me,vectorizationEmbeddingMetadata:_t,progressEnabled:s}),Sa=[...await oe({path:A,scope:"project",op:"reindex:manifest"}),...await oe({path:R,scope:"project",op:"reindex:embeddings"}),...await Cs({mode:l,total_items:b.length})];return I(s,"done"),{ok:!0,mode:l,total_items:b.length,semantic:ve,artifacts:{manifest:cs,embeddings:ms},warnings:[...g,...H,...ka,...Sa],generated_at:v}}finally{await a?.()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="196ad1a3-c78f-5eef-90fd-ea5de108b9fa")}catch{}})();var ga=Symbol("pm.active-extension-host-context");function M(e){return{fullChangedFields:!0,options:e}}var y=class e{defaults;constructor(t={}){this.defaults={...t.pmRoot===void 0?{}:{path:t.pmRoot},...t.cwd===void 0?{}:{cwd:t.cwd},...t.author===void 0?{}:{author:t.author},...t.noExtensions===void 0?{}:{noExtensions:t.noExtensions}}}static forActiveExtensionHost(t){let n=new e({...t,noExtensions:!0});return n.defaults[ga]=!0,n}run(t,n={}){return wl({...this.defaults,...n,action:t})}runTyped(t,n={}){return this.run(t,n)}context(t={}){return this.runTyped("context",{options:t})}list(t={}){return this.runTyped("list",{options:t})}search(t,n={}){return this.runTyped("search",{query:t,options:n})}get(t,n={}){return this.runTyped("get",{id:t,options:n})}next(t={}){return this.runTyped("next",{options:t})}aggregate(t={}){return this.runTyped("aggregate",{options:t})}stats(t={}){return this.runTyped("stats",{options:t})}duplicates(t={}){return this.runTyped("duplicates",{options:t})}comments(t,n={}){return this.runTyped("comments",{id:t,options:n})}notes(t,n={}){return this.runTyped("notes",{id:t,options:n})}learnings(t,n={}){return this.runTyped("learnings",{id:t,options:n})}files(t,n={}){return this.runTyped("files",{id:t,options:n})}filesDiscover(t,n={}){return this.runTyped("files-discover",{id:t,options:n})}filesLookup(t){return this.runTyped("files-lookup",{options:t})}docs(t,n={}){return this.runTyped("docs",{id:t,options:n})}deps(t,n={}){return this.runTyped("deps",{id:t,options:n})}graph(t,n={},s={}){return this.runTyped("graph",{subcommand:t,...n,options:s})}append(t,n,s={}){return this.runTyped("append",{id:t,...M({...s,body:n})})}init(t,n={}){return this.runTyped("init",{...t===void 0?{}:{prefix:t},options:n})}config(t,n,s,o,r={}){return this.runTyped("config",{scope:t,configAction:n,...s===void 0?{}:{key:s},...o===void 0?{}:{value:o},options:r})}schema(t,n={}){return this.runTyped("schema",{options:{...n,subcommand:t}})}schemaList(){return this.runTyped("schema",{options:{subcommand:"list"}})}schemaShow(t){return this.runTyped("schema",{name:t,options:{subcommand:"show"}})}schemaAddType(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"add-type"}})}schemaRemoveType(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-type"}})}schemaAddStatus(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"add-status"}})}schemaRemoveStatus(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-status"}})}schemaAddField(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"add-field"}})}schemaRemoveField(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-field"}})}schemaListFields(){return this.runTyped("schema",{options:{subcommand:"list-fields"}})}schemaShowField(t){return this.runTyped("schema",{name:t,options:{subcommand:"show-field"}})}schemaApplyPreset(t,n={}){return this.runTyped("schema",{typePreset:t,options:{...n,subcommand:"apply-preset"}})}schemaInferTypes(t={}){return this.runTyped("schema",{options:{...t,subcommand:"add-type",infer:!0}})}schemaRenameType(t,n,s){return this.runTyped("schema",{name:t,options:{...s,subcommand:"rename-type",to:n}})}schemaRenameField(t,n,s,o){return this.runTyped("schema",{name:t,options:{...s,subcommand:"rename-field",to:n,...o?{fieldTypeScope:o}:{}}})}schemaRemapStatus(t,n,s){return this.runTyped("schema",{name:t,options:{...s,subcommand:"remap-status",to:n}})}schemaShowStatus(t){return this.runTyped("schema",{name:t,options:{subcommand:"show-status"}})}profile(t,n={}){return this.runTyped("profile",{options:{...n,subcommand:t}})}profileList(){return this.runTyped("profile",{options:{subcommand:"list"}})}profileShow(t){return this.runTyped("profile",{name:t,options:{subcommand:"show"}})}profileApply(t,n={}){return this.runTyped("profile",{name:t,options:{...n,subcommand:"apply"}})}profileLint(t){return this.runTyped("profile",{name:t,options:{subcommand:"lint"}})}validate(t={}){return this.runTyped("validate",{options:t})}health(t={}){return this.runTyped("health",{options:t})}gc(t={}){return this.runTyped("gc",{options:t})}historyRedact(t,n){return this.runTyped("history-redact",{id:t,options:n})}historyRepair(t,n={}){return this.runTyped("history-repair",{id:t,options:n})}historyRepairAll(t={}){return this.runTyped("history-repair",{options:{...t,all:!0}})}historyCompact(t,n={}){return this.runTyped("history-compact",{id:t,options:n})}historyCompactBulk(t){return this.runTyped("history-compact",{options:t})}historyAuthorAcknowledge(t){return this.runTyped("history-author-acknowledge",{historyEvent:(t.events??[]).map(n=>`${n.item_id}:${String(n.line)}`),allActionable:t.all_actionable===!0,attributedAuthor:t.attributed_author,reviewer:t.reviewer,reason:t.reason})}plan(t,n,s={},o,r){return this.runTyped("plan",{...n===void 0?{}:{id:n},...o===void 0?{}:{stepRef:o},...r===void 0?{}:{reorderTo:r},options:{...s,subcommand:t}})}planCreate(t){return this.plan("create",void 0,t)}planShow(t,n={}){return this.plan("show",t,n)}planAddStep(t,n){return this.plan("add-step",t,n)}planUpdateStep(t,n,s){return this.plan("update-step",t,s,n)}planCompleteStep(t,n,s={}){return this.plan("complete-step",t,s,n)}planBlockStep(t,n,s){return this.plan("block-step",t,s,n)}planReorderStep(t,n,s,o={}){return this.plan("reorder-step",t,o,n,s)}planRemoveStep(t,n,s={}){return this.plan("remove-step",t,s,n)}planLink(t,n,s){return this.plan("link",t,s,n)}planUnlink(t,n,s){return this.plan("unlink",t,s,n)}planDecision(t,n){return this.plan("decision",t,n)}planDiscovery(t,n){return this.plan("discovery",t,n)}planValidation(t,n){return this.plan("validation",t,n)}planResume(t,n){return this.plan("resume",t,n)}planApprove(t,n={}){return this.plan("approve",t,n)}planMaterialize(t,n){return this.plan("materialize",t,n)}create(t={}){return this.runTyped("create",M(t))}update(t,n={}){return this.runTyped("update",{id:t,...M(n)})}close(t,n,s={}){return this.runTyped("close",{id:t,reason:n,...M(s)})}claim(t,n={}){return this.runTyped("claim",{id:t,...M(n)})}claimNext(t={}){return this.runTyped("claim",{next:!0,...M(t)})}release(t,n={}){return this.runTyped("release",{id:t,...M(n)})}copy(t,n={}){return this.runTyped("copy",{id:t,...M(n)})}delete(t,n={}){return this.runTyped("delete",{id:t,...M(n)})}restore(t,n,s={}){return this.runTyped("restore",{fullChangedFields:!0,id:t,options:{...s,target:n}})}focus(t,n={}){return this.runTyped("focus",{...t===void 0?{}:{id:t},...M(n)})}startTask(t,n={}){return this.runTyped("start-task",{id:t,...M(n)})}pauseTask(t,n={}){return this.runTyped("pause-task",{id:t,...M(n)})}closeTask(t,n,s={}){return this.runTyped("close-task",{id:t,reason:n,...M(s)})}extension(t,n={}){return this.runTyped("extension",{...t===void 0?{}:{target:t},options:n})}extensionList(t={}){return this.extension("list",t)}extensionActivate(t,n={}){return this.runTyped("extension-activate",{target:t,options:n})}extensionDeactivate(t,n={}){return this.runTyped("extension-deactivate",{target:t,options:n})}package(t,n={}){return this.runTyped("package",{...t===void 0?{}:{target:t},options:{...n,vocabulary:"package"}})}packageList(t={}){return this.package("list",t)}packageInstall(t,n={}){return this.runTyped("package-install",{target:t,options:n})}packageUninstall(t,n={}){return this.runTyped("package-uninstall",{target:t,options:n})}packageDoctor(t={}){return this.runTyped("package-doctor",{options:t})}packageManage(t,n={}){return this.runTyped("package-manage",{...t===void 0?{}:{target:t},options:n})}packageDescribe(t,n={}){return this.runTyped("package-describe",{...t===void 0?{}:{target:t},options:n})}packageReload(t={}){return this.runTyped("package-reload",{options:t})}packageCatalog(t={}){return this.runTyped("package-catalog",{options:t})}packageActivate(t,n={}){return this.runTyped("package-activate",{target:t,options:n})}packageDeactivate(t,n={}){return this.runTyped("package-deactivate",{target:t,options:n})}upgrade(t,n={}){return this.runTyped("upgrade",{...t===void 0?{}:{target:t},options:n})}};function Uh(e={},t={}){return new y(t).context(e)}function qh(e={},t={}){return new y(t).list(e)}function zh(e,t={},n={}){return new y(n).search(e,t)}function Hh(e,t={},n={}){return new y(n).get(e,t)}function Vh(e={},t={}){return new y(t).next(e)}function Bh(e={},t={}){return new y(t).aggregate(e)}function Wh(e={},t={}){return new y(t).stats(e)}function Yh(e={},t={}){return new y(t).duplicates(e)}function Jh(e,t={},n={}){return new y(n).comments(e,t)}function Kh(e,t={},n={}){return new y(n).notes(e,t)}function Xh(e,t={},n={}){return new y(n).learnings(e,t)}function Zh(e,t={},n={}){return new y(n).files(e,t)}function Qh(e,t={},n={}){return new y(n).filesDiscover(e,t)}function eg(e,t={}){return new y(t).filesLookup(e)}function tg(e,t={},n={}){return new y(n).docs(e,t)}function ng(e,t={},n={}){return new y(n).deps(e,t)}function sg(e,t={},n={},s={}){return new y(s).graph(e,t,n)}function og(e,t,n={},s={}){return new y(s).append(e,t,n)}function rg(e,t={},n={}){return new y(n).init(e,t)}function ig(e,t,n,s,o={},r={}){return new y(r).config(e,t,n,s,o)}function ag(e,t={},n={}){return new y(n).schema(e,t)}function cg(e={}){return new y(e).schemaList()}function mg(e,t={}){return new y(t).schemaShow(e)}function dg(e,t={},n={}){return new y(n).schemaAddType(e,t)}function lg(e,t={},n={}){return new y(n).schemaRemoveType(e,t)}function pg(e,t={},n={}){return new y(n).schemaAddStatus(e,t)}function ug(e,t={},n={}){return new y(n).schemaRemoveStatus(e,t)}function fg(e,t={},n={}){return new y(n).schemaAddField(e,t)}function _g(e,t={},n={}){return new y(n).schemaRemoveField(e,t)}function hg(e={}){return new y(e).schemaListFields()}function gg(e,t={}){return new y(t).schemaShowField(e)}function yg(e,t={},n={}){return new y(n).schemaApplyPreset(e,t)}function bg(e={},t={}){return new y(t).schemaInferTypes(e)}function wg(e,t,n,s={}){return new y(s).schemaRenameType(e,t,n)}function vg(e,t,n,s,o={}){return new y(o).schemaRenameField(e,t,n,s)}function kg(e,t,n,s={}){return new y(s).schemaRemapStatus(e,t,n)}function Sg(e,t={}){return new y(t).schemaShowStatus(e)}function xg(e,t={},n={}){return new y(n).profile(e,t)}function Eg(e={}){return new y(e).profileList()}function Ag(e,t={}){return new y(t).profileShow(e)}function Ig(e,t={},n={}){return new y(n).profileApply(e,t)}function Rg(e,t={}){return new y(t).profileLint(e)}function Cg(e={},t={}){return new y(t).validate(e)}function Tg(e={},t={}){return new y(t).health(e)}function Og(e={},t={}){return new y(t).gc(e)}function $g(e,t,n={}){return new y(n).historyRedact(e,t)}function Fg(e,t={},n={}){return new y(n).historyRepair(e,t)}function Pg(e={},t={}){return new y(t).historyRepairAll(e)}function Lg(e,t={},n={}){return new y(n).historyCompact(e,t)}function Ng(e,t={}){return new y(t).historyCompactBulk(e)}function Mg(e={},t={}){return new y(t).create(e)}function Dg(e,t={},n={}){return new y(n).update(e,t)}function jg(e,t,n={},s={}){return new y(s).close(e,t,n)}function Gg(e,t={},n={}){return new y(n).claim(e,t)}function Ug(e={},t={}){return new y(t).claimNext(e)}function qg(e,t={},n={}){return new y(n).release(e,t)}function zg(e,t={},n={}){return new y(n).copy(e,t)}function Hg(e,t={},n={}){return new y(n).delete(e,t)}function Vg(e,t,n={},s={}){return new y(s).restore(e,t,n)}function Bg(e,t={},n={}){return new y(n).focus(e,t)}function Wg(e,t={},n={}){return new y(n).startTask(e,t)}function Yg(e,t={},n={}){return new y(n).pauseTask(e,t)}function Jg(e,t,n={},s={}){return new y(s).closeTask(e,t,n)}function Kg(e,t={},n={}){return new y(n).extension(e,t)}function Xg(e={},t={}){return new y(t).extensionList(e)}function Zg(e,t={},n={}){return new y(n).extensionActivate(e,t)}function Qg(e,t={},n={}){return new y(n).extensionDeactivate(e,t)}function ey(e,t={},n={}){return new y(n).package(e,t)}function ty(e={},t={}){return new y(t).packageList(e)}function ny(e,t={},n={}){return new y(n).packageInstall(e,t)}function sy(e,t={},n={}){return new y(n).packageUninstall(e,t)}function oy(e={},t={}){return new y(t).packageDoctor(e)}function ry(e,t={},n={}){return new y(n).packageManage(e,t)}function iy(e,t={},n={}){return new y(n).packageDescribe(e,t)}function ay(e={},t={}){return new y(t).packageReload(e)}function cy(e={},t={}){return new y(t).packageCatalog(e)}function my(e,t={},n={}){return new y(n).packageActivate(e,t)}function dy(e,t={},n={}){return new y(n).packageDeactivate(e,t)}function ly(e,t={},n={}){return new y(n).upgrade(e,t)}function ul(e,t,n){return JSON.stringify([ua.resolve(e),ua.resolve(n??process.cwd()),t.extensions.enabled,t.extensions.disabled,t.extensions.policy])}async function fl(e,t,n){let s=ul(e,t,n);return ii(s,()=>np(e,t,n))}async function py(e,t={}){let n=await D(e),s=t.extensionRegistrations??(t.noExtensions===!0?null:await fl(e,n,t.cwd)),o=ee(n,s),r=re(n.schema),i=Lt(n.schema);return{types:[...o.types],statuses:r.definitions.map(a=>a.id),openStatus:r.open_status,closeStatus:r.close_status,canceledStatus:r.canceled_status,fields:oi(i.definitions),extensionCommands:ri(s?.commands??[])}}async function uy(e,t={}){let n=typeof e=="string"?{...t,pmRoot:e}:e??t,s={json:!0,quiet:n.quiet??!0,noExtensions:n.noExtensions??!1,noPager:!0,profile:n.profile??!1,path:n.pmRoot};return ln(n,s)}function Y(e,t){let n=p(e,t);if(!n)throw new u(`Missing required argument: ${t}`,64);return n}var fa=Is(),ya=new pl;function ut(){Rt(ws()),Ct(vs()),Tt(ks()),Ot(Ss()),$t(xs()),Ft(Es()),Pt(As())}async function ba(e,t,n,s){return Rs(()=>t===void 0?fa.read(()=>_a(e,n,s)):fa.write(()=>hl(t,()=>_a(e,n,s))))}async function fy(e,t){let n=e.cwd,s=n??process.cwd();return ba(st({path:e.path,noExtensions:e.noExtensions}),n,s,()=>ya.run(!0,t))}async function _a(e,t,n){let s=$(t,e.path);if(e.noExtensions)return ut(),Sn({pmRoot:s},()=>n(null));if(!await G(U(s)))return ut(),n(null);let o=null,r;try{let i=await D(s),a=await Et({pmRoot:s,settings:i,cwd:t,noExtensions:!1}),c=await It({...a,loaded:a.loaded});r={loadResult:a,activationResult:c},Rt(c.hooks),Ct(c.commands),Tt(c.parsers),Ot(c.preflight),$t(c.services),Ft(c.renderers),Pt(c.registrations),o={registrations:c.registrations,commands:c.commands,pmRoot:s,packages:a.loaded}}catch(i){ut(),console.error("[pm-sdk] extension activation failed; continuing without active extensions:",i)}try{return await Sn({pmRoot:s,packages:o?.packages},()=>n(o))}finally{ut(),r&&await At(r.loadResult,r.activationResult).catch(()=>{})}}async function _l(e,t,n,s,o){if(!o)throw new u(`Unsupported native pm action: ${e}`,_.USAGE);let r=se(e),a=o.registrations.commands.find(d=>se(d.action)===r)?.command??o.commands.handlers.find(d=>se(d.command)===r)?.command;if(!a)throw new u(`Unsupported native pm action: ${e}`,_.USAGE);let c=await Ts({command:Yn(a),args:P(n.args??t.args),options:Jn(t,n),global:s,pm_root:o.pmRoot,sdk:pi(o.pmRoot,y.forActiveExtensionHost({pmRoot:o.pmRoot,author:typeof s.author=="string"&&s.author.trim()?s.author.trim():"pm-extension"}))});if(!c.handled){let d=c.warnings.length>0?` (${c.warnings.join(", ")})`:"";throw new u(`Unsupported native pm action: ${e}${d}`,_.USAGE)}return c.result}async function hl(e,t){let n=process.cwd();process.chdir(e);try{return await t()}finally{process.chdir(n)}}var gl=new Set(["activity","aggregate","context","contracts","deps","files-discover","get","graph","health","history","list","next","search","stats","telemetry","validate"]);function yl(e){let t=Y(e,"action"),n=se(t),s=we(hn,n),o=s?.action??n,r={...e,action:o};return s?.options!==void 0&&(r.options={...s.options,...ke(e.options)}),o==="package"&&(r.options={...ke(r.options),vocabulary:"package"}),{action:o,args:r}}function bl(e){return!gl.has(se(e))}async function wl(e){let t=yl(e),n=st(t.args),s=bl(t.action),o=p(t.args,"cwd"),r=o??process.cwd();try{return e[ga]===!0||ya.getStore()===!0?await ha(t.action,t.args,n,null):await ba(n,o,r,i=>ha(t.action,t.args,n,i))}finally{s&&_n()}}function we(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function ft(e){return p(e.args,"target")??p(e.options,"target")}function E(e,t=e.options){return e.id??Y(t,"id")}async function vl(e){let t=ue("list",e.options);return t.compact===void 0&&t.brief===void 0&&t.fields===void 0&&t.includeBody===void 0&&(t.compact=!0),fn(await Kt(p(e.args,"status")??p(t,"status"),t,e.global),t)}async function kl(e){let t=ue("search",e.options);return t.compact===void 0&&t.full===void 0&&t.fields===void 0&&(t.compact=!0),fn(await mn(Y(e.args,"query"),t,e.global),t)}async function Sl(e){let{changedFields:t,idOnly:n,runnerOptions:s}=W(e.args,e.options);return J(await Ae(s,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}async function xl(e){let{changedFields:t,idOnly:n,runnerOptions:s}=W(e.args,e.options),o={...s,...s.title===void 0&&typeof e.args.title=="string"?{title:e.args.title}:{},...s.message===void 0&&typeof e.args.message=="string"?{message:e.args.message}:{}};return J(await nn(E(e,o),o,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}async function El(e){let{changedFields:t,idOnly:n,runnerOptions:s}=W(e.args,e.options);return J(await fe(E(e,s),s,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}async function Al(e){let{changedFields:t,idOnly:n,runnerOptions:s}=W(e.args,e.options),o=p(e.args,"reason")??p(e.args,"text")??p(s,"reason")??p(s,"text");return J(await We(E(e,s),o,s,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}function Il(e){let t={...e.options};return t.add===void 0&&t.stdin===void 0&&t.file===void 0&&t.edit===void 0&&t.delete===void 0&&(t.includeMeta=!0,t.limit===void 0&&t.full!==!0&&(t.limit="20")),delete t.full,Xo(E(e),t,e.global)}function Rl(e){let t=P(e.options.lookupPath);if(t&&t.length>0)return an({paths:t,scope:e.options.scope==="project"||e.options.scope==="global"?e.options.scope:void 0,limit:O(e.options.limit,"files lookup limit"),offset:O(e.options.offset,"files lookup offset"),noTruncate:e.options.noTruncate===!0,strictRead:e.options.strictRead===!0},e.global);let n=E(e);return e.options.discover===!0?cn(n,Wn(e.options),e.global):Er(n,rt(e.options),e.global)}function Cl(e){return Xr({subcommand:p(e.args,"subcommand")??p(e.options,"subcommand"),limit:Tl(e.args,e.options)},e.global)}function Tl(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:p(e,"limit")??p(t,"limit")}function Ol(e){let t={...e.options};return t.brief===void 0&&t.summary===void 0&&t.full===void 0&&(t.summary=!0),Sr(e.global,t)}function $l(e){let t=p(e.args,"configAction")??p(e.options,"configAction")??p(e.options,"action");if(t===void 0)throw new u("Missing required argument: configAction",64);return Ar(p(e.args,"scope")??p(e.options,"scope")??"project",t,p(e.args,"key")??p(e.options,"key"),e.options,e.global,p(e.args,"value")??p(e.options,"value"))}function Fl(e){let t={...e.options};return t.compact===void 0&&(t.compact=t.full!==!0),delete t.full,zo(t,e.global)}function Pl(e,t){if(typeof e=="number"){if(!Number.isFinite(e)||!Number.isInteger(e))throw new u(`${t} must be a finite integer.`,64);return e}if(typeof e=="string"&&e.trim().length>0){let n=e.trim();if(!/^[+-]?\d+(?:st|nd|rd|th)?$/i.test(n))throw new u(`${t} must be a finite integer.`,64);let s=Number.parseInt(n,10);if(!Number.isInteger(s))throw new u(`${t} must be a finite integer.`,64);return s}}function Ll(e){let t=p(e.args,"subcommand")??Y(e.options,"subcommand"),n=e.options;return Ai({subcommand:t,id:typeof e.id=="string"?e.id:typeof n.id=="string"?n.id:void 0,stepRef:Nl(e),reorderTo:Pl(n.reorderTo??e.args.reorderTo,"plan reorderTo"),options:e.options,global:e.global})}function Nl(e){return typeof e.options.stepRef=="string"?e.options.stepRef:typeof e.args.stepRef=="string"?e.args.stepRef:void 0}function Ml(e){let t=p(e.args,"subcommand")??Y(e.options,"subcommand"),n=e.args.alias??e.options.alias;return{ctx:e,subcommand:t.trim().toLowerCase(),name:p(e.args,"name")??p(e.options,"name"),author:p(e.args,"author")??p(e.options,"author"),force:e.args.force===!0||e.options.force===!0,aliases:n===void 0?void 0:P(n)}}function Dl(e){let{ctx:t,subcommand:n,name:s,author:o,force:r}=e,a=we({list:()=>ar(t.global),show:()=>cr(s,t.global),"show-status":()=>mr(s,t.global),"list-fields":()=>pr(t.global),"show-field":()=>ur(s,t.global),"remove-type":()=>or(s,{author:o,force:r},t.global),"remove-field":()=>lr(s,{author:o,force:r},t.global),"remove-status":()=>ir(s,{author:o,force:r},t.global),"apply-preset":()=>fr(p(t.args,"typePreset")??p(t.options,"typePreset"),{author:o,force:r},t.global)},n);return a?a():null}function jl(e){let{ctx:t,name:n,author:s,force:o,aliases:r}=e,i=t.args.commands??t.options.commands,a=t.args.requiredTypes??t.options.requiredTypes;return dr(n,{type:p(t.args,"fieldType")??p(t.options,"fieldType"),commands:i===void 0?void 0:P(i),description:p(t.args,"description")??p(t.options,"description"),cliFlag:p(t.args,"cliFlag")??p(t.options,"cliFlag"),alias:r,required:t.args.required===!0||t.options.required===!0,requiredOnCreate:t.args.requiredOnCreate===!0||t.options.requiredOnCreate===!0,allowUnset:!(t.args.allowUnset===!1||t.options.allowUnset===!1),requiredTypes:a===void 0?void 0:P(a),author:s,force:o},t.global)}function Gl(e){let{ctx:t,name:n,author:s,force:o,aliases:r}=e,i=t.args.role??t.options.role;return rr(n,{role:i===void 0?void 0:P(i),alias:r,description:p(t.args,"description")??p(t.options,"description"),order:O(t.args.order??t.options.order,"schema add-status order"),author:s,force:o},t.global)}function Ul(e){let{ctx:t,name:n,author:s,force:o,aliases:r}=e;return sr(n,{description:p(t.args,"description")??p(t.options,"description"),defaultStatus:p(t.args,"defaultStatus")??p(t.args,"default_status")??p(t.options,"defaultStatus")??p(t.options,"default_status"),folder:p(t.args,"folder")??p(t.options,"folder"),alias:r,author:s,force:o},t.global)}function ql(e){let{ctx:t,subcommand:n,name:s,author:o,force:r}=e,i=p(t.args,"to")??Y(t.options,"to"),a=p(t.args,"migrationId")??p(t.args,"migration_id")??p(t.options,"migrationId")??p(t.options,"migration_id"),c=p(t.args,"fieldTypeScope")??p(t.options,"fieldTypeScope")??p(t.args,"type")??p(t.options,"type"),d=n==="rename-type"?{kind:"rename-type",from:s??"",to:i}:n==="rename-field"?{kind:"rename-field",from:s??"",to:i,...c===void 0?{}:{type:c}}:{kind:"remap-status",from:s??"",to:i};return nr(d,{migrationId:a,dryRun:t.args.dryRun===!0||t.options.dryRun===!0,author:o,force:r},t.global)}function zl(e){let t=Ml(e),n=Dl(t);if(n!==null)return n;if(t.subcommand==="rename-type"||t.subcommand==="rename-field"||t.subcommand==="remap-status")return ql(t);if(t.subcommand==="add-field")return jl(t);if(t.subcommand==="add-status")return Gl(t);if(t.subcommand==="add-type")return e.args.infer===!0||e.options.infer===!0?_r({minCount:O(e.args.minCount??e.options.minCount,"schema infer minCount"),apply:e.args.apply===!0||e.options.apply===!0,author:t.author,force:t.force},e.global):Ul(t);throw new u(`Unknown pm schema subcommand "${t.subcommand}". Allowed: add-type, remove-type, add-status, remove-status, add-field, remove-field, rename-type, rename-field, remap-status, list-fields, show-field, apply-preset, list, show, show-status`,64)}function Hl(e){let t=p(e.args,"subcommand")??Y(e.options,"subcommand"),n=t.trim().toLowerCase(),s=p(e.args,"name")??p(e.options,"name"),r=we({list:()=>Ur(),show:()=>qr(s),lint:()=>zr(s),apply:()=>Hr(s,{dryRun:e.args.dryRun===!0||e.options.dryRun===!0,author:p(e.args,"author")??p(e.options,"author"),force:e.args.force===!0||e.options.force===!0},e.global)},n);if(!r)throw new u(`Unknown pm profile subcommand "${t}". Allowed: list, show, apply, lint`,64);return r()}function Vl(e){return pn(e.global,{storage:e.options.storage===!0,metadataCoverage:e.options.metadataCoverage===!0,fieldUtilization:e.options.fieldUtilization===!0,byAssignee:e.options.byAssignee===!0,byTag:e.options.byTag===!0,byPriority:e.options.byPriority===!0,tagPrefix:typeof e.options.tagPrefix=="string"?e.options.tagPrefix:void 0})}async function Bl(e){let{changedFields:t,idOnly:n,runnerOptions:s}=W(e.args,e.options);return J(await Ho(E(e,s),s,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}async function Wl(e){let{changedFields:t,runnerOptions:n}=W(e.args,e.options);return J(await er(Xn(n),e.global),{changedFields:t})}async function Yl(e){let{changedFields:t,runnerOptions:n}=W(e.args,e.options),s=p(e.args,"reason"),o=s!==void 0&&n.reason===void 0?{...n,reason:s}:{...n};return e.force&&o.force===void 0&&(o.force=!0),J(await Ko(Kn(o),e.global),{changedFields:t})}async function Jl(e){let{changedFields:t,idOnly:n,runnerOptions:s}=W(e.args,e.options),o=p(s,"target")??Y(e.args,"target");return J(await tn(E(e,s),o,s,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}function wa(e){let t={...e};return delete t.assignee,t}async function Kl(e){let t=$(process.cwd(),e.global.path),n=await D(t),s=ei(re(n.schema)),o=E(e),r=await en(o,e.force,e.global,e.options),i=await fe(o,{...wa(e.options),status:s,force:e.force},e.global);return{id:o,action:"start_task",claim:r,update:i}}async function Xl(e){let t=$(process.cwd(),e.global.path),n=await D(t),s=E(e),o=re(n.schema).open_status,r=await fe(s,{...wa(e.options),status:o,force:e.force},e.global),i=await Be(s,e.force,e.global,e.options);return{id:s,action:"pause_task",update:r,release:i}}async function Zl(e){let t=E(e),n=p(e.args,"reason")??p(e.args,"text")??p(e.options,"reason")??p(e.options,"text"),s=await We(t,n,{...e.options,force:e.force},e.global),o=await Be(t,e.force,e.global,e.options);return{id:t,action:"close_task",close:s,release:o}}function Ql(e){let t={...e.args,...e.options};return Jr(Y(t,"subcommand"),p(t,"id")??e.id,p(t,"target"),Ni(t),e.global)}function ep(e){let t={...e.args,...e.options},n=P(t.historyEvent).map(s=>{let o=s.lastIndexOf(":");return{item_id:s.slice(0,o).trim(),line:Number(s.slice(o+1))}});return yr($(process.cwd(),e.global.path),{events:n,all_actionable:t.allActionable===!0||t.all_actionable===!0,attributed_author:p(t,"attributedAuthor")??p(t,"attributed_author")??"",reviewer:p(t,"reviewer")??"",reason:p(t,"reason")??""})}var va={init:e=>Ir(p(e.args,"prefix"),e.global,e.options),context:e=>Zt(ue("context",e.options),e.global),next:e=>Qt(ue("next",e.options),e.global),eval:Mi,events:Di,merge:ji,workspace:Gi,meet:at,event:at,remind:at,list:vl,get:e=>rn(E(e),e.global,ue("get",e.options)),search:kl,duplicates:e=>{let t=typeof e.options.status=="string"?[e.options.status]:P(e.options.status);return un(e.global,{...t.length===0?{}:{status:t},since:p(e.options,"since"),threshold:typeof e.options.threshold=="number"?e.options.threshold:void 0,limit:e.options.limit==="default"?void 0:O(e.options.limit,"limit")})},create:Sl,copy:xl,focus:e=>on(e.id,{clear:e.options.clear===!0||e.args.clear===!0},e.global),update:El,restore:Jl,claim:e=>e.options.next===!0||e.args.next===!0?Jo(e.force,e.global,{...e.options,...e.args},{...e.options,...e.args}):en(E(e),e.force,e.global,e.options),release:e=>Be(E(e),e.force,e.global,e.options),"start-task":Kl,"pause-task":Xl,"close-task":Zl,close:Al,comments:Il,notes:e=>fi(E(e),e.options,e.global),learnings:e=>Qo(E(e),e.options,e.global),files:Rl,docs:e=>xr(E(e),rt(e.options),e.global),test:e=>Zr(E(e),e.options,e.global),"test-all":e=>Qr(e.options,e.global),telemetry:Cl,validate:e=>Je(e.options,e.global,{runUpdate:(t,n,s)=>fe(t,n,s)}),health:Ol,contracts:e=>ln(e.options,e.global),config:$l,activity:Fl,aggregate:e=>Xt(e.options,e.global),extension:e=>Ye(ft(e),e.options,e.global),package:e=>Ye(ft(e),e.options,e.global),install:e=>Ye(ft(e),{...e.options,install:!0},e.global),upgrade:e=>hr(ft(e),e.options,e.global),delete:e=>sn(E(e),e.options,e.global),deps:e=>Yr(E(e),e.options,e.global),graph:Ql,"files-discover":e=>cn(E(e),e.options,e.global),"files-lookup":e=>an({paths:P(e.options.paths),scope:e.options.scope==="project"||e.options.scope==="global"?e.options.scope:void 0,limit:O(e.options.limit,"files lookup limit"),offset:O(e.options.offset,"files lookup offset"),noTruncate:e.options.noTruncate===!0,strictRead:e.options.strictRead===!0},e.global),history:e=>Zo(E(e),e.options,e.global),"history-redact":e=>jo(E(e),e.options,e.global),"history-repair":Ui,"history-compact":qi,"history-author-acknowledge":ep,plan:Ll,schema:zl,profile:Hl,stats:Vl,append:Bl,"update-many":Wl,"close-many":Yl,gc:e=>gr(e.global,e.options)};function _y(e=Us){return e.map(t=>{let n=se(t),s=we(hn,n),o=s?.action??n,r=we(va,o)!==void 0;return{action:t,resolved_action:o,covered:r,route:r?s?"alias":"native":"missing"}})}async function ha(e,t,n,s){let o=Bn(t,e);Ms(e,o);let r={action:e,args:t,options:o,id:p(t,"id"),force:t.force===!0||o.force===!0,global:n,activeExtensions:s},i=we(va,e),a=i?await i(r):await _l(e,t,o,n,s);return js(e,o,a)}var tp={closeManyOptionsFromFlat:Kn,extensionOptionsFromArgs:Jn,globalOptions:st,mutationListOptions:Fe,normalizeActionName:se,normalizeCommandPath:Yn,normalizeMcpUpdateOptions:it,normalizeMcpOptionsArrays:ot,optionsWithAuthor:Bn,readRequiredString:Y,readScalarString:x,readScalarStringAllowBlank:Vn,readStringArray:P,updateManyOptionsFromFlat:Xn,withAddNoteOption:rt,withFilesDiscoveryOptions:Wn,withMutationCompaction:W};(process.env.NODE_ENV==="test"||process.env.VITEST!==void 0||process.env.VITEST_WORKER_ID!==void 0)&&(globalThis.__pmCliActionRunnerTestHooks=tp);async function np(e,t,n){let s=await Et({pmRoot:e,settings:t,cwd:n??process.cwd(),noExtensions:!1}),o=await It(s);try{return o.registrations}finally{try{await At(s,o)}catch{}}}export{ci as a,Ca as b,gn as c,Te as d,et as e,pi as f,mp as g,dp as h,lp as i,pp as j,up as k,ni as l,fp as m,xa as n,_n as o,kn as p,ui as q,Ga as r,qa as s,za as t,Sn as u,fi as v,Zp as w,_i as x,Rn as y,Ai as z,Ii as A,Ri as B,jc as C,Gc as D,Ci as E,Oi as F,$i as G,Fi as H,Pi as I,$e as J,mm as K,dm as L,lm as M,T as N,pm as O,um as P,fm as Q,_m as R,Qn as S,zi as T,ge as U,Zn as V,Hi as W,hm as X,Vi as Y,gm as Z,ym as _,bm as $,wm as aa,vm as ba,Rm as ca,Ji as da,Cm as ea,Nm as fa,zm as ga,Vm as ha,Gd as ia,ll as ja,y as ka,Uh as la,qh as ma,zh as na,Hh as oa,Vh as pa,Bh as qa,Wh as ra,Yh as sa,Jh as ta,Kh as ua,Xh as va,Zh as wa,Qh as xa,eg as ya,tg as za,ng as Aa,sg as Ba,og as Ca,rg as Da,ig as Ea,ag as Fa,cg as Ga,mg as Ha,dg as Ia,lg as Ja,pg as Ka,ug as La,fg as Ma,_g as Na,hg as Oa,gg as Pa,yg as Qa,bg as Ra,wg as Sa,vg as Ta,kg as Ua,Sg as Va,xg as Wa,Eg as Xa,Ag as Ya,Ig as Za,Rg as _a,Cg as $a,Tg as ab,Og as bb,$g as cb,Fg as db,Pg as eb,Lg as fb,Ng as gb,Mg as hb,Dg as ib,jg as jb,Gg as kb,Ug as lb,qg as mb,zg as nb,Hg as ob,Vg as pb,Bg as qb,Wg as rb,Yg as sb,Jg as tb,Kg as ub,Xg as vb,Zg as wb,Qg as xb,ey as yb,ty as zb,ny as Ab,sy as Bb,oy as Cb,ry as Db,iy as Eb,ay as Fb,cy as Gb,my as Hb,dy as Ib,ly as Jb,py as Kb,uy as Lb,Y as Mb,fy as Nb,wl as Ob,_y as Pb};
|
|
2005
|
-
//# sourceMappingURL=chunk-
|
|
2005
|
+
//# sourceMappingURL=chunk-UN66FZRO.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{E as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{E as i}from"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5b7b3eaf-a792-5f44-9981-8c82ce511070")}catch{}})();function M(e,n){let t=e.trim().toLowerCase();return n.alias_to_id.get(t)??t}function B(e){return{isTerminal(n){return e.terminal_statuses.has(M(n,e))},classify(n){let t=M(n,e);return e.terminal_canceled_statuses.has(t)?"canceled":e.terminal_statuses.has(t)?"closed":e.blocked_statuses.has(t)?"blocked":e.draft_statuses.has(t)?"draft":t===e.open_status?"open":e.active_statuses.has(t)?"in_progress":"other"}}}function p(e){return i(e.acceptance_criteria)===void 0}function d(e){return!Number.isFinite(e.estimated_minutes)}function m(e,n){return n.isTerminal(e.status)?i(e.resolution)===void 0:!1}function x(e){return i(e.reviewer)===void 0}function k(e){return i(e.risk)===void 0}function w(e){return typeof e.confidence=="number"?!Number.isFinite(e.confidence):i(e.confidence)===void 0}function v(e){return i(e.sprint)===void 0}function E(e){return i(e.release)===void 0}function R(e){return!!(e.acMissing||e.estimatesMissing||e.resolutionMissing||e.reviewerMissing||e.riskMissing||e.confidenceMissing||e.sprintMissing||e.releaseMissing||e.metadataMissing)}function C(e,n,t){return[[n.acMissing,p(e)],[n.estimatesMissing,d(e)],[n.resolutionMissing,m(e,t)],[n.reviewerMissing,x(e)],[n.riskMissing,k(e)],[n.confidenceMissing,w(e)],[n.sprintMissing,v(e)],[n.releaseMissing,E(e)]].every(([s,o])=>s!==!0||o)}function F(e,n){return p(e)||d(e)||m(e,n)}function U(e,n,t){return R(n)?!(!C(e,n,t)||n.metadataMissing&&!F(e,t)):!0}var g=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function A(e,n){switch(n){case"acceptance_criteria":return!p(e);case"estimated_minutes":return!d(e);case"resolution":return i(e.resolution)!==void 0;case"tags":return Array.isArray(e.tags)&&e.tags.length>0;default:return i(e.parent)!==void 0}}function D(e,n,t){return n==="resolution"?t.isTerminal(e.status):!0}function I(e,n){return n===0?100:Math.round(e/n*1e3)/10}function b(){let e={};for(let n of g)e[n]={present:0,applicable:0,percent:100};return e}function _(e,n,t){for(let r of g){if(!D(n,r,t))continue;let s=e[r];s.applicable+=1,A(n,r)&&(s.present+=1)}}function h(e){for(let n of g){let t=e[n];t.percent=I(t.present,t.applicable)}}function G(e,n){let t=b(),r={};for(let s of e){_(t,s,n);let o=r[s.type]??(r[s.type]=b());_(o,s,n)}h(t);for(let s of Object.values(r))h(s);return{overall:t,by_type:r}}var L={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function T(e){return L[e]}function P(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function O(e,n,t){switch(n){case"assignee":return[i(e.assignee)??null];case"parent":return[i(e.parent)??null];case"type":return[i(e.type)??null];case"status":return[i(e.status)??null];case"priority":return[typeof e.priority=="number"?`P${e.priority}`:null];default:{let r=t.tagPrefix?.trim(),o=(Array.isArray(e.tags)?e.tags:[]).filter(c=>typeof c=="string"&&c.length>0&&(!r||c.startsWith(r)));return o.length>0?o:[null]}}}function K(e,n,t,r={}){let s=new Map,o=0;for(let a of e){o+=1;let u=t.classify(a.status);for(let l of O(a,n,r)){let y=l??"\0empty",f=s.get(y);f||(f={label:l??T(n),key:l,buckets:P(),total:0},s.set(y,f)),f.buckets[u]+=1,f.total+=1}}let c=[...s.values()].sort((a,u)=>u.total!==a.total?u.total-a.total:a.key===null?1:u.key===null?-1:a.label.localeCompare(u.label));return{dimension:n,rows:c,total_items:o}}export{B as a,R as b,U as c,G as d,K as e};
|
|
2
|
+
//# sourceMappingURL=chunk-UP7DTVMD.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as _,l as Q,m as Y,o as ee,p as te}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{h as _,l as Q,m as Y,o as ee,p as te}from"./chunk-4VN6GS4U.js";import{A as m,Af as D,C as h,Da as P,Df as G,If as V,La as T,Lf as H,Ma as $,Mf as X,Nf as B,Oa as L,Sf as J,Y as E,b as I,lc as z,xc as W,zd as Z}from"./chunk-GE4KCSZP.js";import oe from"node:fs/promises";import p from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5e45d0f1-a1a7-50ea-a9a3-ec6283d3471d")}catch{}})();var ne=32768;function b(e){return _(p.normalize(e))}async function v(e){try{return await oe.realpath(e)}catch{return p.resolve(e)}}function g(e,t){let c=p.isAbsolute(e.path)?p.resolve(e.path):p.resolve(t,e.path);return`${b(c)}::${e.scope}`}function R(e,t,c){if(typeof e=="string"){let n=e.trim();n.length>0&&c.push({field:t,value:n});return}if(Array.isArray(e)){e.forEach((n,s)=>R(n,`${t}[${s}]`,c));return}if(typeof e=="object"&&e!==null)for(let[n,s]of Object.entries(e))R(s,t?`${t}.${n}`:n,c)}function se(e){let t=[];return R(e.metadata,"metadata",t),R(e.body,"body",t),t}function ae(e){let t=e.trim();return t=t.replace(/^[`"'<([{]+/u,""),t=t.replace(/[`"'>)\]},;!?]+$/u,""),t=t.replace(/[.]+$/u,""),t=t.replace(/:(?:\d+)(?::\d+)?$/u,""),t=t.replace(/[.]+$/u,""),t}function ie(e){let t=[],c=/(?:[A-Za-z]:[\\/]|\/)[^\s"'`<>()[\]{},;]+/gu,n=/(?:\.{1,2}[\\/])?(?:(?:[A-Za-z0-9_.@-]+[\\/])+[A-Za-z0-9_.@-]+|[A-Za-z0-9_.@-]+\.[A-Za-z0-9][A-Za-z0-9._-]*)/gu;for(let s of e){let l=new Set,a=s.value.slice(0,ne);for(let[i,r]of[[c,s.value],[n,a]]){i.lastIndex=0;for(let o of r.matchAll(i)){let d=ae(o[0]);!d||l.has(d)||(l.add(d),t.push({field:s.field,value:d}))}}}return t}async function re(e,t,c=t){let n=p.isAbsolute(e)?p.resolve(e):p.resolve(c,e),s;try{s=await oe.stat(n)}catch{return}if(!s.isFile())return;let[l,a]=await Promise.all([v(t),v(n)]);if(E(l,a)){let i=p.relative(l,a);return!i||i.startsWith("..")||p.isAbsolute(i)?void 0:{path:b(i),scope:"project"}}return{path:b(n),scope:"global"}}async function ce(e,t,c=t){let n=new Set((e.metadata.files??[]).map(r=>g(r,t))),s=new Map,l=ie(se(e)),a=new Map;await Promise.all([...new Set(l.map(r=>r.value))].map(async r=>{a.set(r,await re(r,t,c))}));let i=l.map(r=>({reference:r,resolved:a.get(r.value)}));for(let{reference:r,resolved:o}of i){if(!o)continue;let d=g(o,t),f=s.get(d)??{path:o.path,scope:o.scope,sourceFields:new Set,originalPaths:new Set,sourceCount:0};f.sourceFields.add(r.field),f.originalPaths.add(r.value),f.sourceCount+=1,s.set(d,f)}return[...s.entries()].map(([r,o])=>({path:o.path,scope:o.scope,status:n.has(r)?"already_linked":"addable",source_count:o.sourceCount,source_fields:[...o.sourceFields].sort((d,f)=>d.localeCompare(f)),original_paths:[...o.originalPaths].sort((d,f)=>d.localeCompare(f))})).sort((r,o)=>{let d=r.status.localeCompare(o.status);if(d!==0)return d;let f=r.path.localeCompare(o.path);return f!==0?f:r.scope.localeCompare(o.scope)})}var $e={relativeReferenceScanMaxChars:ne,normalizeCandidatePathForOutput:b,realpathForContainment:v,linkedFileResolvedKey:g,collectTextReferences:R,collectItemTextReferences:se,cleanupPathToken:ae,extractRawPathReferences:ie,resolveDiscoveredFile:re,discoverReferencedFiles:ce};async function Le(e,t,c){let n=await ee(e,t,c,{metadataKey:"files",op:"files_add",bareNoun:"file",supportsAppendStable:!0});return te(n,"files")}async function me(e,t){let c=await v(t),n=await Promise.all(e.map(async l=>{let a=l.trim();if(!a)throw new h("Files lookup paths must not be empty.",m.USAGE);if(!p.isAbsolute(a))return _(a);let i=await v(a);return E(c,i)?_(p.relative(c,i)):_(i)})),s=[...new Set(n)].sort((l,a)=>l.localeCompare(a));if(s.length===0)throw new h("Files lookup requires at least one path.",m.USAGE);return s}function he(e){for(let[n,s]of[["limit",e.limit],["offset",e.offset]])if(s!==void 0&&(!Number.isInteger(s)||s<0))throw new h(`Files lookup ${n} must be a non-negative integer.`,m.USAGE);let{offset:t=0,limit:c=50}=e;return{offset:Math.max(0,Math.floor(t)),limit:e.noTruncate?void 0:Math.max(0,Math.floor(c))}}function le(e){return{id:e.id,title:e.title,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}async function ge(e){if([e.strictRead,e.noTruncate,W()].includes(!0))return null;let t=await V(e.pmRoot,[...new Set(Object.values(e.typeToFolder))]);return t?G({pmRoot:e.pmRoot,expectedSourceCursor:t.source_cursor,paths:e.paths,scope:e.scope,limit:e.limit,offset:e.offset}):null}async function ye(e){let t=[],n=(await B(e.pmRoot,e.settings.item_format,e.typeToFolder,t,e.settings.schema)).map(a=>({item:a,files:(a.files??[]).filter(i=>e.paths.includes(_(i.path))&&(e.scope===void 0||i.scope===e.scope)).sort((i,r)=>{let o=i.path.localeCompare(r.path);return o===0?i.scope.localeCompare(r.scope):o})})).filter(a=>a.files.length>0).sort((a,i)=>{let r=a.item.priority-i.item.priority;if(r!==0)return r;let o=i.item.updated_at.localeCompare(a.item.updated_at);return o===0?a.item.id.localeCompare(i.item.id):o}),s=t.filter(a=>/^item_list_(?:item|directory)_read_failed:/u.test(a));if(e.strictRead&&s.length>0)throw new h(`Files lookup could not read every item: ${s.join("; ")}`,m.GENERIC_FAILURE);let l=n.slice(e.offset,e.limit===void 0?void 0:e.offset+e.limit);return{paths:e.paths,total:n.length,count:l.length,offset:e.offset,limit:e.limit??null,has_more:e.offset+l.length<n.length,truncated:e.offset+l.length<n.length,completeness:{status:s.length===0?"complete":"partial",source:"source_scan"},warnings:t,matches:l.map(a=>({item:le(a.item),files:a.files}))}}async function ze(e,t){let c=T(process.cwd(),t.path),n=$(c);if(!await I(L(c)))throw new h(`Tracker is not initialized at ${c}. Run pm init first.`,m.NOT_FOUND);let s=await me(e.paths,n),l=await D(c),a=P(l,z()),{offset:i,limit:r}=he(e),o=await ge({pmRoot:c,typeToFolder:a.type_to_folder,paths:s,scope:e.scope,limit:r,offset:i,strictRead:e.strictRead===!0,noTruncate:e.noTruncate===!0});return o?{paths:s,total:o.total,count:o.matches.length,offset:i,limit:r,has_more:i+o.matches.length<o.total,truncated:i+o.matches.length<o.total,completeness:{status:"unchecked",source:"index"},warnings:[],matches:o.matches.map(d=>({item:le(d.item),files:d.files}))}:ye({pmRoot:c,settings:l,typeToFolder:a.type_to_folder,paths:s,scope:e.scope,limit:r,offset:i,strictRead:e.strictRead===!0})}async function De(e,t,c){let n=T(process.cwd(),c.path),s=$(n);if(!await I(L(n)))throw new h(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let l=await D(n),a=P(l,z()),i=await H(n,e,l.id_prefix,l.item_format,a.type_to_folder);if(!i)throw new h(`Item ${e} not found`,m.NOT_FOUND);let r=await X(i,{schema:l.schema}),o=await ce(r.document,s,process.cwd()),d=o.filter(u=>u.status==="addable"),f=o.filter(u=>u.status==="already_linked"),O=t.apply===!0,de=t.note?.trim()||"discovered from item text";if(!O||d.length===0){let u=r.document.metadata.files??[];return{id:i.id,files:u,changed:!1,apply:O,count:u.length,candidate_count:o.length,addable_count:d.length,added_count:0,skipped_existing_count:f.length,candidates:o,added:[],skipped_existing:f}}let ue=Z(t.author,l.author_default),A=d.map(u=>({path:u.path,scope:u.scope,note:de})),y=[],x=new Set,M=await J({pmRoot:n,settings:l,id:e,op:"files_discover",author:ue,message:t.message??"Discover referenced file links",force:t.force,mutate(u){let w=[...u.metadata.files??[]],U=new Set(w.map(S=>g(S,s)));y=[],x.clear();for(let[S,C]of A.entries()){let q=g(C,s);U.has(q)||(w.push(C),U.add(q),y.push(C),x.add(S))}let j=Y(w),K=t.appendStable?j:Q(j);return K.length>0?u.metadata.files=K:delete u.metadata.files,{changedFields:y.length>0?["files"]:[],warnings:y.length!==A.length?[`files_discover_skipped_existing:${A.length-y.length}`]:[]}}}),k=M.item.files??[],fe=new Set(y.map(u=>g(u,s))),F=k.filter(u=>fe.has(g(u,s))),pe=d.filter((u,w)=>!x.has(w)),N=[...f,...pe];return{id:M.item.id,files:k,changed:F.length>0,apply:!0,count:k.length,candidate_count:o.length,addable_count:d.length,added_count:F.length,skipped_existing_count:N.length,candidates:o,added:F,skipped_existing:N}}export{$e as a,Le as b,ze as c,De as d};
|
|
2
|
+
//# sourceMappingURL=chunk-UZBWIUYD.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as m,d as p,g as w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as m,d as p,g as w}from"./chunk-54FNT7U2.js";import{i as f}from"./chunk-42E7YPLG.js";import{A as i,C as s}from"./chunk-GE4KCSZP.js";import{readFile as y}from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="500e83b0-28a8-58b1-a625-2d81eb245eb4")}catch{}})();async function c(e,t){let d=e.add!==void 0,a=e.stdin===!0,o=typeof e.file=="string",l=Number(d)+Number(a)+Number(o);if(l===0)return;if(l>1)throw new s("Specify comment text using only one input source: --add, --stdin, or --file",i.USAGE);if(d)return{value:await t.resolveValue(e.add,"--add")??"",emptyFlag:"--add"};if(a)return{value:await t.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};let n=e.file.trim();if(!n)throw new s("--file path cannot be empty",i.USAGE);try{return{value:await y(n,"utf8"),emptyFlag:"--file"}}catch(r){if(p(r)&&r.code==="ENOENT")throw new s(`--file path not found: ${n}`,i.USAGE);let u=r instanceof Error?r.message:String(r);throw new s(`Failed to read --file path "${n}": ${u}`,i.USAGE)}}async function h(e,t){let d=e.edit,a=e.delete,o=d!==void 0,l=a!==void 0;if(o&&l)throw new s("Specify only one of --edit or --delete",i.USAGE);if(d!==void 0&&(!Number.isInteger(d)||d<1))throw new s("--edit must be a positive integer",i.USAGE);if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new s("--delete must be a positive integer",i.USAGE);if(l){if(await c(e,t)!==void 0)throw new s("--delete does not take comment text",i.USAGE);return{mode:"delete",index:a}}if(o){let u=await c(e,t);if(u===void 0)throw new s("--edit requires replacement text via positional [text], --add, --stdin, or --file",i.USAGE);return{mode:"edit",index:d,value:u.value,emptyFlag:u.emptyFlag}}let n=await c(e,t);return n===void 0?{mode:"list"}:{mode:n.emptyFlag==="--add"?"add":n.emptyFlag==="--stdin"?"stdin":"file",value:n.value,emptyFlag:n.emptyFlag}}async function x(e,t,d){let a=f(),o=await h(t,a),l=o.mode==="add"||o.mode==="edit",n=o.value??"";return w(e,t,d,{input:{...o,rawValue:t.add??n,value:l?m(n,{stripPlainTextPrefix:!0}):n},collectionKey:"comments",op:"comment_add",editOp:"comment_edit",deleteOp:"comment_delete",parseText:r=>r,createEntry:r=>r,bypassOwnershipConflict:!!(o.mode==="add"&&t.ownershipAppendBypass),conflictGuidance:{required:"For an approved append-only handoff on another owner's item, use the package-provided ownership bypass before considering --force.",examples:['pm comments pm-a1b2 --add "review note" --author "reviewer" --force'],nextSteps:["Use an installed package's narrow append-only ownership bypass when available.","Use --force only when an ownership override is explicitly approved."]}})}export{x as a};
|
|
2
|
+
//# sourceMappingURL=chunk-V3774P7D.js.map
|