@unbrained/pm-cli 2026.8.5 → 2026.8.7
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 +44 -0
- package/dist/cli/main.js +14 -37
- package/dist/cli/register-operations.js +11 -2
- package/dist/cli/register-setup.d.ts +1 -1
- package/dist/cli/register-setup.js +46 -20
- package/dist/cli/stats-analytics-json.d.ts +9 -0
- package/dist/cli/stats-analytics-json.js +69 -0
- package/dist/cli-bundle/bundle-manifest.json +403 -403
- package/dist/cli-bundle/chunks/append-7BXBFDGD.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-PMXJEU3F.js → chunk-2AXF3VSK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MHK6LIWE.js → chunk-2XS43CCV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-3A6KWB72.js +8 -0
- package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-45G53IU4.js → chunk-4MTI7XOV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7C4PTJG6.js → chunk-6BX5UDCN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YUBDMQM.js → chunk-6QPO7KLR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HWRRMBJO.js → chunk-7MXHZHSQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3FTILRJ2.js → chunk-7ZPMJW4U.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2WFXWAYX.js → chunk-AGYNSNCI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-43HQQI6S.js → chunk-B4KLBBMN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VCKLFEUN.js → chunk-CALJHNBL.js} +12 -12
- package/dist/cli-bundle/chunks/{chunk-CSI3WS5I.js → chunk-CFIGP5LY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V3EUXXOF.js → chunk-CS6MRHG7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YSO3YFZ4.js → chunk-CUGNQQKH.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +164 -0
- package/dist/cli-bundle/chunks/{chunk-BXQLRKWF.js → chunk-H5Y5YE6A.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-54FNT7U2.js → chunk-H5Y6UV6E.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UP7DTVMD.js → chunk-H7KGWPDF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-E2RKBKWB.js → chunk-HFSD77TQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V3774P7D.js → chunk-HX2GTA6L.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UZBWIUYD.js → chunk-J2IEKAVR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HNFD72UK.js → chunk-K44PYFXH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5ZBOIPGP.js → chunk-K4KGEEBT.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +21 -0
- package/dist/cli-bundle/chunks/{chunk-OMXVBQ2N.js → chunk-KL6IEBV2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7A5OT5J2.js → chunk-KWQZDZSS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-M72BKL5Q.js → chunk-KZ4X3DGU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +13 -0
- package/dist/cli-bundle/chunks/{chunk-VN5VITU3.js → chunk-ME2JJ4LA.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-A62CYISG.js → chunk-NG6OXIBR.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-42E7YPLG.js → chunk-NYIGHWQY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RKAVWO3O.js → chunk-NZ75GNSA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DXDREUXT.js → chunk-PCJWJNC2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZYHOB3SN.js → chunk-PD3225AM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OTHLDSFP.js → chunk-PDEGKG7P.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +2 -0
- package/dist/cli-bundle/chunks/chunk-PW2H7YJR.js +56 -0
- package/dist/cli-bundle/chunks/{chunk-L3AZOELJ.js → chunk-TPKN3S7S.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LKDGK44W.js → chunk-TPXAXTCO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-R546TPDE.js → chunk-UQLZQVFW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BPELKUQD.js → chunk-VT3Z5G7D.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WOD3WWUN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-4VN6GS4U.js → chunk-WSJEIGJF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UN66FZRO.js → chunk-WYNUU7ZW.js} +49 -46
- package/dist/cli-bundle/chunks/{chunk-NY4T3JWN.js → chunk-YGPNCCXZ.js} +2 -2
- package/dist/cli-bundle/chunks/close-CMY3BAUG.js +2 -0
- package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +2 -0
- package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +2 -0
- package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +2 -0
- package/dist/cli-bundle/chunks/{create-XLKTXTUF.js → create-I5DVV4YG.js} +2 -2
- package/dist/cli-bundle/chunks/delete-RL3JACSW.js +2 -0
- package/dist/cli-bundle/chunks/{deps-ITTY3GIC.js → deps-S7UBCECS.js} +2 -2
- package/dist/cli-bundle/chunks/{docs-W4OSRTYR.js → docs-ZZNVBBYO.js} +2 -2
- package/dist/cli-bundle/chunks/{files-EOK4AZI4.js → files-27C337VT.js} +2 -2
- package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +2 -0
- package/dist/cli-bundle/chunks/{history-compact-7UGTMLL3.js → history-compact-HJQK67CZ.js} +2 -2
- package/dist/cli-bundle/chunks/{history-redact-4DZRMD6Z.js → history-redact-PWC6PDWA.js} +2 -2
- package/dist/cli-bundle/chunks/{history-repair-UPOSZW5R.js → history-repair-N3CY4WBF.js} +2 -2
- package/dist/cli-bundle/chunks/{learnings-GMRNCBS3.js → learnings-4FH23XDT.js} +2 -2
- package/dist/cli-bundle/chunks/{profile-2MUUMHRE.js → profile-5Y5XXH5N.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-LR3SQ5ZF.js → register-list-query-FJZCJ67O.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-SUOHFVWM.js → register-mutation-YGYPW3BL.js} +3 -3
- package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-DL7FFABC.js +2 -0
- package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +2 -0
- package/dist/cli-bundle/chunks/{schema-FJ4EA3XF.js → schema-EQGKBYXJ.js} +2 -2
- package/dist/cli-bundle/chunks/update-QVTYOD6I.js +2 -0
- package/dist/cli-bundle/chunks/update-many-DJSBU525.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-MJ7HWSFK.js → chunk-2ECLECMK.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-A7BJ5SS6.js → chunk-3K4XV2BF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PIMMYG7Q.js → chunk-4EX25PXM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-4VJQTS3P.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-73JUDYXT.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-WVIVUWVL.js → chunk-CIXVQPB7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-DLTS3IHM.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-FGKY4MBE.js → chunk-DQ6FKGL3.js} +10 -10
- package/dist/cli-bundle/focused-chunks/{chunk-QVHKCI4T.js → chunk-HNL6IFGS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-G6ETT4QK.js → chunk-MHMTKV5V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7J5TUBUJ.js → chunk-MOTJFQ3F.js} +22 -22
- package/dist/cli-bundle/focused-chunks/{chunk-UIL2M2NA.js → chunk-NBJKQP4S.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RUR5I3TK.js → chunk-QHRTT7WT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-B7LJWAZE.js → chunk-R2LEMEV5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SV3O7TSH.js → chunk-RPNYG5MO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-RW5IYD4J.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-TIKDBG4D.js +29 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IPWSFADF.js → chunk-VZFU2R4M.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WEM2E2PE.js → chunk-YZEZAPJK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +2 -0
- package/dist/cli-bundle/main.js +13 -13
- 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 +29 -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/activation-summary.d.ts +4 -0
- package/dist/core/extensions/activation-summary.js +5 -2
- package/dist/core/extensions/contribution-inventory.d.ts +1 -0
- package/dist/core/extensions/contribution-inventory.js +35 -2
- package/dist/core/extensions/extension-hook-runtime.js +5 -3
- package/dist/core/extensions/extension-types.d.ts +18 -1
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/loader.js +5 -13
- package/dist/core/extensions/preflight-ownership.d.ts +5 -0
- package/dist/core/extensions/preflight-ownership.js +42 -0
- package/dist/core/extensions/reserved-host-flags.js +3 -2
- package/dist/core/history/workspace-history.d.ts +22 -2
- package/dist/core/history/workspace-history.js +60 -36
- package/dist/core/output/output.d.ts +2 -0
- package/dist/core/output/output.js +3 -2
- package/dist/core/shared/command-types.d.ts +2 -0
- package/dist/core/shared/command-types.js +2 -2
- package/dist/mcp/tool-definitions.js +6 -2
- package/dist/sdk/author-attribution.js +23 -7
- package/dist/sdk/cli-bootstrap.d.ts +2 -0
- package/dist/sdk/cli-bootstrap.js +7 -2
- package/dist/sdk/cli-contracts/completeness.js +51 -4
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
- package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +16 -9
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +116 -10
- package/dist/sdk/cli-contracts/tool-schema.js +18 -2
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +3 -3
- package/dist/sdk/cli-program.js +3 -2
- package/dist/sdk/completion.js +5 -2
- package/dist/sdk/compose.d.ts +2 -2
- package/dist/sdk/compose.js +7 -2
- package/dist/sdk/contracts.d.ts +1 -0
- package/dist/sdk/contracts.js +2 -2
- package/dist/sdk/core.d.ts +3 -1
- package/dist/sdk/core.js +4 -3
- package/dist/sdk/define.d.ts +3 -1
- package/dist/sdk/define.js +3 -8
- package/dist/sdk/extension/install-sources.d.ts +43 -5
- package/dist/sdk/extension/install-sources.js +36 -2
- package/dist/sdk/extension/migrations.d.ts +114 -0
- package/dist/sdk/extension/migrations.js +175 -0
- package/dist/sdk/extension/scaffold.js +14 -9
- package/dist/sdk/extension/source-resolution.d.ts +50 -0
- package/dist/sdk/extension/source-resolution.js +66 -0
- package/dist/sdk/extension.d.ts +5 -1
- package/dist/sdk/extension.js +31 -35
- package/dist/sdk/generated-error-code-catalog.js +112 -2
- package/dist/sdk/governance/health.js +11 -2
- package/dist/sdk/history-analytics.d.ts +141 -0
- package/dist/sdk/history-analytics.js +283 -0
- package/dist/sdk/improvement-ledger-validation.d.ts +3 -0
- package/dist/sdk/improvement-ledger-validation.js +63 -0
- package/dist/sdk/improvement-ledger.d.ts +139 -0
- package/dist/sdk/improvement-ledger.js +261 -0
- package/dist/sdk/index.d.ts +11 -3
- package/dist/sdk/index.js +12 -4
- package/dist/sdk/lifecycle/plan.js +6 -3
- package/dist/sdk/merge/install.js +10 -2
- package/dist/sdk/package-migrations.d.ts +10 -0
- package/dist/sdk/package-migrations.js +21 -0
- package/dist/sdk/read-output-budget.js +24 -22
- package/dist/sdk/read-output-contracts.d.ts +10 -2
- package/dist/sdk/read-output-contracts.js +124 -65
- package/dist/sdk/read-output-rows.d.ts +29 -0
- package/dist/sdk/read-output-rows.js +100 -0
- package/dist/sdk/read-output-session.d.ts +69 -0
- package/dist/sdk/read-output-session.js +200 -0
- package/dist/sdk/runtime-input.d.ts +2 -0
- package/dist/sdk/runtime-input.js +14 -2
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +3 -3
- package/dist/sdk/runtime-stats-options.d.ts +9 -0
- package/dist/sdk/runtime-stats-options.js +38 -0
- package/dist/sdk/runtime.d.ts +3 -0
- package/dist/sdk/runtime.js +10 -27
- package/dist/sdk/stats.d.ts +40 -0
- package/dist/sdk/stats.js +112 -29
- package/docs/COMMANDS.md +9 -0
- package/docs/EXTENSIONS.md +2 -2
- package/docs/EXTENSION_LIFECYCLE.md +46 -0
- package/docs/IMPROVEMENT_ANALYTICS.md +103 -0
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +5 -5
- package/docs/README.md +2 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +60 -1
- package/docs/RELEASING.md +33 -20
- package/docs/SDK.md +31 -3
- package/marketplace.json +2 -2
- package/package.json +5 -5
- 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 +566 -815
- package/dist/cli-bundle/chunks/append-VXXGOXSG.js +0 -2
- package/dist/cli-bundle/chunks/chunk-6MSQJOTG.js +0 -13
- package/dist/cli-bundle/chunks/chunk-EGJ4JTUG.js +0 -55
- package/dist/cli-bundle/chunks/chunk-FPBQHMFT.js +0 -8
- package/dist/cli-bundle/chunks/chunk-GE4KCSZP.js +0 -164
- package/dist/cli-bundle/chunks/chunk-LN2WFEU4.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OPVH7SKD.js +0 -8
- package/dist/cli-bundle/chunks/chunk-Q35VBGOQ.js +0 -5
- package/dist/cli-bundle/chunks/chunk-SSF4PIUR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-WRL4KNDL.js +0 -20
- package/dist/cli-bundle/chunks/chunk-XCEZYMNI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-YEWNL576.js +0 -2
- package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +0 -2
- package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +0 -2
- package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +0 -2
- package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +0 -2
- package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +0 -2
- package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-ARRRKOVN.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-O6AYP6NP.js +0 -2
- package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +0 -2
- package/dist/cli-bundle/chunks/update-YHV52CSS.js +0 -2
- package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-BIMTMOS7.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-GJ2TG2CW.js +0 -28
- package/dist/cli-bundle/focused-chunks/chunk-N5XU5UVK.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-PG2RIZBX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VLYOEYML.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-W7BJEWHX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-Y4LDYLLT.js +0 -2
|
@@ -1,27 +1,27 @@
|
|
|
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
|
-
`);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
|
|
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(
|
|
1
|
+
import{b as Ke,c as Cr,d as Xe}from"./chunk-CS6MRHG7.js";import{B as Lr,Ba as Zr,C as Nr,Ca as Qr,D as Mr,Da as ei,E as Dr,F as jr,H as Gr,M as Kr,aa as ln,b as en,c as Jo,d as Be,f as gr,k as yr,l as Re,m as br,n as wr,o as vr,p as kr,q as Sr,sa as pn,ta as un,va as Xr,w as Je,x as $r,y as Fr,z as Pr}from"./chunk-KFLK5TRH.js";import{a as sn}from"./chunk-PCJWJNC2.js";import{a as Ho}from"./chunk-4MTI7XOV.js";import{r as Ur,s as qr,t as zr,u as Hr}from"./chunk-UQLZQVFW.js";import{a as Qo}from"./chunk-2XS43CCV.js";import{b as Er,c as an,d as cn}from"./chunk-J2IEKAVR.js";import{a as xr}from"./chunk-KL6IEBV2.js";import{a as er}from"./chunk-7ZPMJW4U.js";import{a as Vr,c as Br,d as Wr}from"./chunk-AGYNSNCI.js";import{a as Xo}from"./chunk-HX2GTA6L.js";import{a as Vo,c as Bo,e as Wo,g as Yo}from"./chunk-H5Y6UV6E.js";import{a as nn}from"./chunk-PDEGKG7P.js";import{a as on}from"./chunk-KWQZDZSS.js";import{a as fe}from"./chunk-ME2JJ4LA.js";import{a as hr,b as Ar}from"./chunk-6BX5UDCN.js";import{B as Ir,i as Ie,v as Ye}from"./chunk-PW2H7YJR.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-CALJHNBL.js";import{D as mn,F as Rr,W as Jr,b as Uo,e as Xt,g as Zo,m as rn}from"./chunk-B4H7FEFH.js";import{h as zo,ja as Zt,oa as Qt,ra as Tr}from"./chunk-LD77HJMQ.js";import{n as Yr}from"./chunk-TPXAXTCO.js";import{p as Or,r as dn}from"./chunk-3ISTDB42.js";import{b as ro,c as io,o as ao}from"./chunk-PIE5HBNA.js";import{P as Ae}from"./chunk-7MXHZHSQ.js";import{a as Ko}from"./chunk-CFIGP5LY.js";import{a as tn}from"./chunk-K44PYFXH.js";import{c as We}from"./chunk-2AXF3VSK.js";import{u as Kt}from"./chunk-NZ75GNSA.js";import{b as Go}from"./chunk-B4KLBBMN.js";import{i as jo}from"./chunk-PD3225AM.js";import{A as ho,Aa as Lo,Da as No,Ea as Ve,Fa as Mo,Ga as Do,Ja as S,T as go,U as yo,aa as bo,c as co,ca as wo,e as mo,f as He,g as lo,ja as vo,ka as ko,m as po,ma as So,pa as xo,qa as Eo,ra as Ao,sa as Io,ta as Ro,u as uo,ua as Co,v as fo,va as To,wa as Oo,x as _o,xa as $o,ya as Fo,za as Po}from"./chunk-WOD3WWUN.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-NG6OXIBR.js";import{a as zs}from"./chunk-K4KGEEBT.js";import{a as Jt}from"./chunk-A6KGKEWT.js";import{a as Ut}from"./chunk-NYIGHWQY.js";import{$ as ys,A as _,Bb as C,C as u,Ce as js,Da as ee,E as gs,Ea as bs,Ec as Ge,Gd as J,La as F,Le as Gs,N as ke,Nc as re,Ne as Us,Nf as D,Oa as U,Pc as Lt,Qc as Fs,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,Xf as Bs,Yf as qt,Zb as Is,Zf as zt,aa as yt,ad as Nt,b as G,ca as bt,cd as Mt,d as Q,dc as Rs,dd as Ue,dg as Ht,ec as Rt,f as gt,fc as Ct,g as ps,gc as Tt,gd as qe,hc as Ot,hd as Se,ic as $t,id as Dt,jb as je,jc as Ft,jf as jt,k as us,kc as Pt,kf as Gt,l as fs,lc as q,m as _s,mb as pe,n as hs,oe as Ms,sa as wt,sb as ws,ta as vt,tb as vs,ua as kt,ub as ks,uc as oe,uf as qs,va as St,vb as Ss,ve as Ds,vf as xe,wb as xs,xb as Es,yb as As,yc as Cs,ye as ue,yf as ie,zc as Ts,zd as z}from"./chunk-D4FPS43D.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),Aa=ni(Ve,io);import{AsyncLocalStorage as fl}from"node:async_hooks";import _a 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 Ia(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=Ia(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 Ra=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>=Ra){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 Ca={"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"},...Ca,...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 Ta(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 Oa(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,Ta(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 $a(e){return Object.freeze({...e,...e.payload===void 0?{}:{payload:Object.freeze(structuredClone(e.payload))}})}function Fa(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 Pa(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 La(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 Na(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 Fa(d,t,o,r),$a(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=La(t,this.version,this.#r),s=this.#e.get(n.relationshipId),o=Na(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=Pa(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}:{}}}},Ma="relationship-event-store",li=Ce.O_NOFOLLOW;function Ze(e){return ie(e,Ma,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
|
+
`);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 Da(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
|
+
`,"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(p=>[p.eventId,p])),d=[],m=[];for(let p of t){let f=p.eventId.trim(),g=c.get(f);if(g!==void 0){if(n.existingEventPolicy==="skip_identical"&&Da(g,p,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(p);c.set(w.eventId,w),d.push(w)}if(d.length>0){let p=i.length===0||i.endsWith(`
|
|
4
4
|
`)?i:`${i}
|
|
5
|
-
`;await bn(K.dirname(o),{recursive:!0}),await ae(this.#t,o),await Q(o,`${
|
|
5
|
+
`;await bn(K.dirname(o),{recursive:!0}),await ae(this.#t,o),await Q(o,`${p}${d.map(f=>JSON.stringify(f)).join(`
|
|
6
6
|
`)}
|
|
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(`
|
|
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 ja}from"node:fs/promises";import Ga 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 Ua(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)=>Ua(s,t,o))}async function qa(e){let t=Ga.join(e,kn),n;try{n=await ja(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 za(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 Ha(e){return e.flatMap(t=>{let n=za(t.module);return n===void 0?[]:ui(n,`package ${t.name}`)})}async function Va(e){let t=await qa(e.pmRoot),n=Ha(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function Sn(e,t){let n=await Va(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 Ba(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 Wa(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 Ya(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=Ba(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=Ya(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:Wa(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(),p=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(p,c):p,g=f.filter(w=>w.format==="json").length;return{...d,notes:f,count:f.length,...i?{total_count:p.length,returned_count:f.length,has_more:f.length<p.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]="5d3c68a6-0b40-56b5-ae9e-776e1830ed3e")}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 Ja(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 Ka(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 P(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 Xa(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 Za(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 Qa(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 ec(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 tc(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=Ka(t.completed,t.total),t}function nc(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 sc(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 oc(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 rc(e){return e.find(t=>t.status==="in_progress")??e.find(t=>t.status==="pending")}function ic(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=tc(n),o=rc(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:ic(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 ac(e){let t=F(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 cc(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 mc(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 dc(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 lc(e){let t=e.stepTitle?.trim()||void 0,n=bi(e.step),s=e.template?.trim()?Ja(e.template):[];return{repeatedStepTitles:n,stepTitleFlag:t,stepTitles:[...t?[t]:[],...n,...s.map(o=>o.title)],templateSteps:s}}function pc(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 uc(e,t){let n=Tn(e.stepStatus,"pending"),s=Ln(e,"depends_on"),o=P(e.file).map($n),r=P(e.test).map(Fn),i=P(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 fc(e){let t=lc(e),n=dc(e);if(pc(t,n),t.stepTitles.length===0)return{steps:[],hasPerStepDetailOptions:n};if(t.stepTitles.length===1)return{steps:[uc(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 _c(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=Xa(e.harness),i=e.fromSearch?.trim(),a=mc(e),{steps:c,hasPerStepDetailOptions:d}=fc(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,p=e.claim?z(e.author,n.settings.author_default):e.assignee?.trim()||void 0,f={...e,title:s,description:m,type:"Plan",template:void 0,file:P(e.file),test:P(e.test),doc:P(e.doc),field:P(e.field),assignee:z(e.author,n.settings.author_default),blockedBy:void 0,dep:cc(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:z(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")),p&&(v.metadata.assignee=p,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 hc(e,t,n){let s=Za(t.depth),o=Qa(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:ec(a,o),next_actions:N(i,a),warnings:[],generated_at:k()}}function gc(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=z(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(([p])=>p.startsWith("plan_")).map(([p,f])=>[p,JSON.stringify(f)])),c=e.mutator(i,o);n=c.resultStep;let d=i.slice().sort((p,f)=>p.order-f.order).map((p,f)=>({...p,order:f+1}));o.metadata.plan_steps=d;let m=gc(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 yc(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 p=m.length+1;xi(m,void 0,o,r);let f=bc(m,t,{order:p,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 bc(e,t,n){let s=Ln(t,"depends_on"),o=P(t.file).map($n),r=P(t.test).map(Fn),i=P(t.doc).map(Pn),a=k();return{id:nc(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 p={id:m,kind:a};return c&&(p.note=c),p});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),p=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),wc(m,t,f,p),d.metadata.updated_at=p,{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 wc(e,t,n,s){vc(e,t,n),kc(e,t),e.status=n,e.updated_at=s,Sc(e,n,s)}function vc(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 kc(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=P(t.file).map($n),o=P(t.test).map(Fn),r=P(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 Sc(e,t,n){if(t==="completed"&&!e.completed_at){e.completed_at=n;return}t!=="completed"&&(e.completed_at=void 0)}async function xc(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),p=Math.max(1,Math.min(o,m.length+1));return m.splice(p-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 Ec(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,p)=>{m.order=p+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 Ac(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,p){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=p.metadata.dependencies??[],h=R=>`${R.kind}:${R.id}`,A=new Set(v.map(h));for(let R of o){let H=R.kind==="depends_on"?"blocked_by":R.kind,V={id:R.id,kind:H,created_at:k(),author:z(t.author,n.settings.author_default)};A.has(h(V))||(v.push(V),A.add(h(V)))}p.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 Ic(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),p=(m.linked_items??[]).filter(f=>!o.includes(f.id));return m.linked_items=p.length>0?p: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=oc(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=z(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 p=k();if(s==="decision"){let g=m.metadata.plan_decisions??[];return g.push({ts:p,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:p,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 Rc(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 Cc(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 Tc(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 Oc(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 $c(e){let t=[],n={},s=new Set(["title","description","type","parent","tags","author","message","dep"]);for(let o of P(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,p=`${d}${m.map(f=>`${f.slice(0,1).toUpperCase()}${f.slice(1)}`).join("")}`;if(s.has(p))throw new u(`Invalid --field entry "${o}"; "${p}" is reserved by materialize and cannot be overridden`,_.USAGE);n[p]=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:Oc(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 Fc(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 Pc(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:p,skipped:f}=sc(m,s);if(p.length===0){if(f.length>0)return Tc(d,f);throw new u("No matching plan steps found for --steps",_.NOT_FOUND)}let g=await $c({targets:p,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 Fc(h,p,g),{changedSteps:p.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 Lc(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 Nc(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 Mc={create:(e,t)=>_c(e.options,e.global,t),show:(e,t)=>hc(X(e,"show"),e.options,t),"add-step":(e,t)=>yc(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=Nc(e);return xc(n.id,e.options,t,n.stepRef,n.reorderTo)},"remove-step":(e,t)=>{let n=ce(e,"remove-step");return Ec(n.id,e.options,t,n.stepRef)},link:(e,t)=>{let n=ce(e,"link");return Ac(n.id,e.options,t,n.stepRef)},unlink:(e,t)=>{let n=ce(e,"unlink");return Ic(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)=>Rc(X(e,"resume"),e.options,t),approve:(e,t)=>Cc(X(e,"approve"),e.options,t),materialize:(e,t)=>Pc(X(e,"materialize"),e.options,t)};function Dc(e){let t=Mc[e];if(!t)throw new u(`Unknown pm plan subcommand "${e}"`,_.USAGE);return t}async function Ai(e){let t=await ac(e.global),n=Lc(e);return Dc(n.subcommand)(n,t)}import{readFile as Jc,writeFile as Kc}from"node:fs/promises";import Xc 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 jc(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=jc(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(p=>!a.has(ne(p))),d=[...i,...c].sort((p,f)=>{let g=De(p.ts,f.ts);if(g!==0)return g;let w=a.has(ne(p)),b=a.has(ne(f));return w!==b?Number(b)-Number(w):ne(p).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
|
-
`}function
|
|
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
|
|
9
|
+
`}function Gc(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}),p=Gc([...s.slice(0,i),...m]);return{merged:tt(p),strategy:"union_reanchor",common_entries:i,entries_from_ours:a.length,entries_from_theirs:d.length,entries_total:p.length,reanchored:!0}}var Uc=["tags","dependencies","comments","notes","learnings","files","tests","test_runs","docs","reminders","events"],qc=["updated_at"];function me(e,t){return C(e??null)===C(t??null)}function zc(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 p=C(m);return!o.has(p)||c.has(p)});for(let m of a){let p=C(m);!i.has(p)&&!o.has(p)&&d.push(m)}return d}function Hc(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 Vc(e,t,n,s){let o=new Set(Uc),r=new Set(qc),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],p=n[c];if(o.has(c)){let g=zc(d,m,p);a.merged[c]=g,me(g,m)||a.unionFields.push(c);continue}if(r.has(c)){a.merged[c]=Hc(m,p);continue}let f=qn(d,m,p,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:p,retained:f.value,discarded:s==="theirs"?m:p})):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),p=Dn(a),{merged:f,conflictFields:g,fieldsFromTheirs:w,unionFields:b,conflictDecisions:v}=Vc(d,m,p,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 Bc(e,t,n){if(!Array.isArray(e)||!Array.isArray(t)||!Array.isArray(n))return null;let s=d=>{let m=new Map;for(let p of d){let f=C(p);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),p=a.get(m)??0;p>0?a.set(m,p-1):c.push(d)}return{merged:[...t,...c],acceptedTheirs:c.length>0}}function Wc(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,p)=>m.localeCompare(p));for(let m of d){let p=o.length>0?`${o}.${m}`:m,f=Yc(a,t,n,m,s,p,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=Bc(e,t,n);if(a!==null)return a.acceptedTheirs&&i.push(o),a.merged;let c=Wc(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 Yc(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]="182fee45-4de8-502d-8aec-84b5b8e4aecb")}catch{}})();var $i=["item","history","relationship","json"];function Zc(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 Qc(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 Jc(e,"utf8")}catch{throw new u(`Cannot read merge ${t} file at ${e}.`,_.NOT_FOUND)}}async function em(e){let t=F(process.cwd(),e.path);return await G(U(t))?D(t):null}function tm(e,t){return e.endsWith(".md")?"json_markdown":e.endsWith(".toon")?"toon":t?.item_format??"toon"}async function Fi(e,t){let n=Zc(e.artifact),s=Qc(e.prefer),o=Xc.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=[],p={};if(n==="history"){let g=Ii(r,i,a);c=g.merged,p.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,p.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 em(t),w=Ci(r,i,a,{format:tm(e.itemPath??o,g),schema:g?.schema,extensionFieldNames:Ge(q()),preferred:s});c=w.merged,m.push(...w.conflict_fields),p.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),p.json={paths_from_theirs:g.paths_from_theirs}}if(await Kc(o,c,"utf8"),d!==void 0){let g=await br(d);g!==null&&(p.receipt=Re(g))}let f=[];if(m.length>0){let g=p.receipt===void 0?'Run "pm merge report" to inspect clone-local merge evidence.':`Run "pm merge report" and correlate receipt ${p.receipt.receipt_id} with item ${p.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"&&p.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,...p,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 p=await Je({checkHistoryDrift:!0,checkStorageIntegrity:!0},t),f=p.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:p,guidance:w,generated_at:p.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]="bcda2578-3b01-5e64-9d53-cd32c0f927b8")}catch{}})();function l(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 $(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 Ni(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:l(e,"limit")??l(t,"limit")}function st(e){let t=l(e,"outputFormat");return{json:!0,quiet:!0,author:l(e,"author"),path:l(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:l(e,"outputInclude"),outputLimit:x(e,"outputLimit"),outputBudget:x(e,"outputBudget"),outputSession:l(e,"outputSession"),outputFormat:t==="json"||t==="toon"?t:void 0}}var nm=new Set(["tags","blockedBy","blocked_by","skills","fields"]),sm=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"]),om=new Set(["files","files-discover","docs","test","test-all"]),rm=new Set(["claim","release","start-task","pause-task","close-task"]),im={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"]},am=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession"];function ot(e,t){let n={},s=t!==void 0&&om.has(t),o=t==="files"||t==="files-discover"||t==="docs";for(let[r,i]of Object.entries(e)){if(Array.isArray(i)&&nm.has(r)){n[r]=i.join(",");continue}if(r==="note"&&o){n[r]=i;continue}if(typeof i=="string"&&sm.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 im[t??""]??[])o(c);for(let c of am)o(c);let r=ot({...s,...n},t),i=l(e,"author"),a=t!==void 0&&rm.has(t)?l(e,"assignee")??l(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 T(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 T(e)}function nt(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function Mi(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:l(e,"after"),direction:l(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:l(e,"filterStatus"),list:$e(e.list)?dn(e.list):Fe(e),reason:l(e,"reason"),resolution:l(e,"resolution"),expectedResult:l(e,"expectedResult")??l(e,"expected_result")??l(e,"expected"),actualResult:l(e,"actualResult")??l(e,"actual_result")??l(e,"actual"),validateClose:l(e,"validateClose")??l(e,"validate_close"),author:l(e,"author"),message:l(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:l(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var cm=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))cm.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:l(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:l(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=l(e,t);if(n!==void 0)return n;throw new u(`Missing required parameter: ${t}`,_.USAGE)}function he(e){return typeof e=="string"?[e]:T(e)}function Di(e){return Rr(Pe(e),e.global)}function ji(e){let t=Pe(e);return Tr({cwd:l(t,"cwd"),pmRoot:l(t,"path"),since:l(t,"since"),type:he(t.type),author:he(t.author),item:he(t.item),limit:t.limit===void 0?void 0:$(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 Gi(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:l(t,"author"),message:l(t,"message"),force:t.force===!0},e.global);if(n==="report")return kr({includeReconciled:t.includeReconciled===!0,cwd:l(t,"cwd")});if(n==="driver")return Fi({artifact:Z(t,"artifact"),basePath:Z(t,"basePath"),oursPath:Z(t,"oursPath"),theirsPath:Z(t,"theirsPath"),outputPath:l(t,"outputPath")??l(t,"output"),itemPath:l(t,"itemPath"),prefer:l(t,"prefer")},e.global);throw new u(`Unknown merge subcommand "${n}".`,_.USAGE,{code:"unknown_subcommand"})}function Ui(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=l(t,"snapshotAction")??Z(t,"snapshot_action"),o=F(process.cwd(),e.global.path);if(s==="create")return Lr(o,{name:l(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:l(t,"author"),message:l(t,"message"),lockTtlSeconds:$(t.lockTtlSeconds,"lockTtlSeconds"),lockWaitMs:$(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 qi(e){let t=e.options.all===!0,n=e.id??l(e.options,"id");return Cr(n,t),t?Xe(e.options,e.global):Ke(n,e.options,e.global)}function zi(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=$(e.options.allOver??e.options.all_over,"history-compact allOver"),o=$(e.options.minEntries??e.options.min_entries,"history-compact minEntries"),r=l(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:l(e.options,"before"),dryRun:e.options.dryRun===!0||e.options.dry_run===!0,author:l(e.options,"author"),message:l(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:l(e.options,"author"),message:l(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]="dbabff08-1bb7-539b-b1c1-c10584aa0a67")}catch{}})();function Hi(e){return{storage:e.storage===!0,metadataCoverage:e.metadataCoverage===!0,fieldUtilization:e.fieldUtilization===!0,byAssignee:e.byAssignee===!0,byTag:e.byTag===!0,byPriority:e.byPriority===!0,tagPrefix:typeof e.tagPrefix=="string"?e.tagPrefix:void 0,measurements:e.measurements===!0,metric:l(e,"metric"),measurementLimit:typeof e.measurementLimit=="number"?e.measurementLimit:void 0,observe:T(e.observe),direction:typeof e.improvementDirection=="string"?e.improvementDirection:void 0,measurementSource:l(e,"measurementSource"),measurementItem:l(e,"measurementItem"),measurementRevision:l(e,"measurementRevision"),author:l(e,"author"),message:l(e,"message"),provenanceCoverage:e.provenanceCoverage===!0,fleetAttribution:e.fleetAttribution===!0,since:l(e,"since"),eventLimit:typeof e.eventLimit=="number"?e.eventLimit:void 0,minimumSample:typeof e.minimumSample=="number"?e.minimumSample: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]="2643d11d-befc-5a87-8bec-760951eec4d0")}catch{}})();var mm=new Set(["true","1","yes","on"]),dm=new Set(["false","0","no","off"]);function lm(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 pm(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(mm.has(i))return!0;if(dm.has(i))return!1}}}}function um(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 O(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function fm(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 _m(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 hm(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 gm(e){let t=O(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 Vi(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=>O(n)).filter(n=>n!==void 0);return t.length>0?t:void 0}function Zn(e){return Yi(e,O)}function Bi(e){return Yi(e,Ki)}function ym(e,t){if(typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=100)return e;let n=O(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 Wi(e,t){let n=O(e)?.toLowerCase();if(!n)return;let s=n==="med"?"medium":n;return t.includes(s)?s:void 0}function es(e){return O(e)?.toLowerCase()==="global"?"global":"project"}function bm(e,t){let n=ts(e,t.allowScalar===!0);if(!n)return;let s=n.map(o=>xm(o,t)).filter(o=>o!==void 0);return s.length>0?s:void 0}function wm(e,t={}){return Ji(e,t,(n,s)=>({path:n,scope:es(s?.scope),note:O(s?.note)}))}function vm(e,t={}){return Ji(e,t,(n,s)=>({path:n,scope:es(s?.scope),note:O(s?.note)}))}function km(e,t={}){let n=ts(e,t.allowScalar===!0);if(!n)return;let s=n.map(o=>Im(o,t)).filter(o=>o!==void 0);return s.length>0?s:void 0}function Sm(e,t){return z(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=O(e[n]);if(s)return s}}function Yi(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 xm(e,t){if(typeof e=="string")return Em(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]):O(e[s]))??t.fallbackCreatedAt,author:O(e[o])??t.fallbackAuthor,text:n}}function Em(e,t){let n=O(e);return n?{created_at:t.fallbackCreatedAt,author:t.fallbackAuthor,text:n}:void 0}function Ji(e,t,n){let s=ts(e,t.allowScalar===!0);if(!s)return;let o=t.pathKeys??["path"],r=s.map(i=>Am(i,o,n)).filter(i=>i!==void 0);return r.length>0?r:void 0}function Am(e,t,n){if(typeof e=="string"){let o=O(e);return o?n(o):void 0}if(!mt(e))return;let s=ct(e,t);return s?n(s,e):void 0}function Im(e,t){if(typeof e=="string"){let o=O(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:Rm(e.timeout_seconds,t),note:O(e.note),...t.includeExtendedAssertions===!0?Cm(e):{}}}function Rm(e,t){let n=t.integerTimeout===!0?Qn(e):Ki(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 Ki(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 Cm(e){return{pm_context_mode:Wi(e.pm_context_mode,["schema","tracker","auto"]),env_set:Zn(e.env_set),env_clear:ge(e.env_clear),shared_host_safe:Vi(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:Bi(e.assert_json_field_gte)}}async function Tm(e){if(!await G(U(e)))throw new u(`Tracker is not initialized at ${e}. Run pm init first.`,_.NOT_FOUND)}function Xi(){return{metadata:{},body:""}}async function Om(e){let{pmRoot:t,id:n,itemPath:s,document:o,author:r,message:i,settings:a,conflictWarningPrefix:c}=e,d=xt(t,n),m=Xi();try{let p=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 p()}}catch(p){if(p instanceof u&&p.exitCode===_.CONFLICT)return{committed:!1,conflictWarning:`${c}:${n}`};throw p}}import{readFile as Fm}from"node:fs/promises";import Pm 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 $m(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 Zi(){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 Qi(e){if(!e)return null;let t=$m(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 Lm=["markdown","toon","json"],Nm=["brief","standard","deep"];function Mm(e){if(!e)return;let t=e.trim().toLowerCase();if(!Lm.includes(t))throw new u("Guide format must be one of markdown|toon|json",_.USAGE);return t}function Dm(e,t){let n=Mm(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 jm(e){if(!e)return"brief";let t=e.trim().toLowerCase();if(!Nm.includes(t))throw new u("Guide depth must be one of brief|standard|deep",_.USAGE);return t}function Gm(){return ys(process.env,"PM_CLI_PACKAGE_ROOT",import.meta.url,["..","..",".."])}function ea(e){return e.replaceAll(`\r
|
|
11
11
|
`,`
|
|
12
|
-
`)}function
|
|
12
|
+
`)}function Um(e,t,n){let o=ea(e).split(`
|
|
13
13
|
`),i=o.slice(0,t).join(`
|
|
14
|
-
`),a=o.length>t;return i.length>n&&(i=i.slice(0,n),a=!0),{excerpt:i.trimEnd(),truncated:a,lineCount:o.length}}async function
|
|
15
|
-
`).length,content_mode:"full",content:d,truncated:!1})}else{let d=
|
|
16
|
-
`)}let t=[`# pm guide ${e.topic.id}`,"",e.topic.summary,"","## Intent",e.topic.intent,"","## Key commands",...e.topic.commands.map(n=>`- \`${n}\``),"","## Workflow prompts"];for(let n of e.topic.workflows)t.push(`### ${n.name}`),t.push(`goal: ${n.goal}`),t.push(`prompt: ${n.prompt}`),t.push("commands:"),t.push(...n.commands.map(s=>`- \`${s}\``)),t.push("");t.push("## Documents");for(let n of e.docs){let s=n.exists?"available":n.optional?"missing (optional)":"missing (required)";t.push(`- \`${n.path}\` - ${n.purpose} (${s})`),n.exists&&n.content_mode!=="none"&&n.content&&(t.push(""),t.push(`### Excerpt: \`${n.path}\``),n.truncated&&t.push("_truncated for context efficiency_"),t.push("```markdown"),t.push(
|
|
17
|
-
`)}(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]="
|
|
14
|
+
`),a=o.length>t;return i.length>n&&(i=i.slice(0,n),a=!0),{excerpt:i.trimEnd(),truncated:a,lineCount:o.length}}async function qm(e,t,n){let s=t!=="brief",o=s?t==="deep"?"full":"excerpt":"none",r=[];for(let i of e.docs){let a=Pm.resolve(n,i.path);if(!s){r.push({path:i.path,purpose:i.purpose,optional:i.optional===!0,exists:!0,line_count:null,content_mode:"none",content:null,truncated:!1});continue}try{let c=await Fm(a,"utf8");if(t==="deep"){let d=ea(c).trimEnd();r.push({path:i.path,purpose:i.purpose,optional:i.optional===!0,exists:!0,line_count:d.length===0?0:d.split(`
|
|
15
|
+
`).length,content_mode:"full",content:d,truncated:!1})}else{let d=Um(c,120,12e3);r.push({path:i.path,purpose:i.purpose,optional:i.optional===!0,exists:!0,line_count:d.lineCount,content_mode:o,content:d.excerpt,truncated:d.truncated})}}catch(c){let m=c?.code==="ENOENT";if(r.push({path:i.path,purpose:i.purpose,optional:i.optional===!0,exists:!1,line_count:null,content_mode:"none",content:null,truncated:!1}),!m)throw new u(`Failed to read guide document "${i.path}".`,_.GENERIC_FAILURE)}}return r}function zm(e){let t=Zi().map(n=>({id:n.id,aliases:n.aliases,title:n.title,summary:n.summary,intent:n.intent,quick_commands:e==="brief"?n.commands.slice(0,3):n.commands.slice(0,6),docs:n.docs.map(s=>({path:s.path,purpose:s.purpose})),related:n.related}));return{output_default:"toon",mode:"index",depth:e,topics:t,suggested_next_steps:["pm guide <topic>","pm guide <topic> --depth standard","pm guide <topic> --depth deep --format markdown","pm guide <topic> --json"]}}function Hm(e){let t=Qi(e);if(t)return t;let n=dt().join(", ");throw new u(`Unknown guide topic "${e}". Available topics: ${n}. Use "pm guide --list" to browse.`,_.USAGE)}async function Vm(e,t){let n=jm(typeof e.depth=="string"?e.depth:void 0),s=e.list===!0,o=typeof e.topic=="string"?e.topic:void 0;if(s||!o)return zm(n);let r=Hm(o),i=Gm(),a=await qm(r,n,i),c=a.filter(d=>!d.exists&&!d.optional).map(d=>`Missing required guide document: ${d.path}`);return{output_default:"toon",mode:"topic",depth:n,requested_topic:o,topic:r,docs:a,warnings:c}}function Bm(e){return e.replaceAll("```","``\\`")}function Wm(e){if(e.mode==="index"){let n=["# pm guide","","Token-efficient local documentation index for agent and maintainer workflows.","","## Topics"];for(let s of e.topics)n.push(`- \`${s.id}\` - ${s.summary}`),e.depth!=="brief"&&(n.push(` - intent: ${s.intent}`),n.push(` - docs: ${s.docs.map(o=>`\`${o.path}\``).join(", ")}`));n.push("","## Next steps");for(let s of e.suggested_next_steps)n.push(`- \`${s}\``);return n.join(`
|
|
16
|
+
`)}let t=[`# pm guide ${e.topic.id}`,"",e.topic.summary,"","## Intent",e.topic.intent,"","## Key commands",...e.topic.commands.map(n=>`- \`${n}\``),"","## Workflow prompts"];for(let n of e.topic.workflows)t.push(`### ${n.name}`),t.push(`goal: ${n.goal}`),t.push(`prompt: ${n.prompt}`),t.push("commands:"),t.push(...n.commands.map(s=>`- \`${s}\``)),t.push("");t.push("## Documents");for(let n of e.docs){let s=n.exists?"available":n.optional?"missing (optional)":"missing (required)";t.push(`- \`${n.path}\` - ${n.purpose} (${s})`),n.exists&&n.content_mode!=="none"&&n.content&&(t.push(""),t.push(`### Excerpt: \`${n.path}\``),n.truncated&&t.push("_truncated for context efficiency_"),t.push("```markdown"),t.push(Bm(n.content)),t.push("```"))}return e.topic.related.length>0&&(t.push("","## Related topics"),t.push(...e.topic.related.map(n=>`- \`${n}\``))),e.warnings.length>0&&(t.push("","## Warnings"),t.push(...e.warnings.map(n=>`- ${n}`))),t.join(`
|
|
17
|
+
`)}(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]="8acb405a-140e-532c-81c0-e8153ea30dc0")}catch{}})();var ta=["bash","zsh","fish"],Ym=[...yt],Jm=[...bt],os=Kr("full"),Km=S(He),Xm=S(lo),Zm=S(yo),Qm=S(xo),ed=S(Eo),td=S(bo),nd=S(wo),sd=S(So),od=S($o),rd=S(Ao),id=S(Io),ad=S(go),cd=S(Co),md=S(po),dd=S(To),ld=S(Ro),pd=S(Oo),ud=S(No),fd=S(Po),_d=S(vo),hd=S(Lo),gd=S(Fo),yd=S(Ve),bd=S(ko),wd=S(fo),vd=S(Mo),kd=S(uo),Sd="create show add-step update-step complete-step block-step reorder-step remove-step link unlink decision discovery validation resume approve materialize",xd=S(Do),Ed=`${xd} bash zsh fish`,rs=ye(dt()),lt="init scaffold install uninstall explore manage describe reload doctor catalog adopt adopt-all activate deactivate",Ad=S(_o),Id=S(ho),Rd="--author --message --force --json --quiet --no-changed-fields --id-only --pm-path --path --no-extensions --no-pager --profile --help",Cd="--dry-run --author --message --force --json --quiet --no-changed-fields --id-only --pm-path --path --no-extensions --no-pager --profile --help",Td="--author --message --validate-close --duplicate-of --force --json --quiet --no-changed-fields --id-only --pm-path --path --no-extensions --no-pager --profile --help",Od="--author --message --force --json --quiet --no-changed-fields --id-only --pm-path --path --no-extensions --no-pager --profile --help",ca=[["init","Initialize pm storage for the current workspace"],["config","Read or update pm settings"],["extension","Manage extension lifecycle operations"],["package","Manage package lifecycle operations"],["packages","Alias for package"],["create","Create a new project management item"],["copy","Copy an existing item to a new ID"],["focus","Set/clear/show the session focused parent for new items"],["list","List active items with optional filters"],["list-all","List all items with optional filters"],["list-draft","List draft items with optional filters"],["list-open","List open items with optional filters"],["list-in-progress","List in-progress items with optional filters"],["list-blocked","List blocked items with optional filters"],["list-closed","List closed items with optional filters"],["list-canceled","List canceled items with optional filters"],["aggregate","Aggregate grouped item counts and numeric stats for governance queries"],["duplicates","Find bounded duplicate clusters across lifecycle statuses"],["guide","Browse local progressive-disclosure guides"],["calendar","Show calendar views for deadlines and reminders"],["cal","Alias for calendar"],["context","Show a token-efficient project context snapshot"],["ctx","Alias for context"],["get","Show item details by ID"],["next","Recommend the next actionable (unblocked, ready) work item"],["search","Search items with keyword, semantic, or hybrid modes"],["reindex","Rebuild search artifacts"],["history","Show item history entries"],["history-compact","Compact history streams into a synthetic baseline + retained tail"],["history-redact","Redact sensitive literals/patterns and recompute history hashes"],["history-repair","Re-anchor a drifted history chain so pm health/validate report ok"],["schema","Manage custom item types and statuses in .agents/pm/schema/*.json"],["profile","List, show, apply, and lint project profiles (archetype schema/config/template/package bundles)"],["plan","Agent-optimized Plan item workflow (create/show/add-step/update-step/complete-step/link/approve/materialize)"],["activity","Show recent activity across items"],["restore","Restore an item to an earlier state"],["update","Update item fields and metadata"],["update-many","Bulk-update matched items with dry-run and rollback checkpoints"],["close","Close an item (reason requirement follows governance settings)"],["close-many","Bulk-close matched items with an optional shared reason and rollback checkpoint"],["delete","Delete an item and record the change"],["append","Append text to an item body"],["comments","List or add comments for an item"],["notes","List or add notes for an item"],["learnings","List or add learnings for an item"],["files","Manage linked files"],["docs","Manage linked docs"],["deps","Show dependency relationships for an item"],["graph","Bounded graph traversal, analytics, and governance-audit queries"],["test","Manage linked tests and optionally run them"],["test-all","Run linked tests across matching items"],["test-runs","Manage background linked-test runs"],["stats","Show project tracker statistics"],["health","Show project tracker health checks"],["validate","Run standalone validation checks"],["gc","Clean optional cache artifacts"],["contracts","Show machine-readable command and schema contracts"],["claim","Claim an item for active work"],["release","Release the active claim for an item"],["start-task","Lifecycle alias to claim and set in_progress"],["pause-task","Lifecycle alias to reopen and release claim"],["close-task","Lifecycle alias to close and release claim"],["meet","Shortcut to create a Meeting with scheduling defaults"],["event","Shortcut to create an Event with scheduling defaults"],["remind","Shortcut to create a Reminder from a point in time"],["templates","Manage reusable create templates"],["completion","Generate shell completion"],["help","Display help for a command"]],$d=new Map([["calendar","Show deadline/reminder calendar views"],["schema","Inspect and manage runtime schema"],["profile","List, show, apply, and lint project profiles (archetype bundles)"],["plan","Agent-optimized Plan workflow (create/show/add-step/update-step/complete-step/link/approve/materialize)"],["start-task","Lifecycle alias to claim and set in-progress"]]),Fd=mo.flatMap(e=>[e.short,e.flag,...e.aliases??[]]).filter(e=>!!e).join(" ");function ye(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n)).join(" ")}function Pd(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].join(" ")}function ma(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"').replaceAll("$","\\$").replaceAll("`","\\`")}function is(e,t){return Pd(e.length>0?e:t.item_types??Ym)}function as(e){return ye(e.statuses??Jm)}function de(e,t){let n=[...e.split(/\s+/u).filter(s=>s.length>0),...t??[]];return ye(n)}function da(e){let t=(e??[]).map(n=>n.trim()).filter(n=>n.startsWith("--")&&n.length>2).map(n=>`--${n.slice(2).replaceAll("_","-")}`);return[...new Set(t)].sort((n,s)=>n.localeCompare(s))}function Le(e){let t=da(e);return t.length===0?"":`${t.map(n=>` '${n}[Runtime schema field flag]:value' \\`).join(`
|
|
18
18
|
`)}
|
|
19
19
|
`}function pt(e,t={}){let n=t.trailingContinuation??!0,s=e.length-1;return e.map((o,r)=>` ${o}${n||r!==s?" \\":""}`).join(`
|
|
20
|
-
`)}function
|
|
21
|
-
`)}function
|
|
22
|
-
`)}function
|
|
20
|
+
`)}function Ld(){return ca.map(([e,t])=>` '${e}:${t}'`).join(`
|
|
21
|
+
`)}function Nd(){return ca.filter(([e])=>e!=="help").map(([e,t])=>{let n=$d.get(e)??t;return`complete -c pm -n __pm_no_subcommand -a ${e.padEnd(16)} -d '${n}'`}).join(`
|
|
22
|
+
`)}function na(e){let t=["reviewer-missing[Select only items missing reviewer]","risk-missing[Select only items missing risk]","confidence-missing[Select only items missing confidence]","sprint-missing[Select only items missing sprint]","release-missing[Select only items missing release]"],n=e.includeContentMissingAliases===!0?["files-missing[Alias for --no-files]","docs-missing[Alias for --no-docs]"]:[],s=[["has-notes[Select only items that have notes]","no-notes[Select only items with no notes]"],["has-learnings[Select only items that have learnings]","no-learnings[Select only items with no learnings]"],["has-files[Select only items that have linked files]","no-files[Select only items with no linked files]"],["has-docs[Select only items that have linked docs]","no-docs[Select only items with no linked docs]"],["has-tests[Select only items that have linked tests]","no-tests[Select only items with no linked tests]"],["has-comments[Select only items that have comments]","no-comments[Select only items with no comments]"],["has-deps[Select only items that have dependencies]","no-deps[Select only items with no dependencies]"],["has-body[Select only items with non-empty body]","empty-body[Select only items with empty body]"],["has-linked-command[Select only items that have a linked command]","no-linked-command[Select only items with no linked command]"]];return pt([...[...t,...n].map(o=>`'--${e.missingPrefix}${o}'`),...s.flatMap(([o,r])=>[`'--${e.pairedPrefix}${o}'`,`'--${e.pairedPrefix}${r}'`])])}var Md=["'--comment[Comment seed author=<value>,created_at=<iso|now>,text=<value>]:comment'","'--note[Note seed author=<value>,created_at=<iso|now>,text=<value>]:note'","'--learning[Learning seed author=<value>,created_at=<iso|now>,text=<value>]:learning'","'--file[Linked file path=<value>,scope=<project|global>,note=<text>]:file'","'--test[Linked test command=<value>,path=<value>,scope=<project|global>]:test'","'--doc[Linked doc path=<value>,scope=<project|global>,note=<text>]:doc'","'--reminder[Reminder entry at=<iso|relative>|date=<iso|relative>,text=<text>|title=<text>]:reminder'","'--event[Event entry start=<iso|relative>,end=<iso|relative>,recur_*]:event'","'--type-option[Type option key=value or key=<name>,value=<value>]:type_option'","'--unset[Clear scalar metadata field by name]:field'","'--replace-files[Atomically replace linked files with provided --file values]'","'--replace-docs[Atomically replace linked docs with provided --doc values]'","'--clear-deps[Clear dependency entries]'","'--clear-comments[Clear comments]'","'--clear-notes[Clear notes]'","'--clear-learnings[Clear learnings]'","'--clear-files[Clear linked files]'","'--clear-tests[Clear linked tests]'","'--clear-docs[Clear linked docs]'","'--clear-reminders[Clear reminders]'","'--clear-events[Clear events]'","'--clear-type-options[Clear type options]'"];function sa(e){return pt([...e==="reminder"?["'--at[Reminder time (default +1d)]:at'","'--text[Reminder text (defaults to title)]:text'"]:["'--start[Start time (ISO, now, or relative)]:start'","'--duration[Duration from start (default 1h)]:duration'","'--end[End time (overrides --duration)]:end'","'--location[Location]:location'","'--timezone[IANA timezone]:timezone'","'--all-day[Mark as an all-day event]'"],"'--parent[Parent item id]:parent'","'--allow-missing-parent[Permit a parent id that does not exist yet]'","'--tags[Comma-separated tags]:tags'","'(-p --priority)'{-p,--priority}'[Priority (0-4)]:(0 1 2 3 4)'","'(-b --body)'{-b,--body}'[Item body]:body'","'(-d --description)'{-d,--description}'[Short description]:description'","'--author[Mutation author]:author'","'--message[History message]:message'","'--json[Output JSON]'","'--quiet[Suppress stdout]'"],{trailingContinuation:!1})}function oa(e,t,n,s){return pt([`'--filter-status[Filter by status before ${e}]:(${t})'`,`'--filter-type[Filter by type before ${e}]:(${n})'`,`'--filter-tag[Filter by tag before ${e}]:(${s})'`,`'--filter-priority[Filter by priority before ${e}]:(0 1 2 3 4)'`,"'--filter-deadline-before[Filter by deadline upper bound]:deadline'","'--filter-deadline-after[Filter by deadline lower bound]:deadline'","'--filter-updated-after[Filter by updated_at lower bound (ISO/relative)]:timestamp'","'--filter-updated-before[Filter by updated_at upper bound (ISO/relative)]:timestamp'","'--filter-created-after[Filter by created_at lower bound (ISO/relative)]:timestamp'","'--filter-created-before[Filter by created_at upper bound (ISO/relative)]:timestamp'",`'--filter-assignee[Filter by assignee before ${e}]:assignee'`,"'--filter-assignee-filter[Filter assignee presence]:(assigned unassigned)'","'--filter-parent[Filter by parent item ID]:parent'","'--filter-sprint[Filter by sprint]:sprint'","'--filter-release[Filter by release]:release'"])}function le(e,t){let n=da(t).map(o=>o.slice(2));if(e.length===0||n.length===0)return"";let s=[];for(let o of e)for(let r of n)s.push(`complete -c pm -n '__fish_seen_subcommand_from ${o}' -l ${r} -d 'Runtime schema field flag' -r`);return`${s.join(`
|
|
23
23
|
`)}
|
|
24
|
-
`}function
|
|
24
|
+
`}function ra(e,t,n){let s=e.toUpperCase(),o=`PM_COMPLETION_${s}_CACHE`,r=`PM_COMPLETION_${s}_CACHE_TS`,i=`PM_COMPLETION_${s}_TTL`,a=ma(n);return[`_pm_completion_${e}_choices() {`," local now ttl cache_ts resolved",' now="$(date +%s 2>/dev/null || echo 0)"',` ttl="\${${i}:-120}"`,` cache_ts="\${${r}:-0}"`,` if [[ -n "\${${o}:-}" && "$now" -ne 0 && $((now - cache_ts)) -lt "$ttl" ]]; then`,` printf '%s\\n' "$${o}"`," return 0"," fi",` resolved="$(pm ${t} 2>/dev/null)"`,' if [[ -z "$resolved" ]]; then',` resolved="${a}"`," fi",` ${o}="$resolved"`,` ${r}="$now"`,` printf '%s\\n' "$${o}"`,"}"]}function ia(e,t,n){let s=e.toUpperCase(),o=`PM_COMPLETION_${s}_CACHE`,r=`PM_COMPLETION_${s}_CACHE_TS`,i=`PM_COMPLETION_${s}_TTL`,a=ma(n);return`
|
|
25
25
|
_pm_${e}_choices() {
|
|
26
26
|
local now ttl cache_ts resolved
|
|
27
27
|
now=\${EPOCHSECONDS:-0}
|
|
@@ -39,7 +39,7 @@ _pm_${e}_choices() {
|
|
|
39
39
|
${r}="$now"
|
|
40
40
|
print -r -- "$${o}"
|
|
41
41
|
}
|
|
42
|
-
`}function
|
|
42
|
+
`}function aa(e,t,n){let s=e.toUpperCase(),o=n.replaceAll("'","\\'");return`
|
|
43
43
|
function __pm_${e}_choices
|
|
44
44
|
set -l now (date +%s ^/dev/null)
|
|
45
45
|
if test -z "$now"
|
|
@@ -64,8 +64,8 @@ function __pm_${e}_choices
|
|
|
64
64
|
set -gx PM_COMPLETION_${s}_CACHE_TS $now
|
|
65
65
|
printf '%s\\n' $resolved
|
|
66
66
|
end
|
|
67
|
-
`}function
|
|
68
|
-
`)}function
|
|
67
|
+
`}function Dd(e=[],t=[],n=!1,s={}){let o=os.join(" "),r=e.length===0,i=is(e,s),a=as(s),c=ye(t),d=de(Km,s.command_flags?.list),m=de(sd,s.command_flags?.create),p=de(rd,s.command_flags?.update),f=de(id,s.command_flags?.["update-many"]),g=de(yd,s.command_flags?.search),w=de(ld,s.command_flags?.calendar),b=de(pd,s.command_flags?.context),v=n||t.length>0,h=A=>`$(compgen -W "${A}" -- "$cur")`;return["# bash completion for pm",`# Source this file or add 'eval "$(pm completion bash)"' to ~/.bashrc`,"",...r?[...ra("type","completion-types",i),""]:[],...ra("status","completion-statuses",a),"","_pm_completion() {"," local cur prev words cword"," _init_completion 2>/dev/null || {",' cur="${COMP_WORDS[COMP_CWORD]}"',' prev="${COMP_WORDS[COMP_CWORD-1]}"'," cword=$COMP_CWORD"," }",""," if [[ $cword -eq 1 ]]; then",` COMPREPLY=(${h(o)})`," return 0"," fi","",' if [[ "$prev" == "--type" ]]; then',r?' COMPREPLY=($(compgen -W "$(_pm_completion_type_choices)" -- "$cur"))':` COMPREPLY=(${h(i)})`," return 0"," fi","",' if [[ "$prev" == "--status" ]]; then',' COMPREPLY=($(compgen -W "$(_pm_completion_status_choices)" -- "$cur"))'," return 0"," fi","",...v?[' if [[ "$prev" == "--tag" || "$prev" == "--tags" ]]; then',` COMPREPLY=(${h(c)})`," return 0"," fi"]:[' if [[ "$prev" == "--tag" || "$prev" == "--tags" ]]; then'," local now ttl cache_ts tag_values",' now="$(date +%s 2>/dev/null || echo 0)"',' ttl="${PM_COMPLETION_TAG_TTL:-120}"',' cache_ts="${PM_COMPLETION_TAG_CACHE_TS:-0}"',' tag_values="${PM_COMPLETION_TAG_CACHE:-}"',' if [[ -z "$tag_values" || "$now" -eq 0 || $((now - cache_ts)) -ge "$ttl" ]]; then',' tag_values="$(pm completion-tags 2>/dev/null)"',' PM_COMPLETION_TAG_CACHE="$tag_values"',' PM_COMPLETION_TAG_CACHE_TS="$now"'," fi",' COMPREPLY=($(compgen -W "$tag_values" -- "$cur"))'," return 0"," fi"],"",' local cmd="${COMP_WORDS[1]}"',"",' case "$cmd" in'," list|list-all|list-draft|list-open|list-in-progress|list-blocked|list-closed|list-canceled)",` COMPREPLY=(${h(d)})`," ;;"," aggregate)",` COMPREPLY=(${h(Xm)})`," ;;"," duplicates)",` COMPREPLY=(${h(_d)})`," ;;"," create)",` COMPREPLY=(${h(m)})`," ;;"," copy)",` COMPREPLY=(${h(Qm)})`," ;;"," focus)",` COMPREPLY=(${h(ed)})`," ;;"," update)",` COMPREPLY=(${h(p)})`," ;;"," update-many)",` COMPREPLY=(${h(f)})`," ;;"," calendar|cal)",` COMPREPLY=(${h(w)})`," ;;"," context|ctx)",` COMPREPLY=(${h(b)})`," ;;"," next)",` COMPREPLY=(${h(ud)})`," ;;"," guide)",` COMPREPLY=(${h(`${gd} ${rs}`)})`," ;;"," search)",` COMPREPLY=(${h(g)})`," ;;"," reindex)",` COMPREPLY=(${h("--mode --progress --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," init)",` COMPREPLY=(${h(`${wd} --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help`)})`," ;;"," config)",` COMPREPLY=(${h("--criterion --clear-criteria --format --policy --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," extension)",` COMPREPLY=(${h(`${lt} ${Ad}`)})`," ;;"," package|packages)",` COMPREPLY=(${h(`${lt} ${Id}`)})`," ;;"," comments)",` COMPREPLY=(${h("--add --body --stdin --file --edit --delete --limit --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," notes)",` COMPREPLY=(${h("--add --add-json --stdin --file --edit --delete --limit --since --event-type --include-meta --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," learnings)",` COMPREPLY=(${h("--add --stdin --file --edit --delete --limit --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," files)",` COMPREPLY=(${h("discover lookup --add --add-glob --remove --migrate --list --apply --note --append-stable --validate-paths --scope --limit --offset --no-truncate --strict-read --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," docs)",` COMPREPLY=(${h("--add --add-glob --remove --migrate --note --validate-paths --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," append)",` COMPREPLY=(${h(Zm)})`," ;;"," deps)",` COMPREPLY=(${h(fd)})`," ;;"," graph)",` COMPREPLY=(${h(`ancestors descendants predecessors successors paths impact analyze audit communities redundancy dominators slack centrality articulation plan index ${hd}`)})`," ;;"," test)",` COMPREPLY=(${h("--add --add-json --remove --list --run --match --only-index --only-last --background --timeout --progress --env-set --env-clear --shared-host-safe --pm-context --override-linked-pm-context --fail-on-context-mismatch --fail-on-skipped --fail-on-empty-test-run --require-assertions-for-pm --check-context --auto-pm-context --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," test-all)",` COMPREPLY=(${h("--status --limit --offset --background --timeout --progress --env-set --env-clear --shared-host-safe --pm-context --override-linked-pm-context --fail-on-context-mismatch --fail-on-skipped --fail-on-empty-test-run --require-assertions-for-pm --check-context --auto-pm-context --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," test-runs)",` COMPREPLY=(${h("list status logs stop resume --status --limit --stream --tail --force --author --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," validate)",` COMPREPLY=(${h("--check-metadata --metadata-profile --check-resolution --check-lifecycle --check-stale-blockers --dependency-cycle-severity --parent-cycle-severity --check-files --scan-mode --include-pm-internals --verbose-file-lists --verbose-diagnostics --all-affected-ids --strict-exit --fail-on-warn --fix-hints --auto-fix --dry-run --fix-scope --prune-missing --check-history-drift --check-command-references --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," health)",` COMPREPLY=(${h(bd)})`," ;;"," history)",` COMPREPLY=(${h(md)})`," ;;"," events)",` COMPREPLY=(${h(dd)})`," ;;"," history-compact)",` COMPREPLY=(${h("--before --ids --all-over --closed --all-streams --min-entries --dry-run --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," history-author-acknowledge)",` COMPREPLY=(${h("--event --all-actionable --attributed-author --reviewer --reason --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," get)",` COMPREPLY=(${h(od)})`," ;;"," history-redact)",` COMPREPLY=(${h("--literal --regex --replacement --dry-run --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," history-repair)",` COMPREPLY=(${h("--all --dry-run --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," schema)",` COMPREPLY=(${h("list show show-status add-type remove-type add-status remove-status add-field remove-field list-fields show-field apply-preset rename-type rename-field remap-status --description --default-status --folder --alias --role --order --type --commands --cli-flag --required --required-on-create --no-allow-unset --required-types --infer --min-count --apply --to --migration-id --dry-run --author --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," profile)",` COMPREPLY=(${h("list show apply lint agile ops research --dry-run --author --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," plan)",` COMPREPLY=(${h(`${Sd} ${kd}`)})`," ;;"," activity)",` COMPREPLY=(${h(cd)})`," ;;"," contracts)",` COMPREPLY=(${h(vd)})`," ;;"," gc)",` COMPREPLY=(${h("--dry-run --scope --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," stats)",` COMPREPLY=(${h("--storage --metadata-coverage --field-utilization --by-assignee --by-tag --by-priority --tag-prefix --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")})`," ;;"," close|close-task)",` COMPREPLY=(${h(Td)})`," ;;"," close-many)",` COMPREPLY=(${h(ad)})`," ;;"," release)",` COMPREPLY=(${h(Od)})`," ;;"," delete)",` COMPREPLY=(${h(Cd)})`," ;;"," claim|restore|start-task|pause-task)",` COMPREPLY=(${h(Rd)})`," ;;"," meet|event)",` COMPREPLY=(${h(td)})`," ;;"," remind)",` COMPREPLY=(${h(nd)})`," ;;"," completion)",` COMPREPLY=(${h(Ed)})`," ;;"," templates)",` COMPREPLY=(${h("save list show")})`," ;;"," *)",` COMPREPLY=(${h(Fd)})`," ;;"," esac"," return 0","}","","complete -F _pm_completion pm"].join(`
|
|
68
|
+
`)}function jd(e=[],t=[],n=!1,s={}){let o=e.length===0,r=is(e,s),i=as(s),a=o?'${(f)"$(_pm_type_choices)"}':r,c='${(f)"$(_pm_status_choices)"}',d=rs,m=ye(t),p=n||t.length>0,f=p?m:'${(f)"$(_pm_tag_choices)"}',g=Le(s.command_flags?.list),w=Le(s.command_flags?.create),b=Le(s.command_flags?.search),v=Le(s.command_flags?.calendar),h=Le(s.command_flags?.context),A=na({missingPrefix:"filter-",pairedPrefix:"",includeContentMissingAliases:!0}),R=na({missingPrefix:"filter-",pairedPrefix:"filter-"}),H=pt(Md),V=p?"":`
|
|
69
69
|
_pm_tag_choices() {
|
|
70
70
|
local now ttl cache_ts
|
|
71
71
|
now=\${EPOCHSECONDS:-0}
|
|
@@ -86,13 +86,13 @@ _pm_tag_choices() {
|
|
|
86
86
|
_pm_commands() {
|
|
87
87
|
local -a commands
|
|
88
88
|
commands=(
|
|
89
|
-
${
|
|
89
|
+
${Ld()}
|
|
90
90
|
)
|
|
91
91
|
_describe 'command' commands
|
|
92
92
|
}
|
|
93
|
-
${
|
|
94
|
-
${o?
|
|
95
|
-
${
|
|
93
|
+
${V}
|
|
94
|
+
${o?ia("type","completion-types",r):""}
|
|
95
|
+
${ia("status","completion-statuses",i)}
|
|
96
96
|
|
|
97
97
|
_pm() {
|
|
98
98
|
local context state line
|
|
@@ -103,6 +103,7 @@ _pm() {
|
|
|
103
103
|
'--output-limit[Set the universal read row ceiling]:limit' \\
|
|
104
104
|
'--output-budget[Set the universal estimated-token ceiling]:tokens' \\
|
|
105
105
|
'--output-format[Select the universal read encoding]:(toon json)' \\
|
|
106
|
+
'--output-session[Carry cross-call read budget and served-item state]:state' \\
|
|
106
107
|
'--no-changed-fields[Omit changed_fields array from mutation output]' \\
|
|
107
108
|
'--pm-path[Explicit tracker storage path for this command]:path:_files -/' \\
|
|
108
109
|
'--path[Compatibility alias for --pm-path]:path:_files -/' \\
|
|
@@ -237,11 +238,11 @@ ${w} '--json[Output JSON]' \\
|
|
|
237
238
|
;;
|
|
238
239
|
meet|event)
|
|
239
240
|
_arguments \\
|
|
240
|
-
${
|
|
241
|
+
${sa("event")}
|
|
241
242
|
;;
|
|
242
243
|
remind)
|
|
243
244
|
_arguments \\
|
|
244
|
-
${
|
|
245
|
+
${sa("reminder")}
|
|
245
246
|
;;
|
|
246
247
|
update)
|
|
247
248
|
_arguments \\
|
|
@@ -260,7 +261,7 @@ ${ta("reminder")}
|
|
|
260
261
|
'--remove-ac[Remove one acceptance criterion by exact text]:criteria' \\
|
|
261
262
|
'--expected[Short alias for --expected-result]:expected_result' \\
|
|
262
263
|
'--actual[Short alias for --actual-result]:actual_result' \\
|
|
263
|
-
${
|
|
264
|
+
${H}
|
|
264
265
|
'--author[Mutation author]:author' \\
|
|
265
266
|
'--message[History message]:message' \\
|
|
266
267
|
'--force[Force override]' \\
|
|
@@ -269,7 +270,7 @@ ${z}
|
|
|
269
270
|
;;
|
|
270
271
|
update-many)
|
|
271
272
|
_arguments \\
|
|
272
|
-
${
|
|
273
|
+
${oa("applying updates",c,a,f)}
|
|
273
274
|
'--filter-ac-missing[Select only items missing acceptance_criteria]' \\
|
|
274
275
|
'--filter-estimates-missing[Select only items missing estimated_minutes]' \\
|
|
275
276
|
'--filter-resolution-missing[Select only terminal items missing resolution]' \\
|
|
@@ -325,7 +326,7 @@ ${R}
|
|
|
325
326
|
'--dep-remove[Dependency removal selector id=<id>,kind=<kind>,author=<author>,created_at=<timestamp>]:dep_remove' \\
|
|
326
327
|
'--replace-deps[Atomically replace dependencies with provided --dep values]' \\
|
|
327
328
|
'--replace-tests[Atomically replace linked tests with provided --test values]' \\
|
|
328
|
-
${
|
|
329
|
+
${H}
|
|
329
330
|
'--author[Mutation author]:author' \\
|
|
330
331
|
'--message[History message]:message' \\
|
|
331
332
|
'--force[Force override]' \\
|
|
@@ -334,7 +335,7 @@ ${z}
|
|
|
334
335
|
;;
|
|
335
336
|
close-many)
|
|
336
337
|
_arguments \\
|
|
337
|
-
${
|
|
338
|
+
${oa("closing",c,a,f)}
|
|
338
339
|
${R}
|
|
339
340
|
'--ids[Explicit comma-separated ID allowlist]:ids' \\
|
|
340
341
|
'--limit[Limit matched item count]:number' \\
|
|
@@ -1061,7 +1062,7 @@ ${b} '--json[Output JSON]' \\
|
|
|
1061
1062
|
esac
|
|
1062
1063
|
}
|
|
1063
1064
|
|
|
1064
|
-
compdef _pm pm`}function
|
|
1065
|
+
compdef _pm pm`}function Gd(e=[],t=[],n=!1,s={}){let o=os.filter(ve=>ve==="list"||ve.startsWith("list-")),r=o.join(" "),i=os.join(" "),a=e.length===0,c=is(e,s),d=as(s),m=a?"(__pm_type_choices)":c,p="(__pm_status_choices)",f=rs,g=ye(t),w=n||t.length>0,b=w?`'${g}'`:"'(__pm_tag_choices)'",v=le(o,s.command_flags?.list),h=le(["create"],s.command_flags?.create),A=le(["update"],s.command_flags?.update),R=le(["update-many"],s.command_flags?.["update-many"]),H=le(["search"],s.command_flags?.search),V=le(["calendar","cal"],s.command_flags?.calendar),Me=le(["context","ctx"],s.command_flags?.context);return`# Fish shell completion for pm
|
|
1065
1066
|
# Save to ~/.config/fish/completions/pm.fish
|
|
1066
1067
|
# or run: pm completion fish > ~/.config/fish/completions/pm.fish
|
|
1067
1068
|
|
|
@@ -1075,6 +1076,7 @@ complete -c pm -l output-include -d 'Retain comma-separated read fields or secti
|
|
|
1075
1076
|
complete -c pm -l output-limit -d 'Set the universal read row ceiling' -r
|
|
1076
1077
|
complete -c pm -l output-budget -d 'Set the universal estimated-token ceiling' -r
|
|
1077
1078
|
complete -c pm -l output-format -d 'Select the universal read encoding' -r -a 'toon json'
|
|
1079
|
+
complete -c pm -l output-session -d 'Carry cross-call read budget and served-item state' -r
|
|
1078
1080
|
complete -c pm -l no-changed-fields -d 'Omit changed_fields array from mutation output'
|
|
1079
1081
|
complete -c pm -l id-only -d 'Print only id and status for single-item mutation output'
|
|
1080
1082
|
complete -c pm -l pm-path -d 'Explicit tracker storage path for this command' -r
|
|
@@ -1113,11 +1115,11 @@ function __pm_tag_choices
|
|
|
1113
1115
|
' $resolved
|
|
1114
1116
|
end
|
|
1115
1117
|
`}
|
|
1116
|
-
${a?
|
|
1117
|
-
${
|
|
1118
|
+
${a?aa("type","completion-types",c):""}
|
|
1119
|
+
${aa("status","completion-statuses",d)}
|
|
1118
1120
|
|
|
1119
1121
|
# Subcommands
|
|
1120
|
-
${
|
|
1122
|
+
${Nd()}
|
|
1121
1123
|
|
|
1122
1124
|
# list* flags
|
|
1123
1125
|
for list_cmd in ${r}
|
|
@@ -1184,7 +1186,7 @@ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l completion -d 'Add
|
|
|
1184
1186
|
complete -c pm -n '__fish_seen_subcommand_from aggregate' -l sum -d 'Numeric field to sum per group' -r
|
|
1185
1187
|
complete -c pm -n '__fish_seen_subcommand_from aggregate' -l avg -d 'Numeric field to average per group' -r
|
|
1186
1188
|
complete -c pm -n '__fish_seen_subcommand_from aggregate' -l include-unparented -d 'Include unparented rows when grouping by parent'
|
|
1187
|
-
complete -c pm -n '__fish_seen_subcommand_from aggregate' -l status -d 'Filter by status' -r -a '${
|
|
1189
|
+
complete -c pm -n '__fish_seen_subcommand_from aggregate' -l status -d 'Filter by status' -r -a '${p}'
|
|
1188
1190
|
complete -c pm -n '__fish_seen_subcommand_from aggregate' -l type -d 'Filter by item type' -r -a '${m}'
|
|
1189
1191
|
complete -c pm -n '__fish_seen_subcommand_from aggregate' -l tag -d 'Filter by tag' -r -a ${b}
|
|
1190
1192
|
complete -c pm -n '__fish_seen_subcommand_from aggregate' -l priority -d 'Filter by priority' -r -a '0 1 2 3 4'
|
|
@@ -1203,7 +1205,7 @@ complete -c pm -n '__fish_seen_subcommand_from create' -s d -l description
|
|
|
1203
1205
|
complete -c pm -n '__fish_seen_subcommand_from create' -l type -d 'Item type' -r -a '${m}'
|
|
1204
1206
|
complete -c pm -n '__fish_seen_subcommand_from create' -l create-mode -d 'Create required-option policy mode' -r -a 'strict progressive'
|
|
1205
1207
|
complete -c pm -n '__fish_seen_subcommand_from create' -l schedule-preset -d 'Scheduling preset for Reminder/Meeting/Event' -r -a 'lightweight'
|
|
1206
|
-
complete -c pm -n '__fish_seen_subcommand_from create' -s s -l status -d 'Item status' -r -a '${
|
|
1208
|
+
complete -c pm -n '__fish_seen_subcommand_from create' -s s -l status -d 'Item status' -r -a '${p}'
|
|
1207
1209
|
complete -c pm -n '__fish_seen_subcommand_from create' -s p -l priority -d 'Priority (0-4)' -r -a '0 1 2 3 4'
|
|
1208
1210
|
complete -c pm -n '__fish_seen_subcommand_from create' -l tags -d 'Comma-separated tags' -r
|
|
1209
1211
|
complete -c pm -n '__fish_seen_subcommand_from create' -l add-tags -d 'Add tags additively without replacing existing' -r
|
|
@@ -1245,7 +1247,7 @@ complete -c pm -n '__fish_seen_subcommand_from update' -s t -l title
|
|
|
1245
1247
|
complete -c pm -n '__fish_seen_subcommand_from update' -s d -l description -d 'Item description' -r
|
|
1246
1248
|
complete -c pm -n '__fish_seen_subcommand_from update' -s b -l body -d 'Item body' -r
|
|
1247
1249
|
complete -c pm -n '__fish_seen_subcommand_from update' -l body-file -d 'Load the item body from a file' -r -F
|
|
1248
|
-
complete -c pm -n '__fish_seen_subcommand_from update' -s s -l status -d 'Item status' -r -a '${
|
|
1250
|
+
complete -c pm -n '__fish_seen_subcommand_from update' -s s -l status -d 'Item status' -r -a '${p}'
|
|
1249
1251
|
complete -c pm -n '__fish_seen_subcommand_from update' -l close-reason -d 'Set close reason' -r
|
|
1250
1252
|
complete -c pm -n '__fish_seen_subcommand_from update' -s p -l priority -d 'Priority (0-4)' -r -a '0 1 2 3 4'
|
|
1251
1253
|
complete -c pm -n '__fish_seen_subcommand_from update' -l type -d 'Item type' -r -a '${m}'
|
|
@@ -1285,7 +1287,7 @@ complete -c pm -n '__fish_seen_subcommand_from update' -l force
|
|
|
1285
1287
|
${A}
|
|
1286
1288
|
|
|
1287
1289
|
# update-many flags
|
|
1288
|
-
complete -c pm -n '__fish_seen_subcommand_from update-many' -l filter-status -d 'Filter by status before applying updates' -r -a '${
|
|
1290
|
+
complete -c pm -n '__fish_seen_subcommand_from update-many' -l filter-status -d 'Filter by status before applying updates' -r -a '${p}'
|
|
1289
1291
|
complete -c pm -n '__fish_seen_subcommand_from update-many' -l filter-type -d 'Filter by type before applying updates' -r -a '${m}'
|
|
1290
1292
|
complete -c pm -n '__fish_seen_subcommand_from update-many' -l filter-tag -d 'Filter by tag before applying updates' -r -a ${b}
|
|
1291
1293
|
complete -c pm -n '__fish_seen_subcommand_from update-many' -l filter-priority -d 'Filter by priority before applying updates' -r -a '0 1 2 3 4'
|
|
@@ -1430,7 +1432,7 @@ complete -c pm -n '__fish_seen_subcommand_from search' -l count -d 'Ret
|
|
|
1430
1432
|
complete -c pm -n '__fish_seen_subcommand_from search' -l include-linked -d 'Include linked content in scoring'
|
|
1431
1433
|
complete -c pm -n '__fish_seen_subcommand_from search' -l highlight -d 'Emit per-field matched-text snippets on each hit'
|
|
1432
1434
|
complete -c pm -n '__fish_seen_subcommand_from search' -l limit -d 'Max results' -r
|
|
1433
|
-
complete -c pm -n '__fish_seen_subcommand_from search' -l status -d 'Filter by status (open/closed/canceled, csv)' -r -a '${
|
|
1435
|
+
complete -c pm -n '__fish_seen_subcommand_from search' -l status -d 'Filter by status (open/closed/canceled, csv)' -r -a '${p}'
|
|
1434
1436
|
complete -c pm -n '__fish_seen_subcommand_from search' -l type -d 'Filter by type' -r -a '${m}'
|
|
1435
1437
|
complete -c pm -n '__fish_seen_subcommand_from search' -l tag -d 'Filter by tag' -r -a ${b}
|
|
1436
1438
|
complete -c pm -n '__fish_seen_subcommand_from search' -l tags -d 'Alias for --tag' -r -a ${b}
|
|
@@ -1468,7 +1470,7 @@ complete -c pm -n '__fish_seen_subcommand_from search' -l has-body -d
|
|
|
1468
1470
|
complete -c pm -n '__fish_seen_subcommand_from search' -l empty-body -d 'Select only items with empty body'
|
|
1469
1471
|
complete -c pm -n '__fish_seen_subcommand_from search' -l has-linked-command -d 'Select only items that have a linked command'
|
|
1470
1472
|
complete -c pm -n '__fish_seen_subcommand_from search' -l no-linked-command -d 'Select only items with no linked command'
|
|
1471
|
-
${
|
|
1473
|
+
${H}
|
|
1472
1474
|
|
|
1473
1475
|
# calendar flags
|
|
1474
1476
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l view -d 'Calendar view' -r -a 'agenda day week month'
|
|
@@ -1480,7 +1482,7 @@ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l full-period -d '
|
|
|
1480
1482
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l type -d 'Filter by type' -r -a '${m}'
|
|
1481
1483
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l tag -d 'Filter by tag' -r -a ${b}
|
|
1482
1484
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l priority -d 'Filter by priority' -r -a '0 1 2 3 4'
|
|
1483
|
-
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l status -d 'Filter by status' -r -a '${
|
|
1485
|
+
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l status -d 'Filter by status' -r -a '${p}'
|
|
1484
1486
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l assignee -d 'Filter by assignee' -r
|
|
1485
1487
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l assignee-filter -d 'Filter assignee presence' -r -a 'assigned unassigned'
|
|
1486
1488
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l sprint -d 'Filter by sprint' -r
|
|
@@ -1491,7 +1493,7 @@ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l recurrence-lookb
|
|
|
1491
1493
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l occurrence-limit -d 'Cap occurrences per recurring event' -r
|
|
1492
1494
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l limit -d 'Limit returned events' -r
|
|
1493
1495
|
complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l format -d 'Output override' -r -a 'markdown toon json'
|
|
1494
|
-
${
|
|
1496
|
+
${V}
|
|
1495
1497
|
|
|
1496
1498
|
# context flags
|
|
1497
1499
|
complete -c pm -n '__fish_seen_subcommand_from context ctx' -l date -d 'Anchor date/time (ISO/date string or relative)' -r
|
|
@@ -1772,6 +1774,7 @@ complete -c pm -n '__fish_seen_subcommand_from stats' -l by-assignee -d 'Lifecyc
|
|
|
1772
1774
|
complete -c pm -n '__fish_seen_subcommand_from stats' -l by-tag -d 'Lifecycle-bucketed breakdown grouped by tag'
|
|
1773
1775
|
complete -c pm -n '__fish_seen_subcommand_from stats' -l by-priority -d 'Lifecycle-bucketed breakdown grouped by priority'
|
|
1774
1776
|
complete -c pm -n '__fish_seen_subcommand_from stats' -l tag-prefix -d 'With --by-tag: only count tags with this prefix' -r
|
|
1777
|
+
complete -c pm -n '__fish_seen_subcommand_from stats' -l analytics -d 'Improvement ledger/history analytics JSON' -r
|
|
1775
1778
|
|
|
1776
1779
|
# append flags
|
|
1777
1780
|
complete -c pm -n '__fish_seen_subcommand_from append' -s b -l body -d 'Item body' -r
|
|
@@ -1816,7 +1819,7 @@ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l author -d '
|
|
|
1816
1819
|
complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l message -d 'History message' -r
|
|
1817
1820
|
|
|
1818
1821
|
# close-many flags
|
|
1819
|
-
complete -c pm -n '__fish_seen_subcommand_from close-many' -l filter-status -d 'Filter by status before closing' -r -a '${
|
|
1822
|
+
complete -c pm -n '__fish_seen_subcommand_from close-many' -l filter-status -d 'Filter by status before closing' -r -a '${p}'
|
|
1820
1823
|
complete -c pm -n '__fish_seen_subcommand_from close-many' -l filter-type -d 'Filter by type before closing' -r -a '${m}'
|
|
1821
1824
|
complete -c pm -n '__fish_seen_subcommand_from close-many' -l filter-tag -d 'Filter by tag before closing' -r -a ${b}
|
|
1822
1825
|
complete -c pm -n '__fish_seen_subcommand_from close-many' -l filter-priority -d 'Filter by priority before closing' -r -a '0 1 2 3 4'
|
|
@@ -1997,9 +2000,9 @@ for package_cmd in package packages
|
|
|
1997
2000
|
complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l ignore-global -d 'Alias for --isolated'
|
|
1998
2001
|
complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l strict-exit -d 'Return non-zero exit when doctor warnings are present'
|
|
1999
2002
|
complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l fail-on-warn -d 'Alias for --strict-exit (doctor)'
|
|
2000
|
-
end`}var
|
|
2001
|
-
`)}catch{}}function Hd(e){let t=(e??"keyword").trim().toLowerCase();if(t==="keyword")return"keyword";if(t==="semantic"||t==="hybrid")return t;throw new u("Reindex mode must be one of keyword|semantic|hybrid",_.USAGE)}async function Vd(e,t,n,s){let o=[];return{candidates:await Bs(e,t,n,o,s),warnings:o}}async function ls(e,t,n,s,o){let r=Ge(q()),i=[];for(let a of t)if(!(o&&!o.has(a.metadata.id))){if(typeof a.body=="string"){i.push({metadata:a.metadata,body:a.body});continue}try{let c=await Ud.readFile(a.item_path,"utf8"),d=qe(c,{format:a.item_format,schema:n,extensionFieldNames:r,onWarning:m=>s.push(m)});i.push({metadata:a.metadata,body:d.body})}catch{s.push(`item_list_item_read_failed:${Ne.relative(e,a.item_path)}`),i.push({metadata:a.metadata,body:""})}}return i}function Bd(e,t,n){let s=e.metadata;return{id:s.id,mode:t,updated_at:s.updated_at,corpus:Ws(e,{fields:n})}}var be=gs;function Wd(e){let t=q(),n=be(e.search?.provider);if(!n)return null;let s=Os(t,n);if(!s)return null;let o=s.runtime_definition??s.definition,r=be(o.name)??be(s.definition.name);if(!r)return null;let i=o.embedBatch,a=o.embed_batch,c=o.embed,d=typeof i=="function"?i:typeof a=="function"?a:void 0,m=typeof c=="function"?c:void 0;return!d&&!m?null:{name:r,embedBatch:d,embed:m}}function Yd(e){let t=q(),n=be(e.vector_store?.adapter);if(!n)return null;let s=$s(t,n);if(!s)return null;let o=s.runtime_definition??s.definition,r=be(o.name)??be(s.definition.name);if(!r)return null;let i=o.upsert,a=o.delete;return{adapterName:r,...typeof i=="function"?{upsert:i}:{},...typeof a=="function"?{delete:a}:{}}}function ds(e,t){if(!Array.isArray(e)||e.some(n=>typeof n!="number"||!Number.isFinite(n)))throw new u(`Invalid vector returned by ${t}`,_.GENERIC_FAILURE);return e}async function Jd(e,t,n){let s=t.search?.embedding_model?.trim()||"text-embedding-3-small";if(e.embedBatch){let r=await Promise.resolve(e.embedBatch({inputs:n,settings:t,model:s}));if(!Array.isArray(r))throw new u(`Extension search provider "${e.name}" embedBatch must return an array of vectors`,_.GENERIC_FAILURE);return r.map((i,a)=>ds(i,`extension search provider "${e.name}" embedBatch output at index ${a}`))}if(!e.embed)throw new u(`Extension search provider "${e.name}" does not implement embed/embedBatch`,_.GENERIC_FAILURE);let o=[];for(let[r,i]of n.entries()){let a=await Promise.resolve(e.embed({input:i,settings:t,model:s}));o.push(ds(a,`extension search provider "${e.name}" embed output at index ${r}`))}return o}function ma(e){return e.search?.embedding_model?.trim()||"text-embedding-3-small"}function da(e,t,n){let s=n?Ee(n.name,ma(e)):t?Ee(t.name,t.model):null;if(!s)throw new u("No embedding identity available for semantic reindex mode",_.USAGE);return s}function Kd(e,t){return Object.keys(e).filter(n=>!t.has(n)).sort((n,s)=>n.localeCompare(s))}async function la(e,t,n,s,o,r,i,a){let c=s?.name??n?.name,d=Ys(c,e.search.embedding_corpus_max_characters).maxCharacters,m=Bt(e),l=o.map(w=>Js(w,{providerName:c,maxCharacters:d,fields:m})),f=[],g=null;if(s)try{f=await Jd(s,e,l),g=Ee(s.name,ma(e))}catch(w){if(!n)throw new u(`Extension search provider "${s.name}" failed to generate embeddings: ${w instanceof Error?w.message:String(w)}`,_.GENERIC_FAILURE);r.push(`Extension search provider "${s.name}" failed; falling back to built-in provider (${w instanceof Error?w.message:String(w)})`)}if(f.length===0){if(!n)throw new u(`No embedding executor available for reindex mode '${t}'`,_.USAGE);let w=await Ks(n,e,l,{onProgress:b=>{b.phase==="complete"&&(i.batches_completed=b.batch_index),I(a,`embedding_batch_${b.phase} batch=${b.batch_index}/${b.batch_total} size=${b.batch_size} completed_inputs=${b.completed_inputs}/${b.total_inputs}`)}});r.push(...w.warnings),f=w.vectors,g=Ee(n.name,n.model)}if(I(a,`embedding_complete vectors=${f.length}`),f.length!==o.length)throw new u(`Embedding output size mismatch (expected ${o.length}, received ${f.length})`,_.GENERIC_FAILURE);if(!g)throw new u(`No embedding identity available for reindex mode '${t}'`,_.USAGE);return{vectors:f,embeddingIdentity:g}}async function Xd(e,t,n,s,o,r){let i=Object.keys(n);if(t){if(i.length>0&&t.delete)try{await Promise.resolve(t.delete({ids:i.sort((a,c)=>a.localeCompare(c)),settings:s}))}catch(a){throw new u(`Extension vector adapter "${t.adapterName}" failed to delete vectors during reindex reset: ${a instanceof Error?a.message:String(a)}`,_.GENERIC_FAILURE)}else i.length>0&&o.push(`search_semantic_reindex_reset_skipped:adapter=${t.adapterName}:known_ids=${i.length}`);if(!e)return}e&&await eo(e,i,{},r)}async function pa(e,t,n,s,o){if(n.length!==0){if(t){if(t.delete)try{await Promise.resolve(t.delete({ids:n,settings:s}))}catch(r){throw new u(`Extension vector adapter "${t.adapterName}" failed to delete orphan vectors during reindex: ${r instanceof Error?r.message:String(r)}`,_.GENERIC_FAILURE)}else o.push(`search_semantic_reindex_orphan_prune_skipped:adapter=${t.adapterName}:count=${n.length}`);if(!e)return}e&&await Qs(e,n)}}function Zd(e){return{enabled:e!=="keyword",stale_items:0,unchanged_items:0,embedded_items:0,vector_upserted:0,batches_completed:0}}function Qd(e,t,n){return{version:1,mode:e,generated_at:t,total_items:n.length,items:n.map(s=>({id:s.metadata.id,type:s.metadata.type,status:s.metadata.status,priority:s.metadata.priority,updated_at:s.metadata.updated_at}))}}function el(e){if(e.requestedMode==="keyword")return{activeEmbeddingProvider:null,activeVectorStore:null};let t=Vt(e.settings);if(!t.active&&!e.extensionEmbedding)throw new u(`Reindex mode '${e.requestedMode}' requires a configured embedding provider in settings.providers.openai/settings.providers.ollama or an extension provider selected by settings.search.provider`,_.USAGE);let n=Xs(e.settings,e.pmRoot);if(!n.active&&!e.extensionVectorAdapter)throw new u(`Reindex mode '${e.requestedMode}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,_.USAGE);return{activeEmbeddingProvider:t.active,activeVectorStore:n.active}}async function tl(e){let t=ee(e.settings,q()),n=await Vd(e.pmRoot,e.settings.item_format,t.type_to_folder,e.settings.schema);return{documentCandidates:n.candidates,warnings:[...n.warnings],metadataDocuments:n.candidates.map(s=>({metadata:s.metadata,body:typeof s.body=="string"?s.body:""}))}}async function nl(e){let t=await Yt(e.pmRoot);if(e.reindexWarnings.push(...t.warnings),e.forceFullSemantic&&e.reindexWarnings.push("search_semantic_reindex_full_ignored:mode_keyword"),!t.embedding)return;let n=(()=>{try{return da(e.settings,Vt(e.settings).active,e.extensionEmbedding)}catch{return null}})();n&&ze(t.embedding,n)&&(e.reindexWarnings.push("search_semantic_reindex_requires_rebuild:embedding_identity_changed"),e.reindexWarnings.push(qd))}async function sl(e){let t=await Yt(e.pmRoot);e.semanticWarnings.push(...t.warnings);let n=da(e.settings,e.activeEmbeddingProvider,e.extensionEmbedding),s=new Set(e.metadataDocuments.map(d=>d.metadata.id)),o=Kd(t.entries,s),r=ze(t.embedding,n);e.forceFullSemantic&&!r&&e.semanticWarnings.push("search_semantic_reindex_full_rebuild_forced");let i=e.forceFullSemantic||r?e.metadataDocuments:e.metadataDocuments.filter(d=>t.entries[d.metadata.id]!==d.metadata.updated_at),a=new Set(i.map(d=>d.metadata.id)),c=a.size>0?await ls(e.pmRoot,e.documentCandidates,e.settings.schema,e.reindexWarnings,a):[];return{ledgerEntries:t.entries,ledgerEmbedding:t.embedding,orphanIds:o,resetRequired:r,staleDocuments:c,freshDocuments:e.metadataDocuments.length-c.length}}async function ol(e){let t=new Set(e.metadataDocuments.map(o=>o.metadata.id)),n=await ls(e.pmRoot,e.documentCandidates,e.settings.schema,e.reindexWarnings,t);e.semanticSummary.stale_items=n.length,e.semanticSummary.unchanged_items=0,I(e.progressEnabled,`embedding_dimension_changed reset_items=${n.length}`);let s=await la(e.settings,e.requestedMode,e.activeEmbeddingProvider,e.extensionEmbedding,n,e.semanticWarnings,e.semanticSummary,e.progressEnabled);return{...s,staleDocuments:n,vectorDimension:Wt(s.vectors,"Reindex embeddings")}}async function rl(e){let t=await la(e.settings,e.requestedMode,e.activeEmbeddingProvider,e.extensionEmbedding,e.staleDocuments,e.semanticWarnings,e.semanticSummary,e.progressEnabled),n=t.vectors,s=t.embeddingIdentity,o=Wt(n,"Reindex embeddings");if(!(!e.resetRequired&&(ze(e.ledgerEmbedding,s)||no(e.ledgerEmbedding,o))))return{vectors:n,embeddingIdentity:s,staleDocuments:e.staleDocuments,vectorDimension:o,resetRequired:e.resetRequired};let i=await ol(e);return n=i.vectors,s=i.embeddingIdentity,o=i.vectorDimension,{vectors:n,embeddingIdentity:s,staleDocuments:i.staleDocuments,vectorDimension:o,resetRequired:!0}}async function il(e){if(e.extensionVectorAdapter)try{let t=e.extensionVectorAdapter.adapterName;if(I(e.progressEnabled,`vector_upsert_start adapter=${t} points=${e.points.length}`),typeof e.extensionVectorAdapter.upsert!="function")throw new u(`Extension vector adapter "${t}" does not support upserting vectors.`,_.USAGE);await Promise.resolve(e.extensionVectorAdapter.upsert({points:e.points,settings:e.settings})),e.semanticSummary.vector_upserted=e.points.length,I(e.progressEnabled,`vector_upsert_complete adapter=${t}`);return}catch(t){if(t instanceof u)throw t;if(!e.activeVectorStore)throw new u(`Extension vector adapter "${e.extensionVectorAdapter.adapterName}" failed to upsert vectors: ${t instanceof Error?t.message:String(t)}`,_.GENERIC_FAILURE);e.semanticWarnings.push(`Extension vector adapter "${e.extensionVectorAdapter.adapterName}" failed; falling back to built-in vector store (${t instanceof Error?t.message:String(t)})`),I(e.progressEnabled,"vector_upsert_fallback built_in_store")}if(e.activeVectorStore){I(e.progressEnabled,`vector_upsert_start adapter=${e.activeVectorStore.name} points=${e.points.length}`),await Zs(e.activeVectorStore,e.points),e.semanticSummary.vector_upserted=e.points.length,I(e.progressEnabled,`vector_upsert_complete adapter=${e.activeVectorStore.name}`);return}throw new u(`No vector upsert executor available for reindex mode '${e.requestedMode}'`,_.USAGE)}function al(e,t){return e.map((n,s)=>({id:n.metadata.id,vector:ds(t[s],`reindex embeddings output at index ${s}`),payload:{id:n.metadata.id,type:n.metadata.type,status:n.metadata.status,priority:n.metadata.priority,updated_at:n.metadata.updated_at}}))}async function cl(e){I(e.progressEnabled,`embedding_start items=${e.plan.staleDocuments.length} unchanged_items=${e.plan.freshDocuments}`);let t=await rl({pmRoot:e.pmRoot,settings:e.settings,requestedMode:e.requestedMode,activeEmbeddingProvider:e.activeEmbeddingProvider,extensionEmbedding:e.extensionEmbedding,documentCandidates:e.documentCandidates,metadataDocuments:e.metadataDocuments,staleDocuments:e.plan.staleDocuments,ledgerEmbedding:e.plan.ledgerEmbedding,resetRequired:e.plan.resetRequired,semanticWarnings:e.semanticWarnings,reindexWarnings:e.reindexWarnings,semanticSummary:e.semanticSummary,progressEnabled:e.progressEnabled});t.resetRequired?(I(e.progressEnabled,"vector_reset_start"),await Xd(e.activeVectorStore,e.extensionVectorAdapter,e.plan.ledgerEntries,e.settings,e.semanticWarnings,e.plan.ledgerEmbedding?t.vectorDimension:void 0),I(e.progressEnabled,"vector_reset_complete")):await pa(e.activeVectorStore,e.extensionVectorAdapter,e.plan.orphanIds,e.settings,e.semanticWarnings);let n=al(t.staleDocuments,t.vectors);return e.semanticSummary.embedded_items=t.vectors.length,await il({requestedMode:e.requestedMode,activeVectorStore:e.activeVectorStore,extensionVectorAdapter:e.extensionVectorAdapter,settings:e.settings,points:n,semanticWarnings:e.semanticWarnings,semanticSummary:e.semanticSummary,progressEnabled:e.progressEnabled}),{staleDocuments:t.staleDocuments,embeddingMetadata:to(t.embeddingIdentity,t.vectorDimension)}}async function ml(e){let t=await sl(e);e.semanticSummary.stale_items=t.staleDocuments.length,e.semanticSummary.unchanged_items=t.freshDocuments;let n=Object.fromEntries(e.metadataDocuments.map(r=>[r.metadata.id,r.metadata.updated_at]));if(I(e.progressEnabled,`semantic_stale_items stale=${t.staleDocuments.length} total=${e.metadataDocuments.length} unchanged=${t.freshDocuments} full=${e.forceFullSemantic||t.resetRequired}`),t.staleDocuments.length===0)return I(e.progressEnabled,`embedding_skipped unchanged_items=${t.freshDocuments}`),e.semanticWarnings.push(`search_semantic_reindex_skipped_unchanged:count=${t.freshDocuments}`),await pa(e.activeVectorStore,e.extensionVectorAdapter,t.orphanIds,e.settings,e.semanticWarnings),{documentsForKeywordArtifacts:e.documentsForKeywordArtifacts,vectorizationLedgerEntries:n,vectorizationEmbeddingMetadata:t.ledgerEmbedding};let s=await cl({...e,plan:t});t.freshDocuments>0&&e.semanticWarnings.push(`search_semantic_reindex_skipped_unchanged:count=${t.freshDocuments}`);let o=new Map(s.staleDocuments.map(r=>[r.metadata.id,r]));return{documentsForKeywordArtifacts:e.metadataDocuments.map(r=>o.get(r.metadata.id)??r),vectorizationLedgerEntries:n,vectorizationEmbeddingMetadata:s.embeddingMetadata}}async function dl(e){let t=Ne.join(e.pmRoot,cs),n=Ne.join(e.pmRoot,ms),s=Bt(e.settings),o=e.documentsForKeywordArtifacts.map(i=>JSON.stringify(Bd(i,e.mode,s))).join(`
|
|
2003
|
+
end`}var Ud={bash:'Add to ~/.bashrc or ~/.bash_profile: eval "$(pm completion bash)"',zsh:'Add to ~/.zshrc: eval "$(pm completion zsh)"',fish:"Run: pm completion fish > ~/.config/fish/completions/pm.fish"};function qd(e,t=[],n=[],s=!1,o={}){let r=e.trim().toLowerCase();if(!ta.includes(r))throw new u(`Unknown shell: "${e}". Supported shells: ${ta.join(", ")}.`,_.USAGE);let i=r,a;return i==="bash"?a=Dd(t,n,s,o):i==="zsh"?a=jd(t,n,s,o):a=Gd(t,n,s,o),{shell:i,script:a,setup_hint:Ud[i]}}import zd from"node:fs/promises";import Ne 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]="fc124f85-8d28-508b-a3f7-2fe767382197")}catch{}})();var cs="index/manifest.json",ms="search/embeddings.jsonl",Hd="Provider or model has changed since last index. Run pm reindex --mode semantic to rebuild.";function Vd(e){return e.progress===!0||process.stderr.isTTY===!0}function I(e,t){if(e)try{process.stderr.write(`[pm reindex] ${t}
|
|
2004
|
+
`)}catch{}}function Bd(e){let t=(e??"keyword").trim().toLowerCase();if(t==="keyword")return"keyword";if(t==="semantic"||t==="hybrid")return t;throw new u("Reindex mode must be one of keyword|semantic|hybrid",_.USAGE)}async function Wd(e,t,n,s){let o=[];return{candidates:await Bs(e,t,n,o,s),warnings:o}}async function ls(e,t,n,s,o){let r=Ge(q()),i=[];for(let a of t)if(!(o&&!o.has(a.metadata.id))){if(typeof a.body=="string"){i.push({metadata:a.metadata,body:a.body});continue}try{let c=await zd.readFile(a.item_path,"utf8"),d=qe(c,{format:a.item_format,schema:n,extensionFieldNames:r,onWarning:m=>s.push(m)});i.push({metadata:a.metadata,body:d.body})}catch{s.push(`item_list_item_read_failed:${Ne.relative(e,a.item_path)}`),i.push({metadata:a.metadata,body:""})}}return i}function Yd(e,t,n){let s=e.metadata;return{id:s.id,mode:t,updated_at:s.updated_at,corpus:Ws(e,{fields:n})}}var be=gs;function Jd(e){let t=q(),n=be(e.search?.provider);if(!n)return null;let s=Os(t,n);if(!s)return null;let o=s.runtime_definition??s.definition,r=be(o.name)??be(s.definition.name);if(!r)return null;let i=o.embedBatch,a=o.embed_batch,c=o.embed,d=typeof i=="function"?i:typeof a=="function"?a:void 0,m=typeof c=="function"?c:void 0;return!d&&!m?null:{name:r,embedBatch:d,embed:m}}function Kd(e){let t=q(),n=be(e.vector_store?.adapter);if(!n)return null;let s=$s(t,n);if(!s)return null;let o=s.runtime_definition??s.definition,r=be(o.name)??be(s.definition.name);if(!r)return null;let i=o.upsert,a=o.delete;return{adapterName:r,...typeof i=="function"?{upsert:i}:{},...typeof a=="function"?{delete:a}:{}}}function ds(e,t){if(!Array.isArray(e)||e.some(n=>typeof n!="number"||!Number.isFinite(n)))throw new u(`Invalid vector returned by ${t}`,_.GENERIC_FAILURE);return e}async function Xd(e,t,n){let s=t.search?.embedding_model?.trim()||"text-embedding-3-small";if(e.embedBatch){let r=await Promise.resolve(e.embedBatch({inputs:n,settings:t,model:s}));if(!Array.isArray(r))throw new u(`Extension search provider "${e.name}" embedBatch must return an array of vectors`,_.GENERIC_FAILURE);return r.map((i,a)=>ds(i,`extension search provider "${e.name}" embedBatch output at index ${a}`))}if(!e.embed)throw new u(`Extension search provider "${e.name}" does not implement embed/embedBatch`,_.GENERIC_FAILURE);let o=[];for(let[r,i]of n.entries()){let a=await Promise.resolve(e.embed({input:i,settings:t,model:s}));o.push(ds(a,`extension search provider "${e.name}" embed output at index ${r}`))}return o}function la(e){return e.search?.embedding_model?.trim()||"text-embedding-3-small"}function pa(e,t,n){let s=n?Ee(n.name,la(e)):t?Ee(t.name,t.model):null;if(!s)throw new u("No embedding identity available for semantic reindex mode",_.USAGE);return s}function Zd(e,t){return Object.keys(e).filter(n=>!t.has(n)).sort((n,s)=>n.localeCompare(s))}async function ua(e,t,n,s,o,r,i,a){let c=s?.name??n?.name,d=Ys(c,e.search.embedding_corpus_max_characters).maxCharacters,m=Bt(e),p=o.map(w=>Js(w,{providerName:c,maxCharacters:d,fields:m})),f=[],g=null;if(s)try{f=await Xd(s,e,p),g=Ee(s.name,la(e))}catch(w){if(!n)throw new u(`Extension search provider "${s.name}" failed to generate embeddings: ${w instanceof Error?w.message:String(w)}`,_.GENERIC_FAILURE);r.push(`Extension search provider "${s.name}" failed; falling back to built-in provider (${w instanceof Error?w.message:String(w)})`)}if(f.length===0){if(!n)throw new u(`No embedding executor available for reindex mode '${t}'`,_.USAGE);let w=await Ks(n,e,p,{onProgress:b=>{b.phase==="complete"&&(i.batches_completed=b.batch_index),I(a,`embedding_batch_${b.phase} batch=${b.batch_index}/${b.batch_total} size=${b.batch_size} completed_inputs=${b.completed_inputs}/${b.total_inputs}`)}});r.push(...w.warnings),f=w.vectors,g=Ee(n.name,n.model)}if(I(a,`embedding_complete vectors=${f.length}`),f.length!==o.length)throw new u(`Embedding output size mismatch (expected ${o.length}, received ${f.length})`,_.GENERIC_FAILURE);if(!g)throw new u(`No embedding identity available for reindex mode '${t}'`,_.USAGE);return{vectors:f,embeddingIdentity:g}}async function Qd(e,t,n,s,o,r){let i=Object.keys(n);if(t){if(i.length>0&&t.delete)try{await Promise.resolve(t.delete({ids:i.sort((a,c)=>a.localeCompare(c)),settings:s}))}catch(a){throw new u(`Extension vector adapter "${t.adapterName}" failed to delete vectors during reindex reset: ${a instanceof Error?a.message:String(a)}`,_.GENERIC_FAILURE)}else i.length>0&&o.push(`search_semantic_reindex_reset_skipped:adapter=${t.adapterName}:known_ids=${i.length}`);if(!e)return}e&&await eo(e,i,{},r)}async function fa(e,t,n,s,o){if(n.length!==0){if(t){if(t.delete)try{await Promise.resolve(t.delete({ids:n,settings:s}))}catch(r){throw new u(`Extension vector adapter "${t.adapterName}" failed to delete orphan vectors during reindex: ${r instanceof Error?r.message:String(r)}`,_.GENERIC_FAILURE)}else o.push(`search_semantic_reindex_orphan_prune_skipped:adapter=${t.adapterName}:count=${n.length}`);if(!e)return}e&&await Qs(e,n)}}function el(e){return{enabled:e!=="keyword",stale_items:0,unchanged_items:0,embedded_items:0,vector_upserted:0,batches_completed:0}}function tl(e,t,n){return{version:1,mode:e,generated_at:t,total_items:n.length,items:n.map(s=>({id:s.metadata.id,type:s.metadata.type,status:s.metadata.status,priority:s.metadata.priority,updated_at:s.metadata.updated_at}))}}function nl(e){if(e.requestedMode==="keyword")return{activeEmbeddingProvider:null,activeVectorStore:null};let t=Vt(e.settings);if(!t.active&&!e.extensionEmbedding)throw new u(`Reindex mode '${e.requestedMode}' requires a configured embedding provider in settings.providers.openai/settings.providers.ollama or an extension provider selected by settings.search.provider`,_.USAGE);let n=Xs(e.settings,e.pmRoot);if(!n.active&&!e.extensionVectorAdapter)throw new u(`Reindex mode '${e.requestedMode}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,_.USAGE);return{activeEmbeddingProvider:t.active,activeVectorStore:n.active}}async function sl(e){let t=ee(e.settings,q()),n=await Wd(e.pmRoot,e.settings.item_format,t.type_to_folder,e.settings.schema);return{documentCandidates:n.candidates,warnings:[...n.warnings],metadataDocuments:n.candidates.map(s=>({metadata:s.metadata,body:typeof s.body=="string"?s.body:""}))}}async function ol(e){let t=await Yt(e.pmRoot);if(e.reindexWarnings.push(...t.warnings),e.forceFullSemantic&&e.reindexWarnings.push("search_semantic_reindex_full_ignored:mode_keyword"),!t.embedding)return;let n=(()=>{try{return pa(e.settings,Vt(e.settings).active,e.extensionEmbedding)}catch{return null}})();n&&ze(t.embedding,n)&&(e.reindexWarnings.push("search_semantic_reindex_requires_rebuild:embedding_identity_changed"),e.reindexWarnings.push(Hd))}async function rl(e){let t=await Yt(e.pmRoot);e.semanticWarnings.push(...t.warnings);let n=pa(e.settings,e.activeEmbeddingProvider,e.extensionEmbedding),s=new Set(e.metadataDocuments.map(d=>d.metadata.id)),o=Zd(t.entries,s),r=ze(t.embedding,n);e.forceFullSemantic&&!r&&e.semanticWarnings.push("search_semantic_reindex_full_rebuild_forced");let i=e.forceFullSemantic||r?e.metadataDocuments:e.metadataDocuments.filter(d=>t.entries[d.metadata.id]!==d.metadata.updated_at),a=new Set(i.map(d=>d.metadata.id)),c=a.size>0?await ls(e.pmRoot,e.documentCandidates,e.settings.schema,e.reindexWarnings,a):[];return{ledgerEntries:t.entries,ledgerEmbedding:t.embedding,orphanIds:o,resetRequired:r,staleDocuments:c,freshDocuments:e.metadataDocuments.length-c.length}}async function il(e){let t=new Set(e.metadataDocuments.map(o=>o.metadata.id)),n=await ls(e.pmRoot,e.documentCandidates,e.settings.schema,e.reindexWarnings,t);e.semanticSummary.stale_items=n.length,e.semanticSummary.unchanged_items=0,I(e.progressEnabled,`embedding_dimension_changed reset_items=${n.length}`);let s=await ua(e.settings,e.requestedMode,e.activeEmbeddingProvider,e.extensionEmbedding,n,e.semanticWarnings,e.semanticSummary,e.progressEnabled);return{...s,staleDocuments:n,vectorDimension:Wt(s.vectors,"Reindex embeddings")}}async function al(e){let t=await ua(e.settings,e.requestedMode,e.activeEmbeddingProvider,e.extensionEmbedding,e.staleDocuments,e.semanticWarnings,e.semanticSummary,e.progressEnabled),n=t.vectors,s=t.embeddingIdentity,o=Wt(n,"Reindex embeddings");if(!(!e.resetRequired&&(ze(e.ledgerEmbedding,s)||no(e.ledgerEmbedding,o))))return{vectors:n,embeddingIdentity:s,staleDocuments:e.staleDocuments,vectorDimension:o,resetRequired:e.resetRequired};let i=await il(e);return n=i.vectors,s=i.embeddingIdentity,o=i.vectorDimension,{vectors:n,embeddingIdentity:s,staleDocuments:i.staleDocuments,vectorDimension:o,resetRequired:!0}}async function cl(e){if(e.extensionVectorAdapter)try{let t=e.extensionVectorAdapter.adapterName;if(I(e.progressEnabled,`vector_upsert_start adapter=${t} points=${e.points.length}`),typeof e.extensionVectorAdapter.upsert!="function")throw new u(`Extension vector adapter "${t}" does not support upserting vectors.`,_.USAGE);await Promise.resolve(e.extensionVectorAdapter.upsert({points:e.points,settings:e.settings})),e.semanticSummary.vector_upserted=e.points.length,I(e.progressEnabled,`vector_upsert_complete adapter=${t}`);return}catch(t){if(t instanceof u)throw t;if(!e.activeVectorStore)throw new u(`Extension vector adapter "${e.extensionVectorAdapter.adapterName}" failed to upsert vectors: ${t instanceof Error?t.message:String(t)}`,_.GENERIC_FAILURE);e.semanticWarnings.push(`Extension vector adapter "${e.extensionVectorAdapter.adapterName}" failed; falling back to built-in vector store (${t instanceof Error?t.message:String(t)})`),I(e.progressEnabled,"vector_upsert_fallback built_in_store")}if(e.activeVectorStore){I(e.progressEnabled,`vector_upsert_start adapter=${e.activeVectorStore.name} points=${e.points.length}`),await Zs(e.activeVectorStore,e.points),e.semanticSummary.vector_upserted=e.points.length,I(e.progressEnabled,`vector_upsert_complete adapter=${e.activeVectorStore.name}`);return}throw new u(`No vector upsert executor available for reindex mode '${e.requestedMode}'`,_.USAGE)}function ml(e,t){return e.map((n,s)=>({id:n.metadata.id,vector:ds(t[s],`reindex embeddings output at index ${s}`),payload:{id:n.metadata.id,type:n.metadata.type,status:n.metadata.status,priority:n.metadata.priority,updated_at:n.metadata.updated_at}}))}async function dl(e){I(e.progressEnabled,`embedding_start items=${e.plan.staleDocuments.length} unchanged_items=${e.plan.freshDocuments}`);let t=await al({pmRoot:e.pmRoot,settings:e.settings,requestedMode:e.requestedMode,activeEmbeddingProvider:e.activeEmbeddingProvider,extensionEmbedding:e.extensionEmbedding,documentCandidates:e.documentCandidates,metadataDocuments:e.metadataDocuments,staleDocuments:e.plan.staleDocuments,ledgerEmbedding:e.plan.ledgerEmbedding,resetRequired:e.plan.resetRequired,semanticWarnings:e.semanticWarnings,reindexWarnings:e.reindexWarnings,semanticSummary:e.semanticSummary,progressEnabled:e.progressEnabled});t.resetRequired?(I(e.progressEnabled,"vector_reset_start"),await Qd(e.activeVectorStore,e.extensionVectorAdapter,e.plan.ledgerEntries,e.settings,e.semanticWarnings,e.plan.ledgerEmbedding?t.vectorDimension:void 0),I(e.progressEnabled,"vector_reset_complete")):await fa(e.activeVectorStore,e.extensionVectorAdapter,e.plan.orphanIds,e.settings,e.semanticWarnings);let n=ml(t.staleDocuments,t.vectors);return e.semanticSummary.embedded_items=t.vectors.length,await cl({requestedMode:e.requestedMode,activeVectorStore:e.activeVectorStore,extensionVectorAdapter:e.extensionVectorAdapter,settings:e.settings,points:n,semanticWarnings:e.semanticWarnings,semanticSummary:e.semanticSummary,progressEnabled:e.progressEnabled}),{staleDocuments:t.staleDocuments,embeddingMetadata:to(t.embeddingIdentity,t.vectorDimension)}}async function ll(e){let t=await rl(e);e.semanticSummary.stale_items=t.staleDocuments.length,e.semanticSummary.unchanged_items=t.freshDocuments;let n=Object.fromEntries(e.metadataDocuments.map(r=>[r.metadata.id,r.metadata.updated_at]));if(I(e.progressEnabled,`semantic_stale_items stale=${t.staleDocuments.length} total=${e.metadataDocuments.length} unchanged=${t.freshDocuments} full=${e.forceFullSemantic||t.resetRequired}`),t.staleDocuments.length===0)return I(e.progressEnabled,`embedding_skipped unchanged_items=${t.freshDocuments}`),e.semanticWarnings.push(`search_semantic_reindex_skipped_unchanged:count=${t.freshDocuments}`),await fa(e.activeVectorStore,e.extensionVectorAdapter,t.orphanIds,e.settings,e.semanticWarnings),{documentsForKeywordArtifacts:e.documentsForKeywordArtifacts,vectorizationLedgerEntries:n,vectorizationEmbeddingMetadata:t.ledgerEmbedding};let s=await dl({...e,plan:t});t.freshDocuments>0&&e.semanticWarnings.push(`search_semantic_reindex_skipped_unchanged:count=${t.freshDocuments}`);let o=new Map(s.staleDocuments.map(r=>[r.metadata.id,r]));return{documentsForKeywordArtifacts:e.metadataDocuments.map(r=>o.get(r.metadata.id)??r),vectorizationLedgerEntries:n,vectorizationEmbeddingMetadata:s.embeddingMetadata}}async function pl(e){let t=Ne.join(e.pmRoot,cs),n=Ne.join(e.pmRoot,ms),s=Bt(e.settings),o=e.documentsForKeywordArtifacts.map(i=>JSON.stringify(Yd(i,e.mode,s))).join(`
|
|
2002
2005
|
`);I(e.progressEnabled,"writing keyword artifacts"),await Q(t,`${JSON.stringify(e.manifest,null,2)}
|
|
2003
2006
|
`),await Q(n,`${o}
|
|
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-
|
|
2007
|
+
`);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 ul(e,t){let n=Bd(e.mode),s=Vd(e),o=e.full===!0;I(s,`start mode=${n}`);let r=F(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,z(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=Jd(i),d=Kd(i),m=nl({requestedMode:n,pmRoot:r,settings:i,extensionEmbedding:c,extensionVectorAdapter:d}),p=n;I(s,"loading item corpus");let f=await sl({pmRoot:r,settings:i}),g=f.warnings,{documentCandidates:w,metadataDocuments:b}=f;I(s,`loaded_items=${b.length}`);let v=k(),h=tl(p,v,b),A=Ne.join(r,cs),R=Ne.join(r,ms),H=p==="keyword"?await ls(r,w,i.schema,g):b,V=[],Me={},_t=null,ve=el(p);if(p==="keyword"&&await ol({pmRoot:r,settings:i,forceFullSemantic:o,extensionEmbedding:c,reindexWarnings:g}),p!=="keyword"){let ht=await ll({pmRoot:r,settings:i,requestedMode:n,activeEmbeddingProvider:m.activeEmbeddingProvider,activeVectorStore:m.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:d,documentCandidates:w,metadataDocuments:b,documentsForKeywordArtifacts:H,forceFullSemantic:o,reindexWarnings:g,semanticWarnings:V,semanticSummary:ve,progressEnabled:s});H=ht.documentsForKeywordArtifacts,Me=ht.vectorizationLedgerEntries,_t=ht.vectorizationEmbeddingMetadata}let xa=await pl({pmRoot:r,mode:p,manifest:h,documentsForKeywordArtifacts:H,settings:i,vectorizationLedgerEntries:Me,vectorizationEmbeddingMetadata:_t,progressEnabled:s}),Ea=[...await oe({path:A,scope:"project",op:"reindex:manifest"}),...await oe({path:R,scope:"project",op:"reindex:embeddings"}),...await Cs({mode:p,total_items:b.length})];return I(s,"done"),{ok:!0,mode:p,total_items:b.length,semantic:ve,artifacts:{manifest:cs,embeddings:ms},warnings:[...g,...V,...xa,...Ea],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]="42339e0d-ca3c-505f-8b98-acec81158b6e")}catch{}})();var ba=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[ba]=!0,n}run(t,n={}){return kl({...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})}packageMigrate(t={}){return this.package(void 0,{...t,migrate:!0})}upgrade(t,n={}){return this.runTyped("upgrade",{...t===void 0?{}:{target:t},options:n})}};function Hh(e={},t={}){return new y(t).context(e)}function Vh(e={},t={}){return new y(t).list(e)}function Bh(e,t={},n={}){return new y(n).search(e,t)}function Wh(e,t={},n={}){return new y(n).get(e,t)}function Yh(e={},t={}){return new y(t).next(e)}function Jh(e={},t={}){return new y(t).aggregate(e)}function Kh(e={},t={}){return new y(t).stats(e)}function Xh(e={},t={}){return new y(t).duplicates(e)}function Zh(e,t={},n={}){return new y(n).comments(e,t)}function Qh(e,t={},n={}){return new y(n).notes(e,t)}function eg(e,t={},n={}){return new y(n).learnings(e,t)}function tg(e,t={},n={}){return new y(n).files(e,t)}function ng(e,t={},n={}){return new y(n).filesDiscover(e,t)}function sg(e,t={}){return new y(t).filesLookup(e)}function og(e,t={},n={}){return new y(n).docs(e,t)}function rg(e,t={},n={}){return new y(n).deps(e,t)}function ig(e,t={},n={},s={}){return new y(s).graph(e,t,n)}function ag(e,t,n={},s={}){return new y(s).append(e,t,n)}function cg(e,t={},n={}){return new y(n).init(e,t)}function mg(e,t,n,s,o={},r={}){return new y(r).config(e,t,n,s,o)}function dg(e,t={},n={}){return new y(n).schema(e,t)}function lg(e={}){return new y(e).schemaList()}function pg(e,t={}){return new y(t).schemaShow(e)}function ug(e,t={},n={}){return new y(n).schemaAddType(e,t)}function fg(e,t={},n={}){return new y(n).schemaRemoveType(e,t)}function _g(e,t={},n={}){return new y(n).schemaAddStatus(e,t)}function hg(e,t={},n={}){return new y(n).schemaRemoveStatus(e,t)}function gg(e,t={},n={}){return new y(n).schemaAddField(e,t)}function yg(e,t={},n={}){return new y(n).schemaRemoveField(e,t)}function bg(e={}){return new y(e).schemaListFields()}function wg(e,t={}){return new y(t).schemaShowField(e)}function vg(e,t={},n={}){return new y(n).schemaApplyPreset(e,t)}function kg(e={},t={}){return new y(t).schemaInferTypes(e)}function Sg(e,t,n,s={}){return new y(s).schemaRenameType(e,t,n)}function xg(e,t,n,s,o={}){return new y(o).schemaRenameField(e,t,n,s)}function Eg(e,t,n,s={}){return new y(s).schemaRemapStatus(e,t,n)}function Ag(e,t={}){return new y(t).schemaShowStatus(e)}function Ig(e,t={},n={}){return new y(n).profile(e,t)}function Rg(e={}){return new y(e).profileList()}function Cg(e,t={}){return new y(t).profileShow(e)}function Tg(e,t={},n={}){return new y(n).profileApply(e,t)}function Og(e,t={}){return new y(t).profileLint(e)}function $g(e={},t={}){return new y(t).validate(e)}function Fg(e={},t={}){return new y(t).health(e)}function Pg(e={},t={}){return new y(t).gc(e)}function Lg(e,t,n={}){return new y(n).historyRedact(e,t)}function Ng(e,t={},n={}){return new y(n).historyRepair(e,t)}function Mg(e={},t={}){return new y(t).historyRepairAll(e)}function Dg(e,t={},n={}){return new y(n).historyCompact(e,t)}function jg(e,t={}){return new y(t).historyCompactBulk(e)}function Gg(e={},t={}){return new y(t).create(e)}function Ug(e,t={},n={}){return new y(n).update(e,t)}function qg(e,t,n={},s={}){return new y(s).close(e,t,n)}function zg(e,t={},n={}){return new y(n).claim(e,t)}function Hg(e={},t={}){return new y(t).claimNext(e)}function Vg(e,t={},n={}){return new y(n).release(e,t)}function Bg(e,t={},n={}){return new y(n).copy(e,t)}function Wg(e,t={},n={}){return new y(n).delete(e,t)}function Yg(e,t,n={},s={}){return new y(s).restore(e,t,n)}function Jg(e,t={},n={}){return new y(n).focus(e,t)}function Kg(e,t={},n={}){return new y(n).startTask(e,t)}function Xg(e,t={},n={}){return new y(n).pauseTask(e,t)}function Zg(e,t,n={},s={}){return new y(s).closeTask(e,t,n)}function Qg(e,t={},n={}){return new y(n).extension(e,t)}function ey(e={},t={}){return new y(t).extensionList(e)}function ty(e,t={},n={}){return new y(n).extensionActivate(e,t)}function ny(e,t={},n={}){return new y(n).extensionDeactivate(e,t)}function sy(e,t={},n={}){return new y(n).package(e,t)}function oy(e={},t={}){return new y(t).packageList(e)}function ry(e,t={},n={}){return new y(n).packageInstall(e,t)}function iy(e,t={},n={}){return new y(n).packageUninstall(e,t)}function ay(e={},t={}){return new y(t).packageDoctor(e)}function cy(e,t={},n={}){return new y(n).packageManage(e,t)}function my(e,t={},n={}){return new y(n).packageDescribe(e,t)}function dy(e={},t={}){return new y(t).packageReload(e)}function ly(e={},t={}){return new y(t).packageCatalog(e)}function py(e,t={},n={}){return new y(n).packageActivate(e,t)}function uy(e,t={},n={}){return new y(n).packageDeactivate(e,t)}function fy(e,t={},n={}){return new y(n).upgrade(e,t)}function _l(e,t,n){return JSON.stringify([_a.resolve(e),_a.resolve(n??process.cwd()),t.extensions.enabled,t.extensions.disabled,t.extensions.policy])}async function hl(e,t,n){let s=_l(e,t,n);return ii(s,()=>np(e,t,n))}async function _y(e,t={}){let n=await D(e),s=t.extensionRegistrations??(t.noExtensions===!0?null:await hl(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 hy(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=l(e,t);if(!n)throw new u(`Missing required argument: ${t}`,64);return n}var ha=Is(),wa=new fl;function ut(){Rt(ws()),Ct(vs()),Tt(ks()),Ot(Ss()),$t(xs()),Ft(Es()),Pt(As())}async function va(e,t,n,s){return Rs(()=>t===void 0?ha.read(()=>ga(e,n,s)):ha.write(()=>yl(t,()=>ga(e,n,s))))}async function gy(e,t){let n=e.cwd,s=n??process.cwd();return va(st({path:e.path,noExtensions:e.noExtensions}),n,s,()=>wa.run(!0,t))}async function ga(e,t,n){let s=F(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 gl(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:T(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 yl(e,t){let n=process.cwd();process.chdir(e);try{return await t()}finally{process.chdir(n)}}var bl=new Set(["activity","aggregate","context","contracts","deps","files-discover","get","graph","health","history","list","next","search","stats","telemetry","validate"]);function wl(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 vl(e){return!bl.has(se(e))}async function kl(e){let t=wl(e),n=st(t.args),s=vl(t.action),o=l(t.args,"cwd"),r=o??process.cwd();try{return e[ba]===!0||wa.getStore()===!0?await ya(t.action,t.args,n,null):await va(n,o,r,i=>ya(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 l(e.args,"target")??l(e.options,"target")}function E(e,t=e.options){return e.id??Y(t,"id")}async function Sl(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(l(e.args,"status")??l(t,"status"),t,e.global),t)}async function xl(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 El(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 Al(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 Il(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 Rl(e){let{changedFields:t,idOnly:n,runnerOptions:s}=W(e.args,e.options),o=l(e.args,"reason")??l(e.args,"text")??l(s,"reason")??l(s,"text");return J(await We(E(e,s),o,s,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}function Cl(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 Tl(e){let t=T(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:$(e.options.limit,"files lookup limit"),offset:$(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 Ol(e){return Xr({subcommand:l(e.args,"subcommand")??l(e.options,"subcommand"),limit:Ni(e.args,e.options)},e.global)}function $l(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 Fl(e){let t=l(e.args,"configAction")??l(e.options,"configAction")??l(e.options,"action");if(t===void 0)throw new u("Missing required argument: configAction",64);return Ar(l(e.args,"scope")??l(e.options,"scope")??"project",t,l(e.args,"key")??l(e.options,"key"),e.options,e.global,l(e.args,"value")??l(e.options,"value"))}function Pl(e){let t={...e.options};return t.compact===void 0&&(t.compact=t.full!==!0),delete t.full,zo(t,e.global)}function Ll(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 Nl(e){let t=l(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:Ml(e),reorderTo:Ll(n.reorderTo??e.args.reorderTo,"plan reorderTo"),options:e.options,global:e.global})}function Ml(e){return typeof e.options.stepRef=="string"?e.options.stepRef:typeof e.args.stepRef=="string"?e.args.stepRef:void 0}function Dl(e){let t=l(e.args,"subcommand")??Y(e.options,"subcommand"),n=e.args.alias??e.options.alias;return{ctx:e,subcommand:t.trim().toLowerCase(),name:l(e.args,"name")??l(e.options,"name"),author:l(e.args,"author")??l(e.options,"author"),force:e.args.force===!0||e.options.force===!0,aliases:n===void 0?void 0:T(n)}}function jl(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(l(t.args,"typePreset")??l(t.options,"typePreset"),{author:o,force:r},t.global)},n);return a?a():null}function Gl(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:l(t.args,"fieldType")??l(t.options,"fieldType"),commands:i===void 0?void 0:T(i),description:l(t.args,"description")??l(t.options,"description"),cliFlag:l(t.args,"cliFlag")??l(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:T(a),author:s,force:o},t.global)}function Ul(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:T(i),alias:r,description:l(t.args,"description")??l(t.options,"description"),order:$(t.args.order??t.options.order,"schema add-status order"),author:s,force:o},t.global)}function ql(e){let{ctx:t,name:n,author:s,force:o,aliases:r}=e;return sr(n,{description:l(t.args,"description")??l(t.options,"description"),defaultStatus:l(t.args,"defaultStatus")??l(t.args,"default_status")??l(t.options,"defaultStatus")??l(t.options,"default_status"),folder:l(t.args,"folder")??l(t.options,"folder"),alias:r,author:s,force:o},t.global)}function zl(e){let{ctx:t,subcommand:n,name:s,author:o,force:r}=e,i=l(t.args,"to")??Y(t.options,"to"),a=l(t.args,"migrationId")??l(t.args,"migration_id")??l(t.options,"migrationId")??l(t.options,"migration_id"),c=l(t.args,"fieldTypeScope")??l(t.options,"fieldTypeScope")??l(t.args,"type")??l(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 Hl(e){let t=Dl(e),n=jl(t);if(n!==null)return n;if(t.subcommand==="rename-type"||t.subcommand==="rename-field"||t.subcommand==="remap-status")return zl(t);if(t.subcommand==="add-field")return Gl(t);if(t.subcommand==="add-status")return Ul(t);if(t.subcommand==="add-type")return e.args.infer===!0||e.options.infer===!0?_r({minCount:$(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):ql(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 Vl(e){let t=l(e.args,"subcommand")??Y(e.options,"subcommand"),n=t.trim().toLowerCase(),s=l(e.args,"name")??l(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:l(e.args,"author")??l(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()}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=l(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=l(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 ka(e){let t={...e};return delete t.assignee,t}async function Kl(e){let t=F(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,{...ka(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=F(process.cwd(),e.global.path),n=await D(t),s=E(e),o=re(n.schema).open_status,r=await fe(s,{...ka(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=l(e.args,"reason")??l(e.args,"text")??l(e.options,"reason")??l(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"),l(t,"id")??e.id,l(t,"target"),Mi(t),e.global)}function ep(e){let t={...e.args,...e.options},n=T(t.historyEvent).map(s=>{let o=s.lastIndexOf(":");return{item_id:s.slice(0,o).trim(),line:Number(s.slice(o+1))}});return yr(F(process.cwd(),e.global.path),{events:n,all_actionable:t.allActionable===!0||t.all_actionable===!0,attributed_author:l(t,"attributedAuthor")??l(t,"attributed_author")??"",reviewer:l(t,"reviewer")??"",reason:l(t,"reason")??""})}var Sa={init:e=>Ir(l(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:Di,events:ji,merge:Gi,workspace:Ui,meet:at,event:at,remind:at,list:Sl,get:e=>rn(E(e),e.global,ue("get",e.options)),search:xl,duplicates:e=>{let t=typeof e.options.status=="string"?[e.options.status]:T(e.options.status);return un(e.global,{...t.length===0?{}:{status:t},since:l(e.options,"since"),threshold:typeof e.options.threshold=="number"?e.options.threshold:void 0,limit:e.options.limit==="default"?void 0:$(e.options.limit,"limit")})},create:El,copy:Al,focus:e=>on(e.id,{clear:e.options.clear===!0||e.args.clear===!0},e.global),update:Il,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:Rl,comments:Cl,notes:e=>fi(E(e),e.options,e.global),learnings:e=>Qo(E(e),e.options,e.global),files:Tl,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:Ol,validate:e=>Je(e.options,e.global,{runUpdate:(t,n,s)=>fe(t,n,s)}),health:$l,contracts:e=>ln(e.options,e.global),config:Fl,activity:Pl,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:T(e.options.paths),scope:e.options.scope==="project"||e.options.scope==="global"?e.options.scope:void 0,limit:$(e.options.limit,"files lookup limit"),offset:$(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":qi,"history-compact":zi,"history-author-acknowledge":ep,plan:Nl,schema:Hl,profile:Vl,stats:e=>pn(e.global,Hi(e.options)),append:Bl,"update-many":Wl,"close-many":Yl,gc:e=>gr(e.global,e.options)};function yy(e=Us){return e.map(t=>{let n=se(t),s=we(hn,n),o=s?.action??n,r=we(Sa,o)!==void 0;return{action:t,resolved_action:o,covered:r,route:r?s?"alias":"native":"missing"}})}async function ya(e,t,n,s){let o=Bn(t,e);Ms(e,o);let r={action:e,args:t,options:o,id:l(t,"id"),force:t.force===!0||o.force===!0,global:n,activeExtensions:s},i=we(Sa,e),a=i?await i(r):await gl(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:T,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,Oa 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,Aa as n,_n as o,kn as p,ui as q,qa as r,Ha as s,Va 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,Uc as C,qc as D,Ci as E,Oi as F,$i as G,Fi as H,Pi as I,$e as J,lm as K,pm as L,um as M,O as N,fm as O,_m as P,hm as Q,gm as R,Qn as S,Vi as T,ge as U,Zn as V,Bi as W,ym as X,Wi as Y,bm as Z,wm as _,vm as $,km as aa,Sm as ba,Tm as ca,Xi as da,Om as ea,Dm as fa,Vm as ga,Wm as ha,qd as ia,ul as ja,y as ka,Hh as la,Vh as ma,Bh as na,Wh as oa,Yh as pa,Jh as qa,Kh as ra,Xh as sa,Zh as ta,Qh as ua,eg as va,tg as wa,ng as xa,sg as ya,og as za,rg as Aa,ig as Ba,ag as Ca,cg as Da,mg as Ea,dg as Fa,lg as Ga,pg as Ha,ug as Ia,fg as Ja,_g as Ka,hg as La,gg as Ma,yg as Na,bg as Oa,wg as Pa,vg as Qa,kg as Ra,Sg as Sa,xg as Ta,Eg as Ua,Ag as Va,Ig as Wa,Rg as Xa,Cg as Ya,Tg as Za,Og as _a,$g as $a,Fg as ab,Pg as bb,Lg as cb,Ng as db,Mg as eb,Dg as fb,jg as gb,Gg as hb,Ug as ib,qg as jb,zg as kb,Hg as lb,Vg as mb,Bg as nb,Wg as ob,Yg as pb,Jg as qb,Kg as rb,Xg as sb,Zg as tb,Qg as ub,ey as vb,ty as wb,ny as xb,sy as yb,oy as zb,ry as Ab,iy as Bb,ay as Cb,cy as Db,my as Eb,dy as Fb,ly as Gb,py as Hb,uy as Ib,fy as Jb,_y as Kb,hy as Lb,Y as Mb,gy as Nb,kl as Ob,yy as Pb};
|
|
2008
|
+
//# sourceMappingURL=chunk-WYNUU7ZW.js.map
|