@unbrained/pm-cli 2026.11.29 → 2026.11.30
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 +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-Q6GIFUCW.js → chunk-2SBTXR6C.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PY6A7ULK.js → chunk-3TXEWHQX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-K3MVVDLN.js → chunk-47ZS6RPL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WLZ5KVM2.js → chunk-5PNOVDVO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3TK2YOVB.js → chunk-AOTI76Q6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CV2B4JUB.js → chunk-CCKM5YQM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JQHLOSSS.js → chunk-DCWGM7CY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LQEB6GSY.js → chunk-FECZV72T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FRYNDVLN.js → chunk-FR7ULTM4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NLHNB2L3.js → chunk-HXQ3OHQR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JFPCL45G.js → chunk-IGEFPHV7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NRCGGNOE.js → chunk-JPJNJHQW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-R6M5OGJH.js → chunk-KCVSSONY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3E53F7QY.js → chunk-KXTKLDKD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DBASKWBO.js → chunk-NHBG5ET3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CNZOC6JD.js → chunk-NVYDPNQP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3US5T6B2.js → chunk-NZSXWIX7.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-VI3A7UZ2.js → chunk-Q4VZSMUL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RWHS77ME.js → chunk-SJWIPGZW.js} +39 -39
- package/dist/cli-bundle/chunks/{chunk-EYEQC3L2.js → chunk-TX74QJ4W.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WNB62BGK.js → chunk-TY55UX6M.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4EBHZBM2.js → chunk-USBTXMKS.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-VCXQ6A35.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-L7HON3BE.js → chunk-WFYE34TO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-YPMNXG2C.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZK4CY24V.js → chunk-YVTALIN3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZSBPE36C.js → chunk-Z7YL2SUM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KCR4NF2A.js → chunk-ZA5NS3PL.js} +2 -2
- package/dist/cli-bundle/chunks/{field-option-collisions-OZE43TOH.js → field-option-collisions-2F2Z7R7B.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-3WXNNFLP.js → item-revision-UAF6L47R.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-RJECL53Y.js +2 -0
- package/dist/cli-bundle/chunks/{linked-resource-value-list-2655COY2.js → linked-resource-value-list-WXPPYUVQ.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-actor-QOKPDYM4.js → mutation-actor-UK3QNEEB.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-JNJHB3E6.js → mutation-admission-UTDYPFWP.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-YGVUE4YZ.js → register-list-query-DRA3CWHI.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-3JVZQDHH.js → register-mutation-WO74VLEQ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-LCHUHKRA.js → register-operations-CRBKH7WN.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-IJ7M3VUK.js → register-setup-6V6NQB5C.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-7BD7U2BX.js → stage-DYEHGASU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WJAUHPXD.js → chunk-2UUBS4BG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KLOHZNJ4.js → chunk-4ER3VMST.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BZ3PUUPG.js → chunk-4YBMHMBJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ACTBMSCH.js → chunk-62AMZMR4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LSVRZ4KQ.js → chunk-7G7JIXLL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BPOU2S44.js → chunk-A3DORTXS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NNLENKU7.js → chunk-FM5WQ6ZU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BPBKHY6H.js → chunk-HXM7K6VH.js} +35 -35
- package/dist/cli-bundle/focused-chunks/{chunk-EUDAUT6T.js → chunk-IIVDBAJM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LKTRICZR.js → chunk-IJ3T3W4U.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-S5VG7RFY.js → chunk-L357ZAES.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PPCBCPIZ.js → chunk-LWBZ7UGG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TSZVCALS.js → chunk-M57KDG7I.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2CQFGJQ6.js → chunk-MZNV26XE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-NGHT2LNG.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-GTUPHXKR.js → chunk-NJTKGBSK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5NSWNLFE.js → chunk-P55AZPFN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NO5MUY4I.js → chunk-RQYVX2T6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KWKPX36T.js → chunk-SXC3NVZI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-QTV6UE2Q.js → chunk-TQQO42C2.js} +5 -5
- package/dist/cli-bundle/focused-chunks/{chunk-S4AC7OMI.js → chunk-U35K7FSE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-42SU4LK3.js → chunk-UQJ4PY2Y.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NZA2LP4Y.js → chunk-WAP3DF4B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MYWUMVCZ.js → chunk-XR745UGE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-HABQYZMQ.js → field-option-collisions-7TG7STO7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-YH5R7YPW.js → item-revision-J7EUGCHR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-YZ2PUPGM.js → item-transaction-2IC2MLML.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-DJ2VRLKG.js → mutation-actor-LJVF2HVD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-3SECKVKY.js → mutation-admission-SLFAUONA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-FEJT2UCG.js → stage-MWR73LTZ.js} +2 -2
- package/dist/cli-bundle/main.js +3 -3
- 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 +1 -1
- 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 +61 -61
- 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/shared/url-credentials.d.ts +4 -2
- package/dist/core/shared/url-credentials.js +1 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/docs/CONFIGURATION.md +22 -3
- package/docs/READ_OUTPUT_CONTRACTS.md +5 -0
- package/docs/SDK.md +19 -3
- package/marketplace.json +1 -1
- package/package.json +1 -1
- 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-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-JV7LREUF.js +0 -3
- package/dist/cli-bundle/chunks/chunk-SV27NNXQ.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-DJ5GAITL.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-TX24L7RQ.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as et,b as te}from"./chunk-3AZOATC2.js";import{$b as Xe,Ib as Ke,Nb as I,Ub as Ge,Xb as Ye,bc as N,fb as j,lh as Qe,mf as G,nf as Y,ph as Ze,xa as Be,za as Je}from"./chunk-
|
|
1
|
+
import{a as et,b as te}from"./chunk-3AZOATC2.js";import{$b as Xe,Ib as Ke,Nb as I,Ub as Ge,Xb as Ye,bc as N,fb as j,lh as Qe,mf as G,nf as Y,ph as Ze,xa as Be,za as Je}from"./chunk-SJWIPGZW.js";import{p as $e,r as q}from"./chunk-GSLOAEY2.js";import{Q as H,a as S,b as x,d as u,x as Ue}from"./chunk-VCXQ6A35.js";import{D as We,P as B,V as J,Z as K,aa as He,r as Ve}from"./chunk-TE6FBDHP.js";import{A as p,C as h,E as Fe,F as ee,H as E,J as De,K as ye,L as U,v as Me,y as c,z as $}from"./chunk-K672XXGQ.js";import tt from"node:fs/promises";import M from"node:path";var C="_workspace";function R(e){return M.join(e,"history",`${C}.jsonl`)}function we(e,t){return{metadata:{id:C,title:"Workspace state",description:"Audited singleton workspace document state.",type:"Chore",status:"open",priority:2,tags:["workspace-history"],created_at:t,updated_at:t,documents:e},body:""}}function z(e,t=e.length){let n=Ge();for(let r of e.slice(0,t))n=Xe(n,r.patch).document;return Ye(n)}function F(e){return"documents"in e.metadata&&typeof e.metadata.documents=="object"&&e.metadata.documents!==null&&!Array.isArray(e.metadata.documents)?e.metadata.documents:{}}function D(e){throw new h(`Workspace history verification failed: ${e.join(", ")}`,p.CONFLICT,{code:"workspace_history_chain_invalid",reason:"workspace_history_chain_verification_failed",verification_errors:[...e],required:"Repair the _workspace history chain before reading, reconciling, restoring, or appending audited singleton state.",why:"Continuing against an unverifiable append-only stream could hide or compound workspace state corruption.",examples:["pm history _workspace --verify --json","pm validate --check-history-drift --fix-hints --json"],nextSteps:["Inspect the exact verification_errors and preserve the corrupt stream as evidence.","Use the history-drift remediation returned by validate before retrying the refused operation."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify --json"}})}function ne(e,t){let n=M.resolve(t),r=M.relative(e,n).replaceAll("\\","/");if(r.length===0||r===".."||r.startsWith("../")||M.isAbsolute(r))throw new TypeError("Workspace history document path must stay inside the tracker root");return{documentPath:r,absolutePath:n}}async function hr(e){let t=await I(R(e),C),n=N(t);n.ok||D(n.errors);let r=F(t.length===0?$:z(t)),o=[],i=[],a=[],s=[];for(let l of Object.keys(r).sort()){let d;try{let _=ne(e,M.resolve(e,l));if(d=await E(_.absolutePath),d===null){a.push(l);continue}let f=JSON.parse(d);(S(f)===S(r[l])?o:i).push(l)}catch{s.push(l)}}return{ok:i.length===0&&a.length===0&&s.length===0,document_count:Object.keys(r).length,matching_documents:o,mismatched_documents:i,missing_documents:a,unreadable_documents:s}}async function nt(e){let t=R(e.pmRoot),n=await I(t,C),r=N(n);r.ok||D(r.errors);let o=e.idempotencyKey===void 0?void 0:n.find(f=>f.op===`${e.op}:${e.idempotencyKey}`);if(o)return{entry:o,historyPath:t};let i=H(),a=n.length===0?$:z(n),s=F(a),l=s[e.documentPath];if(l!==void 0&&S(l)!==S(e.before))throw new h(`Workspace history state for "${e.documentPath}" changed outside the audited mutation path.`,p.CONFLICT,{code:"workspace_history_state_conflict",reason:"out_of_band_workspace_state",required:"Reconcile the singleton document with its matching _workspace history state before retrying the mutation.",why:"Accepting the write would make the append-only audit stream describe a state that was not actually observed.",examples:["pm history _workspace --verify","pm validate --check-history-drift --fix-hints"],nextSteps:["Review the version-control change that altered the singleton and preserve the intended document plus its matching workspace history.","Rerun the original mutation only after the on-disk singleton agrees with the latest audited workspace state."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify"}});let d=we({...s,[e.documentPath]:e.after},n.length===0?i:a.metadata.created_at),_=G({nowIso:i,author:e.author,op:e.idempotencyKey===void 0?e.op:`${e.op}:${e.idempotencyKey}`,before:a,after:d,message:e.message});return await Y(t,_),{entry:_,historyPath:t}}async function yr(e){let t=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await nt(e)}finally{await t()}}async function wr(e){let t=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let n=R(e.pmRoot),r=await I(n,C),o=N(r);o.ok||D(o.errors);let i=r.length===0?$:z(r),a=G({nowIso:H(),author:e.author,op:e.op,before:i,after:i,message:e.message,context:e.context});return await Y(n,a),{entry:a,historyPath:n}}finally{await t()}}async function rt(e,t){if(t===e.raw)return!1;let n=t===null?null:JSON.parse(t),r=JSON.parse(e.raw);await U(e.filePath,e.raw);try{(t!==null||e.recordCreation!==!1)&&await nt({pmRoot:e.pmRoot,documentPath:M.relative(e.pmRoot,e.filePath).replaceAll("\\","/"),before:n,after:r,op:e.op,idempotencyKey:e.idempotencyKey,author:e.author,lockTtlSeconds:e.lockTtlSeconds,lockWaitMs:e.lockWaitMs,message:e.message})}catch(o){throw t===null?await tt.rm(e.filePath,{force:!0}):await U(e.filePath,t),o}return!0}async function ot(e){let{documentPath:t}=ne(e.pmRoot,e.filePath),n=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let r=await E(e.filePath);if(e.dryRun===!0||e.idempotencyKey!==void 0){let i=await I(R(e.pmRoot),C),a=N(i);a.ok||D(a.errors);let s=F(i.length===0?$:z(i))[t];if(s!==void 0&&S(s)!==S(r===null?null:JSON.parse(r)))throw new h(`Workspace history state for "${t}" changed outside the audited mutation path.`,p.CONFLICT,{code:"workspace_history_state_conflict"});if(e.idempotencyKey!==void 0&&i.some(l=>l.op===`${e.op}:${e.idempotencyKey}`))return{changed:!1,result:void 0,replayed:!0}}let o=await e.mutate(r);return JSON.parse(o.raw),e.dryRun===!0?{changed:r!==o.raw,result:o.result}:{changed:await rt({...e,raw:o.raw},r),result:o.result}}finally{await n()}}async function kr(e){let t=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await rt(e,await E(e.filePath))}finally{await t()}}async function gr(e){let t=e.authorizationDecision.trim();if(!t)throw new TypeError("Workspace history reconciliation requires an authorization decision");let n=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let{documentPath:r,absolutePath:o}=ne(e.pmRoot,e.filePath),i=R(e.pmRoot),a=await I(i,C),s=N(a);s.ok||D(s.errors);let l=z(a),d=F(l);if(!Object.hasOwn(d,r))throw new TypeError(`Workspace history does not govern document ${r}`);let _=await E(o);if(_===null)throw new TypeError(`Workspace history document is missing: ${r}`);let f=JSON.parse(_);if(S(d[r])===S(f))return{changed:!1,historyPath:i};let w=H(),W=G({nowIso:w,author:e.author,op:e.op,before:l,after:we({...d,[r]:f},l.metadata.created_at),message:e.message,context:{reason:"out_of_band_workspace_state_reconciliation",document_path:r,authorization_decision:t}});return await Y(i,W),{changed:!0,entry:W,historyPath:i}}finally{await n()}}async function br(e){let t=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let{documentPath:n,absolutePath:r}=ne(e.pmRoot,e.filePath),o=await I(R(e.pmRoot),C),i=N(o);if(i.ok||D(i.errors),!Number.isInteger(e.targetVersion)||e.targetVersion<1||e.targetVersion>o.length)throw new TypeError(`Invalid workspace history target version: ${String(e.targetVersion)}`);let a=F(z(o,e.targetVersion))[n];if(a===void 0)throw new TypeError(`Workspace history version ${e.targetVersion} does not contain ${n}`);let s=await E(r),l=`${JSON.stringify(a,null,2)}
|
|
2
2
|
`;if(s===l)return{document_path:n,restored_from_version:e.targetVersion,changed:!1};let d=z(o),_=H(),f=G({nowIso:_,author:e.author,op:e.op,before:d,after:we({...F(d),[n]:a},d.metadata.created_at),message:e.message,context:{reason:"workspace_state_restore",document_path:n,restored_from_version:e.targetVersion,replaced_out_of_band_state:!0}});await U(r,l);try{await Y(R(e.pmRoot),f)}catch(w){throw s===null?await tt.rm(r,{force:!0}):await U(r,s),w}return{document_path:n,restored_from_version:e.targetVersion,changed:!0}}finally{await t()}}import{AsyncLocalStorage as Qt}from"node:async_hooks";import{lstat as Zt,realpath as pt}from"node:fs/promises";import ht from"node:path";function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ke(e,t,n,r=[]){if(x(e,t)&&(r.length>0||re(n)))return n;if(x(e,n)||x(t,n))return t;if((e===void 0||re(e))&&re(t)&&re(n)){let o=e??{},i=new Set([...Object.keys(o),...Object.keys(t),...Object.keys(n)]);return Object.fromEntries([...i].flatMap(a=>{let s=ke(Object.hasOwn(o,a)?o[a]:void 0,Object.hasOwn(t,a)?t[a]:void 0,Object.hasOwn(n,a)?n[a]:void 0,[...r,a]);return s===void 0?[]:[[a,s]]}))}throw new h(`Settings changed concurrently at ${r.join(".")||"<root>"}; read the latest settings and reapply the intended change.`,p.CONFLICT,{reason:"stale_settings_snapshot",required:"Read a fresh settings snapshot and reapply the intended change.",why:"Another writer changed the same setting after this snapshot was read.",examples:["pm config project export --json"],nextSteps:["Read the current settings, then retry the original config operation."]})}var Jt={Epic:2880,Feature:480,Story:480,Milestone:2880,Task:120,Issue:60,Bug:60,Chore:30,Decision:15,Plan:120},it=120;function ge(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function st(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n.toLowerCase(),r);return t}var Kt=st(Jt),at=new WeakMap;function Gt(e){let t=at.get(e);if(t)return t;let n=st(e);return at.set(e,n),n}function Or(e,t){let n=(e??"").trim().toLowerCase();if(n.length===0)return it;if(t){let o=Gt(t).get(n);if(ge(o))return Math.floor(o)}let r=Kt.get(n);return ge(r)?Math.floor(r):it}function be(e){let t={};if(e===null||typeof e!="object"||Array.isArray(e))return t;for(let[n,r]of Object.entries(e)){let o=n.trim();o.length===0||!ge(r)||(t[o]=Math.floor(r))}return t}import{stat as Yt}from"node:fs/promises";var oe=new Map;function ct(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}async function Xt(e){try{let t=await Yt(e);return{path:e,mtime_ms:t.mtimeMs,size:t.size}}catch{return{path:e,mtime_ms:null,size:null}}}async function O(e){let t=ct(e),n=await Promise.all(t.map(r=>Xt(r)));return n.sort((r,o)=>r.path.localeCompare(o.path)),n}function X(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],o=t[n];if(r.path!==o.path||r.mtime_ms!==o.mtime_ms||r.size!==o.size)return!1}return!0}function lt(e){return oe.get(e)}function ie(e,t){let n=ct(t.tracked_paths),r=[...t.signatures].map(o=>({path:o.path,mtime_ms:o.mtime_ms,size:o.size})).sort((o,i)=>o.path.localeCompare(i.path));oe.set(e,{tracked_paths:n,signatures:r,value:t.value})}function L(e){if(e){oe.delete(e);return}oe.clear()}var Ee=new Qt;async function Gr(e,t,n=()=>!0){let r=new Set([ht.resolve(e)]);try{r.add(await pt(e))}catch{}let o=!1,i=[r,()=>!o&&n()];try{return await Ee.run([...Ee.getStore()??[],i],t)}finally{o=!0}}function en(e){let t=ht.resolve(e);return Ee.getStore()?.some(([n,r])=>n.has(t)&&r())??!1}var tn="settings:write",yt=Symbol("pm.settings.persist_source"),wt=Symbol("pm.settings.fallback_origin"),kt=Symbol("pm.settings.fallback_baseline"),nn=128,rn=new Set(["off","advisory","strict"]);function dt(e){return structuredClone(Me[e])}function on(e){return e==="minimal"||e==="default"||e==="strict"||e==="custom"?e:c.governance.preset}var an=new Set(Ve);function gt(e){return an.has(e)}function ut(e,t){let n=typeof t.create_default_type=="string"?t.create_default_type.trim():void 0;return n&&n.length>0&&(e.create_default_type=n),(t.workflow_enforcement==="off"||t.workflow_enforcement==="warn"||t.workflow_enforcement==="strict")&&(e.workflow_enforcement=t.workflow_enforcement),gt(t.start_blocker_enforcement)&&(e.start_blocker_enforcement=t.start_blocker_enforcement),t.require_close_reason===!1&&(e.require_close_reason=!1),e.duplicate_detection_mode=t.duplicate_detection_mode,e.duplicate_detection_threshold=t.duplicate_detection_threshold,e.duplicate_detection_limit=t.duplicate_detection_limit,e}function sn(e){return e.preset==="custom"?ut({preset:"custom",ownership_enforcement:e.ownership_enforcement,create_mode_default:e.create_mode_default,close_validation_default:e.close_validation_default,parent_reference:e.parent_reference,metadata_profile:e.metadata_profile,force_required_for_stale_lock:e.force_required_for_stale_lock},e):ut({preset:e.preset},e)}function cn(e){let t=typeof e.create_default_type=="string"?e.create_default_type.trim():void 0,n={};t&&t.length>0&&(n.create_default_type=t),(e.workflow_enforcement==="off"||e.workflow_enforcement==="warn"||e.workflow_enforcement==="strict")&&(n.workflow_enforcement=e.workflow_enforcement),gt(e.start_blocker_enforcement)&&(n.start_blocker_enforcement=e.start_blocker_enforcement),typeof e.require_close_reason=="boolean"&&(n.require_close_reason=e.require_close_reason),rn.has(String(e.duplicate_detection_mode))&&(n.duplicate_detection_mode=e.duplicate_detection_mode);let r=e.duplicate_detection_threshold;[typeof r=="number",Number.isFinite(r),Number(r)>=0,Number(r)<=1].every(Boolean)&&(n.duplicate_detection_threshold=r);let o=e.duplicate_detection_limit;return[typeof o=="number",Number.isSafeInteger(o),Number(o)>=0,Number(o)<=20].every(Boolean)&&(n.duplicate_detection_limit=o),n}function bt(e){let t=e.governance??{},n=on(t.preset),r=cn(t);if(n==="custom"){let a=dt("default"),s=r.require_close_reason??a.require_close_reason;return{preset:n,ownership_enforcement:t.ownership_enforcement??a.ownership_enforcement,create_mode_default:t.create_mode_default??a.create_mode_default,close_validation_default:t.close_validation_default??a.close_validation_default,parent_reference:t.parent_reference??a.parent_reference,metadata_profile:t.metadata_profile??a.metadata_profile,force_required_for_stale_lock:t.force_required_for_stale_lock??a.force_required_for_stale_lock,...r,require_close_reason:s,duplicate_detection_mode:r.duplicate_detection_mode??a.duplicate_detection_mode,duplicate_detection_threshold:r.duplicate_detection_threshold??a.duplicate_detection_threshold,duplicate_detection_limit:r.duplicate_detection_limit??a.duplicate_detection_limit}}let o=dt(n),i=r.require_close_reason??o.require_close_reason;return{preset:n,...o,...r,require_close_reason:i}}function Te(){return structuredClone(c)}function xt(e){return e==="cache_only"||e==="semantic_configured"||e==="semantic_auto"?e:c.search.mutation_refresh_policy}function vt(e){return e==="auto"||e==="keyword"||e==="semantic"||e==="hybrid"?e:"auto"}function St(e){return typeof e=="boolean"?e:c.search.query_expansion.enabled}function Et(e){return typeof e!="string"?c.search.query_expansion.provider:e.trim()}function Ct(e){return typeof e=="boolean"?e:c.search.rerank.enabled}function Ot(e){return typeof e!="string"?c.search.rerank.model:e.trim()}function Tt(e){return typeof e=="number"&&Number.isFinite(e)&&Number.isInteger(e)&&e>0?e:c.search.rerank.top_k}function At(e){if(typeof e!="string")return c.vector_store.collection_name;let n=e.trim().replaceAll(/[^a-zA-Z0-9_-]/g,"_").slice(0,nn);return n.length>0?n:c.vector_store.collection_name}function xe(e){return{present:Array.isArray(e),values:Array.isArray(e)?structuredClone(e):[]}}function Pt(e,t){let n=e.schema,r=xe(n?.statuses),o=xe(n?.fields),i=xe(n?.type_workflows);return{persisted_settings:structuredClone(e),source_settings:structuredClone(e),has_source_item_type_definitions:Array.isArray(e.item_types?.definitions),source_item_type_definitions:V(e.item_types?.definitions),has_source_schema_statuses:r.present,source_schema_statuses:r.values,has_source_schema_fields:o.present,source_schema_fields:o.values,has_source_schema_type_workflows:i.present,source_schema_type_workflows:i.values,runtime_item_type_definitions:V(t.item_types?.definitions),runtime_schema_statuses:structuredClone(t.schema.statuses),runtime_schema_fields:structuredClone(t.schema.fields),runtime_schema_type_workflows:structuredClone(t.schema.type_workflows??[])}}function ce(e,t){Object.defineProperty(e,yt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function Ae(e){let t=e[yt];if(!(!t||typeof t!="object"))return t}function Yr(e){let t=Ae(e);if(t){let n=structuredClone(t);n.source_settings.item_format=e.item_format,ce(e,n)}}function ae(e){let t=structuredClone(e.settings),n=Ae(e.settings);n&&ce(t,n);let r=Pe(e.settings);return r!==void 0&&jt(t,r),{settings:t,metadata:{has_explicit_item_format:e.metadata.has_explicit_item_format},warnings:[...e.warnings]}}function ln(e,t,n){let r=J(t);return[n,K(e,r.files.types,B.types),K(e,r.files.statuses,B.statuses),K(e,r.files.fields,B.fields),K(e,r.files.workflows,B.workflows)]}async function dn(e,t,n){let r=await O(t);ie(e,{tracked_paths:t,signatures:r,value:ae(n)})}async function un(e,t,n){try{await dn(e,t,n)}catch{L(e)}}function _t(e,t){return e.find(n=>n.path===t)}function _n(e,t,n){for(let r of n){let o=_t(e,r),i=_t(t,r);if(!o||!i||!X([o],[i]))return!1}return!0}async function ve(e,t,n,r,o){try{let i=await O(t);if(!_n(r,i,o)){L(e);return}ie(e,{tracked_paths:t,signatures:i,value:ae(n)})}catch{L(e)}}function fn(e,t){let n=J(e.schema),r=V(e.item_types?.definitions);if(!t)return{item_type_definitions:r,schema_statuses:n.statuses,schema_fields:n.fields,schema_type_workflows:n.type_workflows};let o=n.type_workflows??[],i=x(r,t.runtime_item_type_definitions),a=x(n.statuses,t.runtime_schema_statuses),s=x(n.fields,t.runtime_schema_fields),l=x(o,t.runtime_schema_type_workflows);return{item_type_definitions:i?t.has_source_item_type_definitions?V(t.source_item_type_definitions):[]:r,schema_statuses:a?t.has_source_schema_statuses?structuredClone(t.source_schema_statuses):[]:n.statuses,schema_fields:s?t.has_source_schema_fields?structuredClone(t.source_schema_fields):[]:n.fields,schema_type_workflows:l?t.has_source_schema_type_workflows?structuredClone(t.source_schema_type_workflows):void 0:n.type_workflows}}function jt(e,t){Object.defineProperty(e,wt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function Xr(e){return Pe(e)!==void 0}function Pe(e){let t=e[wt];return typeof t=="string"?t:void 0}function mn(e){return e[kt]}function pn(e,t){Object.defineProperty(e,kt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function v(e){let t=Te();return e!==void 0&&jt(t,e),{settings:t,metadata:{has_explicit_item_format:!1},warnings:e?[e]:[]}}function It(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e.item_format;return t==="toon"||t==="json_markdown"}function Ce(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Nt(e){let t=c.agent_guidance,n=e?.template_version;return{prompt_completed:e?.prompt_completed===!0,declined:e?.declined===!0,declined_at:typeof e?.declined_at=="string"?e.declined_at:t.declined_at,template_version:typeof n=="number"&&Number.isInteger(n)&&n>0?n:t.template_version,last_checked_files:Ce(e?.last_checked_files??t.last_checked_files)}}function b(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function hn(e){return e==="off"||e==="warn"||e==="enforce"?e:c.extensions.policy.mode}function yn(e){return e==="off"||e==="warn"||e==="enforce"?e:c.extensions.policy.trust_mode}function Rt(e){return e==="none"||e==="restricted"||e==="strict"?e:c.extensions.policy.default_sandbox_profile}function wn(e){let t=e.name.trim().toLowerCase();if(t.length===0)return null;let n={name:t};e.disabled===!0&&(n.disabled=!0),e.require_trusted===!0&&(n.require_trusted=!0),e.require_provenance===!0&&(n.require_provenance=!0),e.sandbox_profile!==void 0&&(n.sandbox_profile=Rt(e.sandbox_profile));let r=b(e.allowed_capabilities),o=b(e.blocked_capabilities),i=b(e.allowed_surfaces),a=b(e.blocked_surfaces),s=b(e.allowed_commands),l=b(e.blocked_commands),d=b(e.allowed_actions),_=b(e.blocked_actions),f=b(e.allowed_services),w=b(e.blocked_services);return r.length>0&&(n.allowed_capabilities=r),o.length>0&&(n.blocked_capabilities=o),i.length>0&&(n.allowed_surfaces=i),a.length>0&&(n.blocked_surfaces=a),s.length>0&&(n.allowed_commands=s),l.length>0&&(n.blocked_commands=l),d.length>0&&(n.allowed_actions=d),_.length>0&&(n.blocked_actions=_),f.length>0&&(n.allowed_services=f),w.length>0&&(n.blocked_services=w),n}function kn(e){let t=new Map;for(let n of e??[]){let r=wn(n);r&&t.set(r.name,r)}return[...t.values()].sort((n,r)=>n.name.localeCompare(r.name))}function Se(e){return e==="block"||e==="warn"?e:void 0}function gn(e){if(typeof e=="string")return Se(e);if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=Se(e.global),n=Se(e.project);return t===void 0&&n===void 0?void 0:{...t!==void 0?{global:t}:{},...n!==void 0?{project:n}:{}}}}function k(e,t){return b(e?.[t]??c.extensions.policy[t])}function zt(e){let t=gn(e?.pm_max_version_exceeded_mode);return{mode:hn(e?.mode),trust_mode:yn(e?.trust_mode),...t!==void 0?{pm_max_version_exceeded_mode:t}:{},require_provenance:e?.require_provenance===!0,trusted_extensions:k(e,"trusted_extensions"),default_sandbox_profile:Rt(e?.default_sandbox_profile),allowed_extensions:k(e,"allowed_extensions"),blocked_extensions:k(e,"blocked_extensions"),allowed_capabilities:k(e,"allowed_capabilities"),blocked_capabilities:k(e,"blocked_capabilities"),allowed_surfaces:k(e,"allowed_surfaces"),blocked_surfaces:k(e,"blocked_surfaces"),allowed_commands:k(e,"allowed_commands"),blocked_commands:k(e,"blocked_commands"),allowed_actions:k(e,"allowed_actions"),blocked_actions:k(e,"blocked_actions"),allowed_services:k(e,"allowed_services"),blocked_services:k(e,"blocked_services"),extension_overrides:kn(e?.extension_overrides??c.extensions.policy.extension_overrides)}}function Lt(e){return[...new Set((e??[]).map(n=>n.trim().toLowerCase().replaceAll("-","_")))].filter(n=>n.length>0).sort((n,r)=>n.localeCompare(r)).filter(n=>["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"].includes(n))}function T(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function m(e,t){return e===void 0?t:e}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function Oe(e){return Array.isArray(e)?e:[]}function bn(e,t,n){return{...t.validation,...e.validation,parent_reference:n.parent_reference,metadata_profile:n.metadata_profile,metadata_required_fields:Lt(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:T(e.validation?.lifecycle_stale_blocker_reason_patterns??t.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:T(e.validation?.lifecycle_closure_like_blocked_reason_patterns??t.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:T(e.validation?.lifecycle_closure_like_resolution_patterns??t.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:T(e.validation?.lifecycle_closure_like_actual_result_patterns??t.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:be(e.validation?.estimate_defaults_by_type)}}function xn(e,t){return{enabled:e.telemetry?.enabled??t.telemetry.enabled,first_run_prompt_completed:e.telemetry?.first_run_prompt_completed??t.telemetry.first_run_prompt_completed,capture_level:e.telemetry?.capture_level??t.telemetry.capture_level,endpoint:e.telemetry?.endpoint??t.telemetry.endpoint,installation_id:e.telemetry?.installation_id??t.telemetry.installation_id,retention_days:e.telemetry?.retention_days??t.telemetry.retention_days}}function vn(e,t){return{...t.search,...e.search,default_mode:vt(e.search?.default_mode),mutation_refresh_policy:xt(e.search?.mutation_refresh_policy),query_expansion:{...t.search.query_expansion,...e.search?.query_expansion,enabled:St(e.search?.query_expansion?.enabled),provider:Et(e.search?.query_expansion?.provider)},rerank:{...t.search.rerank,...e.search?.rerank,enabled:Ct(e.search?.rerank?.enabled),model:Ot(e.search?.rerank?.model),top_k:Tt(e.search?.rerank?.top_k)}}}function Sn(e,t){return{adapter:e.vector_store.adapter??t.vector_store.adapter,collection_name:At(e.vector_store.collection_name),qdrant:{...t.vector_store.qdrant,...e.vector_store.qdrant},lancedb:{...t.vector_store.lancedb,...e.vector_store.lancedb}}}function En(e,t){return e.item_format==="json_markdown"?"toon":e.item_format??t.item_format}function Cn(e,t){return{default_depth:e.context?.default_depth??t.context.default_depth,activity_limit:e.context?.activity_limit??t.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??t.context.stale_threshold_days,next_ranking_policy:e.context?.next_ranking_policy??t.context.next_ranking_policy,sections:{...t.context.sections,...e.context?.sections}}}function On(e,t){return{openai:{...t.providers.openai,...e.providers.openai},ollama:{...t.providers.ollama,...e.providers.ollama}}}async function Tn(e,t){let n=await He(e,t.schema);return{settings:{...t,item_types:{definitions:V([...t.item_types.definitions,...Oe(n.type_definitions_from_file)])},schema:n.schema},warnings:n.warnings}}function V(e){let t=(e??[]).map(r=>We(r)).filter(r=>r!==null),n=new Map;for(let r of t)n.set(r.name.toLowerCase(),r);return[...n.values()].sort((r,o)=>r.name.localeCompare(o.name))}function se(e){let t=Te(),n=bt({governance:e.governance??{preset:"default"}});return{...t,...e,item_format:En(e,t),locks:{...t.locks,...e.locks},ids:{...t.ids,...e.ids},agent_identity:structuredClone(e.agent_identity??t.agent_identity),mutation_guard:{...t.mutation_guard,...e.mutation_guard},checkpoints:{...t.checkpoints,...e.checkpoints},output:{...t.output,...e.output},ux:{...t.ux,...e.ux},history:{...t.history,...e.history,compact_policy:{...t.history.compact_policy,...e.history?.compact_policy}},validation:bn(e,t,n),governance:n,workflow:{definition_of_done:[...e.workflow?.definition_of_done??t.workflow.definition_of_done]},testing:{record_results_to_items:e.testing?.record_results_to_items??t.testing.record_results_to_items,allow_untrusted_linked_tests:e.testing?.allow_untrusted_linked_tests??t.testing.allow_untrusted_linked_tests},telemetry:xn(e,t),agent_guidance:Nt(e.agent_guidance??t.agent_guidance),item_types:{definitions:V(e.item_types?.definitions)},schema:J(e.schema??t.schema),context:Cn(e,t),extensions:{enabled:[...e.extensions.enabled],disabled:[...e.extensions.disabled],policy:zt(e.extensions.policy??t.extensions.policy)},search:vn(e,t),providers:On(e,t),vector_store:Sn(e,t)}}function An(e){e.agent_identity=u(e.agent_identity,["probes_enabled","identity_vocabulary","harness_signals"]);let t=e.agent_identity;Object.hasOwn(t,"identity_vocabulary")&&(t.identity_vocabulary=u(g(t.identity_vocabulary),["version","aliases"])),e.agent_identity.harness_signals=Oe(e.agent_identity.harness_signals).map(n=>u(g(n),["harness","environment_keys","model_environment_keys","session_environment_keys","provenance_environment_keys","provenance_resolvers","provenance_unavailable_dimensions","argv_markers","client_names"])),e.locks=u(e.locks,["ttl_seconds","wait_ms"]),e.ids=u(e.ids,["token_length"]),e.mutation_guard=u(e.mutation_guard,["require_attributed_author","secret_guard","stale_in_progress_hours"]),e.checkpoints=u(e.checkpoints,["retention_days"]),e.output=u(e.output,["default_format"]),e.ux=u(e.ux,["deprecation_hints"]),e.history=u(e.history,["missing_stream","compact_policy"]),e.validation=u(e.validation,["sprint_release_format","parent_reference","metadata_profile","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns","estimate_defaults_by_type"]),e.governance=u(e.governance,["preset","ownership_enforcement","create_mode_default","close_validation_default","require_close_reason","parent_reference","metadata_profile","force_required_for_stale_lock","create_default_type","workflow_enforcement","duplicate_detection_mode","duplicate_detection_threshold","duplicate_detection_limit"]),e.workflow=u(e.workflow,["definition_of_done"]),e.testing=u(e.testing,["record_results_to_items","allow_untrusted_linked_tests"]),e.telemetry=u(e.telemetry,["enabled","first_run_prompt_completed","capture_level","endpoint","installation_id","retention_days"]),e.agent_guidance=u(e.agent_guidance,["prompt_completed","declined","declined_at","template_version","last_checked_files"]),e.item_types=u(e.item_types,["definitions"]),e.schema=u(e.schema,["version","files","statuses","fields","workflow","type_workflows","unknown_field_policy"]),e.schema.files=u(g(e.schema.files),["types","statuses","fields","workflows"]),e.schema.workflow=u(g(e.schema.workflow),["draft_status","open_status","in_progress_status","blocked_status","close_status","canceled_status"]),e.context=u(e.context,["default_depth","activity_limit","stale_threshold_days","next_ranking_policy","sections"]),e.context.sections=u(g(e.context.sections),["hierarchy","activity","progress","blockers","files","workload","staleness","tests"]),e.extensions=u(e.extensions,["enabled","disabled","policy"]),e.extensions.policy=u(g(e.extensions.policy),["mode","trust_mode","pm_max_version_exceeded_mode","require_provenance","trusted_extensions","default_sandbox_profile","allowed_extensions","blocked_extensions","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services","extension_overrides"]),e.extensions.policy.extension_overrides=Oe(e.extensions.policy.extension_overrides).map(n=>u(g(n),["name","disabled","require_trusted","require_provenance","sandbox_profile","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services"])),e.search=u(e.search,["score_threshold","hybrid_semantic_weight","max_results","embedding_model","embedding_corpus_max_characters","embedding_batch_size","embedding_timeout_ms","scanner_max_batch_retries","provider","default_mode","mutation_refresh_policy","query_expansion","rerank"]),e.search.query_expansion=u(g(e.search.query_expansion),["enabled","provider"]),e.search.rerank=u(g(e.search.rerank),["enabled","model","top_k"]),e.providers=u(e.providers,["openai","ollama"]),e.providers.openai=u(g(e.providers.openai),["base_url","api_key","model"]),e.providers.ollama=u(g(e.providers.ollama),["base_url","model"]),e.vector_store=u(e.vector_store,["adapter","collection_name","qdrant","lancedb"]),e.vector_store.qdrant=u(g(e.vector_store.qdrant),["url","api_key"]),e.vector_store.lancedb=u(g(e.vector_store.lancedb),["path"])}function Pn(e){return{...e,locks:m(e.locks,c.locks),ids:m(e.ids,c.ids),agent_identity:m(e.agent_identity,c.agent_identity),mutation_guard:m(e.mutation_guard,c.mutation_guard),checkpoints:m(e.checkpoints,c.checkpoints),output:m(e.output,c.output),ux:m(e.ux,c.ux),history:m(e.history,c.history),validation:m(e.validation,c.validation),workflow:m(e.workflow,c.workflow),testing:m(e.testing,c.testing),telemetry:m(e.telemetry,c.telemetry),agent_guidance:m(e.agent_guidance,c.agent_guidance),item_types:m(e.item_types,c.item_types),schema:m(e.schema,c.schema),context:m(e.context,c.context),extensions:m(e.extensions,c.extensions),search:m(e.search,c.search),providers:m(e.providers,c.providers),vector_store:m(e.vector_store,c.vector_store)}}function jn(e,t){return{...e.validation,parent_reference:t.parent_reference,metadata_profile:t.metadata_profile,metadata_required_fields:Lt(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:T(e.validation?.lifecycle_stale_blocker_reason_patterns??c.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:T(e.validation?.lifecycle_closure_like_blocked_reason_patterns??c.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:T(e.validation?.lifecycle_closure_like_resolution_patterns??c.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:T(e.validation?.lifecycle_closure_like_actual_result_patterns??c.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:be(e.validation?.estimate_defaults_by_type)}}function In(e){return{...c.search,...e.search,default_mode:vt(e.search?.default_mode),mutation_refresh_policy:xt(e.search?.mutation_refresh_policy),query_expansion:{...c.search.query_expansion,...e.search?.query_expansion,enabled:St(e.search?.query_expansion?.enabled),provider:Et(e.search?.query_expansion?.provider)},rerank:{...c.search.rerank,...e.search?.rerank,enabled:Ct(e.search?.rerank?.enabled),model:Ot(e.search?.rerank?.model),top_k:Tt(e.search?.rerank?.top_k)}}}function Nn(e){return{default_depth:e.context?.default_depth??c.context.default_depth,activity_limit:e.context?.activity_limit??c.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??c.context.stale_threshold_days,next_ranking_policy:e.context?.next_ranking_policy??c.context.next_ranking_policy,sections:{...c.context.sections,...e.context?.sections}}}function Rn(e){return{...e.vector_store,adapter:e.vector_store?.adapter??c.vector_store.adapter,collection_name:At(e.vector_store?.collection_name),qdrant:{...e.vector_store?.qdrant},lancedb:{...e.vector_store?.lancedb}}}function zn(e,t,n,r){return{...e,item_format:"toon",validation:jn(e,t),governance:t,agent_guidance:Nt(e.agent_guidance),item_types:{definitions:r.item_type_definitions},schema:{...n,statuses:r.schema_statuses,fields:r.schema_fields,type_workflows:r.schema_type_workflows},search:In(e),context:Nn(e),extensions:{enabled:Ce(e.extensions?.enabled),disabled:Ce(e.extensions?.disabled),policy:zt(e.extensions?.policy)},vector_store:Rn(e)}}function qt(e,t){for(let n of Object.keys(t)){let r=Reflect.get(t,n),o=e[n];typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?qt(o,r):e[n]=structuredClone(r)}}function je(e,t,n){let r=new Set([...Object.keys(t),...Object.keys(n)]);for(let o of r){let i=t[o],a=n[o];if(!x(i,a)){if(a===void 0){delete e[o];continue}if(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof a=="object"&&a!==null&&!Array.isArray(a)){let s=e[o],l=typeof s=="object"&&s!==null&&!Array.isArray(s)?s:{};je(l,i,a),Object.keys(l).length>0?e[o]=l:delete e[o];continue}e[o]=structuredClone(a)}}}var le=["version","id_prefix","ids","author_default","agent_identity","mutation_guard","item_format","locks","checkpoints","output","ux","history","validation","governance","workflow","testing","telemetry","agent_guidance","item_types","schema","context","extensions","search","providers","vector_store"];function ft(e,t){let n=Pn(e),r=bt(n),o=J(n.schema),i=fn(n,t),a=zn(n,r,o,i),s=u({...a,governance:sn(r)},le);return An(s),s}function Mt(e,t={}){let n=t.source===void 0?t.persist_source:Pt(t.source.validated,se(t.source.validated)),r=ft(e,n);if(n){let o=se(n.source_settings);o.item_types={definitions:structuredClone(n.runtime_item_type_definitions)},o.schema={...o.schema,statuses:structuredClone(n.runtime_schema_statuses),fields:structuredClone(n.runtime_schema_fields),type_workflows:structuredClone(n.runtime_schema_type_workflows)};let i=ft(o,n);t.source!==void 0&&qt(i,t.source.validated);let a=structuredClone(t.source===void 0?n.source_settings:t.source.raw);return je(a,i,r),`${JSON.stringify(u(a,le),null,2)}
|
|
3
3
|
`}return`${JSON.stringify(r,null,2)}
|
|
4
4
|
`}async function Ln(e){let t;try{t=await pt(e)}catch(s){if(ee(s))return v();throw s}let n=q(t),r;try{r=await Zt(n)}catch(s){if(ee(s))return v();throw s}if(!r.isFile())throw ye("settings.json");let o;try{o=await De(n,ye("settings.json"))}catch(s){if(ee(s))return v();throw s}let i;try{i=JSON.parse(o)}catch{return v("settings_read_invalid_json")}let a=te(i);return a.success?{settings:se(a.data),metadata:{has_explicit_item_format:It(i)},warnings:a.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[]}:v("settings_read_invalid_schema")}async function Ft(e){if(en(e))return Ln(e);let t=q(e),n=[t];await Ze({path:t,scope:"project"});let r=lt(e);if(r){let d=await O(r.tracked_paths);if(X(d,r.signatures))return ae(r.value)}let o=await O([t]),i;try{i=await E(t)}catch{return v("settings_read_fs_error")}if(i===null){let d=v();return await ve(e,[t],d,o,[t]),d}let a=await O([t]);if(!X(o,a))return L(e),Ft(e);let s;try{s=JSON.parse(i)}catch{let d=v("settings_read_invalid_json");return await ve(e,[t],d,a,[t]),d}let l=te(s);if(!l.success){let d=v("settings_read_invalid_schema");return await ve(e,[t],d,a,[t]),d}try{let d=se(l.data),_=ln(e,d.schema,t);n=_;let f=await O(_),w=await Tn(e,d),W=await O(_),he=w.settings;ce(he,Pt(l.data,he));let qe={settings:he,metadata:{has_explicit_item_format:It(s)},warnings:[...l.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[],...w.warnings]};return X(f,W)?ie(e,{tracked_paths:_,signatures:W,value:ae(qe)}):L(e),qe}catch{let d=v("settings_read_merge_failed");return await un(e,n,d),d}}function qn(e,t=[],n=null){let r=Ie(n)??{},o=t.filter(a=>!Object.hasOwn(r,a));if(o.length===0)return e;let i=JSON.parse(e);for(let a of o)Reflect.deleteProperty(i,a);return`${JSON.stringify(i,null,2)}
|
|
@@ -6,4 +6,4 @@ import{a as et,b as te}from"./chunk-3AZOATC2.js";import{$b as Xe,Ib as Ke,Nb as
|
|
|
6
6
|
`}function Un(e){try{return JSON.parse(e)}catch{throw new h("Existing settings.json is malformed; the settings write was refused.",p.USAGE,{code:"settings_write_invalid_existing_json",reason:"existing_settings_json_malformed",why:"Writing defaults over malformed settings could destroy intended project configuration.",nextSteps:["Repair the syntax in .agents/pm/settings.json, then retry the original command.","Run pm health to confirm the settings warning has cleared."]})}}async function Qr(e){return(await Ft(e)).settings}async function Zr(e,t,n=tn,r={}){let o=r.assignedPaths??[];Dn(o);let i=q(e),a=Ae(t),s=a?void 0:Pe(t),l=Mt(t,{persist_source:a}),d=JSON.parse(l),_=!1;try{if(await ot({pmRoot:e,filePath:i,mutate:f=>{let w=f===null?null:Un(f);return f!==null&&r.skipIfStored?.(w)===!0?(_=!0,{raw:f,result:void 0}):s!==void 0&&f!==null?{raw:$n(w,d,s,o,mn(t)),result:void 0}:{raw:a?`${JSON.stringify(u(ke(a.persisted_settings,d,w),le),null,2)}
|
|
7
7
|
`:qn(l,r.omitSections,w),result:void 0}},op:n,author:Ke(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),_)return;a?ce(t,{...a,persisted_settings:structuredClone(d)}):s!==void 0&&pn(t,structuredClone(d)),await Qe({path:i,scope:"project",op:n})}finally{L(e)}}import Vt from"node:fs";import Q from"node:path";import{createRequire as Hn}from"node:module";var Z="@unbrained/pm-cli",Bn=new Set(["append","claim","changelog","close","close-many","close-task","comments","config","copy","create","dedupe-merge","delete","deps","docs","extension","event","events","files","focus","gc","history-author-acknowledge","history-compact","history-redact","history-repair","init","install","item","learnings","meet","merge","normalize","notes","package","packages","pause-task","plan","profile","reindex","release","remind","restore","schema","start-task","test","test-all","test-runs","test-runs-worker","telemetry","templates","twin","update","update-many","upgrade","vcs","workspace"]),Wt=new Set(["--author","--expect-hash","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),Re=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,fe="2026.8.31";function y(e,t){return e.some(n=>t.includes(n.split("=",1)[0]))}function Ne(e,t){return["activate","adopt","adopt-all","deactivate","init","install","migrate","reload","uninstall"].includes(t[0]??"")||y(e,["--activate","--adopt","--adopt-all","--deactivate","--fix-managed-state","--init","--install","--output","--reload","--scaffold","--uninstall"])}var Jn={changelog:(e,t)=>{if(t[0]==="generate")return!y(e,["--check"]);let n=e.indexOf("export");return t[0]==="export"&&(y(e,["--output"])||n>=0&&e[n+1]!==void 0&&!e[n+1].startsWith("-"))},comments:e=>y(e,["--add","--delete","--edit","--file","--stdin"]),config:(e,t)=>(t[0]==="project"||t[0]==="global"?t[1]:t[0])==="set",deps:()=>!1,docs:e=>y(e,["--add","--add-glob","--migrate","--remove"]),duplicates:()=>!1,events:()=>!1,extension:Ne,files:(e,t)=>y(e,["--add","--add-glob","--migrate","--remove"])||t[0]==="discover"&&y(e,["--apply"]),health:e=>!y(e,["--check-only","--no-refresh","--skip-vectors"]),learnings:e=>y(e,["--add","--delete","--edit","--file","--stdin"]),merge:(e,t)=>t[0]!=="report",notes:e=>y(e,["--add","--delete","--edit","--file","--stdin"]),package:Ne,packages:Ne,profile:(e,t)=>t[0]==="apply",schema:(e,t)=>["add-field","add-status","add-type","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type"].includes(t[0]??"")&&!(y(e,["--infer"])&&!y(e,["--apply"])),telemetry:(e,t)=>t.slice(0,2).some(n=>["clear","flush"].includes(n)),templates:(e,t)=>t[0]==="save",test:e=>y(e,["--update","--update-index","--add","--add-json","--background","--measure","--remove","--resume","--run","--stop"]),validate:e=>y(e,["--auto-fix","--prune-missing"]),vcs:(e,t)=>["abandon","create","merge","propose","ref-create"].includes(t[0]??""),workspace:(e,t)=>t[0]==="snapshot"&&["create","delete","restore"].includes(t[1]??"")};function ue(e){let t=e.match(Re);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]??0)]:null}function A(e,t){let n=ue(e),r=ue(t);if(!n||!r)return null;for(let o=0;o<n.length;o+=1){let i=n[o]-r[o];if(i!==0)return Math.sign(i)}return 0}function de(e){return A(e,fe)!==-1?3:2}function Kn(e,t){if(t===3)return e.filter(n=>n.history_epoch_compatible===!1).map(n=>({...n,declaration:n.declaration??n.version})).sort((n,r)=>A(n.version,r.version))[0]}function _e(e){try{let t=JSON.parse(Vt.readFileSync(e,"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Gn(e){let t=[...e.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(r=>({inclusive:r[1]==="<=",version:r[2]})),n=e.match(/\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?\s+-\s+v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/u);return n?[...t,{inclusive:!0,version:n[1]}]:t}function Yn(e){let t=e.split("||").map(n=>Gn(n));return{bounded:t.some(n=>n.length>0),compatible:t.some(n=>n.every(r=>{let o=A(fe,r.version);return o!==null&&(r.inclusive?o!==1:o===-1)}))}}function $t(e){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(t=>{let n=e[t];if(typeof n!="object"||n===null)return[];let r=n[Z];return typeof r=="string"?[r.trim()]:[]})}function Xn(e){return $t(e).flatMap(t=>{let n=/^[<!]/u.test(t)?void 0:t.match(Re)?.[0];if(!n)return[];let r=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(t),o=Yn(t);return[{version:n,constraint:r?"exact":o.bounded?"range":"minimum",...r?{}:{declaration:t},history_epoch_compatible:r?A(n,fe)!==-1:o.compatible}]})}function Qn(e){let n=_e(Q.join(e,"package-lock.json"))?.packages;if(typeof n!="object"||n===null)return;let r=n["node_modules/@unbrained/pm-cli"];if(typeof r!="object"||r===null)return;let o=r.version;return typeof o=="string"?o:void 0}function Zn(e,t){try{let n=Vt.readFileSync(Q.join(e,t),"utf8").split(/\r?\n/u),r=n.findIndex(l=>l.includes(Z));if(r<0)return;let o=n[r].match(/^\s*/u)[0].length,i=[n[r]];for(let l=r+1;l<n.length;l+=1){let d=n[l],_=d.trim(),f=d.match(/^\s*/u)[0].length;if(_.length>0&&f<=o)break;i.push(d)}return i.join(`
|
|
8
8
|
`).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??i[0].match(Re)?.[0]}catch{return}}function Ut(e){let t=[],n=_e(Q.join(e,"package.json"));n&&t.push(...Xn(n).map(a=>({...a,source:"package.json"})));let o=_e(Q.join(e,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof o=="string"&&ue(o)&&t.push({version:o,source:"installed-package",constraint:"exact",history_epoch_compatible:de(o)===3});let i=Qn(e);i&&ue(i)&&t.push({version:i,source:"package-lock.json",constraint:"exact",history_epoch_compatible:de(i)===3});for(let a of["pnpm-lock.yaml","yarn.lock"]){let s=Zn(e,a);s&&t.push({version:s,source:a,constraint:"exact",history_epoch_compatible:de(s)===3})}return t}function er(e,t){if(t<=1)return;let{minVersion:n,lt:r}=Hn(import.meta.url)("semver"),o=$t(_e(Q.join(e,"package.json"))??{}).find(a=>{try{let s=n(a);return s!==null&&r(s,"2026.10.10")}catch{return!1}}),i=o===void 0?Ut(e).find(a=>A(a.version,"2026.10.10")===-1):{version:o,source:"package.json"};if(i)throw new h(`The project selects pm ${i.version}, which cannot safely refuse item format ${t}.`,p.CONFLICT,{code:"project_runtime_item_format_incompatible",reason:i.source,required:"Upgrade project pins, installed SDKs, CI hosts and Git merge drivers before writing guarded item formats.",nextSteps:["Use a pm runtime supporting the required item format throughout the project; preserve original item and history bytes, and never re-anchor history to satisfy an older host."]})}function co(e,t){let n=Je(e);n<=1||(er($e(t),n),e.pm_format_version=n)}function Ht(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(Wt.has(n)){t+=1;continue}if(!n.startsWith("-"))return{command:n.toLowerCase(),index:t}}}function tr(e){let t=Ht(e);if(!t||y(e,["--help","-h","--dry-run"]))return!1;let{command:n,index:r}=t,o=[];for(let a=r+1;a<e.length;a+=1){let s=e[a];if(Wt.has(s)){a+=1;continue}s.startsWith("-")||o.push(s.toLowerCase())}let i=Jn[n];return i?i(e,o):Bn.has(n)}function nr(e){let t=Ht(e.argv)?.command,n=tr(e.argv),r=Ut(e.projectRoot).filter(_=>A(_.version,e.executingVersion)!==null).sort((_,f)=>A(f.version,_.version)),o=r[0],i=o!==void 0&&A(e.executingVersion,o.version)===-1,a=de(e.executingVersion),s=Kn(r,a),l=n&&s!==void 0,d=i&&!n?{code:"project_runtime_stale_read",executing_version:e.executingVersion,project_version:o.version,source:o.source,message:"This read is using an older pm runtime than the project requires.",next_steps:[`Run the command through the project's installed ${Z} ${o.version}.`,"Install the project dependencies with its declared package manager if the local executable is missing."]}:void 0;return{compatible:!n||!i&&!l||e.allowStale===!0,executing_version:e.executingVersion,...o?{project_version:o.version,source:o.source}:{},...t?{command:t}:{},mutating:n,stale:i,history_epoch_incompatible:l,writer_item_hash_version:a,...s?{incompatible_project_version:s.declaration,incompatible_source:s.source}:{},...d?{warning:d}:{},override_applied:n&&(i||l)&&e.allowStale===!0}}function lo(e){let t=nr(e);if(t.compatible)return t;throw t.history_epoch_incompatible?new h(`pm ${t.executing_version} cannot write item-hash epoch ${t.writer_item_hash_version} into a project pinned to pm ${t.incompatible_project_version}.`,p.CONFLICT,{code:"project_runtime_history_epoch_incompatible",reason:t.incompatible_source,why:`The pinned runtime cannot read item_hash_version ${t.writer_item_hash_version}; allowing the write would break its health and validation gates.`,nextSteps:[`Upgrade the project's ${Z} pin to ${fe} or newer before mutating tracker history.`,"For an intentional coordinated migration only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]}):new h(`pm ${t.executing_version} cannot mutate a project pinned to newer pm ${t.project_version}.`,p.CONFLICT,{code:"project_runtime_stale_mutation",reason:t.source,why:"An older runtime can write storage, history, and merge contracts it does not understand.",nextSteps:[`Run this command through the project's installed ${Z} ${t.project_version}.`,"For an intentional recovery only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]})}import Le from"node:fs/promises";import me from"node:path";function P(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function Bt(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:Ue(t),suggested_retry_args:t}}function pe(e){return new h(`Tracker root is not a directory at ${e}.`,p.USAGE,{code:"tracker_root_not_directory",reason:"not_a_directory",resolved_path:e,nextSteps:["Pass a tracker directory, usually <workspace>/.agents/pm, rather than a file path."]})}function ze(e){return new h(`Tracker root is not readable at ${e}.`,p.GENERIC_FAILURE,{code:"tracker_root_unreadable",reason:"unreadable",resolved_path:e,nextSteps:["Grant read and directory-search permission to the tracker root, then retry."]})}async function rr(e){let t=me.resolve(e),n=me.parse(t).root,r=me.dirname(t);for(;r!==n;){let o;try{o=await Le.stat(r)}catch(i){if(P(i,"ENOTDIR"))throw pe(e);if(!P(i,"ENOENT"))throw i;r=me.dirname(r);continue}if(!o.isDirectory())throw pe(e);return}}async function or(e){let t;try{t=await Le.stat(e)}catch(n){throw P(n,"ENOENT")?(await rr(e),new h(`Tracker is not initialized at ${e}. Tracker root does not exist. Run pm init first.`,p.NOT_FOUND,{code:"tracker_root_missing",reason:"missing",resolved_path:e,nextSteps:["Confirm the tracker root path or initialize it with the emitted retry."],recovery:Bt(e)})):P(n,"ENOTDIR")?pe(e):P(n,"EACCES")||P(n,"EPERM")?ze(e):n}if(!t.isDirectory())throw pe(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw ze(e);try{await(await Le.opendir(e)).close()}catch(n){throw P(n,"EACCES")||P(n,"EPERM")?ze(e):n}}async function ko(e){if(await or(e),!await Fe(q(e)))throw new h(`Tracker is not initialized at ${e}. Run pm init first.`,p.NOT_FOUND,{code:"tracker_not_initialized",reason:"settings_missing",resolved_path:e,nextSteps:["Initialize the selected tracker root with the emitted retry."],recovery:Bt(e)})}export{C as a,R as b,hr as c,yr as d,wr as e,ot as f,kr as g,gr as h,br as i,Or as j,L as k,Gr as l,en as m,bt as n,Yr as o,Xr as p,Tn as q,se as r,Mt as s,Ft as t,Qr as u,Zr as v,fe as w,A as x,de as y,Ut as z,er as A,co as B,tr as C,nr as D,lo as E,Bt as F,or as G,ko as H};
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-KXTKLDKD.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{I as m,J as C,K as w,L as y,M as g,N as _,ja as F}from"./chunk-RWHS77ME.js";import{mb as E,nb as x}from"./chunk-NRCGGNOE.js";import{j as S,k as h,n as L}from"./chunk-JV7LREUF.js";import{A as b,C as k}from"./chunk-K672XXGQ.js";var V=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),O=new Map([["files","discover"],["item","complete"]]),D=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function N(e){let t=h(e?.trim().toLowerCase()??"");return V.has(t)||O.has(t)}function U(e,t,n){let o=V.has(n)?t+1:void 0,s=g(e.slice(t+1));if(s===void 0)return o;let i=t+1+s,r=`${n} ${e[i]}`,a=h(r);return a===r?n==="item"&&e[i]==="complete"?i+1:o:N(a)?A(e,i,a):void 0}function A(e,t,n){if(["history","context","ctx","update","close","item"].includes(n))return U(e,t,n);let o=O.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;return t+(s?2:1)}function q(e){let t=new Map;for(let n of x(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function j(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function K(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let s=n.get(e);return s!==void 0&&s.value_type!=="boolean"}function X(e,t,n,o,s){let i=0;for(let r=t;r<e.length;r+=1){let a=e[r];if(a==="--")break;if(a==="--id"){r+=1;continue}if(!a.startsWith("--id=")){if(!a.startsWith("-")){if(r<o)return!0;i+=1;continue}K(a,e[r+1],s)&&(r+=1)}}return i>(D.get(h(n))??0)}function P(e){let t=g(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(n!=="context"&&n!=="ctx"&&!N(n))return{argv:[...e],changed:!1,conflict:!1};let o=A(e,t,n);if(o===void 0)return{argv:[...e],changed:!1,conflict:!1};let s=o>t+1?`${h(e.slice(t,o-1).join(" "))} ${e[o-1]}`:n,i=q(s),r=j(e),a=r[0];if(!a||!a.value?.trim())return{argv:[...e],changed:!1,conflict:!1};if(r.length>1||X(e,o,s,a.index,i))return{argv:[...e],changed:!1,conflict:!0,itemId:a.value};let u=[...e.slice(0,a.index),...e.slice(a.index+a.consumed)],c=g(u),l=A(u,c,n);return u.splice(l,0,a.value),{argv:u,changed:!0,conflict:!1,itemId:a.value}}var Y=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),H=new Set(["toon","json"]);function Z(e,t,n){let o=e[t];if(C.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),i=s>0?o.slice(0,s):o;if(!m.has(i))return 1;let r=s>0?o.slice(s+1):void 0,a=r===void 0&&y(i,e[t+1]),u=r??(a?e[t+1]:void 0);return i==="--author"?n.author=u??"":typeof u=="string"&&u.length>0&&(Y.has(i)?n.outputValues:n.pathValues).set(i,u),a?2:1}function J(e){return e.outputValues.get("--output-format")!=="toon"&&(e.booleanFlags.has("--json")||e.outputValues.get("--output-format")==="json"||e.pathValues.get("--format")?.trim().toLowerCase()==="json")}function Q(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=Z(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions")||["history attest","history-attest"].includes(W(e)??""),noPager:t.booleanFlags.has("--no-pager"),json:J(t),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...H.has(t.outputValues.get("--output-format"))?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function $(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(C.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(m.has(o)){n+=y(o,e[n+1])?2:1;continue}if(w(o)){n+=1;continue}t.push(o),n+=1}return t}function v(e){let t=$(e);if(t[0]?.trim().toLowerCase()==="help"){let i=[];for(let r=1;r<t.length;r+=1){let a=t[r];if(a.startsWith("-"))break;i.push(a.trim().toLowerCase())}return{requested:!0,commandPathTokens:i}}if(t.findIndex(i=>i==="--help"||i==="-h")<0)return{requested:!1,commandPathTokens:[]};let s=[];for(let i of t){if(i.startsWith("-"))break;s.push(i.trim().toLowerCase())}return{requested:!0,commandPathTokens:s}}function I(e){return g(e)}function ee(e){return _(e)}function te(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:v(e).requested}function Ue(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(i=>process.env[i]),o=()=>{for(let[i,r]of t.entries()){let a=n[i];a===void 0?delete process.env[r]:process.env[r]=a}},s=Q(e);return te(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var ne=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function oe(e){let t=e.indexOf("--");return(t===-1?e:e.slice(0,t)).some(n=>/^(?:--)?fields(?:[=:]|$)/iu.test(n))}function se(e){let t=I(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!ne.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];if((n==="explore"||n==="manage")&&oe(e.slice(t+2)))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var ie=new Set(["pm","pm-cli"]);function ae(e,t){let n=I(e);if(n===void 0)return e;let o=e[n];return ie.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function re(e,t){let n=I(e);if(n!==void 0&&e[n]==="help"){let a=I(e.slice(n+1));n=a===void 0?void 0:n+1+a}if(n===void 0)return e;let o=e[n],s=L[o.trim().toLowerCase()];if(!s)return e;let i=s.split(" "),r=[...e.slice(0,n),...i,...e.slice(n+1)];return t.push({from:o,to:i,reason:"command_alias",confidence:"high"}),r}function T(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function B(e){return T(e).replace(/-/g,"")}function M(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function ue(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function ce(e,t){let n=t??x(e),o=new Map,s=new Map,i=new Map,r=new Set;for(let a of n){let u=ue(a);if(u.length===0)continue;let c=`--${T(u[0])}`;for(let f of u)M(o,T(f),c),M(s,B(f),c);let l=B(c);i.has(c)||i.set(c,l),a.list===!0&&r.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...i.entries()].map(([a,u])=>({canonicalFlag:a,comparable:u})),listCanonicalFlags:r}}function G(e,t){let n=T(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),i=t.canonicalByCompact.get(s);if(typeof i=="string")return{flag:i,reason:"flag_alias",confidence:"high"};let r=s.length>=8?2:1,a=Number.POSITIVE_INFINITY,u,c=!1;for(let l of t.canonicalComparables){let f=F(s,l.comparable,r);if(f!==null){if(f<a){a=f,u=l.canonicalFlag,c=!1;continue}f===a&&u!==l.canonicalFlag&&(c=!0)}}return!u||c||!Number.isFinite(a)||a<=0?null:{flag:u,reason:"flag_typo",confidence:a>=2?"medium":"high"}}function qe(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function le(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0||n[2]===":"&&/\s/u.test(e)?null:{key:o,value:s}}function fe(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,i=o>=0?e.slice(o+1):void 0,r=G(s,t);if(!r)return{tokens:[e]};let a=i===void 0?r.flag:`${r.flag}=${i}`;return a===e?{tokens:[e]}:{tokens:[a],event:{from:e,to:[a],reason:r.reason,confidence:r.confidence}}}function de(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function pe(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function he(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function me(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],i=t+1;for(;i<e.length&&e[i]!=="--"&&!e[i].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[i]),i+=1;let r=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+r),value:s.length===0?void 0:s.join(","),consumed:r}}function ge(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function xe(e,t){let n=[],o=[];for(let[s,i]of e){if(!(i.occurrences>=2||t.has(s)&&i.originalTokens.length>2)){o.push({outputIndex:i.outputIndex,tokens:i.originalTokens});continue}let a=`${s}=${i.values.join(",")}`;o.push({outputIndex:i.outputIndex,tokens:[a]}),n.push({from:`${s} (x${i.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function Ie(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function Ce(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],i=new Map,r=0;for(;r<e.length;){let c=e[r];if(c==="--"){s.push(...e.slice(r));break}if(n.has(c)){r=he(e,r,s);continue}let l=pe(c);if(!l||!t.has(l.flag)){s.push(c),r+=1;continue}let f=me(e,r,l,o);if(f.value===void 0){s.push(c),r+=f.consumed;continue}ge(i,s,l.flag,{originalTokens:f.originalTokens,value:f.value}),r+=f.consumed}let{events:a,splices:u}=xe(i,o);return Ie(s,u),{argv:s,events:a}}var z=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function Te(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=z.get(o);return s!==void 0&&s.has(n)}function be(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let i=e[s];if(i==="--")return o.push(...e.slice(s)),o;let r=z.get(i),a=r?e[s+1]:void 0;if(!r||typeof a!="string"||!r.has(a)){o.push(i),s+=1;continue}let u=s+2;for(;u<e.length&&!e[u].startsWith("-");)u+=1;if(u-(s+2)!==1){o.push(i),s+=1;continue}let c=e[s+2],l=`${a}=${c}`;o.push(i,l),n.push({from:`${i} ${a} ${c}`,to:[i,l],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function ke(e,t,n,o){let s=[],i=de(e);for(let r=0;r<e.length;r+=1){let a=e[r];if(a==="--"){s.push(...e.slice(r));break}let u=i.has(r),c=s[s.length-1];if(a.startsWith("--")){let p=fe(a,t,u);s.push(...p.tokens),p.event&&o.push(p.event);continue}let l=le(a,u);if(!l||typeof c=="string"&&c.startsWith("-")&&!c.includes("=")||["search","comments","notes","learnings"].includes(n)||Te(n,s)){s.push(a);continue}let f=G(l.key,t);if(!f){s.push(a);continue}let d=l.value.startsWith("-")?[`${f.flag}=${l.value}`]:[f.flag,l.value];s.push(...d),o.push({from:a,to:d,reason:"bare_key_value",confidence:f.confidence})}return s}function ye(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--verify"){let o=e[t+1];if(o===void 0||o==="--")throw new k("history attest --verify requires a bundle file.",b.USAGE);e.splice(t,2,`--verify=${o}`)}else(m.has(n)||n==="--output"||n==="--hash-algorithm")&&(t+=1)}}function Ae(e,t){if(!e.some(o=>o==="--help"||o==="-h"))return;let n=new Set(x(t).flatMap(o=>[o.flag,...o.aliases??[],...o.short===void 0?[]:[o.short]]));for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="--")break;s!=="--help"&&s!=="-h"||n.has(e[o-1])&&!C.has(e[o-1])&&(e[o-1]=s)}}function je(e){let t=[],n=ae(e,t),o=se(n);(o.length!==n.length||o.some((p,R)=>p!==n[R]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=re(o,t),i=P(s);if(i.conflict)throw new k("Provide the item id either positionally or with --id, not both.",b.USAGE);i.changed&&t.push({from:`--id ${i.itemId}`,to:[i.itemId],reason:"item_id_alias",confidence:"high"});let r=ee(i.argv),a=W(i.argv),u=h(a??r??""),c=ce(a??r),l=ke(i.argv,c,u,t),f=be(l,u,t),d=Ce(f,c.listCanonicalFlags,m,r==="create"?new Set(["--tags"]):new Set);for(let p of d.events)t.push(p);return Ae(d.argv,a??r),a==="history attest"&&ye(d.argv),{argv:d.argv,commandName:r,trace:t}}var Se=new Set(["--capability","--gh","--github","--ref","--output","--detail"]);function Le(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(!n.startsWith("-"))return n;(Se.has(n)||m.has(n))&&(t+=1)}}function Ke(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return[...e.slice(0,t),...e.slice(t+1)];if(!n.startsWith("-"))break;m.has(n)&&(t+=1)}return[...e]}function we(e,t){let n=Le(t);if(n===void 0||n===t[0])return n;let o=n.trim().toLowerCase();return E(`${e} ${o}`)||e!=="extension"&&o==="upgrade"?n:void 0}function W(e){let t=I(e),n=$(t===void 0?e:e.slice(t)),o=n[0]?.trim().toLowerCase(),s=(o==="extension"||o==="package"||o==="packages"?we(o,n.slice(1)):n[1])?.trim().toLowerCase(),i=S(n);return i?i.canonical:(o==="extension"||o==="package"||o==="packages")&&typeof s=="string"&&s.length>0&&!s.startsWith("-")?`${o} ${s}`:o}function Xe(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}export{N as a,P as b,Q as c,$ as d,v as e,I as f,ee as g,Ue as h,se as i,qe as j,Ce as k,be as l,je as m,Le as n,Ke as o,Xe as p};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{I as m,J as C,K as w,L as y,M as g,N as _,ja as F}from"./chunk-SJWIPGZW.js";import{mb as E,nb as x}from"./chunk-JPJNJHQW.js";import{j as S,k as h,n as L}from"./chunk-VCXQ6A35.js";import{A as b,C as k}from"./chunk-K672XXGQ.js";var V=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),O=new Map([["files","discover"],["item","complete"]]),D=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function N(e){let t=h(e?.trim().toLowerCase()??"");return V.has(t)||O.has(t)}function U(e,t,n){let o=V.has(n)?t+1:void 0,s=g(e.slice(t+1));if(s===void 0)return o;let i=t+1+s,r=`${n} ${e[i]}`,a=h(r);return a===r?n==="item"&&e[i]==="complete"?i+1:o:N(a)?A(e,i,a):void 0}function A(e,t,n){if(["history","context","ctx","update","close","item"].includes(n))return U(e,t,n);let o=O.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;return t+(s?2:1)}function q(e){let t=new Map;for(let n of x(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function j(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function K(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let s=n.get(e);return s!==void 0&&s.value_type!=="boolean"}function X(e,t,n,o,s){let i=0;for(let r=t;r<e.length;r+=1){let a=e[r];if(a==="--")break;if(a==="--id"){r+=1;continue}if(!a.startsWith("--id=")){if(!a.startsWith("-")){if(r<o)return!0;i+=1;continue}K(a,e[r+1],s)&&(r+=1)}}return i>(D.get(h(n))??0)}function P(e){let t=g(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(n!=="context"&&n!=="ctx"&&!N(n))return{argv:[...e],changed:!1,conflict:!1};let o=A(e,t,n);if(o===void 0)return{argv:[...e],changed:!1,conflict:!1};let s=o>t+1?`${h(e.slice(t,o-1).join(" "))} ${e[o-1]}`:n,i=q(s),r=j(e),a=r[0];if(!a||!a.value?.trim())return{argv:[...e],changed:!1,conflict:!1};if(r.length>1||X(e,o,s,a.index,i))return{argv:[...e],changed:!1,conflict:!0,itemId:a.value};let u=[...e.slice(0,a.index),...e.slice(a.index+a.consumed)],c=g(u),l=A(u,c,n);return u.splice(l,0,a.value),{argv:u,changed:!0,conflict:!1,itemId:a.value}}var Y=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),H=new Set(["toon","json"]);function Z(e,t,n){let o=e[t];if(C.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),i=s>0?o.slice(0,s):o;if(!m.has(i))return 1;let r=s>0?o.slice(s+1):void 0,a=r===void 0&&y(i,e[t+1]),u=r??(a?e[t+1]:void 0);return i==="--author"?n.author=u??"":typeof u=="string"&&u.length>0&&(Y.has(i)?n.outputValues:n.pathValues).set(i,u),a?2:1}function J(e){return e.outputValues.get("--output-format")!=="toon"&&(e.booleanFlags.has("--json")||e.outputValues.get("--output-format")==="json"||e.pathValues.get("--format")?.trim().toLowerCase()==="json")}function Q(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=Z(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions")||["history attest","history-attest"].includes(W(e)??""),noPager:t.booleanFlags.has("--no-pager"),json:J(t),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...H.has(t.outputValues.get("--output-format"))?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function $(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(C.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(m.has(o)){n+=y(o,e[n+1])?2:1;continue}if(w(o)){n+=1;continue}t.push(o),n+=1}return t}function v(e){let t=$(e);if(t[0]?.trim().toLowerCase()==="help"){let i=[];for(let r=1;r<t.length;r+=1){let a=t[r];if(a.startsWith("-"))break;i.push(a.trim().toLowerCase())}return{requested:!0,commandPathTokens:i}}if(t.findIndex(i=>i==="--help"||i==="-h")<0)return{requested:!1,commandPathTokens:[]};let s=[];for(let i of t){if(i.startsWith("-"))break;s.push(i.trim().toLowerCase())}return{requested:!0,commandPathTokens:s}}function I(e){return g(e)}function ee(e){return _(e)}function te(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:v(e).requested}function Ue(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(i=>process.env[i]),o=()=>{for(let[i,r]of t.entries()){let a=n[i];a===void 0?delete process.env[r]:process.env[r]=a}},s=Q(e);return te(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var ne=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function oe(e){let t=e.indexOf("--");return(t===-1?e:e.slice(0,t)).some(n=>/^(?:--)?fields(?:[=:]|$)/iu.test(n))}function se(e){let t=I(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!ne.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];if((n==="explore"||n==="manage")&&oe(e.slice(t+2)))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var ie=new Set(["pm","pm-cli"]);function ae(e,t){let n=I(e);if(n===void 0)return e;let o=e[n];return ie.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function re(e,t){let n=I(e);if(n!==void 0&&e[n]==="help"){let a=I(e.slice(n+1));n=a===void 0?void 0:n+1+a}if(n===void 0)return e;let o=e[n],s=L[o.trim().toLowerCase()];if(!s)return e;let i=s.split(" "),r=[...e.slice(0,n),...i,...e.slice(n+1)];return t.push({from:o,to:i,reason:"command_alias",confidence:"high"}),r}function T(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function B(e){return T(e).replace(/-/g,"")}function M(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function ue(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function ce(e,t){let n=t??x(e),o=new Map,s=new Map,i=new Map,r=new Set;for(let a of n){let u=ue(a);if(u.length===0)continue;let c=`--${T(u[0])}`;for(let f of u)M(o,T(f),c),M(s,B(f),c);let l=B(c);i.has(c)||i.set(c,l),a.list===!0&&r.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...i.entries()].map(([a,u])=>({canonicalFlag:a,comparable:u})),listCanonicalFlags:r}}function G(e,t){let n=T(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),i=t.canonicalByCompact.get(s);if(typeof i=="string")return{flag:i,reason:"flag_alias",confidence:"high"};let r=s.length>=8?2:1,a=Number.POSITIVE_INFINITY,u,c=!1;for(let l of t.canonicalComparables){let f=F(s,l.comparable,r);if(f!==null){if(f<a){a=f,u=l.canonicalFlag,c=!1;continue}f===a&&u!==l.canonicalFlag&&(c=!0)}}return!u||c||!Number.isFinite(a)||a<=0?null:{flag:u,reason:"flag_typo",confidence:a>=2?"medium":"high"}}function qe(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function le(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0||n[2]===":"&&/\s/u.test(e)?null:{key:o,value:s}}function fe(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,i=o>=0?e.slice(o+1):void 0,r=G(s,t);if(!r)return{tokens:[e]};let a=i===void 0?r.flag:`${r.flag}=${i}`;return a===e?{tokens:[e]}:{tokens:[a],event:{from:e,to:[a],reason:r.reason,confidence:r.confidence}}}function de(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function pe(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function he(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function me(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],i=t+1;for(;i<e.length&&e[i]!=="--"&&!e[i].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[i]),i+=1;let r=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+r),value:s.length===0?void 0:s.join(","),consumed:r}}function ge(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function xe(e,t){let n=[],o=[];for(let[s,i]of e){if(!(i.occurrences>=2||t.has(s)&&i.originalTokens.length>2)){o.push({outputIndex:i.outputIndex,tokens:i.originalTokens});continue}let a=`${s}=${i.values.join(",")}`;o.push({outputIndex:i.outputIndex,tokens:[a]}),n.push({from:`${s} (x${i.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function Ie(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function Ce(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],i=new Map,r=0;for(;r<e.length;){let c=e[r];if(c==="--"){s.push(...e.slice(r));break}if(n.has(c)){r=he(e,r,s);continue}let l=pe(c);if(!l||!t.has(l.flag)){s.push(c),r+=1;continue}let f=me(e,r,l,o);if(f.value===void 0){s.push(c),r+=f.consumed;continue}ge(i,s,l.flag,{originalTokens:f.originalTokens,value:f.value}),r+=f.consumed}let{events:a,splices:u}=xe(i,o);return Ie(s,u),{argv:s,events:a}}var z=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function Te(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=z.get(o);return s!==void 0&&s.has(n)}function be(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let i=e[s];if(i==="--")return o.push(...e.slice(s)),o;let r=z.get(i),a=r?e[s+1]:void 0;if(!r||typeof a!="string"||!r.has(a)){o.push(i),s+=1;continue}let u=s+2;for(;u<e.length&&!e[u].startsWith("-");)u+=1;if(u-(s+2)!==1){o.push(i),s+=1;continue}let c=e[s+2],l=`${a}=${c}`;o.push(i,l),n.push({from:`${i} ${a} ${c}`,to:[i,l],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function ke(e,t,n,o){let s=[],i=de(e);for(let r=0;r<e.length;r+=1){let a=e[r];if(a==="--"){s.push(...e.slice(r));break}let u=i.has(r),c=s[s.length-1];if(a.startsWith("--")){let p=fe(a,t,u);s.push(...p.tokens),p.event&&o.push(p.event);continue}let l=le(a,u);if(!l||typeof c=="string"&&c.startsWith("-")&&!c.includes("=")||["search","comments","notes","learnings"].includes(n)||Te(n,s)){s.push(a);continue}let f=G(l.key,t);if(!f){s.push(a);continue}let d=l.value.startsWith("-")?[`${f.flag}=${l.value}`]:[f.flag,l.value];s.push(...d),o.push({from:a,to:d,reason:"bare_key_value",confidence:f.confidence})}return s}function ye(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--verify"){let o=e[t+1];if(o===void 0||o==="--")throw new k("history attest --verify requires a bundle file.",b.USAGE);e.splice(t,2,`--verify=${o}`)}else(m.has(n)||n==="--output"||n==="--hash-algorithm")&&(t+=1)}}function Ae(e,t){if(!e.some(o=>o==="--help"||o==="-h"))return;let n=new Set(x(t).flatMap(o=>[o.flag,...o.aliases??[],...o.short===void 0?[]:[o.short]]));for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="--")break;s!=="--help"&&s!=="-h"||n.has(e[o-1])&&!C.has(e[o-1])&&(e[o-1]=s)}}function je(e){let t=[],n=ae(e,t),o=se(n);(o.length!==n.length||o.some((p,R)=>p!==n[R]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=re(o,t),i=P(s);if(i.conflict)throw new k("Provide the item id either positionally or with --id, not both.",b.USAGE);i.changed&&t.push({from:`--id ${i.itemId}`,to:[i.itemId],reason:"item_id_alias",confidence:"high"});let r=ee(i.argv),a=W(i.argv),u=h(a??r??""),c=ce(a??r),l=ke(i.argv,c,u,t),f=be(l,u,t),d=Ce(f,c.listCanonicalFlags,m,r==="create"?new Set(["--tags"]):new Set);for(let p of d.events)t.push(p);return Ae(d.argv,a??r),a==="history attest"&&ye(d.argv),{argv:d.argv,commandName:r,trace:t}}var Se=new Set(["--capability","--gh","--github","--ref","--output","--detail"]);function Le(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(!n.startsWith("-"))return n;(Se.has(n)||m.has(n))&&(t+=1)}}function Ke(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return[...e.slice(0,t),...e.slice(t+1)];if(!n.startsWith("-"))break;m.has(n)&&(t+=1)}return[...e]}function we(e,t){let n=Le(t);if(n===void 0||n===t[0])return n;let o=n.trim().toLowerCase();return E(`${e} ${o}`)||e!=="extension"&&o==="upgrade"?n:void 0}function W(e){let t=I(e),n=$(t===void 0?e:e.slice(t)),o=n[0]?.trim().toLowerCase(),s=(o==="extension"||o==="package"||o==="packages"?we(o,n.slice(1)):n[1])?.trim().toLowerCase(),i=S(n);return i?i.canonical:(o==="extension"||o==="package"||o==="packages")&&typeof s=="string"&&s.length>0&&!s.startsWith("-")?`${o} ${s}`:o}function Xe(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}export{N as a,P as b,Q as c,$ as d,v as e,I as f,ee as g,Ue as h,se as i,qe as j,Ce as k,be as l,je as m,Le as n,Ke as o,Xe as p};
|
|
2
|
+
//# sourceMappingURL=chunk-NHBG5ET3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F,nb as w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{F,nb as w}from"./chunk-JPJNJHQW.js";import{X as r,Y as y,ba as k,ca as A}from"./chunk-VCXQ6A35.js";import{J as u,S as h,da as d}from"./chunk-TE6FBDHP.js";import{A as c,C as f,m as _}from"./chunk-K672XXGQ.js";function S(e){return e.trim().toLowerCase().replace(/^-+/u,"")}function v(e){let n=S(e),i=A({key:n,cli_flag:n,cli_aliases:[]});return[...new Set([...i,k(n)])]}var $=new Set(_.filter(e=>!u.has(e))),E={flag:"--help",short:"-h"},C=new Map;function b(e){let n=C.get(e);if(n===void 0){let i=new Map,o=new Map;for(let l of[...w(e),...F,E]){for(let t of[l.flag,...l.aliases??[]].flatMap(v))i.has(t)||i.set(t,l.flag);l.short!==void 0&&!o.has(l.short)&&o.set(l.short,l.flag)}n={long:i,short:o},C.set(e,n)}return n}function D(e,n){return r(e)?n.short.get(e.trim()):v(e).map(i=>n.long.get(i)).find(i=>i!==void 0)}function p(e){let n=[];for(let i of e){let o=a=>r(a)?a.trim():S(a),l=[...new Set([i.cli_flag,...i.cli_aliases].map(o))],t=o(i.key);for(let a of i.commands)n.push(...T(i.key,l,l.includes(t)?void 0:t,a.replaceAll("_","-")))}return n.sort((i,o)=>i.field.localeCompare(o.field)||i.command.localeCompare(o.command)||i.option.localeCompare(o.option))}function T(e,n,i,o){let l=b(o),t=new Map;for(let a of i===void 0?n:[...n,i]){if($.has(e)&&a.replaceAll("-","_")===e)continue;let s=D(a,l);s===void 0||t.has(s)||a===i&&s===E.flag||t.set(s,{field:e,command:o,field_flag:r(a)?a:`--${a.replaceAll("_","-")}`,option:s})}return[...t.values()]}function I(e){return p([{key:e.key,cli_flag:e.cliFlag??e.key.replaceAll("_","-"),cli_aliases:e.cliAliases,commands:e.commands}])}function g(e){return e.flatMap(n=>[...new Set([n.cli_flag,...n.cli_aliases])].flatMap(i=>{let o=y(i);return o===void 0?[]:[{field:n.key,spelling:i,reason:o}]}))}function M(e,n){return[...O(e.key,n?.cliFlag,n?.aliases),...g([{key:e.key,cli_flag:e.cliFlag??e.key.replaceAll("_","-"),cli_aliases:e.cliAliases}])]}function L(e){return`${JSON.stringify(e.spelling)} ${e.reason}`}function R(e){return`${e.field_flag} shadows built-in ${e.option} on pm ${e.command}`}function q(e,n){let i=d(e).definitions,o=p(i),l=g(i),t=l.length===0?{details:{},warnings:[]}:{details:{schema_field_flag_invalid_count:l.length,schema_field_flag_invalid:l.slice(0,n),schema_field_flag_invalid_truncated:l.length>n,schema_field_flag_invalid_fix_hint:"Re-register the field with one flag and one spelling per alias: pm schema add-field <key> --cli-flag <flag> --alias <alias>. A short alias is one dash and one character. Edit a field defined inline in settings.json there."},warnings:[`validate_schema_field_flag_invalid:${l.length}`]};return o.length===0?t:{details:{...t.details,schema_field_option_collision_count:o.length,schema_field_option_collisions:o.slice(0,n),schema_field_option_collisions_truncated:o.length>n,schema_field_option_collision_fix_hint:"Rename a file-backed field without losing item values: pm schema rename-field <key> --to <new-key>. For a colliding flag, alias or command list, re-register the same key: pm schema add-field <key> --cli-flag <flag> --commands <commands>. Edit a field defined inline in settings.json there."},warnings:[...t.warnings,`validate_schema_field_option_collision:${o.length}`]}}function z(e,n){m(e.key,M(e,n)),x(e.key,e.commands,I(e))}function O(e,n,i){return[n,...Array.isArray(i)?i:[]].filter(o=>typeof o=="string"&&h(o).length===0).map(o=>({field:e,spelling:o,reason:"is empty"}))}function H(e){m(e.key,O(e.key,e.cli_flag,e.cli_aliases));let n=d({fields:[e]}).definitions;m(e.key,g(n)),x(e.key,n.flatMap(i=>i.commands),p(n))}function m(e,n){if(n.length!==0)throw new f(`Cannot define custom field "${e}": flag ${n.map(L).join("; ")}. The command it is registered for could not register it as one option.`,c.USAGE,{code:"schema_field_flag_invalid",field:e,flag:n[0].spelling,required:"Each custom field flag and alias must be one option spelling: a long name without spaces, pipes, commas, '=' or brackets, or a short flag of one dash and one character.",nextSteps:[`Pass one spelling per --alias, for example pm schema add-field ${e} --alias <first> --alias <second>.`]})}function x(e,n,i){if(i.length===0)return;let o={key:e,commands:n},l=new Set(i.map(a=>a.command)),t=o.commands.filter(a=>!l.has(a.replaceAll("_","-")));throw new f(`Cannot define custom field "${o.key}": ${i.map(R).join("; ")}. The built-in option would stop working for that command.`,c.USAGE,{code:"schema_field_option_collision",field:o.key,flag:i[0].option,required:"A custom field's key, flag and aliases must differ from every built-in option of each command it is registered for.",nextSteps:[`Rename the field with a project-specific prefix, for example pm schema add-field project_${o.key}.`,...t.length>0?[`Or register "${o.key}" only where its option is free: --commands ${t.join(",")}.`]:[]]})}export{p as a,I as b,g as c,M as d,L as e,R as f,q as g,z as h,H as i};
|
|
2
|
+
//# sourceMappingURL=chunk-NVYDPNQP.js.map
|