@unbrained/pm-cli 2026.8.17 → 2026.8.19

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.
Files changed (204) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/AGENTS.md +4 -3
  3. package/CHANGELOG.md +51 -5
  4. package/README.md +3 -3
  5. package/dist/cli/error-guidance.js +8 -4
  6. package/dist/cli/help-content.js +32 -13
  7. package/dist/cli/help-json-payload.d.ts +15 -0
  8. package/dist/cli/help-json-payload.js +101 -23
  9. package/dist/cli/main.js +6 -2
  10. package/dist/cli/register-list-query.js +138 -54
  11. package/dist/cli/register-mutation.js +8 -8
  12. package/dist/cli/register-operations.js +6 -6
  13. package/dist/cli-bundle/bundle-manifest.json +149 -149
  14. package/dist/cli-bundle/chunks/chunk-4NRRH7AM.js +2 -0
  15. package/dist/cli-bundle/chunks/chunk-4THEB6PD.js +13 -0
  16. package/dist/cli-bundle/chunks/{chunk-HBJAS566.js → chunk-BHYMXLAE.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-GWMXAQOD.js +197 -0
  18. package/dist/cli-bundle/chunks/chunk-HVFQTLYM.js +35 -0
  19. package/dist/cli-bundle/chunks/chunk-OI4XI562.js +5 -0
  20. package/dist/cli-bundle/chunks/{chunk-3UEGXBMR.js → chunk-OIOKV6NO.js} +58 -54
  21. package/dist/cli-bundle/chunks/chunk-QXSH7BLM.js +3 -0
  22. package/dist/cli-bundle/chunks/chunk-SARFF5H5.js +3 -0
  23. package/dist/cli-bundle/chunks/{chunk-7IBRGCHX.js → chunk-TOXJM4WA.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-JOKATURE.js → chunk-YBMRWW4E.js} +44 -44
  25. package/dist/cli-bundle/chunks/register-list-query-Y56KINDU.js +11 -0
  26. package/dist/cli-bundle/chunks/register-mutation-AUWVCW4M.js +20 -0
  27. package/dist/cli-bundle/chunks/register-operations-PZQPHXW5.js +2 -0
  28. package/dist/cli-bundle/chunks/{register-setup-DOSFBGKE.js → register-setup-I4LUHGVW.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-34QBIYZI.js +155 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-MHPIL773.js → chunk-BJRYFVSH.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-DKPLYW3L.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-SALH6B6K.js → chunk-EF6ZS5GH.js} +44 -44
  33. package/dist/cli-bundle/focused-chunks/{chunk-XKAMP5OU.js → chunk-ESISGDAY.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-SYZENPIT.js → chunk-EXBCLIBU.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-JDOMQ7VQ.js +4 -0
  36. package/dist/cli-bundle/focused-chunks/chunk-L623ZPNK.js +2 -0
  37. package/dist/cli-bundle/focused-chunks/chunk-MCZXYZAF.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-ODHQEECS.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-ZQPGZZWQ.js → chunk-PRHY2IMX.js} +3 -3
  40. package/dist/cli-bundle/focused-chunks/chunk-RZU5U6Q7.js +2 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-ATEY76SX.js → chunk-US7VEYZG.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/chunk-VXDSU5MC.js +26 -0
  43. package/dist/cli-bundle/focused-chunks/chunk-YBMGXBFV.js +16 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-YLVBJ6GF.js +2 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-CYFK5UPB.js → chunk-ZBIQQYMI.js} +2 -2
  46. package/dist/cli-bundle/main.js +13 -13
  47. package/dist/cli-bundle/sdk-authoring.js +1 -1
  48. package/dist/cli-bundle/sdk-contracts.js +2 -1
  49. package/dist/cli-bundle/sdk-core.js +28 -28
  50. package/dist/cli-bundle/sdk-governance.js +1 -1
  51. package/dist/cli-bundle/sdk-graph.js +1 -1
  52. package/dist/cli-bundle/sdk-merge.js +32 -32
  53. package/dist/cli-bundle/sdk-query.js +1 -1
  54. package/dist/cli-bundle/sdk-runtime.js +1 -1
  55. package/dist/cli-bundle/sdk-testing.js +1 -1
  56. package/dist/cli-bundle/sdk.js +5 -4
  57. package/dist/core/config/nested-settings.js +8 -2
  58. package/dist/core/extensions/exporter-output-contract.d.ts +12 -0
  59. package/dist/core/extensions/exporter-output-contract.js +67 -0
  60. package/dist/core/extensions/extension-types.d.ts +36 -1
  61. package/dist/core/extensions/extension-types.js +2 -2
  62. package/dist/core/extensions/loader.js +35 -44
  63. package/dist/core/history/event-index.d.ts +5 -0
  64. package/dist/core/history/event-index.js +133 -27
  65. package/dist/core/sentry/helpers.js +3 -3
  66. package/dist/core/shared/constants.js +5 -2
  67. package/dist/core/shared/errors.d.ts +2 -0
  68. package/dist/core/shared/errors.js +2 -2
  69. package/dist/core/store/settings-validator.d.ts +4 -0
  70. package/dist/core/store/settings-validator.js +3 -2
  71. package/dist/core/store/settings.js +8 -2
  72. package/dist/mcp/tool-definitions.js +12 -7
  73. package/dist/sdk/agent/refusal-closure.d.ts +41 -0
  74. package/dist/sdk/agent/refusal-closure.js +92 -0
  75. package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
  76. package/dist/sdk/agent/refusal-reachability.js +4 -4
  77. package/dist/sdk/agent-capability-contracts.d.ts +13 -0
  78. package/dist/sdk/agent-capability-contracts.js +104 -7
  79. package/dist/sdk/authoring.d.ts +1 -1
  80. package/dist/sdk/authoring.js +2 -2
  81. package/dist/sdk/cli-bootstrap.d.ts +2 -2
  82. package/dist/sdk/cli-bootstrap.js +4 -4
  83. package/dist/sdk/cli-contracts/command-aliases.d.ts +34 -2
  84. package/dist/sdk/cli-contracts/command-aliases.js +80 -13
  85. package/dist/sdk/cli-contracts/commander-mutation-options.js +30 -6
  86. package/dist/sdk/cli-contracts/commander-types.js +5 -4
  87. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -0
  88. package/dist/sdk/cli-contracts/enum-contracts.js +9 -2
  89. package/dist/sdk/cli-contracts/flag-contracts.d.ts +5 -0
  90. package/dist/sdk/cli-contracts/flag-contracts.js +84 -13
  91. package/dist/sdk/cli-contracts/flag-lexicon-contracts.d.ts +55 -0
  92. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +240 -0
  93. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +151 -0
  94. package/dist/sdk/cli-contracts/grammar-contracts.js +958 -0
  95. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +33 -5
  96. package/dist/sdk/cli-contracts/runtime-contracts.js +100 -23
  97. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +28 -1
  98. package/dist/sdk/cli-contracts/tool-option-contracts.js +38 -3
  99. package/dist/sdk/cli-contracts/tool-parameter-tables.js +7 -2
  100. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  101. package/dist/sdk/cli-contracts/tool-schema.js +20 -11
  102. package/dist/sdk/cli-contracts.d.ts +5 -4
  103. package/dist/sdk/cli-contracts.js +7 -6
  104. package/dist/sdk/completion.js +13 -15
  105. package/dist/sdk/compose.d.ts +3 -3
  106. package/dist/sdk/compose.js +2 -2
  107. package/dist/sdk/context-intent-contracts.d.ts +2 -2
  108. package/dist/sdk/context-intent-contracts.js +22 -7
  109. package/dist/sdk/contracts.d.ts +3 -0
  110. package/dist/sdk/contracts.js +5 -2
  111. package/dist/sdk/core.d.ts +1 -1
  112. package/dist/sdk/core.js +3 -3
  113. package/dist/sdk/environment/host-environment-errors.js +3 -3
  114. package/dist/sdk/flag-invocation-contracts.d.ts +37 -0
  115. package/dist/sdk/flag-invocation-contracts.js +218 -9
  116. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +186 -14
  117. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +194 -26
  118. package/dist/sdk/guide-topics.js +5 -5
  119. package/dist/sdk/index.d.ts +10 -7
  120. package/dist/sdk/index.js +10 -7
  121. package/dist/sdk/init-agent-guidance.js +3 -3
  122. package/dist/sdk/mutation-events.d.ts +18 -2
  123. package/dist/sdk/mutation-events.js +59 -16
  124. package/dist/sdk/output-projection.d.ts +2 -0
  125. package/dist/sdk/output-projection.js +11 -5
  126. package/dist/sdk/output.d.ts +44 -0
  127. package/dist/sdk/output.js +28 -2
  128. package/dist/sdk/query/complete-list.d.ts +94 -0
  129. package/dist/sdk/query/complete-list.js +173 -0
  130. package/dist/sdk/query/get.js +25 -6
  131. package/dist/sdk/query/list.js +19 -2
  132. package/dist/sdk/query/search-contracts.d.ts +1 -1
  133. package/dist/sdk/query/search-contracts.js +23 -9
  134. package/dist/sdk/query/search.js +3 -3
  135. package/dist/sdk/query.d.ts +1 -0
  136. package/dist/sdk/query.js +3 -2
  137. package/dist/sdk/read-output/continuation.d.ts +1 -1
  138. package/dist/sdk/read-output/continuation.js +7 -24
  139. package/dist/sdk/read-output-contracts.d.ts +2 -2
  140. package/dist/sdk/read-output-contracts.js +89 -13
  141. package/dist/sdk/read-output-rows.d.ts +4 -0
  142. package/dist/sdk/read-output-rows.js +47 -18
  143. package/dist/sdk/runtime-extended-actions.js +10 -2
  144. package/dist/sdk/runtime.d.ts +8 -2
  145. package/dist/sdk/runtime.js +18 -11
  146. package/dist/sdk/workspace-snapshot.d.ts +2 -0
  147. package/dist/sdk/workspace-snapshot.js +10 -2
  148. package/dist/types.d.ts +5 -0
  149. package/dist/types.js +2 -2
  150. package/docs/AGENT_GUIDE.md +25 -9
  151. package/docs/CLI_GRAMMAR.md +106 -0
  152. package/docs/COMMANDS.md +39 -27
  153. package/docs/ONBOARDING.md +4 -4
  154. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +11 -2
  155. package/docs/QUICKSTART.md +1 -1
  156. package/docs/README.md +2 -0
  157. package/docs/READ_OUTPUT_CONTRACTS.md +10 -6
  158. package/docs/RELEASING.md +30 -6
  159. package/docs/SDK.md +42 -2
  160. package/docs/SDK_ARTIFACT_OUTPUT.md +72 -0
  161. package/docs/SDK_CONTEXT_COORDINATION.md +46 -12
  162. package/docs/TESTING.md +14 -1
  163. package/docs/agent-task-token-baseline.json +5 -5
  164. package/docs/generated/AGENT_COMMAND_SURFACE.md +78 -78
  165. package/docs/generated/FLAG_LEXICON_BUDGETS.md +76 -0
  166. package/marketplace.json +2 -2
  167. package/package.json +5 -2
  168. package/packages/pm-beads/package.json +1 -1
  169. package/packages/pm-calendar/package.json +1 -1
  170. package/packages/pm-command-kit/package.json +1 -1
  171. package/packages/pm-digital-twin/package.json +1 -1
  172. package/packages/pm-governance-audit/package.json +1 -1
  173. package/packages/pm-guide-shell/package.json +1 -1
  174. package/packages/pm-kanban/package.json +1 -1
  175. package/packages/pm-lifecycle-hooks/package.json +1 -1
  176. package/packages/pm-linked-test-adapters/package.json +1 -1
  177. package/packages/pm-search-advanced/package.json +1 -1
  178. package/packages/pm-templates/package.json +1 -1
  179. package/packages/pm-todos/package.json +1 -1
  180. package/packages/pm-vcs/package.json +1 -1
  181. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  182. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  183. package/scripts/generate-agent-capability-surfaces.mjs +20 -14
  184. package/sdk/public-surface.json +1245 -60
  185. package/dist/cli-bundle/chunks/chunk-2QLOXC3V.js +0 -3
  186. package/dist/cli-bundle/chunks/chunk-4JPYF536.js +0 -35
  187. package/dist/cli-bundle/chunks/chunk-6VDLG2FC.js +0 -13
  188. package/dist/cli-bundle/chunks/chunk-ION3E43Q.js +0 -197
  189. package/dist/cli-bundle/chunks/chunk-OAC5NIV4.js +0 -3
  190. package/dist/cli-bundle/chunks/chunk-TPXZIBIV.js +0 -5
  191. package/dist/cli-bundle/chunks/chunk-YM2YAMF7.js +0 -2
  192. package/dist/cli-bundle/chunks/register-list-query-Q7KII4G5.js +0 -10
  193. package/dist/cli-bundle/chunks/register-mutation-4WBRPXLV.js +0 -20
  194. package/dist/cli-bundle/chunks/register-operations-SSENDH5B.js +0 -2
  195. package/dist/cli-bundle/focused-chunks/chunk-267MUUS6.js +0 -16
  196. package/dist/cli-bundle/focused-chunks/chunk-2NNFLLNG.js +0 -2
  197. package/dist/cli-bundle/focused-chunks/chunk-2QSAKMIH.js +0 -2
  198. package/dist/cli-bundle/focused-chunks/chunk-BUCG4ZI2.js +0 -2
  199. package/dist/cli-bundle/focused-chunks/chunk-EHXIKD6K.js +0 -2
  200. package/dist/cli-bundle/focused-chunks/chunk-KGEXTMPG.js +0 -2
  201. package/dist/cli-bundle/focused-chunks/chunk-KP2VQQVQ.js +0 -2
  202. package/dist/cli-bundle/focused-chunks/chunk-POEEAD2V.js +0 -4
  203. package/dist/cli-bundle/focused-chunks/chunk-XPIC53VA.js +0 -26
  204. package/dist/cli-bundle/focused-chunks/chunk-ZT2DJS27.js +0 -155
@@ -1,4 +1,4 @@
1
- import{$ as It,$a as M,Fa as Ct,La as vt,V as R,_a as se,aa as At,ab as ae,fb as ce,ja as K,jb as Ue,l as Pe,nb as Ve,o as ie,oa as ze,pa as $e,qb as qe,ra as Fe,rb as je,tb as de}from"./chunk-ZT2DJS27.js";import{$ as xt,G as U,M as oe,O as Re,P as Me,Q as ke,R as St,Sa as Oe,V as g,X as W,Y as V,Z as b,a as Le,q as F,s as G,t as S,u as T,w as ne}from"./chunk-POEEAD2V.js";import{R as De,Y as f,Z as m,ba as Ne}from"./chunk-EHXIKD6K.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]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function en(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]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var tn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,rn=/\bnpm_[A-Za-z0-9]{36}\b/,nn=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,on=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,sn=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,Lt=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,an=[{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"}],Ye=new Map(an.map(e=>[e.action,e]));function cn(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 He(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)=>He(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>He(o,`${t}.${n}`,r)))}function Dt(e){let t=[];for(let r of He(e)){tn.test(r.value)&&t.push({rule:"github_token",path:r.path}),rn.test(r.value)&&t.push({rule:"npm_token",path:r.path}),nn.test(r.value)&&t.push({rule:"slack_token",path:r.path}),on.test(r.value)&&t.push({rule:"private_key",path:r.path}),sn.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),Lt.lastIndex=0;for(let n of r.value.matchAll(Lt)){let o=n[1];if(cn(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 dn(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=Dt(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 ln(e){return Ye.has(e.trim().toLowerCase())}function un(){return[...Ye.keys()].sort((e,t)=>e.localeCompare(t))}function la(e){return Ye.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]="3ad30a32-0f83-5473-b0a3-349e271d8378")}catch{}})();function fn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function fa(e){return fn(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function Q(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]="dff9b113-2b29-5154-afbf-f191f2f556a6")}catch{}})();var mn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function le(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function J(e){return[...new Set(le(e).match(/[\p{L}\p{N}]+/gu)??[])]}function X(e){let t=le(e);return{normalized:t,tokens:J(t),issueCodes:[...new Set(t.match(mn)?.map(r=>r.toLowerCase())??[])]}}function ue(e,t){return fe(X(e),X(t))}function fe(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:Q(e.tokens,t.tokens),reason:"title_token_jaccard"}}import pn 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]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function me(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function _n(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 Rt(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=me(t.in_progress_status),i=[];for(let s of e){if(me(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=_n(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 hn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>me(String(o.status))===me(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Fe(pn.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)})),Rt(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as gn,readFile as yn}from"node:fs/promises";import Mt from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function wn(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 En(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function kt(e,t){return Mt.join(e,"checkpoints",t)}function Nt(e,t,r){return Mt.join(kt(e,t),`${r}.json`)}async function bn(e,t,r,n){let o=kt(e,t);await gn(o,{recursive:!0});let i=Nt(e,t,r);return await T(i,`${JSON.stringify(n,null,2)}
1
+ import{$ as It,$a as se,Ga as Ct,Ma as vt,V as R,aa as At,ab as M,bb as ae,gb as ce,ja as K,kb as Ue,l as Pe,o as ie,oa as ze,ob as Ve,pa as $e,ra as Fe,rb as qe,sb as je,ub as de}from"./chunk-34QBIYZI.js";import{$ as xt,G as U,M as oe,O as Re,P as Me,Q as ke,R as St,Sa as Oe,V as g,X as W,Y as V,Z as b,a as Le,q as F,s as G,t as S,u as T,w as ne}from"./chunk-JDOMQ7VQ.js";import{R as De,Y as f,Z as m,ba as Ne}from"./chunk-RZU5U6Q7.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]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function en(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]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var tn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,rn=/\bnpm_[A-Za-z0-9]{36}\b/,nn=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,on=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,sn=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,Lt=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,an=[{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"}],Ye=new Map(an.map(e=>[e.action,e]));function cn(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 He(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)=>He(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>He(o,`${t}.${n}`,r)))}function Dt(e){let t=[];for(let r of He(e)){tn.test(r.value)&&t.push({rule:"github_token",path:r.path}),rn.test(r.value)&&t.push({rule:"npm_token",path:r.path}),nn.test(r.value)&&t.push({rule:"slack_token",path:r.path}),on.test(r.value)&&t.push({rule:"private_key",path:r.path}),sn.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),Lt.lastIndex=0;for(let n of r.value.matchAll(Lt)){let o=n[1];if(cn(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 dn(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=Dt(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 ln(e){return Ye.has(e.trim().toLowerCase())}function un(){return[...Ye.keys()].sort((e,t)=>e.localeCompare(t))}function la(e){return Ye.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]="3ad30a32-0f83-5473-b0a3-349e271d8378")}catch{}})();function fn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function fa(e){return fn(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function Q(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]="dff9b113-2b29-5154-afbf-f191f2f556a6")}catch{}})();var mn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function le(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function J(e){return[...new Set(le(e).match(/[\p{L}\p{N}]+/gu)??[])]}function X(e){let t=le(e);return{normalized:t,tokens:J(t),issueCodes:[...new Set(t.match(mn)?.map(r=>r.toLowerCase())??[])]}}function ue(e,t){return fe(X(e),X(t))}function fe(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:Q(e.tokens,t.tokens),reason:"title_token_jaccard"}}import pn 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]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function me(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function _n(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 Rt(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=me(t.in_progress_status),i=[];for(let s of e){if(me(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=_n(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 hn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>me(String(o.status))===me(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Fe(pn.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)})),Rt(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as gn,readFile as yn}from"node:fs/promises";import Mt from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function wn(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 En(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function kt(e,t){return Mt.join(e,"checkpoints",t)}function Nt(e,t,r){return Mt.join(kt(e,t),`${r}.json`)}async function bn(e,t,r,n){let o=kt(e,t);await gn(o,{recursive:!0});let i=Nt(e,t,r);return await T(i,`${JSON.stringify(n,null,2)}
2
2
  `),i}function Tn(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 Sn(e,t,r,n){let o=wn(r),i=Nt(e,t,o);if(!await F(i))throw new m(`Checkpoint ${o} not found`,f.NOT_FOUND);let s=await yn(i,"utf8"),a;try{a=JSON.parse(s)}catch(l){throw new m(`Checkpoint ${o} contains invalid JSON: ${b(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=Tn(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 xn(e,t){let r=[],n=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);r.push({id:o.id,status:"restored",changed_fields:i.changed_fields,warnings:i.warnings}),n.push(o.id)}catch(i){r.push({id:o.id,status:"failed",error:b(i)})}return{rows:r,restored_ids:n,failed_count:r.filter(o=>o.status==="failed").length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ab276268-7a98-5f97-b3f5-300dfd1b5ed5")}catch{}})();function k(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function va(e,t){let r=k(t);return!e||!r?null:[...e.assurance_providers??[]].reverse().find(n=>k(n.definition.id)===r)??null}function In(e,t){let r=k(t);return!e||!r?null:[...e.search_providers].reverse().find(o=>(k(o.runtime_definition?.name)??k(o.definition?.name))===r)??null}function An(e,t){let r=k(t);return!e||!r?null:[...e.vector_store_adapters].reverse().find(o=>(k(o.runtime_definition?.name)??k(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]="19ff592c-0746-54e8-a304-2006f4845da2")}catch{}})();function Ot(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function Be(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let r=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return r?Ot(r):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?Ot(t):"root"}function pe(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function Cn(e,t){let r=t?.windowStartIndex??0,n=t?.field;if(e.length===0||r>=e.length)return[];let o=Ct(),i=[];for(let s=0;s<e.length;s+=1){let a=e[s],c=o,d=vt(o,a.patch),l;d.ok?(l=d.document,o=l):l=c;let u=new Set;for(let p of a.patch)u.add(Be(p.path)),p.from!==void 0&&u.add(Be(p.from));let _=[...u].sort((p,h)=>p.localeCompare(h));if(s>=r)if(n!==void 0){if(!u.has(n))continue;let p={field:n,before:pe(c,n),after:pe(l,n)};i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:[n],changes:[p]})}else{let p=_.map(h=>({field:h,before:pe(c,h),after:pe(l,h)}));i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:_,changes:p})}}return 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]="7426082f-94a6-5b4e-9748-d3faab2fe1d4")}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]="4a376062-2e23-5991-80a5-27183909caf3")}catch{}})();var vn=new Set(["none","null","undefined"]);function $a(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new m("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",f.USAGE)}function Ln(e){if(typeof e!="string")throw new m("--parent must be a string. Use --unset parent to clear this field.",f.USAGE);let t=e.trim();if(t.length===0)throw new m("--parent must not be empty. Use --parent none to unset.",f.USAGE);if(Pt(t))throw new m(`--parent must not use placeholder token "${t}". Use --unset parent to clear this field.`,f.USAGE);return t}function Pt(e){return vn.has(e.trim().toLowerCase())}function Dn(e,t){if(t==="strict_error")throw new m(`Parent item "${e}" was not found. Create it first or use --parent none.`,f.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function Rn(e,t,r){let n=ce(e,r),o=ce(t,r);if(n!==o)return;let i=t!==o||e!==n?` (normalized from parent "${t}" and item "${e}")`:"";throw new m(`Parent item "${o}" cannot be the same as item "${n}"${i}. Use --unset parent to clear this field.`,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]="d5003dd5-f208-5734-9711-dff935d8c851")}catch{}})();var q="-",zt=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 $t(e){let t=e.trim();if(t==="")return[];let n=(Pn(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 Ft(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of $t(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function Ut(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function Mn(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function kn(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 Nn(e,t){let r=Ut(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 Ft(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function On(e,t){let r=Array.from(new Set(Ut(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(Ft(t));return n.size===0?r:r.filter(o=>!n.has(o))}function Pn(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 Ge(e){return e.replace(/\r\n/g,`
3
3
  `)}function Vt(e){let t=Ge(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
4
4
  `);return r.length<2||r.at(-1)?.trim()!=="```"?e:r.slice(1,-1).join(`
@@ -7,7 +7,7 @@ import{$ as It,$a as M,Fa as Ct,La as vt,V as R,_a as se,aa as At,ab as ae,fb as
7
7
  `).map(i=>i.trim()).filter(i=>i.length>0);for(let i of o){let s=i.match(/^(?:[-*+]\s+)?([a-zA-Z0-9_.-]+)\s*(=|:)\s*(.*)$/);if(s){let a=s[1].trim();r[a]=qt(s[3].trim()),n=a;continue}if(n&&zt.has(n.toLowerCase())){r[n]=`${r[n]}
8
8
  ${i}`;continue}return null}return r}function qn(e,t){let r=Vt(e).trim();if(!r)throw new m(`${t} cannot be empty`,f.USAGE);let n=Vn(r);if(n)return n;let o={},i,s=zn(r);for(let a of s){let c=$n(a);if(c>0){let d=a.slice(0,c).trim(),l=qt(a.slice(c+1).trim());o[d]=l,i=d;continue}if(i&&zt.has(i.toLowerCase())){o[i]=`${o[i]},${a.trim()}`;continue}throw new m(Un(e,t),f.USAGE)}return o}var jn=/^[A-Za-z]:[\\/]/,Hn=/^(?:[-*+]\s+)?[A-Za-z_][A-Za-z0-9_.-]*\s*=/;function Yn(e){let t=e.trim();return jn.test(t)?!1:Hn.test(t)}function Bn(e,t,r){let n=new Set(r.map(i=>i.toLowerCase())),o=Object.keys(e).filter(i=>!n.has(i.toLowerCase()));if(o.length>0)throw new m(`${t} does not recognize key${o.length>1?"s":""} ${o.map(i=>`"${i}"`).join(", ")}. Allowed keys: ${r.join(", ")}.`,f.USAGE);for(let i of Object.keys(e)){let s=i.toLowerCase();if(s!==i){if(Object.hasOwn(e,s))throw new m(`${t} provides key "${i}" more than once after case normalization.`,f.USAGE);e[s]=e[i],delete e[i]}}}async function Gn(e){if(process.stdin.isTTY===!0)throw new m(`${e} value "${q}" requires piped stdin input. Pipe content into the command, or end manual stdin with Ctrl+D (Unix/macOS) or Ctrl+Z then Enter (Windows).`,f.USAGE);return process.stdin.setEncoding("utf8"),await new Promise((t,r)=>{let n="";process.stdin.on("data",o=>{n+=o}),process.stdin.on("end",()=>{t(Ge(n))}),process.stdin.on("error",o=>{r(o)})})}function Wn(){let e,t,r=async i=>{if(t&&t!==i)throw new m(`Only one option may use "${q}" stdin token per command invocation. Already used by ${t}.`,f.USAGE);return t=i,e||(e=Gn(i)),await e};return{resolveValue:async(i,s)=>{if(i!==void 0)return i.trim()!==q?i:await r(s)},resolveList:async(i,s)=>{if(!i)return;let a=i.map((l,u)=>l.trim()===q?u:-1).filter(l=>l>=0);if(a.length===0)return i;if(a.length>1)throw new m(`${s} accepts "${q}" stdin token at most once per command invocation`,f.USAGE);let c=await r(s),d=[...i];return d[a[0]]=c,d}}}function Kn(e,t){let r=Number(e);if(!Number.isFinite(r))throw new m(`Invalid ${t} value "${e}"`,f.USAGE);return r}function Qn(e,t){let r=e.trim(),n=Number(r);if(r===""||!Number.isInteger(n)||n<0)throw new m(`Invalid ${t} value "${e}". Expected a non-negative integer.`,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]="806bf35f-dc7e-55a8-9bb9-64be87111c22")}catch{}})();var We={critical:0,high:1,medium:2,low:3,minimal:4},Xn=Object.keys(We),Jn=`numbers 0..4 (0=critical, 1=high, 2=medium, 3=low, 4=minimal) or names (${Xn.join(", ")}), case-insensitive`;function _e(e){return new m(`Invalid priority "${e}". Accepted values: ${Jn}.`,f.USAGE)}function Zn(e){if(typeof e=="number"){if(Number.isInteger(e)&&e>=0&&e<=4)return e;throw _e(String(e))}if(typeof e!="string")throw _e(String(e));let t=e.trim();if(t.length===0)throw _e(e);let r=t.toLowerCase();if(Object.prototype.hasOwnProperty.call(We,r))return We[r];if(/^[0-4]$/.test(t))return Number(t);throw _e(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf76a01e-7292-59df-94ca-1e41aaff7365")}catch{}})();var eo=/^[A-Za-z0-9][A-Za-z0-9._/-]*$/,to=64;function Wa(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new m("Config set sprint-release-format-policy requires --policy with one of: warn, strict_error (alias: strict)",f.USAGE)}function ro(e,t,r){let n=t.trim();if(n.length===0)throw new m(`--${e} must not be empty. Use --${e} none to unset.`,f.USAGE);if(n.length<=to&&eo.test(n))return{value:n,warnings:[]};let i="Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._/-]* (no spaces).";if(r==="strict_error")throw new m(`Invalid --${e} value "${n}". ${i}`,f.USAGE);return{value:n,warnings:[`validation_warning:${e}_format:${n}`]}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d0e997bc-8bdb-5602-8606-73ecf77b2a35")}catch{}})();var jt={open:"open_status",closed:"close_status",canceled:"canceled_status",cancelled:"canceled_status"},Ht="all";function ec(e){if(typeof e!="string")return!1;let t=e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r.length>0);return t.length===1&&t[0]===Ht}function no(e,t){let r=e.trim().toLowerCase();if(r.length===0)return;let n=jt[r];return n?t[n]:K(e,t)}function oo(e){let t=new Set(Object.keys(jt));for(let r of e.definitions){t.add(r.id);for(let n of r.aliases)t.add(n)}return[...t]}function io(e,t){let r=e.trim().toLowerCase(),n,o=Number.POSITIVE_INFINITY;for(let i of oo(t)){let s=Le(r,i.toLowerCase(),2);s!==null&&s<o&&(n=i,o=s)}return n}function so(e,t,r){if(typeof e!="string")return;let n=r?.strict===!0,o=r?.flagLabel??"--status",i=e.split(",").map(c=>c.trim()).filter(c=>c.length>0);if(i.length===0)return;if(i.filter(c=>c.trim().toLowerCase()===Ht).length>0){if(i.length===1)return;throw new m(`Invalid ${o} value "all". Use it by itself, or omit ${o} to search every status.`,f.USAGE)}let a=[];for(let c of i){let d=no(c,t);if(d===void 0){if(n){let l=io(c,t);throw new m(`Invalid ${o} value "${c}". Use open|closed|canceled or a configured status id${l?`. Did you mean "${l}"?`:"."}`,f.USAGE)}a.push(c);continue}a.push(d)}return[...new Set(a)]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b7a167e0-3041-5056-a672-ea0a054ed8df")}catch{}})();var ao={bug:"Issue",bugfix:"Issue",defect:"Issue",incident:"Issue",enhancement:"Feature",story:"Feature",userstory:"Feature","user-story":"Feature","user story":"Feature",change:"Chore",ticket:"Task",todo:"Task"};function co(e){if(e!==void 0)return ao[e.trim().toLowerCase()]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6d11dc0f-e313-5b39-965d-6bc84ad52966")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43a56374-808c-5fa6-bd6c-5d93175df0d2")}catch{}})();function Yt(e,t){return Ne(e,t)}function lo(e,t,r){let n={};for(let o of t.command_to_fields.get(r)??[]){let i=It(e,o);i!==void 0&&(n[o.metadata_key]=At(o,i))}return n}function uo(e,t){for(let[r,n]of Object.entries(t)){let o=e[r];if(Array.isArray(n)){if(Array.isArray(o)){let i=o.map(a=>String(a));if(!n.map(a=>String(a)).every(a=>i.includes(a)))return!1;continue}if(!Yt(o,n[n.length-1]))return!1;continue}if(!Yt(o,n))return!1}return!0}import{spawnSync as Gt}from"node:child_process";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="12bfc6e7-8979-58e8-8276-98cc859f3e32")}catch{}})();var fo="PM_DISABLE_OLLAMA_AUTO_DEFAULTS",mo="PM_OLLAMA_MODEL",po="http://localhost:11434",_o="qwen3-embedding:0.6b",ho=".agents/pm/search/lancedb/",go=1500,yo=2500,wo=/qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i,Eo=/embed|embedding/i,I=g;function bo(){let e=I(process.env[fo]);if(!e)return!1;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"}function Bt(e){return e.some(t=>I(t)!==null)}function To(e){let t=I(e);return!!(t&&t.toLowerCase()!=="ollama")}function So(e){let t=I(e);return!!(t&&t.toLowerCase()!=="lancedb")}function xo(e){return To(e.search?.provider)||So(e.vector_store?.adapter)||Bt([e.providers?.openai?.base_url,e.providers?.openai?.model,e.providers?.openai?.api_key])?!0:Bt([e.vector_store?.qdrant?.url,e.vector_store?.qdrant?.api_key])}function Io(){let e=Gt("ollama",["--version"],{encoding:"utf8",timeout:go});return e.error?!1:e.status===0}function Ao(e){let t=e.split(/\r?\n/).map(i=>i.trim()).filter(i=>i.length>0);if(t.length===0)return null;let r=t.map(i=>i.split(/\s+/)[0]?.trim()).filter(i=>!!(i&&i.length>0)).filter(i=>i.toUpperCase()!=="NAME");if(r.length===0)return null;let n=r.find(i=>wo.test(i));return n||(r.find(i=>Eo.test(i))??null)}function Co(e){let t=I(e.providers?.ollama?.model);if(t)return t;let r=I(process.env[mo]);if(r)return r;let n=Gt("ollama",["list"],{encoding:"utf8",timeout:yo});if(!n.error&&n.status===0){let o=Ao(typeof n.stdout=="string"?n.stdout:"");if(o)return o}return null}function vo(e){return{baseUrl:I(e.providers?.ollama?.base_url)===null,model:I(e.providers?.ollama?.model)===null,lancedbPath:I(e.vector_store?.lancedb?.path)===null,embeddingModel:I(e.search?.embedding_model)===null}}function Lo(e){return e.baseUrl||e.model||e.lancedbPath||e.embeddingModel}function Do(e,t,r){if(!t.baseUrl&&!t.model)return;let n=e.providers??={},o=n.ollama??={};t.baseUrl&&(o.base_url=po),t.model&&(o.model=r)}function Ro(e,t){if(!t.lancedbPath)return;let r=e.vector_store??={},n=r.lancedb??={};n.path=ho}function Mo(e,t,r){if(!t.embeddingModel)return;let n=e.search??={};n.embedding_model=r}function he(e){let t={settings:e,auto_ollama_defaults_applied:!1};if(bo()||xo(e))return t;let r=vo(e);if(!Lo(r)||r.model&&!Io())return t;let n=structuredClone(e),o=Co(n);return o?(Do(n,r,o),Ro(n,r),Mo(n,r,o),{settings:n,auto_ollama_defaults_applied:!0}):{...t,auto_ollama_defaults_skipped_reason:"no_installed_embedding_model",auto_ollama_defaults_remediation:`Run ollama pull ${_o} or configure providers.ollama.model explicitly (and search.embedding_model if you need an override).`}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d8d5f7e9-5293-564b-bc44-f5ba30336893")}catch{}})();var Oo="reindex";import cr 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]="b5ce7132-0024-5d42-9cb8-585933beb7c7")}catch{}})();var Po=3e4;function N(e,t,r=Po){let n=e??r;if(!Number.isFinite(n)||n<=0)throw new Error(`${t} timeout must be a positive finite number`);return Math.floor(n)}function O(e,t){if(e)return e;if(typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error(`${t} execution requires a fetch implementation`)}async function zo(e){try{return(await e.text()).replaceAll(/\s+/g," ").trim()}catch(t){return`(failed to read response body: ${b(t)})`}}async function ge(e){let t=new AbortController,r=setTimeout(()=>{t.abort()},e.timeoutMs);try{let n;try{n=await e.fetcher(e.endpoint,{method:e.method,headers:e.headers,body:JSON.stringify(e.body),signal:t.signal})}catch(o){throw o instanceof Error&&o.name==="AbortError"?new Error(`${e.requestLabel} timed out after ${e.timeoutMs}ms`):new Error(`${e.requestLabel} execution failed: ${b(o)}`)}if(!n.ok){let o=await zo(n),i=o.length>0?`: ${o}`:"";throw new Error(`${e.requestLabel} failed with status ${n.status} ${n.statusText}${i}`)}try{return await n.json()}catch(o){throw new Error(`${e.responseLabel} JSON parse failed: ${b(o)}`)}}finally{clearTimeout(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]="af754be6-8026-530a-8a20-b03d4ed742e1")}catch{}})();function Tc(e,t){let r=g(e);if(!r)return"unconfigured";let n=g(t);return n&&n.toLowerCase()===r.toLowerCase()?"configured":"auto-detected"}function $o(e){let t=W(e),r=t.toLowerCase();return r.endsWith("/embeddings")?t:r.endsWith("/v1")?`${t}/embeddings`:`${t}/v1/embeddings`}function Qt(e){let t=e.search?.embedding_model;return g(t)||null}function Fo(e){let t=g(e.providers?.openai?.base_url),r=g(e.providers?.openai?.model);if(!t||!r)return null;let n=Qt(e),o=g(e.providers?.openai?.api_key);return{name:"openai",base_url:t,model:n??r,...o?{api_key:o}:{}}}function Uo(e){let t=g(e.providers?.ollama?.base_url),r=g(e.providers?.ollama?.model);if(!t||!r)return null;let n=Qt(e);return{name:"ollama",base_url:t,model:n??r}}function Xt(e){let t=(Array.isArray(e)?e:[e]).map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)throw new Error("Embedding input must include at least one non-empty string");return t}function Vo(e){let t=[],r=[],n=new Map;for(let o of e){let i=n.get(o);if(i===void 0){let s=t.length;t.push(o),n.set(o,s),r.push(s);continue}r.push(i)}return{uniqueInputs:t,originalToUniqueIndex:r}}function qo(e){let t=e.map((n,o)=>({embedding:n.embedding,index:n.index,position:o}));if(t.some(n=>n.index!==void 0)){for(let n of t)if(!Number.isInteger(n.index))throw new TypeError(`OpenAI embedding response entry at position ${n.position} is missing a valid integer index`);return[...t].sort((n,o)=>{let i=n.index-o.index;return i!==0?i:n.position-o.position})}return t}function Ke(e){let t=Fo(e),r=Uo(e),n=[t,r].filter(a=>a!==null),o=g(e.search?.provider),i=o?o.toLowerCase():null;return{active:(i?n.find(a=>a.name===i):void 0)??n[0]??null,available:n}}function Kt(e){let t=W(e.base_url);return e.name==="openai"?{provider:"openai",endpoint:$o(t),model:e.model}:{provider:"ollama",endpoint:`${t}/api/embed`,model:e.model}}function jo(e,t){let r=Xt(t);return e.name==="openai"?{target:Kt(e),method:"POST",headers:{"content-type":"application/json",...e.api_key?{authorization:`Bearer ${e.api_key}`}:{}},body:{model:e.model,input:r.length===1?r[0]:r}}:{target:Kt(e),method:"POST",headers:{"content-type":"application/json"},body:{model:e.model,input:r}}}function Ho(e,t){if(e.name==="openai"){let o=t.data;if(!Array.isArray(o)||o.length===0)throw new Error("OpenAI embedding response must include a non-empty data array");return qo(o).map((s,a)=>{let c=s.embedding;if(!V(c))throw new Error(`OpenAI embedding response entry at index ${a} is missing a numeric embedding vector`);return[...c]})}let r=t.embedding;if(V(r))return[[...r]];let n=t.embeddings;if(Array.isArray(n)&&n.length>0)return n.map((o,i)=>{if(!V(o))throw new Error(`Ollama embedding response entry at index ${i} is missing a numeric embedding vector`);return[...o]});throw new Error("Ollama embedding response must include embedding or embeddings vectors")}async function Jt(e,t,r={}){let n=N(r.timeout_ms,"Embedding request"),o=O(r.fetcher,"Embedding request"),i=Xt(t),s=Vo(i),a=jo(e,s.uniqueInputs),c=await ge({endpoint:a.target.endpoint,method:a.method,headers:a.headers,body:a.body,timeoutMs:n,fetcher:o,requestLabel:"Embedding request",responseLabel:"Embedding response"}),d=Ho(e,c);if(d.length!==s.uniqueInputs.length)throw new Error(`Embedding response cardinality mismatch: expected ${s.uniqueInputs.length} vector(s), received ${d.length}`);return s.originalToUniqueIndex.map(l=>[...d[l]])}(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]="61c0153b-8fa5-5c26-aa88-ca9807f2d160")}catch{}})();var ye=["title","description","tags","status","type","priority","assignee","parent","goal","value","why_now","risk","confidence","estimated_minutes","acceptance_criteria","resolution","expected_result","actual_result","body","comments","notes","learnings","reminders","events","dependencies","plan"];function Qe(e){let t=e?.search?.corpus_fields;if(!Array.isArray(t))return[...ye];let r=new Set(ye),n=Array.from(new Set(t.filter(o=>typeof o=="string").map(o=>o.trim()).filter(o=>o.length>0&&r.has(o))));return n.length>0?n:[...ye]}var Yo=8e3,Xe=3200,P="...[semantic corpus truncated]",Bo="search_embedding_corpus_max_characters_invalid:using_provider_default";function C(e){return e.map(t=>t==null?"":String(t).trim()).filter(t=>t.length>0).join(" ")}function Go(e){return(e.reminders??[]).map(t=>C([t.at,t.text]))}function Wo(e){return(e.events??[]).map(t=>C([t.start_at,t.end_at,t.title,t.description,t.location,t.all_day===!0?"all day":void 0,t.timezone,t.recurrence?.freq,t.recurrence?.interval,t.recurrence?.count,t.recurrence?.until,t.recurrence?.by_weekday?.join(" "),t.recurrence?.by_month_day?.join(" "),t.recurrence?.exdates?.join(" ")]))}function Ko(e,t){e.push(t.title,t.body,t.status,t.owner,t.evidence,t.blocked_reason,t.superseded_by);for(let r of t.linked_items??[])e.push(`${r.kind} ${r.id}`,r.note);for(let r of t.files??[])e.push(r.path,r.note);for(let r of t.tests??[])e.push(r.command,r.path,r.note);for(let r of t.docs??[])e.push(r.path,r.note)}function Qo(e,t){for(let r of t.plan_decisions??[])e.push(r.decision,r.rationale,r.evidence);for(let r of t.plan_discoveries??[])e.push(r.text);for(let r of t.plan_validation??[])e.push(r.text,r.command,r.expected)}function Ic(e){let t=[];t.push(e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context);for(let r of e.plan_steps??[])Ko(t,r);return Qo(t,e),t.filter(r=>typeof r=="string"&&r.length>0).join(" ")}function Xo(e){let t=(e.plan_steps??[]).map(s=>C([s.order,s.id,s.title,s.body,s.status,s.owner,s.evidence,s.blocked_reason,s.superseded_by,(s.linked_items??[]).map(a=>C([a.kind,a.id,a.note])).join(" "),(s.files??[]).map(a=>C([a.path,a.note])).join(" "),(s.tests??[]).map(a=>C([a.command,a.path,a.note])).join(" "),(s.docs??[]).map(a=>C([a.path,a.note])).join(" ")])),r=(e.plan_decisions??[]).map(s=>C([s.decision,s.rationale,s.evidence,s.step_id])),n=(e.plan_discoveries??[]).map(s=>C([s.text,s.step_id])),o=(e.plan_validation??[]).map(s=>C([s.text,s.command,s.expected]));if([e.plan_mode,e.plan_scope,e.plan_harness,e.plan_resume_context,...t,...r,...n,...o].some(s=>s!==void 0))return{mode:e.plan_mode,scope:e.plan_scope,harness:e.plan_harness,resume_context:e.plan_resume_context,steps:t,decisions:r,discoveries:n,validation:o}}function A(e){return typeof e=="string"&&e.trim().length>0}var Jo={title:e=>e.metadata.title,description:e=>e.metadata.description,tags:e=>e.metadata.tags,status:e=>e.metadata.status,type:e=>e.metadata.type,priority:e=>typeof e.metadata.priority=="number"?e.metadata.priority:void 0,assignee:e=>A(e.metadata.assignee)?e.metadata.assignee:void 0,parent:e=>A(e.metadata.parent)?e.metadata.parent:void 0,goal:e=>A(e.metadata.goal)?e.metadata.goal:void 0,value:e=>A(e.metadata.value)?e.metadata.value:void 0,why_now:e=>A(e.metadata.why_now)?e.metadata.why_now:void 0,risk:e=>A(e.metadata.risk)?e.metadata.risk:void 0,confidence:e=>e.metadata.confidence!==void 0&&e.metadata.confidence!==null?e.metadata.confidence:void 0,estimated_minutes:e=>typeof e.metadata.estimated_minutes=="number"?e.metadata.estimated_minutes:void 0,acceptance_criteria:e=>A(e.metadata.acceptance_criteria)?e.metadata.acceptance_criteria:void 0,resolution:e=>A(e.metadata.resolution)?e.metadata.resolution:void 0,expected_result:e=>A(e.metadata.expected_result)?e.metadata.expected_result:void 0,actual_result:e=>A(e.metadata.actual_result)?e.metadata.actual_result:void 0,body:e=>e.body,comments:e=>(e.metadata.comments??[]).map(t=>t.text),notes:e=>(e.metadata.notes??[]).map(t=>t.text),learnings:e=>(e.metadata.learnings??[]).map(t=>t.text),reminders:e=>Go(e.metadata),events:e=>Wo(e.metadata),dependencies:e=>(e.metadata.dependencies??[]).map(t=>({id:t.id,kind:t.kind})),plan:e=>Xo(e.metadata)};function Zt(e,t={}){let r=t.fields??ye,n={};for(let o of r){let i=Jo[o];if(!i)continue;let s=i(e);s!==void 0&&(n[o]=s)}return n}function Zo(e){return e?.trim().toLowerCase()==="ollama"?Xe:Yo}function j(e,t){let r=Zo(e),n=xt(t);return n!==null?{maxCharacters:n,warning:null}:{maxCharacters:r,warning:t==null?null:Bo}}function Je(e,t={}){let r=JSON.stringify(Zt(e,{fields:t.fields})),n=j(t.providerName,t.maxCharacters).maxCharacters;if(r.length<=n)return r;if(n<=P.length)return P.slice(0,n);let o=Math.max(0,n-P.length);return`${r.slice(0,o)}${P}`}(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]="2c518b97-bc75-5e3f-91e8-d6779d565558")}catch{}})();function ei(e,t){let r=e.search.embedding_batch_size,n=e.search.embedding_timeout_ms,o=e.search.scanner_max_batch_retries,i=Number.isFinite(r)&&r>0?Math.floor(r):1,s=Number.isFinite(n)&&n>0?Math.floor(n):3e4,a=Number.isFinite(o)&&o>=0?Math.floor(o):0;return{batchSize:i,timeoutMs:s,maxRetries:a,maxBatchInputCharacters:Number.POSITIVE_INFINITY,maxInputCharacters:t}}function ti(e,t,r){let n=[],o=[],i=0;for(let s of e){let a=o.length>=t,c=o.length>0&&Number.isFinite(r)&&i+s.length>r;(a||c)&&(n.push(o),o=[],i=0),o.push(s),i+=s.length}return n.push(o),n}function ri(e,t){return e.name!=="ollama"?t:{...t,maxBatchInputCharacters:Xe}}function ni(e,t){if(!Number.isFinite(t)||t<=0||e.length<=t)return e;let r=Math.max(0,t-P.length);return`${e.slice(0,r)}${P}`.slice(0,t)}function er(e){let t=b(e).toLowerCase();return t.includes("timed out")||t.includes("timeout")}function oi(e,t,r,n,o,i){let s=`Embedding batch ${t} failed after ${o} attempt(s): ${b(i)}`,a=`provider=${e.name} model=${e.model} batch_size=${r} timeout_ms=${n}`;return er(i)?`${s} (${a}; guidance=check provider availability or lower search.embedding_batch_size, raise search.embedding_timeout_ms, or run keyword search while semantic indexing catches up)`:`${s} (${a})`}async function Ze(e,t,r,n,o,i){let s=null;for(let a=0;a<=o;a+=1)try{let c=await Jt(e,t,{timeout_ms:n});return a>0&&i.push(`search_embedding_batch_retry_succeeded:batch=${r}:attempt=${a+1}:size=${t.length}`),c}catch(c){if(s=c,er(c)&&t.length>1){let d=Math.ceil(t.length/2),l=t.slice(0,d),u=t.slice(d);return i.push(`search_embedding_batch_split_after_timeout:batch=${r}:size=${t.length}:parts=${l.length}|${u.length}`),[...await Ze(e,l,`${r}.1`,n,o,i),...await Ze(e,u,`${r}.2`,n,o,i)]}if(a<o){let d=Math.min(1e3*2**a,8e3);await new Promise(l=>setTimeout(l,d))}}throw new Error(oi(e,r,t.length,n,o+1,s))}async function et(e,t,r,n={}){if(r.length===0)return{vectors:[],warnings:[]};let o=[],i=j(e.name,t.search.embedding_corpus_max_characters);i.warning&&o.push(i.warning);let s=ri(e,ei(t,i.maxCharacters)),a=0,c=r.map(_=>{let p=ni(_,s.maxInputCharacters);return p.length<_.length&&(a+=1),p});a>0&&o.push(`search_embedding_input_truncated:count=${a}:max_characters=${s.maxInputCharacters}`);let d=ti(c,s.batchSize,s.maxBatchInputCharacters),l=[],u=0;for(let _=0;_<d.length;_+=1){let p=d[_];n.onProgress?.({batch_index:_+1,batch_total:d.length,batch_size:p.length,completed_inputs:u,total_inputs:c.length,phase:"start"}),l.push(...await Ze(e,p,String(_+1),s.timeoutMs,s.maxRetries,o)),u+=p.length,n.onProgress?.({batch_index:_+1,batch_total:d.length,batch_size:p.length,completed_inputs:u,total_inputs:c.length,phase:"complete"})}return{vectors:l,warnings:o}}import{mkdir as ii,readFile as si,stat as nt,unlink as ai}from"node:fs/promises";import{basename as tr,dirname as tt,isAbsolute as ci,join as di,resolve as ot}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]="98c8d03c-bdde-5ac4-b80d-395d885f7442")}catch{}})();var it="pm_items",li=/[^a-zA-Z0-9_-]/g,ui=128,fi=".pm-cli-local-vectors",rt=1,z=new Map;function ee(e){return(g(e.collection_name)??it).replaceAll(li,"_").slice(0,ui)}function we(e){if(!V(e)||e.length===0)throw new Error("Vector values must be a non-empty numeric array");return[...e]}function nr(e){if(!Number.isFinite(e)||e<=0)throw new Error("Vector query limit must be a positive number");return Math.floor(e)}function mi(e){let t=e.result;if(!Array.isArray(t))throw new TypeError("Qdrant query response must include a result array");let r=t.map((n,o)=>{let i=n.id,s=typeof i=="number"?String(i):i,a=g(s);if(!a)throw new Error(`Qdrant query response entry at index ${o} is missing a non-empty id`);let c=n.score;if(typeof c!="number"||!Number.isFinite(c))throw new TypeError(`Qdrant query response entry at index ${o} is missing a finite numeric score`);let d=n.payload;if(d!==void 0&&(typeof d!="object"||d===null||Array.isArray(d)))throw new Error(`Qdrant query response entry at index ${o} must provide payload as an object when set`);return{id:a,score:c,...d?{payload:d}:{}}});return r.sort((n,o)=>n.score!==o.score?o.score-n.score:n.id.localeCompare(o.id)),r}function st(e){let t=g(e.result?.status);if(t)return{status:t};let r=g(e.status);if(r)return{status:r};throw new Error("Qdrant upsert response must include status metadata")}async function Z(e,t,r,n,o){return await ge({endpoint:e,method:t.method,headers:t.headers,body:t.body,timeoutMs:r,fetcher:n,requestLabel:`Vector ${o} request`,responseLabel:`Vector ${o} response`})}function pi(e){let t=g(e.vector_store?.qdrant?.url);if(!t)return null;let r=g(e.vector_store?.collection_name),n=g(e.vector_store?.qdrant?.api_key);return{name:"qdrant",url:t,...r&&r!==it?{collection_name:r}:{},...n?{api_key:n}:{}}}function _i(e){let t=ot(e),r=tt(t);return tr(t)==="pm"&&tr(r)===".agents"?tt(r):t}function hi(e,t){return!t||ci(e)?e:ot(_i(t),e)}function gi(e,t){let r=g(e.vector_store?.lancedb?.path);if(!r)return null;let n=g(e.vector_store?.collection_name);return{name:"lancedb",path:hi(r,t),...n&&n!==it?{collection_name:n}:{}}}function yi(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector upsert records must include at least one entry");return e.map((t,r)=>{let n=g(t.id);if(!n)throw new Error(`Vector upsert record at index ${r} is missing a non-empty id`);let o=we(t.vector),i=t.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`Vector upsert record at index ${r} must provide payload as an object when set`);return{id:n,vector:o,...i?{payload:i}:{}}})}function wi(e){if(!Array.isArray(e)||e.length===0)throw new Error("Vector delete ids must include at least one entry");let t=e.map((n,o)=>{let i=g(n);if(!i)throw new Error(`Vector delete id at index ${o} is missing a non-empty value`);return i}).sort((n,o)=>n.localeCompare(o)),r=[];for(let n of t)r.at(-1)!==n&&r.push(n);return r}function Ei(e){return e.replace(/\/points\?wait=true$/,"/points/delete?wait=true")}function bi(e){return e.replace(/\/points\?wait=true$/,"")}function Ee(e){return{"content-type":"application/json",...e.api_key?{"api-key":e.api_key}:{}}}function be(e,t){return H(e,t)}function H(e,t){return di(ot(e),fi,`${t}.json`)}function Ti(e,t,r){let n=g(e.id);if(!n)throw new Error(`LanceDB local snapshot '${r}' record at index ${t} is missing a non-empty id`);let o=we(e.vector),i=e.payload;if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))throw new Error(`LanceDB local snapshot '${r}' record '${n}' must provide payload as an object when set`);return{id:n,vector:o,...i?{payload:i}:{}}}function Si(e,t,r){let n;try{n=JSON.parse(r)}catch(c){throw new Error(`LanceDB local snapshot at '${e}' is not valid JSON: ${b(c)}`)}if(typeof n!="object"||n===null||Array.isArray(n))throw new Error(`LanceDB local snapshot at '${e}' must be a JSON object`);if(n.version!==rt)throw new Error(`LanceDB local snapshot at '${e}' must include version=${rt}`);let i=g(n.table);if(!i)throw new Error(`LanceDB local snapshot at '${e}' must include a non-empty table value`);if(i!==t)throw new Error(`LanceDB local snapshot at '${e}' table mismatch: expected '${t}', received '${i}'`);let s=n.records;if(!Array.isArray(s))throw new TypeError(`LanceDB local snapshot at '${e}' must include a records array`);let a=new Map;for(let c=0;c<s.length;c+=1){let d=Ti(s[c],c,e);a.set(d.id,d)}return a}async function xi(e){try{let t=await nt(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch(t){if(!G(t))throw t;return null}}function Ii(e,t){if(!t)return null;if(t.mtimeMs===null&&t.size===null&&t.records.size===0)return t.records;let r=new Map;return z.set(e,{records:r,mtimeMs:null,size:null}),r}function Ai(e,t){return e!==void 0&&t!==null&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function at(e,t){let r=be(e,t),n=H(e,t),o=await xi(n),i=z.get(r);if(!o){let a=Ii(r,i);if(a)return a}if(Ai(i,o))return i.records;let s=new Map;try{let a=await si(n,"utf8");s=Si(n,t,a)}catch(a){if(!G(a))throw a}return z.set(r,{records:s,mtimeMs:o?.mtimeMs??null,size:o?.size??null}),s}function Ci(e){let t=[...e.values()];return t.sort((r,n)=>r.id.localeCompare(n.id)),t.map(r=>({id:r.id,vector:[...r.vector],...r.payload?{payload:r.payload}:{}}))}async function or(e){try{await ai(e)}catch(t){if(!G(t))throw new Error(`LanceDB local snapshot delete failed at '${e}': ${b(t)}`)}}async function ir(e,t,r){let n=H(e,t);if(r.size===0){await or(n);return}let o=tt(n);try{await ii(o,{recursive:!0})}catch(s){throw new Error(`LanceDB local snapshot directory create failed at '${o}': ${b(s)}`)}let i=`${JSON.stringify({version:rt,table:t,records:Ci(r)})}
9
9
  `;try{await T(n,i)}catch(s){throw new Error(`LanceDB local snapshot write failed at '${n}': ${b(s)}`)}}async function vi(e,t){let r=be(e,t),n=H(e,t);await or(n),z.delete(r)}function rr(e){let t=0;for(let r=0;r<e.length;r+=1)t+=e[r]*e[r];return Math.sqrt(t)}function Li(e,t){let r=0;for(let i=0;i<e.length;i+=1)r+=e[i]*t[i];let n=rr(e),o=rr(t);return n===0||o===0?0:r/(n*o)}function ct(e,t){let r=pi(e),n=gi(e,t),o=[r,n].filter(c=>c!==null),i=g(e.vector_store?.adapter),s=i?i.toLowerCase():null;return{active:(s?o.find(c=>c.name===s):void 0)??o[0]??null,available:o}}function Te(e){let t=ee(e);if(e.name==="qdrant"){let o=W(e.url),i=encodeURIComponent(t);return{store:"qdrant",query_target:`${o}/collections/${i}/points/search`,upsert_target:`${o}/collections/${i}/points?wait=true`}}let r=encodeURIComponent(e.path),n=encodeURIComponent(t);return{store:"lancedb",query_target:`lancedb://${r}#${n}`,upsert_target:`lancedb://${r}#${n}`}}function Di(e,t,r){let n=Te(e),o=we(t),i=nr(r);return e.name==="qdrant"?{target:n,method:"POST",headers:Ee(e),body:{vector:o,limit:i,with_payload:!0}}:{target:n,method:"LOCAL",headers:{},body:{table:ee(e),vector:o,limit:i}}}function Ri(e,t){let r=Te(e),n=yi(t);return e.name==="qdrant"?{target:r,method:"POST",headers:Ee(e),body:{points:n}}:{target:r,method:"LOCAL",headers:{},body:{table:ee(e),records:n}}}function Mi(e,t){let r=Te(e),n=wi(t);return e.name==="qdrant"?{target:r,method:"POST",headers:Ee(e),body:{points:n}}:{target:r,method:"LOCAL",headers:{},body:{table:ee(e),ids:n}}}async function Pc(e,t,r,n={}){let o=Di(e,t,r);if(o.method==="LOCAL"){let c=e,d=o.body,l=await at(c.path,d.table);if(l.size===0)return[];let u=we(d.vector),_=nr(d.limit),p=[],h=0;for(let y of l.values()){if(y.vector.length!==u.length){h++;continue}p.push({id:y.id,score:Li(u,y.vector),...y.payload?{payload:y.payload}:{}})}return h>0&&n.warnings&&n.warnings.push(`vector_dimension_mismatch:${h} records skipped (expected ${u.length} dimensions)`),p.sort((y,w)=>y.score!==w.score?w.score-y.score:y.id.localeCompare(w.id)),p.slice(0,_)}let i=N(n.timeout_ms,"Vector request"),s=O(n.fetcher,"Vector request"),a=await Z(o.target.query_target,{method:"POST",headers:o.headers,body:o.body},i,s,"query");return mi(a)}async function dt(e,t,r={}){let n=Ri(e,t);if(n.method==="LOCAL"){let a=e,c=n.body,d=be(a.path,c.table),l=await at(a.path,c.table);for(let p of c.records)l.set(p.id,p);await ir(a.path,c.table,l);let u=H(a.path,c.table),_=await nt(u);return z.set(d,{records:l,mtimeMs:_.mtimeMs,size:_.size}),{status:"ok"}}let o=N(r.timeout_ms,"Vector request"),i=O(r.fetcher,"Vector request"),s=await Z(n.target.upsert_target,{method:"POST",headers:n.headers,body:n.body},o,i,"upsert");return st(s)}async function Se(e,t,r={}){let n=Mi(e,t);if(n.method==="LOCAL"){let a=e,c=n.body,d=be(a.path,c.table),l=await at(a.path,c.table);if(l.size===0)return{status:"ok"};for(let u of c.ids)l.delete(u);if(await ir(a.path,c.table,l),l.size===0)z.delete(d);else{let u=H(a.path,c.table),_=await nt(u);z.set(d,{records:l,mtimeMs:_.mtimeMs,size:_.size})}return{status:"ok"}}let o=N(r.timeout_ms,"Vector request"),i=O(r.fetcher,"Vector request"),s=await Z(Ei(n.target.upsert_target),{method:"POST",headers:n.headers,body:n.body},o,i,"delete");return st(s)}async function sr(e,t=[],r={},n){if(e.name==="lancedb")return await vi(e.path,ee(e)),{status:"ok"};if(n!==void 0){if(!Number.isInteger(n)||n<=0)throw new Error("Vector reset dimension must be a positive integer when provided");let i=Te(e),s=bi(i.upsert_target),a=N(r.timeout_ms,"Vector request"),c=O(r.fetcher,"Vector request"),d=Ee(e);try{await Z(s,{method:"DELETE",headers:d,body:{}},a,c,"delete")}catch(u){if(!b(u).includes("failed with status 404"))throw u}let l=await Z(s,{method:"PUT",headers:d,body:{vectors:{size:n,distance:"Cosine"}}},a,c,"upsert");return st(l)}let o=t.map(i=>i.trim()).filter(i=>i.length>0);return o.length===0?{status:"ok"}:await Se(e,o,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]="4b3ad5fc-0f86-5f20-a23b-19d447cb0973")}catch{}})();function xe(e,t){let r=g(e),n=g(t);return!r||!n?null:{provider:r,model:n}}function ar(e){if(e==null)return null;if(typeof e!="object"||Array.isArray(e))throw new Error("Vectorization embedding metadata must be an object when set");let t=xe(e.provider,e.model),r=e.vector_dimension;if(!t||typeof r!="number"||!Number.isInteger(r)||r<=0)throw new Error("Vectorization embedding metadata must include provider, model, and positive vector_dimension");return{...t,vector_dimension:r}}function lt(e,t){if(!Number.isInteger(t)||t<=0)throw new Error("Vectorization embedding metadata requires a positive vector dimension");return{provider:e.provider,model:e.model,vector_dimension:t}}function ut(e,t){return!e||e.provider!==t.provider||e.model!==t.model}function ft(e,t){return!!(e&&e.vector_dimension!==t)}function mt(e,t){if(e.length===0)throw new Error(`${t} returned no vectors`);let n=e[0].length;if(!Number.isInteger(n)||n<=0)throw new Error(`${t} returned an empty vector`);for(let o=1;o<e.length;o+=1)if(e[o]?.length!==n)throw new Error(`${t} returned mixed vector dimensions`);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]="7939a590-3662-5c66-99aa-3835a0dbaecc")}catch{}})();var dr="search/vectorization-status.json";function re(e){return[...new Set([...e].map(t=>t.trim()).filter(t=>t.length>0))].sort((t,r)=>t.localeCompare(r))}function lr(e){return typeof e=="string"&&e.trim().length>0&&Number.isFinite(Date.parse(e))}function ur(e){let t=new Map;for(let[r,n]of Object.entries(e)){let o=r.trim();o.length===0||!lr(n)||t.set(o,n)}return Object.fromEntries([...t.entries()].sort((r,n)=>r[0].localeCompare(n[0])))}async function fr(e){let t=cr.join(e,dr),r=await S(t);if(r===null||r.trim().length===0)return{entries:{},embedding:null,warnings:[]};let n;try{n=JSON.parse(r)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}if(typeof n!="object"||n===null||n.version!==1||!Array.isArray(n.items))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let o=new Map;for(let s of n.items){if(typeof s!="object"||s===null)return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};let a=s.id,c=s.updated_at;if(typeof a!="string"||a.trim().length===0||!lr(c))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};o.set(a.trim(),c)}let i=null;try{i=ar(n.embedding)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}return{entries:Object.fromEntries([...o.entries()].sort((s,a)=>s[0].localeCompare(a[0]))),embedding:i,warnings:[]}}async function mr(e,t,r){let n=ur(t),o=cr.join(e,dr),i=`${JSON.stringify({version:1,generated_at:R(),...r?{embedding:r}:{},items:Object.entries(n).map(([s,a])=>({id:s,updated_at:a}))},null,2)}
10
- `;await T(o,i)}function ki(e){return{id:e.id,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}function Ni(e){let t=xe(e.name,e.model);if(!t)throw new Error("Embedding provider must include a provider name and model");return t}function te(e,t){return{refreshed:[],skipped:e,warnings:[t]}}async function Oi(e,t,r){if(!r.settings&&!await F(Me(e)))return te(t,"search_semantic_refresh_skipped:settings_not_initialized");let n;try{if(r.settings)n=r.settings;else{let a=await se(e),c=a.warnings.find(d=>d.startsWith("settings_read_"));if(c)return te(t,`search_semantic_refresh_skipped:settings_read_failed:${c}`);n=a.settings}}catch(a){return te(t,`search_semantic_refresh_skipped:settings_read_failed:${b(a)}`)}let o=r.apply_runtime_defaults?he(n).settings:n,i=Ke(o).active;if(!i)return te(t,"search_semantic_refresh_skipped:provider_unconfigured");let s=ct(o,e).active;return s?{settings:o,provider:i,vectorStore:s}:te(t,"search_semantic_refresh_skipped:vector_store_unconfigured")}async function Pi(e,t,r,n,o,i){let s=[],a=new Set,c=new Set,d=[];for(let l of n){let u=await qe(e,l,t,r,o);if(!u){c.add(l);continue}try{let _=await je(u,{schema:i});d.push({id:_.document.metadata.id,document:_.document})}catch(_){a.add(u.id),s.push(`search_semantic_refresh_item_read_failed:${u.id}:${b(_)}`)}}return d.sort((l,u)=>l.id.localeCompare(u.id)),{documents:d,missingIds:re(c),skippedIds:re(a),warnings:s}}async function zi(e,t,r){let n=j(t.name,e.search.embedding_corpus_max_characters).maxCharacters,o=Qe(e),i=r.map(a=>Je(a.document,{providerName:t.name,maxCharacters:n,fields:o})),s=await et(t,e,i);return{vectors:s.vectors,vector_dimension:mt(s.vectors,"Semantic refresh embedding"),warnings:s.warnings}}async function $i(e,t,r){return await dt(e,t.map((n,o)=>({id:n.id,vector:r[o],payload:ki(n.document.metadata)}))),{refreshed:t.map(n=>n.id),skipped:[],warnings:[]}}async function Fi(e,t){if(t.length===0)return{refreshed:[],skipped:[],warnings:[]};try{return await Se(e,t),{refreshed:[],skipped:[],warnings:[]}}catch(r){return{refreshed:[],skipped:t,warnings:[`search_semantic_refresh_delete_failed:${b(r)}`]}}}async function nd(e,t,r={}){let n=re(t);if(n.length===0)return{refreshed:[],skipped:[],warnings:[]};let o=await Oi(e,n,r);if(!("settings"in o))return o;let i=U(o.settings,Pe()),s=await Pi(e,o.settings.id_prefix,o.settings.item_format,n,i.type_to_folder,o.settings.schema),a=s.documents.length>0||s.missingIds.length>0?await fr(e):{entries:{},embedding:null,warnings:[]},c=Ni(o.provider),d=a.entries,l={refreshed:[],skipped:[],warnings:[]},u=a.embedding;if(s.documents.length>0)if(a.embedding&&ut(a.embedding,c))l={refreshed:[],skipped:s.documents.map(w=>w.id),warnings:["search_semantic_refresh_requires_reindex:embedding_identity_changed"]};else try{let w=await zi(o.settings,o.provider,s.documents);if(ft(a.embedding,w.vector_dimension))l={refreshed:[],skipped:s.documents.map(E=>E.id),warnings:[...w.warnings,"search_semantic_refresh_requires_reindex:vector_dimension_changed"]};else{u=lt(c,w.vector_dimension);let E=await $i(o.vectorStore,s.documents,w.vectors);l={refreshed:E.refreshed,skipped:E.skipped,warnings:[...w.warnings,...E.warnings]}}}catch(w){l={refreshed:[],skipped:s.documents.map(E=>E.id),warnings:[`search_semantic_refresh_failed:${b(w)}`]}}let _=await Fi(o.vectorStore,s.missingIds),p=new Set(l.refreshed),h=Object.fromEntries(s.documents.filter(w=>p.has(w.id)).map(w=>[w.id,w.document.metadata.updated_at])),y=[];if(Object.keys(h).length>0||s.missingIds.length>0){let w={...d,...ur(h)};for(let E of s.missingIds)delete w[E];try{await mr(e,w,u)}catch(E){y.push(`search_vectorization_status_ledger_write_failed:${b(E)}`)}y.push(...a.warnings)}return{refreshed:re([...l.refreshed,..._.refreshed]),skipped:re([...s.skippedIds,...l.skipped,..._.skipped]),warnings:[...s.warnings,...l.warnings,..._.warnings,...y]}}import{createRequire as Vi}from"node:module";(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]="8eb48648-6e55-5710-990e-6471c7cdcde0")}catch{}})();var qi=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i,ad=new RegExp(`\\b(${qi.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");var cd=Vi(import.meta.url);(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]="e896db69-ed90-53f1-a227-e3d061b3bc8d")}catch{}})();var ud=new Map([[f.USAGE,"invalid_command_usage"],[f.NOT_FOUND,"item_not_found"],[f.CONFLICT,"lock_conflict"],[f.DEPENDENCY_FAILED,"dependency_failed"]]);(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]="ffe56aed-b794-5bf4-99fd-e3c5fe065163")}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]="c43dd9f2-78ac-5c22-970a-0016a06b87b3")}catch{}})();var wd=Object.freeze({"&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&amp;":"&"});(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]="0ce743d1-917a-5c96-b038-c95e3922bc48")}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]="868dfae8-2575-5d5f-8425-c7e68aefdc84")}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]="4ecab833-db06-5baa-bfe6-d28b4c97f85a")}catch{}})();function Hi(e,t){if(e==null)return[];let r=t?.separators??/,/,o=e.split(r).map(a=>a.trim()).filter(a=>a.length>0),s=t?.unique!==!1?Array.from(new Set(o)):o;return t?.sort===!0?[...s].sort():s}import _r from"node:fs/promises";import Ie 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]="4baf0ef3-2412-51cf-9ade-18b5c6e610d1")}catch{}})();function Yi(e){return"json_markdown"}function hr(e,t){return Ie.relative(e,t).replaceAll("\\","/")}function Bi(e){return String(e).replaceAll(/[^a-zA-Z0-9._-]+/g,"_").slice(0,120)}async function Gi(e,t,r="item_format:migrate",n=De,o){if(t!=="toon")throw new Error("Only toon item-format migration targets are supported. Markdown item files are legacy read-only input.");let i=new Set,s=new Set,a=[],c=0,d=Yi(t),l=Object.entries(n);for(let[u,_]of l){let p=Ie.join(e,_),h=[];try{h=await _r.readdir(p)}catch{continue}let y=new Map;for(let E of h){let L=Ie.join(p,E),D=St(L);if(!D)continue;let Y=Ie.extname(E),B=E.slice(0,E.length-Y.length).trim();if(B.length===0)continue;let $=y.get(B)??{};$[D]=L,y.set(B,$)}let w=[...y.keys()].sort((E,L)=>E.localeCompare(L));for(let E of w){let L=y.get(E);c+=1;let D=L[d];if(!D)continue;let Y=L[t]??D,B=Y===L[t]?t:d;try{let $=await _r.readFile(Y,"utf8"),Jr=ze($,{format:B,schema:o,onWarning:Zr=>a.push(`item_format_migration_parse_warning:${E}:${Zr}`)}),ve=ke(e,u,E,t,n),Tt=$e(Jr,{format:t,schema:o});await S(ve)!==Tt&&(await T(ve,Tt),a.push(...await ie({path:ve,scope:"project",op:r})),i.add(E)),await ne(D),s.add(hr(e,D)),a.push(...await ie({path:D,scope:"project",op:`${r}:remove`})),i.add(E)}catch($){a.push(`item_format_migration_skipped:${hr(e,Y)}:${Bi($)}`)}}}return{target_format:t,scanned:c,migrated:[...i].sort((u,_)=>u.localeCompare(_)),removed:[...s].sort((u,_)=>u.localeCompare(_)),warnings: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]="f280c1df-b134-57c3-91f6-cbf5a37e6e31")}catch{}})();var Wi=new Set(["completed","superseded"]);function Ki(e){return e!==void 0&&Wi.has(e)}function Qi(e){if(e.type.trim().toLowerCase()!=="plan")return!1;let t=e.plan_steps??[];return t.length>0&&t.every(r=>r.status==="completed")}import Nd from"node:readline/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6783b122-a1a8-5f86-9ac5-2c3e811622ed")}catch{}})();import ht from"node:crypto";import{mkdirSync as jd,rmSync as Zi,statSync as Hd}from"node:fs";import{mkdir as pt,readdir as es,rm as gt,stat as Sr}from"node:fs/promises";import{request as ts}from"node:http";import{request as rs}from"node:https";import x 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]="26ea62d9-874d-5826-9822-83c5523b673b")}catch{}})();var ns=x.join("runtime","telemetry","events.jsonl"),os=x.join("runtime","telemetry","state.json"),is=x.join("runtime","telemetry","otel-spans.jsonl"),ss=8,gr=500,as=1;var cs=100,ds=36e5,ls=3e4,yr=2e4,us=1e3,fs=25e3,ms=864e5,xr=65536;var Ir=15;var Ar=[25,50,100,200],ps=3600*1e3,_s=6e4;var hs="PM_TELEMETRY_DISABLED",gs="PM_NO_TELEMETRY",wr=new Set(["1","true","yes","on"]);var ys="PM_TELEMETRY_HTTP_TIMEOUT_MS",ws=globalThis.fetch,Es=["user","automation","test","dogfood"],nl=Promise.resolve(),Er=Promise.resolve();var ol=new Set(Es);var il=ht.randomUUID();var Cr="(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer|literals?|regex(?:es)?|replacements?)",bs=new RegExp(`\\b(${Cr})\\s*([:=])\\s*([^\\s,;]+)`,"giu"),Ts=new RegExp(`(--${Cr})(=|\\s+)([^\\s,;]+)`,"giu"),Ss=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,xs=/bearer\s+[a-z0-9._=-]+/giu,Is=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;function Ce(e){return x.join(e,ns)}function yt(e){return x.join(e,is)}function As(e){return x.dirname(Ce(e))}function vr(e){return x.join(e,os)}function Lr(e){return x.join(e,"runtime","telemetry","flush.lock")}function Cs(e){return x.join(e,"runtime","telemetry","flush.spawn.lock")}async function vs(e){let t=await S(vr(e));if(!t||t.trim().length===0)return{};try{let r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)?{}:r}catch{return{}}}async function v(e,t){try{let n={...await vs(e),...t},o=Object.fromEntries(Object.entries(n).filter(([,i])=>i!==void 0).sort((i,s)=>i[0].localeCompare(s[0])));await T(vr(e),`${JSON.stringify(o,null,2)}
10
+ `;await T(o,i)}function ki(e){return{id:e.id,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}function Ni(e){let t=xe(e.name,e.model);if(!t)throw new Error("Embedding provider must include a provider name and model");return t}function te(e,t){return{refreshed:[],skipped:e,warnings:[t]}}async function Oi(e,t,r){if(!r.settings&&!await F(Me(e)))return te(t,"search_semantic_refresh_skipped:settings_not_initialized");let n;try{if(r.settings)n=r.settings;else{let a=await se(e),c=a.warnings.find(d=>d.startsWith("settings_read_"));if(c)return te(t,`search_semantic_refresh_skipped:settings_read_failed:${c}`);n=a.settings}}catch(a){return te(t,`search_semantic_refresh_skipped:settings_read_failed:${b(a)}`)}let o=r.apply_runtime_defaults?he(n).settings:n,i=Ke(o).active;if(!i)return te(t,"search_semantic_refresh_skipped:provider_unconfigured");let s=ct(o,e).active;return s?{settings:o,provider:i,vectorStore:s}:te(t,"search_semantic_refresh_skipped:vector_store_unconfigured")}async function Pi(e,t,r,n,o,i){let s=[],a=new Set,c=new Set,d=[];for(let l of n){let u=await qe(e,l,t,r,o);if(!u){c.add(l);continue}try{let _=await je(u,{schema:i});d.push({id:_.document.metadata.id,document:_.document})}catch(_){a.add(u.id),s.push(`search_semantic_refresh_item_read_failed:${u.id}:${b(_)}`)}}return d.sort((l,u)=>l.id.localeCompare(u.id)),{documents:d,missingIds:re(c),skippedIds:re(a),warnings:s}}async function zi(e,t,r){let n=j(t.name,e.search.embedding_corpus_max_characters).maxCharacters,o=Qe(e),i=r.map(a=>Je(a.document,{providerName:t.name,maxCharacters:n,fields:o})),s=await et(t,e,i);return{vectors:s.vectors,vector_dimension:mt(s.vectors,"Semantic refresh embedding"),warnings:s.warnings}}async function $i(e,t,r){return await dt(e,t.map((n,o)=>({id:n.id,vector:r[o],payload:ki(n.document.metadata)}))),{refreshed:t.map(n=>n.id),skipped:[],warnings:[]}}async function Fi(e,t){if(t.length===0)return{refreshed:[],skipped:[],warnings:[]};try{return await Se(e,t),{refreshed:[],skipped:[],warnings:[]}}catch(r){return{refreshed:[],skipped:t,warnings:[`search_semantic_refresh_delete_failed:${b(r)}`]}}}async function nd(e,t,r={}){let n=re(t);if(n.length===0)return{refreshed:[],skipped:[],warnings:[]};let o=await Oi(e,n,r);if(!("settings"in o))return o;let i=U(o.settings,Pe()),s=await Pi(e,o.settings.id_prefix,o.settings.item_format,n,i.type_to_folder,o.settings.schema),a=s.documents.length>0||s.missingIds.length>0?await fr(e):{entries:{},embedding:null,warnings:[]},c=Ni(o.provider),d=a.entries,l={refreshed:[],skipped:[],warnings:[]},u=a.embedding;if(s.documents.length>0)if(a.embedding&&ut(a.embedding,c))l={refreshed:[],skipped:s.documents.map(w=>w.id),warnings:["search_semantic_refresh_requires_reindex:embedding_identity_changed"]};else try{let w=await zi(o.settings,o.provider,s.documents);if(ft(a.embedding,w.vector_dimension))l={refreshed:[],skipped:s.documents.map(E=>E.id),warnings:[...w.warnings,"search_semantic_refresh_requires_reindex:vector_dimension_changed"]};else{u=lt(c,w.vector_dimension);let E=await $i(o.vectorStore,s.documents,w.vectors);l={refreshed:E.refreshed,skipped:E.skipped,warnings:[...w.warnings,...E.warnings]}}}catch(w){l={refreshed:[],skipped:s.documents.map(E=>E.id),warnings:[`search_semantic_refresh_failed:${b(w)}`]}}let _=await Fi(o.vectorStore,s.missingIds),p=new Set(l.refreshed),h=Object.fromEntries(s.documents.filter(w=>p.has(w.id)).map(w=>[w.id,w.document.metadata.updated_at])),y=[];if(Object.keys(h).length>0||s.missingIds.length>0){let w={...d,...ur(h)};for(let E of s.missingIds)delete w[E];try{await mr(e,w,u)}catch(E){y.push(`search_vectorization_status_ledger_write_failed:${b(E)}`)}y.push(...a.warnings)}return{refreshed:re([...l.refreshed,..._.refreshed]),skipped:re([...s.skippedIds,...l.skipped,..._.skipped]),warnings:[...s.warnings,...l.warnings,..._.warnings,...y]}}import{createRequire as Vi}from"node:module";(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]="8eb48648-6e55-5710-990e-6471c7cdcde0")}catch{}})();var qi=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i,ad=new RegExp(`\\b(${qi.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");var cd=Vi(import.meta.url);(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]="e896db69-ed90-53f1-a227-e3d061b3bc8d")}catch{}})();var ud=new Map([[f.USAGE,"invalid_command_usage"],[f.NOT_FOUND,"item_not_found"],[f.CONFLICT,"lock_conflict"],[f.DEPENDENCY_FAILED,"dependency_failed"]]);(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]="5e6ba316-b067-51df-abeb-c3e3488a504d")}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]="c43dd9f2-78ac-5c22-970a-0016a06b87b3")}catch{}})();var wd=Object.freeze({"&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&amp;":"&"});(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]="0ce743d1-917a-5c96-b038-c95e3922bc48")}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]="868dfae8-2575-5d5f-8425-c7e68aefdc84")}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]="4ecab833-db06-5baa-bfe6-d28b4c97f85a")}catch{}})();function Hi(e,t){if(e==null)return[];let r=t?.separators??/,/,o=e.split(r).map(a=>a.trim()).filter(a=>a.length>0),s=t?.unique!==!1?Array.from(new Set(o)):o;return t?.sort===!0?[...s].sort():s}import _r from"node:fs/promises";import Ie 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]="4baf0ef3-2412-51cf-9ade-18b5c6e610d1")}catch{}})();function Yi(e){return"json_markdown"}function hr(e,t){return Ie.relative(e,t).replaceAll("\\","/")}function Bi(e){return String(e).replaceAll(/[^a-zA-Z0-9._-]+/g,"_").slice(0,120)}async function Gi(e,t,r="item_format:migrate",n=De,o){if(t!=="toon")throw new Error("Only toon item-format migration targets are supported. Markdown item files are legacy read-only input.");let i=new Set,s=new Set,a=[],c=0,d=Yi(t),l=Object.entries(n);for(let[u,_]of l){let p=Ie.join(e,_),h=[];try{h=await _r.readdir(p)}catch{continue}let y=new Map;for(let E of h){let L=Ie.join(p,E),D=St(L);if(!D)continue;let Y=Ie.extname(E),B=E.slice(0,E.length-Y.length).trim();if(B.length===0)continue;let $=y.get(B)??{};$[D]=L,y.set(B,$)}let w=[...y.keys()].sort((E,L)=>E.localeCompare(L));for(let E of w){let L=y.get(E);c+=1;let D=L[d];if(!D)continue;let Y=L[t]??D,B=Y===L[t]?t:d;try{let $=await _r.readFile(Y,"utf8"),Jr=ze($,{format:B,schema:o,onWarning:Zr=>a.push(`item_format_migration_parse_warning:${E}:${Zr}`)}),ve=ke(e,u,E,t,n),Tt=$e(Jr,{format:t,schema:o});await S(ve)!==Tt&&(await T(ve,Tt),a.push(...await ie({path:ve,scope:"project",op:r})),i.add(E)),await ne(D),s.add(hr(e,D)),a.push(...await ie({path:D,scope:"project",op:`${r}:remove`})),i.add(E)}catch($){a.push(`item_format_migration_skipped:${hr(e,Y)}:${Bi($)}`)}}}return{target_format:t,scanned:c,migrated:[...i].sort((u,_)=>u.localeCompare(_)),removed:[...s].sort((u,_)=>u.localeCompare(_)),warnings: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]="f280c1df-b134-57c3-91f6-cbf5a37e6e31")}catch{}})();var Wi=new Set(["completed","superseded"]);function Ki(e){return e!==void 0&&Wi.has(e)}function Qi(e){if(e.type.trim().toLowerCase()!=="plan")return!1;let t=e.plan_steps??[];return t.length>0&&t.every(r=>r.status==="completed")}import Nd from"node:readline/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6783b122-a1a8-5f86-9ac5-2c3e811622ed")}catch{}})();import ht from"node:crypto";import{mkdirSync as jd,rmSync as Zi,statSync as Hd}from"node:fs";import{mkdir as pt,readdir as es,rm as gt,stat as Sr}from"node:fs/promises";import{request as ts}from"node:http";import{request as rs}from"node:https";import x 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]="26ea62d9-874d-5826-9822-83c5523b673b")}catch{}})();var ns=x.join("runtime","telemetry","events.jsonl"),os=x.join("runtime","telemetry","state.json"),is=x.join("runtime","telemetry","otel-spans.jsonl"),ss=8,gr=500,as=1;var cs=100,ds=36e5,ls=3e4,yr=2e4,us=1e3,fs=25e3,ms=864e5,xr=65536;var Ir=15;var Ar=[25,50,100,200],ps=3600*1e3,_s=6e4;var hs="PM_TELEMETRY_DISABLED",gs="PM_NO_TELEMETRY",wr=new Set(["1","true","yes","on"]);var ys="PM_TELEMETRY_HTTP_TIMEOUT_MS",ws=globalThis.fetch,Es=["user","automation","test","dogfood"],nl=Promise.resolve(),Er=Promise.resolve();var ol=new Set(Es);var il=ht.randomUUID();var Cr="(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer|literals?|regex(?:es)?|replacements?)",bs=new RegExp(`\\b(${Cr})\\s*([:=])\\s*([^\\s,;]+)`,"giu"),Ts=new RegExp(`(--${Cr})(=|\\s+)([^\\s,;]+)`,"giu"),Ss=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,xs=/bearer\s+[a-z0-9._=-]+/giu,Is=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;function Ce(e){return x.join(e,ns)}function yt(e){return x.join(e,is)}function As(e){return x.dirname(Ce(e))}function vr(e){return x.join(e,os)}function Lr(e){return x.join(e,"runtime","telemetry","flush.lock")}function Cs(e){return x.join(e,"runtime","telemetry","flush.spawn.lock")}async function vs(e){let t=await S(vr(e));if(!t||t.trim().length===0)return{};try{let r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)?{}:r}catch{return{}}}async function v(e,t){try{let n={...await vs(e),...t},o=Object.fromEntries(Object.entries(n).filter(([,i])=>i!==void 0).sort((i,s)=>i[0].localeCompare(s[0])));await T(vr(e),`${JSON.stringify(o,null,2)}
11
11
  `)}catch{}}function Dr(e){return e.replaceAll(bs,(r,n,o)=>`${n}${o}[redacted]`).replaceAll(Ts,(r,n,o)=>`${n}${o}[redacted]`)}function Rr(e){return e.replaceAll(Ss,(t,r)=>`${r}[redacted_path]`)}function Mr(e){let t=e>=65&&e<=90,r=e>=97&&e<=122,n=e>=48&&e<=57;return t||r||n}function kr(e){if(!e)return!1;let t=e.charCodeAt(0);return Mr(t)?!0:e==="."||e==="_"||e==="%"||e==="+"||e==="-"}function Nr(e){if(!e)return!1;let t=e.charCodeAt(0);return Mr(t)?!0:e==="."||e==="-"}function Ls(e){let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@")||t===e.length-1)return!1;let r=e.slice(0,t),n=e.slice(t+1),o=n.lastIndexOf(".");if(o<=0||o===n.length-1||n.length-(o+1)<2)return!1;for(let i of r)if(!kr(i))return!1;for(let i of n)if(!Nr(i))return!1;return!0}function Ds(e){let t="",r=0;for(;r<e.length;){let n=e.indexOf("@",r);if(n<0){t+=e.slice(r);break}let o=n-1;for(;o>=r&&kr(e[o]);)o-=1;o+=1;let i=n+1;for(;i<e.length&&Nr(e[i]);)i+=1;let s=e.slice(o,i);if(Ls(s)){t+=e.slice(r,o),t+="[redacted_email]",r=i;continue}t+=e.slice(r,n+1),r=n+1}return t}function Or(e){return Ds(e).replaceAll(xs,"bearer [redacted_token]").replaceAll(Is,"[redacted_ip]")}function Rs(e){let t=Or(e),r=Dr(t),n=Rr(r),o=n.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":n.length>512?`${n.slice(0,509)}...`:n}function Ms(e){let t=Or(e),r=Dr(t),n=Rr(r),o=n.trim();return o.startsWith("/")&&o.length>1?"[redacted_path]":n.length>2048?`${n.slice(0,2045)}...`:n}function _t(e,t="redacted"){return t==="max"?Ms(e):Rs(e)}function br(){let e=process.env[ys]?.trim();if(!e)return yr;let t=Number(e);return Number.isFinite(t)?Math.min(fs,Math.max(us,Math.trunc(t))):yr}async function Pr(e,t,r){let n=new URL(e);if(globalThis.fetch!==ws){let i=new AbortController,s,a=new Promise((c,d)=>{s=setTimeout(()=>{i.abort(),d(new Error("telemetry_http_timeout"))},br())});try{return(await Promise.race([globalThis.fetch(e,{method:"POST",headers:t,body:r,signal:i.signal}),a])).status}finally{clearTimeout(s)}}let o=n.protocol==="https:"?rs:n.protocol==="http:"?ts:void 0;if(!o)throw new Error(`telemetry_http_protocol_unsupported_${n.protocol}`);return new Promise((i,s)=>{let a=br(),c={method:"POST",headers:{...t,"content-length":Buffer.byteLength(r)},signal:AbortSignal.timeout(a),autoSelectFamilyAttemptTimeout:Math.min(5e3,a)},d=o(n,c,l=>{l.once("error",s),l.once("end",()=>i(l.statusCode)),l.resume()});d.once("error",s),d.end(r)})}function ks(){return wr.has((process.env[hs]??"").trim().toLowerCase())||wr.has((process.env[gs]??"").trim().toLowerCase())}async function Ns(e){let t=await M(e),r=!1;return t.telemetry.installation_id.trim().length===0&&(t.telemetry.installation_id=ht.randomUUID(),r=!0),r&&await ae(e,t,"telemetry:install_id"),{installationId:t.telemetry.installation_id,endpoint:t.telemetry.endpoint,retentionDays:Math.max(1,Math.trunc(t.telemetry.retention_days))}}function zr(e){let t=[];for(let r of e.split(`
12
12
  `)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);o&&typeof o=="object"&&o.event&&typeof o.event=="object"&&typeof o.attempts=="number"&&(o.client_schema_version===void 0||typeof o.client_schema_version=="number"&&Number.isFinite(o.client_schema_version))&&t.push(o)}catch{}}return t}function $r(e){let t=Math.min(ls*2**Math.max(e-1,0),ds);return new Date(Date.now()+t).toISOString()}function Fr(e){if(typeof e!="string"||e.trim().length===0)return!0;let t=Date.parse(e);return Number.isNaN(t)?!0:t<=Date.now()}function Os(e){return Fr(e.next_attempt_after)}function Ur(e){let t=Number.isFinite(e)?Math.max(1,Math.trunc(e)):1;return Date.now()-t*ms}function Ps(e,t){let r=e.event?.occurred_at;if(typeof r!="string"||r.trim().length===0)return!1;let n=Date.parse(r);return Number.isNaN(n)?!1:n<t}function wt(e,t){let r=Ur(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>xr||Ps(i,r)||i.attempts>=Ir){o+=1;continue}n.push(i)}return{entries:n,prunedCount:o}}async function Ae(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
13
13
  `),n=r.length>0?`${r}
@@ -15,4 +15,4 @@ ${i}`;continue}return null}return r}function qn(e,t){let r=Vt(e).trim();if(!r)th
15
15
  `)){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=zs(o)),t.push(o))}catch{}}return t}function $s(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 Hr(e,t){let r=Ur(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>xr||$s(i,r)||i.attempts>=Ir){o+=1;continue}n.push(i)}if(n.length>gr){let i=n.length-gr;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function Fs(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
16
16
  `),n=r.length>0?`${r}
17
17
  `:"";for(let o=0;;o+=1)try{await T(yt(e),n);return}catch(i){let s=Ar[o];if(s===void 0||!Vr(i))throw i;await qr(s)}}async function Tr(e,t,r,n){return Et(async()=>{let o=await S(yt(e)),i=o===null?[]:jr(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}=Hr(s,t);return await Fs(e,a),a.length})}async function Us(e,t){let r=await S(yt(e));if(r===null||r.trim().length===0){await v(e,{pending_otel_spans:0});return}let n=jr(r),{entries:o,prunedCount:i}=Hr(n,t),s=o.filter(h=>Fr(h.next_attempt_after)).slice(0,ss);if(s.length===0){let h=i>0?await Tr(e,t,new Set,new Map):o.length;await v(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 Pr(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?_t(y.message,"redacted"):"local_otel_export_failed";let w=h.attempts+1;d.set(h.id,{attempts:w,next_attempt_after:$r(w)})}}));let _=await Tr(e,t,c,d),p={pending_otel_spans:_,last_otel_attempt_at:a};l>0&&(p.last_otel_success_at=a),u!==void 0?(p.last_otel_failure_at=a,p.last_otel_failure_error=u):_===0&&(p.last_otel_failure_at=void 0,p.last_otel_failure_error=void 0),await v(e,p)}async function Vs(e,t,r){try{await Ys(e,t,r)}catch{}try{await Us(e,r)}catch{}}async function qs(e,t=ps){try{let r=As(e),n=await es(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 Sr(s)).mtimeMs<o&&await gt(s,{force:!0})}))}catch{}}async function Et(e){let t=Er.catch(()=>{}).then(e);return Er=t.catch(()=>{}),t}async function bt(e){let t=await S(Ce(e));return t===null||t.trim().length===0?[]:zr(t)}async function js(e,t,r){return Et(async()=>{let n=await bt(e),{entries:o}=wt(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await Ae(e,i),i})}async function Hs(e,t,r,n){return Et(async()=>{let o=await bt(e),{entries:i}=wt(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:$r(c)}});return await Ae(e,s),s})}async function Ys(e,t,r){await qs(e);let n=t.trim();if(n.length===0)return;let o=await S(Ce(e));if(o===null||o.trim().length===0){await v(e,{endpoint:n,queue_entries:0});return}let i=zr(o);if(i.length===0){await v(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=wt(i,r);if(s.length===0){await Ae(e,[]),await v(e,{endpoint:n,queue_entries:0});return}let c=s.filter(p=>Os(p)).slice(0,cs);if(c.length===0){a>0&&await Ae(e,s),await v(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(p=>p.event.event_id)),l=R(),u={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(u["x-pm-telemetry-key"]=_);try{let p=await Pr(n,u,JSON.stringify({schema_version:as,events:c.map(h=>h.event)}));if(p<200||p>=300)throw new Error(`telemetry_flush_http_${p}`)}catch(p){let h=await Hs(e,d,l,r),y=p instanceof Error?_t(p.message,"redacted"):"telemetry_flush_failed";await v(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 p=await js(e,d,r);await v(e,{endpoint:n,queue_entries:p.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(p){let h=p instanceof Error?_t(p.message,"redacted"):"telemetry_flush_failed",y=await bt(e).catch(()=>s);await v(e,{endpoint:n,queue_entries:y.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:h})}}async function Bs(e){let t=Lr(e);await pt(x.dirname(t),{recursive:!0});try{return await pt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await Sr(t);return Date.now()-r.mtimeMs<_s?!1:(await gt(t,{recursive:!0,force:!0}),await pt(t),!0)}catch{return!1}}function Gs(e){try{Zi(e,{recursive:!0,force:!0})}catch{}}function Ws(e){Gs(Cs(e))}async function Ks(e,t,r){let n=await Bs(e);if(Ws(e),!!n)try{await Vs(e,t,r)}finally{try{await gt(Lr(e),{recursive:!0,force:!0})}catch{}}}async function sl(e=Re(process.cwd())){if(!ks())try{if(!(await M(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await Ns(e);await Ks(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]="a678b9f8-ba36-5127-877f-96bb4acc38c5")}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]="13c02696-29a7-598e-888a-3502fd88bfbe")}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]="a2fad90a-3575-5f3e-8cbe-ac380ac45591")}catch{}})();var Qs=3,Yr=20,Xs=.8,Js=100,Br=1e3,Gr=1e6;function Sp(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`]}function Wr(e){let t=e.limit??Qs,r=e.threshold??Xs;if(!Number.isSafeInteger(t)||t<0||t>Yr)throw new m(`Similarity limit must be an integer from 0 to ${Yr}.`,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 Zs(e){let t=e.limit??Js;if(!Number.isSafeInteger(t)||t<0||t>Br)throw new m(`Duplicate cluster limit must be an integer from 0 to ${Br}.`,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 ea(e,t){let r=oe(e.cwd??process.cwd(),e.pmRoot),n=await M(r),o=U(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=Oe(n.schema),a=i?.map(u=>{if(u==="all")return u;let _=K(u,s);if(!_)throw new m(`Unknown duplicate-cluster status "${u}". Allowed: all, ${s.definitions.map(p=>p.id).join(", ")}.`,f.USAGE);return _}),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 de(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())).sort((u,_)=>u.id.localeCompare(_.id)).map(u=>({item:u,prepared:X(u.title)})),statuses:d}}function Kr(e,t=Gr){let r=new Set,n=[new Map,new Map,new Map];for(let[o,i]of e.entries()){let s=[[i.prepared.normalized],i.prepared.issueCodes,i.prepared.tokens];for(let[a,c]of s.entries())for(let d of c){let l=n[a].get(d)??[];for(let u of l)r.add(`${u}:${o}`);if(r.size>t)throw new m(`Duplicate sweep exceeded ${Gr} candidate pairs; narrow it with statuses or since.`,f.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the batch duplicate query until its deterministic candidate set fits the disclosed safety bound."});l.push(o),n[a].set(d,l)}}return r}var xp={buildDuplicateClusters:Xr,collectDuplicateCandidatePairs:Kr,createDuplicateUnionFind:Qr};function Qr(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 ta(e,t,r,n){let o=[];for(let i of t){let[s,a]=i.split(":").map(u=>Number.parseInt(u,10)),c=fe(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 Xr(e,t,r,n){let o=new Map;for(let i of e.keys()){let s=r.findRoot(i),a=o.get(s)??[];a.push(i),o.set(s,a)}return[...o.values()].filter(i=>i.length>1).map(i=>{let s=new Set(i.map(c=>e[c].item.id)),a=t.filter(c=>s.has(c.left_id)&&s.has(c.right_id)).sort((c,d)=>d.score-c.score||c.left_id.localeCompare(d.left_id)||c.right_id.localeCompare(d.right_id));return{id:e[i[0]].item.id,items:i.map(c=>{let d=e[c].item;return{id:d.id,title:d.title,status:d.status,type:d.type}}),matches:a,max_score:a[0]?.score??0}}).sort((i,s)=>s.max_score-i.max_score||i.id.localeCompare(s.id)).slice(0,n)}function ra(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,...ue(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 na(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}=Wr(t),i=oe(t.cwd??process.cwd(),t.pmRoot),s=await M(i),a=U(s),c=await Ve(i,Object.values(a.type_to_folder)),d=J(r),l=c&&d.length>0?await Ue({pmRoot:i,expectedSourceCursor:c.source_cursor,query:d.map(p=>`"${p.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(n*10,50)}):null,u=l===null?await de(i,s.item_format,a.type_to_folder,void 0,s.schema):l.items,_=ra(r,u,new Set(e.excludeIds??[]),o,n);return{items:_,count:_.length,threshold:o,source:l?"persistent_index":"metadata_fallback"}}async function Ip(e={}){let{threshold:t}=Wr({...e,limit:void 0}),{limit:r,since:n}=Zs(e),{items:o,statuses:i}=await ea(e,n),s=Kr(o),a=Qr(o.length),c=ta(o,s,t,a),d=Xr(o,c,a,r);return{clusters:d,count:d.length,threshold:t,source:"metadata_scan",filters:{statuses:i??null,since:e.since??null},cost:{item_count:o.length,candidate_pairs:s.size,scored_pairs:s.size}}}async function Ap(e,t){if(t.mode==="off")return;let r=await na(e,t);if(r.count===0)return;let n=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!n){let o=r.items.map(i=>`${i.id} (${i.status}): ${i.title}`).join("; ");throw new m(`Likely duplicate item(s) found: ${o}. Reuse the canonical item or pass --allow-duplicate with explicit intent.`,f.CONFLICT,{code:"likely_duplicate",required:"Reuse an existing item, or explicitly acknowledge the duplicate with --allow-duplicate.",recovery:{suggested_flags:["--allow-duplicate"]}})}return{mode:t.mode,bypassed:n,result: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]="412fc2d2-daee-5d87-82ab-5411a1503087")}catch{}})();function Lp(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{En as a,bn as b,Sn as c,xn as d,va as e,In as f,An as g,Be as h,Cn as i,$a as j,Ln as k,Pt as l,Dn as m,Rn as n,$t as o,Mn as p,kn as q,Nn as r,On as s,qn as t,Yn as u,Bn as v,Wn as w,Kn as x,Qn as y,Zn as z,Wa as A,ro as B,ec as C,so as D,co as E,en as F,lo as G,uo as H,he as I,Oo as J,Tc as K,Ke as L,Jt as M,Qe as N,Go as O,Wo as P,Ic as Q,Zt as R,j as S,Je as T,et as U,ct as V,Pc as W,dt as X,Se as Y,sr as Z,xe as _,lt as $,ut as aa,ft as ba,mt as ca,fr as da,mr as ea,nd as fa,an as ga,Dt as ha,dn as ia,ln as ja,un as ka,la,fa as ma,Q as na,le as oa,J as pa,X as qa,ue as ra,fe as sa,Rt as ta,hn as ua,Hi as va,Gi as wa,Ki as xa,Qi as ya,as as za,Ir as Aa,Es as Ba,sl as Ca,Lp as Da,Sp as Ea,xp as Fa,na as Ga,Ip as Ha,Ap as Ia};
18
- //# sourceMappingURL=chunk-ZQPGZZWQ.js.map
18
+ //# sourceMappingURL=chunk-PRHY2IMX.js.map
@@ -0,0 +1,2 @@
1
+ (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]="a54549aa-2f6c-5092-a3eb-5b36ee698ea4")}catch{}})();var G=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],ze=2,$e=Object.freeze({migration:"schema",validation:"schema"}),On=Object.freeze({version:ze,capabilities:[...G],legacy_aliases:{...$e}}),ae=["off","warn","enforce"],ce=["off","warn","enforce"],ue=["none","restricted","strict"],An=["block","warn"],de=["commands.override","commands.handler","hooks.beforecommand","hooks.beforemutation","hooks.aftercommand","hooks.onwrite","hooks.onread","hooks.onindex","schema.flags","schema.itemfields","schema.itemtypes","schema.relationshipkinds","schema.migrations","schema.profiles","parser.override","preflight.override","services.override","renderers.override","importers.importer","importers.exporter","search.provider","search.vectorstore","services.assuranceprovider"],le=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function fe(){return{mode:"off",trust_mode:"off",require_provenance:!1,trusted_extensions:[],default_sandbox_profile:"none",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:[]}}(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]="f6ab5bae-53b3-5feb-b89f-46e64afe7058")}catch{}})();var Xe=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],wn=Xe,Tn=["draft","open","in_progress","blocked","closed","canceled"],kn=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],xn=["string","number","boolean","string_array","array","object"],Rn=["create","update","update_many","list","search","calendar","context"],Nn=["allow","warn","reject"],In=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","recurs_from","supersedes","task","verifies"],Cn=["project","global"],vn=["low","medium","high","critical"],Dn=["low","medium","high","critical"],Mn=["low","medium","high"];var Un=["minimal","default","strict","custom"],Ln=["none","warn","strict"],Pn=["progressive","strict"],jn=["off","warn","strict"],Vn=["off","warn","strict"];var Fn=["daily","weekly","monthly","yearly"],Ye=["mon","tue","wed","thu","fri","sat","sun"];function Bn(e){return Ye.indexOf(e)}var Gn=["draft","research","review","approved","executing","paused","completed","superseded"],Kn=["pending","in_progress","completed","blocked","skipped","superseded"],zn=["codex","claude-code","cursor","generic"],$n=["related","blocks","blocked_by","depends_on","discovered_from","implements","recurs_from","verifies","supersedes"],Xn=["brief","standard","deep","full"],Yn=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(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]="45e1dcb9-d2d6-52d7-b0b0-a57556a3fb03")}catch{}})();var qe=Object.freeze([{id:"draft",roles:["draft"]},{id:"open",roles:["active","default_open"]},{id:"in_progress",aliases:["in-progress"],roles:["active"]},{id:"blocked",roles:["blocked"]},{id:"closed",roles:["terminal","terminal_done","default_close"]},{id:"canceled",aliases:["cancelled"],roles:["terminal","terminal_canceled","default_cancel"]}]),We=Object.freeze({draft_status:"draft",open_status:"open",in_progress_status:"in_progress",blocked_status:"blocked",close_status:"closed",canceled_status:"canceled"}),Qn=".agents/pm",Jn="settings.json";var Qe=["","epics","features","tasks","chores","issues","schema","history","search","extensions","locks"],Je=["decisions","events","reminders","milestones","meetings","plans"],Hn=[...Qe,...Je],Zn={Epic:"epics",Feature:"features",Task:"tasks",Chore:"chores",Issue:"issues",Decision:"decisions",Event:"events",Reminder:"reminders",Milestone:"milestones",Meeting:"meetings",Plan:"plans"},He=["goal","objective","value","impact","outcome","why_now","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","unblock_note","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result"],eo=["id","title","description","type","pm_format_version","source_type","type_options","status","priority","tags","created_at","updated_at","deadline","reminders","events","closed_at","completed_at","assignee","claim_principal","source_owner","author","estimated_minutes","acceptance_criteria","design","external_ref","definition_of_ready","order",...He,"affected_version","fixed_version","component","regression","customer_impact","dependencies","comments","notes","learnings","files","tests","test_runs","docs","close_reason","duplicate_of","plan_mode","plan_scope","plan_harness","plan_resume_context","plan_validation","plan_decisions","plan_discoveries","plan_steps"],Ze={minimal:{ownership_enforcement:"none",create_mode_default:"progressive",close_validation_default:"off",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!1,duplicate_detection_mode:"off",duplicate_detection_threshold:.8,duplicate_detection_limit:3},default:{ownership_enforcement:"warn",create_mode_default:"progressive",close_validation_default:"warn",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3},strict:{ownership_enforcement:"strict",create_mode_default:"strict",close_validation_default:"strict",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"strict",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3}},et=["no active blocker","ready for planned execution sequencing","work completed","work is closed"],K={blocked_reason:["no active blocker because work is closed","work is closed"],resolution:["closed with implementation evidence","closed with verification evidence","work completed and recorded","work is closed"],actual_result:["closed and recorded","work completed","work completed and recorded"]};function _e(e){return e?[...e]:void 0}var to={version:1,id_prefix:"pm-",ids:{token_length:4},author_default:"",agent_identity:{probes_enabled:!0,identity_vocabulary:{version:1,aliases:{}},harness_signals:[]},mutation_guard:{require_attributed_author:!1,secret_guard:"advise",stale_in_progress_hours:72},item_format:"toon",locks:{ttl_seconds:1800,wait_ms:3e3},checkpoints:{retention_days:14},output:{default_format:"toon"},ux:{deprecation_hints:!0},history:{missing_stream:"auto_create",compact_policy:{enabled:!1,max_entries:500,trigger:"health_warn"}},validation:{sprint_release_format:"warn",parent_reference:"warn",metadata_profile:"core",metadata_required_fields:[],lifecycle_stale_blocker_reason_patterns:[...et],lifecycle_closure_like_blocked_reason_patterns:[...K.blocked_reason],lifecycle_closure_like_resolution_patterns:[...K.resolution],lifecycle_closure_like_actual_result_patterns:[...K.actual_result],estimate_defaults_by_type:{}},governance:{preset:"minimal",...Ze.minimal},workflow:{definition_of_done:[]},testing:{record_results_to_items:!1},telemetry:{enabled:!0,first_run_prompt_completed:!1,capture_level:"redacted",endpoint:"https://pm-cli.unbrained.dev/v1/events",installation_id:"",retention_days:365},agent_guidance:{prompt_completed:!1,declined:!1,declined_at:"",template_version:1,last_checked_files:[]},item_types:{definitions:[]},schema:{version:1,files:{types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"},statuses:qe.map(e=>({...e,aliases:_e(e.aliases),roles:_e(e.roles)})),fields:[],workflow:{...We},unknown_field_policy:"allow"},extensions:{enabled:[],disabled:[],policy:fe()},search:{score_threshold:0,hybrid_semantic_weight:.7,max_results:50,embedding_model:"",embedding_batch_size:32,embedding_timeout_ms:3e4,scanner_max_batch_retries:3,provider:"",mutation_refresh_policy:"semantic_configured",query_expansion:{enabled:!1,provider:""},rerank:{enabled:!1,model:"",top_k:20}},providers:{openai:{base_url:"",api_key:"",model:""},ollama:{base_url:"",model:""}},context:{default_depth:"brief",activity_limit:10,stale_threshold_days:7,sections:{hierarchy:!0,activity:!0,progress:!0,recently_created:!0,unparented:!0,blockers:!0,files:!0,workload:!0,staleness:!0,tests:!0}},vector_store:{adapter:"",collection_name:"pm_items",qdrant:{url:"",api_key:""},lancedb:{path:""}}},no={metadata:{},body:""},m={SUCCESS:0,GENERIC_FAILURE:1,USAGE:2,NOT_FOUND:3,CONFLICT:4,DEPENDENCY_FAILED:5,NO_EFFECT:6,PARTIAL_EFFECT:7},oo=Object.freeze({unknown_command:"usage",unknown_option:"usage",missing_required_option:"usage",missing_required_argument:"usage",invalid_command_usage:"usage",linked_test_value_not_quoted:"usage",invalid_argument_value:"validation",health_findings:"validation",validation_findings:"validation",close_through_update:"validation",no_update_fields:"validation",unsupported_update_option:"validation",tracker_not_initialized:"validation",item_not_found:"validation",ownership_conflict:"conflict",lock_conflict:"conflict",terminal_state_conflict:"conflict",dependency_failed:"runtime",init_gitignore_unwritable:"runtime",merge_git_config_unwritable:"runtime",command_failed:"runtime",unknown_error:"runtime"});(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]="a19ff5c0-2c4d-5576-a551-cab35276fdc3")}catch{}})();var p=class extends Error{exitCode;code;context;constructor(t,n,o={}){super(t),this.name="PmCliError",this.exitCode=n,this.context=o,this.code=o.code}};(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]="9afc5057-afcd-5d6c-a4c1-c2883640fc50")}catch{}})();var N=[...[["fetch","get"],["read","get"],["show","get"],["view","get"],["comment","comments"],["note","notes"],["learning","learnings"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:[t],lifecycle:"permanent",hidden:!1,registration:"bootstrap",owner:"pm-pbyu"})),...[["extension list","extension catalog"],["extension scaffold","extension init"],["package list","package catalog"],["package scaffold","package init"],["packages list","packages catalog"],["packages scaffold","packages init"]].map(([e,t])=>({alias:e,canonical:t,canonical_argv:t.split(" "),lifecycle:"permanent",hidden:!1,registration:"commander",owner:"pm-ya7x55"})),{alias:"list-all",canonical:"list",canonical_argv:["list","--all"],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"},...[["list-draft","draft"],["list-open","open"],["list-in-progress","in_progress"],["list-blocked","blocked"],["list-closed","closed"],["list-canceled","canceled"]].map(([e,t])=>({alias:e,canonical:"list",canonical_argv:["list","--status",t],lifecycle:"deprecated",hidden:!0,registration:"commander",owner:"pm-pfqi"}))],io=Object.fromEntries(N.filter(e=>e.registration==="bootstrap").map(e=>[e.alias,e.canonical]));function ao(e){let t=e.trim().toLowerCase();return N.find(n=>n.alias===t)}function co(e){return`Deprecated command \`${e.alias}\`; use \`pm ${e.canonical_argv.join(" ")}\`.`}(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]="d05ce92b-bee8-5cce-afc2-8c7901306a30")}catch{}})();var tt=[...G],nt=[...le],ot=[...ae],_o=[...ce],po=[...ue],rt=[...de],I=["init","config","extension","package","packages","install","upgrade","create","item","copy","focus","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","aggregate","context","ctx","get","graph","search","duplicates","eval","next","history","events","history-redact","history-repair","history-compact","history-author-acknowledge","merge","schema","profile","activity","restore","update","update-many","close","close-many","delete","append","comments","notes","learnings","files","docs","deps","plan","test","test-all","telemetry","stats","health","validate","assurance","gc","workspace","contracts","claim","release","start-task","pause-task","close-task","meet","event","remind","help"],mo=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],st=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],pe={help:"Commander help rendering has no SDK operation result.",item:"The item namespace only groups lifecycle subcommands already exposed as actions.",packages:"The plural package alias only renders package-oriented help."},C=Object.freeze(I.flatMap(e=>e in pe?[]:e==="extension"||e==="package"?[...st.map(t=>`${e}-${t}`),e]:[e])),it=Object.freeze(N.filter(e=>e.lifecycle==="deprecated"&&e.registration==="commander"&&C.includes(e.alias)).map(e=>e.alias)),go=Object.freeze(C.filter(e=>!it.includes(e)));function yo(e=I,t=C,n=pe){let o=new Set(t),r=new Set(e);return{missing_cli_actions:e.filter(s=>!o.has(s)&&n[s]===void 0),waived_cli_actions:e.filter(s=>!o.has(s)&&n[s]!==void 0),stale_waivers:Object.keys(n).filter(s=>!r.has(s)||o.has(s))}}function ho(e){return C.includes(e)}function bo(e){return tt.includes(e)}function Eo(e){return nt.includes(e)}function Oo(e){return ot.includes(e)}function Ao(e){return rt.includes(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="810d42b5-98f4-57a7-bdd9-2dfa1b2b1c03")}catch{}})();var at=new Set(["applied_bound","completeness","budget_retention_policy","continuation_contract","continuation_kind","continuation_path","filters","omission_receipt","output_budget_truncation","projection","read_output","read_session","row_contract","sorting"]);function E(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function me(e,t){let n=e;for(let o of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(o))return;n=n[Number(o)]}else{if(!E(n))return;n=n[o]}return n}function z(e,t,n){let o=t.split("."),r=(s,a)=>{if(a===o.length)return n;let i=o[a];if(Array.isArray(s)){let u=Number(i),l=[...s];return l[u]=r(s[u],a+1),l}let d=s;return{...d,[i]:r(d[i],a+1)}};return r(e,0)}function ge(e,t,n){let o=A(e).find(s=>s.path===t);if(!o)return e;let r=Array.isArray(o.value)?o.value.slice(n):Object.fromEntries(Object.entries(o.value).slice(n));return z(e,t,r)}function v(e){let t=e.row_contract;return E(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function ct(e){let t=e.row_contract;return E(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):v(e)}function O(e){return v(e).flatMap(t=>{let n=me(e,t);return Array.isArray(n)||E(n)?[{path:t,value:n}]:[]})}function A(e){return ct(e).flatMap(t=>{let n=me(e,t);return Array.isArray(n)||E(n)?[{path:t,value:n}]:[]})}function D(e){let t=O(e),n=new Set(t.map(r=>r.path)),o=(r,s)=>{if(Array.isArray(r)){n.has(s)||t.push({path:s,value:r}),r.forEach((a,i)=>o(a,`${s}.${i}`));return}if(E(r))for(let[a,i]of Object.entries(r))s.length===0&&at.has(a)||o(i,s.length===0?a:`${s}.${a}`)};return o(e,""),t}function M(e){return O(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function T(e,t){let n=e;for(let o of O(n)){let r=Array.isArray(o.value)?o.value.map((s,a)=>t(s,o.path,a)):Object.fromEntries(Object.entries(o.value).map(([s,a],i)=>[s,t(a,o.path,i)]));n=z(n,o.path,r)}return n}function ye(e,t){let n=e,o=!1;for(let r of O(n)){let s=Array.isArray(r.value)?r.value:Object.entries(r.value);if(s.length<=t)continue;o=!0;let a=Array.isArray(r.value)?s.slice(0,t):Object.fromEntries(s.slice(0,t));n=z(n,r.path,a)}return{result:n,truncated:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="642f6dec-c0b2-5377-a401-dfa4f8ef6a2a")}catch{}})();var $=256,X=1e4,ut=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,dt=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,lt=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),ft=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&ut.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=$,reason:`token_budget must be a safe integer of at least ${$}.`},{valid:e=>Number.isSafeInteger(e.spent_tokens)&&e.spent_tokens>=0&&e.spent_tokens<=e.token_budget,reason:"spent_tokens must be a non-negative safe integer no larger than token_budget."},{valid:e=>Array.isArray(e.seen_item_ids)&&e.seen_item_ids.length<=X&&e.seen_item_ids.every(t=>typeof t=="string"&&dt.test(t)),reason:`seen_item_ids must contain at most ${X} portable item identifiers.`}];function L(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function U(e){throw new p(`--output-session ${e}`,m.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function P(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{U("must be a valid JSON object.")}L(t)||U("must be a JSON object.");let n=Object.keys(t).filter(s=>!lt.has(s));n.length>0&&U(`contains unknown field "${n.sort()[0]}".`);let o=ft.find(s=>!s.valid(t));o!==void 0&&U(o.reason);let r=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:r}}function he(e){if(L(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:L(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function _t(e){let t=new Set,n=0;for(let o of O(e)){let r=Array.isArray(o.value)?o.value:Object.values(o.value);for(let s of r){if(!L(s))continue;if(typeof s.context_ref=="string"){n+=1;continue}let a=he(s);a!==void 0&&t.add(a)}}return{deliveredIds:t,suppressedRepeatCount:n}}function be(e,t){let n=new Set(t.seen_item_ids);return T(e,o=>{let r=he(o);return r!==void 0&&n.has(r)?{id:r,context_ref:`session:${t.id}:${r}`}:o})}function Y(e,t){let{deliveredIds:n,suppressedRepeatCount:o}=_t(e),r=new Set(t.seen_item_ids),s=[...n].filter(g=>!r.has(g)).sort(),a=s.slice(0,X-t.seen_item_ids.length),i=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,u={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:n.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:i}},l={...e,read_session:u},c=g=>{u.spent_this_call_tokens=g,u.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,g),u.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+u.charged_this_call_tokens),u.remaining_tokens=Math.max(0,t.token_budget-u.spent_total_tokens),u.exhausted=u.remaining_tokens<$,u.next_state.spent_tokens=u.spent_total_tokens},_=0,f=0;for(let g=0;g<8;g+=1){c(_);let R=Math.ceil(Buffer.byteLength(JSON.stringify(l),"utf8")/4);if(R===_)return l;f=Math.max(f,R),_=R}return c(f),l}function Ee(e){return Math.max(0,e.token_budget-e.spent_tokens)}(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]="23b3a820-f205-506b-9507-dbd60087f62e")}catch{}})();var pt=["full","compact","brief","summary","counts"],Io=["mutation","read","discovery","governance"],mt=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),gt=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),yt=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),ht={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},bt=3,Et=2;function Ot(e){let[t=""]=e.trim().split(/\s+/u);return mt.has(t)?"mutation":gt.has(t)?"discovery":yt.has(t)?"governance":"read"}function Oe(e,t=Ot(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let o=ht[t];return At({command:n,budget_class:t,default_max_estimated_tokens:o,default_max_estimated_tokens_by_format:{toon:o,json:Math.ceil(o*bt/Et)},degradation_ladder:pt,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function At(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var St=I.map(e=>Oe(e)),wt=new Map(St.map(e=>[e.command,e]));function Ae(e,t={}){let n=e.trim().replace(/\s+/gu," "),[o]=n.split(" "),r=wt.get(o);return r?{...r,command:n}:t.generateFallback?Oe(n):null}function Co(e){return Math.ceil(Math.max(0,e)/4)}import{createHash as hn}from"node:crypto";import Tt from"node:crypto";(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]="83232698-197a-5aef-be7c-aa37f3c56822")}catch{}})();function kt(e){if(e===null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return e.toString();if(e===void 0)return"undefined";if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[function:${e.name||"anonymous"}]`}function xt(e){let t=Object.keys(e).sort(),n={};for(let o of t){let r=e[o];r!==void 0&&(n[o]=j(r))}return n}function j(e){let t=kt(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(o=>j(o));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let o=n.toJSON();if(o!==e)return j(o)}return xt(e)}function V(e){return JSON.stringify(j(e))}function Se(e,t,n,o){for(let r=0;r<t.length;r+=1)if(!n.has(r)&&o(e,t[r]))return n.add(r),!0;return!1}function Rt(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function Nt(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function It(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let n=[...t],o=new Set;for(let r of e)if(!Se(r,n,o,k))return!1;return!0}function Ct(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let n=[...t.entries()],o=new Set;for(let[r,s]of e.entries())if(!Se([r,s],n,o,([i,d],[u,l])=>k(i,u)&&k(d,l)))return!1;return!0}function vt(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,o)=>k(n,t[o]))}function Dt(e,t){let n=Object.keys(e).sort((r,s)=>r.localeCompare(s)),o=Object.keys(t).sort((r,s)=>r.localeCompare(s));if(n.length!==o.length)return!1;for(let r=0;r<n.length;r+=1){let s=n[r];if(s!==o[r]||!k(e[s],t[s]))return!1}return!0}var Mt=[Rt,Nt,It,Ct,vt];function k(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of Mt){let o=n(e,t);if(o!==void 0)return o}return Dt(e,t)}function Mo(e){return Tt.createHash("sha256").update(e,"utf8").digest("hex")}function Uo(e,t){let n={};for(let r of t){let s=e[r];s!==void 0&&(n[r]=s)}let o=Object.keys(e).filter(r=>!t.includes(r)).sort((r,s)=>r.localeCompare(s));for(let r of o){let s=e[r];s!==void 0&&(n[r]=s)}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]="737ac274-c165-5d1a-8b8e-cb5d57a81c46")}catch{}})();var Ut=8,Lt=64;function W(e){return Math.ceil(Buffer.byteLength(JSON.stringify(e),"utf8")/4)}function Pt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function q(e,t){return typeof e=="string"?e.length<=240?e:(t.compacted=!0,`${e.slice(0,240)}\u2026`):Array.isArray(e)?e.map(n=>q(n,t)):Pt(e)?Object.fromEntries(Object.entries(e).map(([n,o])=>[n,q(o,t)])):e}function h(e,t){let n=t.estimated_tokens;for(let o=0;o<Ut;o+=1){t.estimated_tokens=n;let r=W(e);if(r===n)return;n=r}t.estimated_tokens=n}function jt(e,t,n,o){for(let r=0;r<Lt;r+=1){if(h(e,t),t.estimated_tokens<=n)return;let s=D(e).filter(i=>(Array.isArray(i.value)?i.value.length:Object.keys(i.value).length)>Math.max(1,o.get(i.path)??0)).map(i=>({collection:i,length:Array.isArray(i.value)?i.value.length:Object.keys(i.value).length})).sort((i,d)=>d.length-i.length||i.collection.path.localeCompare(d.collection.path))[0]?.collection;if(!s)return;let a=Math.max(1,o.get(s.path)??0);if(Array.isArray(s.value))s.value.splice(-Math.min(s.value.length-a,Math.max(1,Math.ceil(s.value.length/2))));else{let i=Object.keys(s.value);for(let d of i.slice(-Math.min(i.length-a,Math.max(1,Math.ceil(i.length/2)))))delete s.value[d]}t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],s.path])].sort((i,d)=>i.localeCompare(d)),e.has_more=!0,e.truncated=!0,typeof e.count=="number"&&(e.count=M(e))}}function we(e,t,n,o=new Map){let r={compacted:!1},s=q(e,r);return t.strings_compacted=r.compacted,s.read_output=t,jt(s,t,n,o),h(s,t),s}import{createHash as Vt}from"node:crypto";(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]="d3329fac-693d-566c-a30a-43f8fb37938f")}catch{}})();var Q=1,ke=4096,Ft=/^[A-Za-z0-9_-]+$/;function Te(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function Ko(e,t){let n=new Set;for(let o of t)if(o.cursor_semantics==="presentation"){n.add(Te(o.flag));for(let r of o.aliases??[])n.add(Te(r))}return Object.fromEntries(Object.entries(e).filter(([o])=>!n.has(o)))}function zo(e,t){return Vt("sha256").update(e).update("\0").update(V(t)).digest("hex").slice(0,24)}function J(e,t,n,o){return Buffer.from(JSON.stringify({version:Q,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...o===void 0?{}:{snapshot:o}})).toString("base64url")}function b(e){return new p(e,m.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]})}function Bt(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===Q&&typeof t.fingerprint=="string"&&typeof t.after_id=="string"&&t.after_id.length>0&&(t.after_index===void 0||Number.isSafeInteger(t.after_index)&&t.after_index>=0)&&(t.snapshot===void 0||typeof t.snapshot=="string"&&t.snapshot.length>0)}function H(e){if(typeof e!="string")throw b("Query cursor is malformed.");let t=e.trim();if(t.length===0||t.length>ke||!Ft.test(t))throw b("Query cursor is malformed.");let n;try{n=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw b("Query cursor is malformed.")}if(!Bt(n))throw b("Query cursor version or payload is unsupported.");return n}function Z(e,t){let n=H(e);if(n.fingerprint!==t)throw b(`Query cursor does not match the current filters, sort, or query (${n.fingerprint} != ${t}).`);return{after_id:n.after_id,...n.after_index===void 0?{}:{after_index:n.after_index},...n.snapshot===void 0?{}:{snapshot:n.snapshot}}}function $o(e,t){return Z(e,t).after_id}function Gt(e,t,n,o){if(t===void 0)return 0;let r=Z(t,n),s=e.findIndex(a=>o(a)===r.after_id);if(s<0){if(r.after_index!==void 0)return Math.min(r.after_index,e.length);throw b(`Query cursor item ${r.after_id} is no longer present in this result set.`)}return s+1}function Xo(e,t){if(t.cursor!==void 0&&Z(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw b("Query cursor does not match the requested snapshot.");let n=Gt(e,t.cursor,t.fingerprint,t.readId),o=e.slice(n,n+t.limit),r=o.length>0&&n+o.length<e.length,s=o.at(-1);return{rows:o,has_more:r,...r&&s!==void 0?{next_cursor:J(t.fingerprint,t.readId(s),n+o.length-1,t.snapshot)}:{}}}var Yo=Object.freeze({version:Q,max_length:ke});(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]="b3c001df-9891-5cf7-990b-8d9da7b51801")}catch{}})();var S=["include","amount","cost","encoding"],Me=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","files","docs","stats","aggregate","package-catalog","package-manage","comments-audit","assurance"],Ue=["canonical","legacy","intent","default"],oe={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},or=Object.freeze(S.map(e=>oe[e])),rr=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),Le={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],cost:["--token-budget"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Pe=new Set(["--collapse","--fields","--section"]),re=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function se(e){return e.slice(2).replaceAll("-","_")}function Kt(e,t){let n=re[e];if(n!==void 0)return n;let o=t==="include"?Pe.has(e)?"<csv>":se(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${oe[t]} ${o}.`}function zt(e){let t=Le[e],n=Object.freeze(Object.fromEntries(S.map(o=>[o,Object.freeze({dimension:o,canonical_option:oe[o],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[o]??[]).map(r=>Object.freeze({flag:r,semantics:re[r]===void 0?"replacement":"behavior_preserving",migration_hint:Kt(r,o),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:Ue,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix"})}var $t=Object.freeze(Me.map(zt)),Xt=new Map($t.map(e=>[e.command,e]));function x(e,t={}){let n=e.trim().toLowerCase().replaceAll(/\s+/gu," "),r=n==="package catalog"||n==="packages catalog"||n==="package-catalog"||(n==="package"||n==="packages"||n==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":n==="package manage"||n==="package-manage"?"package-manage":n.split(" ")[0],s=r.startsWith("list-")?"list":r==="ctx"?"context":r;return Me.includes(s)?s:void 0}var Yt=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],qt={comments:["add","body","stdin","file","edit","delete"],notes:["add","addJson","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function Wt(e){return Yt.some(t=>e[t]!==void 0)}var Qt=[{keys:["outputInclude","output_include"],valid:e=>F(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||w(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||w(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputFormat","output_format"],valid:e=>e==="toon"||e==="json",message:"--output-format must be toon or json."},{keys:["outputSession","output_session"],valid:e=>(P(e),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:e=>typeof e=="string"&&e.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}];function sr(e,t){if(!Wt(t))return;let n=x(e,t);if(!n)throw new p(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,m.USAGE);if((qt[n]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new p(`Universal output controls cannot be combined with a ${n} mutation.`,m.USAGE);for(let o of Qt){let r=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(r!==void 0&&!o.valid(r))throw new p(o.message,m.USAGE)}}function je(e){let t=x(e);return t?new Map((Le[t].include??[]).filter(n=>!Pe.has(n)&&re[n]===void 0).map(n=>[se(n),Ve(n)])):new Map}function Jt(e,t,n){let o=F(t)??[],r=je(e),s=[],a=[];for(let i of o){let d=r.get(i);if(d===void 0){s.push(i);continue}n[d]=!0,a.push(i)}return{selectors:s,modes:a}}function ir(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:o,modes:r}=Jt(e,n,t);if(r.length===0)return;let s=o.length>0?o.join(","):void 0;t.outputInclude=s,Object.hasOwn(t,"output_include")&&(t.output_include=s)}function Ve(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function Ht(e,t){let n=Ve(t);if(Object.hasOwn(e,n))return e[n];let o=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,o))return e[o];if(t==="--no-truncate"&&e.truncate===!1)return!0}function Zt(e){return e!==void 0&&e!==!1&&e!==null}function F(e){let n=(Array.isArray(e)?e:[e]).flatMap(o=>typeof o=="string"?o.split(","):[]).map(o=>o.trim()).filter(Boolean);return n.length>0?[...new Set(n)]:void 0}function w(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function en(e,t,n){for(let o of e.legacy_aliases){let r=Ht(t,o.flag),s={value:r,flag:o.flag};if(Zt(r)&&n(s))return s}}function xe(e,t){let n=F(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:F(t.value)??[se(t.flag)]}}function Re(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=w(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let o=w(t.value);return o===void 0?void 0:{source:"legacy",value:o}}function Ne(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=w(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let o=w(t.value);return o===void 0?void 0:{source:"legacy",value:o}}function Ie(e,t){if(e==="json"||e==="toon")return{source:"canonical",value:e};if(t)return t.flag==="--stream"||t.flag==="--follow"?{source:"legacy",value:"stream"}:t.value==="json"||t.value==="toon"?{source:"legacy",value:t.value}:void 0}function Fe(e,t){let n=x(e,t);if(!n)return;let o=Xt.get(n),r={include:f=>xe(void 0,f),amount:f=>Re(void 0,f),cost:f=>Ne(void 0,f),encoding:f=>Ie(void 0,f)},s=Object.fromEntries(S.map(f=>[f,en(o.dimensions[f],t,g=>r[f](g)!==void 0)])),a=S.flatMap(f=>{let g=s[f];return g?[g.flag]:[]}),i=S.flatMap(f=>{let g=s[f];return g?[o.dimensions[f].legacy_aliases.find(Ke=>Ke.flag===g.flag).migration_hint]:[]}),d=Ie(t.outputFormat??t.output_format,s.encoding),u=Ne(t.outputBudget??t.output_budget,s.cost),l=e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||s.amount?.flag==="--no-truncate"||s.include?.flag==="--full",c=Ae(e,{generateFallback:!0}),_=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon";return{command:n,include:xe(t.outputInclude??t.output_include,s.include),amount:Re(t.outputLimit??t.output_limit,s.amount),cost:u??(l?{source:"intent",value:"unbounded"}:{source:"default",value:c.default_max_estimated_tokens_by_format[_]}),encoding:d,legacy_aliases_used:a,migration_hints:i,precedence:Ue}}function y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var ie=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),tn=["collection_counts","notes_count","tests_count"];function Be(e,t){let n=new Set(t.map(o=>o.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([o])=>n.has(o)))}function nn(e){let t=y(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...tn.filter(r=>Object.hasOwn(t,r))])].sort((r,s)=>r.localeCompare(s)),o=Object.keys(e).filter(r=>r!=="item"&&r!=="read_output"&&!ie.has(r)).sort((r,s)=>r.localeCompare(s));return{item:t,itemFields:n,sections:o,valid:[...n,"item",...n.map(r=>`item.${r}`),...o]}}function on(e,t){let n=nn(e),o=t.filter(c=>!n.valid.includes(c));if(o.length>0)throw new p(`Unknown --output-include selector(s) for get: ${o.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,m.USAGE);let r=t.includes("item"),s=t.flatMap(c=>c.startsWith("item.")?[c.slice(5)]:n.itemFields.includes(c)?[c]:[]).filter((c,_,f)=>f.indexOf(c)===_);if(r&&s.length>0)throw new p("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",m.USAGE);let a=new Set(t.filter(c=>n.sections.includes(c))),i=Object.fromEntries(Object.entries(e).filter(([c])=>ie.has(c)||a.has(c)));r?i.item=n.item:s.length>0&&(i.item=Be(n.item,s));let d=[...r?[]:s.length>0?n.itemFields.filter(c=>!s.includes(c)).map(c=>({name:`item.${c}`,restore_with:`--output-include item.${c}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(c=>!a.has(c)).map(c=>({name:c,restore_with:`--output-include ${c}`}))],l=[...y(i.omission_receipt)&&Array.isArray(i.omission_receipt.omitted_field_groups)?i.omission_receipt.omitted_field_groups:[],...d];return i.omission_receipt={has_omissions:l.length>0,omitted_field_group_count:l.length,omitted_field_groups:l},i}function Ce(e){let t=0;return T({...e},n=>(y(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function rn(e,t,n,o){if(Ce(t)===0||Ce(n)>0)return;let r=[...je(e).keys()],s=r.length>0?` Declared ${e} projection modes: ${r.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new p(`Unknown --output-include selector(s) for ${e}: ${o.join(", ")}. No selector matched any returned row field.${s}`,m.USAGE)}function sn(e,t,n){if(e==="get")return on(t,n);let o=v(t),r=n.flatMap(a=>o.flatMap(i=>a.startsWith(`${i}.`)?[a.slice(i.length+1)]:[])),s=n.some(a=>Object.hasOwn(t,a.split(".")[0])&&!o.some(i=>a.startsWith(`${i}.`)));if(o.length>0&&(!s||r.length>0)){let a={...t},i=r.length>0?r:n,d=T(a,u=>y(u)?Be(u,i):u);return rn(e,t,d,i),d}return Object.fromEntries(Object.entries(t).filter(([a])=>n.some(i=>i.split(".")[0]===a)||ie.has(a)))}function an(e,t){if(t==="unbounded")return e;let{result:n,truncated:o}=ye(e,t);return o&&(n.has_more=!0,n.truncated=!0,typeof n.count=="number"&&(n.count=M(n)),n.applied_bound={kind:"output_limit",source:"explicit",value:t}),n}function cn(e){return S.filter(t=>e[t]!==void 0&&e[t]?.source!=="default")}function B(e,t,n){let o=Y(e,t);for(let r=0;r<8;r+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;h(o,n),o=Y(o,t);let i=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&i===a)return o}return o}function ar(e,t){if(!y(e.read_output))return e;let n=e.read_output,o=P(t.outputSession??t.output_session);return o===void 0?(h(e,n),e):B(e,o,n)}function un(e,t){if(e!=="validate")return t;let n=y(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(c=>y(c)&&c.name==="diagnostic_rows"))return t;let r=[...new Set(D(t).map(({path:c})=>c).filter(c=>/^checks\.\d+\.details\./u.test(c)))],s=r.filter(c=>!r.some(_=>_!==c&&c.startsWith(`${_}.`)));if(s.length===0)return t;let a=y(t.row_contract)?t.row_contract:{},i=Array.isArray(a.row_keys)?a.row_keys.filter(c=>typeof c=="string"):[],d=Array.isArray(a.continuation_row_keys)?a.continuation_row_keys.filter(c=>typeof c=="string"):[],u=i.length>0?i:s,l=[...new Set(s)];return JSON.stringify(u)===JSON.stringify(i)&&JSON.stringify(l)===JSON.stringify(d)?t:{...t,row_contract:{...a,row_keys:u,continuation_row_keys:l,jq_selector:typeof a.jq_selector=="string"?a.jq_selector:".checks[].details"}}}function dn(e,t,n,o){let r={...e};return t.include?.source==="canonical"&&(r=sn(t.command,r,t.include.value)),t.command==="assurance"&&(r=ve(r)),r=De(r,t.command,o),t.amount?.source==="canonical"&&(r=an(r,t.amount.value)),n===void 0?r:be(r,n)}function ln(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:Ee(t)}]].sort((o,r)=>o.tokens-r.tokens)[0]}function fn(e,t,n,o,r){let s={contract_version:1,command:e.command,requested_dimensions:t,...o.source==="default"?{budget_source:o.source,budget_tokens:o.tokens}:{},precedence:e.precedence,legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:r}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},i=n===void 0?a:B(a,n,s);if(n===void 0&&h(i,s),n!==void 0&&s.estimated_tokens>o.tokens)throw new p("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",m.USAGE);return i}function _n(e,t,n,o){if(n!==void 0)return!1;let r=t.filter(s=>e[s]?.source==="canonical").length;return e.cost?.value==="unbounded"?r===(e.cost.source==="canonical"?1:0):e.cost?.source==="legacy"&&r===0?!0:r===0&&(e.cost===void 0||W(o)<=e.cost.value)}function pn(e,t,n,o,r,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],i=new Map(A(e).map(l=>[l.path,Array.isArray(l.value)?l.value.length:Object.keys(l.value).length])),d=[...s.entries()].flatMap(([l,c])=>{let _=i.get(l);if(_>=c.rows)return[];let f=c.baseOffset+_;return[{path:l,cursor:te({command:t.command,path:l,offset:f,total_rows:c.totalRows,fingerprint:c.fingerprint}),retained_rows:_,remaining_rows:c.totalRows-f,total_rows:c.totalRows}]}),u=d[0];u&&typeof e.next_cursor!="string"&&(e.next_cursor=u.cursor),e.continuation_kind=r?"producer_cursor":u?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:o.source,budget_tokens:o.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:r,continuation_available:d.length>0,recovery_budget_multiplier:1,continuations:d,restore_with:u?"Use recovery binding.":"Increase --output-budget because no declared row collection can be continued.",recovery:u?{cursor:u.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:"--output-budget 1200",sdk:{outputBudget:1200},mcp:{outputBudget:1200}}}}function mn(e,t,n,o){if(typeof n!="string"||!Array.isArray(e.items))return!1;let r=e.items.length;if(r===0||r>=t)return!1;let s;try{s=H(n)}catch{return!1}let a=s.after_index;if(a===void 0)return!1;let i=e.items.at(-1);if(Object.prototype.toString.call(i)!=="[object Object]")return!1;let d=Reflect.get(i,"id");if(typeof d!="string"||d.length===0)return!1;let u=o?a-(t-r):a+r;return u<0?!1:(e.next_cursor=J(s.fingerprint,d,u,s.snapshot),typeof e.applied_limit=="number"&&(e.applied_limit=r),!0)}function gn(e,t,n){let o=new Map(A(e).map(s=>{let a=Array.isArray(s.value)?s.value.length:Object.keys(s.value).length,i=t?.path===s.path;return[s.path,{rows:a,totalRows:i?t.total_rows:a,baseOffset:i?t.offset:0,fingerprint:i?t.fingerprint:ee(s.path,s.value)}]})),r=typeof e.next_cursor=="string";return{collectionsBeforeBudget:o,originalItemCount:Array.isArray(e.items)?e.items.length:0,cursorContinuesExistingPage:r,cursorSource:r?e.next_cursor:n.after}}function yn(e,t,n,o,r,s){let a=t.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(u=>y(u)&&u.verdict!=="pass").length:0,i=we(e,n,o.tokens,a>0?new Map([["assertions",a]]):new Map),d=mn(i,s.originalItemCount,s.cursorSource,s.cursorContinuesExistingPage);return pn(i,t,n,o,d,s.collectionsBeforeBudget),r!==void 0&&(i=B(i,r,n)),i}function cr(e,t,n){let o=Fe(e,t);if(!o)return n;let r=P(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?ne(s):void 0,i=cn(o);if(a===void 0&&_n(o,i,r,n))return n;let d=un(o.command,n),u=ln(o,r),l=dn(d,o,r,a),c=gn(l,a,t),_={contract_version:1,command:o.command,requested_dimensions:i,...u?.source==="default"?{budget_source:u.source,budget_tokens:u.tokens}:{},precedence:o.precedence,legacy_aliases_used:o.legacy_aliases_used,migration_hints:o.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};return l.read_output=_,l=r===void 0?l:B(l,r,_),h(l,_),u!==void 0&&_.estimated_tokens>u.tokens&&(l=yn(l,o,_,u,r,c)),u!==void 0&&_.estimated_tokens>u.tokens?fn(o,i,r,u,_.estimated_tokens):l}function ur(e){return y(e)&&y(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function dr(e,t){let n=Fe(e,t)?.encoding;return n?.value==="json"||n?.value==="toon"?n.value:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1c73c31e-6246-5730-8c8a-d3ba7c9ec112")}catch{}})();var bn=4096;function Ge(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ee(e,t){return hn("sha256").update(V({path:e,value:t})).digest("base64url").slice(0,16)}function te(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function ne(e){if(e.length>bn)throw new p("The read-output continuation cursor is malformed or unsupported.",m.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!Ge(t)||t.v!==1||x(String(t.c??""))!==t.c||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new p("The read-output continuation cursor is malformed or unsupported.",m.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function ve(e){if(!Array.isArray(e.assertions))return e;let t=n=>!Ge(n)||n.verdict==="pass"?4:n.verdict==="retired"?3:n.enforcement==="block"?0:n.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((n,o)=>({row:n,index:o})).sort((n,o)=>t(n.row)-t(o.row)||n.index-o.index).map(({row:n})=>n),budget_retention_policy:"verdict_priority"}}function De(e,t,n){if(!n)return e;if(n.command!==t)throw new p(`The read-output cursor belongs to ${n.command}, not ${t}.`,m.USAGE,{code:"read_output_cursor_command_mismatch"});let o=A(e).find(s=>s.path===n.path),r=o?Array.isArray(o.value)?o.value.length:Object.keys(o.value).length:0;if(!o||r!==n.total_rows||n.offset>r||ee(n.path,o.value)!==n.fingerprint)throw new p("The read-output continuation no longer matches the declared row collection; restart the bounded read.",m.USAGE,{code:"read_output_cursor_stale"});return ge(e,n.path,n.offset)}(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]="f6e82c93-54e8-53a7-94df-10a573aae933")}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]="08ee7e43-8811-57ed-8bfe-0345ee5d3308")}catch{}})();var En=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields"},{flag:"--output-limit",value_name:"count"},{flag:"--output-budget",value_name:"tokens"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state"},{flag:"--output-cursor",value_name:"cursor"},{flag:"--output-row-contract"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"]},{flag:"--no-extensions"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"}]),Ar=new Set(En.flatMap(e=>[e.flag,...e.aliases??[]]));export{G as a,ze as b,$e as c,On as d,ae as e,ce as f,ue as g,An as h,de as i,le as j,fe as k,Xe as l,wn as m,Tn as n,kn as o,xn as p,Rn as q,Nn as r,In as s,Cn as t,vn as u,Dn as v,Mn as w,Un as x,Ln as y,Pn as z,jn as A,Vn as B,Fn as C,Ye as D,Bn as E,Gn as F,Kn as G,zn as H,$n as I,Xn as J,Yn as K,qe as L,We as M,Qn as N,Jn as O,Qe as P,Hn as Q,Zn as R,eo as S,Ze as T,et as U,K as V,to as W,no as X,m as Y,p as Z,En as _,Ar as $,V as aa,k as ba,Mo as ca,Uo as da,N as ea,io as fa,ao as ga,co as ha,tt as ia,nt as ja,ot as ka,_o as la,po as ma,rt as na,I as oa,mo as pa,st as qa,pe as ra,C as sa,it as ta,go as ua,yo as va,ho as wa,bo as xa,Eo as ya,Oo as za,Ao as Aa,X as Ba,P as Ca,be as Da,Y as Ea,Ee as Fa,pt as Ga,Io as Ha,Ot as Ia,Oe as Ja,At as Ka,St as La,Ae as Ma,Co as Na,te as Oa,ne as Pa,Ko as Qa,zo as Ra,J as Sa,H as Ta,Z as Ua,$o as Va,Gt as Wa,Xo as Xa,Yo as Ya,S as Za,Me as _a,or as $a,rr as ab,$t as bb,x as cb,sr as db,je as eb,Jt as fb,ir as gb,Fe as hb,ar as ib,cr as jb,ur as kb,dr as lb};
2
+ //# sourceMappingURL=chunk-RZU5U6Q7.js.map
@@ -1,2 +1,2 @@
1
- import{ka as I,la as b}from"./chunk-ZT2DJS27.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="de8a82e1-0b02-5d5a-9086-686529a1ccab")}catch{}})();var v="blocked_by",D="blocks",T=Object.freeze([v,D]),y="no-active-blocker";function l(e){return e.trim().toLowerCase()}function p(e){let n=new Set,t=typeof e.blocked_by=="string"?l(e.blocked_by):"";t.length>0&&t!==y&&n.add(t);for(let o of e.dependencies??[]){let c=typeof o.id=="string"?l(o.id):"";o.kind===v&&c.length>0&&c!==y&&n.add(c)}return[...n].sort((o,c)=>o.localeCompare(c))}function k(e){let n=new Map;for(let t of e){let o=l(t.id);o.length!==0&&n.set(o,new Set(p(t)))}for(let t of e){let o=l(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=c.kind===D&&typeof c.id=="string"?l(c.id):"";if(s.length===0||s===y)continue;let d=n.get(s)??new Set;d.add(o),n.set(s,d)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function S(e,n){let t=l(e.id);return t.length>0?k(n).get(t)??p(e):p(e)}function B(e,n,t,o){let c=e;return(typeof c.id=="string"?o?.get(l(c.id))??S(c,[...n.values()]):p(e)).map(d=>{let r=n.get(l(d));return r?{id:d,title:r.title,status:r.status,resolved:b(r.status,t)}:{id:d,title:null,status:null,resolved:!1}})}function O(e,n,t){return B(e,n,t)}function K(e,n){let t=new Map(e.map(d=>[l(d.id),d])),o=k(e),c=new Set([...C(n),...n.blocked_statuses]),s=new Set;for(let d of e){let r=I(d.status,n);if(!c.has(r))continue;(n.blocked_statuses.has(r)||B(d,t,n,o).some(f=>!f.resolved))&&s.add(l(d.id))}return s}function C(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function A(e,n,t){let o=[l(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let d of n.get(s)??[]){if(!b(d.status,t))return!0;o.push(l(d.id))}}}return!1}function L(e){let n=new Map,t=new Map,o=new Map,c=k(e);for(let s of e){n.set(l(s.id),s);let d=typeof s.parent=="string"?s.parent.trim():"";if(d.length>0){let r=l(d),a=t.get(r)??[];a.push(s),t.set(r,a)}for(let r of c.get(l(s.id))){let a=l(r),f=o.get(a)??[];f.push(s.id),o.set(a,f)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function M(e,n,t){let{itemsById:o,childrenByParent:c,blockedByReverse:s,blockerIdsByItem:d}=L(n),r=new Set([...C(t),...t.blocked_statuses]),a=new Set(n.filter(i=>!b(i.status,t)).map(i=>l(i.id))),f=[],h=[],m=0,_=0;for(let i of e){if(!r.has(I(i.status,t)))continue;if(m+=1,A(i.id,c,t)){_+=1;continue}let g=B(i,o,t,d).filter(u=>!u.resolved),E=(s.get(l(i.id))??[]).filter(u=>a.has(l(u))).sort((u,x)=>u.localeCompare(x)),w={item:i,open_blockers:g,unblocks:E},N=t.blocked_statuses.has(I(i.status,t));g.length===0&&!N?f.push(w):h.push(w)}return{ready:f,blocked:h,active_count:m,container_count:_}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cc271a73-9767-54bb-a142-d4d4569e3c6a")}catch{}})();export{T as a,p as b,k as c,S as d,O as e,K as f,M as g};
2
- //# sourceMappingURL=chunk-ATEY76SX.js.map
1
+ import{ka as I,la as b}from"./chunk-34QBIYZI.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="de8a82e1-0b02-5d5a-9086-686529a1ccab")}catch{}})();var v="blocked_by",D="blocks",T=Object.freeze([v,D]),y="no-active-blocker";function l(e){return e.trim().toLowerCase()}function p(e){let n=new Set,t=typeof e.blocked_by=="string"?l(e.blocked_by):"";t.length>0&&t!==y&&n.add(t);for(let o of e.dependencies??[]){let c=typeof o.id=="string"?l(o.id):"";o.kind===v&&c.length>0&&c!==y&&n.add(c)}return[...n].sort((o,c)=>o.localeCompare(c))}function k(e){let n=new Map;for(let t of e){let o=l(t.id);o.length!==0&&n.set(o,new Set(p(t)))}for(let t of e){let o=l(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=c.kind===D&&typeof c.id=="string"?l(c.id):"";if(s.length===0||s===y)continue;let d=n.get(s)??new Set;d.add(o),n.set(s,d)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function S(e,n){let t=l(e.id);return t.length>0?k(n).get(t)??p(e):p(e)}function B(e,n,t,o){let c=e;return(typeof c.id=="string"?o?.get(l(c.id))??S(c,[...n.values()]):p(e)).map(d=>{let r=n.get(l(d));return r?{id:d,title:r.title,status:r.status,resolved:b(r.status,t)}:{id:d,title:null,status:null,resolved:!1}})}function O(e,n,t){return B(e,n,t)}function K(e,n){let t=new Map(e.map(d=>[l(d.id),d])),o=k(e),c=new Set([...C(n),...n.blocked_statuses]),s=new Set;for(let d of e){let r=I(d.status,n);if(!c.has(r))continue;(n.blocked_statuses.has(r)||B(d,t,n,o).some(f=>!f.resolved))&&s.add(l(d.id))}return s}function C(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function A(e,n,t){let o=[l(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let d of n.get(s)??[]){if(!b(d.status,t))return!0;o.push(l(d.id))}}}return!1}function L(e){let n=new Map,t=new Map,o=new Map,c=k(e);for(let s of e){n.set(l(s.id),s);let d=typeof s.parent=="string"?s.parent.trim():"";if(d.length>0){let r=l(d),a=t.get(r)??[];a.push(s),t.set(r,a)}for(let r of c.get(l(s.id))){let a=l(r),f=o.get(a)??[];f.push(s.id),o.set(a,f)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function M(e,n,t){let{itemsById:o,childrenByParent:c,blockedByReverse:s,blockerIdsByItem:d}=L(n),r=new Set([...C(t),...t.blocked_statuses]),a=new Set(n.filter(i=>!b(i.status,t)).map(i=>l(i.id))),f=[],h=[],m=0,_=0;for(let i of e){if(!r.has(I(i.status,t)))continue;if(m+=1,A(i.id,c,t)){_+=1;continue}let g=B(i,o,t,d).filter(u=>!u.resolved),E=(s.get(l(i.id))??[]).filter(u=>a.has(l(u))).sort((u,x)=>u.localeCompare(x)),w={item:i,open_blockers:g,unblocks:E},N=t.blocked_statuses.has(I(i.status,t));g.length===0&&!N?f.push(w):h.push(w)}return{ready:f,blocked:h,active_count:m,container_count:_}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cc271a73-9767-54bb-a142-d4d4569e3c6a")}catch{}})();export{T as a,p as b,k as c,S as d,O as e,K as f,M as g};
2
+ //# sourceMappingURL=chunk-US7VEYZG.js.map
@@ -0,0 +1,26 @@
1
+ import{f as w,i as f,j as B,k as j,l as U,o as y,p as X,q as W,r as Y}from"./chunk-EXBCLIBU.js";import{C as H,a as P,b as D}from"./chunk-MCZXYZAF.js";import{c as u,f as M,g as z,i as q}from"./chunk-ESISGDAY.js";import{Ta as F,q as L,t as R}from"./chunk-L623ZPNK.js";import{Ka as g,Ma as K,Z as k}from"./chunk-JDOMQ7VQ.js";import{a as N,e as x,f as O,g as A,i as C,l as $}from"./chunk-RZU5U6Q7.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bb16b445-3bd4-520d-becf-c55621bfa186")}catch{}})();var Ce=N,$e=x,Pe=C,De=O,Le=A;function G(e,t,n,s){let r=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),o=n.has(r);return{long:t,...s?{short:s}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:o?"string":"boolean",...o?{value_name:e.value_name??"value"}:{}}}function Q(e,t=[]){let n=new Set(t.flatMap(r=>r.keys)),s=[];for(let r of L(e.map(o=>({...o})))){s.push(G(r,r.flag,n,r.short));for(let o of r.aliases??[])s.push(G(r,o,n))}return s}var Re=Q(R,P),Fe=Q(F,D);(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]="bed1d1d4-0c1d-59e5-8267-fbe800dfd83b")}catch{}})();var _=["agile","ops","research"],I={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:w.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
2
+
3
+ ## I want
4
+
5
+ ## So that
6
+
7
+ ## Acceptance
8
+ - [ ]
9
+ `}}],packages:[{spec:"templates",reason:"Reusable create templates for recurring story shapes."},{spec:"calendar",reason:"Sprint and iteration scheduling views."},{spec:"search-advanced",reason:"Richer retrieval as the backlog grows."}]},ops:{name:"ops",title:"Operations",summary:"Incident/Runbook response with mitigation and monitoring stages, severity, and service fields.",types:w.ops,statuses:[{id:"mitigating",roles:["active"],aliases:["mitigation"],description:"Active mitigation is underway to restore service."},{id:"monitoring",roles:["active"],aliases:["observing"],description:"Mitigation applied; monitoring for recurrence before closure."}],fields:[{key:"severity",type:"string",commands:["create","update","list"],description:"Incident severity classification (e.g. sev1, sev2, sev3).",aliases:["sev"]},{key:"service",type:"string",commands:["create","update","list"],description:"Primary affected service or component."}],workflows:[{type:"Incident",allowed_transitions:[["open","mitigating"],["mitigating","monitoring"],["monitoring","mitigating"],["monitoring","closed"],["mitigating","blocked"],["blocked","mitigating"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search for fast incident lookup."},{key:"search_max_results",value:"25",summary:"Wider result cap to surface related incidents and runbooks."}],templates:[{name:"incident",options:{type:"Incident",priority:"1",tags:"incident",acceptanceCriteria:"Service restored, root cause documented, and follow-ups filed.",body:`## Impact
10
+
11
+ ## Timeline
12
+
13
+ ## Root cause
14
+
15
+ ## Mitigation
16
+
17
+ ## Follow-ups
18
+ `}}],packages:[{spec:"lifecycle-hooks",reason:"Automate transitions and notifications on incident state changes."},{spec:"governance-audit",reason:"Audit incident metadata completeness and closure quality."},{spec:"calendar",reason:"On-call and follow-up scheduling."}]},research:{name:"research",title:"Research",summary:"Experiment/Hypothesis investigation with an analysis stage, hypothesis, and method fields.",types:w.research,statuses:[{id:"analyzing",roles:["active"],aliases:["analysis"],description:"Data collected; analysis and synthesis in progress."}],fields:[{key:"hypothesis",type:"string",commands:["create","update"],description:"The testable claim the experiment evaluates."},{key:"method",type:"string",commands:["create","update","list"],description:"Experimental method or protocol used to evaluate the hypothesis.",aliases:["protocol"]}],workflows:[{type:"Experiment",allowed_transitions:[["open","in_progress"],["in_progress","analyzing"],["analyzing","in_progress"],["analyzing","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search across the research corpus."},{key:"search_max_results",value:"50",summary:"Broader recall cap for literature and prior-experiment discovery."}],templates:[{name:"experiment",options:{type:"Experiment",priority:"2",tags:"experiment",acceptanceCriteria:"Hypothesis is supported, rejected, or refined with recorded evidence.",body:`## Hypothesis
19
+
20
+ ## Method
21
+
22
+ ## Results
23
+
24
+ ## Conclusion
25
+ `}}],packages:[{spec:"search-advanced",reason:"Semantic retrieval over experiments and findings."},{spec:"templates",reason:"Consistent experiment and hypothesis scaffolds."},{spec:"beads",reason:"Import structured prior work into the tracker."}]}};function ne(e){if(e===void 0)return;let t=p(e);if(t.length===0)throw new Error("Profile name must not be empty.");if(_.includes(t))return t;throw new Error(`Invalid profile "${e}". Allowed: ${_.join(", ")}.`)}function qe(e){let t=ne(e);if(t===void 0)throw new Error(`Profile name is required. Allowed: ${_.join(", ")}.`);return I[t]}function Be(){return _.map(e=>I[e])}function p(e){return e.trim().toLowerCase().replaceAll("-","_")}function J(e){return e.map(t=>t.definition.name).join(", ")}function se(e=[]){let t=_.map(o=>({definition:I[o],source:"builtin"})),n=new Set(_.map(o=>p(o))),s=new Set(n),r=[];for(let o of e){let i=p(o.profile.name);if(n.has(i)){r.push(`Extension "${o.name}" profile "${o.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(s.has(i)){r.push(`Profile "${o.profile.name}" from extension "${o.name}" duplicates an already-registered profile and was ignored.`);continue}s.add(i),t.push({definition:o.profile,source:"extension",package:o.name})}return{profiles:t,warnings:r}}function je(e,t=[]){let{profiles:n,warnings:s}=se(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${J(n)}.`);let r=p(e),o=n.find(i=>p(i.definition.name)===r);if(o===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${J(n)}.`);return{resolved:o,warnings:s}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="933d8f74-c4aa-58d0-bd3b-8932a35d3702")}catch{}})();function re(e){return{types:e.types.length,statuses:e.statuses.length,fields:e.fields.length,workflows:e.workflows.length,config:e.config.length,templates:e.templates.length,packages:e.packages.length}}function Ye(e){return{name:e.name,title:e.title,summary:e.summary,composition:re(e),types:e.types.map(t=>S(()=>u(t).name,()=>String(t.name??""))),statuses:e.statuses.map(t=>S(()=>y(t).id,()=>String(t.id??""))),fields:e.fields.map(t=>S(()=>f(t).key,()=>String(t.key??""))),workflows:e.workflows.map(t=>t.type),config:e.config.map(t=>`${t.key}=${t.value}`),templates:e.templates.map(t=>t.name),packages:e.packages.map(t=>({spec:t.spec,reason:t.reason}))}}function S(e,t){try{return e()}catch{return 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]="be95f220-5f66-5e8c-8447-996696d02e43")}catch{}})();var oe=[{key:"search_provider",path:"search.provider",kind:"string",summary:"Search embedding provider name (e.g. openai, ollama, or an extension provider)."},{key:"search_mutation_refresh_policy",path:"search.mutation_refresh_policy",kind:"string",choices:["cache_only","semantic_configured","semantic_auto"],summary:"Mutation-time search refresh policy: cache_only, semantic_configured, or semantic_auto."},{key:"search_query_expansion_enabled",path:"search.query_expansion.enabled",kind:"boolean",summary:"Enable or disable query expansion for semantic/hybrid search."},{key:"search_query_expansion_provider",path:"search.query_expansion.provider",kind:"string",summary:"Query expansion provider name (built-in openai/ollama or extension provider)."},{key:"search_rerank_enabled",path:"search.rerank.enabled",kind:"boolean",summary:"Enable or disable post-retrieval reranking for hybrid search."},{key:"search_rerank_model",path:"search.rerank.model",kind:"string",summary:"Rerank model name override used by built-in providers."},{key:"search_rerank_top_k",path:"search.rerank.top_k",kind:"integer",min:1,summary:"Number of top hybrid candidates to rerank when rerank is enabled."},{key:"search_embedding_model",path:"search.embedding_model",kind:"string",summary:"Default embedding model name (overrides provider-specific model when set)."},{key:"search_embedding_corpus_max_characters",path:"search.embedding_corpus_max_characters",kind:"integer",min:1,summary:"Maximum semantic corpus characters per item before truncation."},{key:"search_embedding_batch_size",path:"search.embedding_batch_size",kind:"integer",min:1,summary:"Number of items embedded per request batch."},{key:"search_embedding_timeout_ms",path:"search.embedding_timeout_ms",kind:"integer",min:1,summary:"Per-request embedding timeout in milliseconds."},{key:"search_score_threshold",path:"search.score_threshold",kind:"number",summary:"Minimum score for a hit to be returned (0 keeps all matches)."},{key:"search_hybrid_semantic_weight",path:"search.hybrid_semantic_weight",kind:"ratio",summary:"Hybrid mode semantic weight in [0, 1] (1-weight goes to keyword)."},{key:"search_max_results",path:"search.max_results",kind:"integer",min:1,summary:"Default upper bound on search hits when --limit is not supplied."},{key:"search_bm25_k1",path:"search.bm25.k1",kind:"number",min:0,summary:"Offline BM25 term-frequency saturation (k1); higher saturates repeated terms slower (default 1.2)."},{key:"search_bm25_b",path:"search.bm25.b",kind:"ratio",summary:"Offline BM25 document-length normalization (b) in [0, 1]; 0 disables, 1 fully normalizes (default 0.75)."},{key:"openai_base_url",path:"providers.openai.base_url",kind:"string",summary:"OpenAI-compatible API base URL (LM Studio/vLLM also use this)."},{key:"openai_api_key",path:"providers.openai.api_key",kind:"string",summary:"OpenAI-compatible API key."},{key:"openai_model",path:"providers.openai.model",kind:"string",summary:"OpenAI-compatible embedding model name."},{key:"ollama_base_url",path:"providers.ollama.base_url",kind:"string",summary:"Ollama API base URL (typically http://localhost:11434)."},{key:"ollama_model",path:"providers.ollama.model",kind:"string",summary:"Ollama embedding model name (e.g. nomic-embed-text)."},{key:"vector_store_adapter",path:"vector_store.adapter",kind:"string",summary:"Vector store adapter name (lancedb, qdrant, or an extension adapter)."},{key:"vector_store_collection_name",path:"vector_store.collection_name",kind:"string",non_empty:!0,summary:"Vector collection/table name shared by Qdrant and LanceDB adapters."},{key:"qdrant_url",path:"vector_store.qdrant.url",kind:"string",summary:"Qdrant HTTP API URL."},{key:"qdrant_api_key",path:"vector_store.qdrant.api_key",kind:"string",summary:"Qdrant API key (empty if running unauthenticated)."},{key:"lancedb_path",path:"vector_store.lancedb.path",kind:"string",summary:"LanceDB storage path (relative to pm root or absolute)."},{key:"id_prefix",path:"id_prefix",kind:"string",non_empty:!0,summary:'Prefix for generated item IDs (e.g. "pm" produces pm-xxxx).'},{key:"author_default",path:"author_default",kind:"string",non_empty:!0,summary:"Default author recorded on mutations when --author is not supplied."},{key:"mutation_guard_require_attributed_author",path:"mutation_guard.require_attributed_author",kind:"boolean",summary:"Reject mutations whose effective author resolves to unknown."},{key:"mutation_guard_secret_guard",path:"mutation_guard.secret_guard",kind:"string",choices:["off","advise","block"],summary:"Detect credential-shaped mutation content: off, advise, or block."},{key:"mutation_guard_stale_in_progress_hours",path:"mutation_guard.stale_in_progress_hours",kind:"integer",min:1,summary:"Age threshold for unclaimed in-progress work surfaced by health."},{key:"governance_duplicate_detection_mode",path:"governance.duplicate_detection_mode",kind:"string",choices:["off","advisory","strict"],summary:"Create/copy duplicate governance: off, advisory, or strict explicit-bypass enforcement."},{key:"governance_duplicate_detection_threshold",path:"governance.duplicate_detection_threshold",kind:"ratio",summary:"Minimum shared similarity score in [0, 1] for create/copy duplicate governance."},{key:"governance_duplicate_detection_limit",path:"governance.duplicate_detection_limit",kind:"integer",min:0,max:20,summary:"Maximum likely duplicates returned by create/copy governance (0-20)."},{key:"output_default_format",path:"output.default_format",kind:"string",choices:["toon","json"],summary:"Default output format for commands that support it: toon or json."},{key:"ux_deprecation_hints",path:"ux.deprecation_hints",kind:"boolean",summary:"Emit one stderr migration hint for deprecated command aliases."},{key:"locks_ttl_seconds",path:"locks.ttl_seconds",kind:"integer",min:1,summary:"Claim/lock time-to-live in seconds before a stale lock can be reclaimed."},{key:"locks_wait_ms",path:"locks.wait_ms",kind:"integer",min:0,summary:"Bounded jittered wait in milliseconds before a contended item mutation fails with lock_conflict; 0 fails fast. PM_LOCK_WAIT_MS overrides per invocation."},{key:"ids_token_length",path:"ids.token_length",kind:"integer",min:4,max:12,summary:"Random base36 token length for newly minted item ids (4-12, default 4). Raise it to shrink cross-branch id collision odds in concurrent multi-agent workflows (pm-pibw)."},{key:"checkpoints_retention_days",path:"checkpoints.retention_days",kind:"integer",min:1,summary:"Age in days above which pm gc --scope checkpoints prunes bulk-mutation rollback checkpoints."},{key:"schema_unknown_field_policy",path:"schema.unknown_field_policy",kind:"string",choices:["allow","warn","reject"],summary:"How item I/O handles metadata keys not in the field registry: allow, warn, or reject."},{key:"history_compact_policy_enabled",path:"history.compact_policy.enabled",kind:"boolean",summary:"Enable the history-compaction advisory: pm health warns on over-threshold streams."},{key:"history_compact_policy_max_entries",path:"history.compact_policy.max_entries",kind:"integer",min:1,summary:"Entry count above which a history stream is flagged (and the default pm history-compact --all-over threshold)."},{key:"history_compact_policy_trigger",path:"history.compact_policy.trigger",kind:"string",choices:["health_warn","auto"],summary:"History-compaction policy intent: health_warn (advisory only) or auto (scheduled sweeps expected)."}],ie=new Map(oe.flatMap(e=>[[e.key,e],[e.path.toLowerCase().replaceAll("-","_"),e]]));function b(e){if(typeof e!="string")return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length!==0)return ie.get(t)}function ae(e,t){let n=t.trim().toLowerCase();return n==="true"||n==="1"||n==="yes"||n==="on"?{ok:!0,parsed:{descriptor:e,value:!0}}:n==="false"||n==="0"||n==="no"||n==="off"?{ok:!0,parsed:{descriptor:e,value:!1}}:{ok:!1,error:{message:`Config set ${e.key} requires a boolean value (true|false), got "${t}"`}}}function le(e,t,n){return e.non_empty===!0&&n.length===0?{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}}:e.choices&&!e.choices.includes(n)?{ok:!1,error:{message:`Config set ${e.key} must be one of ${e.choices.join("|")}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function de(e,t,n){if(n.length===0)return{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}};let s=Number(n);return Number.isFinite(s)?{ok:!0,value:s}:{ok:!1,error:{message:`Config set ${e.key} requires a finite number, got "${t}"`}}}function ce(e,t,n){return!Number.isInteger(n)||n<0?{ok:!1,error:{message:`Config set ${e.key} requires a non-negative integer, got "${t}"`}}:e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires an integer >= ${e.min}, got "${t}" (the runtime silently ignores 0 here and falls back to the default)`}}:e.max!==void 0&&n>e.max?{ok:!1,error:{message:`Config set ${e.key} requires an integer <= ${e.max}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function me(e,t,n){return n<0||n>1?{ok:!1,error:{message:`Config set ${e.key} requires a number in [0, 1], got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function pe(e,t,n){return e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires a number >= ${e.min}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function v(e,t){if(typeof t!="string")return{ok:!1,error:{message:`Config set ${e.key} requires a string value`}};let n=t.trim();if(e.kind==="boolean")return ae(e,t);if(e.kind==="string")return le(e,t,n);let s=de(e,t,n);return s.ok?e.kind==="integer"?ce(e,t,s.value):e.kind==="ratio"?me(e,t,s.value):pe(e,t,s.value):{ok:!1,error:s.error}}function V(e,t){let n=t.path.split("."),s=e;for(let r of n){if(typeof s!="object"||s===null)return null;s=s[r]}return typeof s=="string"||typeof s=="number"||typeof s=="boolean"?s:null}function Ge(e,t,n){let s=t.path.split("."),r=e;for(let a=0;a<s.length-1;a+=1){let c=s[a],d=r[c];if(typeof d!="object"||d===null||Array.isArray(d)){let l={};r[c]=l,r=l}else r=d}let o=s[s.length-1];return r[o]===n?!1:(r[o]=n,!0)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f9b22df0-7ec2-5d72-bc88-3eb7201a6051")}catch{}})();var at=["profile","types","statuses","fields","workflows","config","templates","packages"],lt=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],ue=new Set(K.flatMap(e=>[g(e.id),...(e.aliases??[]).map(t=>g(t))]).filter(e=>e.length>0)),Z=new Set($.map(e=>e.toLowerCase()));function fe(e,t){e.name.trim().length===0?t.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):e.name!==p(e.name)&&t.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:e.name,message:`Profile name "${e.name}" is not in canonical form; resolution folds it to "${p(e.name)}" (lowercase, hyphens as underscores).`}),e.title.trim().length===0&&t.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),e.summary.trim().length===0&&t.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function ye(e,t){let n=new Set,s=new Set;for(let[r,o]of e.types.entries()){let i;try{i=u(o).name}catch(c){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof o.name=="string"?o.name:`#${r}`,message:k(c)});continue}let a=i.toLowerCase();if(s.has(a)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:i,message:`Item type "${i}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}s.add(a),n.add(a)}return n}function he(e,t){let n=new Set,s=new Set;for(let[r,o]of e.statuses.entries()){let i;try{i=y(o)}catch(a){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof o.id=="string"?o.id:`#${r}`,message:k(a)});continue}if(s.has(i.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:i.id,message:`Status "${i.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}s.add(i.id),n.add(i.id);for(let a of i.aliases??[])n.add(g(a))}return n}function ge(e,t){let n=new Set;for(let[s,r]of e.fields.entries()){let o;try{o=f(r).key}catch(a){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof r.key=="string"?r.key:`#${s}`,message:k(a)});continue}if(n.has(o)){t.push({severity:"error",code:"field_duplicate",dimension:"fields",target:o,message:`Field "${o}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}n.add(o);let i=H(o);i&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:o,message:`Field "${o}" collides with canonical MCP property "${i.property}" owned by ${i.owner}; callers must pass the custom value through ${i.nested_path}.`})}}function _e(e,t,n,s){let r=new Set;for(let[o,i]of e.workflows.entries()){let a=i.type.trim().toLowerCase();if(a.length===0){s.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${o}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}let c=r.has(a);r.add(a),c?s.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:i.type,message:`Workflow type "${i.type}" is declared more than once; the later transition set wins.`}):!Z.has(a)&&!t.has(a)&&s.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:i.type,message:`Workflow governs type "${i.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});let d=new Set;for(let l of i.allowed_transitions){let m=g(l[0]),T=g(l[1]);if(m.length===0||T.length===0){s.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:i.type,message:`Workflow "${i.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(let h of[m,T])ue.has(h)||n.has(h)||d.has(h)||(d.add(h),s.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:h,message:`Workflow "${i.type}" references status "${h}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function ke(e,t){let n=new Set;for(let s of e.config){let r=b(s.key);if(r===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:s.key,message:`Config knob "${s.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}n.has(r.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:r.key,message:`Config knob "${r.key}" is set more than once; the later value silently overwrites the earlier one.`}):n.add(r.key);let o=v(r,s.value);o.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:s.key,message:o.error.message})}}function we(e,t,n){for(let s of e.templates){let r=s.options.type;if(typeof r!="string"||r.trim().length===0)continue;let o=r.trim().toLowerCase();!Z.has(o)&&!t.has(o)&&n.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:s.name,message:`Template "${s.name}" creates type "${r}" which is neither a built-in type nor declared by this profile.`})}}function be(e,t){for(let[n,s]of e.packages.entries())s.spec.trim().length===0&&t.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${n}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function dt(e){let t=[];fe(e,t);let n=ye(e,t),s=he(e,t);ge(e,t),_e(e,n,s,t),ke(e,t),we(e,n,t),be(e,t);let r=t.filter(i=>i.severity==="error").length,o=t.length-r;return{profile:e.name,ok:r===0,findings:t,errorCount:r,warningCount:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ead1caea-8e8b-5208-9fba-23fb114044b5")}catch{}})();function E(e,t,n,s,r){let o=e,i=[];for(let a of t){let c=s(o),d=r(o,a),l=s(d.file);o=d.file;let m=c===l?"unchanged":d.replaced?"update":"add";i.push({key:n(a),status:m})}return{file:o,changes:i,changed:i.some(a=>a.status!=="unchanged")}}function ee(e){return JSON.stringify(e.map(t=>t.join("\0")).sort())}function ve(e,t){let n=e.map(r=>({...r})),s=[];for(let r of t){let o=n.findIndex(a=>a.type===r.type),i={type:r.type,allowed_transitions:r.allowed_transitions};o<0?(n.push(i),s.push({type:r.type,status:"add"})):ee(n[o].allowed_transitions)===ee(r.allowed_transitions)?s.push({type:r.type,status:"unchanged"}):(n[o]=i,s.push({type:r.type,status:"update"}))}return{changes:s,result:n,changed:s.some(r=>r.status!=="unchanged")}}function Ie(e,t){let n=[];for(let s of e.config){let r=b(s.key);if(r===void 0)throw new Error(`Profile "${e.name}" references unknown config key "${s.key}".`);let o=v(r,s.value);if(!o.ok)throw new Error(`Profile "${e.name}" config ${s.key}: ${o.error.message}`);let i=V(t,r),a=i===null?"add":i===o.parsed.value?"unchanged":"update";n.push({key:r.key,path:r.path,value:o.parsed.value,status:a})}return{changes:n,changed:n.some(s=>s.status!=="unchanged")}}function te(e){let t=Object.entries(e).sort(([n],[s])=>n.localeCompare(s));return JSON.stringify(t)}function Se(e,t){let n=[];for(let s of e.templates){let r=t.get(s.name),o;r===void 0?o="add":te(r)===te(s.options)?o="unchanged":o="update",n.push({name:s.name,options:s.options,status:o})}return{changes:n,changed:n.some(s=>s.status!=="unchanged")}}function yt(e,t){let n=E(M(t.typesRaw),e.types,l=>u(l).name,q,(l,m)=>z(l,u(m))),s=E(X(t.statusesRaw),e.statuses,l=>y(l).id,W,(l,m)=>Y(l,y(m))),r=E(B(t.fieldsRaw),e.fields,l=>f(l).key,j,(l,m)=>U(l,f(m))),o=ve(t.workflows,e.workflows),i=Ie(e,t.settings),a=Se(e,t.templates),c=e.packages.map(l=>({spec:l.spec,reason:l.reason,status:t.installedPackages.has(l.spec)?"installed":"recommended"})),d=n.changed||s.changed||r.changed||o.changed||i.changed||a.changed;return{profile:{name:e.name,title:e.title,summary:e.summary},types:n,statuses:s,fields:r,workflows:o,config:i,templates:a,packages:c,changed:d}}export{Ce as a,$e as b,Pe as c,De as d,Le as e,Q as f,Re as g,Fe as h,_ as i,I as j,ne as k,qe as l,Be as m,se as n,je as o,re as p,Ye as q,oe as r,b as s,v as t,V as u,Ge as v,at as w,lt as x,dt as y,yt as z};
26
+ //# sourceMappingURL=chunk-VXDSU5MC.js.map