@unbrained/pm-cli 2026.9.9 → 2026.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +17 -0
- package/dist/cli/command-namespaces.d.ts +9 -0
- package/dist/cli/command-namespaces.js +2 -0
- package/dist/cli/help-content.js +1 -1
- package/dist/cli/help-json-payload.d.ts +5 -1
- package/dist/cli/help-json-payload.js +2 -2
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +3 -3
- package/dist/cli/register-mutation.js +2 -2
- package/dist/cli/register-operations.d.ts +0 -5
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +154 -154
- package/dist/cli-bundle/chunks/chunk-4SFBH77G.js +2233 -0
- package/dist/cli-bundle/chunks/{chunk-4VL5P22L.js → chunk-74RGSPLL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WQKMSFBV.js → chunk-7WIHZI2M.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-L5RCDKQ2.js → chunk-EOCKPCEY.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-GLQMKUGP.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-OHNLSGGV.js → chunk-I6XT3DLQ.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-MACGGTLQ.js +29 -0
- package/dist/cli-bundle/chunks/{chunk-ECBLPN7B.js → chunk-NKOYVKFM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Z3XVXUVF.js → chunk-P6BEYAON.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3IPRM75M.js → chunk-PYUITRSV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-T3AMFUCN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-D3YVILJJ.js → chunk-TSWEX72T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-J6ERHBV2.js → chunk-YKQTETJI.js} +71 -71
- package/dist/cli-bundle/chunks/{register-list-query-UIHRCS6D.js → register-list-query-CUIW7SSE.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-5F5CYUWZ.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-XIZPLPQY.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-PERI45EM.js → register-setup-JVGPCAIL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OQUGRHKV.js → chunk-26O2WB73.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-5YU75QLV.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QQQ4SAUO.js → chunk-7N5MRONP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-B2CMFYRZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-PNKIANFZ.js → chunk-CRY5MHEI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YCDQ2N23.js → chunk-F6WKFXBT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BUCJUZVG.js → chunk-FHUARRMA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5FHTCOHS.js → chunk-M36SF4GE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TTYXF5YD.js → chunk-OROZM37I.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XNR3DM6J.js → chunk-PNGYYQY7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZTCE4UO6.js → chunk-SL5YVVPV.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-XSS3APUF.js → chunk-TPOL4TWE.js} +5 -5
- package/dist/cli-bundle/focused-chunks/{chunk-7PC4R5QB.js → chunk-U5SHHU7E.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2WSBXIGF.js → chunk-XSMA2W6Q.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZAWAL2CG.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7N6DOREF.js → chunk-ZDNAWWQI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YJUXGS57.js → chunk-ZJHYQOTM.js} +2 -2
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +37 -37
- 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 +42 -42
- 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 +10 -10
- package/dist/sdk/agent/item-addressing.js +1 -1
- package/dist/sdk/agent-capability-contracts.js +1 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.d.ts +11 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +4 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -3
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -0
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/completion.js +359 -346
- package/dist/sdk/index.d.ts +2 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/lifecycle-transitions.d.ts +1 -1
- package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
- package/dist/sdk/lifecycle/mcp-actions.js +1 -1
- package/dist/sdk/lifecycle/task-composition.d.ts +17 -0
- package/dist/sdk/lifecycle/task-composition.js +2 -0
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/workspace-contracts.d.ts +3 -0
- package/dist/sdk/query/workspace-contracts.js +2 -0
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime.d.ts +69 -9
- package/dist/sdk/runtime.js +1 -1
- package/docs/COMMANDS.md +26 -24
- package/docs/COMMAND_NAMESPACES.md +65 -0
- package/docs/LIFECYCLE_COMMANDS.md +77 -0
- package/docs/README.md +2 -0
- package/docs/generated/AGENT_CAPABILITY_ROUTING.md +6 -6
- package/docs/generated/AGENT_COMMAND_SURFACE.md +19 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +21 -3
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +2 -2
- package/marketplace.json +2 -2
- 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/README.md +4 -2
- 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/README.md +6 -4
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli-bundle/chunks/chunk-AAFBV3U3.js +0 -29
- package/dist/cli-bundle/chunks/chunk-JUNJ5EKI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NSAPNEYH.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XZ6T7YPP.js +0 -2217
- package/dist/cli-bundle/chunks/register-mutation-WHWMGRVX.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-64YZYTC5.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2W4XIYOB.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-FE3BABLJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IWITF53W.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as dt,b as lt,d as ut}from"./chunk-PNKIANFZ.js";import{t as wr}from"./chunk-FE3BABLJ.js";import{$a as re,Aa as yt,Bb as kr,Cb as Rr,E as Ir,F as Ar,Fb as Mr,Na as Ce,O as ue,Oa as v,Pa as xe,Q as H,T as ft,U as mt,X as pt,_a as Le,bb as ht,cc as Dr,db as gt,fb as xr,hb as me,lb as ke,mb as pe,nb as wt,pb as bt,qa as _t,qb as ne,ra as Cr,rb as Lr,ya as fe}from"./chunk-TTYXF5YD.js";import{m as ee,o as at}from"./chunk-5FHTCOHS.js";import{A as Tr,G as R,K as te,L as vr,M as Ae,u as q,x as Ie}from"./chunk-OQUGRHKV.js";import{$ as f,Aa as k,Ba as ce,Ga as F,Ia as nt,Ja as ot,Ka as it,La as hr,Ma as de,Pa as w,Qa as S,Ra as le,Sa as Z,Ta as E,Uc as br,V as rt,Va as gr,Vc as Er,Wc as ct,_c as Sr,aa as m,i as tt,ja as z,la as J,ma as I,na as T,pa as ve,qb as st}from"./chunk-XSS3APUF.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="df9abedd-6e84-5712-8e5e-4e510ec3ed60")}catch{}})();function Nr(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new m(`${t} must be a non-negative number`,f.USAGE);return Math.floor(r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="960053d8-8ed1-50c3-a0fb-bd035ff5c1b8")}catch{}})();var ri=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,ni=/\bnpm_[A-Za-z0-9]{36}\b/,oi=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,ii=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,si=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,Or=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,ai=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],St=new Map(ai.map(e=>[e.action,e]));function ci(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function Et(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>Et(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>Et(o,`${t}.${n}`,r)))}function Fr(e){let t=[];for(let r of Et(e)){ri.test(r.value)&&t.push({rule:"github_token",path:r.path}),ni.test(r.value)&&t.push({rule:"npm_token",path:r.path}),oi.test(r.value)&&t.push({rule:"slack_token",path:r.path}),ii.test(r.value)&&t.push({rule:"private_key",path:r.path}),si.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),Or.lastIndex=0;for(let n of r.value.matchAll(Or)){let o=n[1];if(ci(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function di(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new m("Mutation author is required by workspace policy.",f.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=Fr(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new m(`Mutation blocked by secret guard (${n}). No detected value was logged.`,f.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function li(e){return St.has(e.trim().toLowerCase())}function ui(){return[...St.keys()].sort((e,t)=>e.localeCompare(t))}function ul(e){return St.get(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c18e4dfc-d3e3-5185-9470-9d46b4dca893")}catch{}})();function fi(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function ml(e){return fi(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function _e(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="54784ad1-36bd-5a10-aa00-ad0b09e935a7")}catch{}})();var mi=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function Re(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function he(e){return[...new Set(Re(e).match(/[\p{L}\p{N}]+/gu)??[])]}function ye(e){let t=Re(e);return{normalized:t,tokens:he(t),issueCodes:[...new Set(t.match(mi)?.map(r=>r.toLowerCase())??[])]}}function Me(e,t){return De(ye(e),ye(t))}function De(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:_e(e.tokens,t.tokens),reason:"title_token_jaccard"}}import pi from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cdae67c6-8316-5e97-84ca-0be4460ffd57")}catch{}})();function Ne(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function _i(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function Pr(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=Ne(t.in_progress_status),i=[];for(let s of e){if(Ne(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=_i(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function yi(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>Ne(String(o.status))===Ne(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await pt(pi.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),Pr(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as hi,readFile as gi}from"node:fs/promises";import $r from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9d3152f0-afc9-5be8-9303-b02ea2666631")}catch{}})();function wi(e){let t=e.trim();if(!t)throw new m("--rollback requires a non-empty checkpoint ID",f.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new m("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",f.USAGE);return t}function bi(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function Ur(e,t){return $r.join(e,"checkpoints",t)}function zr(e,t,r){return $r.join(Ur(e,t),`${r}.json`)}async function Ei(e,t,r,n){let o=Ur(e,t);await hi(o,{recursive:!0});let i=zr(e,t,r);return await T(i,`${JSON.stringify(n,null,2)}
|
|
1
|
+
import{a as dt,b as lt,d as ut}from"./chunk-CRY5MHEI.js";import{t as wr}from"./chunk-B2CMFYRZ.js";import{$a as re,Aa as yt,Bb as kr,Cb as Rr,E as Ir,F as Ar,Fb as Mr,Na as Ce,O as ue,Oa as v,Pa as xe,Q as H,T as ft,U as mt,X as pt,_a as Le,bb as ht,cc as Dr,db as gt,fb as xr,hb as me,lb as ke,mb as pe,nb as wt,pb as bt,qa as _t,qb as ne,ra as Cr,rb as Lr,ya as fe}from"./chunk-OROZM37I.js";import{m as ee,o as at}from"./chunk-M36SF4GE.js";import{A as Tr,G as R,K as te,L as vr,M as Ae,u as q,x as Ie}from"./chunk-26O2WB73.js";import{$ as f,$c as ct,Aa as k,Ba as ce,Ga as F,Ia as nt,Ja as ot,Ka as it,La as hr,Ma as de,Pa as w,Qa as S,Ra as le,Sa as Z,Ta as E,V as rt,Va as gr,Zc as br,_c as Er,aa as m,dd as Sr,i as tt,ja as z,la as J,ma as I,na as T,pa as ve,qb as st}from"./chunk-TPOL4TWE.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="df9abedd-6e84-5712-8e5e-4e510ec3ed60")}catch{}})();function Nr(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new m(`${t} must be a non-negative number`,f.USAGE);return Math.floor(r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="960053d8-8ed1-50c3-a0fb-bd035ff5c1b8")}catch{}})();var ri=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,ni=/\bnpm_[A-Za-z0-9]{36}\b/,oi=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,ii=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,si=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,Or=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,ai=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],St=new Map(ai.map(e=>[e.action,e]));function ci(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function Et(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>Et(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>Et(o,`${t}.${n}`,r)))}function Fr(e){let t=[];for(let r of Et(e)){ri.test(r.value)&&t.push({rule:"github_token",path:r.path}),ni.test(r.value)&&t.push({rule:"npm_token",path:r.path}),oi.test(r.value)&&t.push({rule:"slack_token",path:r.path}),ii.test(r.value)&&t.push({rule:"private_key",path:r.path}),si.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),Or.lastIndex=0;for(let n of r.value.matchAll(Or)){let o=n[1];if(ci(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function di(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new m("Mutation author is required by workspace policy.",f.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=Fr(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new m(`Mutation blocked by secret guard (${n}). No detected value was logged.`,f.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function li(e){return St.has(e.trim().toLowerCase())}function ui(){return[...St.keys()].sort((e,t)=>e.localeCompare(t))}function ul(e){return St.get(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c18e4dfc-d3e3-5185-9470-9d46b4dca893")}catch{}})();function fi(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function ml(e){return fi(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function _e(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="54784ad1-36bd-5a10-aa00-ad0b09e935a7")}catch{}})();var mi=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function Re(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function he(e){return[...new Set(Re(e).match(/[\p{L}\p{N}]+/gu)??[])]}function ye(e){let t=Re(e);return{normalized:t,tokens:he(t),issueCodes:[...new Set(t.match(mi)?.map(r=>r.toLowerCase())??[])]}}function Me(e,t){return De(ye(e),ye(t))}function De(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:_e(e.tokens,t.tokens),reason:"title_token_jaccard"}}import pi from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cdae67c6-8316-5e97-84ca-0be4460ffd57")}catch{}})();function Ne(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function _i(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function Pr(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=Ne(t.in_progress_status),i=[];for(let s of e){if(Ne(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=_i(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function yi(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>Ne(String(o.status))===Ne(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await pt(pi.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),Pr(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as hi,readFile as gi}from"node:fs/promises";import $r from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9d3152f0-afc9-5be8-9303-b02ea2666631")}catch{}})();function wi(e){let t=e.trim();if(!t)throw new m("--rollback requires a non-empty checkpoint ID",f.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new m("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",f.USAGE);return t}function bi(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function Ur(e,t){return $r.join(e,"checkpoints",t)}function zr(e,t,r){return $r.join(Ur(e,t),`${r}.json`)}async function Ei(e,t,r,n){let o=Ur(e,t);await hi(o,{recursive:!0});let i=zr(e,t,r);return await T(i,`${JSON.stringify(n,null,2)}
|
|
2
2
|
`),i}function Si(e,t){if(!Array.isArray(e.items))throw new m(`Checkpoint ${t} is missing items`,f.GENERIC_FAILURE);return e.items.map(r=>{if(!r||typeof r!="object")throw new m(`Checkpoint ${t} contains an invalid item entry`,f.GENERIC_FAILURE);let n=r;if(typeof n.id!="string"||n.id.trim().length===0)throw new m(`Checkpoint ${t} contains an item entry without ID`,f.GENERIC_FAILURE);if(typeof n.target_updated_at!="string"||n.target_updated_at.trim().length===0)throw new m(`Checkpoint ${t} contains an item entry without target_updated_at`,f.GENERIC_FAILURE);return{id:n.id.trim(),target_updated_at:n.target_updated_at.trim()}})}async function Ti(e,t,r,n){let o=wi(r),i=zr(e,t,o);if(!await z(i))throw new m(`Checkpoint ${o} not found`,f.NOT_FOUND);let s=await gi(i,"utf8"),a;try{a=JSON.parse(s)}catch(l){throw new m(`Checkpoint ${o} contains invalid JSON: ${E(l)}`,f.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new m(`Checkpoint ${o} is invalid`,f.GENERIC_FAILURE);let c=a;if(c.schema_version!==n)throw new m(`Checkpoint ${o} has unsupported schema version`,f.GENERIC_FAILURE);let d=Si(c,o);return{record:c,items:d,path:i,id:typeof c.id=="string"?c.id:o,created_at:typeof c.created_at=="string"?c.created_at:R(),author:typeof c.author=="string"?c.author:"unknown"}}async function vi(e,t){let r=[],n=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);r.push({id:o.id,status:"restored",changed_fields:i.changed_fields,warnings:i.warnings}),n.push(o.id)}catch(i){r.push({id:o.id,status:"failed",error:E(i)})}return{rows:r,restored_ids:n,failed_count:r.filter(o=>o.status==="failed").length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fdacd8ac-787a-5639-84d5-a32b6ce79d41")}catch{}})();function V(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function Ll(e,t){let r=V(t);return!e||!r?null:[...e.assurance_providers??[]].reverse().find(n=>V(n.definition.id)===r)??null}function Ii(e,t){let r=V(t);return!e||!r?null:[...e.search_providers].reverse().find(o=>(V(o.runtime_definition?.name)??V(o.definition?.name))===r)??null}function Ai(e,t){let r=V(t);return!e||!r?null:[...e.vector_store_adapters].reverse().find(o=>(V(o.runtime_definition?.name)??V(o.definition?.name))===r)??null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="74ce3524-6c25-5646-b1a0-5ca8a3759034")}catch{}})();var P="-",jr=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function Dl(e,t){if(e.startsWith("```")||e.includes(`
|
|
3
3
|
`))return!0;let r=t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${r})\\s*[:=]`,"i").test(e)}function Kr(e){let t=e.trim();if(t==="")return[];let n=(Ri(t)??t.split(",")).map(o=>o.trim()).filter(Boolean).map(o=>o.toLowerCase());return Array.from(new Set(n)).sort((o,i)=>o.localeCompare(i))}function qr(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of Kr(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function Hr(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function Ci(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function xi(e,t,r){let n=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new m('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',f.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});a.length>0&&!n.includes(a)&&n.push(a)}let o=[],i=n;for(let s of r??[]){let a=s.trim();if(a.length!==0){if(!i.includes(a)){o.push(a);continue}i=i.filter(c=>c!==a)}}return{criteria:i,unmatchedRemovals:o}}function Li(e,t){let r=Hr(e);if(!t||t.length===0)return Array.from(new Set(r)).sort((o,i)=>o.localeCompare(i));let n=new Set(r);for(let o of qr(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function ki(e,t){let r=Array.from(new Set(Hr(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(qr(t));return n.size===0?r:r.filter(o=>!n.has(o))}function Ri(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):"").filter(n=>n.length>0)}function Tt(e){return e.replace(/\r\n/g,`
|
|
4
4
|
`)}function Br(e){let t=Tt(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
|
|
@@ -17,4 +17,4 @@ ${i}`;continue}return null}return r}function Fi(e,t){let r=Br(e).trim();if(!r)th
|
|
|
17
17
|
`)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=Pc(o)),t.push(o))}catch{}}return t}function $c(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let r=Date.parse(e.enqueued_at);return Number.isNaN(r)?!1:r<t}function eo(e,t){let r=Xn(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>Nn||$c(i,r)||i.attempts>=On){o+=1;continue}n.push(i)}if(n.length>Cn){let i=n.length-Cn;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function Uc(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
|
|
18
18
|
`),n=r.length>0?`${r}
|
|
19
19
|
`:"";for(let o=0;;o+=1)try{await T(Zt(e),n);return}catch(i){let s=Fn[o];if(s===void 0||!Qn(i))throw i;await Jn(s)}}async function Mn(e,t,r,n){return tr(async()=>{let o=await I(Zt(e)),i=o===null?[]:Zn(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=eo(s,t);return await Uc(e,a),a.length})}async function zc(e,t){let r=await I(Zt(e));if(r===null||r.trim().length===0){await O(e,{pending_otel_spans:0});return}let n=Zn(r),{entries:o,prunedCount:i}=eo(n,t),s=o.filter(h=>Wn(h.next_attempt_after)).slice(0,sc);if(s.length===0){let h=i>0?await Mn(e,t,new Set,new Map):o.length;await O(e,{pending_otel_spans:h});return}let a=R(),c=new Set,d=new Map,l=0,u;await Promise.all(s.map(async h=>{try{let y=await Bn(h.endpoint,{"content-type":"application/json"},JSON.stringify(h.payload));if(y<200||y>=300)throw new Error(`local_otel_export_http_${y}`);c.add(h.id),l+=1}catch(y){u=y instanceof Error?Xt(y.message,"redacted"):"local_otel_export_failed";let g=h.attempts+1;d.set(h.id,{attempts:g,next_attempt_after:Yn(g)})}}));let p=await Mn(e,t,c,d),_={pending_otel_spans:p,last_otel_attempt_at:a};l>0&&(_.last_otel_success_at=a),u!==void 0?(_.last_otel_failure_at=a,_.last_otel_failure_error=u):p===0&&(_.last_otel_failure_at=void 0,_.last_otel_failure_error=void 0),await O(e,_)}async function Vc(e,t,r){try{await Hc(e,t,r)}catch{}try{await zc(e,r)}catch{}}async function jc(e,t=pc){try{let r=Ac(e),n=await ec(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=x.join(r,i.name);(await Dn(s)).mtimeMs<o&&await Jt(s,{force:!0})}))}catch{}}async function tr(e){let t=kn.catch(()=>{}).then(e);return kn=t.catch(()=>{}),t}async function rr(e){let t=await I(Xe(e));return t===null||t.trim().length===0?[]:Gn(t)}async function Kc(e,t,r){return tr(async()=>{let n=await rr(e),{entries:o}=er(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await We(e,i),i})}async function qc(e,t,r,n){return tr(async()=>{let o=await rr(e),{entries:i}=er(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:Yn(c)}});return await We(e,s),s})}async function Hc(e,t,r){await jc(e);let n=t.trim();if(n.length===0)return;let o=await I(Xe(e));if(o===null||o.trim().length===0){await O(e,{endpoint:n,queue_entries:0});return}let i=Gn(o);if(i.length===0){await O(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=er(i,r);if(s.length===0){await We(e,[]),await O(e,{endpoint:n,queue_entries:0});return}let c=s.filter(_=>Oc(_)).slice(0,cc);if(c.length===0){a>0&&await We(e,s),await O(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(_=>_.event.event_id)),l=R(),u={"content-type":"application/json"},p=process.env.PM_TELEMETRY_INGEST_KEY?.trim();p&&(u["x-pm-telemetry-key"]=p);try{let _=await Bn(n,u,JSON.stringify({schema_version:ac,events:c.map(h=>h.event)}));if(_<200||_>=300)throw new Error(`telemetry_flush_http_${_}`)}catch(_){let h=await qc(e,d,l,r),y=_ instanceof Error?Xt(_.message,"redacted"):"telemetry_flush_failed";await O(e,{endpoint:n,queue_entries:h.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:y});return}try{let _=await Kc(e,d,r);await O(e,{endpoint:n,queue_entries:_.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(_){let h=_ instanceof Error?Xt(_.message,"redacted"):"telemetry_flush_failed",y=await rr(e).catch(()=>s);await O(e,{endpoint:n,queue_entries:y.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:h})}}async function Bc(e){let t=Un(e);await Wt(x.dirname(t),{recursive:!0});try{return await Wt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await Dn(t);return Date.now()-r.mtimeMs<_c?!1:(await Jt(t,{recursive:!0,force:!0}),await Wt(t),!0)}catch{return!1}}function Gc(e){try{Za(e,{recursive:!0,force:!0})}catch{}}function Yc(e){Gc(Cc(e))}async function Wc(e,t,r){let n=await Bc(e);if(Yc(e),!!n)try{await Vc(e,t,r)}finally{try{await Jt(Un(e),{recursive:!0,force:!0})}catch{}}}async function ym(e=nt(process.cwd())){if(!Dc())try{if(!(await v(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await Nc(e);await Wc(e,r,n)}catch{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d27383c3-03c8-51ff-98c5-700cc6c2c114")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fdc16f69-f63f-5e17-9139-35d54db7bab5")}catch{}})();function Qe(e,t="--limit"){if(e===void 0)return;let r=String(e).trim(),n=r.length===0?Number.NaN:Number(r);if(!Number.isInteger(n)||n<0)throw new m(`${t} must be a non-negative integer`,f.USAGE);return n}function to(e,t="--priority"){if(e===void 0)return;let r=String(e).trim(),n=r.length===0?Number.NaN:Number(r);if(!Number.isInteger(n)||n<0||n>4)throw new m(`${t} filter must be 0..4`,f.USAGE);return n}function Ih(e,t,r="--type"){if(e===void 0)return;let n=ce(e,t);if(!n)throw new m(`${r} filter must be one of ${t.types.join("|")}`,f.USAGE);return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e524f0ad-faad-5d89-b8f5-1283979919ad")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b03f0596-8c1f-59ec-a20e-8919cf8bbb98")}catch{}})();function nr(e,t){if(e===void 0)return;let r=[],n="";for(let s=0;s<e.length;s+=1){let a=e[s];if(a==="\\"){let c=e[s+1];if(c===","||c==="\\"){n+=c,s+=1;continue}n+=a;continue}if(a===","){r.push(n),n="";continue}n+=a}r.push(n);let o=r.map(s=>s.trim());if(o.some(s=>s.length===0))throw new m(`${t.label} requires at least one non-empty value`,f.USAGE);let i=o.map(s=>t.normalize?.(s)??s);return[...new Set(i)]}function Se(e,t){let r=nr(e,t);return r===void 0?void 0:new Set(r)}function ro(e,t,r="--type"){let n=nr(e,{label:r});if(n===void 0)return;let o=n.map(i=>{let s=ce(i,t);if(!s)throw new m(`${r} filter token "${i}" must be one of ${t.types.join("|")}`,f.USAGE);return s});return new Set(o)}function no(e,t="--priority"){let r=nr(e,{label:t});if(r!==void 0)return new Set(r.map(n=>to(n,t)))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="81a10252-4fa3-5c14-878d-7d78717419a4")}catch{}})();function oo(e,t){let r=e.trim().toLowerCase();return t.alias_to_id.get(r)??r}function co(e){return{isTerminal(t){return e.terminal_statuses.has(oo(t,e))},classify(t){let r=oo(t,e);return e.terminal_canceled_statuses.has(r)?"canceled":e.terminal_statuses.has(r)?"closed":e.blocked_statuses.has(r)?"blocked":e.draft_statuses.has(r)?"draft":r===e.open_status?"open":e.active_statuses.has(r)?"in_progress":"other"}}}function or(e){return S(e.acceptance_criteria)===void 0}function ir(e){return!Number.isFinite(e.estimated_minutes)}function lo(e,t){return t.isTerminal(e.status)?S(e.resolution)===void 0:!1}function Qc(e){return S(e.reviewer)===void 0}function Jc(e){return S(e.risk)===void 0}function Zc(e){return typeof e.confidence=="number"?!Number.isFinite(e.confidence):S(e.confidence)===void 0}function ed(e){return S(e.sprint)===void 0}function td(e){return S(e.release)===void 0}function sr(e){return!!(e.acMissing||e.estimatesMissing||e.resolutionMissing||e.reviewerMissing||e.riskMissing||e.confidenceMissing||e.sprintMissing||e.releaseMissing||e.metadataMissing)}function rd(e,t,r){return[[t.acMissing,or(e)],[t.estimatesMissing,ir(e)],[t.resolutionMissing,lo(e,r)],[t.reviewerMissing,Qc(e)],[t.riskMissing,Jc(e)],[t.confidenceMissing,Zc(e)],[t.sprintMissing,ed(e)],[t.releaseMissing,td(e)]].every(([o,i])=>o!==!0||i)}function nd(e,t){return or(e)||ir(e)||lo(e,t)}function uo(e,t,r){return sr(t)?!(!rd(e,t,r)||t.metadataMissing&&!nd(e,r)):!0}var ar=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function od(e,t){switch(t){case"acceptance_criteria":return!or(e);case"estimated_minutes":return!ir(e);case"resolution":return S(e.resolution)!==void 0;case"tags":return Array.isArray(e.tags)&&e.tags.length>0;default:return S(e.parent)!==void 0}}function id(e,t,r){return t==="resolution"?r.isTerminal(e.status):!0}function sd(e,t){return t===0?100:Math.round(e/t*1e3)/10}function io(){let e={};for(let t of ar)e[t]={present:0,applicable:0,percent:100};return e}function so(e,t,r){for(let n of ar){if(!id(t,n,r))continue;let o=e[n];o.applicable+=1,od(t,n)&&(o.present+=1)}}function ao(e){for(let t of ar){let r=e[t];r.percent=sd(r.present,r.applicable)}}function zh(e,t){let r=io(),n={};for(let o of e){so(r,o,t);let i=n[o.type]??(n[o.type]=io());so(i,o,t)}ao(r);for(let o of Object.values(n))ao(o);return{overall:r,by_type:n}}var ad={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function cd(e){return ad[e]}function dd(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function ld(e,t,r){switch(t){case"assignee":return[S(e.assignee)??null];case"parent":return[S(e.parent)??null];case"type":return[S(e.type)??null];case"status":return[S(e.status)??null];case"priority":return[typeof e.priority=="number"?`P${e.priority}`:null];default:{let n=r.tagPrefix?.trim(),i=(Array.isArray(e.tags)?e.tags:[]).filter(s=>typeof s=="string"&&s.length>0&&(!n||s.startsWith(n)));return i.length>0?i:[null]}}}function Vh(e,t,r,n={}){let o=new Map,i=0;for(let a of e){i+=1;let c=r.classify(a.status);for(let d of ld(a,t,n)){let l=d??"\0empty",u=o.get(l);u||(u={label:d??cd(t),key:d,buckets:dd(),total:0},o.set(l,u)),u.buckets[c]+=1,u.total+=1}}let s=[...o.values()].sort((a,c)=>c.total!==a.total?c.total-a.total:a.key===null?1:c.key===null?-1:a.label.localeCompare(c.label));return{dimension:t,rows:s,total_items:i}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2e200f74-0e6c-58ac-ab8c-da49071465ff")}catch{}})();var se=["notes","learnings","files","docs","tests","comments","deps","body","linked_command"];function Q(e){return Array.isArray(e)&&e.length>0}function ud(e){return typeof e=="string"&&e.trim().length>0}function fd(e){return Array.isArray(e)?e.some(t=>{if(typeof t!="object"||t===null)return!1;let r=t.command;return typeof r=="string"&&r.trim().length>0}):!1}function mo(e,t){switch(t){case"notes":return Q(e.notes);case"learnings":return Q(e.learnings);case"files":return Q(e.files);case"docs":return Q(e.docs);case"tests":return Q(e.tests);case"comments":return Q(e.comments);case"deps":return Q(e.dependencies);case"body":return ud(e.body);case"linked_command":return fd(e.tests)}}function po(e){return se.some(t=>e[t]!==void 0)}function _o(e,t){for(let r of se){let n=t[r];if(n===void 0)continue;let o=mo(e,r);if(n==="present"&&!o||n==="absent"&&o)return!1}return!0}function yo(e){return se.some(t=>t!=="body"&&e[t]!==void 0)}function ho(e){return e.body!==void 0}function fo(e,t){return t===0?100:Math.round(e/t*1e3)/10}function md(){let e={};for(let t of se)e[t]={present:0,total:0,percent:100};return e}function Kh(e){let t=md(),r=e.length;for(let s of e)for(let a of se)mo(s,a)&&(t[a].present+=1);for(let s of se)t[s].total=r,t[s].percent=fo(t[s].present,r);let n=t.body,o=r-n.present,i={present:o,total:r,percent:fo(o,r)};return{total_items:r,fields:t,body_populated:n,empty_body:i}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9957767d-cc97-58ad-a46e-3f88a18a3c8c")}catch{}})();var To=e=>({acMissing:e.filterAcMissing===!0,estimatesMissing:e.filterEstimatesMissing===!0,resolutionMissing:e.filterResolutionMissing===!0,metadataMissing:e.filterMetadataMissing===!0,reviewerMissing:e.filterReviewerMissing===!0,riskMissing:e.filterRiskMissing===!0,confidenceMissing:e.filterConfidenceMissing===!0,sprintMissing:e.filterSprintMissing===!0,releaseMissing:e.filterReleaseMissing===!0}),go=[{field:"notes",presentKey:"hasNotes",absentKey:"noNotes",presentFlag:"--has-notes",absentFlag:"--no-notes"},{field:"learnings",presentKey:"hasLearnings",absentKey:"noLearnings",presentFlag:"--has-learnings",absentFlag:"--no-learnings"},{field:"files",presentKey:"hasFiles",absentKey:"noFiles",presentFlag:"--has-files",absentFlag:"--no-files"},{field:"docs",presentKey:"hasDocs",absentKey:"noDocs",presentFlag:"--has-docs",absentFlag:"--no-docs"},{field:"tests",presentKey:"hasTests",absentKey:"noTests",presentFlag:"--has-tests",absentFlag:"--no-tests"},{field:"comments",presentKey:"hasComments",absentKey:"noComments",presentFlag:"--has-comments",absentFlag:"--no-comments"},{field:"deps",presentKey:"hasDeps",absentKey:"noDeps",presentFlag:"--has-deps",absentFlag:"--no-deps"},{field:"body",presentKey:"hasBody",absentKey:"emptyBody",presentFlag:"--has-body",absentFlag:"--empty-body"},{field:"linked_command",presentKey:"hasLinkedCommand",absentKey:"noLinkedCommand",presentFlag:"--has-linked-command",absentFlag:"--no-linked-command"}],dr=e=>{let t=go.find(r=>e[r.presentKey]===!0&&e[r.absentKey]===!0);if(t)throw new m(`Cannot combine ${t.presentFlag} with ${t.absentFlag} for the same field.`,f.USAGE);return Object.fromEntries(go.flatMap(r=>e[r.presentKey]===!0?[[r.field,"present"]]:e[r.absentKey]===!0?[[r.field,"absent"]]:[]))},wo=["priority","deadline","updated_at","created_at","title","parent"],bo=["asc","desc"],vo=new Set(xr);function pd(e,t,r){let n=e.filter(s=>s.startsWith("item_list_item_read_failed:")).length,o=e.filter(s=>s.startsWith("item_list_directory_read_failed:")).length,i={status:t?"unchecked":n+o>0?"partial":"complete",unreadable_item_count:n,unreadable_directory_count:o};if(r&&i.status==="partial")throw new m(`List source is incomplete: ${n} item document(s) and ${o} item directory/directories could not be read.`,f.GENERIC_FAILURE,{code:"list_source_incomplete",why:"Strict list reads fail closed so agents and SDK consumers never treat an omitted item as a complete workspace.",nextSteps:["Run pm validate --check-storage-integrity to locate unreadable tracker artifacts.","Repair the reported files or align the installed decoder version, then retry."]});return i}function _d(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length>0}var yd=[{key:"hasNotes",summaryKey:"has_notes"},{key:"hasLearnings",summaryKey:"has_learnings"},{key:"hasFiles",summaryKey:"has_files"},{key:"hasDocs",summaryKey:"has_docs"},{key:"hasTests",summaryKey:"has_tests"},{key:"hasComments",summaryKey:"has_comments"},{key:"hasDeps",summaryKey:"has_deps"},{key:"hasBody",summaryKey:"has_body"},{key:"hasLinkedCommand",summaryKey:"has_linked_command"},{key:"noNotes",summaryKey:"no_notes"},{key:"noLearnings",summaryKey:"no_learnings"},{key:"noFiles",summaryKey:"no_files"},{key:"noDocs",summaryKey:"no_docs"},{key:"noTests",summaryKey:"no_tests"},{key:"noComments",summaryKey:"no_comments"},{key:"noDeps",summaryKey:"no_deps"},{key:"emptyBody",summaryKey:"empty_body"},{key:"noLinkedCommand",summaryKey:"no_linked_command"}],hd=[{key:"filterReviewerMissing",summaryKey:"filter_reviewer_missing"},{key:"filterRiskMissing",summaryKey:"filter_risk_missing"},{key:"filterConfidenceMissing",summaryKey:"filter_confidence_missing"},{key:"filterSprintMissing",summaryKey:"filter_sprint_missing"},{key:"filterReleaseMissing",summaryKey:"filter_release_missing"}];function Io(e,t){for(let r of yd)t[r.key]===!0&&(e[r.summaryKey]=!0)}function Ao(e,t){for(let r of hd)t[r.key]===!0&&(e[r.summaryKey]=!0)}function gd(e,t,r){for(let n of r){let o=t[n.optionKey];o!==void 0&&(e[n.summaryKey]=n.normalize?n.normalize(o):o)}}function Co(e){let t={};return Io(t,e),t}function xo(e){let t={};return Ao(t,e),t}var wd=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"}],bd=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"},{optionKey:"limit",summaryKey:"limit"},{optionKey:"offset",summaryKey:"offset"},{optionKey:"includeBody",summaryKey:"include_body"},{optionKey:"compact",summaryKey:"compact"},{optionKey:"fields",summaryKey:"fields"}],Ed=[{key:"filterAcMissing",summaryKey:"filter_ac_missing"},{key:"filterEstimatesMissing",summaryKey:"filter_estimates_missing"},{key:"filterResolutionMissing",summaryKey:"filter_resolution_missing"},{key:"filterMetadataMissing",summaryKey:"filter_metadata_missing"}],Sd="-7d";function Lo(e){let{filtersStatus:t,options:r,treeEnabled:n,treeDepth:o,sortField:i,sortOrder:s,runtimeFieldFilters:a}=e,c={};return t!==null&&(c.status=t),r.dependencyBlocked===!0&&(c.blocked_semantics="status_or_dependency"),gd(c,r,wd),Ro(c,r),r.filterAcMissing===!0&&(c.filter_ac_missing=!0),r.filterEstimatesMissing===!0&&(c.filter_estimates_missing=!0),r.filterResolutionMissing===!0&&(c.filter_resolution_missing=!0),r.filterMetadataMissing===!0&&(c.filter_metadata_missing=!0),Ao(c,r),Io(c,r),r.limit!==void 0&&(c.limit=r.limit),r.offset!==void 0&&(c.offset=r.offset),r.includeBody===!0&&(c.include_body=!0),r.fields!==void 0&&(c.fields=r.fields),n&&(c.tree=!0,o!==void 0&&(c.tree_depth=o)),i!==void 0&&(c.sort=i,c.order=s),_d(a)&&(c.runtime_filters=a),c}function lr(e,t,r){let n=H(e.status,r),o=H(t.status,r);if(n!==o)return n?1:-1;let i=e.priority-t.priority;if(i!==0)return i;let s=te(t.updated_at,e.updated_at);return s!==0?s:(e.id??"").localeCompare(t.id??"")}function Td(e,t){return[...e].sort((r,n)=>lr(r,n,t))}function Eo(e,t){if(e!==void 0)return Ae(e,new Date,t)}function Te(e,t){if(e==null)return;let r=String(e).trim();if(r.length!==0)return Ae(r,new Date,t)}function ko(e){let t=e.updatedAfter!=null&&String(e.updatedAfter).trim().length>0;if([e.today===!0,e.recent===!0,t].filter(n=>n).length>1)throw new m("Choose only one updated_at window: --today, --recent, or --updated-after.",f.USAGE);if(e.today===!0){let n=new Date;return n.setHours(0,0,0,0),n.toISOString()}return e.recent===!0?Te(Sd,"recent"):Te(e.updatedAfter,"updated-after")}function Ro(e,t){t.today===!0&&(e.today=!0),t.recent===!0&&(e.recent=!0)}function Mo(e){if(e==null)return;let t=String(e).trim();if(t.length===0)throw new m("--ids requires at least one non-empty item ID",f.USAGE);let r=t.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(r.length===0)throw new m("--ids requires at least one non-empty item ID",f.USAGE);return new Set(r)}function ur(e){if(e===void 0)return;let t=String(e).trim(),r=t.length===0?Number.NaN:Number(t);if(!Number.isInteger(r)||r<0)throw new m("Offset filter must be a non-negative integer",f.USAGE);return r}function Do(e){if(e===void 0)return;let t=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)throw new m("List --fields requires a comma-separated list of field names",f.USAGE);return[...new Set(t)]}function No(e,t=e.projectionCommand??"list"){let r=e.compact===!0,n=e.brief===!0,o=e.full===!0,i=Do(e.fields);if(Number(r)+Number(n)+Number(o)+ +(i!==void 0)>1)throw new m("List projection options are mutually exclusive. Use one of --compact, --brief, --full, or --fields.",f.USAGE,{code:"projection_options_mutually_exclusive",recovery:{suggested_retry:`pm ${t} --brief`,suggested_retry_args:[t,"--brief"]}});return o?{mode:"full",fields:[]}:n?{mode:"brief",fields:[...lt]}:r?{mode:"compact",fields:[...dt]}:i?{mode:"fields",fields:[...new Set(i.map(a=>j(a)))]}:{mode:"full",fields:[]}}function j(e){return e.startsWith("item.")?e.slice(5):e}function vd(e,t,r){if(e.mode!=="fields")return;let n=ut(t),o=new Set(n.map(s=>j(s))),i=e.fields.filter(s=>!o.has(j(s)));if(i.length>0)throw new m(`Unknown list --fields value(s): ${i.join(", ")}`,f.USAGE,{code:"unknown_field_projection",examples:["pm list-open --fields id,title,status,type,updated_at","pm list --fields id,title,parent,priority --limit 10","pm list-all --fields id,title,body --limit 5"],recovery:{allowed_values:n,suggested_retry:`pm ${r} --fields id,title,status --limit 10`,suggested_retry_args:[r,"--fields","id,title,status","--limit","10"]}})}var Id=new Map([["updated","updated_at"],["update","updated_at"],["modified","updated_at"],["created","created_at"],["create","created_at"]]);function Oo(e){if(e===void 0)return;let t=e.trim().toLowerCase(),r=Id.get(t);if(r)return r;if(!wo.includes(t))throw new m(`Sort field must be one of ${wo.join("|")} (aliases: updated->updated_at, created->created_at)`,f.USAGE);return t}function Fo(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!bo.includes(t))throw new m(`Sort order must be one of ${bo.join("|")}`,f.USAGE);return t}function Ad(e){return Qe(e,"--tree-depth")}function Po(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new m("Assignee filter must be one of assigned|unassigned",f.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new m(`Invalid assignee filter "${e}". Allowed: assigned|unassigned`,f.USAGE);return t}function So(e,t){return Ct(e,t,{strict:!0})}function $o(e){return Se(e,{label:"--tag",normalize:t=>t.toLowerCase()})}function Cd(e,t,r){let n=$o(t);if(n===void 0)return;let o=new Set(e.flatMap(s=>s.tags.map(a=>a.trim().toLowerCase()))),i=[...n].filter(s=>!o.has(s));i.length>0&&r.push(`unknown_tags:${i.join(",")}`)}function xd(e,t){if(e&&[...e].some(r=>r.toLowerCase()==="none"||r.toLowerCase()==="null"))throw new m('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',f.USAGE);if(e!==void 0&&t==="unassigned")throw new m("Cannot combine --assignee with --assignee-filter unassigned",f.USAGE)}function Ld(e,t,r,n){let o=Se(t.assignee,{label:"--assignee"}),i=Po(t.assigneeFilter);xd(o,i);let s=To(t),a=dr(t);return{idsFilter:Mo(t.ids),statusSet:e&&e.length>0?new Set(e):void 0,excludeTerminal:t.excludeTerminal===!0,typeFilter:ro(t.type,r),tagFilters:$o(t.tag),priorityFilter:no(t.priority),deadlineBefore:Eo(t.deadlineBefore,"deadline-before"),deadlineAfter:Eo(t.deadlineAfter,"deadline-after"),updatedAfter:ko(t),updatedBefore:Te(t.updatedBefore,"updated-before"),createdAfter:Te(t.createdAfter,"created-after"),createdBefore:Te(t.createdBefore,"created-before"),assigneeFilter:o,assigneeModeFilter:i,parentFilter:t.parent?.trim(),treeEnabled:t.tree===!0,sprintFilter:Se(t.sprint,{label:"--sprint"}),releaseFilter:Se(t.release,{label:"--release"}),missingMetadataFilters:s,missingMetadataActive:sr(s),lifecycleClassifier:co(n),contentFieldFilters:a,contentFiltersActive:po(a)}}function kd(e,t,r){return t.idsFilter&&!t.idsFilter.has(e.id)||t.statusSet&&!t.statusSet.has(e.status)||t.excludeTerminal&&H(e.status,r)||t.typeFilter&&!t.typeFilter.has(e.type)||t.tagFilters&&![...t.tagFilters].some(n=>(e.tags??[]).some(o=>o.trim().toLowerCase()===n))?!1:t.priorityFilter===void 0||t.priorityFilter.has(e.priority)}function Rd(e,t){return vr(e,t)}function Md(e,t){return t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee?!1:t.assigneeFilter===void 0||e.assignee!==void 0&&t.assigneeFilter.has(e.assignee)}function Dd(e,t,r){let n=e.parent?.trim().toLowerCase(),o=[...new Set([...r?.get(e.id.trim().toLowerCase())??[],...n?[n]:[]])];return t.parentFilter!==void 0&&!t.treeEnabled&&!o.includes(t.parentFilter.trim().toLowerCase())||t.sprintFilter!==void 0&&(e.sprint===void 0||!t.sprintFilter.has(e.sprint))?!1:t.releaseFilter===void 0||e.release!==void 0&&t.releaseFilter.has(e.release)}function Nd(e,t,r,n,o){return!(!kd(e,t,r)||!Rd(e,t)||!Md(e,t)||!Dd(e,t,o)||t.missingMetadataActive&&!uo(e,t.missingMetadataFilters,t.lifecycleClassifier)||t.contentFiltersActive&&!_o(e,t.contentFieldFilters)||!Lt(e,n))}function Uo(e,t,r,n,o,i,s){let a=Ld(t,r,n,o);return e.filter(c=>Nd(c,a,o,i,s))}function ae(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function cr(e,t,r,n){let o=e,i=typeof o.title=="string"?o.title:"",s=n??ae(typeof o.parent=="string"?o.parent:void 0)??null;return{...e,tree_depth:t,tree_parent:s,tree_children:r,tree_title:`${" ".repeat(t)}${i}`}}function Od(e,t){let r=new Map,n=new Map;for(let o of e){let i=o.id.trim().toLowerCase();r.set(i,o);let s=t?t.parents_by_child.get(i)??[]:[ae(o.parent)?.toLowerCase()].filter(a=>a!==void 0);for(let a of s){let c=n.get(a)??[];c.push(o),n.set(a,c)}}return{byId:r,childrenByParent:n}}function Fd(e,t,r,n,o){return t?[...n.get(t.toLowerCase())??[]]:e.filter(i=>(o?o.parents_by_child.get(i.id.trim().toLowerCase())??[]:[ae(i.parent)?.toLowerCase()].filter(a=>a!==void 0)).every(a=>!r.has(a)))}function zo(e,t,r,n,o=e){let{byId:i,childrenByParent:s}=Od(e,n),a=Fd(e,t,i,s,n),c=[],d=new Set,l=new Map(o.map(p=>[p.id.trim().toLowerCase(),p.id.trim()])),u=[...a].reverse().map(p=>({node:p,depth:0,parentId:t===void 0?void 0:l.get(t.trim().toLowerCase())??t.trim()}));for(;u.length>0;){let{node:p,depth:_,parentId:h}=u.pop(),y=p.id.trim().toLowerCase();if(d.has(y))continue;d.add(y);let g=s.get(y)??[];if(c.push(cr(p,_,g.length,h)),!(r!==void 0&&_>=r))for(let b of[...g].reverse())u.push({node:b,depth:_+1,parentId:l.get(y)})}if(t===void 0&&r===void 0)for(let p of e){let _=p.id.trim().toLowerCase();d.has(_)||(d.add(_),c.push(cr(p,0,s.get(_)?.length??0)))}return c}function Vo(e,t){return e===t?0:e===null?1:t===null?-1:e.localeCompare(t)}function jo(e,t){return e===t?0:e===null?1:t===null?-1:te(e,t)}function Ko(e,t,r){switch(r){case"priority":return e.priority-t.priority;case"deadline":return jo(e.deadline??null,t.deadline??null);case"updated_at":return te(e.updated_at,t.updated_at);case"created_at":return te(e.created_at,t.created_at);case"title":return(e.title??"").localeCompare(t.title??"");case"parent":return Vo(e.parent??null,t.parent??null);default:return 0}}function qo(e,t,r,n){return t?[...e].sort((o,i)=>{let s=Ko(o,i,t);if(s!==0)return r==="desc"?-s:s;let a=lr(o,i,n);return r==="desc"?-a:a}):Td(e,n)}function Ho(e,t,r=!1){let n=j(t.trim());if(n.length===0)return null;let o=e;return r&&n==="title"&&typeof o.tree_title=="string"?o.tree_title:Object.prototype.hasOwnProperty.call(o,n)?o[n]??null:null}function fr(e,t,r=!1){return t.mode==="full"?e:e.map(n=>{let o={};for(let i of t.fields)o[i]=Ho(n,i,r);return o})}function Bo(e){let t=[];for(let r of e)t.push(r.metadata_key);return t}function Go(e,t){if(e.noTruncate!==!0)return Qe(e.limit)??(t>=1e4?20:void 0)}function Pd(e,t,r){return t.after===void 0?ur(t.offset)??0:Sr(e,t.after,r,n=>n.id)}function Yo(e,t,r){return{...e!==void 0?{applied_limit:e}:{},has_more:t,truncated:t,next_cursor:r??null}}async function $d(e,t){let r=F(process.cwd(),t.path);await ke(r);let n=await v(r),o=ee(n.schema),i=at(n.schema),s=e.projectionCommand??"list",a=No(e,s);return vd(a,Bo(i.definitions),s),{pmRoot:r,settings:n,statusRegistry:o,runtimeFieldFilters:xt(e,i,"list"),typeRegistry:k(n,q()),projection:a}}async function Ud(e,t,r){let n=t.projection.fields.some(c=>j(c)==="body"),o=t.projection.mode==="full"||t.projection.fields.some(c=>vo.has(j(c))),i=dr(e),s=yo(i),a=ho(i);return e.includeBody||n||a?await Lr(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema):o||s?await bt(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema):await ne(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema)}function zd(e){let t=Oo(e.sort),r=Fo(e.order)??"asc",n=e.tree===!0;if(!n&&e.treeDepth!==void 0)throw new m("List --tree-depth requires --tree",f.USAGE);if(!t&&e.order!==void 0)throw new m("List --order requires --sort",f.USAGE);return{sortField:t,sortOrder:r,treeEnabled:n,treeDepth:n?Ad(e.treeDepth):void 0,parentRoot:n?ae(e.parent):void 0}}function Vd(e,t,r){let n=So(t.status,r),o;t.lifecycleBucket==="in_progress"?o=[r.in_progress_status]:t.lifecycleBucket==="open"&&(o=[...r.active_statuses].filter(d=>d!==r.in_progress_status).sort((d,l)=>d.localeCompare(l)));let i=n??o??So(e,r),s=Zr(t.status),a=n||s?{...t,excludeTerminal:!1}:t,c="all";return s?c="all":n!==void 0?c=n.length===1?n[0]:n:t.lifecycleBucket!==void 0?c=t.lifecycleBucket:i!==void 0?c=i.length===1?i[0]:i:a.excludeTerminal===!0&&(c=null),{resolvedStatus:i,explicitAllStatuses:s,effectiveOptions:a,filtersStatus:c}}function jd(e,t,r,n,o){if(t.after!==void 0&&t.offset!==void 0)throw new m("List --after cannot be combined with --offset.",f.USAGE);let i=Go(t,e.length),s=Pd(e,t,o),a=i===void 0?e.slice(s):e.slice(s,s+i),c=fr(a,r,n),d=e.length,l=a.length>0&&s+a.length<d,u=l&&a.length>0?ct(o,a[a.length-1].id,s+a.length-1):void 0;return{projected:c,totalMatched:d,pageExtras:Yo(i,l,u)}}function Wo(e,t,r){return Er("list",{status:e,options:br(t,wr),sort:r.sortField??"default",order:r.sortOrder,tree:r.treeEnabled,tree_depth:r.treeDepth??null})}async function Kd(e){let{options:t,runtime:r,statusSelection:n,ordering:o}=e,i=new Set(["status","limit","offset","compact","brief","full","fields","format","stream","includeBody","excludeTerminal","dependencyBlocked","lifecycleBucket","noTruncate","projectionCommand","truncate","notes","learnings","files","docs","tests","comments","deps","linkedCommand"]),s=[r.projection.mode==="full",r.projection.fields.some(h=>{let y=j(h);return y==="body"||vo.has(y)})].includes(!0);if([t.limit===void 0,t.after!==void 0,t.noTruncate===!0,t.includeBody===!0,t.dependencyBlocked===!0,t.strictRead===!0,o.treeEnabled,o.sortField!==void 0,s,Tr(),Object.keys(r.runtimeFieldFilters).length>0,Object.entries(t).some(([h,y])=>y!==void 0&&!i.has(h))].includes(!0))return null;let c=await me(r.pmRoot,[...new Set(Object.values(r.typeRegistry.type_to_folder))]);if(!c)return null;let d=Qe(t.limit),l=ur(t.offset)??0,u=await ht({pmRoot:r.pmRoot,expectedSourceCursor:c.source_cursor,query:{statuses:n.resolvedStatus,excludeStatuses:n.resolvedStatus===void 0&&n.effectiveOptions.excludeTerminal===!0?[...r.statusRegistry.terminal_statuses]:void 0,terminalStatuses:[...r.statusRegistry.terminal_statuses],limit:d,offset:l}});if(!u)return null;let p=u.items.length>0&&l+u.items.length<u.total,_=p?ct(Wo(n.filtersStatus,t,o),u.items.at(-1).id,l+u.items.length-1):void 0;return{projected:fr(u.items,r.projection,!1),totalMatched:u.total,pageExtras:Yo(d,p,_)}}function qd(e){let{filtersStatus:t,options:r,noTruncate:n,treeEnabled:o,treeDepth:i,sortField:s,sortOrder:a,runtimeFieldFilters:c}=e,d={};t!==null&&(d.status=t),r.dependencyBlocked===!0&&(d.blocked_semantics="status_or_dependency");let l=r;for(let u of bd){let p=l[u.optionKey];p!=null&&(d[u.summaryKey]=p)}for(let u of Ed)l[u.key]===!0&&(d[u.summaryKey]=!0);return Object.assign(d,xo(r),Co(r)),Ro(d,r),n&&(d.no_truncate=!0),r.strictRead===!0&&(d.strict_read=!0),o&&(d.tree=!0,i!==void 0&&(d.tree_depth=i)),s!==void 0&&(d.sort=s,d.order=a),d.runtime_filters=c,d}async function wg(e,t,r){let n=await $d(t,r),o=[],i=zd(t),s=Vd(e,t,n.statusRegistry),a=t.noTruncate===!0,c=await Kd({options:t,runtime:n,statusSelection:s,ordering:i}),d=c;if(!d){let y=await Ud(t,n,o),b=i.treeEnabled||ae(t.parent)!==void 0?Mr(Rr(y,kr())):void 0;Cd(y,t.tag,o);let A=Uo(y,s.resolvedStatus,s.effectiveOptions,n.typeRegistry,n.statusRegistry,n.runtimeFieldFilters,b?.parents_by_child),L=t.dependencyBlocked===!0?(()=>{let U=Dr(y,n.statusRegistry);return A.filter(Ze=>U.has(Ze.id.trim().toLowerCase()))})():A,$=qo(L,i.sortField,i.sortOrder,n.statusRegistry),K=i.treeEnabled?zo($,i.parentRoot,i.treeDepth,b,y):$;d=jd(K,t,n.projection,i.treeEnabled,Wo(s.filtersStatus,t,i))}let l=R(),u=[...new Set(o)].sort((y,g)=>y.localeCompare(g)),p=pd(u,c!==null,t.strictRead===!0),_=n.projection.mode==="full"?null:[...n.projection.fields];if(n.projection.mode==="compact"&&t.compact===!0){let y=Lo({filtersStatus:s.filtersStatus,options:t,treeEnabled:i.treeEnabled,treeDepth:i.treeDepth,sortField:i.sortField,sortOrder:i.sortOrder,runtimeFieldFilters:n.runtimeFieldFilters});return{items:d.projected,count:d.projected.length,total:d.totalMatched,...d.pageExtras,completeness:p,filters:y,projection:{mode:"compact",fields:_},...u.length>0?{warnings:u}:{}}}return{items:d.projected,count:d.projected.length,total:d.totalMatched,...d.pageExtras,completeness:p,filters:qd({filtersStatus:s.filtersStatus,options:t,noTruncate:a,treeEnabled:i.treeEnabled,treeDepth:i.treeDepth,sortField:i.sortField,sortOrder:i.sortOrder,runtimeFieldFilters:n.runtimeFieldFilters}),projection:{mode:n.projection.mode,fields:_},sorting:{sort:i.sortField??"default",order:i.sortField?i.sortOrder:"asc"},now:l,...u.length>0?{warnings:u}:{}}}var bg={applyFilters:Uo,buildCompactListFilterSummary:Lo,buildContentFilterEcho:Co,buildGovernanceMissingFilterEcho:xo,resolveContentFieldFilters:dr,resolveMissingMetadataFilters:To,compareBySortField:Ko,compareDefaultSort:lr,compareNullableString:Vo,compareNullableTimestamp:jo,normalizeProjectionField:j,parseAssigneeFilter:Po,parseFieldSelectors:Do,parseIdsFilter:Mo,parseOffset:ur,parseProjectionConfig:No,resolveListUpdatedAfter:ko,resolveListPageLimit:Go,parseSortField:Oo,parseSortOrder:Fo,orderItemsAsTree:zo,projectListItems:fr,readListFieldValue:Ho,runtimeMetadataKeysForProjection:Bo,sortItems:qo,trimNonEmpty:ae,withTreeMetadata:cr};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4e54ed7b-3bab-51a2-912b-1284eaf8187a")}catch{}})();var Je=1e6;function mr(e,t=Je,r=.8,n=!1){let o=new Set,i=(l,u)=>{if(o.add(`${l}:${u}`),o.size>t)throw new m(`Duplicate sweep exceeded ${t} candidate pairs; narrow it with statuses or since.`,f.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the duplicate query or increase its similarity threshold. No partial result was returned."})};if(n||r===0){for(let l=0;l<e.length;l+=1)for(let u=0;u<l;u+=1)i(u,l);return o}let s=new Map;for(let{prepared:l}of e)for(let u of l.tokens)s.set(u,(s.get(u)??0)+1);let a=new Map,c=new Map,d=new Map;for(let[l,{prepared:u}]of e.entries()){let p=[...u.tokens].sort((y,g)=>s.get(y)-s.get(g)||y.localeCompare(g)),_=p.length-Math.ceil(r*p.length-1e-12)+1,h=[{index:a,keys:[u.normalized],lengthFilter:!1},{index:c,keys:r<=.99?u.issueCodes:[],lengthFilter:!1},{index:d,keys:p.length===0?[""]:p.slice(0,_),lengthFilter:!0}];for(let y of h)Hd(e,l,y,r,i)}return o}function Hd(e,t,r,n,o){let i=e[t].prepared.tokens.length;for(let s of r.keys){let a=r.index.get(s)??[];for(let c of a){let d=e[c].prepared.tokens.length;r.lengthFilter&&Math.min(d,i)/Math.max(d,i)+1e-12<n||o(c,t)}a.push(t),r.index.set(s,a)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8d07624c-8663-5aba-8018-1b2c47997bef")}catch{}})();var Bd=3,Xo=20,Gd=.8,Yd=100,Qo=1e3;function $g(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`,`likely_duplicate_recovery:${e.recovery.action}:${e.recovery.item_id}`]}async function Wd(e,t){let r=e.items[0],n=F(t.cwd??process.cwd(),t.pmRoot),o=ee((await v(n)).schema);return H(r.status,o)?{action:"reopen",item_id:r.id,command:`pm item reopen ${r.id} "<recurrence reason>"`,args:["item","reopen",r.id,"<recurrence reason>"]}:{action:"reuse",item_id:r.id,command:`pm get ${r.id} --full`,args:["get",r.id,"--full"]}}function pr(e){let t=e.limit??Bd,r=e.threshold??Gd;if(!Number.isSafeInteger(t)||t<0||t>Xo)throw new m(`Similarity limit must be an integer from 0 to ${Xo}.`,f.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new m("Similarity threshold must be a number from 0 to 1.",f.USAGE);return{limit:t,threshold:r}}function Jo(e){let t=e.limit??Yd;if(!Number.isSafeInteger(t)||t<0||t>Qo)throw new m(`Duplicate cluster limit must be an integer from 0 to ${Qo}.`,f.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new m("Duplicate cluster --since must be a valid ISO timestamp.",f.USAGE);return{limit:t,since:r}}async function Xd(e,t){let r=F(e.cwd??process.cwd(),e.pmRoot),n=await v(r),o=k(n),i=e.statuses?.map(u=>u.trim().toLowerCase()).filter(Boolean);if(e.statuses!==void 0&&i?.length===0)throw new m("Duplicate cluster statuses must include at least one lifecycle status or all.",f.USAGE);let s=ee(n.schema),a=i?.map(u=>{if(u==="all")return u;let p=ue(u,s);if(!p)throw new m(`Unknown duplicate-cluster status "${u}". Allowed: all, ${s.definitions.map(_=>_.id).join(", ")}.`,f.USAGE);return p}),c=a?.includes("all")===!0;if(c&&a?.some(u=>u!=="all"))throw new m('The "all" status cannot be combined with other statuses.',f.USAGE);let d=c?void 0:a,l=d?new Set(d):void 0;return{items:(await ne(r,n.item_format,o.type_to_folder,void 0,n.schema)).filter(u=>(!l||l.has(u.status))&&(!t||new Date(u.created_at).getTime()>=t.getTime())),statuses:d}}var Ug={buildDuplicateClusters:ei,collectDuplicateCandidatePairs:mr,createDuplicateUnionFind:Zo};function Zo(e){let t=Array.from({length:e},(n,o)=>o);return{parent:t,findRoot:n=>{let o=n;for(;t[o]!==o;)o=t[o];for(;t[n]!==n;){let i=t[n];t[n]=o,n=i}return o}}}function Qd(e,t,r,n){let o=[];for(let i of t){let[s,a]=i.split(":").map(u=>Number.parseInt(u,10)),c=De(e[s].prepared,e[a].prepared);if(c.score<r)continue;let d=n.findRoot(s),l=n.findRoot(a);d!==l&&(n.parent[l]=d),o.push({left_id:e[s].item.id,right_id:e[a].item.id,...c})}return o}function ei(e,t,r,n){let o=new Map;for(let a of e.keys()){let c=r.findRoot(a),d=o.get(c)??[];d.push(a),o.set(c,d)}let i=new Map(e.map(({item:a},c)=>[a.id,r.findRoot(c)])),s=new Map;for(let a of t){let c=i.get(a.left_id),d=s.get(c)??[];d.push(a),s.set(c,d)}return[...o.values()].filter(a=>a.length>1).map(a=>{let c=(s.get(r.findRoot(a[0]))??[]).sort((d,l)=>l.score-d.score||d.left_id.localeCompare(l.left_id)||d.right_id.localeCompare(l.right_id));return{id:e[a[0]].item.id,items:a.map(d=>{let l=e[d].item;return{id:l.id,title:l.title,status:l.status,type:l.type}}),matches:c,max_score:c[0]?.score??0}}).sort((a,c)=>c.max_score-a.max_score||a.id.localeCompare(c.id)).slice(0,n)}function Jd(e,t,r,n,o){return t.filter(i=>!r.has(i.id)).map(i=>({id:i.id,title:i.title,status:i.status,type:i.type,...Me(e,i.title)})).filter(i=>i.score>=n).sort((i,s)=>s.score-i.score||i.id.localeCompare(s.id)).slice(0,o)}async function Zd(e,t={}){let r=e.title.trim();if(r.length===0)throw new m("Similarity candidate title must not be empty.",f.USAGE);let{limit:n,threshold:o}=pr(t),i=F(t.cwd??process.cwd(),t.pmRoot),s=await v(i),a=k(s),c=await me(i,Object.values(a.type_to_folder)),d=he(r),l=c&&d.length>0?await gt({pmRoot:i,expectedSourceCursor:c.source_cursor,query:d.map(_=>`"${_.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(n*10,50)}):null,u=l===null?await ne(i,s.item_format,a.type_to_folder,void 0,s.schema):l.items,p=Jd(r,u,new Set(e.excludeIds??[]),o,n);return{items:p,count:p.length,threshold:o,source:l?"persistent_index":"metadata_fallback"}}function el(e,t={}){let{threshold:r}=pr({...t,limit:void 0}),{limit:n}=Jo(t),o=new Set;for(let l of e){if(!l.id.trim()||o.has(l.id))throw new m("Duplicate analysis requires unique non-empty item ids.",f.USAGE);o.add(l.id)}let i=[...e].sort((l,u)=>l.id.localeCompare(u.id)).map(l=>({item:l,prepared:ye(l.title)})),s=mr(i,Je,r,t.exhaustive===!0),a=Zo(i.length),c=Qd(i,s,r,a),d=ei(i,c,a,n);return{clusters:d,count:d.length,threshold:r,cost:{item_count:i.length,algorithm:t.exhaustive===!0||r===0?"exhaustive":"prefix_exact",possible_pairs:i.length*(i.length-1)/2,pair_limit:Je,recall_guarantee:"exact",candidate_pairs:s.size,scored_pairs:s.size}}}async function zg(e={}){pr({...e,limit:void 0});let{since:t}=Jo(e),{items:r,statuses:n}=await Xd(e,t);return{...el(r,e),source:"metadata_scan",filters:{statuses:n??null,since:e.since??null}}}async function Vg(e,t){if(t.mode==="off")return;let r=await Zd(e,t);if(r.count===0)return;let n=await Wd(r,t),o=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!o){let i=r.items.map(a=>`${a.id} (${a.status}): ${a.title}`).join("; "),s=n.action==="reopen"?"Reopen the canonical item":"Reuse the canonical item";throw new m(`Likely duplicate item(s) found: ${i}. ${s} or pass --allow-duplicate with explicit intent.`,f.CONFLICT,{code:"likely_duplicate",required:`${s}, or explicitly acknowledge the duplicate with --allow-duplicate.`,recovery:{suggested_flags:["--allow-duplicate"],suggested_retry:n.command,suggested_retry_args:n.args}})}return{mode:t.mode,bypassed:o,result:r,recovery:n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cb9a55d6-9ba9-50af-a54f-2bba5d076fdb")}catch{}})();function _r(e,t=!1){let r=e[0];if(r?.op!=="history_compact_baseline")return 0;let n=r.context?.history_compaction,o=typeof n=="object"&&n!==null&&"version_offset"in n?n.version_offset:void 0;if(typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&Number.isSafeInteger(o+e.length))return o;if(t)return null;throw new m("This compacted stream has no trustworthy version offset; numeric history addresses are unavailable.",f.USAGE,{code:"history_version_mapping_unavailable",required:"Use a retained timestamp or recover the pre-compaction stream from version control.",nextSteps:["Run pm history <id> --full to inspect the retained timestamps and checkpoint evidence."]})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8835b501-34c7-51ba-b02e-782f8a457e1b")}catch{}})();function tl(e,t){let r=-1;return e.forEach((n,o)=>{let i=Date.parse(n.ts);if(!Number.isFinite(i))throw new m(`History for this item contains invalid timestamp at entry ${o+1}.`,f.GENERIC_FAILURE);i<=t&&(r=o)}),r}function rl(e,t){let r=e[0]?.ts??null,n=e.at(-1)?.ts??null,o={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:r,last_timestamp:n}};return n!==null&&(o.examples=[n],t!==null&&(o.examples.unshift(String(t+1),String(t+e.length)),o.valid_range.first_version=t+1,o.valid_range.last_version=t+e.length)),{guidance:o,lastTimestamp:n}}function nl(e,t){let r={};if(t instanceof Error&&t.message.trim().length>0&&(r.reason=t.message.trim()),typeof t!="object"||t===null)return r;let n=t;if(typeof n.index=="number"&&Number.isInteger(n.index)&&n.index>=0&&(r.patchIndex=n.index),typeof n.operation=="object"&&n.operation!==null){let o=n.operation;Object.assign(r,Object.fromEntries(["op","path","from"].flatMap(i=>{let s=o[i];return typeof s=="string"?[[i,s]]:[]})))}if(r.patchIndex!==void 0){let o=e[r.patchIndex];o&&(r.op??=o.op,r.path??=o.path,r.from??=o.from)}return r}function Xg(e,t,r={}){let n=e.trim(),o=r.errorSubject??"history",i=o==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=rl(t,_r(t,!0));if(!n)throw new m(`Missing ${o} target. Use a timestamp or version number.`,f.USAGE,s);if(/^\d+$/.test(n)){let l=_r(t),u=Number(n);if(u>=1&&u<=l)throw new m(`History version ${u} was pruned by compaction.`,f.USAGE,{...s,code:"history_version_pruned"});if(!Number.isSafeInteger(u)||u<1||u>l+t.length)throw new m(`${i} version must be between ${l+1} and ${l+t.length} for this item.`,f.USAGE,s);return{kind:"version",raw:n,historyIndex:u-l-1}}let c=Date.parse(n);if(!Number.isFinite(c))throw new m(`Invalid ${o} target "${e}". Use a positive version number or ISO timestamp.`,f.USAGE,s);let d=tl(t,c);if(d<0||r.allowFutureTimestamp!==!0&&c>Date.parse(a))throw new m(o==="restore"?`No history entries exist at or before timestamp ${n}.`:`No history entry exists at timestamp ${n}.`,f.USAGE,s);return{kind:"timestamp",raw:n,historyIndex:d}}function ol(e,t,r,n){let o=fe(e,t);if(o.ok)return o.document;let i=nl(t,o.error),s=[`history_op=${n}`,i.patchIndex===void 0?null:`patch_index=${i.patchIndex}`,i.op?`op=${i.op}`:null,i.path?`path=${i.path}`:null,i.from?`from=${i.from}`:null].filter(a=>a!==null);throw new m(`Failed to apply history patch at entry ${r} (${s.join(", ")}). ${i.reason??String(o.error)}`,f.GENERIC_FAILURE)}function Qg(e,t){let r=e[0];if(r&&r.op!=="create"&&r.op!=="history_compact_baseline"){let s=fe(_t,r.patch);if(!s.ok||typeof s.document.metadata.id!="string")throw new m("History starts without a reconstructable item baseline.",f.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the missing baseline."]})}let n=e.slice(0,t+1),o=yt([...n]),i=structuredClone(_t);for(let s=0;s<=t;s+=1){let a=e[s];if(!a)throw new m(`History target entry ${s+1} does not exist.`,f.USAGE);i=ol(i,a.patch,s+1,a.op)}if(!o.ok)throw new m(`History cannot be replayed: ${o.errors.join(", ")}.`,f.GENERIC_FAILURE,{code:"history_replay_invalid",verification_errors:o.errors,required:"Inspect the history integrity findings before attempting recovery.",nextSteps:["Run pm history <id> --verify --full."]});return i}function Jg(e,t){if(Object.keys(e.metadata).length>0){if(typeof e.metadata.id!="string"||!Array.isArray(e.metadata.tags))throw new m("History has no complete item baseline for this target.",f.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the first recorded state."]});return e}throw new m(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,f.USAGE)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e252abd5-9585-56f7-9fc2-7b20459a2238")}catch{}})();async function uw(e){let t=F(process.cwd(),e);await ke(t);let r=await v(t),n=k(r,q());return{pmRoot:t,settings:r,typeRegistry:n}}async function fw(e,t,r,n){de(e,Le(t));let o=await pe(e,t,r.id_prefix,r.item_format,n);if(o)return{id:o.id,historyPath:de(e,o.id),located:o};let i=re(t,r.id_prefix),s=Le(t),a=i===s?[i]:[i,s];for(let c of a){let d=de(e,c);if(await z(d))return{id:c,historyPath:d,located:null}}throw new m(`Item ${t} not found`,f.NOT_FOUND)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e15abc24-c46a-512b-b859-015186c960df")}catch{}})();function pw(e,t){let r=t??{};return e.filter(n=>r[n.id]!==n.updated_at).map(n=>n.id).sort((n,o)=>n.localeCompare(o))}export{_r as a,Xg as b,ol as c,Qg as d,Jg as e,uw as f,fw as g,bi as h,Ei as i,Ti as j,vi as k,Ll as l,Ii as m,Ai as n,Dl as o,Kr as p,Ci as q,xi as r,Li as s,ki as t,Fi as u,Ui as v,Nl as w,zi as x,Yr as y,ji as z,Ki as A,Ol as B,qi as C,Oe as D,Fl as E,Fe as F,Bi as G,Gi as H,vt as I,Wi as J,It as K,Xi as L,Ql as M,Ji as N,Xr as O,Zi as P,es as Q,ns as R,ou as S,ss as T,Ct as U,us as V,Nr as W,xt as X,Lt as Y,Ue as Z,Os as _,Ru as $,kt as aa,cn as ba,Rt as ca,Gs as da,Ys as ea,Nu as fa,dn as ga,oe as ha,Dt as ia,Ot as ja,Kt as ka,Hu as la,qt as ma,Be as na,yn as oa,Ge as pa,Ht as qa,Bt as ra,Gt as sa,Yt as ta,Sn as ua,Tn as va,mf as wa,ai as xa,Fr as ya,di as za,li as Aa,ui as Ba,ul as Ca,ml as Da,_e as Ea,Re as Fa,he as Ga,ye as Ha,Me as Ia,De as Ja,Pr as Ka,yi as La,qa as Ma,Ga as Na,Wa as Oa,Xa as Pa,ac as Qa,On as Ra,bc as Sa,ym as Ta,Qe as Ua,to as Va,Ih as Wa,pw as Xa,nr as Ya,Se as Za,ro as _a,no as $a,co as ab,sr as bb,uo as cb,zh as db,Vh as eb,po as fb,_o as gb,Kh as hb,To as ib,dr as jb,wo as kb,bo as lb,gd as mb,Co as nb,xo as ob,wg as pb,bg as qb,$g as rb,Ug as sb,Zd as tb,el as ub,zg as vb,Vg as wb};
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
20
|
+
//# sourceMappingURL=chunk-ZJHYQOTM.js.map
|