@unbrained/pm-cli 2026.8.5 → 2026.8.6
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 +14 -0
- package/dist/cli/main.js +12 -37
- package/dist/cli/register-setup.d.ts +1 -1
- package/dist/cli/register-setup.js +46 -20
- package/dist/cli-bundle/bundle-manifest.json +391 -391
- package/dist/cli-bundle/chunks/append-XAJ5Z4XS.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-2WFXWAYX.js → chunk-343QETLI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RKAVWO3O.js → chunk-3KFVGGRE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VCKLFEUN.js → chunk-3ZJRFYY2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UZBWIUYD.js → chunk-4AVFKHHC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BPELKUQD.js → chunk-4OVGQW22.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-54FNT7U2.js → chunk-5PBP2ZP3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NY4T3JWN.js → chunk-5ZKQPA44.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YUBDMQM.js → chunk-A3XQ7VPU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OPVH7SKD.js → chunk-AJE3AHPD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V3774P7D.js → chunk-AOBDLU4T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VN5VITU3.js → chunk-AYRUGRNS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HWRRMBJO.js → chunk-BP6EMEDP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZYHOB3SN.js → chunk-C3YABSJK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-43HQQI6S.js → chunk-CA3BURYF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-E2RKBKWB.js → chunk-D7I3TUGV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4VN6GS4U.js → chunk-DQGJ2RWT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YSO3YFZ4.js → chunk-DWOAOZHZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q35VBGOQ.js → chunk-E7BFPLUZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LKDGK44W.js → chunk-F4NREH3G.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OMXVBQ2N.js → chunk-FDBRXV25.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3FTILRJ2.js → chunk-GU3TSEHD.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HS7OVAUN.js +164 -0
- package/dist/cli-bundle/chunks/{chunk-OTHLDSFP.js → chunk-JFZIS6JF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7A5OT5J2.js → chunk-JQ4NZ5EB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BXQLRKWF.js → chunk-L6LGKJX3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CSI3WS5I.js → chunk-M357ZCOR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5ZBOIPGP.js → chunk-M4VEE3FK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7C4PTJG6.js → chunk-MCS73BKB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-A62CYISG.js → chunk-MDTH7SAE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HNFD72UK.js → chunk-OXY3SJ3N.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-L3AZOELJ.js → chunk-PECV7L5T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DXDREUXT.js → chunk-Q3VOP62W.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UP7DTVMD.js → chunk-QJ7C3JIW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-42E7YPLG.js → chunk-R6LSRGPS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MHK6LIWE.js → chunk-R6RKEYYW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UN66FZRO.js → chunk-RAFUN7IX.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-RUAU5OSH.js +2 -0
- package/dist/cli-bundle/chunks/chunk-SD3YXU2U.js +56 -0
- package/dist/cli-bundle/chunks/{chunk-SSF4PIUR.js → chunk-SV3YQ4RY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V3EUXXOF.js → chunk-SVV3DQES.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-45G53IU4.js → chunk-SXECIECW.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-T45OHXDW.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-PMXJEU3F.js → chunk-TPKDJ5WL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-M72BKL5Q.js → chunk-UVVXHGYS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WRL4KNDL.js → chunk-V663653R.js} +19 -19
- package/dist/cli-bundle/chunks/{chunk-R546TPDE.js → chunk-WSI5KZQJ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6MSQJOTG.js → chunk-XPOQQJTX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XCEZYMNI.js → chunk-YCCDXBNU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LN2WFEU4.js → chunk-ZFBWCKYF.js} +2 -2
- package/dist/cli-bundle/chunks/close-DI66JMSB.js +2 -0
- package/dist/cli-bundle/chunks/close-many-VFKT6U3O.js +2 -0
- package/dist/cli-bundle/chunks/comments-E73HIEZJ.js +2 -0
- package/dist/cli-bundle/chunks/copy-WBYVLCPC.js +2 -0
- package/dist/cli-bundle/chunks/{create-XLKTXTUF.js → create-TG67IVFI.js} +2 -2
- package/dist/cli-bundle/chunks/delete-6XKUVVQN.js +2 -0
- package/dist/cli-bundle/chunks/{deps-ITTY3GIC.js → deps-AJUGP2OH.js} +2 -2
- package/dist/cli-bundle/chunks/{docs-W4OSRTYR.js → docs-QOCLDRKJ.js} +2 -2
- package/dist/cli-bundle/chunks/{files-EOK4AZI4.js → files-3ST5TY64.js} +2 -2
- package/dist/cli-bundle/chunks/focus-R2AWS63Y.js +2 -0
- package/dist/cli-bundle/chunks/{history-compact-7UGTMLL3.js → history-compact-7BJFML4S.js} +2 -2
- package/dist/cli-bundle/chunks/{history-redact-4DZRMD6Z.js → history-redact-WJN3HYXR.js} +2 -2
- package/dist/cli-bundle/chunks/{history-repair-UPOSZW5R.js → history-repair-XDNZUB7F.js} +2 -2
- package/dist/cli-bundle/chunks/{learnings-GMRNCBS3.js → learnings-SZMUPVNA.js} +2 -2
- package/dist/cli-bundle/chunks/{profile-2MUUMHRE.js → profile-KL53JIAC.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-LR3SQ5ZF.js → register-list-query-QH7ONPKU.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-SUOHFVWM.js → register-mutation-OCRQNZK4.js} +3 -3
- package/dist/cli-bundle/chunks/{register-operations-ARRRKOVN.js → register-operations-HIBJXRGB.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-QWBQ6HBS.js +2 -0
- package/dist/cli-bundle/chunks/restore-FXA5QPM7.js +2 -0
- package/dist/cli-bundle/chunks/{schema-FJ4EA3XF.js → schema-QJ27OTRV.js} +2 -2
- package/dist/cli-bundle/chunks/update-7GBO4SXG.js +2 -0
- package/dist/cli-bundle/chunks/update-many-VF6ZKQUO.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-B7LJWAZE.js → chunk-27DK4A5O.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SV3O7TSH.js → chunk-4JC3AOGS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-G6ETT4QK.js → chunk-6KDHXURF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PG2RIZBX.js → chunk-74CWP3A4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-Y4LDYLLT.js → chunk-7AZDTGPA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7YTZ7A4E.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-A7BJ5SS6.js → chunk-CL3NB7VW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EAXXF2HW.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UIL2M2NA.js → chunk-EYO4F74Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7J5TUBUJ.js → chunk-GEYU23YS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WEM2E2PE.js → chunk-GIERI4YU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WVIVUWVL.js → chunk-GSW2Y7VZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VLYOEYML.js → chunk-LKQXXO62.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MJ7HWSFK.js → chunk-MBBMTDD3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PIMMYG7Q.js → chunk-ME4XVOBJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IPWSFADF.js → chunk-N7QN3NE6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-W7BJEWHX.js → chunk-QL5H3AQH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-TQMFQYXR.js +29 -0
- package/dist/cli-bundle/focused-chunks/{chunk-RUR5I3TK.js → chunk-XNVXIQ4B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FGKY4MBE.js → chunk-YHDCGUIW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-QVHKCI4T.js → chunk-YLPZHWX7.js} +2 -2
- package/dist/cli-bundle/main.js +13 -13
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +25 -25
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +1 -1
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +1 -1
- package/dist/core/extensions/activation-summary.d.ts +4 -0
- package/dist/core/extensions/activation-summary.js +5 -2
- package/dist/core/extensions/contribution-inventory.d.ts +1 -0
- package/dist/core/extensions/contribution-inventory.js +35 -2
- package/dist/core/extensions/extension-hook-runtime.js +5 -3
- package/dist/core/extensions/extension-types.d.ts +18 -1
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/loader.js +5 -13
- package/dist/core/extensions/preflight-ownership.d.ts +5 -0
- package/dist/core/extensions/preflight-ownership.js +42 -0
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +8 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +4 -3
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +3 -3
- package/dist/sdk/compose.d.ts +2 -2
- package/dist/sdk/compose.js +7 -2
- package/dist/sdk/define.d.ts +3 -1
- package/dist/sdk/define.js +3 -8
- package/dist/sdk/extension/install-sources.d.ts +43 -5
- package/dist/sdk/extension/install-sources.js +36 -2
- package/dist/sdk/extension/migrations.d.ts +114 -0
- package/dist/sdk/extension/migrations.js +175 -0
- package/dist/sdk/extension/scaffold.js +14 -9
- package/dist/sdk/extension/source-resolution.d.ts +50 -0
- package/dist/sdk/extension/source-resolution.js +66 -0
- package/dist/sdk/extension.d.ts +5 -1
- package/dist/sdk/extension.js +24 -26
- package/dist/sdk/governance/health.js +11 -2
- package/dist/sdk/index.d.ts +6 -2
- package/dist/sdk/index.js +8 -4
- package/dist/sdk/package-migrations.d.ts +10 -0
- package/dist/sdk/package-migrations.js +21 -0
- package/dist/sdk/runtime.d.ts +2 -0
- package/dist/sdk/runtime.js +6 -2
- package/docs/COMMANDS.md +9 -0
- package/docs/EXTENSIONS.md +2 -2
- package/docs/EXTENSION_LIFECYCLE.md +46 -0
- package/docs/README.md +1 -0
- package/docs/RELEASING.md +33 -20
- package/docs/SDK.md +31 -3
- package/marketplace.json +2 -2
- package/package.json +3 -3
- 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 +218 -20
- package/dist/cli-bundle/chunks/append-VXXGOXSG.js +0 -2
- package/dist/cli-bundle/chunks/chunk-EGJ4JTUG.js +0 -55
- package/dist/cli-bundle/chunks/chunk-FPBQHMFT.js +0 -8
- package/dist/cli-bundle/chunks/chunk-GE4KCSZP.js +0 -164
- package/dist/cli-bundle/chunks/chunk-YEWNL576.js +0 -2
- package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +0 -2
- package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +0 -2
- package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +0 -2
- package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +0 -2
- package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +0 -2
- package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-O6AYP6NP.js +0 -2
- package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +0 -2
- package/dist/cli-bundle/chunks/update-YHV52CSS.js +0 -2
- package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-BIMTMOS7.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-GJ2TG2CW.js +0 -28
- package/dist/cli-bundle/focused-chunks/chunk-N5XU5UVK.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{F as it,G as lt,H as ot,I as ct,J as Y,K as F,L as ut,M as ft,N as pt,O as yt,a as qe,b as He,c as Xe,d as Ze,e as Je,f as Qe,g as xe,h as K,i as et,j as R,k as tt,l as at,m as nt,n as rt,o as st,p as dt}from"./chunk-
|
|
1
|
+
import{F as it,G as lt,H as ot,I as ct,J as Y,K as F,L as ut,M as ft,N as pt,O as yt,a as qe,b as He,c as Xe,d as Ze,e as Je,f as Qe,g as xe,h as K,i as et,j as R,k as tt,l as at,m as nt,n as rt,o as st,p as dt}from"./chunk-BP6EMEDP.js";import{d as z,e as W}from"./chunk-PECV7L5T.js";import{c as Ye}from"./chunk-TPKDJ5WL.js";import{j as Se,l as Ee,m as Te,n as Le,p as Pe}from"./chunk-MDTH7SAE.js";import{b as Ge,c as Be,d as Ve}from"./chunk-RSIC5OPE.js";import{a as ke,b as Ie,c as Ue,d as De,e as Fe,f as G,g as Oe,h as B,i as Me,j as Ce,k as Ne}from"./chunk-R6LSRGPS.js";import{k as $e}from"./chunk-UVVXHGYS.js";import{A as o,Aa as _,Af as je,C as c,Cb as U,Da as ce,Ea as I,Ec as ge,Fa as ue,Fc as he,Ga as fe,Gc as we,Ha as $,La as pe,Lc as _e,Lf as b,Mf as V,Nc as ve,Oa as ye,Of as ze,Pc as Ae,Rf as j,Sf as We,V as N,Vc as be,ad as g,b as de,cd as Ke,ga as L,ia as ie,ja as le,lc as me,uf as D,ya as P,za as oe,zd as Re}from"./chunk-HS7OVAUN.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]="ada579bd-134d-5201-9221-6ce39d282a37")}catch{}})();var Q=[...it,{canonical:"close-reason",aliases:["close_reason","close-reason"],optionKey:"closeReason",metadataKey:"close_reason"},...lt,...ot],zt=(()=>{let e=new Map;for(let t of Q)for(let r of t.aliases)e.set(r,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),O=new Map(Q.map(e=>[e.optionKey,e.canonical])),Wt=Q.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", "),Yt=new Set(["close_reason","assignee","parent","blocked_by","blocked_reason","unblock_note","dependencies","comments","notes","learnings","files","tests","docs","reminders","events"]),qt=Je({depDisableFlagKey:"replaceDeps",fileDisableFlagKey:"replaceFiles",testDisableFlagKey:"replaceTests",docDisableFlagKey:"replaceDocs"});function At(e){let t={...e,unset:e.unset?[...e.unset]:void 0},r=a=>{let n=t.unset?[...t.unset]:[];n.includes(a)||n.push(a),t.unset=n},s=new Set([...O.keys(),"rank"]);for(let a of s){let n=t[a];if(typeof n!="string"||!Qe(n))continue;let i=a==="rank"?"order":O.get(a)??a;r(i),t[a]=void 0}return et(t,qt)}function x(e,t,r=[]){return ct({raw:e,supportedFields:Wt,resolveDefinition:s=>{let a=r.find(i=>{let l=i.toLowerCase();return l===s||l.replaceAll("_","-")===s||l.replaceAll("-","_")===s});return zt.get(s)??Y(s,"update",t)??(a?{optionKey:"field",metadataKey:a}:void 0)}})}var mt=new Map([["--comment",e=>`pm comments ${e} --add "<text>" --force`],["--file",e=>`pm files ${e} --add "path=<path>,scope=<scope>,note=<note>" --force`],["--doc",e=>`pm docs ${e} --add "path=<path>,scope=<scope>,note=<note>" --force`]]);function X(e){let t=e.disallowedFlags.flatMap(s=>{let a=mt.get(s);return a?[a(e.id)]:[]}),r=e.disallowedFlags.flatMap(s=>{let a=mt.get(s);return a?[`Replace ${s} with: ${a(e.id)}`]:[]});return new c(e.message,o.USAGE,{code:e.code,required:e.required,why:e.why,...t.length>0?{examples:t}:{},nextSteps:[`Re-run without: ${e.disallowedFlags.join(", ")}`,...r]})}function bt(e,t,r){let s=t.ownershipMetadataBypass===!0,a=t.ownershipDependencyBypass===!0;if(!s&&!a)return;if(s&&a)throw new c("Choose only one package-provided ownership bypass mode.",o.USAGE);let n=(d,u,p)=>{d&&p.push(u)};if(a){let d=[];if(n(t.title!==void 0,"--title",d),n(t.description!==void 0,"--description",d),n(t.body!==void 0,"--body",d),n(t.status!==void 0,"--status",d),n(t.closeReason!==void 0,"--close-reason",d),n(t.priority!==void 0,"--priority",d),n(t.type!==void 0,"--type",d),n(t.tags!==void 0,"--tags",d),n(Array.isArray(t.addTags)&&t.addTags.length>0,"--add-tags",d),n(Array.isArray(t.removeTags)&&t.removeTags.length>0,"--remove-tags",d),n(t.deadline!==void 0,"--deadline",d),n(t.estimatedMinutes!==void 0,"--estimate",d),n(t.acceptanceCriteria!==void 0,"--acceptance-criteria",d),n(Array.isArray(t.addAc)&&t.addAc.length>0,"--add-ac",d),n(Array.isArray(t.removeAc)&&t.removeAc.length>0,"--remove-ac",d),n(t.definitionOfReady!==void 0,"--definition-of-ready",d),n(t.order!==void 0||t.rank!==void 0,"--order/--rank",d),n(t.goal!==void 0,"--goal",d),n(t.objective!==void 0,"--objective",d),n(t.value!==void 0,"--value",d),n(t.impact!==void 0,"--impact",d),n(t.outcome!==void 0,"--outcome",d),n(t.whyNow!==void 0,"--why-now",d),n(t.assignee!==void 0,"--assignee",d),n(t.parent!==void 0,"--parent",d),n(t.reviewer!==void 0,"--reviewer",d),n(t.risk!==void 0,"--risk",d),n(t.confidence!==void 0,"--confidence",d),n(t.sprint!==void 0,"--sprint",d),n(t.release!==void 0,"--release",d),n(t.blockedBy!==void 0,"--blocked-by",d),n(t.blockedReason!==void 0,"--blocked-reason",d),n(t.unblockNote!==void 0,"--unblock-note",d),n(t.reporter!==void 0,"--reporter",d),n(t.severity!==void 0,"--severity",d),n(t.environment!==void 0,"--environment",d),n(t.reproSteps!==void 0,"--repro-steps",d),n(t.resolution!==void 0,"--resolution",d),n(t.expectedResult!==void 0,"--expected-result",d),n(t.actualResult!==void 0,"--actual-result",d),n(t.affectedVersion!==void 0,"--affected-version",d),n(t.fixedVersion!==void 0,"--fixed-version",d),n(t.component!==void 0,"--component",d),n(t.regression!==void 0,"--regression",d),n(t.customerImpact!==void 0,"--customer-impact",d),n(t.depRemove!==void 0,"--dep-remove",d),n(t.replaceDeps===!0,"--replace-deps",d),n(t.replaceTests===!0,"--replace-tests",d),n(t.replaceFiles===!0,"--replace-files",d),n(t.replaceDocs===!0,"--replace-docs",d),n(t.comment!==void 0,"--comment",d),n(t.note!==void 0,"--note",d),n(t.learning!==void 0,"--learning",d),n(t.file!==void 0,"--file",d),n(t.test!==void 0,"--test",d),n(t.doc!==void 0,"--doc",d),n(t.reminder!==void 0,"--reminder",d),n(t.event!==void 0,"--event",d),n(t.typeOption!==void 0,"--type-option",d),n(t.clearDeps===!0,"--clear-deps",d),n(t.clearComments===!0,"--clear-comments",d),n(t.clearNotes===!0,"--clear-notes",d),n(t.clearLearnings===!0,"--clear-learnings",d),n(t.clearFiles===!0,"--clear-files",d),n(t.clearTests===!0,"--clear-tests",d),n(t.clearDocs===!0,"--clear-docs",d),n(t.clearReminders===!0,"--clear-reminders",d),n(t.clearEvents===!0,"--clear-events",d),n(t.clearTypeOptions===!0,"--clear-type-options",d),n(t.force===!0,"--force",d),n(r.size>0,"--unset",d),t.dep===void 0||t.dep.length===0)throw new c("The dependency ownership bypass requires at least one --dep value",o.USAGE);if(d.length>0)throw X({id:e,code:"ownership_dependency_bypass_restricted_options",message:`The dependency ownership bypass supports append-only dependency additions via --dep. Remove restricted options: ${d.join(", ")}`,required:"Pass only --dep additions (plus --message/--author) with the dependency ownership bypass.",why:"the dependency ownership bypass is a narrow non-owner override scoped to append-only dependency additions; every other mutation keeps its normal ownership rules.",disallowedFlags:d});return}let i=[];n(t.status!==void 0,"--status",i),n(t.closeReason!==void 0,"--close-reason",i),n(t.assignee!==void 0,"--assignee",i),n(t.parent!==void 0,"--parent",i),n(t.blockedBy!==void 0,"--blocked-by",i),n(t.blockedReason!==void 0,"--blocked-reason",i),n(t.unblockNote!==void 0,"--unblock-note",i),n(t.dep!==void 0,"--dep",i),n(t.depRemove!==void 0,"--dep-remove",i),n(t.replaceDeps===!0,"--replace-deps",i),n(t.replaceTests===!0,"--replace-tests",i),n(t.replaceFiles===!0,"--replace-files",i),n(t.replaceDocs===!0,"--replace-docs",i),n(t.note!==void 0,"--note",i),n(t.learning!==void 0,"--learning",i),n(t.test!==void 0,"--test",i),n(t.reminder!==void 0,"--reminder",i),n(t.event!==void 0,"--event",i),n(t.clearDeps===!0,"--clear-deps",i),n(t.clearComments===!0,"--clear-comments",i),n(t.clearNotes===!0,"--clear-notes",i),n(t.clearLearnings===!0,"--clear-learnings",i),n(t.clearFiles===!0,"--clear-files",i),n(t.clearTests===!0,"--clear-tests",i),n(t.clearDocs===!0,"--clear-docs",i),n(t.clearReminders===!0,"--clear-reminders",i),n(t.clearEvents===!0,"--clear-events",i);let l=[...r].filter(d=>Yt.has(d)).sort((d,u)=>d.localeCompare(u)).map(d=>`--unset ${d.replaceAll("_","-")}`);if(i.push(...l),i.length>0)throw X({id:e,code:"ownership_metadata_bypass_restricted_options",message:`The metadata ownership bypass only supports non-lifecycle metadata fields and evidence appends. Remove restricted options: ${i.join(", ")}`,required:"Limit the metadata ownership bypass to non-lifecycle metadata fields plus append-only --comment/--file/--doc evidence; route restricted appends and lifecycle changes through their dedicated commands.",why:"the metadata ownership bypass is a non-owner override scoped to metadata maintenance and append-only evidence; lifecycle, ownership, dependency mutations, restricted append fields, and clear/replace operations keep their normal ownership rules.",disallowedFlags:i})}function Ht(e,t){let r=g(e,t);if(!r){let s=t.definitions.map(a=>a.id);throw new c(`Invalid --status value "${e}". Allowed: ${s.join(", ")}`,o.USAGE)}return r}function Kt(e){if(e.enforcement==="off"||e.typeWorkflows.length===0)return;let t=Be({typeName:e.typeName,fromStatus:e.fromStatus,toStatus:e.toStatus,typeWorkflows:e.typeWorkflows,statusRegistry:e.statusRegistry});if(!t.hasRule||t.allowed)return;let r=g(e.fromStatus,e.statusRegistry)??e.fromStatus,s=g(e.toStatus,e.statusRegistry)??e.toStatus,a=`Disallowed transition for type "${e.typeName}": ${r} -> ${s}. Allowed transitions: ${Ve(t.allowedTransitions)}.`;if(e.enforcement==="strict")throw new c(a,o.USAGE);return`workflow_transition_not_allowed: ${a}`}function Xt(e,t){if(!e||e.trim()===""||e.trim().toLowerCase()==="now")return t;let r=Date.parse(e);if(!Number.isFinite(r))throw new c(`Invalid dependency created_at timestamp "${e}"`,o.USAGE);return new Date(r).toISOString()}function M(e){if(e===void 0)return;let t=e.trim();return t.length>0?t:void 0}var Zt=["id","kind","type","author","created_at","source_kind"],Jt=["id","kind","type","source_kind"];function Qt(e){return e.startsWith("```")||e.includes(`
|
|
2
2
|
`)||/^(?:[-*+]\s+)?(?:id|kind|type|author|created_at|source_kind)\s*[:=]/i.test(e)?!0:Oe(e)}var xt={"blocked-by":"blocked_by",depends_on:"blocked_by","depends-on":"blocked_by"};function Rt(e){if(typeof e!="string")return e;let t=e.trim();return xt[t.toLowerCase()]??t}function St(e,t,r,s){return e?(K(e,"--dep","Use --clear-deps to clear dependencies."),{additions:e.map(n=>{let i=n.trim(),l=Qt(i);rt(i,l);let d=l?G(n,"--dep"):{id:i,kind:"related"};l&&B(d,"--dep",Zt);let u=d.id?.trim(),p=Rt((d.kind??d.type)?.trim());if(!u||!p)throw new c("--dep requires id and kind, or a bare item id to add a related dependency",o.USAGE);if(u.toLowerCase()==="undefined")throw new c(`--dep id must not use placeholder token "${u}". Use --clear-deps to clear dependencies.`,o.USAGE);let f=z(M(d.source_kind)),S=M(d.author);return{id:W(u,t,f),kind:R(p,L,"dependency kind"),created_at:Xt(d.created_at,r),author:S??s,source_kind:f??"cli:update:dep",author_source:S?"asserted":"detected"}})}):{additions:[]}}function Et(e,t){return e?(K(e,"--dep-remove"),e.map(r=>{let s=r.trim();if(!s)throw new c("--dep-remove requires id or key/value selectors",o.USAGE);if(s.includes("=")||/^(?:[-*+]\s+)?(?:id|kind|type|source_kind)\s*[:=]/i.test(s)||s.startsWith("```")){let a=G(s,"--dep-remove");B(a,"--dep-remove",Jt);let n=a.id?.trim();if(!n)throw new c("--dep-remove key/value form requires id=<value>",o.USAGE);if(n.toLowerCase()==="undefined")throw new c(`--dep-remove id must not use placeholder token "${n}"`,o.USAGE);let i=Rt(M(a.kind??a.type)),l=z(M(a.source_kind));return{id:W(n,t,l),kind:i?R(i,L,"dependency kind"):void 0,source_kind:l}}if(s.toLowerCase()==="undefined")throw new c(`--dep-remove id must not use placeholder token "${s}"`,o.USAGE);return{id:D(s,t)}})):[]}function gt(e){let t=e.source_kind?.trim().toLowerCase()??"";return`${e.id.trim().toLowerCase()}::${e.kind}::${t}`}function Tt(e,t,r,s){let a=[...e??[]],n=!1;if(t===void 0){let i=a.filter(l=>l.kind!=="blocked_by");return i.length!==a.length&&(a=i,n=!0),n?{dependencies:a.length>0?a:void 0,changed:!0}:{dependencies:e,changed:!1}}return a.some(i=>i.kind==="blocked_by"&&i.id===t)||(a.push({id:t,kind:"blocked_by",created_at:r,author:s,source_kind:"cli:update:blocked_by",author_source:"detected"}),n=!0),n?{dependencies:a.length>0?a:void 0,changed:!0}:{dependencies:e,changed:!1}}async function ea(e,t,r,s,a,n){if(e===void 0||t)return{};let i=e.trim();if(i.length===0)return{};let l=await b(r,D(i,s),s,a,n);return l?{id:l.id}:{unresolved:i}}function ta(e,t,r,s,a){let n=Tt(e.dependencies,t,r,s);n.changed&&(n.dependencies===void 0?delete e.dependencies:e.dependencies=n.dependencies,a.includes("dependencies")||a.push("dependencies"))}function aa(e){return`${e.path}::${e.scope}`}function na(e){return`${e.path}::${e.scope}`}function ra(e){return`${e.command}::${e.path??""}::${e.scope}::${e.pm_context_mode??""}`}function kt(e,t){return!(e.id.trim().toLowerCase()!==t.id.trim().toLowerCase()||t.kind&&e.kind!==t.kind||t.source_kind!==void 0&&e.source_kind?.trim().toLowerCase()!==t.source_kind.trim().toLowerCase())}function sa(e){return Le(e)}function Z(e,t){let r=oe("update",e);if(!r)throw new c(`Unsupported command_option_policies option "${e}" for update command on type "${t}"`,o.CONFLICT);return r}function It(e,t,r){let s=new Set,a=(n,i)=>{i&&s.add(n)};if(a("title",e.title!==void 0),a("description",e.description!==void 0),a("body",e.body!==void 0),a("status",e.status!==void 0),a("closeReason",e.closeReason!==void 0),a("priority",e.priority!==void 0),a("type",e.type!==void 0),a("tags",e.tags!==void 0||Array.isArray(e.addTags)&&e.addTags.length>0||Array.isArray(e.removeTags)&&e.removeTags.length>0),a("deadline",e.deadline!==void 0),a("estimatedMinutes",e.estimatedMinutes!==void 0),a("acceptanceCriteria",e.acceptanceCriteria!==void 0||Array.isArray(e.addAc)&&e.addAc.length>0||Array.isArray(e.removeAc)&&e.removeAc.length>0),a("definitionOfReady",e.definitionOfReady!==void 0),a("order",e.order!==void 0||e.rank!==void 0),a("goal",e.goal!==void 0),a("objective",e.objective!==void 0),a("value",e.value!==void 0),a("impact",e.impact!==void 0),a("outcome",e.outcome!==void 0),a("whyNow",e.whyNow!==void 0),a("author",e.author!==void 0),a("message",e.message!==void 0),a("assignee",e.assignee!==void 0),a("parent",e.parent!==void 0),a("reviewer",e.reviewer!==void 0),a("risk",e.risk!==void 0),a("confidence",e.confidence!==void 0),a("sprint",e.sprint!==void 0),a("release",e.release!==void 0),a("blockedBy",e.blockedBy!==void 0),a("blockedReason",e.blockedReason!==void 0),a("unblockNote",e.unblockNote!==void 0),a("reporter",e.reporter!==void 0),a("severity",e.severity!==void 0),a("environment",e.environment!==void 0),a("reproSteps",e.reproSteps!==void 0),a("resolution",e.resolution!==void 0),a("expectedResult",e.expectedResult!==void 0),a("actualResult",e.actualResult!==void 0),a("affectedVersion",e.affectedVersion!==void 0),a("fixedVersion",e.fixedVersion!==void 0),a("component",e.component!==void 0),a("regression",e.regression!==void 0),a("customerImpact",e.customerImpact!==void 0),a("dep",e.dep!==void 0),a("depRemove",e.depRemove!==void 0),a("dep",e.replaceDeps===!0),a("comment",e.comment!==void 0),a("note",e.note!==void 0),a("learning",e.learning!==void 0),a("file",e.file!==void 0),a("test",e.test!==void 0),a("test",e.replaceTests===!0),a("file",e.replaceFiles===!0),a("doc",e.replaceDocs===!0),a("doc",e.doc!==void 0),a("reminder",e.reminder!==void 0),a("event",e.event!==void 0),a("typeOption",e.typeOption!==void 0),a("field",e.field!==void 0),a("force",e.force===!0),a("ownershipMetadataBypass",e.ownershipMetadataBypass===!0),a("ownershipDependencyBypass",e.ownershipDependencyBypass===!0),a("dep",e.clearDeps===!0),a("comment",e.clearComments===!0),a("note",e.clearNotes===!0),a("learning",e.clearLearnings===!0),a("file",e.clearFiles===!0),a("test",e.clearTests===!0),a("doc",e.clearDocs===!0),a("reminder",e.clearReminders===!0),a("event",e.clearEvents===!0),a("typeOption",e.clearTypeOptions===!0),e.unset&&e.unset.length>0){let n=x(e.unset,t,r);for(let i of n.optionKeys)a(i,!0)}return s}function da(e,t,r,s,a){let n=ue(e,r);if(!n)throw new c(`Invalid type value "${e}"`,o.USAGE);let i=fe(n,"update",[]);if(i.errors.length>0)throw new c(i.errors.join("; "),o.CONFLICT);let l=It(t,s,a);for(let d of i.disabled)if(l.has(Z(d,e)))throw new c(`Option ${_("update",d)} is disabled for type "${e}" by command_option_policies`,o.USAGE);for(let d of i.required)if(!l.has(Z(d,e)))throw new c(`Missing required option ${_("update",d)} for type "${e}"`,o.USAGE)}var ia=new Set(["order","rank"]),la=P.filter(e=>!ia.has(e)),Ut=["tags","closeReason",...la],oa=["title","description","body","status","closeReason","completedAt","priority","type",...P,"dep","depRemove","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],ca=[{optionKey:"deadline",metadataKey:"deadline",transform:(e,t)=>N(e,t.nowValue,"deadline")},{optionKey:"estimatedMinutes",metadataKey:"estimated_minutes",transform:e=>Ne(e,"estimated-minutes")},{optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria",transform:e=>e},{optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{optionKey:"goal",metadataKey:"goal"},{optionKey:"objective",metadataKey:"objective"},{optionKey:"value",metadataKey:"value"},{optionKey:"impact",metadataKey:"impact"},{optionKey:"outcome",metadataKey:"outcome"},{optionKey:"whyNow",metadataKey:"why_now"}],ua=[{optionKey:"reviewer",metadataKey:"reviewer"},{optionKey:"risk",metadataKey:"risk",transform:e=>R(qe(e),ie,"risk")},{optionKey:"confidence",metadataKey:"confidence",transform:e=>Xe(e)}],fa=[{optionKey:"blockedReason",metadataKey:"blocked_reason"},{optionKey:"unblockNote",metadataKey:"unblock_note"},{optionKey:"reporter",metadataKey:"reporter"},{optionKey:"severity",metadataKey:"severity",transform:e=>R(He(e),le,"severity")},{optionKey:"environment",metadataKey:"environment"},{optionKey:"reproSteps",metadataKey:"repro_steps"},{optionKey:"resolution",metadataKey:"resolution"},{optionKey:"expectedResult",metadataKey:"expected_result"},{optionKey:"actualResult",metadataKey:"actual_result"},{optionKey:"affectedVersion",metadataKey:"affected_version"},{optionKey:"fixedVersion",metadataKey:"fixed_version"},{optionKey:"component",metadataKey:"component"},{optionKey:"regression",metadataKey:"regression",transform:e=>Ze(e)},{optionKey:"customerImpact",metadataKey:"customer_impact"}];function J(e,t,r){for(let s of e){let a=t[s.optionKey],n=r.clearItemMetadataKeys.has(s.metadataKey);if(!(a===void 0&&!n)){if(n){delete r.metadataRecord[s.metadataKey],r.changedFields.push(s.metadataKey);continue}if(typeof a!="string")throw new c(`${_("update",String(s.optionKey))} must be a string value`,o.USAGE);r.metadataRecord[s.metadataKey]=s.transform?s.transform(a,r):a.trim(),r.changedFields.push(s.metadataKey)}}}async function pa(e){let t=Me();return At({...e,body:await t.resolveValue(e.body,"--body"),dep:await t.resolveList(e.dep,"--dep"),depRemove:await t.resolveList(e.depRemove,"--dep-remove"),comment:await t.resolveList(e.comment,"--comment"),note:await t.resolveList(e.note,"--note"),learning:await t.resolveList(e.learning,"--learning"),file:await t.resolveList(e.file,"--file"),test:await t.resolveList(e.test,"--test"),doc:await t.resolveList(e.doc,"--doc"),reminder:await t.resolveList(e.reminder,"--reminder"),event:await t.resolveList(e.event,"--event"),typeOption:await t.resolveList(e.typeOption,"--type-option"),field:await t.resolveList(e.field,"--field")})}function ya(e){return[{enabled:e.clearDeps||e.replaceDeps,optionKey:"dep",clearFlag:"--clear-deps",valueFlag:"--dep",values:e.dep,metadataKey:"dependencies"},{enabled:e.clearComments,optionKey:"comment",clearFlag:"--clear-comments",valueFlag:"--comment",values:e.comment,metadataKey:"comments"},{enabled:e.clearNotes,optionKey:"note",clearFlag:"--clear-notes",valueFlag:"--note",values:e.note,metadataKey:"notes"},{enabled:e.clearLearnings,optionKey:"learning",clearFlag:"--clear-learnings",valueFlag:"--learning",values:e.learning,metadataKey:"learnings"},{enabled:e.clearFiles||e.replaceFiles,optionKey:"file",clearFlag:"--clear-files",valueFlag:"--file",values:e.file,metadataKey:"files"},{enabled:e.clearTests||e.replaceTests,optionKey:"test",clearFlag:"--clear-tests",valueFlag:"--test",values:e.test,metadataKey:"tests"},{enabled:e.clearDocs||e.replaceDocs,optionKey:"doc",clearFlag:"--clear-docs",valueFlag:"--doc",values:e.doc,metadataKey:"docs"},{enabled:e.clearReminders,optionKey:"reminder",clearFlag:"--clear-reminders",valueFlag:"--reminder",values:e.reminder,metadataKey:"reminders"},{enabled:e.clearEvents,optionKey:"event",clearFlag:"--clear-events",valueFlag:"--event",values:e.event,metadataKey:"events"},{enabled:e.clearTypeOptions,optionKey:"typeOption",clearFlag:"--clear-type-options",valueFlag:"--type-option",values:e.typeOption,metadataKey:"type_options"}]}function q(e){if(e.enabled&&(!e.values||e.values.length===0))throw new c(`${e.replaceFlag} requires at least one ${e.valueFlag} entry`,o.USAGE);if(e.enabled&&e.clearEnabled)throw new c(`${e.replaceFlag} cannot be combined with ${e.clearFlag}`,o.USAGE)}function ma(e){if(e.replaceDeps===!0&&(e.dep===void 0||e.dep.length===0))throw new c("--replace-deps requires at least one --dep entry",o.USAGE);if(e.replaceDeps===!0&&e.depRemove!==void 0&&e.depRemove.length>0)throw new c("--replace-deps cannot be combined with --dep-remove",o.USAGE);q({enabled:e.replaceTests===!0,values:e.test,replaceFlag:"--replace-tests",clearEnabled:e.clearTests===!0,clearFlag:"--clear-tests",valueFlag:"--test"}),q({enabled:e.replaceFiles===!0,values:e.file,replaceFlag:"--replace-files",clearEnabled:e.clearFiles===!0,clearFlag:"--clear-files",valueFlag:"--file"}),q({enabled:e.replaceDocs===!0,values:e.doc,replaceFlag:"--replace-docs",clearEnabled:e.clearDocs===!0,clearFlag:"--clear-docs",valueFlag:"--doc"})}function ga(e){for(let t of e.definitions){if(!t.enabled)continue;let r=t.optionKey==="dep"&&e.options.replaceDeps===!0||t.optionKey==="test"&&e.options.replaceTests===!0||t.optionKey==="file"&&e.options.replaceFiles===!0||t.optionKey==="doc"&&e.options.replaceDocs===!0;if(t.values&&t.values.length>0&&!r)throw new c(`Cannot combine ${t.clearFlag} with ${t.valueFlag}`,o.USAGE);e.clearOptionKeys.add(t.optionKey),e.clearItemMetadataKeys.add(t.metadataKey)}}function ha(e){let t={};for(let r of Ut)t[String(r)]=e[r]!==void 0;return t.order=e.order!==void 0||e.rank!==void 0,t}function wa(e,t){let r=ha(e);for(let[s,a]of Object.entries(r)){if(!a||!t.optionKeys.has(s))continue;let n=O.get(s)??s;throw new c(`Cannot combine --unset ${n} with ${_("update",s)}`,o.USAGE)}if(t.metadataKeys.has("acceptance_criteria")){if(Array.isArray(e.addAc)&&e.addAc.length>0)throw new c("Cannot combine --unset acceptance-criteria with --add-ac",o.USAGE);if(Array.isArray(e.removeAc)&&e.removeAc.length>0)throw new c("Cannot combine --unset acceptance-criteria with --remove-ac",o.USAGE)}if(t.metadataKeys.has("tags")){if(Array.isArray(e.addTags)&&e.addTags.length>0)throw new c("Cannot combine --unset tags with --add-tags",o.USAGE);if(Array.isArray(e.removeTags)&&e.removeTags.length>0)throw new c("Cannot combine --unset tags with --remove-tags",o.USAGE)}}function _a(e){let t=(r,s)=>{let a=O.get(s),n=a?`Use --unset ${a} to clear this field.`:void 0;xe(r,_("update",s),n)};for(let r of Ut)t(e[r],String(r));t(e.order??e.rank,"order"),K(e.reminder,"--reminder","Use --clear-reminders to clear reminders."),K(e.event,"--event","Use --clear-events to clear linked events.")}function va(e,t){let r={};for(let s of oa)r[String(s)]=e[s]!==void 0;return r.tags=e.tags!==void 0,r.addTags=Array.isArray(e.addTags)&&e.addTags.length>0,r.removeTags=Array.isArray(e.removeTags)&&e.removeTags.length>0,r.addAc=Array.isArray(e.addAc)&&e.addAc.length>0,r.removeAc=Array.isArray(e.removeAc)&&e.removeAc.length>0,r.order=e.order!==void 0,r.rank=e.rank!==void 0,r.replaceDeps=e.replaceDeps===!0,r.replaceTests=e.replaceTests===!0,r.replaceFiles=e.replaceFiles===!0,r.replaceDocs=e.replaceDocs===!0,r.unset=e.unset!==void 0&&e.unset.length>0,r.clearDeps=e.clearDeps===!0,r.clearComments=e.clearComments===!0,r.clearNotes=e.clearNotes===!0,r.clearLearnings=e.clearLearnings===!0,r.clearFiles=e.clearFiles===!0,r.clearTests=e.clearTests===!0,r.clearDocs=e.clearDocs===!0,r.clearReminders=e.clearReminders===!0,r.clearEvents=e.clearEvents===!0,r.clearTypeOptions=e.clearTypeOptions===!0,r.runtimeFields=Object.keys(t).length>0,r}async function Aa(e){let t=await b(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,e.typeRegistry.type_to_folder);if(!t)throw await j(e.pmRoot,e.id,e.settings.id_prefix,e.typeRegistry.type_to_folder);let{document:r}=await V(t,{schema:e.settings.schema});return{item:r.metadata,changed_fields:[],warnings:["noop_no_update_fields"]}}async function ba(e){if(!await de(ye(e)))throw new c(`Tracker is not initialized at ${e}. Run pm init first.`,o.NOT_FOUND)}function Ka(e){if(e.order!==void 0&&e.rank!==void 0&&e.order!==e.rank)throw new c("--order and --rank must match when both are provided",o.USAGE)}async function Ra(e){if(e.options.parent===void 0||e.unsetTargets.metadataKeys.has("parent"))return{resolvedParentValue:void 0,warnings:[]};let t=Se(e.options.parent);if(Te(e.id,t,e.settings.id_prefix),await b(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,e.typeRegistry.type_to_folder))return{resolvedParentValue:t,warnings:[]};let s=D(t,e.settings.id_prefix);return{resolvedParentValue:t,warnings:Ee(s,e.parentReferencePolicy).warnings}}function Sa(e){return e.unresolved===void 0?[]:[`blocked_by_unresolved:${e.unresolved}`]}async function Ea(e){if(e.workflowEnforcement==="off"||e.typeWorkflows.length===0||!e.fieldFlags.status||e.options.status===void 0)return[];let t=await b(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,e.typeRegistry.type_to_folder);if(!t)throw await j(e.pmRoot,e.id,e.settings.id_prefix,e.typeRegistry.type_to_folder);let{document:r}=await V(t,{schema:e.settings.schema}),s=e.options.type!==void 0?I(e.options.type,e.typeRegistry)??e.options.type:r.metadata?.type??"",a=Kt({enforcement:e.workflowEnforcement,typeWorkflows:e.typeWorkflows,statusRegistry:e.statusRegistry,typeName:s,fromStatus:r.metadata?.status??"",toStatus:e.options.status});return a?[a]:[]}async function Ta(e){if(!e.fieldFlags.status||g(e.options.status,e.statusRegistry)!==e.statusRegistry.close_status)return;let r=Object.entries(e.fieldFlags).filter(([l,d])=>d&&l!=="status"&&l!=="closeReason"&&l!=="completedAt").map(([l])=>l),s=[],a=[];if(r.length>0){let l=await Ha(e.id,{...e.options,status:void 0,closeReason:void 0,message:void 0},e.global);a=l.changed_fields,s.push(...l.warnings)}let n=await Ye(e.id,e.options.closeReason,{author:e.options.author,message:e.options.message,force:e.options.force,completedAt:e.options.completedAt},e.global),i=[...e.workflowTransitionWarnings,...s,...n.warnings,"auto_routed_from_update_to_close"];return{item:n.item,changed_fields:[...a,...n.changed_fields],warnings:i}}function ka(e,t,r,s){return t.title!==void 0&&(e.metadata.title=yt(t.title,"--title"),s.push("title")),t.description!==void 0&&(e.metadata.description=t.description,s.push("description")),t.body!==void 0&&(e.body=t.body,s.push("body")),g(e.metadata.status,r)??e.metadata.status}function Ia(e,t,r,s,a){let n=Ht(r,t.statusRegistry);if(e.metadata.status=n,a.push("status"),n===t.statusRegistry.close_status&&(e.metadata.closed_at===void 0||e.metadata.closed_at===null)){e.metadata.closed_at=t.nowIso,e.metadata.completed_at=t.nowIso,a.push("closed_at","completed_at");return}n!==t.statusRegistry.close_status&&s===t.statusRegistry.close_status&&e.metadata.closed_at!==void 0&&(delete e.metadata.closed_at,a.push("closed_at"),e.metadata.completed_at!==void 0&&(delete e.metadata.completed_at,a.push("completed_at")))}function Ua(e,t,r,s){if(t.options.status!==void 0&&Ia(e,t,t.options.status,r,s),t.options.completedAt!==void 0){if(!Ke(e.metadata.status,t.statusRegistry))throw new c("--completed-at can only be set on a terminal item",o.USAGE);e.metadata.completed_at=N(t.options.completedAt,new Date(t.nowIso),"completed-at"),s.push("completed_at")}}function Da(e,t,r,s){if(t.options.closeReason!==void 0||t.clearItemMetadataKeys.has("close_reason")){if(t.clearItemMetadataKeys.has("close_reason"))delete e.metadata.close_reason;else{let a=t.options.closeReason?.trim()??"";if(a.length===0)throw new c("--close-reason must not be empty",o.USAGE);e.metadata.close_reason=a}s.push("close_reason");return}t.options.status!==void 0&&r===t.statusRegistry.close_status&&e.metadata.status!==t.statusRegistry.canceled_status&&e.metadata.close_reason!==void 0&&(delete e.metadata.close_reason,s.push("close_reason"))}function Dt(e,t,r,s){Ua(e,t,r,s),Da(e,t,r,s)}function Fa(e,t,r){let s=I(e.metadata.type,t.typeRegistry)??e.metadata.type;if(t.options.priority!==void 0&&(e.metadata.priority=sa(t.options.priority),r.push("priority")),t.options.type!==void 0){let a=I(t.options.type,t.typeRegistry);if(!a)throw new c($e(t.options.type,t.typeRegistry.types,_e(t.pmRoot,t.settings.schema)),o.USAGE);e.metadata.type=a,s=a,r.push("type")}return da(s,t.options,t.typeRegistry,t.runtimeFieldRegistry,t.extensionFieldNames),Oa(e,t,s,r),s}function Oa(e,t,r,s){if(t.options.typeOption!==void 0||t.clearItemMetadataKeys.has("type_options")){if(t.clearItemMetadataKeys.has("type_options"))delete e.metadata.type_options;else{let n=nt(t.options.typeOption??[]),i=$(r,n,t.typeRegistry);if(i.errors.length>0)throw new c(i.errors.join("; "),o.USAGE);e.metadata.type_options=i.normalized}s.push("type_options");return}if(t.options.type===void 0||e.metadata.type_options===void 0)return;let a=$(r,e.metadata.type_options,t.typeRegistry);if(a.errors.length>0)throw new c(`Current type options are incompatible with type "${r}". ${a.errors.join("; ")}. Use --clear-type-options to clear them.`,o.USAGE);e.metadata.type_options=a.normalized}function Ma(e,t,r){if(t.options.dep===void 0&&t.options.depRemove===void 0&&!t.clearItemMetadataKeys.has("dependencies"))return;let s=t.clearItemMetadataKeys.has("dependencies")?[]:[...e.metadata.dependencies??[]];if(t.dependencyUpdates.additions.length>0){let a=new Set(s.map(n=>gt(n)));for(let n of t.dependencyUpdates.additions){let i=gt(n);a.has(i)||(s.push(n),a.add(i))}}t.dependencyRemovals.length>0&&(s=s.filter(a=>!t.dependencyRemovals.some(n=>kt(a,n)))),s.length===0?delete e.metadata.dependencies:e.metadata.dependencies=s,r.push("dependencies")}function Ca(e,t,r){H(e,"comments",t.options.comment,t.commentUpdates.values,t.clearItemMetadataKeys,r),H(e,"notes",t.options.note,t.noteUpdates.values,t.clearItemMetadataKeys,r),H(e,"learnings",t.options.learning,t.learningUpdates.values,t.clearItemMetadataKeys,r)}function H(e,t,r,s,a,n){r===void 0&&!a.has(t)||(a.has(t)||!s||s.length===0?delete e.metadata[t]:e.metadata[t]=[...e.metadata[t]??[],...s],n.push(t))}function Na(e,t,r){ht(e,"files",t.options.file,t.fileUpdates.values,aa,t.options.replaceFiles===!0,t.clearItemMetadataKeys,r),La(e,t,r),ht(e,"docs",t.options.doc,t.docUpdates.values,na,t.options.replaceDocs===!0,t.clearItemMetadataKeys,r)}function ht(e,t,r,s,a,n,i,l){if(!(r===void 0&&!i.has(t))){if(n)e.metadata[t]=s;else if(i.has(t)||!s||s.length===0)delete e.metadata[t];else{let d=[...e.metadata[t]??[]],u=new Set(d.map(p=>a(p)));for(let p of s){let f=a(p);u.has(f)||(d.push(p),u.add(f))}e.metadata[t]=d}l.push(t)}}function La(e,t,r){t.options.test===void 0&&!t.clearItemMetadataKeys.has("tests")||(t.clearItemMetadataKeys.has("tests")&&t.options.replaceTests===!0?e.metadata.tests=wt(t.testUpdates.values)??[]:t.clearItemMetadataKeys.has("tests")||!t.testUpdates.values||t.testUpdates.values.length===0?delete e.metadata.tests:e.metadata.tests=wt([...e.metadata.tests??[],...t.testUpdates.values]),e.metadata.tests!==void 0&&e.metadata.tests.length===0&&delete e.metadata.tests,r.push("tests"))}function wt(e){if(!e||e.length===0)return;let t=[],r=new Set;for(let s of e){let a=ra(s);r.has(a)||(t.push(s),r.add(a))}return t}function Pa(e,t,r){let s=t.options.addTags,a=t.options.removeTags,n=Array.isArray(s)&&s.length>0||Array.isArray(a)&&a.length>0;if(t.options.tags!==void 0||t.clearItemMetadataKeys.has("tags")||n){let i=t.clearItemMetadataKeys.has("tags")?[]:t.options.tags!==void 0?ke(t.options.tags):Array.isArray(e.metadata.tags)?[...e.metadata.tags]:[];e.metadata.tags=Fe(De(i,s),a),r.changedFields.push("tags")}J(ca,t.options,r),Ga(e,t,r.changedFields)}function $a(e,t,r,s){let a=t.options.addAc,n=t.options.removeAc;if(!(Array.isArray(a)&&a.length>0)&&!(Array.isArray(n)&&n.length>0))return;let i=Ue(Ie(e.metadata.acceptance_criteria),a,n);for(let d of i.unmatchedRemovals)s.push(`remove_ac_unmatched:${d}`);let l=i.criteria.join("; ");e.metadata.acceptance_criteria!==l&&(l===""&&e.metadata.acceptance_criteria===void 0||(e.metadata.acceptance_criteria=l,r.changedFields.includes("acceptance_criteria")||r.changedFields.push("acceptance_criteria")))}function Ga(e,t,r){let s=t.options.order??t.options.rank;if(!(s===void 0&&!t.clearItemMetadataKeys.has("order"))){if(t.clearItemMetadataKeys.has("order"))delete e.metadata.order;else{let a=Ce(s??"","order");if(!Number.isInteger(a))throw new c("Order must be an integer",o.USAGE);e.metadata.order=a}r.push("order")}}function Ba(e,t,r,s){Va(e,t,r.changedFields),ja(e,t,r.changedFields),J(ua,t.options,r),_t(e,t,"sprint",s,r.changedFields),_t(e,t,"release",s,r.changedFields),za(e,t,r.changedFields),J(fa,t.options,r)}function Va(e,t,r){if(!(t.options.assignee===void 0&&!t.clearItemMetadataKeys.has("assignee"))){if(t.clearItemMetadataKeys.has("assignee"))delete e.metadata.assignee;else{let s=t.options.assignee?.trim()??"";if(s==="")throw new c("--assignee must not be empty. Use --unset assignee to clear it.",o.USAGE);e.metadata.assignee=s}r.push("assignee")}}function ja(e,t,r){t.options.parent===void 0&&!t.clearItemMetadataKeys.has("parent")||(t.clearItemMetadataKeys.has("parent")?delete e.metadata.parent:e.metadata.parent=t.resolvedParentValue??"",r.push("parent"))}function _t(e,t,r,s,a){if(!(t.options[r]===void 0&&!t.clearItemMetadataKeys.has(r))){if(t.clearItemMetadataKeys.has(r))delete e.metadata[r];else{let n=Pe(r,t.options[r]??"",t.settings.validation.sprint_release_format);e.metadata[r]=n.value,s.push(...n.warnings)}a.push(r)}}function za(e,t,r){t.options.blockedBy===void 0&&!t.clearItemMetadataKeys.has("blocked_by")||(t.clearItemMetadataKeys.has("blocked_by")?delete e.metadata.blocked_by:e.metadata.blocked_by=t.options.blockedBy?.trim()??"",r.push("blocked_by"),(t.clearItemMetadataKeys.has("blocked_by")||t.resolvedBlockedByDependencyId!==void 0)&&ta(e.metadata,t.resolvedBlockedByDependencyId,t.nowIso,t.author,r))}function Wa(e,t,r){(t.options.reminder!==void 0||t.clearItemMetadataKeys.has("reminders"))&&(t.clearItemMetadataKeys.has("reminders")?delete e.metadata.reminders:e.metadata.reminders=tt(t.options.reminder??[],t.nowValue,{valueMode:"trimmed"}),r.push("reminders")),(t.options.event!==void 0||t.clearItemMetadataKeys.has("events"))&&(t.clearItemMetadataKeys.has("events")?delete e.metadata.events:e.metadata.events=at(t.options.event??[],t.nowValue,{allDayEmptyGuard:"truthy",recurrenceEmptyNumericGuard:"truthy"}),r.push("events"))}function Ya(e,t,r){vt(e,t.runtimeFieldRegistry.definitions.map(a=>a.metadata_key),t.clearItemMetadataKeys,r),vt(e,t.extensionFieldNames,t.clearItemMetadataKeys,r);for(let[a,n]of Object.entries(t.runtimeFieldUpdates)){if(t.clearItemMetadataKeys.has(a)){let i=a.replaceAll("_","-"),d=t.runtimeFieldRegistry.definitions.find(u=>u.metadata_key===a)?.cli_flag??i;throw new c(`Cannot combine --unset ${i} with --${d}`,o.USAGE)}U(e[a],n)||(e[a]=n,r.push(a))}let s=he(t.options.field,t.extensionRegistrations);for(let a of Object.keys(s))if(t.clearItemMetadataKeys.has(a))throw new c(`Cannot combine --unset ${a.replaceAll("_","-")} with --field ${a}=...`,o.USAGE);for(let[a,n]of Object.entries(s))U(e[a],n)||(e[a]=n,r.push(a))}function vt(e,t,r,s){for(let a of t)!r.has(a)||e[a]===void 0||(delete e[a],s.push(a))}function qa(e,t){let r=structuredClone(e.metadata),s=e.body,a=[],n=[],i=ka(e,t.options,t.statusRegistry,a),l=e.metadata,d={metadataRecord:l,clearItemMetadataKeys:t.clearItemMetadataKeys,changedFields:a,nowValue:t.nowValue};Dt(e,t,i,a),Fa(e,t,a),Ma(e,t,a),Ca(e,t,a),Na(e,t,a),Pa(e,t,d),$a(e,t,d,n),Ba(e,t,d,n),(t.options.dep!==void 0||t.options.depRemove!==void 0||t.options.blockedBy!==void 0||t.clearItemMetadataKeys.has("dependencies")||t.clearItemMetadataKeys.has("blocked_by"))&&st(e.metadata.id,e.metadata.dependencies),g(e.metadata.status,t.statusRegistry)===t.statusRegistry.canceled_status&&e.metadata.assignee!==void 0&&(delete e.metadata.assignee,a.includes("assignee")||a.push("assignee")),Wa(e,t,a),Ya(l,t,a);try{we(l,t.extensionRegistrations,{skipDefaultFields:t.clearItemMetadataKeys})}catch(f){throw new c(f instanceof Error?f.message:"Invalid extension item field values",o.USAGE)}let u=e.metadata;return{changedFields:[...new Set(a)].filter(f=>f==="body"?e.body!==s:!U(r[f],u[f])),warnings:n}}async function Ha(e,t,r){t=await pa(t);let s=pe(process.cwd(),r.path);await ba(s);let a=await je(s),n=ve(a.schema),i=Ae(a.schema),l=me(),d=ge(l),u=ce(a,l),p=a.governance.workflow_enforcement??"off",f=p==="off"?[]:Ge(a.schema),S=[{strict_error:"strict_error",warn:"warn",off:"off"},{strict_error:"warn",warn:"warn",off:"off"}][+(t.allowMissingParent===!0)][a.validation.parent_reference],E=x(t.unset,i,d),Ft=new Set(E.optionKeys),T=new Set(E.metadataKeys);ma(t),ga({definitions:ya(t),options:t,clearOptionKeys:Ft,clearItemMetadataKeys:T}),bt(e,t,T),wa(t,E),_a(t);let m=Re(t.author,a.author_default),ee=new Date,v=ee.toISOString(),Ot=St(t.dep,a.id_prefix,v,m),Mt=Et(t.depRemove,a.id_prefix),k=F("--comment",t.comment,v,m),Ct=t.ownershipMetadataBypass===!0&&k.values?{...k,values:k.values.map(y=>({...y,author:m}))}:k,Nt=F("--note",t.note,v,m),Lt=F("--learning",t.learning,v,m),Pt=ut(t.file),$t=ft(t.test),Gt=pt(t.doc),C=[],te=await Ra({id:e,options:t,unsetTargets:E,pmRoot:s,settings:a,typeRegistry:u,parentReferencePolicy:S}),ae=await ea(t.blockedBy,T.has("blocked_by"),s,a.id_prefix,a.item_format,u.type_to_folder),Bt=ae.id,Vt=[...te.warnings,...Sa(ae)],ne=be(t,i,t.runtimeFieldCommands),h=va(t,ne);if(!Object.values(h).some(Boolean))return Aa({pmRoot:s,id:e,settings:a,typeRegistry:u});C.push(...await Ea({options:t,fieldFlags:h,workflowEnforcement:p,typeWorkflows:f,statusRegistry:n,typeRegistry:u,pmRoot:s,id:e,settings:a}));let re=await Ta({options:t,fieldFlags:h,statusRegistry:n,workflowTransitionWarnings:C,global:r,id:e});if(re)return re;Ka(t);let A=h.dep||h.depRemove||h.blockedBy?await ze(s,a.item_format,u.type_to_folder,void 0,a.schema):void 0,w=await We({pmRoot:s,settings:a,typeToFolder:u.type_to_folder,id:e,op:t.ownershipMetadataBypass===!0||t.ownershipDependencyBypass===!0?"update_ownership_bypass":"update",author:m,message:t.message,force:t.force,bypassAssigneeConflict:t.ownershipMetadataBypass===!0||t.ownershipDependencyBypass===!0,extensionFieldNames:d,skipNoop:!0,mutate(y){return A=A?.map(se=>se.id===y.metadata.id?structuredClone(y.metadata):se),qa(y,{options:t,settings:a,typeRegistry:u,statusRegistry:n,runtimeFieldRegistry:i,extensionRegistrations:l,extensionFieldNames:d,clearItemMetadataKeys:T,dependencyUpdates:Ot,dependencyRemovals:Mt,commentUpdates:Ct,noteUpdates:Nt,learningUpdates:Lt,fileUpdates:Pt,testUpdates:$t,docUpdates:Gt,resolvedParentValue:te.resolvedParentValue,resolvedBlockedByDependencyId:Bt,runtimeFieldUpdates:ne,nowValue:ee,nowIso:v,author:m,pmRoot:s})}}),jt=A?dt(A,A.map(y=>y.id===w.item.id?w.item:y),w.item.id):[];return{item:w.item,changed_fields:w.changedFields,warnings:[...C,...Vt,...jt,...w.warnings]}}var cn={applyStatusAndCloseReasonMutations:Dt,collectProvidedUpdatePolicyOptions:It,buildOwnershipBypassRestrictedOptionsError:X,enforceOwnershipBypassScope:bt,enforceTypeWorkflowTransition:Kt,matchesDependencySelector:kt,normalizeLegacyNoneUpdateOptions:At,normalizeUpdatePolicyOptionKey:Z,parseDependencyAdditions:St,parseDependencyRemovals:Et,parseUpdateUnsetTargets:x,reconcileBlockedByDependency:Tt,resolveRuntimeUnsetDefinition:(e,t)=>Y(e,"update",t)};export{Ha as a,cn as b};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-AYRUGRNS.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as ln,e as Re}from"./chunk-
|
|
1
|
+
import{a as ln,e as Re}from"./chunk-DWOAOZHZ.js";import{k as dn}from"./chunk-NE5VRDAI.js";import{d as an,e as sn,f as cn,g as Z}from"./chunk-PECV7L5T.js";import{d as on}from"./chunk-5ZKQPA44.js";import{ga as rn,j as jt,k as Gt,l as Mt,m as Pt,n as Wt,p as Jt,s as Ht}from"./chunk-MDTH7SAE.js";import{a as xe}from"./chunk-A6KGKEWT.js";import{a as qt,d as Vt,f as x,g as zt,h as L,i as Bt,j as R,k as Yt}from"./chunk-R6LSRGPS.js";import{k as Xt}from"./chunk-UVVXHGYS.js";import{A as s,Aa as M,Af as Zt,C as c,Da as lt,Ea as V,Ec as St,Fa as ut,Fc as kt,Ga as ft,Gc as Tt,H as nt,Ha as mt,Hf as Qt,Jf as en,La as pt,Lc as xt,Lf as X,Nc as Rt,Oa as yt,Oc as At,Of as tn,Pa as _t,Pc as It,Qf as nn,R as rt,Ra as gt,Uc as Ct,Ue as Te,V as k,Ze as $t,_e as Nt,ad as ke,b as Ze,d as Qe,ed as Kt,f as et,ga as ot,ha as $,hd as Ut,ia as at,id as Lt,ja as it,ka as st,lb as ht,lc as J,mf as Ft,pa as ct,qa as dt,qc as wt,ra as be,rc as Et,uc as Se,uf as H,v as tt,vc as bt,vf as Ot,za as ve,zc as vt,zd as Dt}from"./chunk-HS7OVAUN.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]="4198a3b2-2541-50eb-bec5-93ac58601f40")}catch{}})();function un(e){return[...e].sort().join("\0")}function lo(e,t,n){let r=e.successors.get(t);r?r.push(n):e.successors.set(t,[n]);let o=e.predecessors.get(n);o?o.push(t):e.predecessors.set(n,[t])}function fn(e,t,n,r,o){let a=t.resolve(o);if(a?.ordering!==!0)return;let i=cn(r),d=i===void 0?void 0:e.canonicalIds.get(i.toLowerCase());if(d===void 0)return;let l=(a.precedence??"source_before_target")==="source_before_target";lo(e,l?n:d,l?d:n)}function uo(e,t){let n={successors:new Map,predecessors:new Map,canonicalIds:new Map},r=e.filter(o=>typeof o?.id=="string"&&o.id.trim().length>0);for(let o of r){let a=o.id.trim();n.canonicalIds.set(a.toLowerCase(),a)}for(let o of r){let a=o.id.trim();fn(n,t,a,o.blocked_by,"blocked_by");for(let i of o.dependencies??[])typeof i!="object"||i===null||fn(n,t,a,i.id,typeof i.kind=="string"?i.kind:"related")}for(let o of[n.successors,n.predecessors])for(let a of o.values())a.sort();return n}function fo(e,t){let n=new Set([t]),r=[t];for(;r.length>0;){let o=r.pop();for(let a of[e.successors,e.predecessors])for(let i of a.get(o)??[])n.has(i)||(n.add(i),r.push(i))}return n}function mo(e,t){let n=new Map;for(let r of t){let o=(e.successors.get(r)??[]).filter(a=>t.has(a));o.length>0&&n.set(r,o)}return n}function mn(e,t,n){let r=uo(e,t),o=r.canonicalIds.get(n.trim().toLowerCase());if(o===void 0)return{cycles:[],successors:new Map,canonical:n};let a=mo(r,fo(r,o));return{cycles:dn(a).filter(i=>i.includes(o)),successors:a,canonical:o}}function po(e,t,n){let r=new Set(t),o=r.has(n)?n:t[0];if(e.get(o)?.includes(o))return[o,o];for(let a of e.get(o)??[]){if(!r.has(a))continue;let i=yo(e,r,o,a);if(i)return i}return[...t,t[0]]}function yo(e,t,n,r){let o=[[r]],a=new Set([n,r]);for(;o.length>0;){let i=o.shift(),d=i.at(-1);for(let l of e.get(d)??[]){if(l===n)return[n,...i,n];!t.has(l)||a.has(l)||(a.add(l),o.push([...i,l]))}}}function pn(e,t,n){let r=Z(),o=mn(e,r,n),a=mn(t,r,n),i=new Set(o.cycles.map(un));return a.cycles.filter(d=>!i.has(un(d))).map(d=>`ordering_cycle_created:${po(a.successors,d,a.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)}(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]="2b20ab37-ffbe-5c65-ac0f-800abf876e16")}catch{}})();var N=["command","cmd","path","scope","timeout","timeout_seconds","pm_context_mode","env_set","env_clear","shared_host_safe","assert_stdout_contains","assert_stdout_regex","assert_stderr_contains","assert_stderr_regex","assert_stdout_min_lines","assert_json_field_equals","assert_json_field_gte","note"],_o=new Set(N),go=N.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),ho=new RegExp(`^(?:[-*+]\\s+)?(?:${go})\\s*[:=]`,"i");function yn(e){return e.startsWith("```")||e.includes(`
|
|
2
2
|
`)?!0:ho.test(e)}function _n(e,t){let n={},r=[];for(let[o,a]of Object.entries(e)){let i=o.toLowerCase();if(!_o.has(i)){r.push(o);continue}if(Object.hasOwn(n,i))throw new c(`${t} provides key "${o}" more than once after case normalization`,s.USAGE);n[i]=a}if(r.length>0)throw new c(`${t} does not recognize key${r.length>1?"s":""} ${r.map(o=>`"${o}"`).join(", ")}. Allowed keys: ${N.join(", ")}.`,s.USAGE);if(n.cmd!==void 0){if(n.command!==void 0&&n.command.trim()!==n.cmd.trim())throw new c(`${t} command and cmd must match when both are provided`,s.USAGE);let{cmd:o,...a}=n;return{...a,command:a.command??o}}return 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]="f592ba2b-fc8d-5930-a2a5-d02835c457a3")}catch{}})();var ne=new Set(["PM_PATH","PM_GLOBAL_PATH","PM_SOURCE_PM_PATH","PM_SOURCE_WORKSPACE_ROOT","FORCE_COLOR"]),re=/^[A-Za-z_][A-Za-z0-9_]*$/,Q=["schema","tracker","auto"];function hn(e,t){if(!e)return;let n=e.split(/[;\n]/).map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw new c(`${t} env_set must include at least one KEY=VALUE assignment`,s.USAGE);let r=Object.create(null);for(let o of n){let a=o.indexOf("=");if(a<=0)throw new c(`${t} env_set entries must use KEY=VALUE and be separated by semicolons. Example: env_set=PORT=0;PLAYWRIGHT_BASE_URL=http://127.0.0.1:4173`,s.USAGE);let i=o.slice(0,a).trim(),d=o.slice(a+1);if(!re.test(i))throw new c(`${t} env_set key "${i}" is invalid`,s.USAGE);if(ne.has(i.toUpperCase()))throw new c(`${t} env_set key "${i}" is reserved for sandbox safety`,s.USAGE);r[i]=d}return Object.keys(r).length>0?r:void 0}function wn(e,t){if(!e)return;let n=xe(e,{separators:/[;,\n]/});if(n.length===0)throw new c(`${t} env_clear must include at least one environment variable name`,s.USAGE);for(let r of n){if(!re.test(r))throw new c(`${t} env_clear key "${r}" is invalid`,s.USAGE);if(ne.has(r.toUpperCase()))throw new c(`${t} env_clear key "${r}" is reserved for sandbox safety`,s.USAGE)}return n}function En(e,t,n){if(!e)return;let r=e.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1;throw new c(`${t} ${n} must be one of true|false|1|0|yes|no`,s.USAGE)}function bn(e,t){if(!e)return;let n=e.trim().toLowerCase();if(Q.includes(n))return n;throw new c(`${t} pm_context_mode must be one of: ${Q.join(", ")}`,s.USAGE)}function oe(e){if(!e)return;let t=xe(e,{separators:/[;\n]/});return t.length>0?t:void 0}function Ae(e,t,n){let r=oe(e);if(!(!r||r.length===0)){for(let o of r)try{new RegExp(o,"m")}catch(a){throw new c(`${t} ${n} includes invalid regex "${o}": ${a instanceof Error?a.message:String(a)}`,s.USAGE)}return r}}function vn(e,t){if(!e)return;let n=R(e,"assert_stdout_min_lines");if(!Number.isInteger(n)||n<0)throw new c(`${t} assert_stdout_min_lines must be an integer >= 0`,s.USAGE);return n}function Sn(e,t){if(!e)return;let n=e.split(/[;\n]/).map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw new c(`${t} assert_json_field_equals must include at least one path=value assignment`,s.USAGE);let r=Object.create(null);for(let o of n){let a=o.indexOf("=");if(a<=0)throw new c(`${t} assert_json_field_equals entries must use path=value and be separated by semicolons`,s.USAGE);let i=o.slice(0,a).trim(),d=o.slice(a+1).trim();if(i.length===0||d.length===0)throw new c(`${t} assert_json_field_equals entries must include non-empty path and value`,s.USAGE);r[i]=d}return Object.keys(r).length>0?r:void 0}function kn(e,t){if(!e)return;let n=e.split(/[;\n]/).map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw new c(`${t} assert_json_field_gte must include at least one path=value assignment`,s.USAGE);let r=Object.create(null);for(let o of n){let a=o.indexOf("=");if(a<=0)throw new c(`${t} assert_json_field_gte entries must use path=value and be separated by semicolons`,s.USAGE);let i=o.slice(0,a).trim(),d=o.slice(a+1).trim();if(i.length===0||d.length===0)throw new c(`${t} assert_json_field_gte entries must include non-empty path and value`,s.USAGE);let l=Number(d);if(!Number.isFinite(l))throw new c(`${t} assert_json_field_gte value for "${i}" must be numeric`,s.USAGE);r[i]=l}return Object.keys(r).length>0?r:void 0}var wo=new Set(N);function ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Eo(e,t){let n={},r=[];for(let[o,a]of Object.entries(e)){let i=o.toLowerCase();if(!wo.has(i)){r.push(o);continue}if(Object.hasOwn(n,i))throw t(`provides key "${o}" more than once after case normalization`);n[i]=a}if(r.length>0)throw t(`does not recognize key${r.length>1?"s":""} ${r.map(o=>`"${o}"`).join(", ")}. Allowed keys: ${N.join(", ")}.`);return n}function P(e,t,n){if(!Object.hasOwn(e,t))return;let r=e[t];if(r!==void 0){if(typeof r!="string")throw n(`field "${t}" must be a JSON string`);return r}}function ee(e,t,n){if(!Object.hasOwn(e,t))return;let r=e[t];if(r===void 0)return;let o=typeof r=="string"?[r]:r;if(!Array.isArray(o)||o.some(i=>typeof i!="string"))throw n(`field "${t}" must be a string or an array of strings`);let a=o.filter(i=>i.length>0);return a.length>0?a:void 0}function gn(e,t,n){let r=ee(e,t,n);if(r){for(let o of r)try{new RegExp(o,"m")}catch(a){throw n(`field "${t}" includes invalid regex "${o}": ${a instanceof Error?a.message:String(a)}`)}return r}}function te(e,t,n){let r=typeof e=="number"?e:typeof e=="string"&&e.trim().length>0?Number(e.trim()):Number.NaN;if(typeof e=="boolean"||!Number.isFinite(r))throw n(`field "${t}" must be a finite number (or numeric string)`);return r}function bo(e,t){let n=e.timeout_seconds,r=e.timeout;if(n===void 0&&r===void 0)return;let o=n===void 0?void 0:te(n,"timeout_seconds",t),a=r===void 0?void 0:te(r,"timeout",t);if(o!==void 0&&a!==void 0&&o!==a)throw t("timeout and timeout_seconds must match when both are provided");let i=o??a;if(!Number.isInteger(i)||i<=0)throw t("timeout_seconds must be a positive integer");return i}function vo(e,t){let n=P(e,"scope",t);if(n===void 0)return"project";if(!$.includes(n))throw t(`field "scope" must be one of: ${$.join(", ")}`);return n}function So(e,t){if(!Object.hasOwn(e,"env_set"))return;let n=e.env_set;if(n===void 0)return;if(!ae(n))throw t('field "env_set" must be a JSON object mapping environment names to string values');let r=Object.create(null);for(let[o,a]of Object.entries(n)){if(typeof a!="string")throw t(`field "env_set" value for "${o}" must be a string`);if(!re.test(o))throw t(`field "env_set" key "${o}" is invalid`);if(ne.has(o.toUpperCase()))throw t(`field "env_set" key "${o}" is reserved for sandbox safety`);r[o]=a}return Object.keys(r).length>0?r:void 0}function ko(e,t){let n=ee(e,"env_clear",t);if(n){for(let r of n){if(!re.test(r))throw t(`field "env_clear" key "${r}" is invalid`);if(ne.has(r.toUpperCase()))throw t(`field "env_clear" key "${r}" is reserved for sandbox safety`)}return n}}function To(e,t,n){if(!Object.hasOwn(e,t))return;let r=e[t];if(r!==void 0){if(typeof r!="boolean")throw n(`field "${t}" must be a JSON boolean (true or false)`);return r}}function xo(e,t){if(!Object.hasOwn(e,"assert_stdout_min_lines"))return;let n=e.assert_stdout_min_lines;if(n===void 0)return;let r=te(n,"assert_stdout_min_lines",t);if(!Number.isInteger(r)||r<0)throw t('field "assert_stdout_min_lines" must be an integer >= 0');return r}function Ro(e,t){if(!Object.hasOwn(e,"assert_json_field_equals"))return;let n=e.assert_json_field_equals;if(n===void 0)return;if(!ae(n))throw t('field "assert_json_field_equals" must be a JSON object mapping field paths to expected values');let r=Object.create(null);for(let[o,a]of Object.entries(n)){if(o.trim().length===0)throw t('field "assert_json_field_equals" keys must be non-empty field paths');if(typeof a!="string"&&typeof a!="number"&&typeof a!="boolean")throw t(`field "assert_json_field_equals" value for "${o}" must be a string, number, or boolean`);r[o]=String(a)}return Object.keys(r).length>0?r:void 0}function Ao(e,t){if(!Object.hasOwn(e,"assert_json_field_gte"))return;let n=e.assert_json_field_gte;if(n===void 0)return;if(!ae(n))throw t('field "assert_json_field_gte" must be a JSON object mapping field paths to numeric minimums');let r=Object.create(null);for(let[o,a]of Object.entries(n)){if(o.trim().length===0)throw t('field "assert_json_field_gte" keys must be non-empty field paths');r[o]=te(a,`assert_json_field_gte.${o}`,t)}return Object.keys(r).length>0?r:void 0}function Io(e,t,n){let r=p=>new c(`${n} ${t} ${p}`,s.USAGE);if(!ae(e))throw r(`must be a JSON object with linked-test fields. Allowed keys: ${N.join(", ")}.`);let o=Eo(e,r),a=P(o,"command",r),i=P(o,"cmd",r);if(a!==void 0&&i!==void 0&&a!==i)throw r("command and cmd must match when both are provided");let d=a??i;if(d===void 0||d.trim().length===0)throw r('requires a non-empty "command" string');let l=P(o,"path",r),u=P(o,"pm_context_mode",r);if(u!==void 0&&!Q.includes(u))throw r(`field "pm_context_mode" must be one of: ${Q.join(", ")}`);let f=P(o,"note",r);return{command:d,path:l!==void 0&&l.length>0?l:void 0,scope:vo(o,r),timeout_seconds:bo(o,r),pm_context_mode:u,env_set:So(o,r),env_clear:ko(o,r),shared_host_safe:To(o,"shared_host_safe",r),assert_stdout_contains:ee(o,"assert_stdout_contains",r),assert_stdout_regex:gn(o,"assert_stdout_regex",r),assert_stderr_contains:ee(o,"assert_stderr_contains",r),assert_stderr_regex:gn(o,"assert_stderr_regex",r),assert_stdout_min_lines:xo(o,r),assert_json_field_equals:Ro(o,r),assert_json_field_gte:Ao(o,r),note:f!==void 0&&f.trim().length>0?f.trim():void 0}}function ei(e,t){let n=e.trim();if(n.length===0)throw new c(`${t} requires a JSON object or array of objects describing linked-test entries`,s.USAGE);let r;try{r=JSON.parse(n)}catch(a){throw new c(`${t} value is not valid JSON: ${a instanceof Error?a.message:String(a)}. Provide a JSON object or array of objects, e.g. '{"command":"node scripts/check.js --flag value, with commas","timeout_seconds":120}'.`,s.USAGE)}let o=Array.isArray(r)?r:[r];if(o.length===0)throw new c(`${t} array must include at least one linked-test entry object`,s.USAGE);return o.map((a,i)=>Io(a,o.length>1?`entry ${i+1}`:"entry",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]="dcbb6070-7457-5454-abf1-fa8153c8efd6")}catch{}})();function Tn(e){let t=e.trim();return t.toLowerCase()==="med"?"medium":t}function xn(e){let t=e.trim();return t.toLowerCase()==="med"?"medium":t}function Rn(e){let t=e.trim().toLowerCase();if(t==="med")return"medium";if(st.includes(t))return t;let n=R(e,"confidence");if(!Number.isInteger(n)||n<0||n>100)throw new c("Confidence must be an integer 0..100 or one of low|med|medium|high",s.USAGE);return n}function An(e){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1;throw new c("Regression must be one of true|false|1|0",s.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]="afc4f3d5-ba5e-5dd7-abc9-531b319cdb4e")}catch{}})();var Co=new Set(["none","null"]);function In(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function C(e){return e===void 0?!1:Co.has(e.trim().toLowerCase())}function Cn(e,t,n){if(!C(e))return;let r=n?` ${n}`:"";throw new c(`${t} no longer accepts "none" or "null".${r}`.trim(),s.USAGE)}function K(e,t,n){if(!e||e.length===0||!e.some(a=>C(a)))return;let o=n?` ${n}`:"";throw new c(`${t} no longer accepts "none" or "null".${o}`.trim(),s.USAGE)}function Kn(e,t){for(let n of t){let r=e[n.optionKey];if(!Array.isArray(r)||r.length===0)continue;if(!r.every(d=>typeof d=="string"))throw new c(`${n.valueFlag} entries must be strings.`,s.USAGE);let o=r;if(!o.some(d=>C(d)))continue;if(o.filter(d=>!C(d)).length>0)throw new c(`Cannot mix legacy clear token "none"/"null" with concrete ${n.valueFlag} entries. Use ${n.clearFlag} to clear or provide explicit entries.`,s.USAGE);e[n.optionKey]=void 0,e[n.clearFlagKey]=!0,n.disableFlagKey&&(e[n.disableFlagKey]=!1)}return 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]="e009d7f9-8d50-519a-9a43-632efd3bf443")}catch{}})();var Ko=new Set(["event","meeting","reminder","milestone","decision","adr"]);function Un(e,t,n,r){if(Ko.has(t.trim().toLowerCase())||n!==r.open_status)return;let o=At("in_progress",r);if(!(o===void 0||o===r.open_status))return{command:`pm start-task ${e}`,to_status:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0062e981-158a-5e6a-b028-6c7cef0f59ba")}catch{}})();var Uo=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],Lo=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],Ln=[...Uo,...Lo],Dn=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}];function $n(e){let t=new Set,n=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:n};for(let r of e.raw){let o=r.trim().toLowerCase();if(!o)throw new c("--unset values must not be empty",s.USAGE);if(C(o))throw new c('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',s.USAGE);let a=e.resolveDefinition(o);if(!a)throw new c(`Unsupported --unset field "${r}". Supported fields: ${e.supportedFields}`,s.USAGE);t.add(a.metadataKey),n.add(a.optionKey)}return{metadataKeys:t,optionKeys:n}}function Ie(e,t,n){let r=e.trim().toLowerCase();if(!n)return;let o=n.command_to_fields?.get(t)??[];for(let a of o){if(a.allow_unset===!1)continue;let i=new Set;if(typeof a.key=="string"&&a.key.length>0&&i.add(a.key.toLowerCase()),typeof a.metadata_key=="string"&&a.metadata_key.length>0&&i.add(a.metadata_key.toLowerCase()),typeof a.cli_flag=="string"&&a.cli_flag.length>0&&(i.add(a.cli_flag.replaceAll("-","_").toLowerCase()),i.add(a.cli_flag.toLowerCase())),Array.isArray(a.cli_aliases))for(let d of a.cli_aliases)typeof d!="string"||d.length===0||(i.add(d.replaceAll("-","_").toLowerCase()),i.add(d.toLowerCase()));if(i.has(r))return{optionKey:a.key,metadataKey:a.metadata_key}}}(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]="2fcfbe50-039b-5031-8b18-a208908a0d87")}catch{}})();function Fn(e,t){let n=e.trim().toLowerCase();if(n==="true"||n==="1"||n==="yes")return!0;if(n==="false"||n==="0"||n==="no")return!1;throw new c(`${t} must be one of true|false|1|0|yes|no`,s.USAGE)}function Ce(e){return e?e.split("|").map(t=>t.trim()).filter(t=>t.length>0):[]}function U(e,t,n){if(!t.includes(e))throw new c(`Invalid ${n} value "${e}". Allowed: ${t.join(", ")}`,s.USAGE);return e}var On=["recur_freq","recur_interval","recur_count","recur_until","recur_by_weekday","recur_by_month_day","recur_exdates"];function Do(e,t){return t==="defined"?e!==void 0:!!e}function Nn(e,t,n){if(!Do(e,n))return;let r=R(e,`event ${t}`);if(!Number.isInteger(r)||r<1)throw new c(`--event ${t} must be an integer >= 1`,s.USAGE);return r}function $o(e,t,n){let r=e?k(e,n,"event.recur_until"):void 0;if(r&&r<t)throw new c("--event recur_until must be at or after start",s.USAGE);return r}function No(e){return Array.from(new Set(Ce(e).map(t=>U(t.toLowerCase(),dt,"event weekday")))).sort((t,n)=>be(t)-be(n))}function Fo(e){return Array.from(new Set(Ce(e).map(t=>{let n=R(t,"event recur_by_month_day");if(!Number.isInteger(n)||n<1||n>31)throw new c("--event recur_by_month_day values must be integers 1..31",s.USAGE);return n}))).sort((t,n)=>t-n)}function Oo(e,t){return Array.from(new Set(Ce(e).map(n=>k(n,t,"event.recur_exdates")))).sort((n,r)=>n.localeCompare(r))}function jn(e,t,n,r){let o=e.recur_freq?.trim(),a=e.recur_interval?.trim(),i=e.recur_count?.trim(),d=e.recur_until?.trim(),l=e.recur_by_weekday?.trim(),u=e.recur_by_month_day?.trim(),f=e.recur_exdates?.trim();if(![o,a,i,d,l,u,f].some(T=>T!==void 0))return;if(!o)throw new c("--event recurrence fields require recur_freq=<daily|weekly|monthly|yearly>",s.USAGE);let y=U(o.toLowerCase(),ct,"event recurrence frequency"),h=Nn(a,"recur_interval",r),E=Nn(i,"recur_count",r),b=$o(d,t,n),_=No(l),S=Fo(u),A=Oo(f,n);return{freq:y,interval:h,count:E,until:b,by_weekday:_.length>0?_:void 0,by_month_day:S.length>0?S:void 0,exdates:A.length>0?A:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1c1314f1-b54f-562c-b6f0-950fcac4c9cc")}catch{}})();function Gn(e,t){if(!t&&/[:,=]/.test(e))throw new c(`Invalid --dep value "${e}". Use a bare item id or id=<id>,kind=<kind>.`,s.USAGE)}function Mn(e,t,n=Z()){for(let r of t??[])try{ht(e,r.id,r.kind,n)}catch(o){throw new c(nt(o),s.USAGE,{code:"dependency_edge_not_allowed",why:`${e} -> ${r.id} (${r.kind}) violates the active relationship-kind policy`})}}(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]="8248687e-ba97-5e1b-afbf-a322a72eb1aa")}catch{}})();var Pn="--event end must be strictly after start. Equal start/end timestamps are treated as an instant event (end is dropped); an end earlier than start is rejected. Omit end for an instant event or set end later than start.",jo="--event end and duration are mutually exclusive; provide only one (use duration=<relative> like duration=2h, duration=30min, or duration=PT30M, or set an explicit end).",Go=/^([+-]?)(\d+)(min|mins|minute|minutes)$/i,Mo=/^([+-]?)[Pp][Tt](?:(\d+)[Hh])?(?:(\d+)[Mm])?(?:(\d+)[Ss])?$/,Vn=1e3,Ke=60*Vn,Po=60*Ke;function qn(e,t){let n=new Date(e);if(!Number.isFinite(n.getTime()))throw new c(`Invalid event.duration value "${t}". Duration is out of supported timestamp range.`,s.USAGE);return n.toISOString()}function qo(e,t){let n=new Date(e),r=t.trim(),o=Go.exec(r);if(o){let d=o[1]==="-"?-1:1,l=Number.parseInt(o[2],10)*d;return qn(n.getTime()+l*Ke,r)}let a=Mo.exec(r);if(a){let[,d,l,u,f]=a;if(l||u||f){let y=d==="-"?-1:1,h=Number.parseInt(l??"0",10),E=Number.parseInt(u??"0",10),b=Number.parseInt(f??"0",10),_=h*Po+E*Ke+b*Vn;return qn(n.getTime()+y*_,r)}}let i=r.startsWith("+")||r.startsWith("-")?r:`+${r}`;return k(i,n,"event.duration")}function zn(e,t,n,r){if(t&&n)throw new c(jo,s.USAGE);if(n){let a=qo(e,n);if(a<e)throw new c(Pn,s.USAGE);return a===e?void 0:a}if(!t)return;let o=k(t,r,"event.end");if(o<e)throw new c(Pn,s.USAGE);if(o!==e)return o}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fd41d2bf-7be0-55ee-9048-a9d5092a9a21")}catch{}})();var Vo=["at","date","text","title"],zo=["start","date","end","duration","title","description","location","timezone","all_day",...On],Bo=["key","value"];function Bn(e,t){return t==="trimmed"?e?.trim():e}function Yo(e,t){return t==="defined"?e!==void 0:!!e}function Yn(e,t,n){return e.map(r=>{let o=x(r,"--reminder");L(o,"--reminder",Vo);let a=Bn(o.at??o.date,n.valueMode),i=Bn(o.text??o.title,n.valueMode);if(!a||!i)throw new c("--reminder requires at=<iso|relative> or date=<iso|relative>, plus text=<value> or title=<value>",s.USAGE);let d=i.trim();if(!d)throw new c("--reminder text must not be empty",s.USAGE);return{at:k(a,t,"reminder.at"),text:d}})}function Wn(e,t,n){return e.map(r=>{let o=x(r,"--event");L(o,"--event",zo);let a=(o.start??o.date)?.trim();if(!a)throw new c("--event requires start=<iso|relative> or date=<iso|relative>",s.USAGE);let i=k(a,t,"event.start"),d=o.end?.trim(),l=o.duration?.trim(),u=zn(i,d,l,t),f=o.title,p=o.description,y=o.location,h=o.timezone,E=f?.trim(),b=p?.trim(),_=y?.trim(),S=h?.trim(),A=[["title",f,E],["description",p,b],["location",y,_],["timezone",h,S]];for(let[O,D,de]of A)if(D!==void 0&&!de)throw new c(`--event ${O} must not be empty`,s.USAGE);let T=o.all_day?.trim(),z=jn(o,i,t,n.recurrenceEmptyNumericGuard),q=Yo(T,n.allDayEmptyGuard)?Fn(T,"--event all_day"):void 0;return{start_at:i,end_at:u,title:E,description:b,location:_,all_day:q,timezone:S,recurrence:z}})}function Jn(e){let t={};for(let n of e){let r=n.trim();if(r.length===0)throw new c("--type-option values must not be empty",s.USAGE);let o,a;if(r.includes(",")||r.includes(`
|
|
3
3
|
`)||r.startsWith("```")||/^(?:[-*+]\s+)?(?:key|value)\s*[:=]/i.test(r)){let d=x(r,"--type-option");L(d,"--type-option",Bo),o=d.key?.trim(),a=d.value?.trim()}else{let d=r.indexOf("="),l=r.indexOf(":"),u=d;if(d<=0&&l>0&&(u=l),u<=0||u===r.length-1)throw new c("--type-option requires key=value or key=<name>,value=<value> entries",s.USAGE);o=r.slice(0,u).trim(),a=r.slice(u+1).trim()}if(!o||!a)throw new c("--type-option requires key and value",s.USAGE);t[o]=a}return Object.fromEntries(Object.entries(t).sort((n,r)=>n[0].localeCompare(r[0])))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="93dc76a3-f205-5a44-85bd-5a6fad80c8d4")}catch{}})();var Wo=["strict","progressive"],Jo=["lightweight"],Zn=new Set(["Reminder","Meeting","Event"]),Ho=new Set(["author","created_at","text"]),$e=[...Ln,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...Dn],Xo=(()=>{let e=new Map;for(let t of $e)for(let n of t.aliases)e.set(n,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),ie=new Map($e.map(e=>[e.optionKey,e.canonical])),Zo=$e.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function Qo(e,t){let n=[...t].sort((o,a)=>o.localeCompare(a)),r=n.length===1?"key":"keys";return`${e} supports only author, created_at, and text seed fields. Found unsupported ${r}: ${n.join(", ")}. If text contains comma-separated key:value-like fragments, wrap text in quotes (for example text="first,scope:project"), use markdown-style key/value input, or pass ${e} - with piped stdin.`}function ea(e,t){let n=ke(e,t);if(!n){let r=t.definitions.map(o=>o.id);throw new c(`Invalid status value "${e}". Allowed: ${r.join(", ")}`,s.USAGE)}return n}function ta(e,t){let n=e.default_status;if(n!==void 0){let r=ke(n,t);if(r)return r}return t.open_status}function Le(e,t){if(!e||e.trim()===""||e.trim().toLowerCase()==="now")return t;let n=Date.parse(e);if(!Number.isFinite(n))throw new c(`Invalid created_at timestamp "${e}"`,s.USAGE);return new Date(n).toISOString()}var na=In();function Qn(e){let t={...e,unset:e.unset?[...e.unset]:void 0},n=o=>{let a=t.unset?[...t.unset]:[];a.includes(o)||a.push(o),t.unset=a};C(t.template)&&(t.template=void 0);let r=new Set([...ie.keys(),"rank"]);for(let o of r){let a=t[o];if(typeof a!="string"||!C(a))continue;let i=o==="rank"?"order":ie.get(o)??o;n(i),t[o]=void 0}return Kn(t,na)}function v(e){if(e!==void 0)return e}function er(e,t){return $n({raw:e,supportedFields:Zo,resolveDefinition:n=>Xo.get(n)??Ie(n,"create",t)})}var Hn=["id","kind","type","author","created_at","source_kind"],se=["path","scope","note"];function tr(e,t,n,r){return!e||e.length===0?{values:void 0,explicitEmpty:!1}:(K(e,"--dep","Use --clear-deps to clear dependencies."),{values:e.map(a=>{let i=a.trim(),d=ce(i,Hn);Gn(i,d);let l=d?x(a,"--dep"):{id:i,kind:"related"};d&&L(l,"--dep",Hn);let u=v(l.id),f=nr(v(l.kind??l.type));if(!u||!f)throw new c("--dep requires id and kind, or a bare item id to create a related dependency",s.USAGE);if(u.trim().toLowerCase()==="undefined")throw new c(`--dep id must not use placeholder token "${u}". Use --clear-deps to clear dependencies.`,s.USAGE);let p=an(v(l.source_kind)),y=v(l.author);return{id:sn(u,n,p),kind:U(f,ot,"dependency kind"),created_at:Le(l.created_at,t),author:y??r,source_kind:p??"cli:create:dep",author_source:y?"asserted":"detected"}}),explicitEmpty:!1})}var ra={"blocked-by":"blocked_by",depends_on:"blocked_by","depends-on":"blocked_by"};function nr(e){return typeof e!="string"?e:ra[e.toLowerCase()]??e}function ce(e,t){if(e.startsWith("```")||e.includes(`
|
|
4
4
|
`))return!0;let n=t.map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${n})\\s*[:=]`,"i").test(e)?!0:zt(e)}function Ue(e,t,n,r){return!t||t.length===0?{values:void 0,explicitEmpty:!1}:(K(t,e,e==="--comment"?"Use --clear-comments to clear comments.":e==="--note"?"Use --clear-notes to clear notes.":"Use --clear-learnings to clear learnings."),{values:t.map(i=>{let d=i.trim(),l=()=>{if(d.length===0)throw new c(`${e} requires text=<value>`,s.USAGE);return{created_at:n,author:r,text:d}},u;try{u=x(i,e)}catch(y){if(e==="--comment"||e==="--note"||e==="--learning")return l();throw y}if(Object.keys(u).filter(y=>!Ho.has(y)).length>0)return{created_at:Le(u.created_at,n),author:v(u.author)??r,text:d};let p=u.text??"";if(p==="")throw new c(`${e} requires text=<value>`,s.USAGE);return{created_at:Le(u.created_at,n),author:v(u.author)??r,text:p}}),explicitEmpty:!1})}function oa(e){return!e||e.length===0?{values:void 0,explicitEmpty:!1}:(K(e,"--file","Use --clear-files to clear linked files."),{values:e.map(n=>{let r=n.trim(),o=ce(r,se),a=o?x(n,"--file"):{path:r};if(o&&L(a,"--file",se),!a.path)throw new c("--file requires path=<value> or a bare file path",s.USAGE);return{path:a.path,scope:U(a.scope??"project",$,"file scope"),note:v(a.note)}}),explicitEmpty:!1})}function aa(e){return!e||e.length===0?{values:void 0,explicitEmpty:!1}:(K(e,"--test","Use --clear-tests to clear linked tests."),{values:e.map(n=>{let r=n.trim(),o=yn(r)?_n(x(n,"--test"),"--test"):{command:r},a=v(o.command),i=v(o.path);if(!a)throw new c("--test requires command=<value> or a bare command (path=<value> is optional metadata)",s.USAGE);let d=v(o.timeout_seconds),l=v(o.timeout);if(d&&l&&d!==l)throw new c("--test timeout and timeout_seconds must match when both are provided",s.USAGE);let u=d??l;return{command:a,path:i,scope:U(o.scope??"project",$,"test scope"),timeout_seconds:u?R(u,"timeout_seconds"):void 0,pm_context_mode:bn(o.pm_context_mode,"--test"),env_set:hn(o.env_set,"--test"),env_clear:wn(o.env_clear,"--test"),shared_host_safe:En(o.shared_host_safe,"--test","shared_host_safe"),assert_stdout_contains:oe(o.assert_stdout_contains),assert_stdout_regex:Ae(o.assert_stdout_regex,"--test","assert_stdout_regex"),assert_stderr_contains:oe(o.assert_stderr_contains),assert_stderr_regex:Ae(o.assert_stderr_regex,"--test","assert_stderr_regex"),assert_stdout_min_lines:vn(o.assert_stdout_min_lines,"--test"),assert_json_field_equals:Sn(o.assert_json_field_equals,"--test"),assert_json_field_gte:kn(o.assert_json_field_gte,"--test"),note:v(o.note)}}),explicitEmpty:!1})}function ia(e){return!e||e.length===0?{values:void 0,explicitEmpty:!1}:(K(e,"--doc","Use --clear-docs to clear linked docs."),{values:e.map(n=>{let r=n.trim(),o=ce(r,se),a=o?x(n,"--doc"):{path:r};if(o&&L(a,"--doc",se),!a.path)throw new c("--doc requires path=<value> or a bare doc path",s.USAGE);return{path:a.path,scope:U(a.scope??"project",$,"doc scope"),note:v(a.note)}}),explicitEmpty:!1})}function sa(e,t){return!e||e.length===0?{values:void 0,explicitEmpty:!1}:(K(e,"--reminder","Use --clear-reminders to clear reminders."),{values:Yn(e,new Date(t),{valueMode:"raw"}),explicitEmpty:!1})}function ca(e,t){return!e||e.length===0?{values:void 0,explicitEmpty:!1}:(K(e,"--event","Use --clear-events to clear linked events."),{values:Wn(e,new Date(t),{allDayEmptyGuard:"defined",recurrenceEmptyNumericGuard:"defined"}),explicitEmpty:!1})}function da(e,t,n,r=[]){let o=[...tt.filter(a=>e[a]!==void 0),...r.filter(a=>e[a]!==void 0),...t.length>0?["body"]:[],...n.map(a=>`unset:${a}`)];return Array.from(new Set(o))}function rr(e,t){let n=e??"";if(t.length===0)return n;let r=`explicit_unset=${t.join(",")}`;return n?`${n} | ${r}`:r}function De(e,t,n){let r=ve("create",e);if(!r)throw new c(`Unsupported ${n} entry "${e}" for type "${t}"`,s.CONFLICT);return r}function la(e){return{scalarValues:{title:e.title,description:e.description,type:e.type,status:e.status,priority:e.priority,tags:e.tags,body:e.body,deadline:e.deadline,estimatedMinutes:e.estimatedMinutes,acceptanceCriteria:e.acceptanceCriteria,definitionOfReady:e.definitionOfReady,order:e.order??e.rank,goal:e.goal,objective:e.objective,value:e.value,impact:e.impact,outcome:e.outcome,whyNow:e.whyNow,author:e.author,message:e.message,assignee:e.assignee,parent:e.parent,reviewer:e.reviewer,risk:e.risk,confidence:e.confidence,sprint:e.sprint,release:e.release,blockedBy:e.blockedBy,blockedReason:e.blockedReason,unblockNote:e.unblockNote,reporter:e.reporter,severity:e.severity,environment:e.environment,reproSteps:e.reproSteps,resolution:e.resolution,expectedResult:e.expectedResult,actualResult:e.actualResult,affectedVersion:e.affectedVersion,fixedVersion:e.fixedVersion,component:e.component,regression:e.regression,customerImpact:e.customerImpact},repeatableValues:{dep:e.dep,comment:e.comment,note:e.note,learning:e.learning,file:e.file,test:e.test,doc:e.doc,reminder:e.reminder,event:e.event,typeOption:e.typeOption,field:e.field},addTags:e.addTags}}function Ne(e,t){if(t==="tags")return e.scalarValues.tags!==void 0||Array.isArray(e.addTags)&&e.addTags.length>0;if(Object.prototype.hasOwnProperty.call(e.scalarValues,t))return e.scalarValues[t]!==void 0;if(Object.prototype.hasOwnProperty.call(e.repeatableValues,t)){let n=e.repeatableValues[t];return Array.isArray(n)&&n.length>0}return!1}function ua(e,t){let n=new Set(["title","type"]);if(t!=="strict")return n;for(let r of e.required_create_fields)n.add(De(r,e.name,"required_create_fields"));for(let r of e.required_create_repeatables)n.add(De(r,e.name,"required_create_repeatables"));return n}function fa(e,t,n,r){for(let o of e)if(!(!Ne(t,o)&&!n.has(o)))throw new c(`Option ${M("create",o)} is disabled for type "${r}" by command_option_policies`,s.USAGE)}function ma(e,t,n){if(t!=="strict")return;let r=e.filter(a=>n.has(a));if(r.length===0)return;let o=[...new Set(r.map(a=>M("create",a)))].sort((a,i)=>a.localeCompare(i));throw new c(`Strict create mode requires concrete values for ${o.join(", ")}; --unset/--clear-* directives cannot satisfy required options`,s.USAGE)}function pa(e){return!e||e.length===0?{values:void 0,explicitEmpty:!1}:(K(e,"--type-option","Use --clear-type-options to clear existing type options."),{values:Jn(e),explicitEmpty:!1})}async function ya(e){let t=Bt();return{...e,body:await t.resolveValue(e.body,"--body"),dep:await t.resolveList(e.dep,"--dep"),comment:await t.resolveList(e.comment,"--comment"),note:await t.resolveList(e.note,"--note"),learning:await t.resolveList(e.learning,"--learning"),file:await t.resolveList(e.file,"--file"),test:await t.resolveList(e.test,"--test"),doc:await t.resolveList(e.doc,"--doc"),reminder:await t.resolveList(e.reminder,"--reminder"),event:await t.resolveList(e.event,"--event"),typeOption:await t.resolveList(e.typeOption,"--type-option"),field:await t.resolveList(e.field,"--field")}}function _a(e,t){if(e===void 0)return t;let n=e.trim().toLowerCase();if(n.length===0)return t;if(n==="strict"||n==="progressive")return n;throw new c(`Invalid --create-mode value "${e}". Allowed: ${Wo.join(", ")}`,s.USAGE)}function ga(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t.length===0)throw new c("--schedule-preset must not be empty",s.USAGE);if(t==="lightweight"||t==="lite"||t==="schedule-lite")return"lightweight";throw new c(`Invalid --schedule-preset value "${e}". Allowed: ${Jo.join(", ")}`,s.USAGE)}function ha(e,t,n){let r=_a(e,n);if(t===void 0)return r;if(typeof e=="string"&&e.trim().length>0&&r==="strict")throw new c("--schedule-preset lightweight cannot be combined with --create-mode strict. Use --create-mode progressive or omit --create-mode.",s.USAGE);return"progressive"}function wa(e,t,n,r){let o=e.name,a=la(t),i=ua(e,n),d=ft(e,"create",i);if(d.errors.length>0)throw new c(d.errors.join("; "),s.CONFLICT);fa(d.disabled,a,r,o),ma(d.required,n,r);let l=f=>f==="status"&&e.default_status!==void 0?!0:Ne(a,f),u=d.required.filter(f=>!l(f));return[...new Set(u.map(f=>M("create",f)))].sort((f,p)=>f.localeCompare(p))}var or=/^Missing required type option "([^"]+)" for type "([^"]+)"$/;function ar(e,t){let n=[];for(let r of e){let o=r.match(or);o&&o[2]===t&&n.push(o[1])}return[...new Set(n)].sort((r,o)=>r.localeCompare(o))}function ir(e,t){return e.filter(n=>{let r=n.match(or);return!r||r[2]!==t})}function Ea(e,t,n,r){let o=ir(e,t);if(o.length===0)return;let a=Fe(n,[],[],r.open_status);throw new c(o.join("; "),s.USAGE,{code:"invalid_argument_value",required:`Provide valid --type-option key/value pairs for type "${t}".`,examples:[a],nextSteps:[`Run "pm create --help --type ${t}" to review allowed type-option keys and values.`]})}function sr(e,t){let r=e.options.find(o=>o.key===t)?.values[0];return typeof r=="string"&&r.trim().length>0?r:"<value>"}function cr(e,t,n){switch(e){case"--title":return["--title",`"${t} example title"`];case"--description":return["--description",`"${t} example description"`];case"--type":return["--type",t];case"--status":return["--status",n];case"--priority":return["--priority","1"];case"--message":return["--message",`"Create ${t} item"`];case"--dep":return["--dep",'"id=pm-xxxx,kind=related,author=maintainer,created_at=now"'];case"--comment":return["--comment",'"author=maintainer,created_at=now,text=Implementation context"'];case"--note":return["--note",'"author=maintainer,created_at=now,text=Design note"'];case"--learning":return["--learning",'"author=maintainer,created_at=now,text=Durable lesson"'];case"--file":return["--file",'"path=src/example.ts,note=implementation file"'];case"--test":return["--test",'"command=node scripts/run-tests.mjs test,timeout_seconds=240"'];case"--doc":return["--doc",'"path=README.md,note=reference doc"'];default:return[e,'"<value>"']}}function Fe(e,t,n,r){let o=["pm","create","--title",`"${e.name} example title"`,"--description",`"${e.name} example description"`,"--type",e.name],a=["--status","--priority","--message"],i=[...new Set([...a,...t])],d=new Set(["--title","--description","--type"]);for(let l of i)d.has(l)||(o.push(...cr(l,e.name,r)),d.add(l));for(let l of n){let u=sr(e,l);o.push("--type-option",`${l}=${u}`)}return o.join(" ")}function dr(e,t){let n=e?.trim();if(!n)throw t==="--title"?e!==void 0?new c("Title cannot be empty or whitespace-only. Retry: pass a non-empty title with --title.",s.USAGE):new c('Missing required option --title. Why required: every item needs a human-readable title for lookup, search, and reporting. Retry: pass the title as the first positional argument (example: pm create "Fix login bug" --type Issue) or with --title.',s.USAGE):new c(`Missing required option ${t}`,s.USAGE);return n}function ba(e){return Wt(e)}function lr(e,t){let n={};for(let[r,o]of Object.entries(e))n[r]=Array.isArray(o)?[...o]:o;for(let[r,o]of Object.entries(t))o!==void 0&&(n[r]=Array.isArray(o)?[...o]:o);return n}function ur(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function fr(){let e=J();return e?e.commands.some(t=>t.action==="templates-show"||ur(t.command)==="templates show"):!1}function mr(e,t){if(typeof e!="object"||e===null||!("options"in e))throw new c(`Templates package returned invalid payload for template "${t}". Expected an options object.`,s.GENERIC_FAILURE);let n=e.options;if(typeof n!="object"||n===null||Array.isArray(n))throw new c(`Templates package returned invalid options for template "${t}".`,s.GENERIC_FAILURE);let r={};for(let[o,a]of Object.entries(n)){if(typeof a=="string"||typeof a=="number"||typeof a=="boolean"){r[o]=a;continue}if(Array.isArray(a)&&a.every(i=>typeof i=="string")){r[o]=[...a];continue}throw new c(`Templates package returned unsupported option value for "${o}" in template "${t}".`,s.GENERIC_FAILURE)}return r}async function pr(e,t,n){if(!fr())throw new c("--template requires the templates package. Install it first (for example: pm install templates --project).",s.USAGE);let r=await vt({command:"templates show",args:[e],options:{},global:t,pm_root:n});if(!r.handled){let o=r.warnings.length>0?` (${r.warnings.join(", ")})`:"";throw new c(`Unable to resolve template "${e}" via templates package. Run "pm templates show ${e}" for details.${o}`,s.USAGE)}return mr(r.result,e)}function va(e){return Ze(yt(e)).then(t=>{if(!t)throw new c(`Tracker is not initialized at ${e}. Run pm init first.`,s.NOT_FOUND)})}function g(e,t,n){return e.has(t)||n===void 0?void 0:v(n)}function F(e,t,n,r){return e.has(t)||n===void 0?void 0:r(n)}var Sa=new Set(["milestone","meeting","reminder","event"]);function yr(e,t,n,r){let o=t!==void 0,a=n!==void 0&&n.length>0,i=r!==void 0&&r.length>0;return Sa.has(e.toLowerCase())&&!o&&!a&&!i}function ka(e,t,n,r,o){let a=[];return e.toLowerCase()==="event"&&(o===void 0||o.length===0)&&a.push(`event_without_schedule:${t}:no_time_set`),yr(e,n,r,o)&&a.push(`calendar_item_without_schedule:${t}:no_deadline_or_reminder_or_event (hint: set --deadline <ISO> or --reminder "<when>", or link an Event via --event "start=<ISO>,end=<ISO>"; otherwise this item never appears on pm calendar)`),a}async function Ta(e,t,n,r){if(e!==void 0||n.has("parent")||t.parent!==void 0)return{parent:e,parentSource:void 0};let o=await rn(r);return o===void 0?{parent:e,parentSource:void 0}:{parent:o,parentSource:"focus"}}async function xa(e,t,n,r,o,a){let i=jt(o);if(Pt(r,i,t.id_prefix),await X(e,i,t.id_prefix,t.item_format,n.type_to_folder))return{parent:i,warnings:[]};let l=H(i,t.id_prefix);return{parent:i,warnings:Mt(l,a).warnings}}async function Ra(e){return e.parent===void 0?{parent:void 0,warnings:[]}:await xa(e.pmRoot,e.settings,e.typeRegistry,e.itemId,e.parent,e.policy)}async function Aa(e){if(e.explicitId===void 0)return Ot(e.pmRoot,e.settings.id_prefix,{tokenLength:e.settings.ids.token_length,typeToFolder:e.typeRegistry.type_to_folder,probeExisting:!1});if(typeof e.explicitId!="string")throw new c("--id must be a string",s.USAGE);let t=e.explicitId.trim();if(t.length===0||Gt(t))throw new c("--id must not be empty or use a placeholder token",s.USAGE);let n=H(t,e.settings.id_prefix);if(!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(n))throw new c("--id must contain only letters, numbers, and dashes after normalization",s.USAGE);return n}function Xn(e,t,n,r,o){let a=g(e,t,n);if(a===void 0)return{value:void 0,warnings:[]};let i=Jt(r,a,o);return{value:i.value,warnings:i.warnings}}async function Ia(e){let{pmRoot:t,settings:n,typeRegistry:r,statusRegistry:o,blockedBy:a,status:i,statusExplicit:d,nowValue:l,author:u}=e,f=e.dependencyValues;if(a===void 0)return{dependencyValues:f,status:i};let p=H(a,n.id_prefix),y=await X(t,p,n.id_prefix,n.item_format,r.type_to_folder);if(!y)return{dependencyValues:f,status:i};if((f??[]).some(b=>b.id===y.id&&b.kind==="blocked_by")||(f=[...f??[],{id:y.id,kind:"blocked_by",created_at:l,author:u,source_kind:"cli:create:blocked_by",author_source:"detected"}]),d)return{dependencyValues:f,status:i};let E=o.blocked_statuses.has("blocked")?"blocked":[...o.blocked_statuses].sort((b,_)=>b.localeCompare(_))[0]??o.open_status;return{dependencyValues:f,status:E}}function Ca(e,t,n){if(typeof e.createMode=="string"&&e.createMode.trim().toLowerCase()==="strict")return;let o=t.governance.create_default_type?.trim();if(o&&o.length>0&&V(o,n)){e.type=o;return}V("Task",n)&&(e.type="Task")}function Ka(e,t){return e.options.filter(n=>ve("create",n.key)===void 0).flatMap(n=>{let r=t[n.key];if(r===void 0)return[];if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return[n];throw new c(`Template custom type option "${n.key}" must be a string, number, or boolean value`,s.USAGE)})}async function Ua(e,t,n,r,o){let a=e;if(a.template!==void 0){let h=a.template.trim();if(h.length===0)throw new c("--template must not be empty. Omit --template to disable template usage.",s.USAGE);let E=await pr(h,t,n);a=Qn(lr(E,a))}if(a.type===void 0&&Ca(a,r,o),a.type===void 0)throw new c("Missing required option --type <value>",s.USAGE);let i=V(a.type,o);if(!i){let h=Ht(a.type),E=h?V(h,o):void 0;if(E)Te(`[pm] note: type '${a.type.trim()}' is not defined; using closest match '${E}'. Run 'pm schema add-type "${a.type.trim()}"' to track it as a distinct type.`),a.type=E,i=E;else throw new c(Xt(a.type,o.types,xt(n,r.schema)),s.USAGE)}let d=ut(i,o);if(!d)throw new c(`Invalid type value "${a.type}"`,s.USAGE);let l=d.name,u=Ka(d,a),f=u.map(h=>`${h.key}=${String(a[h.key])}`);if(f.length>0){a.typeOption=[...f,...a.typeOption??[]];for(let h of u)delete a[h.key]}let p=ga(a.schedulePreset);if(p!==void 0&&!Zn.has(l))throw new c(`--schedule-preset ${p} is only supported for Reminder, Meeting, or Event types`,s.USAGE);let y=ha(a.createMode,p,r.governance.create_mode_default);return{resolvedOptions:a,typeDefinition:d,type:l,schedulePreset:p,createMode:y}}function La(e,t){let n=new Set(t.metadataKeys),r=new Set(t.optionKeys),o=[{enabled:e.clearDeps,optionKey:"dep",clearFlag:"--clear-deps",valueFlag:"--dep",values:e.dep,metadataKey:"dependencies"},{enabled:e.clearComments,optionKey:"comment",clearFlag:"--clear-comments",valueFlag:"--comment",values:e.comment,metadataKey:"comments"},{enabled:e.clearNotes,optionKey:"note",clearFlag:"--clear-notes",valueFlag:"--note",values:e.note,metadataKey:"notes"},{enabled:e.clearLearnings,optionKey:"learning",clearFlag:"--clear-learnings",valueFlag:"--learning",values:e.learning,metadataKey:"learnings"},{enabled:e.clearFiles,optionKey:"file",clearFlag:"--clear-files",valueFlag:"--file",values:e.file,metadataKey:"files"},{enabled:e.clearTests,optionKey:"test",clearFlag:"--clear-tests",valueFlag:"--test",values:e.test,metadataKey:"tests"},{enabled:e.clearDocs,optionKey:"doc",clearFlag:"--clear-docs",valueFlag:"--doc",values:e.doc,metadataKey:"docs"},{enabled:e.clearReminders,optionKey:"reminder",clearFlag:"--clear-reminders",valueFlag:"--reminder",values:e.reminder,metadataKey:"reminders"},{enabled:e.clearEvents,optionKey:"event",clearFlag:"--clear-events",valueFlag:"--event",values:e.event,metadataKey:"events"},{enabled:e.clearTypeOptions,optionKey:"typeOption",clearFlag:"--clear-type-options",valueFlag:"--type-option",values:e.typeOption,metadataKey:"type_options"}];for(let a of o)if(a.enabled){if(a.values&&a.values.length>0)throw new c(`Cannot combine ${a.clearFlag} with ${a.valueFlag}`,s.USAGE);n.add(a.metadataKey),r.add(a.optionKey)}return{explicitUnsets:n,clearOptionKeys:r}}function Da(e,t){let n={tags:e.tags!==void 0,deadline:e.deadline!==void 0,estimatedMinutes:e.estimatedMinutes!==void 0,acceptanceCriteria:e.acceptanceCriteria!==void 0,definitionOfReady:e.definitionOfReady!==void 0,order:e.order!==void 0||e.rank!==void 0,goal:e.goal!==void 0,objective:e.objective!==void 0,value:e.value!==void 0,impact:e.impact!==void 0,outcome:e.outcome!==void 0,whyNow:e.whyNow!==void 0,author:e.author!==void 0,assignee:e.assignee!==void 0,parent:e.parent!==void 0,reviewer:e.reviewer!==void 0,risk:e.risk!==void 0,confidence:e.confidence!==void 0,sprint:e.sprint!==void 0,release:e.release!==void 0,blockedBy:e.blockedBy!==void 0,blockedReason:e.blockedReason!==void 0,unblockNote:e.unblockNote!==void 0,reporter:e.reporter!==void 0,severity:e.severity!==void 0,environment:e.environment!==void 0,reproSteps:e.reproSteps!==void 0,resolution:e.resolution!==void 0,expectedResult:e.expectedResult!==void 0,actualResult:e.actualResult!==void 0,affectedVersion:e.affectedVersion!==void 0,fixedVersion:e.fixedVersion!==void 0,component:e.component!==void 0,regression:e.regression!==void 0,customerImpact:e.customerImpact!==void 0};for(let[r,o]of Object.entries(n)){if(!o||!t.optionKeys.has(r))continue;let a=ie.get(r)??r;throw new c(`Cannot combine --unset ${a} with ${M("create",r)}`,s.USAGE)}}function $a(e){let t=(n,r)=>{let o=ie.get(r),a=o?`Use --unset ${o} to clear this field.`:void 0;Cn(n,M("create",r),a)};t(e.tags,"tags"),t(e.deadline,"deadline"),t(e.estimatedMinutes,"estimatedMinutes"),t(e.acceptanceCriteria,"acceptanceCriteria"),t(e.definitionOfReady,"definitionOfReady"),t(e.order??e.rank,"order"),t(e.goal,"goal"),t(e.objective,"objective"),t(e.value,"value"),t(e.impact,"impact"),t(e.outcome,"outcome"),t(e.whyNow,"whyNow"),t(e.author,"author"),t(e.assignee,"assignee"),t(e.parent,"parent"),t(e.reviewer,"reviewer"),t(e.risk,"risk"),t(e.confidence,"confidence"),t(e.sprint,"sprint"),t(e.release,"release"),t(e.blockedBy,"blockedBy"),t(e.blockedReason,"blockedReason"),t(e.unblockNote,"unblockNote"),t(e.reporter,"reporter"),t(e.severity,"severity"),t(e.environment,"environment"),t(e.reproSteps,"reproSteps"),t(e.resolution,"resolution"),t(e.expectedResult,"expectedResult"),t(e.actualResult,"actualResult"),t(e.affectedVersion,"affectedVersion"),t(e.fixedVersion,"fixedVersion"),t(e.component,"component"),t(e.regression,"regression"),t(e.customerImpact,"customerImpact")}function Na(e,t,n){for(let r of Object.keys(e))if(n.metadataKeys.has(r))throw new c(`Cannot combine --unset ${r.replaceAll("_","-")} with --field ${r}=...`,s.USAGE);for(let r of Object.keys(t.values??{}))if(n.metadataKeys.has(r))throw new c(`Cannot combine --unset ${r.replaceAll("_","-")} with its value flag`,s.USAGE)}function Fa(e){let{combinedMissingFlags:t,typeDefinition:n,missingRequiredCreateFlags:r,missingRequiredTypeOptionKeys:o,openStatus:a,type:i,createMode:d}=e;if(t.length===0)return;let l=Fe(n,r,o,a),u=[`Run "pm create --help --type ${i}" for type-aware required option guidance.`];t.includes("--title")&&u.push('Title can also be passed as the first positional argument (example: pm create "Your title" --type '+i+")."),d==="strict"&&(u.push('For staged onboarding, retry with "--create-mode progressive".'),Zn.has(i)&&u.push('For minimal scheduling inputs, try "--schedule-preset lightweight".'));let f=t.length===1?`Missing required option ${t[0]} for type "${i}"`:`Missing required options ${t.join(", ")} for type "${i}"`;throw new c(f,s.USAGE,{code:"missing_required_option",required:`Provide all required create options and type options for type "${i}" in one invocation.`,examples:[l],nextSteps:u,recovery:d==="strict"?{recovery_mode:"compact",missing_required_fields:t,suggested_flags:["--create-mode progressive",...t]}:void 0})}function Oa(e,t){if(e.has("tags")&&Array.isArray(t.addTags)&&t.addTags.length>0)throw new c("Cannot combine --unset tags with --add-tags",s.USAGE);let n=e.has("tags")?[]:t.tags!==void 0?qt(t.tags):[];return Vt(n,t.addTags)}function ja(e,t){if(t.order!==void 0&&t.rank!==void 0&&t.order!==t.rank)throw new c("--order and --rank must match when both are provided",s.USAGE);let n=t.order??t.rank,r=F(e,"order",n,o=>R(o,"order"));if(r!==void 0&&!Number.isInteger(r))throw new c("Order must be an integer",s.USAGE);return r}function Ga(e,t,n,r,o,a){if(r.completedAt!==void 0&&e!==t.close_status)throw new c("--completed-at requires a terminal create status.",s.USAGE);let i=e!==t.close_status?void 0:r.completedAt===void 0?a:k(r.completedAt,new Date(a),"completed-at");if(e!==t.close_status)return{closeReason:void 0,completedAt:i,warnings:[]};let d=n.governance.require_close_reason?{explicit:r.closeReason??r.message,resolution:o}:{explicit:r.closeReason};return{closeReason:on(d,n.governance.require_close_reason,{operation:"create",status:e}).closeReason,completedAt:i,warnings:[]}}async function Ma(e){let{pmRoot:t,type:n,id:r,settings:o,typeRegistry:a,author:i,extensionFieldNames:d,afterDocument:l,beforeDocument:u,historyMessage:f,changedFields:p,nowValue:y,similarityCandidate:h,allowDuplicate:E}=e,b=_t(t,n,r,o.item_format,a.type_to_folder),_=gt(t,r),S=await Ft(t,r,o.locks.ttl_seconds,i,!1,o.governance.force_required_for_stale_lock,o.locks.wait_ms),A=[];try{let T=l.metadata.dependencies&&l.metadata.dependencies.length>0?await tn(t,o.item_format,a.type_to_folder,void 0,o.schema):void 0;if(await X(t,r,o.id_prefix,o.item_format,a.type_to_folder))throw new c(`Item "${r}" already exists`,s.CONFLICT);await bt({pm_root:t,operation:"create",before:null,after:l,changed_fields:p,sdk:nn({pmRoot:t,settings:o,typeToFolder:a.type_to_folder})});let q=await Qt(t,i,{required:o.governance.duplicate_detection_mode==="strict"&&E!==!0}),O=[];try{o.governance.duplicate_detection_mode==="strict"&&E!==!0&&await Re(h,{pmRoot:t,mode:"strict",threshold:o.governance.duplicate_detection_threshold,limit:o.governance.duplicate_detection_limit,allowDuplicate:!1}),await Qe(b,Ut(l,{format:o.item_format,schema:o.schema,extensionFieldNames:d}));try{let D=$t({nowIso:y,author:i,op:"create",before:u,after:l,message:f});await Nt(_,D)}catch(D){throw await et(b),D}O=await en({pmRoot:t,preferredFormat:o.item_format,typeToFolder:a.type_to_folder,schema:o.schema,itemPath:b,document:l})}finally{await q()}A=[...T?pn(T,[...T,l.metadata],r):[],...O,...await Se({path:b,scope:"project",op:"create",item_id:l.metadata.id,item_type:l.metadata.type,before:u,after:l,changed_fields:p}),...await Se({path:_,scope:"project",op:"create:history",item_id:l.metadata.id,item_type:l.metadata.type,before:u,after:l,changed_fields:p})],wt({id:l.metadata.id,op:"create",item_type:l.metadata.type,status:l.metadata.status,current:Et(l.metadata,p),changed_fields:p})}finally{await S()}return A}async function qi(e,t){let n=Qn(await ya(e)),r=pt(process.cwd(),t.path);await va(r);let o=await Zt(r),a=Rt(o.schema),i=It(o.schema),d=lt(o,J()),l=await Ua(n,t,r,o,d);n=l.resolvedOptions;let{typeDefinition:u,type:f,createMode:p}=l,y=er(n.unset,i),{explicitUnsets:h,clearOptionKeys:E}=La(n,y);Da(n,y),$a(n);let b=wa(u,n,p,E),_=rt(),S=Dt(v(n.author),o.author_default),A=tr(n.dep,_,o.id_prefix,S),T=Ue("--comment",n.comment,_,S),z=Ue("--note",n.note,_,S),q=Ue("--learning",n.learning,_,S),O=oa(n.file),D=aa(n.test),de=ia(n.doc),le=sa(n.reminder,_),ue=ca(n.event,_),_r=pa(n.typeOption),fe=mt(f,_r.values,d),me=J(),Oe=St(me),pe=kt(n.field,me),B=Ct(n,i,f);Na(pe,B,y);let je=ar(fe.errors,f),gr=je.map(w=>`--type-option ${w}=<value>`),hr=[...new Set([...b,...gr,...B.missing_required_flags])].sort((w,Ee)=>w.localeCompare(Ee));Fa({combinedMissingFlags:hr,typeDefinition:u,missingRequiredCreateFlags:b,missingRequiredTypeOptionKeys:je,openStatus:a.open_status,type:f,createMode:p}),Ea(fe.errors,f,u,a);let I=await Aa({pmRoot:r,settings:o,typeRegistry:d,explicitId:n.id}),j=n.status!==void 0?ea(n.status,a):ta(u,a),wr=n.priority!==void 0?ba(n.priority):2,m=y.metadataKeys,Er=Oa(m,n),ye=F(m,"deadline",n.deadline,w=>k(w,new Date(_),"deadline")),br=F(m,"estimated_minutes",n.estimatedMinutes,w=>Yt(w,"estimated-minutes")),vr=g(m,"acceptance_criteria",n.acceptanceCriteria),Sr=g(m,"definition_of_ready",n.definitionOfReady),kr=ja(m,n),Tr=g(m,"goal",n.goal),xr=g(m,"objective",n.objective),Rr=g(m,"value",n.value),Ar=g(m,"impact",n.impact),Ir=g(m,"outcome",n.outcome),Cr=g(m,"why_now",n.whyNow),Kr=g(m,"assignee",n.assignee),Ur=m.has("author")?void 0:v(n.author)??S,Lr=g(m,"parent",n.parent),Ge=await Ta(Lr,n,m,r),_e=Ge.parent,Dr=Ge.parentSource,$r=g(m,"reviewer",n.reviewer),Nr=F(m,"risk",n.risk,w=>U(Tn(w),at,"risk")),Fr=F(m,"confidence",n.confidence,w=>Rn(w)),Or=n.allowMissingParent===!0&&o.validation.parent_reference==="strict_error"?"warn":o.validation.parent_reference,Me=o.validation.sprint_release_format,G=ka(f,I,ye,le.values,ue.values),Pe=await Ra({itemId:I,parent:_e,pmRoot:r,settings:o,typeRegistry:d,policy:Or});_e=Pe.parent,G.push(...Pe.warnings);let qe=Xn(m,"sprint",n.sprint,"sprint",Me),jr=qe.value;G.push(...qe.warnings);let Ve=Xn(m,"release",n.release,"release",Me),Gr=Ve.value;G.push(...Ve.warnings);let ze=g(m,"blocked_by",n.blockedBy),Be=await Ia({pmRoot:r,settings:o,typeRegistry:d,statusRegistry:a,blockedBy:ze,dependencyValues:A.values,status:j,statusExplicit:n.status!==void 0,nowValue:_,author:S}),Ye=Be.dependencyValues;Mn(I,Ye),j=Be.status;let Mr=g(m,"blocked_reason",n.blockedReason),Pr=g(m,"unblock_note",n.unblockNote),qr=g(m,"reporter",n.reporter),Vr=F(m,"severity",n.severity,w=>U(xn(w),it,"severity")),zr=g(m,"environment",n.environment),Br=g(m,"repro_steps",n.reproSteps),We=g(m,"resolution",n.resolution),Yr=g(m,"expected_result",n.expectedResult),Wr=g(m,"actual_result",n.actualResult),Jr=g(m,"affected_version",n.affectedVersion),Hr=g(m,"fixed_version",n.fixedVersion),Xr=g(m,"component",n.component),Zr=F(m,"regression",n.regression,w=>An(w)),Qr=g(m,"customer_impact",n.customerImpact),ge=dr(n.title,"--title"),he=n.description??"",Y=n.body??"",Je=await Re({title:ge,description:he,body:Y},{pmRoot:r,mode:o.governance.duplicate_detection_mode,threshold:o.governance.duplicate_detection_threshold,limit:o.governance.duplicate_detection_limit,allowDuplicate:n.allowDuplicate});G.push(...ln(Je));let we=Ga(j,a,o,n,We,_),eo=we.closeReason,to=j===a.close_status?_:void 0,no=we.completedAt;G.push(...we.warnings);let W=Kt({id:I,title:ge,description:he,type:f,type_options:fe.normalized,status:j,closed_at:to,completed_at:no,close_reason:eo,priority:wr,tags:Er,created_at:_,updated_at:_,deadline:ye,assignee:Kr,author:Ur,estimated_minutes:br,acceptance_criteria:vr,definition_of_ready:Sr,order:kr,goal:Tr,objective:xr,value:Rr,impact:Ar,outcome:Ir,why_now:Cr,parent:_e,reviewer:$r,risk:Nr,confidence:Fr,sprint:jr,release:Gr,blocked_by:ze,blocked_reason:Mr,unblock_note:Pr,reporter:qr,severity:Vr,environment:zr,repro_steps:Br,resolution:We,expected_result:Yr,actual_result:Wr,affected_version:Jr,fixed_version:Hr,component:Xr,regression:Zr,customer_impact:Qr,dependencies:Ye,comments:T.values,notes:z.values,learnings:q.values,files:O.values,tests:D.values,docs:de.values,reminders:le.values,events:ue.values,...pe,...B.values});try{Tt(W,me)}catch(w){throw new c(w instanceof Error?w.message:"Invalid extension item field values",s.USAGE)}let ro=Lt({metadata:W,body:Y},{schema:o.schema,extensionFieldNames:Oe}),oo={metadata:{},body:""},He=[...h].sort((w,Ee)=>w.localeCompare(Ee)),ao=rr(n.message,He),Xe=da(W,Y,He,[...Object.keys(pe),...Object.keys(B.values??{})]),io=await Ma({pmRoot:r,type:f,id:I,settings:o,typeRegistry:d,author:S,extensionFieldNames:Oe,afterDocument:ro,beforeDocument:oo,historyMessage:ao,changedFields:Xe,nowValue:_,similarityCandidate:{title:ge,description:he,body:Y},allowDuplicate:n.allowDuplicate}),so=structuredClone(W),co=Un(I,f,j,a);return yr(f,ye,le.values,ue.values)&&Te(`[pm] warning: ${f} '${I}' has no deadline/reminder/event \u2014 it will not appear on the calendar. Add one via 'pm update ${I} --deadline <ISO>' or 'pm update ${I} --event "start=<ISO>,end=<ISO>"'.`),{item:so,changed_fields:Xe,warnings:[...G,...io],...Object.fromEntries([["parent_source",Dr],["next_transition",co],["similarity_advisory",Je]].filter(w=>w[1]!==void 0))}}var Vi={buildHistoryMessage:rr,buildInvalidLogSeedKeysMessage:Qo,buildTypeSpecificCreateExample:Fe,collectMissingRequiredTypeOptionKeys:ar,createExampleTokensForFlag:cr,filterNonMissingTypeOptionErrors:ir,hasTemplatesShowHandler:fr,hasCreateOptionValue:Ne,loadCreateTemplateOptionsFromRuntime:pr,looksLikeStructuredEntry:ce,mergeCreateOptionsWithTemplate:lr,normalizeCreatePolicyOptionKey:De,normalizeDependencyKindInput:nr,parseDependencies:tr,normalizeExtensionCommandPath:ur,parseCreateUnsetTargets:er,requireStringOption:dr,readTemplateOptionsFromRuntimeResult:mr,resolveRuntimeCreateUnsetDefinition:(e,t)=>Ie(e,"create",t),typeOptionExampleValue:sr};export{Tn as a,xn as b,Rn as c,An as d,In as e,C as f,Cn as g,K as h,Kn as i,U as j,Yn as k,Wn as l,Jn as m,Gn as n,Mn as o,pn as p,yn as q,_n as r,ne as s,re as t,Q as u,hn as v,wn as w,En as x,bn as y,oe as z,Ae as A,vn as B,Sn as C,kn as D,ei as E,Uo as F,Lo as G,Dn as H,$n as I,Ie as J,Ue as K,oa as L,aa as M,ia as N,dr as O,qi as P,Vi as Q};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-BP6EMEDP.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$e as _,A as c,Ad as K,Af as st,C as l,Da as B,Hf as at,Jf as ct,La as q,Lf as P,Mf as D,Oa as z,Pa as V,R as C,Ra as S,We as p,Ze as Q,b as k,bf as d,c as H,cf as U,d as m,gf as Z,hd as Y,hf as tt,id as X,jf as et,lc as W,mf as rt,tf as nt,uc as L,uf as ot,xf as it,zd as J}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]="47c087c2-124a-58b7-a5c9-09403235f4a2")}catch{}})();function xt(t,e){let n=-1;return t.forEach((r,o)=>{let i=Date.parse(r.ts);if(!Number.isFinite(i))throw new l(`History for this item contains invalid timestamp at entry ${o+1}.`,c.GENERIC_FAILURE);i<=e&&(n=o)}),n}function bt(t){let e=t[0]?.ts??null,n=t.at(-1)?.ts??null,r={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:e,last_timestamp:n}};return n!==null&&(r.examples=["1",String(t.length),n],r.valid_range.first_version=1,r.valid_range.last_version=t.length),{guidance:r,lastTimestamp:n}}function Rt(t,e){let n={};if(e instanceof Error&&e.message.trim().length>0&&(n.reason=e.message.trim()),typeof e!="object"||e===null)return n;let r=e;if(typeof r.index=="number"&&Number.isInteger(r.index)&&r.index>=0&&(n.patchIndex=r.index),typeof r.operation=="object"&&r.operation!==null){let o=r.operation;Object.assign(n,Object.fromEntries(["op","path","from"].flatMap(i=>{let s=o[i];return typeof s=="string"?[[i,s]]:[]})))}if(n.patchIndex!==void 0){let o=t[n.patchIndex];o&&(n.op??=o.op,n.path??=o.path,n.from??=o.from)}return n}function Mt(t,e,n={}){let r=t.trim(),o=n.errorSubject??"history",i=o==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=bt(e);if(!r)throw new l(`Missing ${o} target. Use a timestamp or version number.`,c.USAGE,s);if(/^\d+$/.test(r)){let u=Number(r);if(!Number.isSafeInteger(u)||u<1||u>e.length)throw new l(`${i} version must be between 1 and ${e.length} for this item.`,c.USAGE,s);return{kind:"version",raw:r,historyIndex:u-1}}let h=Date.parse(r);if(!Number.isFinite(h))throw new l(`Invalid ${o} target "${t}". Use a positive version number or ISO timestamp.`,c.USAGE,s);let f=xt(e,h);if(f<0||n.allowFutureTimestamp!==!0&&h>Date.parse(a))throw new l(o==="restore"?`No history entries exist at or before timestamp ${r}.`:`No history entry exists at timestamp ${r}.`,c.USAGE,s);return{kind:"timestamp",raw:r,historyIndex:f}}function A(t,e,n,r){let o=Z(t,e);if(o.ok)return o.document;let i=Rt(e,o.error),s=[`history_op=${r}`,i.patchIndex===void 0?null:`patch_index=${i.patchIndex}`,i.op?`op=${i.op}`:null,i.path?`path=${i.path}`:null,i.from?`from=${i.from}`:null].filter(a=>a!==null);throw new l(`Failed to apply history patch at entry ${n} (${s.join(", ")}). ${i.reason??String(o.error)}`,c.GENERIC_FAILURE)}function Gt(t,e){let n=structuredClone(_);for(let r=0;r<=e;r+=1){let o=t[r];if(!o)throw new l(`History target entry ${r+1} does not exist.`,c.USAGE);if(d(n)!==o.before_hash)throw new l(`History hash mismatch before replay at entry ${r+1}.`,c.GENERIC_FAILURE);if(n=A(n,o.patch,r+1,o.op),d(n)!==o.after_hash)throw new l(`History hash mismatch after replay at entry ${r+1}.`,c.GENERIC_FAILURE)}return n}function Bt(t,e){if(Object.keys(t.metadata).length>0)return t;throw new l(`History target ${e.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,c.USAGE)}import F from"node:fs/promises";import Et from"node:fs/promises";(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]="a2ec9f1a-aae2-59d5-8c9a-7acd8bf5a7a2")}catch{}})();function vt(t){if(!t.itemDocument)return[];let e=t.itemDocument.metadata?.assignee?.trim();if(!e||e===t.author||t.force)return[];let n=it(t.settings);if(n.ownership_enforcement==="strict")throw new l(`Item ${t.subjectId} is assigned to ${e}. Use --force to override.`,c.CONFLICT);return n.ownership_enforcement==="warn"?[`ownership_warning:assignee_conflict:${t.subjectId}:${e}`]:[]}async function kt(t){let e=await H(t.subject.historyPath);if(e!==t.historyRawBeforeLock)throw new l(`History for ${t.subject.id} changed while waiting for lock; retry ${t.operation}.`,c.CONFLICT);let n=await P(t.pmRoot,t.subject.id,t.settings.id_prefix,t.settings.item_format,t.typeRegistry.type_to_folder),r=n?await D(n,{schema:t.settings.schema}):null;if((r?.raw??null)!==(t.currentItemRawBeforeLock??null))throw new l(`Item ${t.subject.id} changed while waiting for lock; retry ${t.operation}.`,c.CONFLICT);return{historyRawUnderLock:e,locatedUnderLock:n,loadedItemUnderLock:r}}async function Zt(t){let e=t.writeHistoryRaw??m;try{await e(t.historyPath,t.nextHistoryRaw),await p(t.historyPath)}catch(n){try{t.historyRawUnderLock===null?await Et.rm(t.historyPath,{force:!0}):await e(t.historyPath,t.historyRawUnderLock),await p(t.historyPath)}catch(r){throw new AggregateError([n,r],`History rewrite failed and rollback also failed: ${String(n)}`)}throw n}}async function lt(t){let e=[...vt({itemDocument:t.itemDocument,subjectId:t.subject.id,author:t.author,force:t.force,settings:t.settings})],n=await rt(t.pmRoot,t.subject.id,t.settings.locks.ttl_seconds,t.author,!!t.force,t.settings.governance.force_required_for_stale_lock,t.settings.locks.wait_ms);try{let r=await kt({pmRoot:t.pmRoot,subject:t.subject,settings:t.settings,typeRegistry:t.typeRegistry,historyRawBeforeLock:t.historyRawBeforeLock,currentItemRawBeforeLock:t.currentItemRawBeforeLock,operation:t.operation});return await t.applyRewrite(r),t.applyPostRewrite&&e.push(...await t.applyPostRewrite(r)),e}finally{await n()}}(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]="cd2a27ec-0f12-591d-ab34-529ddda05063")}catch{}})();function N(t){return Array.isArray(t)?t:typeof t=="string"?[t]:[]}function ht(t){let e=[];for(let n of t)e.includes(n)||e.push(n);return e.includes("g")||e.push("g"),e.join("")}function ut(t){let e=t.trim();if(e.length===0)throw new l("history-redact --regex requires a non-empty pattern.",c.USAGE);let n=e,r="g";if(e.startsWith("/")&&e.length>1){let o=e.lastIndexOf("/");o>0&&(n=e.slice(1,o),r=ht(e.slice(o+1)))}if(n.length===0)throw new l("history-redact --regex cannot use an empty pattern.",c.USAGE);try{new RegExp(n,r)}catch{throw new l("Invalid --regex value; provide a valid JavaScript regular expression.",c.USAGE)}return{kind:"regex",source:n,flags:r}}function ft(t,e){let n=[...new Set(N(t).map(i=>i.trim()))].filter(i=>i.length>0).map(i=>({kind:"literal",value:i})),r=[...new Set(N(e).map(i=>i.trim()))].filter(i=>i.length>0).map(ut),o=[...n,...r];if(o.length===0)throw new l("history-redact requires at least one matcher via --literal or --regex.",c.USAGE,{code:"missing_required_argument",required:"Provide --literal <value> and/or --regex <pattern>.",examples:['pm history-redact pm-a1b2 --literal "[redacted_path_prefix]/private"','pm history-redact pm-a1b2 --regex "/192\\\\.168\\\\.[0-9.]+/g" --replacement "[scrubbed_ip]"']});return o}function dt(t,e,n){if(e.length===0)return{value:t,replacements:0};let r=0,o=0;for(;r<=t.length;){let i=t.indexOf(e,r);if(i===-1)break;o+=1,r=i+Math.max(1,e.length)}return o===0?{value:t,replacements:0}:{value:t.split(e).join(n),replacements:o}}function mt(t,e,n){let r=new RegExp(e.source,e.flags),o=[...t.matchAll(r)];return o.length===0?{value:t,replacements:0}:{value:t.replace(r,n),replacements:o.length}}function O(t,e,n){let r=t,o=0;for(let i of e){let s=i.kind==="literal"?dt(r,i.value,n):mt(r,i,n);r=s.value,o+=s.replacements}return{value:r,replacements:o}}function T(t,e,n){if(typeof t=="string")return O(t,e,n);if(Array.isArray(t)){let r=0;return{value:t.map(i=>{let s=T(i,e,n);return r+=s.replacements,s.value}),replacements:r}}if(typeof t=="object"&&t!==null){let r=0,o={};for(let[i,s]of Object.entries(t)){let a=T(s,e,n);r+=a.replacements,o[i]=a.value}return{value:o,replacements:r}}return{value:t,replacements:0}}function Ht(t){let e=structuredClone(_),n=0,r=0;for(let o=0;o<t.length;o+=1){let i=t[o];d(e)!==i.before_hash&&(n+=1),e=A(e,i.patch,o+1,i.op),d(e)!==i.after_hash&&(r+=1)}return{hashMismatchesBefore:n,hashMismatchesAfter:r,finalDocument:e}}function Pt(t,e,n){let r=0,o=!1,i=t.message;if(typeof t.message=="string"){let a=O(t.message,e,n);i=a.value,r+=a.replacements,a.replacements>0&&(o=!0)}let s=t.patch.map(a=>{if(!Object.prototype.hasOwnProperty.call(a,"value"))return a;let h=T(a.value,e,n);return r+=h.replacements,h.replacements>0?(o=!0,{...a,value:h.value}):a});return{entry:{...t,message:i,patch:s},replacements:r,changed:o}}function Dt(t,e,n){let r=structuredClone(_),o=0,i=0,s=[];for(let a=0;a<t.length;a+=1){let h=Pt(t[a],e,n);i+=h.replacements,h.changed&&(o+=1);let f=d(r);r=A(r,h.entry.patch,a+1,h.entry.op);let u=d(r);s.push({...h.entry,before_hash:f,after_hash:u})}return{entries:s,finalDocument:r,entriesChanged:o,replacements:i}}function yt(t){return Object.keys(t.metadata).length>0}async function At(t,e){let n=t.located?.itemPath??null;if(!t.located)return{raw:null,path:n,document:null};let r=await D(t.located,{schema:e.schema});return{raw:r.raw,path:n,document:r.document}}function Tt(t){if(!yt(t.finalDocument))return{raw:null,path:null,document:null};let e=X(U(t.finalDocument),{schema:t.settings.schema});if(e.metadata.id!==t.subject.id)throw new l("history-redact would change the item id; narrow your patterns.",c.USAGE);return{document:e,path:V(t.pmRoot,e.metadata.type,t.subject.id,"toon",t.typeToFolder),raw:Y(e,{format:"toon",schema:t.settings.schema})}}function $t(t,e){return typeof t.message=="string"&&t.message.trim().length>0?t.message:`history-redact replaced ${e.replacements} match(es) across ${e.entriesChanged} entr${e.entriesChanged===1?"y":"ies"}.`}function jt(t){let e=[...t.rewritten.entries];if(t.dryRun||!t.changed)return{rewrittenEntries:e,auditEntryAdded:!1};let n=t.nextItemDocument??U(t.rewritten.finalDocument);return e.push(Q({nowIso:C(),author:t.author,op:"history_redact",before:n,after:n,message:t.message})),{rewrittenEntries:e,auditEntryAdded:!0}}async function Ct(t){let e=[];return lt({pmRoot:t.pmRoot,subject:t.subject,settings:t.settings,typeRegistry:t.typeRegistry,historyRawBeforeLock:t.historyRawBeforeLock,currentItemRawBeforeLock:t.currentItem.raw,operation:"history-redact",author:t.author,force:t.force,itemDocument:t.currentItem.document,applyRewrite:async({historyRawUnderLock:n})=>{let r=await at(t.pmRoot,t.author),o=new Set;t.currentItem.path&&o.add(t.currentItem.path),t.nextItem.path&&o.add(t.nextItem.path);let i=new Map;t.currentItem.path&&t.currentItem.raw!==null&&i.set(t.currentItem.path,t.currentItem.raw);let s=()=>{};try{try{t.nextItem.path&&t.nextItem.raw!==null&&t.nextItem.raw!==t.currentItem.raw&&await m(t.nextItem.path,t.nextItem.raw),t.currentItem.path&&(!t.nextItem.path||t.nextItem.path!==t.currentItem.path)&&await F.rm(t.currentItem.path,{force:!0}),await m(t.subject.historyPath,et(t.rewrittenEntries))}catch(h){try{await St(t.subject.historyPath,n,o,i)}finally{await p(t.subject.historyPath)}throw h}await p(t.subject.historyPath);let a=t.nextItem.path??t.currentItem.path;a&&(e=await ct({pmRoot:t.pmRoot,preferredFormat:t.settings.item_format,typeToFolder:t.typeRegistry.type_to_folder,schema:t.settings.schema,itemPath:a,...t.currentItem.path?{previousItemPath:t.currentItem.path}:{},document:t.nextItem.document}))}finally{await r().catch(a=>{s=()=>{throw a}})}s()},applyPostRewrite:async()=>[...e,...await Lt(t.subject.historyPath,[t.nextItem.path,t.currentItem.path])]})}async function St(t,e,n,r){e===null?await F.rm(t,{force:!0}):await m(t,e);for(let o of n){let i=r.get(o);i===void 0?await F.rm(o,{force:!0}):await m(o,i)}}async function Lt(t,e){let n=[],r=new Set(e.filter(o=>o!==null));for(let o of r)n.push(...await L({path:o,scope:"project",op:"history_redact"}));return n.push(...await L({path:t,scope:"project",op:"history_redact:history"})),n}async function Ut(t,e,n,r){let o=await P(t,e,n.id_prefix,n.item_format,r);if(o)return{id:o.id,historyPath:S(t,o.id),located:o};let i=ot(e,n.id_prefix),s=nt(e),a=i===s?[i]:[i,s];for(let h of a){let f=S(t,h);if(await k(f))return{id:h,historyPath:f,located:null}}throw new l(`Item ${e} not found`,c.NOT_FOUND)}async function xe(t,e,n){let r=q(process.cwd(),n.path);if(!await k(z(r)))throw new l(`Tracker is not initialized at ${r}. Run pm init first.`,c.NOT_FOUND);let o=await st(r),i=B(o,W()),s=e.replacement??"",a=s.length===0,h=a?"[redacted]":s,f=ft(e.literal,e.regex),u=await Ut(r,t,o,i.type_to_folder);if(!await k(u.historyPath))throw new l(`No history stream exists for ${u.id}.`,c.NOT_FOUND);let wt=await H(u.historyPath),x=await K(u.historyPath,u.id);if(x.length===0)throw new l(`No history entries exist for ${u.id}; nothing to redact.`,c.USAGE);let b=Ht(x),y=Dt(x,f,h),$=b.hashMismatchesBefore+b.hashMismatchesAfter,j=!!e.dryRun,R=y.replacements>0,E=[];$>0&&E.push(`history_redact_preexisting_hash_mismatches:${$}`),R||E.push("history_redact_no_matches");let g=await At(u,o),w=Tt({pmRoot:r,subject:u,settings:o,typeToFolder:i.type_to_folder,finalDocument:y.finalDocument}),pt=(g.path??null)!==(w.path??null)||(g.raw??null)!==(w.raw??null),M=J(e.author,o.author_default),gt=$t(e,y),{rewrittenEntries:G,auditEntryAdded:It}=jt({rewritten:y,dryRun:j,changed:R,nextItemDocument:w.document,author:M,message:gt}),v=tt(G);if(!v.ok)throw new l(`history-redact produced an invalid rewritten chain (${v.errors.join(", ")}).`,c.GENERIC_FAILURE);return!j&&R&&E.push(...await Ct({pmRoot:r,subject:u,settings:o,typeRegistry:i,historyRawBeforeLock:wt,currentItem:g,nextItem:w,author:M,force:e.force,rewrittenEntries:G})),{id:u.id,dry_run:j,changed:R,patterns:{literal_count:f.filter(I=>I.kind==="literal").length,regex_count:f.filter(I=>I.kind==="regex").length,total_count:f.length,replacement_is_default:a},history:{path:u.historyPath,entries_scanned:x.length,entries_changed:y.entriesChanged,replacements:y.replacements,hash_mismatches_before:b.hashMismatchesBefore,hash_mismatches_after:b.hashMismatchesAfter,preexisting_hash_mismatches:$,audit_entry_added:It,verify_ok:v.ok,verify_errors:v.errors},item:{existed_before:g.path!==null,exists_after:w.path!==null,path_before:g.path,path_after:w.path,changed:pt},warnings:[...new Set(E)].sort((I,_t)=>I.localeCompare(_t)),generated_at:C()}}var be={applyLiteralRule:dt,applyRegexRule:mt,buildRedactionRules:ft,hasItemMetadata:yt,normalizeRegexFlags:ht,normalizeStringArrayInput:N,parseRegexRule:ut,redactStringValue:O,redactUnknownValue:T};export{Rt as a,Mt as b,A as c,Gt as d,Bt as e,Zt as f,lt as g,Ut as h,xe as i,be as j};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{$e as _,A as c,Ad as K,Af as st,C as l,Da as B,Hf as at,Jf as ct,La as q,Lf as P,Mf as D,Oa as z,Pa as V,R as C,Ra as S,We as p,Ze as Q,b as k,bf as d,c as H,cf as U,d as m,gf as Z,hd as Y,hf as tt,id as X,jf as et,lc as W,mf as rt,tf as nt,uc as L,uf as ot,xf as it,zd as J}from"./chunk-HS7OVAUN.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]="47c087c2-124a-58b7-a5c9-09403235f4a2")}catch{}})();function xt(t,e){let n=-1;return t.forEach((r,o)=>{let i=Date.parse(r.ts);if(!Number.isFinite(i))throw new l(`History for this item contains invalid timestamp at entry ${o+1}.`,c.GENERIC_FAILURE);i<=e&&(n=o)}),n}function bt(t){let e=t[0]?.ts??null,n=t.at(-1)?.ts??null,r={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:e,last_timestamp:n}};return n!==null&&(r.examples=["1",String(t.length),n],r.valid_range.first_version=1,r.valid_range.last_version=t.length),{guidance:r,lastTimestamp:n}}function Rt(t,e){let n={};if(e instanceof Error&&e.message.trim().length>0&&(n.reason=e.message.trim()),typeof e!="object"||e===null)return n;let r=e;if(typeof r.index=="number"&&Number.isInteger(r.index)&&r.index>=0&&(n.patchIndex=r.index),typeof r.operation=="object"&&r.operation!==null){let o=r.operation;Object.assign(n,Object.fromEntries(["op","path","from"].flatMap(i=>{let s=o[i];return typeof s=="string"?[[i,s]]:[]})))}if(n.patchIndex!==void 0){let o=t[n.patchIndex];o&&(n.op??=o.op,n.path??=o.path,n.from??=o.from)}return n}function Mt(t,e,n={}){let r=t.trim(),o=n.errorSubject??"history",i=o==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=bt(e);if(!r)throw new l(`Missing ${o} target. Use a timestamp or version number.`,c.USAGE,s);if(/^\d+$/.test(r)){let u=Number(r);if(!Number.isSafeInteger(u)||u<1||u>e.length)throw new l(`${i} version must be between 1 and ${e.length} for this item.`,c.USAGE,s);return{kind:"version",raw:r,historyIndex:u-1}}let h=Date.parse(r);if(!Number.isFinite(h))throw new l(`Invalid ${o} target "${t}". Use a positive version number or ISO timestamp.`,c.USAGE,s);let f=xt(e,h);if(f<0||n.allowFutureTimestamp!==!0&&h>Date.parse(a))throw new l(o==="restore"?`No history entries exist at or before timestamp ${r}.`:`No history entry exists at timestamp ${r}.`,c.USAGE,s);return{kind:"timestamp",raw:r,historyIndex:f}}function A(t,e,n,r){let o=Z(t,e);if(o.ok)return o.document;let i=Rt(e,o.error),s=[`history_op=${r}`,i.patchIndex===void 0?null:`patch_index=${i.patchIndex}`,i.op?`op=${i.op}`:null,i.path?`path=${i.path}`:null,i.from?`from=${i.from}`:null].filter(a=>a!==null);throw new l(`Failed to apply history patch at entry ${n} (${s.join(", ")}). ${i.reason??String(o.error)}`,c.GENERIC_FAILURE)}function Gt(t,e){let n=structuredClone(_);for(let r=0;r<=e;r+=1){let o=t[r];if(!o)throw new l(`History target entry ${r+1} does not exist.`,c.USAGE);if(d(n)!==o.before_hash)throw new l(`History hash mismatch before replay at entry ${r+1}.`,c.GENERIC_FAILURE);if(n=A(n,o.patch,r+1,o.op),d(n)!==o.after_hash)throw new l(`History hash mismatch after replay at entry ${r+1}.`,c.GENERIC_FAILURE)}return n}function Bt(t,e){if(Object.keys(t.metadata).length>0)return t;throw new l(`History target ${e.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,c.USAGE)}import F from"node:fs/promises";import Et from"node:fs/promises";(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]="a2ec9f1a-aae2-59d5-8c9a-7acd8bf5a7a2")}catch{}})();function vt(t){if(!t.itemDocument)return[];let e=t.itemDocument.metadata?.assignee?.trim();if(!e||e===t.author||t.force)return[];let n=it(t.settings);if(n.ownership_enforcement==="strict")throw new l(`Item ${t.subjectId} is assigned to ${e}. Use --force to override.`,c.CONFLICT);return n.ownership_enforcement==="warn"?[`ownership_warning:assignee_conflict:${t.subjectId}:${e}`]:[]}async function kt(t){let e=await H(t.subject.historyPath);if(e!==t.historyRawBeforeLock)throw new l(`History for ${t.subject.id} changed while waiting for lock; retry ${t.operation}.`,c.CONFLICT);let n=await P(t.pmRoot,t.subject.id,t.settings.id_prefix,t.settings.item_format,t.typeRegistry.type_to_folder),r=n?await D(n,{schema:t.settings.schema}):null;if((r?.raw??null)!==(t.currentItemRawBeforeLock??null))throw new l(`Item ${t.subject.id} changed while waiting for lock; retry ${t.operation}.`,c.CONFLICT);return{historyRawUnderLock:e,locatedUnderLock:n,loadedItemUnderLock:r}}async function Zt(t){let e=t.writeHistoryRaw??m;try{await e(t.historyPath,t.nextHistoryRaw),await p(t.historyPath)}catch(n){try{t.historyRawUnderLock===null?await Et.rm(t.historyPath,{force:!0}):await e(t.historyPath,t.historyRawUnderLock),await p(t.historyPath)}catch(r){throw new AggregateError([n,r],`History rewrite failed and rollback also failed: ${String(n)}`)}throw n}}async function lt(t){let e=[...vt({itemDocument:t.itemDocument,subjectId:t.subject.id,author:t.author,force:t.force,settings:t.settings})],n=await rt(t.pmRoot,t.subject.id,t.settings.locks.ttl_seconds,t.author,!!t.force,t.settings.governance.force_required_for_stale_lock,t.settings.locks.wait_ms);try{let r=await kt({pmRoot:t.pmRoot,subject:t.subject,settings:t.settings,typeRegistry:t.typeRegistry,historyRawBeforeLock:t.historyRawBeforeLock,currentItemRawBeforeLock:t.currentItemRawBeforeLock,operation:t.operation});return await t.applyRewrite(r),t.applyPostRewrite&&e.push(...await t.applyPostRewrite(r)),e}finally{await n()}}(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]="cd2a27ec-0f12-591d-ab34-529ddda05063")}catch{}})();function N(t){return Array.isArray(t)?t:typeof t=="string"?[t]:[]}function ht(t){let e=[];for(let n of t)e.includes(n)||e.push(n);return e.includes("g")||e.push("g"),e.join("")}function ut(t){let e=t.trim();if(e.length===0)throw new l("history-redact --regex requires a non-empty pattern.",c.USAGE);let n=e,r="g";if(e.startsWith("/")&&e.length>1){let o=e.lastIndexOf("/");o>0&&(n=e.slice(1,o),r=ht(e.slice(o+1)))}if(n.length===0)throw new l("history-redact --regex cannot use an empty pattern.",c.USAGE);try{new RegExp(n,r)}catch{throw new l("Invalid --regex value; provide a valid JavaScript regular expression.",c.USAGE)}return{kind:"regex",source:n,flags:r}}function ft(t,e){let n=[...new Set(N(t).map(i=>i.trim()))].filter(i=>i.length>0).map(i=>({kind:"literal",value:i})),r=[...new Set(N(e).map(i=>i.trim()))].filter(i=>i.length>0).map(ut),o=[...n,...r];if(o.length===0)throw new l("history-redact requires at least one matcher via --literal or --regex.",c.USAGE,{code:"missing_required_argument",required:"Provide --literal <value> and/or --regex <pattern>.",examples:['pm history-redact pm-a1b2 --literal "[redacted_path_prefix]/private"','pm history-redact pm-a1b2 --regex "/192\\\\.168\\\\.[0-9.]+/g" --replacement "[scrubbed_ip]"']});return o}function dt(t,e,n){if(e.length===0)return{value:t,replacements:0};let r=0,o=0;for(;r<=t.length;){let i=t.indexOf(e,r);if(i===-1)break;o+=1,r=i+Math.max(1,e.length)}return o===0?{value:t,replacements:0}:{value:t.split(e).join(n),replacements:o}}function mt(t,e,n){let r=new RegExp(e.source,e.flags),o=[...t.matchAll(r)];return o.length===0?{value:t,replacements:0}:{value:t.replace(r,n),replacements:o.length}}function O(t,e,n){let r=t,o=0;for(let i of e){let s=i.kind==="literal"?dt(r,i.value,n):mt(r,i,n);r=s.value,o+=s.replacements}return{value:r,replacements:o}}function T(t,e,n){if(typeof t=="string")return O(t,e,n);if(Array.isArray(t)){let r=0;return{value:t.map(i=>{let s=T(i,e,n);return r+=s.replacements,s.value}),replacements:r}}if(typeof t=="object"&&t!==null){let r=0,o={};for(let[i,s]of Object.entries(t)){let a=T(s,e,n);r+=a.replacements,o[i]=a.value}return{value:o,replacements:r}}return{value:t,replacements:0}}function Ht(t){let e=structuredClone(_),n=0,r=0;for(let o=0;o<t.length;o+=1){let i=t[o];d(e)!==i.before_hash&&(n+=1),e=A(e,i.patch,o+1,i.op),d(e)!==i.after_hash&&(r+=1)}return{hashMismatchesBefore:n,hashMismatchesAfter:r,finalDocument:e}}function Pt(t,e,n){let r=0,o=!1,i=t.message;if(typeof t.message=="string"){let a=O(t.message,e,n);i=a.value,r+=a.replacements,a.replacements>0&&(o=!0)}let s=t.patch.map(a=>{if(!Object.prototype.hasOwnProperty.call(a,"value"))return a;let h=T(a.value,e,n);return r+=h.replacements,h.replacements>0?(o=!0,{...a,value:h.value}):a});return{entry:{...t,message:i,patch:s},replacements:r,changed:o}}function Dt(t,e,n){let r=structuredClone(_),o=0,i=0,s=[];for(let a=0;a<t.length;a+=1){let h=Pt(t[a],e,n);i+=h.replacements,h.changed&&(o+=1);let f=d(r);r=A(r,h.entry.patch,a+1,h.entry.op);let u=d(r);s.push({...h.entry,before_hash:f,after_hash:u})}return{entries:s,finalDocument:r,entriesChanged:o,replacements:i}}function yt(t){return Object.keys(t.metadata).length>0}async function At(t,e){let n=t.located?.itemPath??null;if(!t.located)return{raw:null,path:n,document:null};let r=await D(t.located,{schema:e.schema});return{raw:r.raw,path:n,document:r.document}}function Tt(t){if(!yt(t.finalDocument))return{raw:null,path:null,document:null};let e=X(U(t.finalDocument),{schema:t.settings.schema});if(e.metadata.id!==t.subject.id)throw new l("history-redact would change the item id; narrow your patterns.",c.USAGE);return{document:e,path:V(t.pmRoot,e.metadata.type,t.subject.id,"toon",t.typeToFolder),raw:Y(e,{format:"toon",schema:t.settings.schema})}}function $t(t,e){return typeof t.message=="string"&&t.message.trim().length>0?t.message:`history-redact replaced ${e.replacements} match(es) across ${e.entriesChanged} entr${e.entriesChanged===1?"y":"ies"}.`}function jt(t){let e=[...t.rewritten.entries];if(t.dryRun||!t.changed)return{rewrittenEntries:e,auditEntryAdded:!1};let n=t.nextItemDocument??U(t.rewritten.finalDocument);return e.push(Q({nowIso:C(),author:t.author,op:"history_redact",before:n,after:n,message:t.message})),{rewrittenEntries:e,auditEntryAdded:!0}}async function Ct(t){let e=[];return lt({pmRoot:t.pmRoot,subject:t.subject,settings:t.settings,typeRegistry:t.typeRegistry,historyRawBeforeLock:t.historyRawBeforeLock,currentItemRawBeforeLock:t.currentItem.raw,operation:"history-redact",author:t.author,force:t.force,itemDocument:t.currentItem.document,applyRewrite:async({historyRawUnderLock:n})=>{let r=await at(t.pmRoot,t.author),o=new Set;t.currentItem.path&&o.add(t.currentItem.path),t.nextItem.path&&o.add(t.nextItem.path);let i=new Map;t.currentItem.path&&t.currentItem.raw!==null&&i.set(t.currentItem.path,t.currentItem.raw);let s=()=>{};try{try{t.nextItem.path&&t.nextItem.raw!==null&&t.nextItem.raw!==t.currentItem.raw&&await m(t.nextItem.path,t.nextItem.raw),t.currentItem.path&&(!t.nextItem.path||t.nextItem.path!==t.currentItem.path)&&await F.rm(t.currentItem.path,{force:!0}),await m(t.subject.historyPath,et(t.rewrittenEntries))}catch(h){try{await St(t.subject.historyPath,n,o,i)}finally{await p(t.subject.historyPath)}throw h}await p(t.subject.historyPath);let a=t.nextItem.path??t.currentItem.path;a&&(e=await ct({pmRoot:t.pmRoot,preferredFormat:t.settings.item_format,typeToFolder:t.typeRegistry.type_to_folder,schema:t.settings.schema,itemPath:a,...t.currentItem.path?{previousItemPath:t.currentItem.path}:{},document:t.nextItem.document}))}finally{await r().catch(a=>{s=()=>{throw a}})}s()},applyPostRewrite:async()=>[...e,...await Lt(t.subject.historyPath,[t.nextItem.path,t.currentItem.path])]})}async function St(t,e,n,r){e===null?await F.rm(t,{force:!0}):await m(t,e);for(let o of n){let i=r.get(o);i===void 0?await F.rm(o,{force:!0}):await m(o,i)}}async function Lt(t,e){let n=[],r=new Set(e.filter(o=>o!==null));for(let o of r)n.push(...await L({path:o,scope:"project",op:"history_redact"}));return n.push(...await L({path:t,scope:"project",op:"history_redact:history"})),n}async function Ut(t,e,n,r){let o=await P(t,e,n.id_prefix,n.item_format,r);if(o)return{id:o.id,historyPath:S(t,o.id),located:o};let i=ot(e,n.id_prefix),s=nt(e),a=i===s?[i]:[i,s];for(let h of a){let f=S(t,h);if(await k(f))return{id:h,historyPath:f,located:null}}throw new l(`Item ${e} not found`,c.NOT_FOUND)}async function xe(t,e,n){let r=q(process.cwd(),n.path);if(!await k(z(r)))throw new l(`Tracker is not initialized at ${r}. Run pm init first.`,c.NOT_FOUND);let o=await st(r),i=B(o,W()),s=e.replacement??"",a=s.length===0,h=a?"[redacted]":s,f=ft(e.literal,e.regex),u=await Ut(r,t,o,i.type_to_folder);if(!await k(u.historyPath))throw new l(`No history stream exists for ${u.id}.`,c.NOT_FOUND);let wt=await H(u.historyPath),x=await K(u.historyPath,u.id);if(x.length===0)throw new l(`No history entries exist for ${u.id}; nothing to redact.`,c.USAGE);let b=Ht(x),y=Dt(x,f,h),$=b.hashMismatchesBefore+b.hashMismatchesAfter,j=!!e.dryRun,R=y.replacements>0,E=[];$>0&&E.push(`history_redact_preexisting_hash_mismatches:${$}`),R||E.push("history_redact_no_matches");let g=await At(u,o),w=Tt({pmRoot:r,subject:u,settings:o,typeToFolder:i.type_to_folder,finalDocument:y.finalDocument}),pt=(g.path??null)!==(w.path??null)||(g.raw??null)!==(w.raw??null),M=J(e.author,o.author_default),gt=$t(e,y),{rewrittenEntries:G,auditEntryAdded:It}=jt({rewritten:y,dryRun:j,changed:R,nextItemDocument:w.document,author:M,message:gt}),v=tt(G);if(!v.ok)throw new l(`history-redact produced an invalid rewritten chain (${v.errors.join(", ")}).`,c.GENERIC_FAILURE);return!j&&R&&E.push(...await Ct({pmRoot:r,subject:u,settings:o,typeRegistry:i,historyRawBeforeLock:wt,currentItem:g,nextItem:w,author:M,force:e.force,rewrittenEntries:G})),{id:u.id,dry_run:j,changed:R,patterns:{literal_count:f.filter(I=>I.kind==="literal").length,regex_count:f.filter(I=>I.kind==="regex").length,total_count:f.length,replacement_is_default:a},history:{path:u.historyPath,entries_scanned:x.length,entries_changed:y.entriesChanged,replacements:y.replacements,hash_mismatches_before:b.hashMismatchesBefore,hash_mismatches_after:b.hashMismatchesAfter,preexisting_hash_mismatches:$,audit_entry_added:It,verify_ok:v.ok,verify_errors:v.errors},item:{existed_before:g.path!==null,exists_after:w.path!==null,path_before:g.path,path_after:w.path,changed:pt},warnings:[...new Set(E)].sort((I,_t)=>I.localeCompare(_t)),generated_at:C()}}var be={applyLiteralRule:dt,applyRegexRule:mt,buildRedactionRules:ft,hasItemMetadata:yt,normalizeRegexFlags:ht,normalizeStringArrayInput:N,parseRegexRule:ut,redactStringValue:O,redactUnknownValue:T};export{Rt as a,Mt as b,A as c,Gt as d,Bt as e,Zt as f,lt as g,Ut as h,xe as i,be as j};
|
|
2
|
+
//# sourceMappingURL=chunk-C3YABSJK.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as I,d as T,e as x,h as H}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as I,d as T,e as x,h as H}from"./chunk-C3YABSJK.js";import{A as c,Ad as y,Af as E,C as f,Da as l,La as p,Oa as u,Xe as _,Ye as w,b as h,df as b,hf as v,lc as g}from"./chunk-HS7OVAUN.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new t.Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="bccbd81b-988f-569d-8dbf-c0998d813953")}catch{}})();function G(t,r){let n=v(t),i=t.length>0?t[t.length-1].after_hash:w(),o=r===void 0?void 0:_(r),d=o===void 0?void 0:o===i,e=[...n.errors];return d===!1&&e.push("verify_failed:current_item_hash_mismatch"),{ok:e.length===0,entries:t.length,errors:e,latest_after_hash:t.length>0?t[t.length-1].after_hash:void 0,current_item_hash:o,current_matches_latest:d}}async function X(t,r,n={}){let i=p(n.cwd??process.cwd(),n.pmRoot);if(!await h(u(i)))throw new f(`Tracker is not initialized at ${i}. Run pm init first.`,c.NOT_FOUND);let o=await E(i),d=l(o,g()),e=await H(i,t,o,d.type_to_folder),s=await y(e.historyPath,e.id);if(s.length===0)throw new f(`No history exists for ${e.id}; point-in-time reads are unavailable.`,c.NOT_FOUND);let a=I(r,s),R=x(T(s,a.historyIndex),a),m=b(R,{schema:o.schema});if(m.metadata.id!==e.id)throw new f(`History target resolved to item ${m.metadata.id}, expected ${e.id}.`,c.GENERIC_FAILURE);let D=s[a.historyIndex];return{document:m,reconstructed:!0,as_of_version:a.historyIndex+1,as_of_timestamp:D.ts,target:a,history_length:s.length}}export{G as a,X as b};
|
|
2
|
+
//# sourceMappingURL=chunk-CA3BURYF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ra as g,Xe as H,d as _,hf as v,nf as u,of as w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{Ra as g,Xe as H,d as _,hf as v,nf as u,of as w}from"./chunk-HS7OVAUN.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-D7I3TUGV.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as B}from"./chunk-A6KGKEWT.js";import{f as m,g as j,h,i as q}from"./chunk-
|
|
1
|
+
import{a as B}from"./chunk-A6KGKEWT.js";import{f as m,g as j,h,i as q}from"./chunk-R6LSRGPS.js";import{A as l,Af as W,C as u,Cb as O,Da as G,La as K,Lf as z,Ma as F,Mf as V,Oa as U,Sf as Y,b as N,ha as E,lc as M,zd as $}from"./chunk-HS7OVAUN.js";import ct from"node:fs/promises";import f from"node:path";import dt from"fast-glob";(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]="2b9ba0a4-396f-5870-bc89-e7fc789bb49d")}catch{}})();var it=/^[a-z][a-z0-9+.-]+:\/\//i;function _(t){return it.test(t.trim())}(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]="3fe80124-596b-591c-9f0d-fbbc129c6bb4")}catch{}})();var pt=["path","scope","note"],lt=["pattern","glob","path","scope","note"],ut=["path"],ft=["from","to"],mt=new Set(["note","scope"]);function Z(t){let e=t??"project";if(!E.includes(e))throw new u(`Invalid scope "${t}". Valid scopes: ${E.join(", ")} (default: project).`,l.USAGE);return e}function H(t){return t.startsWith("```")||t.includes(`
|
|
2
2
|
`)||/^(?:[-*+]\s+)?(?:path|scope|note)\s*[:=]/i.test(t)?!0:j(t)}function ht(t){return t.flatMap(e=>{let o=e.trim();return o.length===0||H(o)||!o.includes(",")?[e]:B(o)})}function gt(t,e){return t?ht(t).map(o=>{let n=o.trim(),r=H(n)?m(o,"--add"):{path:n};if(h(r,"--add",pt),!r.path)throw new u(`--add requires path=<value> or a bare ${e} path`,l.USAGE);return{path:r.path,scope:Z(r.scope),note:r.note?.trim()||void 0}}):[]}function bt(t){return t?t.map(e=>{let o=e.trim();if(!o)throw new u("--add-glob requires a glob pattern value",l.USAGE);if(o.includes("=")||/^(?:[-*+]\s+)?(?:pattern|glob|path)\s*[:=]/i.test(o)||o.startsWith("```")){let n=m(o,"--add-glob");h(n,"--add-glob",lt);let r=n.pattern?.trim()||n.glob?.trim()||n.path?.trim();if(!r)throw new u("--add-glob key/value form requires pattern=<glob>",l.USAGE);return{pattern:r,scope:Z(n.scope),note:n.note?.trim()||void 0}}return{pattern:o,scope:"project"}}):[]}function vt(t){return t?t.map(e=>{let o=e.trim();if(!o)throw new u("--remove requires a path value",l.USAGE);if(o.includes("=")||/^(?:[-*+]\s+)?path\s*[:=]/i.test(o)||o.startsWith("```")){let n=m(o,"--remove"),r=Object.keys(n).filter(i=>mt.has(i.toLowerCase()));if(r.length>0)throw new u(`--remove identifies a linked artifact by path only and does not accept ${r.map(i=>`"${i}"`).join(", ")}. Pass just the path (path=<value>, path:<value>, or a bare path); record removal context with --message "<why removed>".`,l.USAGE);if(h(n,"--remove",ut),!n.path)throw new u("--remove key/value form requires path=<value>",l.USAGE);return n.path}return o}):[]}function At(t){return t?t.map(e=>{let o=m(e,"--migrate");h(o,"--migrate",ft);let n=o.from?.trim(),r=o.to?.trim();if(!n||!r)throw new u("--migrate requires from=<value> and to=<value>",l.USAGE);return{from:n,to:r}}):[]}function y(t,e){let o=t;for(let n of e)o.startsWith(n.from)&&(o=`${n.to}${o.slice(n.from.length)}`);return o}function x(t){return t.split(f.sep).join("/")}function k(t,e,o=process.cwd()){let n=t.trim();if(_(n))return n;if(f.isAbsolute(n)||/^[A-Za-z]:[\\/]/.test(n))return x(n.replaceAll("\\",f.sep));let r=f.relative(e,o);return r.startsWith(`..${f.sep}`)||r===".."||f.isAbsolute(r)?x(f.normalize(n)):x(f.relative(e,f.resolve(o,n)))}async function wt(t,e=process.cwd(),o=process.cwd()){let n=[];for(let r of t){let i=f.isAbsolute(r.pattern),s=await dt(r.pattern,{cwd:o,absolute:i,onlyFiles:!0,dot:!0,unique:!0,followSymbolicLinks:!0}),a=[...new Set(s.map(d=>k(d,e,o)))].sort((d,c)=>d.localeCompare(c));for(let d of a)n.push({path:d,scope:r.scope,note:r.note})}return n}function Et(t,e,o){if(e===void 0)return t;if(!o)throw new u("--note requires --add or --add-glob in the same invocation (the note annotates the links being added)",l.USAGE);let n=e.trim();return n.length===0?t:t.map(r=>r.note===void 0?{...r,note:n}:r)}function _t(t){return`${t.path}::${t.scope}`}function yt(t){return[...t].sort((e,o)=>{let n=e.path.localeCompare(o.path);return n!==0?n:e.scope.localeCompare(o.scope)})}function xt(t){return[...new Map(t.map(e=>[_t(e),e])).values()].map(e=>({...e,note:e.note?.trim()||void 0}))}async function kt(t,e=process.cwd()){let o=[...new Set(t)].sort((a,d)=>a.localeCompare(d)),n=[],r=[],i=[],s=[];for(let a of o){if(_(a)){s.push(a.trim());continue}let d=f.isAbsolute(a)?a:f.resolve(e,a);try{(await ct.stat(d)).isFile()?n.push(a):i.push(a)}catch(c){if(typeof c=="object"&&c!==null&&"code"in c&&c.code==="ENOENT"){r.push(a);continue}i.push(a)}}return{checked:o.length,existing_files:n,missing_paths:r,non_file_paths:i,remote_references:s}}function Rt(t,e,o,n){let r=0;for(let s=0;s<t.length;s+=1){let a=y(t[s].path,n);a!==t[s].path&&(t[s]={...t[s],path:a},r+=1)}return{adds:e.map(s=>{let a=y(s.path,n);return a!==s.path&&(r+=1),{...s,path:a}}),removes:o.map(s=>y(s,n)),count:r}}function St(t,e,o,n){for(let i of e)t.some(s=>s.path===i.path&&s.scope===i.scope)||t.push(i);if(o.length>0)for(let i=t.length-1;i>=0;i-=1)o.includes(t[i].path)&&t.splice(i,1);let r=xt(t);return n?r:yt(r)}async function X(t){let e=t.artifacts.map(o=>o.path);return{id:t.id,artifacts:t.artifacts,changed:t.changed,count:t.artifacts.length,migrations_applied:t.migrationsApplied&&t.migrationsApplied>0?t.migrationsApplied:void 0,validation:t.options.validatePaths?await kt(e,t.workspaceRoot):void 0}}async function Yt(t,e,o,n){let{metadataKey:r}=n,i=q(),s=K(process.cwd(),o.path),a=F(s),d=process.cwd();if(!await N(U(s)))throw new u(`Tracker is not initialized at ${s}. Run pm init first.`,l.NOT_FOUND);let c=await W(s),J=G(c,M()),Q=await i.resolveList(e.add,"--add"),tt=await i.resolveList(e.addGlob,"--add-glob"),et=await i.resolveList(e.remove,"--remove"),ot=await i.resolveList(e.migrate,"--migrate"),R=gt(Q,n.bareNoun).map(p=>({...p,path:k(p.path,a,d)})),S=bt(tt),nt=await wt(S,a,d),T=Et([...R,...nt],e.note,R.length>0||S.length>0),L=vt(et).map(p=>k(p,a,d)),I=At(ot);if(!(T.length>0||L.length>0||I.length>0)){let p=await z(s,t,c.id_prefix,c.item_format,J.type_to_folder);if(!p)throw new u(`Item ${t} not found`,l.NOT_FOUND);let v=(await V(p,{schema:c.schema})).document.metadata[r]??[];return X({id:p.id,artifacts:v,changed:!1,options:e,workspaceRoot:a})}let rt=$(e.author,c.author_default),g=await Y({pmRoot:s,settings:c,id:t,op:n.op,author:rt,message:e.message,force:e.force,skipNoop:!0,mutate(p){let b=p.metadata,v=b[r]??[],C=[...v],A=Rt(C,T,L,I),w=St(C,A.adds,A.removes,n.supportsAppendStable&&e.appendStable===!0);w.length>0?b[r]=w:delete b[r];let D=!O(v,w);return{changedFields:D?[r]:[],warnings:D&&A.count>0?[`path_migrations_applied:${A.count}`]:[]}}}),st=g.item[r]??[],P=g.warnings.find(p=>p.startsWith("path_migrations_applied:")),at=P?Number(P.slice(24)):0;return X({id:g.item.id,artifacts:st,changed:g.changedFields.includes(r),migrationsApplied:at,options:e,workspaceRoot:a})}function Bt(t,e){let o={};for(let[n,r]of Object.entries(t))o[n==="artifacts"?e:n]=r;return o}export{_ as a,Z as b,gt as c,bt as d,vt as e,At as f,y as g,x as h,wt as i,Et as j,_t as k,yt as l,xt as m,kt as n,Yt as o,Bt as p};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-DQGJ2RWT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{qa as w,ra as I,ta as S,ua as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{qa as w,ra as I,ta as S,ua as g}from"./chunk-MDTH7SAE.js";import{A as u,Af as _,C as m,Da as f,Ef as x,If as b,La as y,Of as h}from"./chunk-HS7OVAUN.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new i.Error().stack;t&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[t]="078456b8-ed61-5c47-afc7-7553833934e1")}catch{}})();var U=3,R=20,k=.8,N=100,A=1e3,D=1e6;function Q(i){return i===void 0?[]:[`likely_duplicates:${i.result.items.map(t=>t.id).join(",")}`]}function C(i){let t=i.limit??U,s=i.threshold??k;if(!Number.isSafeInteger(t)||t<0||t>R)throw new m(`Similarity limit must be an integer from 0 to ${R}.`,u.USAGE);if(!Number.isFinite(s)||s<0||s>1)throw new m("Similarity threshold must be a number from 0 to 1.",u.USAGE);return{limit:t,threshold:s}}function O(i){let t=i.limit??N;if(!Number.isSafeInteger(t)||t<0||t>A)throw new m(`Duplicate cluster limit must be an integer from 0 to ${A}.`,u.USAGE);let s=i.since===void 0?void 0:new Date(i.since);if(s&&Number.isNaN(s.getTime()))throw new m("Duplicate cluster --since must be a valid ISO timestamp.",u.USAGE);return{limit:t,since:s}}async function $(i,t){let s=y(i.cwd??process.cwd(),i.pmRoot),o=await _(s),n=f(o),e=i.statuses?new Set(i.statuses.map(r=>r.trim()).filter(Boolean)):void 0;return(await h(s,o.item_format,n.type_to_folder,void 0,o.schema)).filter(r=>(!e||e.has(r.status))&&(!t||new Date(r.created_at).getTime()>=t.getTime())).sort((r,c)=>r.id.localeCompare(c.id)).map(r=>({item:r,prepared:I(r.title)}))}function L(i,t=D){let s=new Set,o=[new Map,new Map,new Map];for(let[n,e]of i.entries()){let r=[[e.prepared.normalized],e.prepared.issueCodes,e.prepared.tokens];for(let[c,a]of r.entries())for(let l of a){let d=o[c].get(l)??[];for(let p of d)s.add(`${p}:${n}`);if(s.size>t)throw new m(`Duplicate sweep exceeded ${D} candidate pairs; narrow it with statuses or since.`,u.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the batch duplicate query until its deterministic candidate set fits the disclosed safety bound."});d.push(n),o[c].set(l,d)}}return s}var Z={buildDuplicateClusters:E,collectDuplicateCandidatePairs:L,createDuplicateUnionFind:M};function M(i){let t=Array.from({length:i},(o,n)=>n);return{parent:t,findRoot:o=>{let n=o;for(;t[n]!==n;)n=t[n];for(;t[o]!==o;){let e=t[o];t[o]=n,o=e}return n}}}function P(i,t,s,o){let n=[];for(let e of t){let[r,c]=e.split(":").map(p=>Number.parseInt(p,10)),a=g(i[r].prepared,i[c].prepared);if(a.score<s)continue;let l=o.findRoot(r),d=o.findRoot(c);l!==d&&(o.parent[d]=l),n.push({left_id:i[r].item.id,right_id:i[c].item.id,...a})}return n}function E(i,t,s,o){let n=new Map;for(let e of i.keys()){let r=s.findRoot(e),c=n.get(r)??[];c.push(e),n.set(r,c)}return[...n.values()].filter(e=>e.length>1).map(e=>{let r=new Set(e.map(a=>i[a].item.id)),c=t.filter(a=>r.has(a.left_id)&&r.has(a.right_id)).sort((a,l)=>l.score-a.score||a.left_id.localeCompare(l.left_id)||a.right_id.localeCompare(l.right_id));return{id:i[e[0]].item.id,items:e.map(a=>{let l=i[a].item;return{id:l.id,title:l.title,status:l.status,type:l.type}}),matches:c,max_score:c[0]?.score??0}}).sort((e,r)=>r.max_score-e.max_score||e.id.localeCompare(r.id)).slice(0,o)}function z(i,t,s,o,n){return t.filter(e=>!s.has(e.id)).map(e=>({id:e.id,title:e.title,status:e.status,type:e.type,...S(i,e.title)})).filter(e=>e.score>=o).sort((e,r)=>r.score-e.score||e.id.localeCompare(r.id)).slice(0,n)}async function F(i,t={}){let s=i.title.trim();if(s.length===0)throw new m("Similarity candidate title must not be empty.",u.USAGE);let{limit:o,threshold:n}=C(t),e=y(t.cwd??process.cwd(),t.pmRoot),r=await _(e),c=f(r),a=await b(e,Object.values(c.type_to_folder)),l=w(s),d=a&&l.length>0?await x({pmRoot:e,expectedSourceCursor:a.source_cursor,query:l.map(v=>`"${v.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(o*10,50)}):null,p=d===null?await h(e,r.item_format,c.type_to_folder,void 0,r.schema):d.items,T=z(s,p,new Set(i.excludeIds??[]),n,o);return{items:T,count:T.length,threshold:n,source:d?"persistent_index":"metadata_fallback"}}async function ee(i={}){let{threshold:t}=C({...i,limit:void 0}),{limit:s,since:o}=O(i),n=await $(i,o),e=L(n),r=M(n.length),c=P(n,e,t,r),a=E(n,c,r,s);return{clusters:a,count:a.length,threshold:t,source:"metadata_scan",cost:{item_count:n.length,candidate_pairs:e.size,scored_pairs:e.size}}}async function te(i,t){if(t.mode==="off")return;let s=await F(i,t);if(s.count===0)return;let o=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!o){let n=s.items.map(e=>`${e.id} (${e.status}): ${e.title}`).join("; ");throw new m(`Likely duplicate item(s) found: ${n}. Reuse the canonical item or pass --allow-duplicate with explicit intent.`,u.CONFLICT,{code:"likely_duplicate",required:"Reuse an existing item, or explicitly acknowledge the duplicate with --allow-duplicate.",recovery:{suggested_flags:["--allow-duplicate"]}})}return{mode:t.mode,bypassed:o,result:s}}export{Q as a,Z as b,F as c,ee as d,te as e};
|
|
2
|
+
//# sourceMappingURL=chunk-DWOAOZHZ.js.map
|