@unbrained/pm-cli 2026.8.4 → 2026.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +39 -13
- package/dist/cli/error-guidance.js +4 -4
- package/dist/cli/register-structured-mutation.d.ts +2 -0
- package/dist/cli/register-structured-mutation.js +124 -12
- package/dist/cli-bundle/bundle-manifest.json +407 -407
- package/dist/cli-bundle/chunks/append-VXXGOXSG.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-QVO3VTA4.js → chunk-2WFXWAYX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NM5G7RLU.js → chunk-3FTILRJ2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VH2EAGUG.js → chunk-42E7YPLG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RB65T4RX.js → chunk-43HQQI6S.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-J4EPW4GT.js → chunk-45G53IU4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PQXEB7W4.js → chunk-4VN6GS4U.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-4YUBDMQM.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-D2MBVMVE.js → chunk-54FNT7U2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NRDKVOUE.js → chunk-5ZBOIPGP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3XZYTRPC.js → chunk-6MSQJOTG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GOICHIX4.js → chunk-7A5OT5J2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HTYC76A4.js → chunk-7C4PTJG6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BKMZTZYL.js → chunk-A62CYISG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5H47J5FG.js → chunk-BPELKUQD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HE3DZFN4.js → chunk-BXQLRKWF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BLINBTMX.js → chunk-CSI3WS5I.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KH4GVBMC.js → chunk-DXDREUXT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KIKLF2W4.js → chunk-E2RKBKWB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-377OOXUF.js → chunk-EGJ4JTUG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SULWTPQO.js → chunk-FPBQHMFT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V5K52PYW.js → chunk-GE4KCSZP.js} +35 -35
- package/dist/cli-bundle/chunks/{chunk-NPUJ7OLK.js → chunk-HNFD72UK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QMWUL66F.js → chunk-HWRRMBJO.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-L3AZOELJ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-CGY5I2GO.js → chunk-LKDGK44W.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-LN2WFEU4.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZSH4GNBH.js → chunk-M72BKL5Q.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HQ2WU7OY.js → chunk-MHK6LIWE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-H6FITE7D.js → chunk-NE5VRDAI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NY4T3JWN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-DCJ6CM6F.js → chunk-OMXVBQ2N.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-OPVH7SKD.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-CU5ENFNP.js → chunk-OTHLDSFP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NH35JNK5.js → chunk-PMXJEU3F.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SVDH5CHC.js → chunk-Q35VBGOQ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-5PZGZMPG.js → chunk-R546TPDE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q5F6OI7C.js → chunk-RKAVWO3O.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JMKVCQSE.js → chunk-SSF4PIUR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PA5XRN2A.js → chunk-UN66FZRO.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FQ4EFFDU.js → chunk-UP7DTVMD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NFF3JAQR.js → chunk-UZBWIUYD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2POYGY53.js → chunk-V3774P7D.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-B5ZLCD5Z.js → chunk-V3EUXXOF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6S7I3UKV.js → chunk-VCKLFEUN.js} +19 -19
- package/dist/cli-bundle/chunks/{chunk-PYYPQLHC.js → chunk-VN5VITU3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WRL4KNDL.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-UJHUR3LZ.js → chunk-XCEZYMNI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JDPKBV5P.js → chunk-YEWNL576.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OB7TRZ2G.js → chunk-YSO3YFZ4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UVZREFZU.js → chunk-ZYHOB3SN.js} +2 -2
- package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +2 -0
- package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +2 -0
- package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +2 -0
- package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +2 -0
- package/dist/cli-bundle/chunks/{create-RLLCBCXM.js → create-XLKTXTUF.js} +2 -2
- package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +2 -0
- package/dist/cli-bundle/chunks/{deps-J4ONTF4X.js → deps-ITTY3GIC.js} +2 -2
- package/dist/cli-bundle/chunks/{docs-YL2DJ4WD.js → docs-W4OSRTYR.js} +2 -2
- package/dist/cli-bundle/chunks/{files-NGNAIYKK.js → files-EOK4AZI4.js} +2 -2
- package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +2 -0
- package/dist/cli-bundle/chunks/{history-compact-HW62K5XP.js → history-compact-7UGTMLL3.js} +2 -2
- package/dist/cli-bundle/chunks/{history-redact-HVBKUJOW.js → history-redact-4DZRMD6Z.js} +2 -2
- package/dist/cli-bundle/chunks/{history-repair-OPNBH5JJ.js → history-repair-UPOSZW5R.js} +2 -2
- package/dist/cli-bundle/chunks/{learnings-F36PZXT6.js → learnings-GMRNCBS3.js} +2 -2
- package/dist/cli-bundle/chunks/{profile-N3XMWBM7.js → profile-2MUUMHRE.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-BKGHBI7Y.js → register-list-query-LR3SQ5ZF.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-SUOHFVWM.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-ARRRKOVN.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-KWV6UD77.js → register-setup-O6AYP6NP.js} +2 -2
- package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +2 -0
- package/dist/cli-bundle/chunks/{schema-4PJQMGUY.js → schema-FJ4EA3XF.js} +2 -2
- package/dist/cli-bundle/chunks/update-YHV52CSS.js +2 -0
- package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-7J5TUBUJ.js +153 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ONIX2KKW.js → chunk-A7BJ5SS6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-B7LJWAZE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QM2BIVK7.js → chunk-BIMTMOS7.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-BOGRY7M6.js → chunk-FGKY4MBE.js} +10 -10
- package/dist/cli-bundle/focused-chunks/chunk-G6ETT4QK.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-C2QSL62X.js → chunk-GJ2TG2CW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RO5BQFG3.js → chunk-IPWSFADF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UFCPSWIL.js → chunk-MJ7HWSFK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2VIIXOAD.js → chunk-N5XU5UVK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-PG2RIZBX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OYTK4VNH.js → chunk-PIMMYG7Q.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-K37BB4JL.js → chunk-QVHKCI4T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SQXVGHMH.js → chunk-RUR5I3TK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SV3O7TSH.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-L6A4NVQC.js → chunk-UIL2M2NA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WVGJAD7L.js → chunk-VLYOEYML.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-W7BJEWHX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DQ4PLKEE.js → chunk-WEM2E2PE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WVIVUWVL.js +5 -0
- package/dist/cli-bundle/focused-chunks/chunk-Y4LDYLLT.js +2 -0
- package/dist/cli-bundle/main.js +4 -4
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +28 -28
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +1 -1
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +1 -1
- package/dist/core/extensions/loader.js +5 -2
- package/dist/core/item/item-format.js +14 -20
- package/dist/core/shared/constants.js +3 -2
- package/dist/core/store/item-store.js +2 -2
- package/dist/core/store/settings.js +2 -2
- package/dist/mcp/server.js +12 -6
- package/dist/mcp/tool-definitions.js +14 -7
- package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +18 -18
- package/dist/sdk/cli-contracts/agent-output-contracts.js +51 -23
- package/dist/sdk/cli-contracts/commander-mutation-options.js +26 -2
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +28 -2
- package/dist/sdk/cli-contracts/registration-helpers.js +4 -2
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +10 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +20 -5
- package/dist/sdk/cli-contracts/tool-schema.js +4 -2
- package/dist/sdk/cli-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts.js +4 -4
- package/dist/sdk/cli-program.js +3 -3
- package/dist/sdk/contracts.d.ts +1 -0
- package/dist/sdk/contracts.js +3 -2
- package/dist/sdk/dependency-provenance.d.ts +2 -0
- package/dist/sdk/dependency-provenance.js +7 -3
- package/dist/sdk/error-code-catalog.d.ts +23 -0
- package/dist/sdk/error-code-catalog.js +25 -5
- package/dist/sdk/generated-error-code-catalog.js +499 -3
- package/dist/sdk/graph/governance.js +3 -3
- package/dist/sdk/graph/remediation.js +3 -3
- package/dist/sdk/graph/run.js +4 -8
- package/dist/sdk/index.d.ts +2 -1
- package/dist/sdk/index.js +4 -3
- package/dist/sdk/item-transaction.d.ts +51 -6
- package/dist/sdk/item-transaction.js +132 -22
- package/dist/sdk/lifecycle/create.d.ts +4 -0
- package/dist/sdk/lifecycle/create.js +26 -10
- package/dist/sdk/lifecycle-policy.d.ts +9 -0
- package/dist/sdk/lifecycle-policy.js +22 -9
- package/dist/sdk/merge/driver.js +6 -3
- package/dist/sdk/output-contracts.d.ts +67 -0
- package/dist/sdk/output-contracts.js +173 -0
- package/dist/sdk/package-import-adapters.js +2 -2
- package/dist/sdk/structured-mutations.d.ts +23 -0
- package/dist/sdk/structured-mutations.js +219 -10
- package/dist/sdk/workspace-snapshot.js +58 -12
- package/dist/sdk/workspace.js +30 -4
- package/docs/COMMANDS.md +40 -10
- package/docs/EXTENSIONS.md +1 -1
- package/docs/MERGE_SAFETY.md +2 -0
- package/docs/PR_REVIEW_LOOP.md +10 -4
- package/docs/README.md +22 -22
- package/docs/RELEASING.md +3 -3
- package/docs/SCRIPTING.md +32 -9
- package/docs/SDK.md +91 -11
- package/docs/SELF_DESCRIBING_CONTEXT_CONTRACTS.md +13 -0
- package/docs/TESTING.md +25 -0
- package/docs/examples/sdk-contract-consumer/README.md +11 -1
- package/docs/examples/sdk-contract-consumer/package.json +2 -1
- package/docs/examples/sdk-contract-consumer/parse-receipt.mjs +22 -0
- package/marketplace.json +2 -2
- package/package.json +3 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +292 -14
- package/dist/cli-bundle/chunks/append-DHBRLHHS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-2INN52SU.js +0 -8
- package/dist/cli-bundle/chunks/chunk-6RSK4IFN.js +0 -20
- package/dist/cli-bundle/chunks/chunk-ASJJKA57.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IYAVULRN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-RRQBHQOV.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XBLOD5TZ.js +0 -2
- package/dist/cli-bundle/chunks/close-VLHNN6YB.js +0 -2
- package/dist/cli-bundle/chunks/close-many-LSJNZKU6.js +0 -2
- package/dist/cli-bundle/chunks/comments-AAIA6A6X.js +0 -2
- package/dist/cli-bundle/chunks/copy-Z7YMLEHN.js +0 -2
- package/dist/cli-bundle/chunks/delete-KNOHHQJM.js +0 -2
- package/dist/cli-bundle/chunks/focus-LFRCGALV.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-GU3DCECN.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-PTWH727R.js +0 -2
- package/dist/cli-bundle/chunks/restore-4HZSLILR.js +0 -2
- package/dist/cli-bundle/chunks/update-E6LPS5IV.js +0 -2
- package/dist/cli-bundle/chunks/update-many-OSIC6KRO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-5MTKO7TV.js +0 -153
- package/dist/cli-bundle/focused-chunks/chunk-6GIZK7VQ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-AOP2WIZZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CL75YW32.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-E7OFMWGT.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-I5F5UK3Q.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-T5TSY36R.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-VT6BF2IX.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as L,b as Nt,c as At,u as V}from"./chunk-Q5F6OI7C.js";import{a as Ot,b as Fe,c as Mt,d as Ft}from"./chunk-HE3DZFN4.js";import{ua as Dt}from"./chunk-JDPKBV5P.js";import{v as It,w as $t}from"./chunk-BKMZTZYL.js";import{a as Tt}from"./chunk-NRDKVOUE.js";import{A as f,Ad as wt,Bb as pt,C as m,Cc as yt,Da as de,Gf as fe,La as N,Md as kt,Mf as me,Nc as H,Oa as ue,Pc as _t,R as O,Rd as bt,Sd as vt,T as b,Td as Ct,Ub as gt,V as G,Wd as St,ad as v,b as ae,bb as mt,bd as C,cd as Me,d as lt,jf as xt,kf as Et,lc as le,od as X,ra as W,wa as Oe,wc as ht,xa as ce,yf as M,z as ft,zd as Y}from"./chunk-V5K52PYW.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8b010e79-a73a-5760-ac05-8dc88484cd69")}catch{}})();var pe={version:1,aliases:{}};function Lt(e=[]){let t=new Set(X),n=r=>{/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(r)&&t.add(r)};for(let r of e){for(let o of Object.keys(r.provenance_environment_keys??{}))n(o);for(let o of Object.keys(r.provenance_resolvers??{}))n(o);for(let o of r.provenance_unavailable_dimensions??[])n(o)}return[...t].sort()}function Rt(e){if(e===void 0)return;let n=(typeof e=="string"?[e]:e).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0);return n.length===0?void 0:new Set(n)}function Re(e,t){if(e.agent_harness?.trim())return{agent_harness:e.agent_harness,harness_source:"recorded"};let n=t.aliases[e.author];return n?{agent_harness:n,harness_source:"vocabulary"}:{harness_source:"unresolved"}}function Un(e,t=X){let n=new Set(t),r=new Map,o=e.provenance===void 0?[]:typeof e.provenance=="string"?[e.provenance]:e.provenance;for(let i of o.flatMap(s=>s.split(","))){let s=i.indexOf("=");if(s<0)throw new m(`Provenance predicate must use dimension=value; received "${i.trim()}".`,f.USAGE,{code:"invalid_provenance_predicate"});let a=i.slice(0,s).trim().toLowerCase(),d=i.slice(s+1).trim();if(!n.has(a))throw new m(`Unknown provenance dimension "${a||i.trim()}". Declared dimensions: ${[...n].sort().join(", ")}.`,f.USAGE,{code:"unknown_provenance_dimension"});if(d.length===0)throw new m(`Provenance predicate must use dimension=value; received "${i.trim()}".`,f.USAGE,{code:"invalid_provenance_predicate"});let c=r.get(a)??new Set;c.add(d),r.set(a,c)}return r}function Ut(e,t=pe,n={}){let r=Re(e,t);return{...n.itemId===void 0?{}:{item_id:n.itemId},...n.version===void 0?{}:{version:n.version},ts:e.ts,op:e.op,author:e.author,...e.author_source===void 0?{}:{author_source:e.author_source},...r,vocabulary_version:t.version,...e.agent_instance===void 0?{}:{agent_instance:e.agent_instance},agent_provenance:e.agent_provenance??{},...e.message===void 0?{}:{message:e.message}}}function Us(e,t,n=pe,r=X){return Le(t,n,r)(e)}function Le(e,t=pe,n=X){let r=Rt(e.harness),o=Rt(e.agentInstance),i=Un(e,n);return s=>{let d=Re(s,t).agent_harness;if(r&&(!d||!r.has(d))||o&&!o.has(s.agent_instance??""))return!1;for(let[c,u]of i){let l=s.agent_provenance?.[c];if(!l||!u.has(l.value))return!1}return!0}}function Pt(e,t=pe,n=X){let r=new Set(n),o=new Map,i=0;for(let s of e){for(let d of Object.keys(s.agent_provenance??{}))r.add(d);Re(s,t).agent_harness?i+=1:o.set(s.author,(o.get(s.author)??0)+1)}return{entries:e.length,vocabulary_version:t.version,harness:{resolved:i,unresolved:e.length-i,unresolved_authors:[...o].map(([s,a])=>({author:s,entries:a})).sort((s,a)=>a.entries-s.entries||s.author.localeCompare(a.author)).slice(0,20)},dimensions:[...r].sort().map(s=>{let a=0,d=0;for(let c of e){let u=c.agent_provenance?.[s];u===null?d+=1:u!==void 0&&(a+=1)}return{dimension:s,observed:a,unavailable:d,legacy_missing:e.length-a-d}})}}import Pn from"node:fs/promises";import Bt 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]="a7efa5e0-5610-51ca-8288-4f5410dbcf51")}catch{}})();var jn=20,Bn=5;function Ue(e,t){if(e===void 0)return;let n=e.trim();if(n.length===0)throw new m(`${t} must not be empty`,f.USAGE);return n}function jt(e,t,n){if(e===void 0)return;let r=e.trim();if(r.length===0)throw new m("Activity time bounds must not be empty",f.USAGE);let o=n==="--from"&&/^\d+[hdwm]$/iu.test(r)?`-${r}`:r;return G(o,new Date(t),n)}function zn(e,t,n){return!(e.ts.length===0&&(t||n)||t&&b(e.ts,t)<0||n&&b(e.ts,n)>=0)}function Gn(e,t){return t===void 0?e:e.slice(0,t)}function K(e,t=""){return typeof e=="string"?e:t}function Wn(e,t){return{...t,id:e,ts:K(t.ts),author:K(t.author,"unknown"),op:K(t.op,"unknown"),patch:Array.isArray(t.patch)?t.patch:[],before_hash:K(t.before_hash),after_hash:K(t.after_hash)}}function Hn(e){return[...e].sort((t,n)=>{let r=n.ts.localeCompare(t.ts);if(r!==0)return r;let o=t.id.localeCompare(n.id);return o!==0?o:t.op.localeCompare(n.op)})}async function Xn(e){try{return(await Pn.readdir(e)).filter(t=>t.endsWith(".jsonl")).sort((t,n)=>t.localeCompare(n))}catch(t){if(t.code==="ENOENT")return[];throw t}}function qn(e){let t=O(),n=jt(e.from,t,"--from"),r=jt(e.to,t,"--to");if(n&&r&&b(n,r)>=0)throw new m("Activity --from must be before --to",f.USAGE);let o=Tt(e.limit);if(e.unbounded===!0&&o!==void 0)throw new m("Activity --unbounded cannot be combined with --limit",f.USAGE);return{id:Ue(e.id,"Activity --id"),op:Ue(e.op,"Activity --op"),author:Ue(e.author,"Activity --author"),from:n,to:r,limit:e.unbounded===!0?void 0:o??(e.compact===!0?jn:Bn),limitSource:e.unbounded===!0||o!==void 0?"explicit":"default",harness:e.harness,agentInstance:e.agentInstance,provenance:e.provenanceFilter}}async function Yn(e){let t=N(process.cwd(),e.path);if(!await ae(ue(t)))throw new m(`Tracker is not initialized at ${t}. Run pm init first.`,f.NOT_FOUND);return{pmRoot:t,settings:await M(t)}}async function Vn(e){let t=de(e.settings,le()),n=await me(e.pmRoot,e.settings.item_format,t.type_to_folder,void 0,e.settings.schema);await xt({pmRoot:e.pmRoot,settings:e.settings,itemIds:n.map(o=>o.id),commandLabel:"activity"});let r=Bt.join(e.pmRoot,"history");return await ht({path:r,scope:"project"}),r}function Kn(e,t,n){return n.op&&e.op!==n.op||n.author&&e.author!==n.author?!1:zn(t,n.from,n.to)}async function Jn(e,t){let n=[];for(let r of await Xn(e)){let o=r.slice(0,-6);if(t.id&&o!==t.id)continue;let i=await wt(Bt.join(e,r),o);for(let s of i){let a=Wn(o,s);Kn(s,a,t)&&n.push(a)}}return n}function Zn(e){return e.map(t=>({id:t.id,op:t.op,ts:t.ts,author:t.author,...t.message?{msg:t.message}:{}}))}async function zt(e,t){let n=await Yn(t),r=qn(e),o=await Vn(n),i=Lt(n.settings.agent_identity.harness_signals),s=n.settings.agent_identity.identity_vocabulary,a=Le({harness:r.harness,agentInstance:r.agentInstance,provenance:r.provenance},s,i),d=Hn(await Jn(o,r)).filter(a),c=Gn(d,r.limit),u=e.compact===!0,l=u?Zn(c):void 0,p=e.provenance===!0?c.map(S=>Ut(S,s,{itemId:S.id})):void 0,g=d.length-c.length,w=e.provenance===!0?"provenance":u?"compact":"full";return{...{compact:{compact_activity:l},provenance:{provenance_activity:p},full:{activity:c}}[w],compact:u,projection:{mode:w,row_key:w==="compact"?"compact_activity":w==="provenance"?"provenance_activity":"activity"},omission_receipt:kt("activity",w),count:c.length,total_count:d.length,limit:r.limit??null,omitted_count:g,has_more:g>0,...e.provenanceSummary===!0?{provenance_summary:Pt(d,s,i)}:{},applied_bound:{kind:r.limit===void 0?"unbounded":"limit",source:r.limitSource,value:r.limit??null}}}import{encode as Qn}from"@toon-format/toon";(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]="f1677c6e-872e-5c42-ae3d-f73f4ec73616")}catch{}})();var Pe=["agenda","day","week","month"],je=["markdown","toon","json"],er=["sun","mon","tue","wed","thu","fri","sat"],tr=365,nr=365,Ht=28,rr=1e3;function Be(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new m(`${t} must be a non-negative integer`,f.USAGE);return n}function or(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw new m("Calendar include filter must not be empty",f.USAGE);let r=new Set;for(let o of n){if(o==="deadlines"||o==="deadline"){r.add("deadlines");continue}if(o==="reminders"||o==="reminder"){r.add("reminders");continue}if(o==="events"||o==="event"||o==="scheduled"){r.add("events");continue}throw new m("Calendar include filter must be deadlines|reminders|events|scheduled|all",f.USAGE)}return r}function Xt(e,t){let n;for(let r of t){let o=mt(e,r,2);o!==null&&(n===void 0||o<n.distance)&&(n={choice:r,distance:o})}return n?.choice}function ir(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!Pe.includes(t)){let n=Xt(t,Pe);throw new m(`Calendar view must be one of ${Pe.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function sr(e){if(!e)return;let t=e.trim().toLowerCase();if(!je.includes(t)){let n=Xt(t,je);throw new m(`Calendar format must be one of ${je.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function Zs(e,t){let n=sr(e.format);if(t.json&&n&&n!=="json")throw new m("Cannot combine --json with --format markdown|toon",f.USAGE);return t.json?"json":n??"markdown"}function ar(e,t){if(e===void 0)return;let n=v(e,t);if(!n){let r=t.definitions.map(o=>o.id);throw new m(`Calendar status filter must be one of ${r.join("|")}`,f.USAGE)}return n}function cr(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new m("Calendar assignee filter must be one of assigned|unassigned",f.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new m(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,f.USAGE);return t}function ge(e){return new Date(e).toISOString().slice(0,10)}function qt(e,t){if(!t||t==="UTC")return ge(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,o=n.find(s=>s.type==="month")?.value,i=n.find(s=>s.type==="day")?.value;if(r&&o&&i)return`${r}-${o}-${i}`}catch{}return ge(e)}function He(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function A(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function Yt(e){let t=new Date(He(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return A(t.toISOString(),r)}function dr(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function ur(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function lr(e,t){return b(e,t)>=0?e:t}function Gt(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function Wt(e,t){e.set(t,(e.get(t)??0)+1)}function fr(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,o)=>W(r)-W(o));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,o)=>r-o);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,o)=>r.localeCompare(o));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function Vt(e,t,n,r){let o=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(o.getUTCFullYear()!==e||o.getUTCMonth()!==t||o.getUTCDate()!==n))return o.toISOString()}function Kt(e){return er[new Date(e).getUTCDay()]}function mr(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function pr(e){let t=new Set;for(let n of e??[]){let r=mr(n);r&&t.add(r)}return t}function gr(e,t,n,r,o){let i=e??A(n,-(r??nr)),s=t??A(e??n,o??tr);return{start:i,end:b(s,i)>0?s:A(i,1)}}function hr(e,t,n,r){let o=t.by_weekday!==void 0?[...t.by_weekday]:[Kt(e)],i=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??rr,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:pr(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(o)].sort((s,a)=>W(s)-W(a)),sortedMonthDays:[...new Set(i)].sort((s,a)=>s-a),occurrences:[],produced:0}}function he(e,t){return b(t,e.startAt)<0?"continue":e.until&&b(t,e.until)>0||b(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,b(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function ye(e,t){let n=Kt(t),r=new Date(t).getUTCDate(),o=!e.weekdayFilter||e.weekdayFilter.has(n),i=!e.monthDayFilter||e.monthDayFilter.has(r);return o&&i}function yr(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(ye(e,t)&&he(e,t)==="stop");n+=1)t=A(t,e.interval);return e.occurrences}function _r(e,t,n){let r=W(n),o=A(t,r),i=new Date(o);return new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function wr(e){let t=Yt(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=A(t,n*e.interval*7);for(let o of e.sortedWeekdays){let i=_r(e,r,o);if(ye(e,i)&&he(e,i)==="stop")return e.occurrences}}return e.occurrences}function kr(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let o=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let i of e.sortedMonthDays){let s=Vt(o.getUTCFullYear(),o.getUTCMonth(),i,e.startDate);if(!(!s||!ye(e,s))&&he(e,s)==="stop")return e.occurrences}}return e.occurrences}function br(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let o=t+r*e.interval;for(let i of e.sortedMonthDays){let s=Vt(o,n,i,e.startDate);if(!(!s||!ye(e,s))&&he(e,s)==="stop")return e.occurrences}}return e.occurrences}function vr(e,t,n,r){let o=hr(e,t,n,r);return t.freq==="daily"?yr(o):t.freq==="weekly"?wr(o):t.freq==="monthly"?kr(o):br(o)}function Jt(e){return[...e].sort((t,n)=>{let r=b(t.at,n.at);if(r!==0)return r;let o=t.item_priority-n.item_priority;if(o!==0)return o;let i=t.item_id.localeCompare(n.item_id);if(i!==0)return i;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function Xe(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Cr(e){return e.deadline?{at:e.deadline,date:ge(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...Xe(e),item_deadline:e.deadline}:null}function Sr(e){return(e.reminders??[]).map(t=>({at:t.at,date:ge(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...Xe(e)}))}function xr(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function Er(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Tr(e,t,n,r){let o=fr(t.recurrence),i=xr(t.start_at,t.end_at);return(t.recurrence?vr(t.start_at,t.recurrence,n,r):[t.start_at]).map(a=>({at:a,date:t.all_day===!0?a.slice(0,10):qt(a,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:Er(a,t,i),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:o,...Xe(e)}))}function Ir(e,t,n,r){let o=[];for(let i of e){let s=n.has("deadlines")?Cr(i):null;s&&o.push(s),n.has("reminders")&&o.push(...Sr(i));for(let a of n.has("events")?i.events??[]:[])o.push(...Tr(i,a,t,r))}return Jt(o)}function $r(e,t,n,r,o){let i=At(t.type,n),s=t.tag?.trim().toLowerCase(),a=Nt(t.priority),d=ar(t.status,r),c=t.assignee?.trim(),u=cr(t.assigneeFilter),l=t.sprint?.trim(),p=t.release?.trim();if(c&&(c.toLowerCase()==="none"||c.toLowerCase()==="null"))throw new m('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',f.USAGE);if(c!==void 0&&u==="unassigned")throw new m("Cannot combine --assignee with --assignee-filter unassigned",f.USAGE);return e.filter(g=>Dr(g,{typeFilter:i,tagFilter:s,priorityFilter:a,statusFilter:d,assigneeFilter:c,assigneeModeFilter:u,sprintFilter:l,releaseFilter:p,runtimeFieldFilters:o}))}function Dr(e,t){return Nr(e,t)&&Ar(e,t)&&$t(e,t.runtimeFieldFilters)}function Nr(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function Ar(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function Or(e,t,n){return!(t&&b(e.at,t)<0||n&&b(e.at,n)>=0)}function ze(e,t,n){return e.trim().toLowerCase()==="today"?He(t):G(e,new Date(t),n)}function Mr(e,t,n){let r=t.date?ze(t.date,n,"--date"):n,o=t.past===!0,i=t.fullPeriod===!0,s=t.from?ze(t.from,n,"--from"):void 0,a=t.to?ze(t.to,n,"--to"):void 0;if(s&&a&&b(s,a)>=0)throw new m("Calendar --from must be before --to",f.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new m("--from and --to are only supported for --view agenda",f.USAGE);if(e==="agenda")return Fr(r,t,n,o,i,s,a);if(e==="day"){let c=He(r);return Ge(r,n,o,i,c,A(c,1))}if(e==="week"){let c=Yt(r);return Ge(r,n,o,i,c,A(c,7))}let d=dr(r);return Ge(r,n,o,i,d,ur(r))}function Fr(e,t,n,r,o,i,s){if(o)throw new m("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",f.USAGE);return{anchor:e,start:i??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function Ge(e,t,n,r,o,i){let s=n||r;return{anchor:e,start:s?o:lr(o,t),end:i,periodStart:o,periodEnd:i,fullPeriod:s}}function Rr(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:Jt(r)}))}function Lr(e){let t=new Set,n=new Map,r=new Map,o=0,i=0,s=0,a=0;for(let d of e)t.add(d.item_id),Wt(n,d.item_type),Wt(r,d.item_status),d.kind==="deadline"?o+=1:d.kind==="reminder"?i+=1:(s+=1,d.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:o,reminders:i,scheduled:s,by_kind:{deadline:o,reminder:i,event:s},by_type:Gt(n),by_status:Gt(r),recurring_events:a}}function Ur(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function Zt(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(i=>i.type==="hour")?.value,o=n.find(i=>i.type==="minute")?.value;if(r&&o)return`${r}:${o}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function We(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function Pr(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===qt(e.event_end,e.event_timezone)?Zt(e.event_end,e.event_timezone):e.event_end:null}function jr(e){let t=`${Zt(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let i=Pr(e);return i&&n.push(`end=${i}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function Qs(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${Ur(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- by-kind: ${We(e.summary.by_kind)}`),t.push(`- by-type: ${We(e.summary.by_type)}`),t.push(`- by-status: ${We(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),t.join(`
|
|
1
|
+
import{a as L,b as Nt,c as At,u as V}from"./chunk-RKAVWO3O.js";import{a as Ot,b as Fe,c as Mt,d as Ft}from"./chunk-BXQLRKWF.js";import{va as Dt}from"./chunk-YEWNL576.js";import{v as It,w as $t}from"./chunk-A62CYISG.js";import{a as Tt}from"./chunk-5ZBOIPGP.js";import{A as f,Ad as wt,Af as M,Bb as pt,C as m,Cc as yt,Da as de,If as fe,La as N,Md as kt,Nc as H,Oa as ue,Of as me,Pc as _t,R as O,Rd as bt,Sd as vt,T as b,Td as Ct,Ub as gt,V as G,Wd as St,ad as v,b as ae,bb as mt,bd as C,cd as Me,d as lt,lc as le,lf as xt,mf as Et,od as X,ra as W,wa as Oe,wc as ht,xa as ce,z as ft,zd as Y}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]="8b010e79-a73a-5760-ac05-8dc88484cd69")}catch{}})();var pe={version:1,aliases:{}};function Lt(e=[]){let t=new Set(X),n=r=>{/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(r)&&t.add(r)};for(let r of e){for(let o of Object.keys(r.provenance_environment_keys??{}))n(o);for(let o of Object.keys(r.provenance_resolvers??{}))n(o);for(let o of r.provenance_unavailable_dimensions??[])n(o)}return[...t].sort()}function Rt(e){if(e===void 0)return;let n=(typeof e=="string"?[e]:e).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0);return n.length===0?void 0:new Set(n)}function Re(e,t){if(e.agent_harness?.trim())return{agent_harness:e.agent_harness,harness_source:"recorded"};let n=t.aliases[e.author];return n?{agent_harness:n,harness_source:"vocabulary"}:{harness_source:"unresolved"}}function Un(e,t=X){let n=new Set(t),r=new Map,o=e.provenance===void 0?[]:typeof e.provenance=="string"?[e.provenance]:e.provenance;for(let i of o.flatMap(s=>s.split(","))){let s=i.indexOf("=");if(s<0)throw new m(`Provenance predicate must use dimension=value; received "${i.trim()}".`,f.USAGE,{code:"invalid_provenance_predicate"});let a=i.slice(0,s).trim().toLowerCase(),d=i.slice(s+1).trim();if(!n.has(a))throw new m(`Unknown provenance dimension "${a||i.trim()}". Declared dimensions: ${[...n].sort().join(", ")}.`,f.USAGE,{code:"unknown_provenance_dimension"});if(d.length===0)throw new m(`Provenance predicate must use dimension=value; received "${i.trim()}".`,f.USAGE,{code:"invalid_provenance_predicate"});let c=r.get(a)??new Set;c.add(d),r.set(a,c)}return r}function Ut(e,t=pe,n={}){let r=Re(e,t);return{...n.itemId===void 0?{}:{item_id:n.itemId},...n.version===void 0?{}:{version:n.version},ts:e.ts,op:e.op,author:e.author,...e.author_source===void 0?{}:{author_source:e.author_source},...r,vocabulary_version:t.version,...e.agent_instance===void 0?{}:{agent_instance:e.agent_instance},agent_provenance:e.agent_provenance??{},...e.message===void 0?{}:{message:e.message}}}function Us(e,t,n=pe,r=X){return Le(t,n,r)(e)}function Le(e,t=pe,n=X){let r=Rt(e.harness),o=Rt(e.agentInstance),i=Un(e,n);return s=>{let d=Re(s,t).agent_harness;if(r&&(!d||!r.has(d))||o&&!o.has(s.agent_instance??""))return!1;for(let[c,u]of i){let l=s.agent_provenance?.[c];if(!l||!u.has(l.value))return!1}return!0}}function Pt(e,t=pe,n=X){let r=new Set(n),o=new Map,i=0;for(let s of e){for(let d of Object.keys(s.agent_provenance??{}))r.add(d);Re(s,t).agent_harness?i+=1:o.set(s.author,(o.get(s.author)??0)+1)}return{entries:e.length,vocabulary_version:t.version,harness:{resolved:i,unresolved:e.length-i,unresolved_authors:[...o].map(([s,a])=>({author:s,entries:a})).sort((s,a)=>a.entries-s.entries||s.author.localeCompare(a.author)).slice(0,20)},dimensions:[...r].sort().map(s=>{let a=0,d=0;for(let c of e){let u=c.agent_provenance?.[s];u===null?d+=1:u!==void 0&&(a+=1)}return{dimension:s,observed:a,unavailable:d,legacy_missing:e.length-a-d}})}}import Pn from"node:fs/promises";import Bt 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]="a7efa5e0-5610-51ca-8288-4f5410dbcf51")}catch{}})();var jn=20,Bn=5;function Ue(e,t){if(e===void 0)return;let n=e.trim();if(n.length===0)throw new m(`${t} must not be empty`,f.USAGE);return n}function jt(e,t,n){if(e===void 0)return;let r=e.trim();if(r.length===0)throw new m("Activity time bounds must not be empty",f.USAGE);let o=n==="--from"&&/^\d+[hdwm]$/iu.test(r)?`-${r}`:r;return G(o,new Date(t),n)}function zn(e,t,n){return!(e.ts.length===0&&(t||n)||t&&b(e.ts,t)<0||n&&b(e.ts,n)>=0)}function Gn(e,t){return t===void 0?e:e.slice(0,t)}function K(e,t=""){return typeof e=="string"?e:t}function Wn(e,t){return{...t,id:e,ts:K(t.ts),author:K(t.author,"unknown"),op:K(t.op,"unknown"),patch:Array.isArray(t.patch)?t.patch:[],before_hash:K(t.before_hash),after_hash:K(t.after_hash)}}function Hn(e){return[...e].sort((t,n)=>{let r=n.ts.localeCompare(t.ts);if(r!==0)return r;let o=t.id.localeCompare(n.id);return o!==0?o:t.op.localeCompare(n.op)})}async function Xn(e){try{return(await Pn.readdir(e)).filter(t=>t.endsWith(".jsonl")).sort((t,n)=>t.localeCompare(n))}catch(t){if(t.code==="ENOENT")return[];throw t}}function qn(e){let t=O(),n=jt(e.from,t,"--from"),r=jt(e.to,t,"--to");if(n&&r&&b(n,r)>=0)throw new m("Activity --from must be before --to",f.USAGE);let o=Tt(e.limit);if(e.unbounded===!0&&o!==void 0)throw new m("Activity --unbounded cannot be combined with --limit",f.USAGE);return{id:Ue(e.id,"Activity --id"),op:Ue(e.op,"Activity --op"),author:Ue(e.author,"Activity --author"),from:n,to:r,limit:e.unbounded===!0?void 0:o??(e.compact===!0?jn:Bn),limitSource:e.unbounded===!0||o!==void 0?"explicit":"default",harness:e.harness,agentInstance:e.agentInstance,provenance:e.provenanceFilter}}async function Yn(e){let t=N(process.cwd(),e.path);if(!await ae(ue(t)))throw new m(`Tracker is not initialized at ${t}. Run pm init first.`,f.NOT_FOUND);return{pmRoot:t,settings:await M(t)}}async function Vn(e){let t=de(e.settings,le()),n=await me(e.pmRoot,e.settings.item_format,t.type_to_folder,void 0,e.settings.schema);await xt({pmRoot:e.pmRoot,settings:e.settings,itemIds:n.map(o=>o.id),commandLabel:"activity"});let r=Bt.join(e.pmRoot,"history");return await ht({path:r,scope:"project"}),r}function Kn(e,t,n){return n.op&&e.op!==n.op||n.author&&e.author!==n.author?!1:zn(t,n.from,n.to)}async function Jn(e,t){let n=[];for(let r of await Xn(e)){let o=r.slice(0,-6);if(t.id&&o!==t.id)continue;let i=await wt(Bt.join(e,r),o);for(let s of i){let a=Wn(o,s);Kn(s,a,t)&&n.push(a)}}return n}function Zn(e){return e.map(t=>({id:t.id,op:t.op,ts:t.ts,author:t.author,...t.message?{msg:t.message}:{}}))}async function zt(e,t){let n=await Yn(t),r=qn(e),o=await Vn(n),i=Lt(n.settings.agent_identity.harness_signals),s=n.settings.agent_identity.identity_vocabulary,a=Le({harness:r.harness,agentInstance:r.agentInstance,provenance:r.provenance},s,i),d=Hn(await Jn(o,r)).filter(a),c=Gn(d,r.limit),u=e.compact===!0,l=u?Zn(c):void 0,p=e.provenance===!0?c.map(S=>Ut(S,s,{itemId:S.id})):void 0,g=d.length-c.length,w=e.provenance===!0?"provenance":u?"compact":"full";return{...{compact:{compact_activity:l},provenance:{provenance_activity:p},full:{activity:c}}[w],compact:u,projection:{mode:w,row_key:w==="compact"?"compact_activity":w==="provenance"?"provenance_activity":"activity"},omission_receipt:kt("activity",w),count:c.length,total_count:d.length,limit:r.limit??null,omitted_count:g,has_more:g>0,...e.provenanceSummary===!0?{provenance_summary:Pt(d,s,i)}:{},applied_bound:{kind:r.limit===void 0?"unbounded":"limit",source:r.limitSource,value:r.limit??null}}}import{encode as Qn}from"@toon-format/toon";(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]="f1677c6e-872e-5c42-ae3d-f73f4ec73616")}catch{}})();var Pe=["agenda","day","week","month"],je=["markdown","toon","json"],er=["sun","mon","tue","wed","thu","fri","sat"],tr=365,nr=365,Ht=28,rr=1e3;function Be(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new m(`${t} must be a non-negative integer`,f.USAGE);return n}function or(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw new m("Calendar include filter must not be empty",f.USAGE);let r=new Set;for(let o of n){if(o==="deadlines"||o==="deadline"){r.add("deadlines");continue}if(o==="reminders"||o==="reminder"){r.add("reminders");continue}if(o==="events"||o==="event"||o==="scheduled"){r.add("events");continue}throw new m("Calendar include filter must be deadlines|reminders|events|scheduled|all",f.USAGE)}return r}function Xt(e,t){let n;for(let r of t){let o=mt(e,r,2);o!==null&&(n===void 0||o<n.distance)&&(n={choice:r,distance:o})}return n?.choice}function ir(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!Pe.includes(t)){let n=Xt(t,Pe);throw new m(`Calendar view must be one of ${Pe.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function sr(e){if(!e)return;let t=e.trim().toLowerCase();if(!je.includes(t)){let n=Xt(t,je);throw new m(`Calendar format must be one of ${je.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function Zs(e,t){let n=sr(e.format);if(t.json&&n&&n!=="json")throw new m("Cannot combine --json with --format markdown|toon",f.USAGE);return t.json?"json":n??"markdown"}function ar(e,t){if(e===void 0)return;let n=v(e,t);if(!n){let r=t.definitions.map(o=>o.id);throw new m(`Calendar status filter must be one of ${r.join("|")}`,f.USAGE)}return n}function cr(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new m("Calendar assignee filter must be one of assigned|unassigned",f.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new m(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,f.USAGE);return t}function ge(e){return new Date(e).toISOString().slice(0,10)}function qt(e,t){if(!t||t==="UTC")return ge(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,o=n.find(s=>s.type==="month")?.value,i=n.find(s=>s.type==="day")?.value;if(r&&o&&i)return`${r}-${o}-${i}`}catch{}return ge(e)}function He(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function A(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function Yt(e){let t=new Date(He(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return A(t.toISOString(),r)}function dr(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function ur(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function lr(e,t){return b(e,t)>=0?e:t}function Gt(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function Wt(e,t){e.set(t,(e.get(t)??0)+1)}function fr(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,o)=>W(r)-W(o));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,o)=>r-o);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,o)=>r.localeCompare(o));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function Vt(e,t,n,r){let o=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(o.getUTCFullYear()!==e||o.getUTCMonth()!==t||o.getUTCDate()!==n))return o.toISOString()}function Kt(e){return er[new Date(e).getUTCDay()]}function mr(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function pr(e){let t=new Set;for(let n of e??[]){let r=mr(n);r&&t.add(r)}return t}function gr(e,t,n,r,o){let i=e??A(n,-(r??nr)),s=t??A(e??n,o??tr);return{start:i,end:b(s,i)>0?s:A(i,1)}}function hr(e,t,n,r){let o=t.by_weekday!==void 0?[...t.by_weekday]:[Kt(e)],i=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??rr,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:pr(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(o)].sort((s,a)=>W(s)-W(a)),sortedMonthDays:[...new Set(i)].sort((s,a)=>s-a),occurrences:[],produced:0}}function he(e,t){return b(t,e.startAt)<0?"continue":e.until&&b(t,e.until)>0||b(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,b(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function ye(e,t){let n=Kt(t),r=new Date(t).getUTCDate(),o=!e.weekdayFilter||e.weekdayFilter.has(n),i=!e.monthDayFilter||e.monthDayFilter.has(r);return o&&i}function yr(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(ye(e,t)&&he(e,t)==="stop");n+=1)t=A(t,e.interval);return e.occurrences}function _r(e,t,n){let r=W(n),o=A(t,r),i=new Date(o);return new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function wr(e){let t=Yt(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=A(t,n*e.interval*7);for(let o of e.sortedWeekdays){let i=_r(e,r,o);if(ye(e,i)&&he(e,i)==="stop")return e.occurrences}}return e.occurrences}function kr(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let o=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let i of e.sortedMonthDays){let s=Vt(o.getUTCFullYear(),o.getUTCMonth(),i,e.startDate);if(!(!s||!ye(e,s))&&he(e,s)==="stop")return e.occurrences}}return e.occurrences}function br(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let o=t+r*e.interval;for(let i of e.sortedMonthDays){let s=Vt(o,n,i,e.startDate);if(!(!s||!ye(e,s))&&he(e,s)==="stop")return e.occurrences}}return e.occurrences}function vr(e,t,n,r){let o=hr(e,t,n,r);return t.freq==="daily"?yr(o):t.freq==="weekly"?wr(o):t.freq==="monthly"?kr(o):br(o)}function Jt(e){return[...e].sort((t,n)=>{let r=b(t.at,n.at);if(r!==0)return r;let o=t.item_priority-n.item_priority;if(o!==0)return o;let i=t.item_id.localeCompare(n.item_id);if(i!==0)return i;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function Xe(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Cr(e){return e.deadline?{at:e.deadline,date:ge(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...Xe(e),item_deadline:e.deadline}:null}function Sr(e){return(e.reminders??[]).map(t=>({at:t.at,date:ge(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...Xe(e)}))}function xr(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function Er(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Tr(e,t,n,r){let o=fr(t.recurrence),i=xr(t.start_at,t.end_at);return(t.recurrence?vr(t.start_at,t.recurrence,n,r):[t.start_at]).map(a=>({at:a,date:t.all_day===!0?a.slice(0,10):qt(a,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:Er(a,t,i),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:o,...Xe(e)}))}function Ir(e,t,n,r){let o=[];for(let i of e){let s=n.has("deadlines")?Cr(i):null;s&&o.push(s),n.has("reminders")&&o.push(...Sr(i));for(let a of n.has("events")?i.events??[]:[])o.push(...Tr(i,a,t,r))}return Jt(o)}function $r(e,t,n,r,o){let i=At(t.type,n),s=t.tag?.trim().toLowerCase(),a=Nt(t.priority),d=ar(t.status,r),c=t.assignee?.trim(),u=cr(t.assigneeFilter),l=t.sprint?.trim(),p=t.release?.trim();if(c&&(c.toLowerCase()==="none"||c.toLowerCase()==="null"))throw new m('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',f.USAGE);if(c!==void 0&&u==="unassigned")throw new m("Cannot combine --assignee with --assignee-filter unassigned",f.USAGE);return e.filter(g=>Dr(g,{typeFilter:i,tagFilter:s,priorityFilter:a,statusFilter:d,assigneeFilter:c,assigneeModeFilter:u,sprintFilter:l,releaseFilter:p,runtimeFieldFilters:o}))}function Dr(e,t){return Nr(e,t)&&Ar(e,t)&&$t(e,t.runtimeFieldFilters)}function Nr(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function Ar(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function Or(e,t,n){return!(t&&b(e.at,t)<0||n&&b(e.at,n)>=0)}function ze(e,t,n){return e.trim().toLowerCase()==="today"?He(t):G(e,new Date(t),n)}function Mr(e,t,n){let r=t.date?ze(t.date,n,"--date"):n,o=t.past===!0,i=t.fullPeriod===!0,s=t.from?ze(t.from,n,"--from"):void 0,a=t.to?ze(t.to,n,"--to"):void 0;if(s&&a&&b(s,a)>=0)throw new m("Calendar --from must be before --to",f.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new m("--from and --to are only supported for --view agenda",f.USAGE);if(e==="agenda")return Fr(r,t,n,o,i,s,a);if(e==="day"){let c=He(r);return Ge(r,n,o,i,c,A(c,1))}if(e==="week"){let c=Yt(r);return Ge(r,n,o,i,c,A(c,7))}let d=dr(r);return Ge(r,n,o,i,d,ur(r))}function Fr(e,t,n,r,o,i,s){if(o)throw new m("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",f.USAGE);return{anchor:e,start:i??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function Ge(e,t,n,r,o,i){let s=n||r;return{anchor:e,start:s?o:lr(o,t),end:i,periodStart:o,periodEnd:i,fullPeriod:s}}function Rr(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:Jt(r)}))}function Lr(e){let t=new Set,n=new Map,r=new Map,o=0,i=0,s=0,a=0;for(let d of e)t.add(d.item_id),Wt(n,d.item_type),Wt(r,d.item_status),d.kind==="deadline"?o+=1:d.kind==="reminder"?i+=1:(s+=1,d.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:o,reminders:i,scheduled:s,by_kind:{deadline:o,reminder:i,event:s},by_type:Gt(n),by_status:Gt(r),recurring_events:a}}function Ur(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function Zt(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(i=>i.type==="hour")?.value,o=n.find(i=>i.type==="minute")?.value;if(r&&o)return`${r}:${o}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function We(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function Pr(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===qt(e.event_end,e.event_timezone)?Zt(e.event_end,e.event_timezone):e.event_end:null}function jr(e){let t=`${Zt(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let i=Pr(e);return i&&n.push(`end=${i}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function Qs(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${Ur(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- by-kind: ${We(e.summary.by_kind)}`),t.push(`- by-type: ${We(e.summary.by_type)}`),t.push(`- by-status: ${We(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),t.join(`
|
|
2
2
|
`);for(let n of e.days){t.push(`## ${n.date} (${n.count})`);for(let r of n.events)t.push(`- ${jr(r)}`);t.push("")}if(e.warnings&&e.warnings.length>0){t.push("### warnings");for(let n of e.warnings)t.push(`- ${n}`);t.push("")}return Br(t.join(`
|
|
3
3
|
`))}function ea(e){return Qn(e)}function Br(e){let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
4
|
`;)t-=1;return e.slice(0,t)}function zr(e){let t=O(),n=ir(e.view),r=Mr(n,e,t),o=L(e.limit),i=or(e.include),s=Be(e.recurrenceLookaheadDays,"Calendar recurrence lookahead days"),a=Be(e.recurrenceLookbackDays,"Calendar recurrence lookback days"),d=Be(e.occurrenceLimit,"Calendar occurrence limit");if(d!==void 0&&d<1)throw new m("Calendar occurrence limit must be >= 1",f.USAGE);let c=i.has("events")&&!i.has("deadlines")&&!i.has("reminders"),u=e.to!==void 0||s!==void 0||a!==void 0||d!==void 0,l=c&&!u;return{nowValue:t,view:n,rangeBounds:r,limit:o,includeSources:i,occurrenceLimit:d,recurrenceLookaheadDays:l?Ht:s,recurrenceLookbackWindowDays:l&&a===void 0?0:a,eventsOnlyCapApplied:l}}function Gr(e,t){t&&e.push(`recurring_events_default_cap_applied:lookback=0d,lookahead=${Ht}d -- use --recurrence-lookback-days/--recurrence-lookahead-days or --to for wider range`)}function Wr(e,t){return{type:e.type??null,tag:e.tag??null,priority:e.priority??null,status:e.status??null,assignee:e.assignee??null,assignee_filter:e.assigneeFilter??null,sprint:e.sprint??null,release:e.release??null,runtime_filters:t,limit:e.limit??null,include:e.include??null,full_period:e.fullPeriod===!0?"true":null,recurrence_lookahead_days:e.recurrenceLookaheadDays??null,recurrence_lookback_days:e.recurrenceLookbackDays??null,occurrence_limit:e.occurrenceLimit??null}}function Hr(e,t){return{start:t.start??null,end:t.end??null,period_start:t.periodStart??null,period_end:t.periodEnd??null,full_period:t.fullPeriod,past:e.past===!0,from:e.from??null,to:e.to??null}}async function Qt(e,t){let n=N(process.cwd(),t.path);if(!await ae(ue(n)))throw new m(`Tracker is not initialized at ${n}. Run pm init first.`,f.NOT_FOUND);let r=zr(e),o=await M(n),i=H(o.schema),s=_t(o.schema),a=It(e,s,"calendar"),d=de(o,le()),c=[];Gr(c,r.eventsOnlyCapApplied);let u=await me(n,o.item_format,d.type_to_folder,c,o.schema),l=$r(u,e,d,i,a),p=gr(r.rangeBounds.start,r.rangeBounds.end,r.nowValue,r.recurrenceLookbackWindowDays,r.recurrenceLookaheadDays),w=Ir(l,p,r.includeSources,r.occurrenceLimit).filter(k=>Or(k,r.rangeBounds.start,r.rangeBounds.end)),h=r.limit===void 0?w:w.slice(0,r.limit),S=Rr(h),_=[...new Set(c)].sort((k,x)=>k.localeCompare(x));return{view:r.view,output_default:"markdown",now:r.nowValue,anchor:r.rangeBounds.anchor,range:Hr(e,r.rangeBounds),filters:Wr(e,a),summary:Lr(h),events:h,days:S,..._.length>0?{warnings:_}:{}}}(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]="1f898377-b606-5bfd-932d-6ce5f2f9c717")}catch{}})();var qe=["structural","recency","activity_density","graph_proximity","claim_focus","priority_pressure","risk_pressure","deadline_pressure","knowledge_density","author_affinity","usage_affinity","semantic_similarity"],Xr=Symbol("no-context-author"),qr=Symbol("no-item-assignee");function en(e,t){if(typeof e!="string")return t;let n=e.trim().toLowerCase();return n.length>0?n:t}function Yr(e,t){let n=typeof e=="number"?e:typeof e=="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)?1-Math.min(Math.max(n,0),t)/t:0}function Vr(e,t){let n=typeof e=="string"?Date.parse(e):e instanceof Date?e.getTime():typeof e=="number"?e:Number.NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return 0;let r=(n-t)/864e5;return r<=0?1:1/(1+r/30)}function Kr(e){let t=typeof e=="string"?e.trim().toLowerCase():void 0;return t==="critical"||t==="high"?1:t==="medium"?.5:t==="low"?.1:0}function _e(e,t,n){return e?.[t]??n}function we(e,t){let n=c=>{if(typeof c!="string")return"";try{return G(c,new Date(Number.NaN),"updated_at")}catch{return""}},r=[...e].sort((c,u)=>{let l=n(c.updated_at),p=n(u.updated_at);return b(p,l)||c.id.localeCompare(u.id)}),o=new Map(r.map((c,u)=>[c.id,u])),i=Math.max(e.length-1,1),s=en(t.author,Xr),a=v("in_progress",t.statusRegistry),d=Date.parse(t.now);return e.map(c=>{let u=en(c.assignee,qr)===s,l=(c.comments?.length??0)+(c.notes?.length??0)+(c.learnings?.length??0);return{id:c.id,item:c,signals:{recency:e.length===1?1:1-o.get(c.id)/i,activity_density:t.activityDensity?.[c.id],graph_proximity:_e(t.graphProximity,c.id,c.parent?.3:0),claim_focus:_e(t.claimFocus,c.id,C(c.status,t.statusRegistry)===a?1:u?.75:0),priority_pressure:Yr(c.priority,4),risk_pressure:Kr(c.risk),deadline_pressure:Vr(c.deadline,d),knowledge_density:_e(t.knowledgeDensity,c.id,Math.min(l/5,1)),author_affinity:_e(t.authorAffinity,c.id,u?1:0),usage_affinity:t.usageAffinity?.[c.id],semantic_similarity:t.semanticSimilarity?.[c.id]}}})}var Jr="context_relevance",Zr={structural:.4,recency:.35,activity_density:.25,graph_proximity:.15,claim_focus:.6,priority_pressure:.35,risk_pressure:.2,deadline_pressure:.45,knowledge_density:.25,author_affinity:.2,usage_affinity:.3,semantic_similarity:.5},Qr=new TextEncoder;function eo(e){let t=new Set;for(let n of e){if(typeof n.id!="string"||n.id.trim().length===0||t.has(n.id))throw new TypeError("Context relevance candidates require unique non-empty ids");t.add(n.id);for(let[r,o]of Object.entries(n.signals??{})){if(r==="structural"||!qe.includes(r))throw new TypeError(`Unknown context relevance signal: ${r}`);if(o!==void 0&&(!Number.isFinite(o)||o<0||o>1))throw new TypeError(`Context relevance signal ${r} must be a finite number from 0 to 1`)}}}function to(e){let t={...Zr};for(let[n,r]of Object.entries(e??{}))r!==void 0&&qe.includes(n)&&(t[n]=r);for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<0)throw new TypeError(`Context relevance weight ${n} must be a finite non-negative number`);return t}function nn(e,t={}){eo(e);let n=to(t.weights),r=Math.max(e.length-1,1),o=new Set(["structural"]);for(let a of e)for(let[d,c]of Object.entries(a.signals??{}))c!==void 0&&o.add(d);let i=qe.filter(a=>o.has(a)),s=e.map((a,d)=>{let c={structural:e.length===1?1:1-d/r,...a.signals},u={},l=0,p=0;for(let g of i){let w=c[g];if(w===void 0)continue;let h=w*n[g];u[g]=h,l+=h,p+=n[g]}return{...a,baseline_rank:d+1,rank:0,score:p===0?0:l/p,contributions:u}});return s.sort((a,d)=>d.score-a.score||a.baseline_rank-d.baseline_rank),s.forEach((a,d)=>{a.rank=d+1}),{model:"default-weighted-v1",available_signals:i,ranked:s}}async function no(e,t={}){let n=nn(e,t);if(!t.scorer)return n;let r=await t.scorer({candidates:e,default_report:n}),o=new Map;for(let s of r){if(o.has(s.id)||!Number.isFinite(s.score))throw new TypeError("Context relevance scorer must return one finite score for every candidate");o.set(s.id,s.score)}if(o.size!==e.length||e.some(s=>!o.has(s.id)))throw new TypeError("Context relevance scorer must return one finite score for every candidate");let i=n.ranked.map(s=>{let a=o.get(s.id);return{...s,score:a,contributions:{custom:a}}});return i.sort((s,a)=>a.score-s.score||s.baseline_rank-a.baseline_rank),i.forEach((s,a)=>{s.rank=a+1}),{model:"custom",available_signals:n.available_signals,ranked:i}}async function ke(e,t,n={}){let r=nn(t,n),o=await yt(Jr,{surface:e,candidates:t,default_report:r});if(!o.handled)return o.warnings.length>0?{...r,warnings:o.warnings}:r;if(!Array.isArray(o.result)||!o.result.every(i=>typeof i=="object"&&i!==null&&typeof i.id=="string"&&typeof i.score=="number"&&Number.isFinite(i.score)))return{...r,warnings:[...o.warnings,"extension_context_relevance_invalid_result"]};try{let i=await no(t,{...n,scorer:()=>o.result});return o.warnings.length>0?{...i,warnings:o.warnings}:i}catch{return{...r,warnings:[...o.warnings,"extension_context_relevance_invalid_result"]}}}var ro=["ndcg","reciprocal_rank","required_recall","continuity_coverage","token_budget_adherence"];function tn(e,t){return e.length===0?1:e.filter(n=>t.has(n)).length/e.length}function oo(e){if(!Number.isFinite(e.actual_tokens)||e.actual_tokens<0||!Number.isFinite(e.token_budget)||e.token_budget<=0)throw new TypeError("Context ranking token counts require actual_tokens >= 0 and token_budget > 0");let t=e.judgments??{},n=e.ranked_ids.map(c=>Math.max(0,t[c]??0)),r=Object.values(t).map(c=>Math.max(0,c)).sort((c,u)=>u-c).slice(0,n.length||1),o=c=>c.reduce((u,l,p)=>u+(2**l-1)/Math.log2(p+2),0),i=o(r),s=n.findIndex(c=>c>0),a=new Set(e.ranked_ids),d=e.actual_tokens<=e.token_budget;return{ndcg:i===0?1:o(n)/i,reciprocal_rank:s<0?0:1/(s+1),required_recall:tn(e.required_ids??[],a),continuity_coverage:tn(e.continuity_ids??[],a),token_budget_adherence:d?1:e.token_budget/e.actual_tokens,within_token_budget:d}}function io(e){return Math.ceil(Qr.encode(JSON.stringify(e)).byteLength/4)}function so(e){return Math.round(e*1e4)/1e4}function ao(e,t){let n=t==="context"?[...e.high_level??[],...e.low_level??[],...e.blocked_fallback??[]].map(i=>i.id):[...e.recommended?[e.recommended]:[],...e.ready??[]].map(i=>i.id),r=new Set(n),o=(e.ranking?.items??[]).filter(i=>r.has(i.id)).map(i=>({id:i.id,contributions:i.contributions}));return{rankedIds:n,attribution:o}}async function co(e,t){if(e.id.trim().length===0||e.rationale.trim().length===0)throw new TypeError("Context evaluation scenarios require non-empty id and rationale values");let n=e.surface==="context"?await t.context({...e.options,explainRanking:!0}):await t.next({...e.options,explainRanking:!0}),{rankedIds:r,attribution:o}=ao(n,e.surface),i={...n,ranking:void 0},s=io(i);return{id:e.id,surface:e.surface,rationale:e.rationale,ranked_ids:r,actual_tokens:s,metrics:oo({ranked_ids:r,judgments:e.judgments,required_ids:e.required_ids,continuity_ids:e.continuity_ids,actual_tokens:s,token_budget:e.token_budget}),attribution:o}}function uo(e,t){if(e.length===0)throw new TypeError("Context evaluation requires at least one scenario report");let n=ro;for(let i of n)if(!Number.isFinite(t[i]))throw new TypeError(`Context evaluation threshold ${i} must be a finite number`);let r=Object.fromEntries(n.map(i=>[i,so(e.reduce((s,a)=>s+a.metrics[i],0)/e.length)])),o=n.filter(i=>r[i]<t[i]).map(i=>`${i}:${r[i]}<${t[i]}`);return{scenario_count:e.length,aggregate:r,scenarios:[...e],passed:o.length===0,failures:o}}async function ia(e,t,n){let r=[];for(let o of e)r.push(await co(o,t));return uo(r,n)}(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]="b5c90a16-c075-5dc6-a326-ad2da7a6ef6d")}catch{}})();var lo={balanced:{redundancyPenalty:.35,uncertaintyPenalty:.2},context:{redundancyPenalty:.45,uncertaintyPenalty:.15},next:{redundancyPenalty:.25,uncertaintyPenalty:.3}},fo=["identity","summary","full"];function mo(e){if(!e.id.trim()||!Number.isInteger(e.rank)||e.rank<1)throw new TypeError("Context packing candidates require a non-empty id and positive integer rank");if(!Number.isFinite(e.score)||e.score<0)throw new TypeError("Context packing candidate scores must be finite and non-negative");let t=fo.map(n=>e.token_costs[n]);if(t.some(n=>!Number.isInteger(n)||n<1)||t[0]>t[1]||t[1]>t[2])throw new TypeError("Context projection costs must be positive monotone integers");if(e.uncertainty!==void 0&&(!Number.isFinite(e.uncertainty)||e.uncertainty<0))throw new TypeError("Context packing uncertainty must be finite and non-negative")}function po(e){if(!Number.isInteger(e.tokenBudget)||e.tokenBudget<1)throw new TypeError("Context packing tokenBudget must be a positive integer");let t=e.profile??"balanced",n=lo[t];if(!n)throw new TypeError("Unknown context packing profile");let r=e.redundancyPenalty??n.redundancyPenalty,o=e.uncertaintyPenalty??n.uncertaintyPenalty;if(!Number.isFinite(r)||r<0||r>1||!Number.isFinite(o)||o<0)throw new TypeError("Context packing penalties must be finite and within their supported ranges");if(e.latencyBudgetMs!==void 0&&(!Number.isFinite(e.latencyBudgetMs)||e.latencyBudgetMs<=0))throw new TypeError("Context packing latencyBudgetMs must be positive");return{redundancy:r,uncertainty:o,profile:t}}function go(e){let t=new Set;for(let n of e){if(mo(n),t.has(n.id))throw new TypeError("Context packing candidates require unique ids");t.add(n.id)}return[...e].sort((n,r)=>n.rank-r.rank||n.id.localeCompare(r.id))}function ho(e,t,n,r,o){let i=-1,s=0;for(let a=0;a<e.length;a+=1){if(a%128===0&&o()>=r)return{index:i,evaluated:s,timedOut:!0};let d=e[a];if(d.token_costs.identity>t)continue;s+=1;let c=i<0?void 0:e[i],u=n(d)/d.token_costs.identity,l=c===void 0?Number.NEGATIVE_INFINITY:n(c)/c.token_costs.identity;(u>l||u===l&&c!==void 0&&(d.rank<c.rank||d.rank===c.rank&&d.id.localeCompare(c.id)<0))&&(i=a)}return{index:i,evaluated:s,timedOut:!1}}function yo(e){let t=new Set,n=[],r=e.tokenBudget,o=c=>{let u=c.lineage??c.cluster,l=u&&t.has(u)?1-e.redundancyPenalty:1;return Math.max(0,(c.score-e.uncertaintyPenalty*(c.uncertainty??0))*l)},i=c=>{let u=c.token_costs.identity;n.push({...c,projection:"identity",tokens:u,marginal_value:o(c)}),r-=u;let l=c.lineage??c.cluster;l&&t.add(l)};for(let c of e.ordered.filter(u=>u.required))c.token_costs.identity<=r&&i(c);let s=e.ordered.filter(c=>!c.required),a=!0,d=0;for(;s.length>0;){let c=ho(s,r,o,e.deadline,e.readClock);if(d+=c.evaluated,c.timedOut&&(a=!1),c.index<0||c.timedOut)break;i(s.splice(c.index,1)[0])}return{included:n,remaining:r,selectionComplete:a,evaluatedCandidates:d}}function _o(e,t){let n=t;for(let r of["summary","full"]){let o=r==="summary"?"identity":"summary",i=[...e].sort((s,a)=>{let d=s.token_costs[r]-s.token_costs[o],c=a.token_costs[r]-a.token_costs[o];return a.marginal_value/Math.max(c,1)-s.marginal_value/Math.max(d,1)||s.rank-a.rank||s.id.localeCompare(a.id)});for(let s of i){if(s.projection!==o)continue;let a=s.token_costs[r]-s.tokens;a>n||(s.projection=r,s.tokens+=a,n-=a)}}return n}function rn(e,t){let n=po(t),r=go(e),o=t.readClock??performance.now.bind(performance),i=t.latencyBudgetMs===void 0?Number.POSITIVE_INFINITY:o()+t.latencyBudgetMs,s=yo({ordered:r,tokenBudget:t.tokenBudget,redundancyPenalty:n.redundancy,uncertaintyPenalty:n.uncertainty,deadline:i,readClock:o}),{included:a}=s,d=_o(a,s.remaining);a.sort((u,l)=>u.rank-l.rank||u.id.localeCompare(l.id));let c=new Set(a.map(u=>u.id));return{included:a,omitted_ids:r.filter(u=>!c.has(u.id)).map(u=>u.id),token_budget:t.tokenBudget,used_tokens:t.tokenBudget-d,remaining_tokens:d,complete:s.selectionComplete&&a.length===e.length&&a.every(u=>u.projection==="full"),selection_complete:s.selectionComplete,termination_reason:s.selectionComplete?"exhausted":"latency_budget",evaluated_candidates:s.evaluatedCandidates,latency_budget_ms:t.latencyBudgetMs??null,profile:n.profile,degradation_ladder:["full","summary","identity"]}}import{randomUUID as wo}from"node:crypto";import{appendFile as ko,mkdir as bo,readFile as vo,rename as Co,stat as So,writeFile as xo}from"node:fs/promises";import on 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]="5f4ccd28-a001-54aa-8378-893025c69b96")}catch{}})();var sn=2048,an=30,cn=864e5,Eo=262144,To="context-usage-ledger",I=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function dn(e){return on.join(e,"runtime","context-usage.jsonl")}function J(e){let t=e.now??new Date().toISOString(),n=Date.parse(t);if(!Number.isFinite(n))throw new I("Context usage now must be a valid timestamp");return{iso:new Date(n).toISOString(),ms:n}}async function un(e){try{let n=(await vo(dn(e.pmRoot),"utf8")).split(`
|
|
@@ -10,4 +10,4 @@ import{a as L,b as Nt,c as At,u as V}from"./chunk-Q5F6OI7C.js";import{a as Ot,b
|
|
|
10
10
|
`)}catch{i.push("workspace_memory_write_failed")}return{snapshot:d,cache_status:"rebuilt",warnings:i}}function ti(e,t,n=yn){let r=Math.max(0,Math.floor(t)),o=0,i=[];for(let s of e.rollups){if(i.length>=Math.max(0,Math.floor(n)))break;let a=Math.ceil(JSON.stringify(s).length/4);o+a>r||(i.push(s),o+=a)}return i}function wn(e,t,n=yn){if(e.snapshot===null)return;let r=ti(e.snapshot,t,n);if(r.length!==0)return{cache_status:e.cache_status==="fresh"?"fresh":"rebuilt",source_cursor:e.snapshot.source_cursor,...e.snapshot.completion_time_sources?{completion_time_sources:{...e.snapshot.completion_time_sources}}:{},rollups:r}}function ni(e,t,n=5){if(e===null)return[];let r=t.trim().toLowerCase().split(/\s+/u).filter(Boolean);return r.length===0?[]:e.rollups.map(o=>({rollup:o,score:r.filter(i=>[o.key,o.label,...o.outcomes,...o.representative_items.flatMap(s=>[s.id,s.title])].join(" ").toLowerCase().includes(i)).length})).filter(({score:o})=>o>0).sort((o,i)=>i.score-o.score||i.rollup.last_closed_at.localeCompare(o.rollup.last_closed_at)||o.rollup.key.localeCompare(i.rollup.key)).slice(0,Math.max(0,Math.floor(n))).map(({rollup:o})=>o)}function Na(e,t,n=5){let r=ni(e.snapshot,t,n);if(r.length!==0)return{cache_status:e.cache_status==="fresh"?"fresh":"rebuilt",matches:r}}(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]="dbcd4e0e-3fa0-5ce9-8bbc-6de05779d729")}catch{}})();var ri=["markdown","toon","json","ndjson"],te=new Set(["Epic","Feature"]),xn=10,En=1e4,Tn=["hierarchy","activity","progress","recently_created","unparented","workload"],oi=[...Tn,"blockers","files","staleness","tests"],ii=/^(\d{4})-(\d{2})-(\d{2})/,si=/^(\d{4})(\d{2})(\d{2})(?:[T ]?\d{2}|$)/,ai=/^(\d{4})(\d{2})(\d{2})$/,ci=/^(\d{4})(\d{2})(\d{2})(?:[T\s]?)(\d{2})(\d{2})(\d{2})?(Z|[+-]\d{2}:?\d{2})?$/i;function di(e){if(!e)return;let t=e.trim().toLowerCase();if(!ri.includes(t))throw new m("Context format must be one of markdown|toon|json|ndjson",f.USAGE);return t}var kn=new Set(["id","title","type","status","priority","order","deadline","assignee","tags","tags_inherited","updated_at","parent","children_total","children_closed","completion_pct","blocked","blocker_ids","created_at"]);function ui(e){if(e===void 0)return;let t=[];for(let n of e.split(",")){let r=n.trim().toLowerCase();if(r.length!==0){if(!kn.has(r))throw new m(`Context --fields value not projectable: ${r} (valid: ${[...kn].join(", ")})`,f.USAGE);t.includes(r)||t.push(r)}}if(t.length===0)throw new m("Context --fields requires at least one field name",f.USAGE);return t}function ee(e,t){return e.map(n=>{let r={},o=n;for(let i of t)r[i]=o[i]??null;return r})}function qa(e,t){let n=di(e.format);if(t.json&&n&&n!=="json"&&n!=="ndjson")throw new m("Cannot combine --json with --format markdown|toon",f.USAGE);return t.json?n==="ndjson"?"ndjson":"json":n??"toon"}function li(e,t){return L(e,"--limit")??(t==="full"?Number.MAX_SAFE_INTEGER:xn)}function et(e,t){if(e===void 0)return t;let n=typeof e=="number"?e:Number(e);if(!Number.isInteger(n)||n<1)throw new m("--token-budget must be a positive integer",f.USAGE);return n}function fi(e,t){return t>=En&&e===Number.MAX_SAFE_INTEGER?xn:e}function mi(e,t){if(!e)return t.default_depth;let n=e.trim().toLowerCase();if(!Oe.includes(n))throw new m(`Context --depth must be one of ${Oe.join("|")}`,f.USAGE);return n}function pi(e,t,n){if(e&&e.length>0){let o=[];for(let i of e){let s=i.trim().toLowerCase();if(!ce.includes(s))throw new m(`Context --section must be one of ${ce.join("|")}`,f.USAGE);o.includes(s)||o.push(s)}return o}return t==="brief"?[]:t==="full"?[...ce]:(t==="deep"?oi:Tn).filter(o=>n.sections[o])}function gi(e,t){return e?L(e,"--activity-limit")??t.activity_limit:t.activity_limit}function hi(e,t){if(!e)return t.stale_threshold_days;let n=e.trim().toLowerCase(),r=/^(\d+)d?$/.exec(n);if(!r)throw new m("--stale-threshold must be a number of days (e.g. 7 or 7d)",f.USAGE);let o=parseInt(r[1],10);if(o<=0)throw new m("--stale-threshold must be positive",f.USAGE);return o}function bn(e,t){let n=C(e,t),r=v("in_progress",t),o=v("open",t),i=v("blocked",t),s=v("draft",t);return r&&n===r?0:o&&n===o?1:i&&n===i?2:s&&n===s?3:t.active_statuses.has(n)?4:t.blocked_statuses.has(n)?5:t.terminal_statuses.has(n)?7:6}function ne(e,t){let n=v("closed",t);return C(e,t)===n}function tt(e,t){let n=v("in_progress",t);return C(e,t)===n}function In(e,t){let n=v("open",t);return C(e,t)===n}function yi(e,t){return t.blocked_statuses.has(C(e,t))}var _i=["compact","brief","fields","includeBody","include_body","parent"];function wi(e){let t={...e};for(let n of _i)delete t[n];return t}function nt(e,t){let n=t.trim().toLowerCase(),r=e.find(a=>a.id.trim().toLowerCase()===n);if(!r)return{ids:new Set,found:!1};let o=q(e),i=re(r.id,o);return{ids:new Set([r.id,...i.map(a=>a.id)].map(a=>a.trim().toLowerCase())),found:!0}}function ki(e){if(e===void 0)return;let t=e.trim();if(t.length===0)throw new m("Context --parent requires an item id",f.USAGE);return t}function bi(e,t){let n=e??null,r=t??null;return n===null&&r===null?0:n===null?1:r===null?-1:n-r}function vi(e,t){let n=e??null,r=t??null;return n===null&&r===null?0:n===null?1:r===null?-1:b(n,r)}function Ci(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}function Si(e){let t=ii.exec(e)??si.exec(e);if(!t)return!0;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10),o=Number.parseInt(t[3],10);return r>=1&&r<=12&&o>=1&&o<=Ci(n,r-1)}function xi(e){let t=ai.exec(e);if(t)return`${t[1]}-${t[2]}-${t[3]}`;let n=ci.exec(e);if(n){let[,r,o,i,s,a,d,c]=n,u=d?`:${d}`:"",l=c&&c.length===5&&c!=="Z"?`${c.slice(0,3)}:${c.slice(3)}`:c??"";return`${r}-${o}-${i}T${s}:${a}${u}${l}`}return e}function $n(e){if(typeof e!="string")return Number.NaN;let t=e.trim();if(t.length===0||!Si(t))return Number.NaN;let n=Date.parse(xi(t));return Number.isFinite(n)?n:Number.NaN}function Qe(e){let t=$n(e);return Number.isFinite(t)?new Date(t).toISOString():""}function Ei(e){let t=$n(e);return Number.isFinite(t)?new Date(t).toISOString().slice(0,10):"unknown"}function rt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function U(e,t,n){let r=bn(e.status,n)-bn(t.status,n);if(r!==0)return r;let o=e.priority-t.priority;if(o!==0)return o;let i=bi(e.order,t.order);if(i!==0)return i;let s=vi(e.deadline,t.deadline);if(s!==0)return s;let a=b(Qe(t.updated_at),Qe(e.updated_at)),d=e.id.localeCompare(t.id);return a!==0?a:d}function Ze(e){return Math.max(1,Math.ceil(Buffer.byteLength(JSON.stringify(e),"utf8")/4))}function ot(e,t,n=new Set,r="context"){return rn(e.ranked.map(o=>({id:o.id,item:o.item,rank:o.rank,score:o.score,required:n.has(o.id),cluster:o.item.parent?.trim()||o.item.type,token_costs:{identity:Ze({id:o.id,title:o.item.title}),summary:Ze({id:o.id,title:o.item.title,type:o.item.type,status:o.item.status,priority:o.item.priority,parent:o.item.parent}),full:Ze(o.item)}})),{tokenBudget:t,profile:r,latencyBudgetMs:25})}function it(e){return{...e,included:e.included.map(t=>({id:t.id,projection:t.projection,tokens:t.tokens}))}}function st(e,t){return{model:e.model,available_signals:e.available_signals,items:e.ranked.map(n=>({id:n.id,rank:n.rank,baseline_rank:n.baseline_rank,score:n.score,contributions:n.contributions})),...t?{feature_store:{source:t.snapshot.source,cache_status:t.cache_status,source_cursor:t.snapshot.source_cursor,generated_at:t.snapshot.generated_at}}:{}}}function Dn(e,t){return t>0?Math.round(e/t*100):0}function q(e){let t=new Map;for(let n of e){let r=rt(n.parent);if(!r)continue;let o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function oe(e,t,n){let r={id:e.id,title:e.title,type:e.type,status:e.status,priority:e.priority,order:e.order??null,deadline:e.deadline??null,assignee:e.assignee??null,tags:Array.isArray(e.tags)?[...e.tags]:[],updated_at:e.updated_at,parent:rt(e.parent)};if(t&&n){let o=re(e.id,n),i=o.length;if(i>0){let s=o.filter(a=>ne(a.status,t)).length;r.children_total=i,r.children_closed=s,r.completion_pct=Dn(s,i)}}return r}function Ti(e){let t=0,n=0,r=0,o=new Set;for(let i of e){if(o.add(i.item_id),i.kind==="deadline"){t+=1;continue}if(i.kind==="reminder"){n+=1;continue}r+=1}return{events:e.length,items:o.size,deadlines:t,reminders:n,scheduled:r}}function xe(...e){return[...new Set(e.flatMap(t=>t??[]))].sort((t,n)=>t.localeCompare(n))}function Ii(e,t){return e.filter(n=>!t.terminal_statuses.has(C(n.item_status,t)))}function $i(e,t,n,r){let o=new Map;for(let d of e)o.set(d.id,d);let i=q(e),s=new Set(t.filter(d=>te.has(d.type)).map(d=>d.id)),a=[];for(let d of s){let c=o.get(d);if(!c)continue;let u=re(d,i),l=i.get(d)??[],p=0,g=0,w=0,h=0;for(let _ of u)ne(_.status,n)?p++:tt(_.status,n)?w++:yi(_.status,n)?h++:In(_.status,n)&&g++;let S=l.sort((_,k)=>U(_,k,n)).slice(0,r).map(_=>{let k=re(_.id,i),x=k.filter($=>ne($.status,n)).length;return{id:_.id,title:_.title,type:_.type,status:_.status,children_total:k.length,children_closed:x}});a.push({id:c.id,title:c.title,type:c.type,status:c.status,children_total:u.length,children_closed:p,children_open:g,children_in_progress:w,children_blocked:h,children:S})}return a.sort((d,c)=>{let u=o.get(d.id),l=o.get(c.id);return U(u,l,n)}).slice(0,r)}function re(e,t){let n=[],r=[e],o=new Set;for(;r.length>0;){let i=r.pop();if(o.has(i))continue;o.add(i);let s=t.get(i)??[];for(let a of s)n.push(a),r.push(a.id)}return n}async function Di(e,t){return(await zt({compact:!0,limit:String(e)},t)).compact_activity??[]}function Ni(e,t,n,r,o){let i=new Map;for(let d of e){if(!d.parent)continue;let c=i.get(d.parent)??[];c.push(d),i.set(d.parent,c)}let s=t.filter(d=>te.has(d.type)),a=[];for(let d of s){let c=re(d.id,i),u=c.length;if(u===0)continue;let l=0,p=0,g=0,w=0;for(let h of c)ne(h.status,r)?l++:n.has(h.id.trim().toLowerCase())?w++:tt(h.status,r)?g++:In(h.status,r)&&p++;a.push({id:d.id,title:d.title,type:d.type,total:u,closed:l,open:p,in_progress:g,blocked:w,completion_pct:Dn(l,u)})}return a.sort((d,c)=>d.completion_pct-c.completion_pct).slice(0,o)}function Ai(e,t,n,r){let o=new Map(t.map(i=>[i.id.trim().toLowerCase(),i]));return e.slice(0,r).map(i=>{let s=Fe(i,o,n),a=s.find(c=>!c.resolved)?.id??s[0]?.id??null,d=a?o.get(a.trim().toLowerCase()):void 0;return{id:i.id,title:i.title,blocked_by:a,blocked_by_title:d?.title??null,blocked_by_status:d?.status??null,blocked_reason:i.blocked_reason??null,unblock_note:i.unblock_note??null}})}function Oi(e,t){let n=new Map;for(let r of e)for(let o of r.files??[]){let i=n.get(o.path)??new Set;i.add(r.id),n.set(o.path,i)}return[...n.entries()].map(([r,o])=>({path:r,references:o.size,items:[...o].sort()})).sort((r,o)=>o.references-r.references).slice(0,t)}function Mi(e,t,n){let r=new Map;for(let o of e){let i=o.assignee??null,s=r.get(i)??[];s.push(o),r.set(i,s)}return[...r.entries()].map(([o,i])=>({assignee:o,active:i.length,in_progress:i.filter(s=>tt(s.status,t)).length,items:i.map(s=>s.id).sort()})).sort((o,i)=>i.active-o.active).slice(0,n)}function Fi(e,t,n,r){let o=new Date(n).getTime()-t*24*60*60*1e3;return e.filter(i=>new Date(i.updated_at).getTime()<o).map(i=>({id:i.id,title:i.title,status:i.status,updated_at:i.updated_at,stale_days:Math.floor((new Date(n).getTime()-new Date(i.updated_at).getTime())/(1440*60*1e3))})).sort((i,s)=>s.stale_days-i.stale_days).slice(0,r)}function Ri(e,t,n,r){return e.map(o=>({item:o,sortKey:Qe(o.created_at)})).sort((o,i)=>{let s=b(i.sortKey,o.sortKey);return s!==0?s:o.item.id.localeCompare(i.item.id)}).slice(0,r).map(({item:o})=>({...oe(o,t,n),created_at:o.created_at}))}function Li(e,t,n,r){return e.filter(o=>!rt(o.parent)&&!te.has(o.type)).sort((o,i)=>U(o,i,t)).slice(0,r).map(o=>oe(o,t,n))}function Ui(e){let t=0,n=0,r=0,o=0,i=0,s=[];for(let a of e){(a.tests??[]).length>0&&t++;let d=a.test_runs??[];if(d.length>0){n++;let c=!1;for(let u of d)r+=u.passed??0,o+=u.failed??0,i+=u.skipped??0,(u.failed??0)>0&&(c=!0);c&&s.push(a.id)}}return{items_with_tests:t,items_with_recent_runs:n,recent_runs:{passed:r,failed:o,skipped:i},items_failing:s.sort()}}function vn(e){return`${new Date(e).toISOString().slice(11,16)}Z`}function Nn(e){let t=e.order===null?"-":String(e.order),n=e.deadline??"-",r=e.parent?` parent:${e.parent}`:"",o=e.children_total!==void 0&&e.children_closed!==void 0&&e.completion_pct!==void 0?` children:${e.children_closed}/${e.children_total} done:${e.completion_pct}%`:"",i=e.blocked===!0?` blocked:${e.blocker_ids?.join(",")||"lifecycle"}`:"";return`${e.id} p${e.priority} ${e.status} ${e.type} order:${t} deadline:${n}${r}${o}${i} ${e.title}`}function Pi(e,t){let n=e;return t.map(r=>{let o=n[r];return Array.isArray(o)?`${r}:${o.join(",")}`:`${r}:${o??"-"}`}).join(" ")}function ji(e){if("reference_only"in e){let n=e.kind==="reminder"?` \u2014 ${e.reminder_text??"reminder"}`:e.kind==="event"?` \u2014 ${e.event_title??"event"}${e.event_recurring?" (recurring)":""}`:"";return`${vn(e.at)} [${e.kind}] ${e.item_id} (see focus item)${n}`}let t=`${vn(e.at)} [${e.kind}] ${e.item_id} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder")return`${t} \u2014 ${e.reminder_text}`;if(e.kind==="event"){let n=e.event_recurring?" (recurring)":"",r=e.event_title??e.item_title;return`${t} \u2014 ${r}${n}`}return t}function Cn(e,t,n,r,o){if(e.push(`## ${t}`),n.length===0)e.push(r);else for(let i of n)e.push(`- ${o(i)}`);e.push("")}function Bi(e,t,n){if(t.blocked_fallback.length!==0){e.push("## Blocked fallback");for(let r of t.blocked_fallback)e.push(`- ${n(r)}`);e.push("")}}function zi(e,t){if(e.push("## Agenda"),e.push(`- events: ${t.agenda.summary.events} (deadlines: ${t.agenda.summary.deadlines}, reminders: ${t.agenda.summary.reminders}, scheduled: ${t.agenda.summary.scheduled})`),t.agenda.events.length===0)e.push("No agenda events matched the selected filters.");else for(let n of t.agenda.events)e.push(`- ${ji(n)}`);e.push("")}function Gi(e,t){if(!(!t.hierarchy||t.hierarchy.length===0)){e.push("## Hierarchy");for(let n of t.hierarchy){let r=n.children_total>0?Math.round(n.children_closed/n.children_total*100):0;e.push(`- ${n.id} ${n.type} ${n.status} "${n.title}" [${n.children_closed}/${n.children_total} done ${r}%]`);for(let o of n.children){let i=o.children_total>0?Math.round(o.children_closed/o.children_total*100):0;e.push(` - ${o.id} ${o.type} ${o.status} "${o.title}" [${o.children_closed}/${o.children_total} done ${i}%]`)}}e.push("")}}function Wi(e,t){if(!(!t.progress||t.progress.length===0)){e.push("## Progress");for(let n of t.progress)e.push(`- ${n.id} "${n.title}" ${n.completion_pct}% (${n.closed}/${n.total} closed, ${n.in_progress} wip, ${n.open} open, ${n.blocked} blocked)`);e.push("")}}function Hi(e,t,n,r){if(!(!t.recently_created||t.recently_created.length===0)){e.push("## Recently created");for(let o of t.recently_created)e.push(n?`- ${r(o)}`:`- ${Ei(o.created_at)} ${Nn(o)}`);e.push("")}}function Xi(e,t,n){if(!(!t.unparented||t.unparented.length===0)){e.push("## Unparented");for(let r of t.unparented)e.push(`- ${n(r)}`);e.push("")}}function qi(e,t){if(!(!t.activity||t.activity.length===0)){e.push("## Recent activity");for(let n of t.activity){let r=n.msg?` ${n.msg}`:"";e.push(`- ${n.ts.slice(0,16)}Z ${n.id} ${n.op} by:${n.author}${r}`)}e.push("")}}function Yi(e,t){if(!(!t.blockers||t.blockers.length===0)){e.push("## Blockers");for(let n of t.blockers){let r=n.blocked_by?`blocked_by:${n.blocked_by}(${n.blocked_by_status??"?"})`:"blocked_by:-",o=n.blocked_reason?` reason:"${n.blocked_reason}"`:"",i=n.unblock_note?` unblock:"${n.unblock_note}"`:"";e.push(`- ${n.id} "${n.title}" ${r}${o}${i}`)}e.push("")}}function Vi(e,t){if(!(!t.files||t.files.length===0)){e.push("## Hot files");for(let n of t.files)e.push(`- ${n.path} refs:${n.references} items:[${n.items.join(",")}]`);e.push("")}}function Ki(e,t){if(!(!t.workload||t.workload.length===0)){e.push("## Workload");for(let n of t.workload){let r=n.assignee??"(unassigned)";e.push(`- ${r} active:${n.active} wip:${n.in_progress} items:[${n.items.join(",")}]`)}e.push("")}}function Ji(e,t){if(!(!t.staleness||t.staleness.length===0)){e.push("## Stale items");for(let n of t.staleness)e.push(`- ${n.id} ${n.status} stale:${n.stale_days}d last:${n.updated_at.slice(0,10)} "${n.title}"`);e.push("")}}function Zi(e,t){t.tests&&(e.push("## Test health"),e.push(`- items_with_tests: ${t.tests.items_with_tests}`),e.push(`- items_with_recent_runs: ${t.tests.items_with_recent_runs}`),e.push(`- passed: ${t.tests.recent_runs.passed}, failed: ${t.tests.recent_runs.failed}, skipped: ${t.tests.recent_runs.skipped}`),t.tests.items_failing.length>0&&e.push(`- items_failing: [${t.tests.items_failing.join(",")}]`),e.push(""))}function Qi(e,t){t.summary.active_items===0&&t.summary.blocked===0&&t.agenda.summary.events===0&&(e.push("## Suggestions"),e.push("No active work items or upcoming events. Consider:"),e.push('- `pm create --type Task --title "..."` to add a new work item'),e.push("- `pm list --status closed --limit 5` to review recent completions"),e.push("- `pm search <keywords>` to find related past work"),e.push("- `pm aggregate` for a full project status overview"))}function Ya(e){let t=[],n=e.focus_fields,r=i=>n?Pi(i,n):Nn(i);if(t.push("# pm context"),t.push(""),t.push(`- now: ${e.now}`),t.push(`- depth: ${e.depth}`),e.filters.parent&&t.push(`- scope: subtree of ${e.filters.parent}`),t.push(`- active_items: ${e.summary.active_items} (in_progress: ${e.summary.in_progress}, open: ${e.summary.open})`),e.summary.total_items!==void 0&&t.push(`- total_items: ${e.summary.total_items} (closed: ${e.summary.closed??0}, canceled: ${e.summary.canceled??0})`),t.push(`- agenda_events: ${e.summary.agenda_events}`),t.push(`- blocked_fallback_used: ${e.summary.blocked_fallback_used}`),e.extension_health){let i=e.extension_health.packages.filter(s=>s.status==="degraded").map(s=>s.name);t.push(`- extensions: ${e.extension_health.ok} ok, ${e.extension_health.degraded} degraded${i.length>0?` (${i.join(", ")})`:""}`)}let o=e.sections_included.filter(i=>i!=="blockers"||(e.blockers?.length??0)>0);if(o.length>0&&t.push(`- sections: ${o.join(", ")}`),t.push(""),Cn(t,"High-level focus",e.high_level,"No high-level active items.",r),Cn(t,"Low-level focus",e.low_level,"No low-level active items.",r),Bi(t,e,r),zi(t,e),e.workspace_memory){t.push("## Workspace memory");for(let i of e.workspace_memory.rollups)t.push(`- ${i.kind}:${i.key} \u2014 ${i.label} (${i.item_count} completed, latest ${i.last_closed_at})`);t.push("")}return Gi(t,e),Wi(t,e),Hi(t,e,n,r),Xi(t,e,r),qi(t,e),Yi(t,e),Vi(t,e),Ki(t,e),Ji(t,e),Zi(t,e),Qi(t,e),t.join(`
|
|
11
11
|
`)}async function es(e,t){let n=N(process.cwd(),t.path),r=await M(n),o=r.context??ft.context,i=H(r.schema),s=mi(e.depth,o),a=li(e.limit??e.maxItems,s);return{settings:r,contextSettings:o,statusRegistry:i,depth:s,limit:a,sectionsIncluded:pi(e.section,s,o),activityLimit:gi(e.activityLimit,o),staleThresholdDays:hi(e.staleThreshold,o),parentScope:ki(e.parent),focusFields:ui(e.fields),baseListOptions:wi(e)}}function at(e){return e.some(t=>["hierarchy","progress","blockers","staleness","recently_created","unparented"].includes(t))}function ts(e,t){return{...e,...t,noTruncate:!0,limit:void 0,offset:void 0,after:void 0}}async function ns(e,t){let n=at(t.sectionsIncluded),r=await V(void 0,ts(t.baseListOptions,{excludeTerminal:!1}),e),o=r.items,i=o.filter(d=>!Me(d.status,t.statusRegistry)),s=n||t.parentScope!==void 0?o:i,a=rs(t.parentScope,o);return a&&(i=i.filter(d=>a.has(d.id.trim().toLowerCase())),s=s.filter(d=>a.has(d.id.trim().toLowerCase()))),{listed:r,listedItemMetadata:i,allItems:s,fullCorpus:o,subtreeIds:a}}function rs(e,t){if(e===void 0)return;let n=nt(t,e);if(!n.found)throw new m(`Context --parent item not found: ${e}`,f.NOT_FOUND);return n.ids}async function os(e,t,n,r,o,i,s,a,d,c,u,l,p,g){let w=[...e].sort((y,z)=>U(y,z,o)),h=await ve({pmRoot:p,author:d,enabled:process.env.PM_CONTEXT_USAGE_DISABLED!=="1"}),S=await Se(w,{pmRoot:p,storeKey:"context",statusRegistry:o,now:a,author:d,usageAffinity:h.affinity}),_=await ke("context",S.candidates),k=_.ranked.map(y=>y.item),x=o.active_statuses,$=k.filter(y=>x.has(C(y.status,o))),P=l?St($,c,u,y=>y.id):0,E=l?$.slice(P,P+s):$,ie=l&&E.length>0&&P+E.length<$.length,se=ie&&E.length>0?Ct(u,E[E.length-1].id,P+E.length-1):void 0,Ie=k.filter(y=>r.has(y.id.trim().toLowerCase())),$e=new Set([...E.map(y=>y.id),...Ie.slice(0,s).map(y=>y.id)]),F=ot({..._,ranked:_.ranked.filter(y=>$e.has(y.id))},g),j=F.included.map(y=>y.item),R=j.filter(y=>x.has(C(y.status,o))),B=j.filter(y=>r.has(y.id.trim().toLowerCase())),De=q(t),Ne=at(i)?De:void 0,D=new Map(n.map(y=>[y.id.trim().toLowerCase(),y])),T=y=>{let z=oe(y,o,Ne);return r.has(y.id.trim().toLowerCase())&&(z.blocked=!0,z.blocker_ids=Fe(y,D,o).filter(Ae=>!Ae.resolved).map(Ae=>Ae.id)),z},Rn=R.filter(y=>te.has(y.type)).slice(0,l?E.length:s).map(T),Ln=R.filter(y=>!te.has(y.type)).slice(0,l?E.length:s).map(T),ut=$.length===0;return{activeItems:R,blockedItems:B,highLevel:Rn,lowLevel:Ln,blockedFallback:ut?B.slice(0,s).map(T):[],blockedFallbackUsed:ut,ranking:_,packing:F,featureStore:S,pageExtras:{...l?{applied_limit:s}:{},...ie?{has_more:!0,truncated:!0}:{},...se?{next_cursor:se}:{}}}}function is(e){return vt("context",bt(e,Dt))}function ss(e,t){return e.limit!==void 0||e.maxItems!==void 0||e.after!==void 0||t>=En}async function as(e,t,n,r){let o={...t.baseListOptions,view:"agenda",include:"all",limit:t.parentScope===void 0?String(t.limit):void 0},i=await Qt(o,e),s=n===void 0?i.events:i.events.filter(c=>n.has(c.item_id.trim().toLowerCase())),a=Ii(s,t.statusRegistry).slice(0,t.limit),d=a.map(c=>r.has(c.item_id)?{at:c.at,date:c.date,kind:c.kind,item_id:c.item_id,reference_only:!0,...c.kind==="reminder"?{reminder_text:c.reminder_text}:{},...c.kind==="event"?{event_title:c.event_title,event_recurring:c.event_recurring}:{}}:c);return{agenda:i,agendaEvents:d,agendaSummary:Ti(a)}}function Sn(e,t,n){let r=String(t);return e.filter(o=>C(o.status,n)===r).length}async function cs(e){let{runtime:t,allItems:n,fullCorpus:r,blockedIds:o,focusGroups:i,now:s,global:a}=e,d=q(n),c=n.filter(l=>!Me(l.status,t.statusRegistry)),u=l=>t.sectionsIncluded.includes(l);return{hierarchy:u("hierarchy")?$i(n,i.activeItems,t.statusRegistry,t.limit):void 0,activity:u("activity")?await Di(t.activityLimit,a):void 0,progress:u("progress")?Ni(n,i.activeItems,o,t.statusRegistry,t.limit):void 0,blockersSection:u("blockers")?Ai(i.blockedItems,r,t.statusRegistry,t.limit):void 0,recentlyCreated:u("recently_created")?Ri(c,t.statusRegistry,d,t.limit):void 0,unparented:u("unparented")?Li(c,t.statusRegistry,d,t.limit):void 0,filesSection:u("files")?Oi(i.activeItems,t.limit):void 0,workload:u("workload")?Mi(i.activeItems,t.statusRegistry,t.limit):void 0,staleness:u("staleness")?Fi(c,t.staleThresholdDays,s,t.limit):void 0,tests:u("tests")?Ui(i.activeItems):void 0}}function ds(e,t,n){if(!e)return{};let r=v("canceled",n);return{total_items:t.length,closed:t.filter(o=>ne(o.status,n)).length,canceled:t.filter(o=>C(o.status,n)===r).length}}function us(e,t){t.hierarchy&&(e.hierarchy=t.hierarchy),t.activity&&(e.activity=t.activity),t.progress&&(e.progress=t.progress),t.blockersSection&&(e.blockers=t.blockersSection),t.recentlyCreated&&(e.recently_created=t.recentlyCreated),t.unparented&&(e.unparented=t.unparented),t.filesSection&&(e.files=t.filesSection),t.workload&&(e.workload=t.workload),t.staleness&&(e.staleness=t.staleness),t.tests&&(e.tests=t.tests)}function ls(e,t){t&&(e.focus_fields=t,e.high_level=ee(e.high_level,t),e.low_level=ee(e.low_level,t),e.blocked_fallback=ee(e.blocked_fallback,t),e.recently_created&&(e.recently_created=ee(e.recently_created,t)),e.unparented&&(e.unparented=ee(e.unparented,t)))}function fs(e,t){let n=[e.high_level,e.low_level,e.blocked_fallback,e.recently_created??[],e.unparented??[]].flat();if(t){for(let i of n)delete i.tags,delete i.tags_inherited;return}let r=new Map(n.map(i=>[i.id,i])),o=new Map(n.map(i=>[i.id,i.tags?[...i.tags].sort().join("\0"):void 0]));for(let i of n){if(!i.parent||!i.tags)continue;let s=r.get(i.parent);s&&o.get(i.id)===o.get(s.id)&&(delete i.tags,i.tags_inherited=s.id)}}function ms(e,t,n){t.length>0||n.length>0||e.agenda.events.length>0||(e.suggestions=['pm create --type Task --title "..." to add a new work item',"pm list --status closed --limit 5 to review recent completions","pm search <keywords> to find related past work","pm aggregate for a full project status overview"])}async function ps(e,t,n,r){try{let o=new Set(t.packing.included.map(i=>i.id));await be({pmRoot:n,author:r,surface:"context",profile:t.packing.profile,rows:t.ranking.ranked.map(i=>({id:i.id,rank:i.rank,included:o.has(i.id)})),enabled:process.env.PM_CONTEXT_USAGE_DISABLED!=="1"})}catch{e.warnings=xe(e.warnings,["context_usage_feedback_write_failed"])}}async function gs(e,t,n){if(e)return{};let o=(await gt({pmRoot:t,settings:n,cwd:process.cwd(),noExtensions:!1})).discovered.map(s=>({name:s.name??s.directory,status:s.status==="ok"?"ok":"degraded"})).sort((s,a)=>s.name.localeCompare(a.name)),i=o.filter(s=>s.status==="degraded").length;return o.length===0?{}:{extension_health:{total:o.length,ok:o.length-i,degraded:i,packages:o.slice(0,20),...o.length>20?{truncated:!0}:{}}}}async function Va(e,t){let n=N(process.cwd(),t.path),r=await es(e,t),o=await ns(t,r),i=fi(r.limit,o.fullCorpus.length),s={...r,limit:i,tokenBudget:et(e.tokenBudget,Math.max(256,i*160))},a=Y(void 0,s.settings.author_default),d=gs(e.noExtensionHealth===!0,n,s.settings),c=Mt(o.fullCorpus,s.statusRegistry),u=await os(o.listedItemMetadata,o.allItems,o.fullCorpus,c,s.statusRegistry,s.sectionsIncluded,s.limit,O(),a,e.after,is(e),ss(e,o.fullCorpus.length),n,s.tokenBudget),l=await as(t,s,o.subtreeIds,new Set([...u.highLevel,...u.lowLevel,...u.blockedFallback].map(x=>x.id))),p=await _n(o.fullCorpus,{pmRoot:n,statusRegistry:s.statusRegistry,now:l.agenda.now}),g=xe(o.listed.warnings,l.agenda.warnings,u.ranking.warnings,[...u.featureStore.warnings],p.warnings),w=Sn(u.activeItems,v("in_progress",s.statusRegistry),s.statusRegistry),h=Sn(u.activeItems,v("open",s.statusRegistry),s.statusRegistry),S=await cs({runtime:s,allItems:o.allItems,fullCorpus:o.fullCorpus,blockedIds:c,focusGroups:u,now:l.agenda.now,global:t}),_=ds(at(s.sectionsIncluded),o.allItems,s.statusRegistry),k={output_default:"toon",now:l.agenda.now,depth:s.depth,sections_included:s.sectionsIncluded,window:{anchor:l.agenda.anchor,start:l.agenda.range.start,end:l.agenda.range.end,past:l.agenda.range.past,from:l.agenda.range.from,to:l.agenda.range.to},filters:{type:e.type??null,tag:e.tag??null,priority:e.priority??null,assignee:e.assignee??null,assignee_filter:e.assigneeFilter??null,sprint:e.sprint??null,release:e.release??null,limit:e.limit??e.maxItems??null,parent:s.parentScope??null,token_budget:s.tokenBudget,runtime_filters:o.listed.filters.runtime_filters??l.agenda.filters.runtime_filters??{}},summary:{active_items:u.activeItems.length,in_progress:w,open:h,blocked:u.blockedItems.length,blocked_fallback_used:u.blockedFallbackUsed,high_level:u.highLevel.length,low_level:u.lowLevel.length,agenda_events:l.agendaSummary.events,..._},high_level:u.highLevel,low_level:u.lowLevel,blocked_fallback:u.blockedFallback,agenda:{summary:l.agendaSummary,events:l.agendaEvents},...u.pageExtras};return k.workspace_memory=wn(p,Math.min(800,Math.floor(s.tokenBudget*.2))),Object.assign(k,await d),us(k,S),fs(k,e.noTags===!0),e.explainRanking===!0&&(k.ranking=st(u.ranking,u.featureStore),k.packing=it(u.packing)),ls(k,s.focusFields),g.length>0&&(k.warnings=g),ms(k,u.activeItems,u.blockedItems),await ps(k,u,n,a),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]="3431d4d4-e053-5416-b3d1-6dbfbed0142d")}catch{}})();var hs=["markdown","toon","json"],ys=5,_s=1440*60*1e3;function ws(e){if(!e)return;let t=e.trim().toLowerCase();if(!hs.includes(t))throw new m("Next format must be one of markdown|toon|json",f.USAGE);return t}function sc(e,t){let n=ws(e.format);if(t.json&&n&&n!=="json")throw new m("Cannot combine --json with --format markdown|toon",f.USAGE);return t.json?"json":n??"toon"}function An(e,t,n){let r=L(e,t);return r===void 0||r<=0?n:r}function ct(e,t,n,r){return{...oe(e.item,t,n),open_blocker_count:e.open_blockers.length,blockers:e.open_blockers.map(o=>({id:o.id,title:o.title,status:o.status})),unblocks:e.unblocks,rank:r}}function ks(e,t,n,r){let o=e.item,i=[],s=v("in_progress",t);return i.push(C(o.status,t)===s?"in progress \u2014 resume to finish":"open and ready to start"),r&&i.push("completed container \u2014 governance closeout"),i.push(`priority p${o.priority}${o.priority===0?" (highest)":""}`),typeof o.deadline=="string"&&o.deadline.trim().length>0&&i.push(vs(o.deadline,n)),i.push(Ot(o).length>0?"all blockers resolved":"no blockers"),typeof o.parent=="string"&&o.parent.trim().length>0&&i.push(`advances ${o.parent.trim()}`),e.unblocks.length>0&&i.push(`unblocks ${e.unblocks.length} item(s): ${e.unblocks.join(", ")}`),i}function Mn(e,t,n){let r=Y(n,t),o=[],i=[];for(let s of e){let a=typeof s.item.assignee=="string"?s.item.assignee.trim():"";a.length>0&&a!==r?i.push({id:s.item.id,assignee:a}):o.push(s)}return{available:o,held:i}}var ac={partitionCallerOwnedReady:Mn,resolveNextCallerAuthor:(e,t)=>Fn(e,t)};function bs(e,t){let n=e.filter(r=>r.item.type.trim().toLowerCase()==="decision");return{agent:t?e:e.filter(r=>r.item.type.trim().toLowerCase()!=="decision"),decisions:t?[]:n}}function vs(e,t){let n=Date.parse(e);if(!Number.isFinite(n))return`deadline ${e.trim()}`;let r=new Date(n).toISOString().slice(0,10),o=new Date(Date.parse(t)).toISOString().slice(0,10),i=Math.round((Date.parse(r)-Date.parse(o))/_s);return i<0?`deadline ${r} (overdue ${-i}d)`:i===0?`deadline ${r} (due today)`:`deadline ${r} (in ${i}d)`}function Cs(e,t){let n=v("in_progress",t);return e.filter(r=>C(r.status,t)===n).length}function dt(e,t){return(t.get(e.id.trim().toLowerCase())??[]).length>0}function Ss(e,t){return{type:e.type,tag:e.tag,priority:typeof e.priority=="number"?String(e.priority):e.priority,assignee:e.assignee,assigneeFilter:e.assigneeFilter,sprint:e.sprint,release:e.release,noTruncate:!0,...t}}function On(e,t,n){return[...e].sort((r,o)=>{let i=dt(r.item,t),s=dt(o.item,t);return i!==s?Number(i)-Number(s):U(r.item,o.item,n)})}function xs(e){return e.projectedReady.length===0?null:{...e.readyRows[0],reasons:ks(e.projectedReady[0],e.statusRegistry,e.now,e.completedContainer)}}function Es(e,t){if(e===null){if(t.length>0){let n=t.find(r=>r.blockers.length>0);return[n?`${t.length} item(s) are blocked; unblock the top one by closing ${n.blockers.map(r=>r.id).join(", ")}`:`${t.length} item(s) are blocked; add blocker context or move the top item back to an active status`,"pm next --ready-only after a blocker closes to re-check ready work",'pm create --type Task --title "..." to add new ready work']}return['pm create --type Task --title "..." to add a new work item',"pm list --status in_progress to review work already underway","pm context --depth deep for the full project snapshot"]}}function Ts(e,t,n){let r={};return e>n&&(r.decision_needed_total=e),t>n&&(r.held_by_others_total=t),Object.keys(r).length>0?r:void 0}async function Is(e){try{let t=new Set(e.packing.included.map(n=>n.id));await be({pmRoot:e.pmRoot,author:e.author,surface:"next",profile:e.packing.profile,rows:e.ranking.ranked.map(n=>({id:n.id,rank:n.rank,included:t.has(n.id)})),enabled:process.env.PM_CONTEXT_USAGE_DISABLED!=="1"})}catch{e.result.warnings=xe(e.result.warnings,["context_usage_feedback_write_failed"])}}async function $s(e){let t=[...new Set([...e.candidatesWarnings??[],...e.corpusWarnings??[],...e.readyRanking.warnings??[],...e.featureStore.warnings])].sort((n,r)=>n.localeCompare(r));return t.length>0&&(e.result.warnings=t),e.explainRanking&&(e.result.ranking=st(e.readyRanking,e.featureStore),e.result.packing=it(e.packing)),e.result.suggestions=Es(e.recommended,e.blockedRows),await Is({result:e.result,pmRoot:e.pmRoot,author:e.author,packing:e.packing,ranking:e.readyRanking}),e.result}function Ds(e,t,n){if(!n)return e;let r=nt(t,n);if(!r.found)throw new m(`Next --parent item not found: ${n}`,f.NOT_FOUND);return e.filter(o=>r.ids.has(o.id.trim().toLowerCase()))}async function Ns(e,t,n,r,o,i,s){let a=e.filter(h=>!dt(h.item,t)),d=a.length>0?a:e,c=await ve({pmRoot:i,author:o,enabled:process.env.PM_CONTEXT_USAGE_DISABLED!=="1"}),u=await Se(d.map(h=>h.item),{pmRoot:i,storeKey:"next",statusRegistry:n,now:r,author:o,usageAffinity:c.affinity}),l=await ke("next",u.candidates),p=ot(l,s,new Set,"next"),g=new Map(d.map(h=>[h.item.id,h]));return{projectedReady:l.ranked.map(h=>g.get(h.id)).filter(h=>h!==void 0),ranking:l,completedContainer:a.length===0,packing:p,featureStore:u}}function Fn(e,t){let n=e.assignee?.trim();return Y(e.callerAuthor??(n&&n.length>0?n:void 0),t)}async function cc(e,t){let n=N(process.cwd(),t.path),r=await M(n),o=Fn(e,r.author_default),i=H(r.schema),s=O(),a=An(e.limit,"--limit",ys),d=et(e.tokenBudget,Math.max(192,a*128)),c=An(e.blockedLimit,"--blocked-limit",a),u=e.readyOnly===!0,l=typeof e.parent=="string"?e.parent.trim():"",p=await V(void 0,Ss(e,{excludeTerminal:!0}),t),g=await V(void 0,{excludeTerminal:!1,noTruncate:!0},t),w=Ds(p.items,g.items,l),h=g.items,S=Ft(w,h,i),_=q(h),k=bs(S.ready,e.includeDecisions===!0),x=Mn(k.agent,r.author_default,o),$=On(x.available,_,i),P=[...S.blocked].sort((D,T)=>U(D.item,T.item,i)),{projectedReady:E,ranking:ie,completedContainer:se,packing:Ie,featureStore:$e}=await Ns($,_,i,s,o,n,d),F=E.map((D,T)=>ct(D,i,_,T+1)),j=P.map((D,T)=>ct(D,i,_,T+1)),R=On(k.decisions,_,i).map((D,T)=>ct(D,i,_,T+1)),B=xs({projectedReady:E,readyRows:F,statusRegistry:i,now:s,completedContainer:se}),De=Ts(R.length,x.held.length,a),Ne={output_default:"toon",now:s,recommended:B,ready:F.slice(1,a+1),decision_needed:R.slice(0,a),blocked:u?[]:j.slice(0,c),held_by_others:x.held.slice(0,a),summary:{recommended:B!==null,ready:F.length,blocked:j.length,in_progress:Cs(F,i),candidates:S.active_count,containers:S.container_count,decision_needed:R.length,held_by_others:x.held.length},filters:{type:e.type??null,tag:e.tag??null,priority:e.priority??null,assignee:e.assignee??null,assignee_filter:e.assigneeFilter??null,sprint:e.sprint??null,release:e.release??null,parent:l.length>0?l:null,limit:a,blocked_limit:c,ready_only:u,include_decisions:e.includeDecisions===!0,token_budget:d},truncation:De};return $s({result:Ne,recommended:B,blockedRows:j,candidatesWarnings:p.warnings,corpusWarnings:g.warnings,readyRanking:ie,explainRanking:e.explainRanking===!0,pmRoot:n,author:o,packing:Ie,featureStore:$e})}function dc(e){let t=["# pm next","",...As(e)];if(t.push(...Ee("Recommended",Os(e.recommended),"No ready work.")),t.push(...Ee("Decision needed",(e.decision_needed??[]).map(n=>`- ${Te(n)}`),"No human-gated decisions.")),t.push(...Ee("Ready",e.ready.map(n=>`- ${Te(n)}`),"No ready items.")),e.filters.ready_only||t.push(...Ee("Blocked",e.blocked.map(n=>`- ${Ms(n)}`),"No blocked items.")),e.suggestions&&e.suggestions.length>0){t.push("## Suggestions");for(let n of e.suggestions)t.push(`- ${n}`)}return t.join(`
|
|
12
12
|
`).trimEnd()}function As(e){let t=[`- now: ${e.now}`,`- ready: ${e.summary.ready} (in_progress: ${e.summary.in_progress}), blocked: ${e.summary.blocked}, candidates: ${e.summary.candidates}`];return e.filters.parent&&t.push(`- scope: subtree of ${e.filters.parent}`),t.push(""),t}function Os(e){return e?[`- ${Te(e)}`,` why: ${e.reasons.join("; ")}`]:[]}function Ee(e,t,n){return[`## ${e}`,...t.length===0?[n]:t,""]}function Ms(e){let t=e.blockers.map(n=>`${n.id}(${n.status??"?"})`).join(", ");return`${Te(e)} blocked_by:${t}`}function Te(e){let t=e.deadline??"-",n=e.parent?` parent:${e.parent}`:"",r=e.unblocks.length>0?` unblocks:${e.unblocks.length}`:"";return`${Number.isInteger(e.rank)?`#${e.rank} `:""}${e.id} p${e.priority} ${e.status} ${e.type} deadline:${t}${n}${r} ${e.title}`}(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]="412fc2d2-daee-5d87-82ab-5411a1503087")}catch{}})();function lc(e,t){let n=t??{};return e.filter(r=>n[r.id]!==r.updated_at).map(r=>r.id).sort((r,o)=>r.localeCompare(o))}export{pe as a,Lt as b,Un as c,Ut as d,Us as e,Le as f,Pt as g,zt as h,Zs as i,Qs as j,ea as k,Qt as l,qe as m,we as n,Jr as o,nn as p,no as q,ke as r,ro as s,oo as t,co as u,uo as v,ia as w,lo as x,rn as y,I as z,be as A,fa as B,ma as C,ve as D,Ye as E,Ve as F,Ro as G,Lo as H,Ke as I,Je as J,Se as K,gn as L,ba as M,Wo as N,Yo as O,_n as P,ti as Q,wn as R,ni as S,Na as T,ri as U,ui as V,ee as W,qa as X,et as Y,mi as Z,pi as _,nt as $,U as aa,ot as ba,it as ca,st as da,q as ea,oe as fa,xe as ga,Ya as ha,fs as ia,Va as ja,hs as ka,sc as la,ac as ma,bs as na,cc as oa,dc as pa,lc as qa};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-6MSQJOTG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ga as N,ha as T,ia as v}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{ga as N,ha as T,ia as v}from"./chunk-A62CYISG.js";import{A as u,Af as p,C as f,Da as m,La as I,Lf as g,Mf as y,Oa as b,Rf as E,b as h,lc as w,uf as F}from"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="d51ebf7a-d759-5a6b-9a4f-810139a1688c")}catch{}})();async function D(e){if(!await h(b(e)))throw new f(`Tracker is not initialized at ${e}. Run pm init first.`,u.NOT_FOUND)}async function O(e,a,i){let t=I(process.cwd(),i.path);if(await D(t),a.clear===!0){if(e!==void 0)throw new f("pm focus --clear does not take an item id. Use 'pm focus --clear' to clear focus or 'pm focus <id>' to set it.",u.USAGE);return await v(t),{action:"clear",focused_item:null,title:null,message:"Focus cleared. New items will not inherit a default parent."}}if(e===void 0){let n=await N(t);if(n===void 0)return{action:"show",focused_item:null,title:null,message:"No focus set. Use 'pm focus <id>' to set a default parent for new items."};let l=await R(t,n);return{action:"show",focused_item:n,title:l,message:`Focused on ${n}${l?` (${l})`:""}. New items default --parent to it.`}}let o=await p(t),_=m(o,w()),r=await g(t,e,o.id_prefix,o.item_format,_.type_to_folder);if(!r)throw await E(t,e,o.id_prefix,_.type_to_folder);let c=F(r.id,o.id_prefix),$=await y(r,{schema:o.schema}),d=x($.document.metadata.title);return await T(t,c),{action:"set",focused_item:c,title:d,message:`Focused on ${c}${d?` (${d})`:""}. New items default --parent to it (override with --parent or clear via 'pm focus --clear').`}}async function R(e,a){let i=await p(e),t=m(i,w()),s=await g(e,a,i.id_prefix,i.item_format,t.type_to_folder);if(!s)return null;let o=await y(s,{schema:i.schema});return x(o.document.metadata.title)}function x(e){return e.trim().length>0?e:null}export{O as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7A5OT5J2.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as ae,o as ie}from"./chunk-
|
|
1
|
+
import{c as ae,o as ie}from"./chunk-EGJ4JTUG.js";import{a as T,b as oe,c as se,d as O,e as le}from"./chunk-CHOQ2VAW.js";import{Aa as ne,i as C,o as I}from"./chunk-A62CYISG.js";import{k as te}from"./chunk-M72BKL5Q.js";import{A as s,Bf as b,C as l,Da as q,Ea as Q,La as k,Lc as ee,Na as J,Oa as Z,Tb as x,_ as X,b as h,lc as R,wa as P,zf as re}from"./chunk-GE4KCSZP.js";import{execFile as qe}from"node:child_process";import Re from"node:path";import{promisify as Ie}from"node:util";(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]="cdfc451a-1148-50c5-934a-cd8bc2bb39e7")}catch{}})();var Te=Ie(qe),Oe="@unbrained/pm-cli",Ue="latest";function Ne(e){let t=e.project===!0||e.local===!0,r=e.global===!0;if(t&&r)throw new l('Options "--project/--local" and "--global" are mutually exclusive.',s.USAGE);return r?"global":"project"}function S(e){return e.trim().toLowerCase()}function ce(e,t){let r=S(t);return[e.name,e.directory,e.source.input,e.source.location,e.source.package,e.source.repository,e.source.owner&&e.source.repo?`${e.source.owner}/${e.source.repo}`:void 0].some(i=>typeof i=="string"&&S(i)===r)}function Le(e,t){let r=k(process.cwd(),t.path),n=x(r,process.cwd());return{selected_root:e==="global"?n.global:n.project}}async function $e(e,t,r){try{let n=await Te(e,t,{cwd:r?.cwd,encoding:"utf8"});return{stdout:n.stdout,stderr:n.stderr}}catch(n){let i=typeof n=="object"&&n!==null&&"stderr"in n?String(n.stderr??""):"",a=i.trim().length>0?i.trim():n instanceof Error?n.message:String(n);throw new l(`Command failed: ${e} ${t.join(" ")}
|
|
2
2
|
${a}`,s.GENERIC_FAILURE)}}async function De(){return X(import.meta.url,["../../.."])}function A(e){return typeof e.tag=="string"&&e.tag.trim().length>0?e.tag.trim():Ue}function E(e){return typeof e.packageName=="string"&&e.packageName.trim().length>0?e.packageName.trim():Oe}async function ze(e,t){let r=e.commandRunner??$e,n=E(e),i=A(e),a=`${n}@${i}`,o=["npm","install","-g",a];e.repair===!0&&o.push("--force");let _=await De(),c={requested:!0,status:"planned",package:n,target:a,command:o,before_version:_,repair:e.repair===!0};if(t)return c;try{await r(o[0],o.slice(1));let f=await r("pm",["--version"]);return{...c,status:"updated",after_version:f.stdout.trim()||void 0}}catch(f){return{...c,status:"failed",error:f instanceof Error?f.message:String(f)}}}function Fe(e){return Re.isAbsolute(e)||e.startsWith(".")||e.startsWith("..")||e.startsWith("file:")}function je(e,t){if(e.kind==="npm"){let r=e.input.startsWith("npm:")?e.input.slice(4).trim():e.input.trim();return!Fe(r)&&e.package&&e.package.trim().length>0?`npm:${e.package.trim()}@${t}`:e.input.startsWith("npm:")?e.input:`npm:${e.input}`}return e.input}async function Ve(e,t){let r=je(e,t);return e.kind!=="local"||await h(r)?r:await h(e.location)?e.location:r}function Ke(e,t,r,n){let i=["pm","install",t,r==="global"?"--global":"--project"];return e.kind==="github"&&n&&n.trim().length>0&&i.push("--ref",n.trim()),i}async function _e(e,t){let r=Le(e,t);return(await ae(r.selected_root)).state.entries.filter(i=>i.scope===e)}async function Ye(e,t,r){let n=await _e(e,t);return n.find(i=>ce(i,r.name))??n.find(i=>S(i.directory)===S(r.directory))}async function Me(e,t,r,n,i){let a=A(t),o=await Ve(e.source,a),_=Ke(e.source,o,n,e.source.ref),c={name:e.name,directory:e.directory,scope:n,source:e.source,status:"planned",command:_,previous_version:e.manifest_version};if(i)return c;try{await ie(o,{install:!0,project:n==="project",global:n==="global",ref:e.source.kind==="github"?e.source.ref:void 0},r);let f=await Ye(n,r,e);return{...c,status:"updated",installed_version:f?.manifest_version}}catch(f){return{...c,status:"failed",error:f instanceof Error?f.message:String(f)}}}function We(e,t,r,n){let i=[r?e.status:void 0,...t.map(a=>a.status)].filter(a=>typeof a=="string");return{requested_cli:r,requested_packages:n,planned:i.filter(a=>a==="planned").length,updated:i.filter(a=>a==="updated").length,skipped:i.filter(a=>a==="skipped").length,failed:i.filter(a=>a==="failed").length}}async function Dt(e,t,r){if(t.cliOnly===!0&&t.packagesOnly===!0)throw new l('Options "--cli-only" and "--packages-only" are mutually exclusive.',s.USAGE);let n=Ne(t),i=t.dryRun===!0,a=typeof e=="string"&&e.trim().length>0?e.trim():void 0;if(t.cliOnly===!0&&a)throw new l('A package target cannot be used with "--cli-only".',s.USAGE);let o=!(t.packagesOnly===!0||a),_=t.cliOnly!==!0,c=o?await ze(t,i):{requested:!1,status:"skipped",package:E(t),target:`${E(t)}@${A(t)}`,command:["npm","install","-g",`${E(t)}@${A(t)}`],repair:t.repair===!0,reason:"not_requested"},f=_?await _e(n,r):[];if(a&&(f=f.filter(v=>ce(v,a)),f.length===0))throw new l(`Managed package "${a}" was not found in ${n} scope.`,s.NOT_FOUND);let u=[];for(let v of f)u.push(await Me(v,t,r,n,i));let y=We(c,u,o,_);return{ok:y.failed===0,action:"upgrade",dry_run:i,scope:n,target:a,cli:c,packages:u,summary:y}}(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]="4f4f5f10-793d-5baa-8985-c0ec855b16c4")}catch{}})();var fe=new Set(["item_format"]),de=new Set(["definition_of_done","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns"]),Be=new Set(["history_missing_stream_policy","sprint_release_format_policy","parent_reference_policy","metadata_validation_profile","governance_preset","governance_ownership_enforcement","governance_create_mode_default","governance_close_validation_default","governance_require_close_reason","governance_create_default_type","governance_workflow_enforcement","governance_parent_reference_policy","governance_metadata_validation_profile","governance_force_required_for_stale_lock","test_result_tracking","telemetry_tracking"]),He=new Set(["governance_require_close_reason","governance_force_required_for_stale_lock","test_result_tracking","telemetry_tracking"]),Xe={off:"disabled",on:"enabled",true:"enabled",false:"disabled",enabled:"enabled",disabled:"disabled"};function Qe(e){let t=e.trim().toLowerCase().replaceAll("-","_");if(fe.has(t)||de.has(t)||Be.has(t)||t==="context")return t}function Je(e){let t=e.trim().toLowerCase();return Xe[t]??e}function ge(e,t){let r=Qe(e);return r===void 0?{routable:!1,reason:`Unknown config key "${e}" cannot route a positional value.`}:r==="context"?{routable:!1,reason:"Config set context does not accept a positional value. Use --default-depth, --activity-limit, --stale-threshold-days, or --section-<name> flags."}:fe.has(r)?{routable:!0,flag:"format",value:t}:de.has(r)?{routable:!0,flag:"criterion",values:[t]}:{routable:!0,flag:"policy",value:He.has(r)?Je(t):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]="2a186a29-9d21-5ebe-9c66-3e889253b15b")}catch{}})();var ue=["project","global"],p={definition_of_done:["definition-of-done","definition_of_done"],item_format:["item-format","item_format"],history_missing_stream_policy:["history-missing-stream-policy","history_missing_stream_policy"],sprint_release_format_policy:["sprint-release-format-policy","sprint_release_format_policy"],parent_reference_policy:["parent-reference-policy","parent_reference_policy"],metadata_validation_profile:["metadata-validation-profile","metadata_validation_profile"],metadata_required_fields:["metadata-required-fields","metadata_required_fields"],lifecycle_stale_blocker_reason_patterns:["lifecycle-stale-blocker-reason-patterns","lifecycle_stale_blocker_reason_patterns"],lifecycle_closure_like_blocked_reason_patterns:["lifecycle-closure-like-blocked-reason-patterns","lifecycle_closure_like_blocked_reason_patterns"],lifecycle_closure_like_resolution_patterns:["lifecycle-closure-like-resolution-patterns","lifecycle_closure_like_resolution_patterns"],lifecycle_closure_like_actual_result_patterns:["lifecycle-closure-like-actual-result-patterns","lifecycle_closure_like_actual_result_patterns"],governance_preset:["governance-preset","governance_preset"],governance_ownership_enforcement:["governance-ownership-enforcement","governance_ownership_enforcement"],governance_create_mode_default:["governance-create-mode-default","governance_create_mode_default"],governance_close_validation_default:["governance-close-validation-default","governance_close_validation_default"],governance_require_close_reason:["governance-require-close-reason","governance_require_close_reason"],governance_create_default_type:["governance-create-default-type","governance_create_default_type"],governance_workflow_enforcement:["governance-workflow-enforcement","governance_workflow_enforcement"],governance_parent_reference_policy:["governance-parent-reference-policy","governance_parent_reference_policy"],governance_metadata_validation_profile:["governance-metadata-validation-profile","governance_metadata_validation_profile"],governance_force_required_for_stale_lock:["governance-force-required-for-stale-lock","governance_force_required_for_stale_lock"],test_result_tracking:["test-result-tracking","test_result_tracking"],telemetry_tracking:["telemetry-tracking","telemetry_tracking"],context:["context"]},Ze=Object.keys(p).map(e=>p[e][0]),xe=Object.fromEntries(Object.keys(p).flatMap(e=>p[e].map(t=>[t,e]))),et={definition_of_done:"Definition of Done criteria list.",item_format:"Default item file format.",history_missing_stream_policy:"Missing history stream handling policy.",sprint_release_format_policy:"Sprint/release format validation policy.",parent_reference_policy:"Parent reference validation policy.",metadata_validation_profile:"Validate metadata profile policy (core|strict|custom).",metadata_required_fields:"Validate custom metadata required-fields list.",lifecycle_stale_blocker_reason_patterns:"Validate lifecycle stale-blocker reason substring patterns (criteria list).",lifecycle_closure_like_blocked_reason_patterns:"Validate lifecycle closure-like blocked_reason substring patterns (criteria list).",lifecycle_closure_like_resolution_patterns:"Validate lifecycle closure-like resolution substring patterns (criteria list).",lifecycle_closure_like_actual_result_patterns:"Validate lifecycle closure-like actual_result substring patterns (criteria list).",governance_preset:"Governance preset policy (minimal|default|strict|custom).",governance_ownership_enforcement:"Governance ownership enforcement policy (none|warn|strict).",governance_create_mode_default:"Governance default create mode (progressive|strict).",governance_close_validation_default:"Governance default close validation mode (off|warn|strict).",governance_require_close_reason:"Governance close-reason requirement policy (enabled|disabled).",governance_create_default_type:"Governance default item type for `pm create` when --type is omitted.",governance_workflow_enforcement:"Governance per-type transition enforcement mode (off|warn|strict).",governance_parent_reference_policy:"Governance parent reference policy (warn|strict_error).",governance_metadata_validation_profile:"Governance metadata validation profile (core|strict|custom).",governance_force_required_for_stale_lock:"Governance stale-lock force policy (enabled|disabled).",test_result_tracking:"Item-level linked test result persistence policy.",telemetry_tracking:"Telemetry usage reporting policy.",context:"Context command settings (depth, section toggles, limits)."},tt=["lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns"],rt=new Set(["metadata_required_fields",...tt]),nt=new Set(["test_result_tracking","telemetry_tracking"]),at=new Set(["governance_require_close_reason","governance_force_required_for_stale_lock"]),it=new Set(["governance_ownership_enforcement","governance_create_mode_default","governance_close_validation_default"]),ot=new Set(["governance_parent_reference_policy","governance_metadata_validation_profile","governance_workflow_enforcement"]),st=new Set(["governance_preset","governance_create_default_type"]),ye=e=>rt.has(e),lt=e=>it.has(e),ct=e=>ot.has(e),_t=e=>st.has(e);function U(e){return e==="definition_of_done"||ye(e)}function ve(e){if(ue.includes(e))return e;throw new l(`Invalid config scope "${e}". Allowed: ${ue.join(", ")}`,s.USAGE)}function we(e){if(e==="get"||e==="set"||e==="list"||e==="export")return e;throw new l(`Invalid config action "${e}". Allowed: get, set, list, export`,s.USAGE)}function he(e){let t=xe[e];if(t)return t;let r=T.map(n=>n.key).join(", ");throw new l(`Invalid config key "${e}". Supported: ${Ze.join(", ")} (underscore variants also accepted). Nested leaf settings: ${r}.`,s.USAGE)}function be(e,t){let r=[...new Set((e??[]).map(n=>n.trim()).filter(n=>n.length>0))].sort((n,i)=>n.localeCompare(i));if(t){if(r.length>0)throw new l("Config set definition-of-done cannot combine --clear-criteria with --criterion values",s.USAGE);return[]}if(r.length===0)throw new l("Config set definition-of-done requires at least one non-empty --criterion value (or --clear-criteria to clear)",s.USAGE);return r}function ke(e){let t=e?.trim().toLowerCase();if(t==="toon")return"toon";throw t==="json_markdown"?new l("Config set item-format no longer accepts json_markdown. Markdown item files are legacy read/migration input only.",s.USAGE):new l("Config set item-format requires --format toon",s.USAGE)}function D(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="auto_create"||t==="strict_error")return t;throw new l("Config set history-missing-stream-policy requires --policy with one of: auto_create, strict_error",s.USAGE)}function z(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set test-result-tracking requires --policy with one of: enabled, disabled",s.USAGE)}function F(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set telemetry-tracking requires --policy with one of: enabled, disabled",s.USAGE)}function G(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="core"||t==="strict"||t==="custom")return t;throw new l("Config set metadata-validation-profile requires --policy with one of: core, strict, custom",s.USAGE)}function j(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="minimal"||t==="default"||t==="strict"||t==="custom")return t;throw new l("Config set governance-preset requires --policy with one of: minimal, default, strict, custom",s.USAGE)}function V(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="none"||t==="warn"||t==="strict")return t;throw new l("Config set governance-ownership-enforcement requires --policy with one of: none, warn, strict",s.USAGE)}function K(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="progressive"||t==="strict")return t;throw new l("Config set governance-create-mode-default requires --policy with one of: progressive, strict",s.USAGE)}function Y(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="off"||t==="warn"||t==="strict")return t;if(t==="none"||t==="disabled")return"off";throw new l("Config set governance-close-validation-default requires --policy with one of: off, warn, strict",s.USAGE)}function M(e){let t=typeof e=="string"?e.trim().toLowerCase().replaceAll("-","_"):void 0;if(t==="off"||t==="warn"||t==="strict")return t;if(t==="none"||t==="disabled")return"off";throw new l("Config set governance-workflow-enforcement requires one of: off, warn, strict",s.USAGE)}function W(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set governance-force-required-for-stale-lock requires --policy with one of: enabled, disabled",s.USAGE)}function B(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set governance-require-close-reason requires --policy with one of: enabled, disabled",s.USAGE)}function N(e,t){switch(e){case"history_missing_stream_policy":return D(t);case"sprint_release_format_policy":return I(t);case"parent_reference_policy":case"governance_parent_reference_policy":return C(t);case"metadata_validation_profile":case"governance_metadata_validation_profile":return G(t);case"governance_preset":return j(t);case"governance_ownership_enforcement":return V(t);case"governance_create_mode_default":return K(t);case"governance_close_validation_default":return Y(t);case"governance_require_close_reason":return B(t);case"governance_workflow_enforcement":return M(t);case"governance_force_required_for_stale_lock":return W(t);case"test_result_tracking":return z(t);case"telemetry_tracking":return F(t);default:return t.trim().toLowerCase().replaceAll("-","_")}}var me={author:"author",acceptance_criteria:"acceptance_criteria","acceptance-criteria":"acceptance_criteria",estimated_minutes:"estimated_minutes","estimated-minutes":"estimated_minutes",estimate:"estimated_minutes",close_reason:"close_reason","close-reason":"close_reason",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release"},ft=["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"];function Ce(e,t){let r=[...new Set((e??[]).map(a=>a.trim()).filter(a=>a.length>0))];if(t){if(r.length>0)throw new l("Config set metadata-required-fields cannot combine --clear-criteria with --criterion values",s.USAGE);return[]}if(r.length===0)throw new l("Config set metadata-required-fields requires at least one --criterion value (or --clear-criteria to clear)",s.USAGE);let n=r.map(a=>a.toLowerCase().replaceAll("-","_")),i=n.filter(a=>me[a]===void 0);if(i.length>0)throw new l(`Config set metadata-required-fields received unsupported values: ${i.join(", ")}. Supported values: ${ft.join(", ")}`,s.USAGE);return[...new Set(n.map(a=>me[a]))].sort((a,o)=>a.localeCompare(o))}function dt(e,t,r){let n=[...new Set((t??[]).map(i=>i.trim().toLowerCase()).filter(i=>i.length>0))].sort((i,a)=>i.localeCompare(a));if(r){if(n.length>0)throw new l(`Config set ${p[e][0]} cannot combine --clear-criteria with --criterion values`,s.USAGE);return[]}if(n.length===0)throw new l(`Config set ${p[e][0]} requires at least one --criterion value (or --clear-criteria to clear)`,s.USAGE);return n}function Ee(e){return[...new Set(e)].sort((t,r)=>t.localeCompare(r))}function gt(e,t){if(e==="list"||e==="export"){if(typeof t=="string"&&t.trim().length>0)throw new l(`Config action "${e}" does not accept <key>`,s.USAGE);return}if(typeof t!="string"||t.trim().length===0)throw new l(`Config action "${e}" requires <key>`,s.USAGE);return he(t)}function Se(e){if(!e)throw new l("Config action requires <key>",s.USAGE)}var ut={definition_of_done:e=>[...e.workflow.definition_of_done],item_format:e=>e.item_format,history_missing_stream_policy:e=>e.history.missing_stream,sprint_release_format_policy:e=>e.validation.sprint_release_format,parent_reference_policy:e=>e.validation.parent_reference,metadata_validation_profile:e=>e.validation.metadata_profile,metadata_required_fields:e=>[...e.validation.metadata_required_fields],lifecycle_stale_blocker_reason_patterns:e=>[...e.validation.lifecycle_stale_blocker_reason_patterns],lifecycle_closure_like_blocked_reason_patterns:e=>[...e.validation.lifecycle_closure_like_blocked_reason_patterns],lifecycle_closure_like_resolution_patterns:e=>[...e.validation.lifecycle_closure_like_resolution_patterns],lifecycle_closure_like_actual_result_patterns:e=>[...e.validation.lifecycle_closure_like_actual_result_patterns],governance_preset:e=>e.governance.preset,governance_ownership_enforcement:e=>e.governance.ownership_enforcement,governance_create_mode_default:e=>e.governance.create_mode_default,governance_close_validation_default:e=>e.governance.close_validation_default,governance_require_close_reason:e=>e.governance.require_close_reason?"enabled":"disabled",governance_create_default_type:e=>e.governance.create_default_type??"",governance_workflow_enforcement:e=>e.governance.workflow_enforcement??"off",governance_parent_reference_policy:e=>e.governance.parent_reference,governance_metadata_validation_profile:e=>e.governance.metadata_profile,governance_force_required_for_stale_lock:e=>e.governance.force_required_for_stale_lock?"enabled":"disabled",test_result_tracking:e=>e.testing.record_results_to_items?"enabled":"disabled",telemetry_tracking:e=>e.telemetry.enabled?"enabled":"disabled",context:e=>({default_depth:e.context.default_depth,activity_limit:e.context.activity_limit,stale_threshold_days:e.context.stale_threshold_days,sections:{...e.context.sections}})};function H(e,t){return ut[t](e)}function m(e,t){return t.length===0?e:{...e,warnings:t}}async function mt(e,t){let r=process.cwd(),n=e==="project"?k(r,t.path):J(r),i=Z(n);if(e==="project"&&!await h(i))throw new l(`Tracker is not initialized at ${n}. Run pm init first.`,s.NOT_FOUND);return{pmRoot:n,settingsPath:i}}function pt(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t==="true"||t==="enabled"||t==="on"||t==="1")return!0;if(t==="false"||t==="disabled"||t==="off"||t==="0")return!1;throw new l(`Context section toggle must be true|false|enabled|disabled, got "${e}"`,s.USAGE)}function pe(e,t){let r=e.trim(),n=Number(r);if(/^\d+$/u.test(r)&&Number.isSafeInteger(n)&&n>0)return n;throw new l(`Context ${t} must be a positive integer`,s.USAGE)}async function yt(e,t,r,n,i){let a=!1,o=e.context;if(t.defaultDepth!==void 0){let c=t.defaultDepth.trim().toLowerCase();if(!P.includes(c))throw new l(`Context --default-depth must be one of ${P.join("|")}`,s.USAGE);o.default_depth!==c&&(o.default_depth=c,a=!0)}if(t.activityLimit!==void 0){let c=pe(t.activityLimit,"--activity-limit");o.activity_limit!==c&&(o.activity_limit=c,a=!0)}if(t.staleThresholdDays!==void 0){let c=pe(t.staleThresholdDays,"--stale-threshold-days");o.stale_threshold_days!==c&&(o.stale_threshold_days=c,a=!0)}let _=[["hierarchy",t.sectionHierarchy],["activity",t.sectionActivity],["progress",t.sectionProgress],["blockers",t.sectionBlockers],["files",t.sectionFiles],["workload",t.sectionWorkload],["staleness",t.sectionStaleness],["tests",t.sectionTests]];for(let[c,f]of _){let u=pt(f);if(u!==void 0){let y=c;o.sections[y]!==u&&(o.sections[y]=u,a=!0)}}return a&&await b(r.pmRoot,e,"config:set:context"),m({scope:n,key:"context",context_settings:{default_depth:o.default_depth,activity_limit:o.activity_limit,stale_threshold_days:o.stale_threshold_days,sections:{...o.sections}},settings_path:r.settingsPath,changed:a},i)}function vt(e,t,r){if(r.value!==void 0&&r.value!==t)throw new l(`Config set ${e} received both positional value "${t}" and --value "${r.value}". Pass only one.`,s.USAGE);return{...r,value:t}}function Ae(e,t,r,n,i,a){if(i===void 0)return a;if(e!=="set")throw new l(`Config action "${e}" does not accept a positional value. Only "set" takes <value>.`,s.USAGE);if(typeof t!="string"||t.trim().length===0)throw new l('Config action "set" requires <key> before a positional <value>.',s.USAGE);if(n)return vt(t,i,a);Se(r);let o=ge(r,i);if(!o.routable)throw new l(o.reason,s.USAGE);if(o.flag==="criterion"){if(a.criterion!==void 0&&a.criterion.length>0)throw new l(`Config set ${t} received both positional value "${i}" and --criterion. Pass criteria via --criterion only when supplying more than one value.`,s.USAGE);return{...a,criterion:o.values}}if(o.flag==="format")return{...a,format:o.value};if(a.policy!==void 0&&N(r,a.policy)!==N(r,o.value))throw new l(`Config set ${t} received both positional value "${i}" and --policy "${a.policy}". Pass only one.`,s.USAGE);return{...a,policy:o.value}}function wt(e){let t=Object.keys(p).map(n=>({key:n,aliases:p[n],value_kind:n==="context"?"object":U(n)?"string_array":"enum",set_flags:n==="context"?["--default-depth","--activity-limit","--stale-threshold-days","--section-<name>"]:U(n)?["--criterion","--clear-criteria"]:n==="item_format"?["--format"]:["--policy"],summary:et[n],value:H(e.settings,n)})),r=T.map(n=>({key:n.key,canonical_key:n.key.replaceAll("_","-"),path:n.path,kind:n.kind,value:O(e.settings,n),summary:n.summary,...n.choices?{choices:[...n.choices]}:{},...n.min===void 0?{}:{min:n.min},...n.max===void 0?{}:{max:n.max}}));return m({scope:e.scope,keys:t,nested_settings:r,count:t.length,settings_path:e.target.settingsPath,changed:!1},e.warnings)}function ht(e){let t=Object.fromEntries(Object.keys(p).map(r=>[r,H(e.settings,r)]));return m({scope:e.scope,values:t,settings_path:e.target.settingsPath,changed:!1},e.warnings)}function bt(e,t){let r=H(e.settings,t),n={scope:e.scope,key:t,settings_path:e.target.settingsPath,changed:!1};return t==="item_format"?m({...n,format:e.settings.item_format,has_explicit_item_format:e.metadata.has_explicit_item_format},e.warnings):t==="context"?m({...n,context_settings:r},e.warnings):Array.isArray(r)?m({...n,criteria:r},e.warnings):m({...n,policy:r},e.warnings)}async function kt(e,t,r,n){if(t==="get"){let _=O(e.settings,r);return m({scope:e.scope,key:r.key,nested_setting:{key:r.key,path:r.path,kind:r.kind,value:_},settings_path:e.target.settingsPath,changed:!1},e.warnings)}let i=n.value;if(typeof i!="string")throw new l(`Config set ${r.key} requires a value. Pass it positionally (\`pm config ${e.scope} set ${r.key} <value>\`) or via --value.`,s.USAGE);let a=se(r,i);if(!a.ok)throw new l(a.error.message,s.USAGE);let o=le(e.settings,r,a.parsed.value);return o&&await b(e.target.pmRoot,e.settings,`config:set:${r.path}`),m({scope:e.scope,key:r.key,nested_setting:{key:r.key,path:r.path,kind:r.kind,value:a.parsed.value},settings_path:e.target.settingsPath,changed:o},e.warnings)}async function d(e,t,r){t&&await b(e.target.pmRoot,e.settings,r)}function L(e,t,r){return e!==r||t!==r}function g(e,t,r,n){return m({scope:e.scope,key:t,policy:r,settings_path:e.target.settingsPath,changed:n},e.warnings)}function $(e,t,r,n){return m({scope:e.scope,key:t,criteria:r,settings_path:e.target.settingsPath,changed:n},e.warnings)}async function Ct(e,t){let r=ke(t.format),n=e.settings.item_format!==r||!e.metadata.has_explicit_item_format,i;if(n){let a=q(e.settings,R()),o=await ne(e.target.pmRoot,r,"config:set:item_format:migrate",a.type_to_folder,e.settings.schema);i={target_format:o.target_format,scanned:o.scanned,migrated:o.migrated,removed:o.removed,warnings:o.warnings},e.settings.item_format=r,await b(e.target.pmRoot,e.settings,"config:set:item_format")}return m({scope:e.scope,key:"item_format",format:e.settings.item_format,has_explicit_item_format:!0,migration:i,settings_path:e.target.settingsPath,changed:n},e.warnings)}async function Et(e,t,r){if(t==="history_missing_stream_policy"){let a=D(r.policy),o=e.settings.history.missing_stream!==a;return e.settings.history.missing_stream=a,await d(e,o,"config:set:history_missing_stream_policy"),g(e,t,e.settings.history.missing_stream,o)}if(t==="sprint_release_format_policy"){let a=I(r.policy),o=e.settings.validation.sprint_release_format!==a;return e.settings.validation.sprint_release_format=a,await d(e,o,"config:set:sprint_release_format_policy"),g(e,t,e.settings.validation.sprint_release_format,o)}if(t==="parent_reference_policy"){let a=C(r.policy),o=e.settings.validation.parent_reference!==a||e.settings.governance.preset!=="custom"||e.settings.governance.parent_reference!==a;return e.settings.validation.parent_reference=a,e.settings.governance.preset="custom",e.settings.governance.parent_reference=a,await d(e,o,"config:set:parent_reference_policy"),g(e,t,e.settings.validation.parent_reference,o)}let n=G(r.policy),i=e.settings.validation.metadata_profile!==n||e.settings.governance.preset!=="custom"||e.settings.governance.metadata_profile!==n;return e.settings.validation.metadata_profile=n,e.settings.governance.preset="custom",e.settings.governance.metadata_profile=n,await d(e,i,"config:set:metadata_validation_profile"),g(e,t,e.settings.validation.metadata_profile,i)}async function St(e,t,r){if(t==="metadata_required_fields"){let _=Ce(r.criterion,r.clearCriteria),c=_.length!==e.settings.validation.metadata_required_fields.length||_.some((f,u)=>f!==e.settings.validation.metadata_required_fields[u]);return e.settings.validation.metadata_required_fields=_,await d(e,c,"config:set:metadata_required_fields"),$(e,t,[...e.settings.validation.metadata_required_fields],c)}let i={lifecycle_stale_blocker_reason_patterns:e.settings.validation.lifecycle_stale_blocker_reason_patterns,lifecycle_closure_like_blocked_reason_patterns:e.settings.validation.lifecycle_closure_like_blocked_reason_patterns,lifecycle_closure_like_resolution_patterns:e.settings.validation.lifecycle_closure_like_resolution_patterns,lifecycle_closure_like_actual_result_patterns:e.settings.validation.lifecycle_closure_like_actual_result_patterns}[t],a=dt(t,r.criterion,r.clearCriteria),o=a.length!==i.length||a.some((_,c)=>_!==i[c]);return i.splice(0,i.length,...a),await d(e,o,`config:set:${t}`),$(e,t,[...i],o)}async function At(e,t,r){if(t==="governance_preset"){let c=j(r.policy),f=e.settings.governance.preset!==c;return e.settings.governance.preset=c,await d(e,f,"config:set:governance_preset"),g(e,t,e.settings.governance.preset,f)}let n=typeof r.policy=="string",i=n?r.policy.trim():"";if(n&&i.length===0){let c=e.settings.governance.create_default_type!==void 0;return delete e.settings.governance.create_default_type,await d(e,c,"config:set:governance_create_default_type"),g(e,t,e.settings.governance.create_default_type??"",c)}if(i.length===0)throw new l('Config set governance-create-default-type requires an item type value (or an empty value "" to clear it)',s.USAGE);let a=q(e.settings,R()),o=Q(i,a);if(!o)throw new l(te(i,a.types,ee(e.target.pmRoot,e.settings.schema)),s.USAGE);let _=e.settings.governance.create_default_type!==o;return e.settings.governance.create_default_type=o,await d(e,_,"config:set:governance_create_default_type"),g(e,t,e.settings.governance.create_default_type,_)}async function Gt(e,t,r){if(t==="governance_ownership_enforcement"){let a=V(r.policy),o=e.settings.governance.preset!=="custom"||e.settings.governance.ownership_enforcement!==a;return e.settings.governance.preset="custom",e.settings.governance.ownership_enforcement=a,await d(e,o,"config:set:governance_ownership_enforcement"),g(e,t,e.settings.governance.ownership_enforcement,o)}if(t==="governance_create_mode_default"){let a=K(r.policy),o=e.settings.governance.preset!=="custom"||e.settings.governance.create_mode_default!==a;return e.settings.governance.preset="custom",e.settings.governance.create_mode_default=a,await d(e,o,"config:set:governance_create_mode_default"),g(e,t,e.settings.governance.create_mode_default,o)}let n=Y(r.policy),i=e.settings.governance.preset!=="custom"||e.settings.governance.close_validation_default!==n;return e.settings.governance.preset="custom",e.settings.governance.close_validation_default=n,await d(e,i,"config:set:governance_close_validation_default"),g(e,t,e.settings.governance.close_validation_default,i)}async function Pt(e,t,r){if(t==="governance_parent_reference_policy"){let a=C(r.policy),o=e.settings.governance.preset!=="custom"||L(e.settings.governance.parent_reference,e.settings.validation.parent_reference,a);return e.settings.governance.preset="custom",e.settings.governance.parent_reference=a,e.settings.validation.parent_reference=a,await d(e,o,"config:set:governance_parent_reference_policy"),g(e,t,e.settings.governance.parent_reference,o)}if(t==="governance_metadata_validation_profile"){let a=G(r.policy),o=e.settings.governance.preset!=="custom"||L(e.settings.governance.metadata_profile,e.settings.validation.metadata_profile,a);return e.settings.governance.preset="custom",e.settings.governance.metadata_profile=a,e.settings.validation.metadata_profile=a,await d(e,o,"config:set:governance_metadata_validation_profile"),g(e,t,e.settings.governance.metadata_profile,o)}let n=M(r.policy),i=(e.settings.governance.workflow_enforcement??"off")!==n;return e.settings.governance.workflow_enforcement=n,await d(e,i,"config:set:governance_workflow_enforcement"),g(e,t,e.settings.governance.workflow_enforcement,i)}async function qt(e,t,r){if(t==="governance_require_close_reason"){let _=B(r.policy)==="enabled",c=e.settings.governance.require_close_reason!==_;return e.settings.governance.require_close_reason=_,await d(e,c,"config:set:governance_require_close_reason"),g(e,t,e.settings.governance.require_close_reason?"enabled":"disabled",c)}let i=W(r.policy)==="enabled",a=e.settings.governance.preset!=="custom"||e.settings.governance.force_required_for_stale_lock!==i;return e.settings.governance.preset="custom",e.settings.governance.force_required_for_stale_lock=i,await d(e,a,"config:set:governance_force_required_for_stale_lock"),g(e,t,e.settings.governance.force_required_for_stale_lock?"enabled":"disabled",a)}async function Rt(e,t,r){if(t==="test_result_tracking"){let _=z(r.policy)==="enabled",c=e.settings.testing.record_results_to_items!==_;return e.settings.testing.record_results_to_items=_,await d(e,c,"config:set:test_result_tracking"),g(e,t,e.settings.testing.record_results_to_items?"enabled":"disabled",c)}let i=F(r.policy)==="enabled",a=e.settings.telemetry.enabled!==i||!e.settings.telemetry.first_run_prompt_completed;return e.settings.telemetry.enabled=i,e.settings.telemetry.first_run_prompt_completed=!0,await d(e,a,"config:set:telemetry_tracking"),g(e,t,e.settings.telemetry.enabled?"enabled":"disabled",a)}async function It(e,t,r){let n=be(r.criterion,r.clearCriteria),i=n.length!==e.settings.workflow.definition_of_done.length||n.some((a,o)=>a!==e.settings.workflow.definition_of_done[o]);return e.settings.workflow.definition_of_done=n,await d(e,i,"config:set:definition_of_done"),$(e,t,[...e.settings.workflow.definition_of_done],i)}async function Tt(e,t,r){if(r.clearCriteria===!0&&!U(t))throw new l("--clear-criteria is only supported with config set criteria-list keys",s.USAGE);return t==="item_format"?Ct(e,r):t==="context"?yt(e.settings,r,e.target,e.scope,e.warnings):t==="definition_of_done"?It(e,t,r):ye(t)?St(e,t,r):nt.has(t)?Rt(e,t,r):at.has(t)?qt(e,t,r):lt(t)?Gt(e,t,r):ct(t)?Pt(e,t,r):_t(t)?At(e,t,r):Et(e,t,r)}async function rr(e,t,r,n,i,a){let o=ve(e),_=we(t),c=_==="get"||_==="set"?oe(r):void 0,f=c?void 0:gt(_,r),u=Ae(_,r,f,c,a,n),y=await mt(o,i),{settings:v,metadata:Ge,warnings:Pe}=await re(y.pmRoot),w={scope:o,target:y,settings:v,metadata:Ge,warnings:Ee(Pe)};return c?kt(w,_,c,u):_==="list"?wt(w):_==="export"?ht(w):(Se(f),_==="get"?bt(w,f):Tt(w,f,u))}var nr={hasGovernanceValidationMirrorChange:L,applyPositionalValue:Ae,normalizeAction:we,normalizeCriteria:be,normalizeGovernanceCloseValidationDefault:Y,normalizeGovernanceCreateModeDefault:K,normalizeGovernanceForceRequiredForStaleLockPolicy:W,normalizeGovernanceOwnershipEnforcement:V,normalizeGovernancePreset:j,normalizeGovernanceRequireCloseReasonPolicy:B,normalizeGovernanceWorkflowEnforcement:M,normalizeHistoryMissingStreamPolicy:D,normalizeItemFormat:ke,normalizeKey:he,normalizeMetadataRequiredFields:Ce,normalizePolicyForConflict:N,normalizeScope:ve,normalizeTelemetryTrackingPolicy:F,normalizeTestResultTrackingPolicy:z,normalizeValidateMetadataProfile:G,normalizeWarnings:Ee};export{Dt as a,rr as b,nr as c};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-7C4PTJG6.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as p,Ad as cr,B as he,C as h,Cb as We,D as w,Da as He,F as ce,G as Q,H as b,I as rr,
|
|
1
|
+
import{A as p,Ad as cr,Af as V,B as he,Bf as ue,C as h,Cb as We,D as w,Da as He,F as ce,G as Q,H as b,I as rr,Lf as tt,Mf as rt,Na as J,Oa as ge,Pa as Ye,Qa as nr,R as L,Sc as ir,Ta as or,Tc as sr,Z as de,_ as qe,ad as Ke,b as z,bb as Be,c as v,d as S,e as Ue,f as ae,gd as Qe,hd as Je,lc as Ge,mf as et,t as je,td as ar,uc as ye,ud as Xe,uf as Ee,zd as Ze,zf as X}from"./chunk-GE4KCSZP.js";import{mkdir as _o,readFile as ho}from"node:fs/promises";import dr 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]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function go(e){let t=e.trim();if(!t)throw new h("--rollback requires a non-empty checkpoint ID",p.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new h("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",p.USAGE);return t}function yo(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function ur(e,t){return dr.join(e,"checkpoints",t)}function lr(e,t,r){return dr.join(ur(e,t),`${r}.json`)}async function Eo(e,t,r,n){let o=ur(e,t);await _o(o,{recursive:!0});let i=lr(e,t,r);return await S(i,`${JSON.stringify(n,null,2)}
|
|
2
2
|
`),i}function wo(e,t){if(!Array.isArray(e.items))throw new h(`Checkpoint ${t} is missing items`,p.GENERIC_FAILURE);return e.items.map(r=>{if(!r||typeof r!="object")throw new h(`Checkpoint ${t} contains an invalid item entry`,p.GENERIC_FAILURE);let n=r;if(typeof n.id!="string"||n.id.trim().length===0)throw new h(`Checkpoint ${t} contains an item entry without ID`,p.GENERIC_FAILURE);if(typeof n.target_updated_at!="string"||n.target_updated_at.trim().length===0)throw new h(`Checkpoint ${t} contains an item entry without target_updated_at`,p.GENERIC_FAILURE);return{id:n.id.trim(),target_updated_at:n.target_updated_at.trim()}})}async function bo(e,t,r,n){let o=go(r),i=lr(e,t,o);if(!await z(i))throw new h(`Checkpoint ${o} not found`,p.NOT_FOUND);let s=await ho(i,"utf8"),a;try{a=JSON.parse(s)}catch(u){throw new h(`Checkpoint ${o} contains invalid JSON: ${b(u)}`,p.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new h(`Checkpoint ${o} is invalid`,p.GENERIC_FAILURE);let c=a;if(c.schema_version!==n)throw new h(`Checkpoint ${o} has unsupported schema version`,p.GENERIC_FAILURE);let d=wo(c,o);return{record:c,items:d,path:i,id:typeof c.id=="string"?c.id:o,created_at:typeof c.created_at=="string"?c.created_at:L(),author:typeof c.author=="string"?c.author:"unknown"}}async function To(e,t){let r=[],n=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);r.push({id:o.id,status:"restored",changed_fields:i.changed_fields,warnings:i.warnings}),n.push(o.id)}catch(i){r.push({id:o.id,status:"failed",error:b(i)})}return{rows:r,restored_ids:n,failed_count:r.filter(o=>o.status==="failed").length}}(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]="4507a449-1c20-5684-9ed8-e72c9bc694c1")}catch{}})();function Z(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function So(e,t){let r=Z(t);return!e||!r?null:[...e.search_providers].reverse().find(o=>(Z(o.runtime_definition?.name)??Z(o.definition?.name))===r)??null}function xo(e,t){let r=Z(t);return!e||!r?null:[...e.vector_store_adapters].reverse().find(o=>(Z(o.runtime_definition?.name)??Z(o.definition?.name))===r)??null}function Fd(e){return e.runtime_definition??e.definition}import{readFile as Io}from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7426082f-94a6-5b4e-9748-d3faab2fe1d4")}catch{}})();var Ao=e=>Io(e,"utf8");async function vo(e,t,r=Ao){if(t!==void 0)throw new h("--body and --body-file are mutually exclusive; provide the body inline with --body or from a file with --body-file, not both.",p.USAGE,{code:"body_file_conflicts_with_body",required:"Choose exactly one body source.",why:"Both --body and --body-file set the item body; allowing both would make the effective body ambiguous.",nextSteps:["Re-run with only --body <text> or only --body-file <path>."]});let n=e.trim();if(n.length===0)throw new h("--body-file requires a file path.",p.USAGE,{code:"body_file_missing_path",required:"Pass a readable file path: --body-file <path>.",why:"An empty --body-file value has no file to read the body from."});try{return await r(n)}catch(o){let i=o?.code,s=i==="EISDIR",a=i?` (${i})`:"";throw new h(s?`--body-file "${n}" is a directory, not a file. Point it at a readable file.`:`--body-file could not read "${n}"${a}. Check that the file exists and is readable.`,p.NOT_FOUND,{code:"body_file_unreadable",required:"Point --body-file at an existing, readable file.",why:`The body content is loaded from the file at the supplied path, so an unreadable path cannot produce a body${i?` (underlying error: ${i})`:""}.`,nextSteps:[`Verify the path: ls -l "${n}"`,"Or pass the body inline with --body <text>."]})}}(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]="4a376062-2e23-5991-80a5-27183909caf3")}catch{}})();var Co=new Set(["none","null","undefined"]);function Wd(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new h("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",p.USAGE)}function Lo(e){if(typeof e!="string")throw new h("--parent must be a string. Use --unset parent to clear this field.",p.USAGE);let t=e.trim();if(t.length===0)throw new h("--parent must not be empty. Use --parent none to unset.",p.USAGE);if(fr(t))throw new h(`--parent must not use placeholder token "${t}". Use --unset parent to clear this field.`,p.USAGE);return t}function fr(e){return Co.has(e.trim().toLowerCase())}function No(e,t){if(t==="strict_error")throw new h(`Parent item "${e}" was not found. Create it first or use --parent none.`,p.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function Ro(e,t,r){let n=Ee(e,r),o=Ee(t,r);if(n!==o)return;let i=t!==o||e!==n?` (normalized from parent "${t}" and item "${e}")`:"";throw new h(`Parent item "${o}" cannot be the same as item "${n}"${i}. Use --unset parent to clear this field.`,p.USAGE)}(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]="806bf35f-dc7e-55a8-9bb9-64be87111c22")}catch{}})();var nt={critical:0,high:1,medium:2,low:3,minimal:4},Do=Object.keys(nt),ko=`numbers 0..4 (0=critical, 1=high, 2=medium, 3=low, 4=minimal) or names (${Do.join(", ")}), case-insensitive`;function we(e){return new h(`Invalid priority "${e}". Accepted values: ${ko}.`,p.USAGE)}function Mo(e){if(typeof e=="number"){if(Number.isInteger(e)&&e>=0&&e<=4)return e;throw we(String(e))}if(typeof e!="string")throw we(String(e));let t=e.trim();if(t.length===0)throw we(e);let r=t.toLowerCase();if(Object.prototype.hasOwnProperty.call(nt,r))return nt[r];if(/^[0-4]$/.test(t))return Number(t);throw we(e)}(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]="bf76a01e-7292-59df-94ca-1e41aaff7365")}catch{}})();var Oo=/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,Po=64;function eu(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new h("Config set sprint-release-format-policy requires --policy with one of: warn, strict_error (alias: strict)",p.USAGE)}function zo(e,t,r){let n=t.trim();if(n.length===0)throw new h(`--${e} must not be empty. Use --${e} none to unset.`,p.USAGE);if(n.length<=Po&&Oo.test(n))return{value:n,warnings:[]};let i="Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._/-]* (no spaces).";if(r==="strict_error")throw new h(`Invalid --${e} value "${n}". ${i}`,p.USAGE);return{value:n,warnings:[`validation_warning:${e}_format:${n}`]}}(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]="d0e997bc-8bdb-5602-8606-73ecf77b2a35")}catch{}})();var mr={open:"open_status",closed:"close_status",canceled:"canceled_status",cancelled:"canceled_status"},pr="all";function su(e){if(typeof e!="string")return!1;let t=e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r.length>0);return t.length===1&&t[0]===pr}function Fo(e,t){let r=e.trim().toLowerCase();if(r.length===0)return;let n=mr[r];return n?t[n]:Ke(e,t)}function $o(e){let t=new Set(Object.keys(mr));for(let r of e.definitions){t.add(r.id);for(let n of r.aliases)t.add(n)}return[...t]}function Vo(e,t){let r=e.trim().toLowerCase(),n,o=Number.POSITIVE_INFINITY;for(let i of $o(t)){let s=Be(r,i.toLowerCase(),2);s!==null&&s<o&&(n=i,o=s)}return n}function Uo(e,t,r){if(typeof e!="string")return;let n=r?.strict===!0,o=r?.flagLabel??"--status",i=e.split(",").map(c=>c.trim()).filter(c=>c.length>0);if(i.length===0)return;if(i.filter(c=>c.trim().toLowerCase()===pr).length>0){if(i.length===1)return;throw new h(`Invalid ${o} value "all". Use it by itself, or omit ${o} to search every status.`,p.USAGE)}let a=[];for(let c of i){let d=Fo(c,t);if(d===void 0){if(n){let u=Vo(c,t);throw new h(`Invalid ${o} value "${c}". Use open|closed|canceled or a configured status id${u?`. Did you mean "${u}"?`:"."}`,p.USAGE)}a.push(c);continue}a.push(d)}return[...new Set(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]="b7a167e0-3041-5056-a672-ea0a054ed8df")}catch{}})();var jo={bug:"Issue",bugfix:"Issue",defect:"Issue",incident:"Issue",enhancement:"Feature",story:"Feature",userstory:"Feature","user-story":"Feature","user story":"Feature",change:"Chore",ticket:"Task",todo:"Task"};function qo(e){if(e!==void 0)return jo[e.trim().toLowerCase()]}(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]="6d11dc0f-e313-5b39-965d-6bc84ad52966")}catch{}})();function hr(e){let t=[],r=new Set;for(let n of e)for(let o of Object.keys(n))r.has(o)||(r.add(o),t.push(o));return t}function ot(e){return e==null?"":Array.isArray(e)?e.map(t=>ot(t)).join(";"):typeof e=="object"?JSON.stringify(e):String(e)}function _r(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Ho(e){if(e.length===0)return"";let t=hr(e),r=[t.map(n=>_r(n)).join(",")];for(let n of e)r.push(t.map(o=>_r(ot(n[o]))).join(","));return r.join(`
|
|
3
3
|
`)}function Yo(e){if(e.length===0)return"";let t=hr(e),r=e.map(s=>t.map(a=>ot(s[a]))),n=t.map((s,a)=>Math.max(s.length,...r.map(c=>c[a].length))),o=(s,a)=>s.padEnd(n[a]),i=[t.map((s,a)=>o(s,a)).join(" | ")];i.push(n.map(s=>"-".repeat(s)).join("-+-"));for(let s of r)i.push(s.map((a,c)=>o(a,c)).join(" | "));return i.join(`
|
|
4
4
|
`)}(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]="43a56374-808c-5fa6-bd6c-5d93175df0d2")}catch{}})();function gr(e,t){return We(e,t)}function Bo(e,t,r){let n={};for(let o of t.command_to_fields.get(r)??[]){let i=ir(e,o);i!==void 0&&(n[o.metadata_key]=sr(o,i))}return n}function Wo(e,t){for(let[r,n]of Object.entries(t)){let o=e[r];if(Array.isArray(n)){if(Array.isArray(o)){let i=o.map(a=>String(a));if(!n.map(a=>String(a)).every(a=>i.includes(a)))return!1;continue}if(!gr(o,n[n.length-1]))return!1;continue}if(!gr(o,n))return!1}return!0}import{spawnSync as Er}from"node:child_process";(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]="12bfc6e7-8979-58e8-8276-98cc859f3e32")}catch{}})();var Go="PM_DISABLE_OLLAMA_AUTO_DEFAULTS",Ko="PM_OLLAMA_MODEL",Qo="http://localhost:11434",Jo="qwen3-embedding:0.6b",Xo=".agents/pm/search/lancedb/",Zo=1500,ei=2500,ti=/qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i,ri=/embed|embedding/i,R=w;function ni(){let e=R(process.env[Go]);if(!e)return!1;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"}function yr(e){return e.some(t=>R(t)!==null)}function oi(e){let t=R(e);return!!(t&&t.toLowerCase()!=="ollama")}function ii(e){let t=R(e);return!!(t&&t.toLowerCase()!=="lancedb")}function si(e){return oi(e.search?.provider)||ii(e.vector_store?.adapter)||yr([e.providers?.openai?.base_url,e.providers?.openai?.model,e.providers?.openai?.api_key])?!0:yr([e.vector_store?.qdrant?.url,e.vector_store?.qdrant?.api_key])}function ai(){let e=Er("ollama",["--version"],{encoding:"utf8",timeout:Zo});return e.error?!1:e.status===0}function ci(e){let t=e.split(/\r?\n/).map(i=>i.trim()).filter(i=>i.length>0);if(t.length===0)return null;let r=t.map(i=>i.split(/\s+/)[0]?.trim()).filter(i=>!!(i&&i.length>0)).filter(i=>i.toUpperCase()!=="NAME");if(r.length===0)return null;let n=r.find(i=>ti.test(i));return n||(r.find(i=>ri.test(i))??null)}function di(e){let t=R(e.providers?.ollama?.model);if(t)return t;let r=R(process.env[Ko]);if(r)return r;let n=Er("ollama",["list"],{encoding:"utf8",timeout:ei});if(!n.error&&n.status===0){let o=ci(typeof n.stdout=="string"?n.stdout:"");if(o)return o}return null}function ui(e){return{baseUrl:R(e.providers?.ollama?.base_url)===null,model:R(e.providers?.ollama?.model)===null,lancedbPath:R(e.vector_store?.lancedb?.path)===null,embeddingModel:R(e.search?.embedding_model)===null}}function li(e){return e.baseUrl||e.model||e.lancedbPath||e.embeddingModel}function fi(e,t,r){if(!t.baseUrl&&!t.model)return;let n=e.providers??={},o=n.ollama??={};t.baseUrl&&(o.base_url=Qo),t.model&&(o.model=r)}function mi(e,t){if(!t.lancedbPath)return;let r=e.vector_store??={},n=r.lancedb??={};n.path=Xo}function pi(e,t,r){if(!t.embeddingModel)return;let n=e.search??={};n.embedding_model=r}function ee(e){let t={settings:e,auto_ollama_defaults_applied:!1};if(ni()||si(e))return t;let r=ui(e);if(!li(r)||r.model&&!ai())return t;let n=structuredClone(e),o=di(n);return o?(fi(n,r,o),mi(n,r),pi(n,r,o),{settings:n,auto_ollama_defaults_applied:!0}):{...t,auto_ollama_defaults_skipped_reason:"no_installed_embedding_model",auto_ollama_defaults_remediation:`Run ollama pull ${Jo} or configure providers.ollama.model explicitly (and search.embedding_model if you need an override).`}}import{spawn as _i}from"node:child_process";import{mkdirSync as wr,rmSync as Tr,statSync as hi}from"node:fs";import be 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]="d8d5f7e9-5293-564b-bc44-f5ba30336893")}catch{}})();var Sr="reindex",gi="search/pending-refresh.json",yi="search/pending-refresh.gate.lock",Ei=3e4,wi="PM_SEARCH_REFRESH_INLINE",xr="PM_SEARCH_REFRESH_CHILD",bi=3e4;function br(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}function Ti(){if(br(process.env[wi])||br(process.env[xr]))return!0;let e=(process.env.NODE_ENV??"").trim().toLowerCase();return typeof process.env.VITEST=="string"||typeof process.env.VITEST_WORKER_ID=="string"||e==="test"}function Ir(e){return be.join(e,gi)}function Ar(e){return be.join(e,yi)}function Si(e){let t=Ar(e);try{if(Date.now()-hi(t).mtimeMs<Ei)return!1;Tr(t,{recursive:!0,force:!0})}catch{}try{return wr(be.dirname(t),{recursive:!0}),wr(t),!0}catch{return!1}}function xi(e){try{Tr(Ar(e),{recursive:!0,force:!0})}catch{}}async function vr(e,t,r){for(let n=0;n<50;n+=1){if(Si(e))try{return await t()}finally{xi(e)}await Ii(20)}return r}function Ii(e){return new Promise(t=>{setTimeout(t,e)})}async function st(e){let t=await v(Ir(e));if(!t||t.trim().length===0)return[];try{let r=JSON.parse(t);return Array.isArray(r.ids)?r.ids.filter(n=>typeof n=="string"&&n.length>0):[]}catch{return[]}}async function Cr(e,t){await S(Ir(e),`${JSON.stringify({ids:t})}
|
|
@@ -16,4 +16,4 @@ Enable telemetry now? [${e?"Y/n":"y/N"}] `,n=sc.createInterface({input:ac,output
|
|
|
16
16
|
`)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=md(o)),t.push(o))}catch{}}return t}function pd(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let r=Date.parse(e.enqueued_at);return Number.isNaN(r)?!1:r<t}function co(e,t){let r=oo(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>ze||pd(i,r)||i.attempts>=On){o+=1;continue}n.push(i)}if(n.length>Tn){let i=n.length-Tn;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function _d(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
|
|
17
17
|
`),n=r.length>0?`${r}
|
|
18
18
|
`:"";for(let o=0;;o+=1)try{await S($e(e),n);return}catch(i){let s=Pn[o];if(s===void 0||!io(i))throw i;await so(s)}}async function Ln(e,t,r,n){return _e(async()=>{let o=await v($e(e)),i=o===null?[]:ao(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=co(s,t);return await _d(e,a),a.length})}async function hd(e,t){let r=await v($e(e));if(r===null||r.trim().length===0){await O(e,{pending_otel_spans:0});return}let n=ao(r),{entries:o,prunedCount:i}=co(n,t),s=o.filter(g=>no(g.next_attempt_after)).slice(0,Tc);if(s.length===0){let g=i>0?await Ln(e,t,new Set,new Map):o.length;await O(e,{pending_otel_spans:g});return}let a=L(),c=new Set,d=new Map,u=0,l;await Promise.all(s.map(async g=>{try{let _=await fetch(g.endpoint,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(g.payload),signal:AbortSignal.timeout(Dn)});if(!_.ok)throw new Error(`local_otel_export_http_${_.status}`);c.add(g.id),u+=1}catch(_){l=_ instanceof Error?T(_.message,"redacted"):"local_otel_export_failed";let y=g.attempts+1;d.set(g.id,{attempts:y,next_attempt_after:ro(y)})}}));let f=await Ln(e,t,c,d),m={pending_otel_spans:f,last_otel_attempt_at:a};u>0&&(m.last_otel_success_at=a),l!==void 0?(m.last_otel_failure_at=a,m.last_otel_failure_error=l):f===0&&(m.last_otel_failure_at=void 0,m.last_otel_failure_error=void 0),await O(e,m)}async function uo(e,t,r){try{await wd(e,t,r)}catch{}try{await hd(e,r)}catch{}}async function gd(e,t=Cc){try{let r=Kc(e),n=await yc(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=C.join(r,i.name);(await Rn(s)).mtimeMs<o&&await qt(s,{force:!0})}))}catch{}}async function _e(e){let t=An.catch(()=>{}).then(e);return An=t.catch(()=>{}),t}async function Zt(e){let t=await v(pe(e));return t===null||t.trim().length===0?[]:to(t)}async function yd(e,t,r){return _e(async()=>{let n=await Zt(e),{entries:o}=Xt(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await Oe(e,i),i})}async function Ed(e,t,r,n){return _e(async()=>{let o=await Zt(e),{entries:i}=Xt(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:ro(c)}});return await Oe(e,s),s})}async function wd(e,t,r){await gd(e);let n=t.trim();if(n.length===0)return;let o=await v(pe(e));if(o===null||o.trim().length===0){await O(e,{endpoint:n,queue_entries:0});return}let i=to(o);if(i.length===0){await O(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=Xt(i,r);if(s.length===0){await Oe(e,[]),await O(e,{endpoint:n,queue_entries:0});return}let c=s.filter(m=>ud(m)).slice(0,Sc);if(c.length===0){a>0&&await Oe(e,s),await O(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(m=>m.event.event_id)),u=L(),l={"content-type":"application/json"},f=process.env.PM_TELEMETRY_INGEST_KEY?.trim();f&&(l["x-pm-telemetry-key"]=f);try{let m=await fetch(n,{method:"POST",headers:l,body:JSON.stringify({schema_version:Pe,events:c.map(g=>g.event)}),signal:AbortSignal.timeout(Dn)});if(!m.ok)throw new Error(`telemetry_flush_http_${m.status}`)}catch(m){let g=await Ed(e,d,u,r),_=m instanceof Error?T(m.message,"redacted"):"telemetry_flush_failed";await O(e,{endpoint:n,queue_entries:g.length,last_attempted_flush_at:u,last_failed_flush_at:u,last_failed_flush_error:_});return}try{let m=await yd(e,d,r);await O(e,{endpoint:n,queue_entries:m.length,last_attempted_flush_at:u,last_successful_flush_at:u,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(m){let g=m instanceof Error?T(m.message,"redacted"):"telemetry_flush_failed",_=await Zt(e).catch(()=>s);await O(e,{endpoint:n,queue_entries:_.length,last_attempted_flush_at:u,last_failed_flush_at:u,last_failed_flush_error:g})}}async function bd(e){let t=Yt(e);await zt(C.dirname(t),{recursive:!0});try{return await zt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await Rn(t);return Date.now()-r.mtimeMs<zn?!1:(await qt(t,{recursive:!0,force:!0}),await zt(t),!0)}catch{return!1}}function Td(e,t){try{return Date.now()-Nn(e).mtimeMs<t}catch{return!1}}function lo(e){try{gc(e,{recursive:!0,force:!0})}catch{}}function fo(e){if(typeof e!="object"||e===null||!("code"in e))return;let t=e.code;return typeof t=="string"?t:void 0}function Sd(e){try{return Pt(e),!0}catch(t){let r=fo(t);if(r==="EEXIST"||r!=="ENOENT")return!1}try{return Pt(C.dirname(e),{recursive:!0}),Pt(e),!0}catch{return!1}}function xd(e){if(Td(Yt(e),zn))return!1;let t=Un(e);try{if(Date.now()-Nn(t).mtimeMs<Lc)return!1;lo(t)}catch(r){if(fo(r)!=="ENOENT")return!1}return Sd(t)}function jt(e){lo(Un(e))}async function Id(e,t,r){let n=await bd(e);if(jt(e),!!n)try{await uo(e,t,r)}finally{try{await qt(Yt(e),{recursive:!0,force:!0})}catch{}}}function er(e,t,r){if(Jc()){let n=In,o=uo(e,t,r);In=Promise.allSettled([n,o]).then(()=>{});return}try{if(!xd(e))return;let o=hc(process.execPath,[Qc()],{detached:!0,stdio:"ignore",cwd:Ht.tmpdir(),env:{...process.env,PM_GLOBAL_PATH:e,[Fn]:"1"}});o.on("error",()=>{jt(e)}),o.unref()}catch{jt(e)}}async function pf(e=J(process.cwd())){if(!Kt())try{if(!(await V(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await Qt(e);await Id(e,r,n)}catch{}}async function Ad(e){if(Kt()||e.command==="telemetry"&&e.args.some(t=>t.trim().toLowerCase()==="clear"))return null;try{let t=J(process.cwd()),r=await V(t);if(!r.telemetry.enabled)return null;let n=Kn(r.telemetry.capture_level),{installationId:o,endpoint:i,retentionDays:s}=await Qt(t),a=Qn(e.pm_version),c=Xn(e.global),d=x(o,e.pm_root),u=x(o,process.cwd()),l=nd(),f=L(),m={schema_version:Pe,event_id:P.randomUUID(),event_type:"command_start",occurred_at:f,installation_id:o,session_id:Fe,command:e.command,payload:ad({captureLevel:n,context:e,pmVersion:a,sourceContext:c,pmRootHash:d,cwdHash:u,installationId:o})};await Jt(t,m),er(t,i,s);let g=oe(e.command);return{started_at:f,started_at_ms:Date.now(),command:e.command,command_taxonomy:g,pm_version:a,source_context:c.source_context,source_context_source:c.source_context_source,installation_id:o,pm_root_hash:d,cwd_hash:u,endpoint:i,retention_days:s,global_pm_root:t,capture_level:n,otel_traces_endpoint:l??void 0,otel_trace_id:l?P.randomBytes(16).toString("hex"):void 0,otel_span_id:l?P.randomBytes(8).toString("hex"):void 0}}catch{return null}}async function vd(e,t){if(e)try{let r=L(),n=Math.max(0,Date.now()-e.started_at_ms),o=Bt(Nt({ok:t.ok,errorCode:t.error_code,errorMessage:t.error,exitCode:t.exit_code})),i=Jn({ok:t.ok,errorCode:o,errorCategory:t.error_category}),s=Wt(t.exit_code,t.ok),a=t.command_resolution??ie({ok:t.ok,errorCode:o,errorCategory:i}),c=t.resolution_stage??"execute",d={schema_version:Pe,event_id:P.randomUUID(),event_type:"command_finish",occurred_at:r,installation_id:e.installation_id,session_id:Fe,command:e.command,payload:cd({captureLevel:e.capture_level,pmVersion:e.pm_version,sourceContext:{source_context:e.source_context,source_context_source:e.source_context_source},outcome:t,durationMs:n,startedAt:e.started_at,command:e.command,installationId:e.installation_id,commandTaxonomy:e.command_taxonomy,exitCode:s,errorCode:o,errorCategory:i,commandResolution:a,resolutionStage:c})};await Jt(e.global_pm_root,d);let u=id(e,{...t,exit_code:s,error_code:o,error_category:i},r,n);u&&await fd(e.global_pm_root,u),er(e.global_pm_root,e.endpoint,e.retention_days)}catch{}}async function Cd(e){if(!Kt())try{let t=J(process.cwd()),r=await V(t);if(!r.telemetry.enabled)return;let n=Kn(r.telemetry.capture_level),{installationId:o,endpoint:i,retentionDays:s}=await Qt(t),a=Qn(e.pm_version),c=Xn(e.global),d=x(o,e.pm_root),u=x(o,process.cwd()),l=L(),f=Bt(Nt({ok:!1,errorCode:e.error_code,errorMessage:e.error_message,exitCode:e.exit_code})),m=e.error_category??he(f),g=Wt(e.exit_code,!1),_=e.command.trim().length>0?e.command:"<unknown>",y=oe(_),E=e.command_resolution??ie({ok:!1,errorCode:f,errorCategory:m}),I=e.resolution_stage??"unknown",A={schema_version:Pe,event_id:P.randomUUID(),event_type:"command_error",occurred_at:l,installation_id:o,session_id:Fe,command:T(_,"redacted"),payload:dd({captureLevel:n,pmVersion:a,sourceContext:c,command:_,commandTaxonomy:y,commandResolution:E,resolutionStage:I,args:e.args,options:e.options,pmRootHash:d,cwdHash:u,installationId:o,errorCode:f,errorCategory:m,exitCode:g,errorMessage:e.error_message})};await Jt(t,A),er(t,i,s)}catch{}}(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]="89efaf82-c9cb-560d-b1ca-5a676b4b979c")}catch{}})();export{yo as a,Eo as b,bo as c,To as d,So as e,xo as f,Fd as g,vo as h,Wd as i,Lo as j,fr as k,No as l,Ro as m,Mo as n,eu as o,zo as p,su as q,Uo as r,qo as s,Ho as t,Yo as u,Bo as v,Wo as w,ee as x,Sr as y,Ti as z,Au as A,Du as B,Se as C,kr as D,ct as E,Vi as F,Ui as G,Ou as H,Mr as I,te as J,ut as K,ft as L,Ce as M,Bu as N,bt as O,Ne as P,Ur as Q,Re as R,Tt as S,St as T,xt as U,It as V,Wr as W,Gr as X,qr as Y,zs as Z,ca as _,ie as $,Ea as aa,wa as ba,ba as ca,Ta as da,Sa as ea,Ia as fa,va as ga,Ca as ha,La as ia,Oa as ja,fn as ka,za as la,Fa as ma,$a as na,Nl as oa,Mt as pa,pn as qa,mn as ra,_n as sa,Ua as ta,ja as ua,hn as va,Ya as wa,Ka as xa,Ja as ya,Za as za,rc as Aa,oc as Ba,ic as Ca,_c as Da,Pe as Ea,On as Fa,$c as Ga,pf as Ha,Ad as Ia,vd as Ja,Cd as Ka};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-A62CYISG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{af as g,gf as y}from"./chunk-GE4KCSZP.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="19ff592c-0746-54e8-a304-2006f4845da2")}catch{}})();function b(t){return t.replaceAll("~1","/").replaceAll("~0","~")}function w(t){if(t==="/body"||t.startsWith("/body/"))return"body";if(t==="/metadata"||t.startsWith("/metadata/")||t==="/front_matter"||t.startsWith("/front_matter/")){let r=t.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return r?b(r):"metadata"}let e=t.replace(/^\//,"").split("/")[0];return e?b(e):"root"}function i(t,e){return e==="body"?t.body:e==="metadata"?t.metadata:e==="root"?t:t.metadata[e]}function D(t,e){let r=e?.windowStartIndex??0,a=e?.field;if(t.length===0||r>=t.length)return[];let l=g(),u=[];for(let d=0;d<t.length;d+=1){let n=t[d],p=l,h=y(l,n.patch),s;h.ok?(s=h.document,l=s):s=p;let f=new Set;for(let o of n.patch)f.add(w(o.path)),o.from!==void 0&&f.add(w(o.from));let m=[...f].sort((o,c)=>o.localeCompare(c));if(d>=r)if(a!==void 0){if(!f.has(a))continue;let o={field:a,before:i(p,a),after:i(s,a)};u.push({index:d+1,ts:n.ts,op:n.op,author:n.author,patch_ops:n.patch.length,changed_fields:[a],changes:[o]})}else{let o=m.map(c=>({field:c,before:i(p,c),after:i(s,c)}));u.push({index:d+1,ts:n.ts,op:n.op,author:n.author,patch_ops:n.patch.length,changed_fields:m,changes:o})}}return u}export{w as a,D as b};
|
|
2
|
+
//# sourceMappingURL=chunk-BPELKUQD.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{bd as u,cd as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{bd as u,cd as p}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]="bf429f76-9722-5e34-a5f0-6ced8d1ed667")}catch{}})();var D="blocked_by",B="no-active-blocker";function d(e){return e.trim().toLowerCase()}function b(e){let t=new Set,n=typeof e.blocked_by=="string"?e.blocked_by.trim():"";n.length>0&&n.toLowerCase()!==B&&t.add(n);for(let o of e.dependencies??[])o.kind===D&&typeof o.id=="string"&&o.id.trim().length>0&&o.id.trim().toLowerCase()!==B&&t.add(o.id.trim());return[...t].sort((o,c)=>o.localeCompare(c))}function k(e,t,n){return b(e).map(o=>{let c=t.get(d(o));return c?{id:o,title:c.title,status:c.status,resolved:p(c.status,n)}:{id:o,title:null,status:null,resolved:!1}})}function C(e,t){let n=new Map(e.map(s=>[d(s.id),s])),o=new Set([...I(t),...t.blocked_statuses]),c=new Set;for(let s of e){let l=u(s.status,t);if(!o.has(l))continue;(t.blocked_statuses.has(l)||k(s,n,t).some(a=>!a.resolved))&&c.add(d(s.id))}return c}function I(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function E(e,t,n){let o=[d(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let l of t.get(s)??[]){if(!p(l.status,n))return!0;o.push(d(l.id))}}}return!1}function T(e){let t=new Map,n=new Map,o=new Map;for(let c of e){t.set(d(c.id),c);let s=typeof c.parent=="string"?c.parent.trim():"";if(s.length>0){let l=d(s),i=n.get(l)??[];i.push(c),n.set(l,i)}for(let l of b(c)){let i=d(l),a=o.get(i)??[];a.push(c.id),o.set(i,a)}}return{itemsById:t,childrenByParent:n,blockedByReverse:o}}function x(e,t,n){let{itemsById:o,childrenByParent:c,blockedByReverse:s}=T(t),l=new Set([...I(n),...n.blocked_statuses]),i=new Set(t.filter(r=>!p(r.status,n)).map(r=>d(r.id))),a=[],y=[],m=0,h=0;for(let r of e){if(!l.has(u(r.status,n)))continue;if(m+=1,E(r.id,c,n)){h+=1;continue}let w=k(r,o,n).filter(f=>!f.resolved),v=(s.get(d(r.id))??[]).filter(f=>i.has(d(f))).sort((f,S)=>f.localeCompare(S)),_={item:r,open_blockers:w,unblocks:v},g=n.blocked_statuses.has(u(r.status,n));w.length===0&&!g?a.push(_):y.push(_)}return{ready:a,blocked:y,active_count:m,container_count:h}}(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]="9184e723-8269-5e45-8c6a-52fd02da60e6")}catch{}})();export{b as a,k as b,C as c,x as d};
|
|
2
|
+
//# sourceMappingURL=chunk-BXQLRKWF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as N}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as N}from"./chunk-HNFD72UK.js";import{c as T}from"./chunk-PMXJEU3F.js";import{a as m}from"./chunk-FB7G2HY2.js";import{u as D}from"./chunk-RKAVWO3O.js";import{a as R,b as I,c as v,d as M}from"./chunk-A62CYISG.js";import{A as u,Af as q,C as f,Da as S,H as C,La as E,Nc as y,Oa as A,Of as x,R as b,b as k,cd as g,lc as O,zd as P}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]="1be4d7c4-3ede-59cc-8d70-df966a66e67e")}catch{}})();var U=1,_="close-many",z=["--filter-status","--filter-type","--filter-tag","--filter-priority","--filter-sprint","--filter-release","--filter-parent","--filter-assignee","--filter-updated-before","--ids"].join(", ");function L(e,t){return m(e,t,{includePagination:!1})}function G(e,t){return m(e,t)}function F(e){if(e?.ids!=null&&String(e.ids).trim().length===0)throw new f("--ids requires at least one non-empty item ID",u.USAGE)}function V(e){let t={};if(!e)return t;for(let[n,o]of Object.entries(e))o==null||typeof o=="string"&&!o.split(",").some(i=>i.trim().length>0)||(t[n]=o);return t}function $(e,t){let n=String(e??"").trim();if(n.length>0)return n;if(t)throw new f("pm close-many requires a shared close reason via --reason because governance.require_close_reason is enabled.",u.USAGE,{code:"close_reason_required",required:"Provide a shared closing summary via --reason for the whole batch.",why:"governance.require_close_reason is enabled, so every close must record why the items are done.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met"','pm close-many --ids pm-a,pm-b --reason "Superseded by redesign"'],nextSteps:["Re-run with --reason describing the shared outcome.","To stop requiring reasons, run: pm config set governance-require-close-reason --policy disabled"]})}async function B(e,t){let n=y(t.schema),o=S(t,O()),i=await x(e,t.item_format,o.type_to_folder,void 0,t.schema),s=new Map,l=new Map;for(let r of i){if(typeof r.parent!="string"||r.parent.length===0||(l.set(r.id,r.parent),g(r.status,n)))continue;let c=s.get(r.parent);c?c.push(r.id):s.set(r.parent,[r.id])}for(let r of s.values())r.sort((c,a)=>c.localeCompare(a));return{childrenByParent:s,parentByChild:l}}function w(e,t,n){let o=n?.get(e);if(o!==void 0)return o;let i=0,s=t.get(e),l=[],r=new Set,c=!1;for(;s!==void 0&&!r.has(s);){let a=n?.get(s);if(a!==void 0){i+=a+1;break}r.add(s),l.push(s),i+=1,s=t.get(s)}if(s!==void 0&&r.has(s)&&(c=!0),!c){n?.set(e,i);for(let[a,h]of l.entries())n?.set(h,i-a-1)}return i}async function K(e){let t=await v(e.pmRoot,_,e.rollbackId,U),n=e.options.message??`Rollback close-many checkpoint ${t.id}`,o=await M(t.items,(i,s)=>N(i,s,{author:e.options.author,message:n,force:!0},e.global));return{mode:"rollback",matched_count:t.items.length,dry_run:!1,rollback_checkpoint_id:t.id,checkpoint:{id:t.id,created_at:t.created_at,path:t.path,rollback_command:`pm close-many --rollback ${t.id}`},restored_count:o.restored_ids.length,failed_count:o.failed_count,rows:o.rows,ids:o.restored_ids}}function X(e,t,n,o,i){return e.map(s=>{let l=(t.get(s.id)??[]).filter(c=>!n.has(c)),r=!H(s,o,i);return{id:s.id,title:typeof s.title=="string"?s.title:"",status:s.status,action:r?"skip":"close",...r?{skip_reason:"already_terminal"}:{},...l.length>0?{active_child_ids:l}:{}}})}async function J(e){let t=await I(e.pmRoot,_,e.checkpointId,{schema_version:U,id:e.checkpointId,created_at:e.nowValue,author:P(e.options.author,"unknown"),...e.reason!==void 0?{reason:e.reason}:{},filters:e.filters,items:e.checkpointItems});return{id:e.checkpointId,created_at:e.nowValue,path:t,rollback_command:`pm close-many --rollback ${e.checkpointId}`}}async function Q(e){let t=[],n=[];for(let o of e.matched){if(!e.closableIds.has(o.id)){t.push({id:o.id,status:"skipped",skip_reason:"already_terminal"});continue}try{let i=await T(o.id,e.reason,e.closeOptions,e.global);t.push({id:o.id,status:"closed",changed_fields:i.changed_fields,...i.warnings&&i.warnings.length>0?{warnings:i.warnings}:{}}),n.push(o.id)}catch(i){t.push({id:o.id,status:"failed",error:C(i)})}}return{rows:t,closedIds:n}}function W(e){return typeof e.rollback=="string"?e.rollback:void 0}function Z(e,t){if(t.trim().length===0)throw new f("--rollback requires a checkpoint id",u.USAGE);if(e.dryRun===!0)throw new f("--dry-run cannot be combined with --rollback",u.USAGE);if(G(e.list,e.status))throw new f("Rollback mode does not accept filter options",u.USAGE)}function ee(e){if(!L(e.list,e.status))throw new f(`close-many requires at least one filter to scope the close (for example: ${z}). Refusing to match every item.`,u.USAGE)}function te(e,t){let n=new Map;return[...e].sort((o,i)=>{let s=w(i.id,t,n)-w(o.id,t,n);return s!==0?s:o.id.localeCompare(i.id)})}function H(e,t,n){return n||!g(e.status,t)}function ne(e,t,n){return new Set(e.filter(o=>H(o,t,n)).map(o=>o.id))}async function oe(e){ee(e.options);let t=y(e.settings.schema),n=$(e.options.reason,e.settings.governance.require_close_reason),o=e.options.force===!0,i=await D(e.options.status,V(e.options.list),e.global),{childrenByParent:s,parentByChild:l}=await B(e.pmRoot,e.settings),r=te(i.items,l),c=ne(r,t,o);return{pmRoot:e.pmRoot,settings:e.settings,statusRegistry:t,reason:n,validateCloseMode:e.options.validateClose,force:o,listed:i,matched:r,planRows:X(r,s,c,t,o)}}function se(e){return{mode:"dry_run",matched_count:e.matched.length,dry_run:!0,...e.reason!==void 0?{reason:e.reason}:{},filters:e.listed.filters,...e.validateCloseMode?{validate_close:e.validateCloseMode}:{},item_plans:e.planRows,ids:[]}}async function ie(e){if(e.options.checkpoint===!1||e.closableIds.size===0)return;let t=e.context.matched.filter(n=>e.closableIds.has(n.id)).map(n=>({id:n.id,target_updated_at:n.updated_at}));return J({pmRoot:e.context.pmRoot,checkpointId:e.checkpointId,nowValue:e.nowValue,options:e.options,reason:e.context.reason,filters:e.context.listed.filters,checkpointItems:t})}async function ue(e,t){let n=E(process.cwd(),t.path);if(!await k(A(n)))throw new f(`Tracker is not initialized at ${n}. Run pm init first.`,u.NOT_FOUND);let o=await q(n),i=e.dryRun===!0,s=W(e);if(F(e.list),s!==void 0)return Z(e,s),K({pmRoot:n,rollbackId:s,options:e,global:t});let l=await oe({pmRoot:n,settings:o,options:e,global:t});if(i)return se(l);let r=new Set(l.planRows.filter(d=>d.action==="close").map(d=>d.id)),c=b(),a=R(_,c),h=await ie({context:l,options:e,closableIds:r,checkpointId:a,nowValue:c}),j={author:e.author,message:e.message??`close-many apply ${a}`,completedAt:e.completedAt,validateClose:l.validateCloseMode,force:l.force,resolution:e.resolution,expectedResult:e.expectedResult,actualResult:e.actualResult},{rows:p,closedIds:Y}=await Q({matched:l.matched,closableIds:r,reason:l.reason,closeOptions:j,global:t});return{mode:"apply",matched_count:l.matched.length,dry_run:!1,...l.reason!==void 0?{reason:l.reason}:{},filters:l.listed.filters,...l.validateCloseMode?{validate_close:l.validateCloseMode}:{},...h?{checkpoint:h}:{},closed_count:p.filter(d=>d.status==="closed").length,skipped_count:p.filter(d=>d.status==="skipped").length,failed_count:p.filter(d=>d.status==="failed").length,rows:p,ids:Y}}var fe={activeListOptions:V,buildActiveChildrenByParent:B,hasCloseManyFilters:L,hasCloseManyRollbackConflicts:G,hierarchyDepth:w,rejectBlankIdsFilter:F,resolveReason:$};export{ue as a,fe as b};
|
|
2
|
+
//# sourceMappingURL=chunk-CSI3WS5I.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as u,C as l,La as f,Oa as c,Ra as g,
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{A as u,Af as m,C as l,La as f,Oa as c,Ra as g,Tf as y,b as o,zd as h}from"./chunk-GE4KCSZP.js";import n from"node:path";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new a.Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="14aa55e1-cb5f-55ea-bf4c-412217d87449")}catch{}})();async function R(a,e,i){let t=f(process.cwd(),i.path);if(!await o(c(t)))throw new l(`Tracker is not initialized at ${t}. Run pm init first.`,u.NOT_FOUND);let s=await m(t),p=h(e.author,s.author_default),r=await y({pmRoot:t,settings:s,id:a,author:p,message:e.message,force:e.force,dryRun:e.dryRun}),d=r.targetPath?n.relative(t,r.targetPath).split(n.sep).join("/"):void 0;return{item:r.item,changed_fields:r.changedFields,dry_run:e.dryRun===!0,deleted:e.dryRun!==!0,outcome:e.dryRun===!0?"would_delete":"deleted",previous_status:r.item.status,...d?{target_path:d}:{},history_retained:n.relative(t,g(t,r.item.id)).split(n.sep).join("/"),tombstone_retention:"retain_append_only",warnings:r.warnings}}export{R as a};
|
|
2
|
+
//# sourceMappingURL=chunk-DXDREUXT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ra as g,
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{Ra as g,Xe as H,d as _,hf as v,nf as u,of as w}from"./chunk-GE4KCSZP.js";import l from"node:fs/promises";import{createHash as N}from"node:crypto";import S from"node:path";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="90364096-b94c-591c-9024-e697fa9322a5")}catch{}})();var b=3,F="history-drift-cache.json";function D(t){return S.join(t,"runtime",F)}async function T(t){try{let e=await l.readFile(D(t),"utf8"),n=JSON.parse(e);return n.version!==b||typeof n.entries!="object"||n.entries===null?null:n}catch{return null}}function p(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}async function j(t,e,n,i,r){let h=w(t),s;try{s=await l.stat(h)}catch(y){return p(y,"ENOENT")||r.unreadableStreams.push(u),!1}let c=r.missingStreams.length,o=await M({itemId:u,historyPath:h,stat:s,cached:e[u],verifyCacheHitByContent:i,accumulator:r});return o.verification?(o.verification.chainOk||r.chainMismatches.push(u),n[u]={mtime_ms:s.mtimeMs,ctime_ms:s.ctimeMs,size:s.size,content_hash:o.verification.contentHash,latest_after_hash:o.verification.latestAfterHash,chain_ok:o.verification.chainOk},o.cacheDirty):(r.missingStreams.splice(c),o.cacheDirty)}function k(t){return N("sha256").update(t).digest("hex")}async function z(t){let e=await l.readFile(t,"utf8");return k(e)}async function V(t){let e=await l.readFile(t,"utf8"),n=k(e);if(e.trim().length===0)return null;let i=[],r=null;for(let h of e.split(/\r?\n/)){let s=h.trim();if(s.length===0)continue;let c=JSON.parse(s);if(typeof c.after_hash!="string"||c.after_hash.trim().length===0)throw new Error("missing after_hash");i.push(c),r=c.after_hash}return r?{latestAfterHash:r,chainOk:v(i).ok,contentHash:n}:null}function x(t,e){return t!==void 0&&t.mtime_ms===e.mtimeMs&&t.ctime_ms===e.ctimeMs&&t.size===e.size}async function C(t,e,n){try{let i=await V(e);return i||(n.missingStreams.push(t),null)}catch{return n.unreadableStreams.push(t),null}}async function M(t){let e=typeof t.cached?.content_hash=="string"&&t.cached.content_hash.length>0?t.cached.content_hash:void 0;if(!(x(t.cached,t.stat)&&e!==void 0&&t.cached!==void 0)||!t.cached)return{verification:await C(t.itemId,t.historyPath,t.accumulator),cacheDirty:!0};let i;if(t.verifyCacheHitByContent)try{i=await z(t.historyPath)}catch{return t.accumulator.unreadableStreams.push(t.itemId),{verification:null,cacheDirty:!1}}else i=e;return!t.verifyCacheHitByContent||i===e?{verification:{latestAfterHash:t.cached.latest_after_hash,chainOk:t.cached.chain_ok,contentHash:i},cacheDirty:!1}:{verification:await C(t.itemId,t.historyPath,t.accumulator),cacheDirty:!0}}async function G(t,e,n={}){let i={missingStreams:[],unreadableStreams:[],hashMismatches:[],chainMismatches:[]},h=(await T(t))?.entries??{},s={},c=!1,o=n.cacheHitVerification!=="metadata";for(let a of e){let m=g(t,a.id),d;try{d=await l.stat(m)}catch(P){p(P,"ENOENT")?i.missingStreams.push(a.id):i.unreadableStreams.push(a.id);continue}let E=h[a.id],f=await M({itemId:a.id,historyPath:m,stat:d,cached:E,verifyCacheHitByContent:o,accumulator:i});if(c||=f.cacheDirty,!f.verification)continue;f.verification.chainOk||i.chainMismatches.push(a.id),s[a.id]={mtime_ms:d.mtimeMs,ctime_ms:d.ctimeMs,size:d.size,content_hash:f.verification.contentHash,latest_after_hash:f.verification.latestAfterHash,chain_ok:f.verification.chainOk};let{body:I,...A}=a;H({metadata:A,body:I})!==f.verification.latestAfterHash&&i.hashMismatches.push(a.id)}let y=await j(t,h,s,o,i);if(c||=y,c||Object.keys(h).length!==Object.keys(s).length){let a=D(t);try{await l.mkdir(S.dirname(a),{recursive:!0}),await _(a,JSON.stringify({version:b,entries:s}))}catch{}}let O=[...new Set([...i.missingStreams,...i.unreadableStreams,...i.hashMismatches,...i.chainMismatches])].sort((a,m)=>a.localeCompare(m));return{...i,driftedItems:O}}export{G as a};
|
|
2
|
+
//# sourceMappingURL=chunk-E2RKBKWB.js.map
|