@unbrained/pm-cli 2026.10.17 → 2026.10.18

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 (188) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +25 -0
  3. package/dist/cli/register-list-query.js +2 -2
  4. package/dist/cli-bundle/bundle-manifest.json +1 -1
  5. package/dist/cli-bundle/chunks/{chunk-3QKI3XNX.js → chunk-4GA4MUTE.js} +2 -2
  6. package/dist/cli-bundle/chunks/{chunk-X2ONXFBP.js → chunk-4V6ONLI6.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-B5QVGCZX.js → chunk-6VZKYJW7.js} +2 -2
  8. package/dist/cli-bundle/chunks/chunk-7PATQWTH.js +20 -0
  9. package/dist/cli-bundle/chunks/{chunk-W3KZ22DW.js → chunk-7WIEAGDS.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-EA2CG7UM.js → chunk-AETP4JEM.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-6ZDKKOKM.js → chunk-FIJOSX2C.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-VMCSTFSO.js → chunk-LUKVNL72.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-J4LPQCET.js → chunk-OJ77ZQN3.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-O4YBC3OM.js → chunk-PYRREEUB.js} +30 -30
  15. package/dist/cli-bundle/chunks/chunk-RHQJ6VWC.js +237 -0
  16. package/dist/cli-bundle/chunks/{chunk-OZCSXX4D.js → chunk-RNABUEFB.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-HY7FQ7QX.js → chunk-TO6CIV4C.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-JS3B2M4D.js → chunk-ZZED447K.js} +2 -2
  19. package/dist/cli-bundle/chunks/{register-list-query-RU3QZSAQ.js → register-list-query-PUCVYYBD.js} +7 -7
  20. package/dist/cli-bundle/chunks/{register-mutation-EQYMT32A.js → register-mutation-GGGVBXD5.js} +2 -2
  21. package/dist/cli-bundle/chunks/{register-operations-VXBGE4XI.js → register-operations-NRZ6Q4QE.js} +2 -2
  22. package/dist/cli-bundle/chunks/{register-setup-UUDEGFRO.js → register-setup-MV3P3YSF.js} +2 -2
  23. package/dist/cli-bundle/focused-chunks/{chunk-LDKX4KYJ.js → chunk-2MPQUMTF.js} +2 -2
  24. package/dist/cli-bundle/focused-chunks/{chunk-MBQF6HT6.js → chunk-5UKCSZWT.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-FTUZ3JF2.js → chunk-A4ZHHTEX.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/{chunk-JXR6UKFM.js → chunk-B4YLP5ZB.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/{chunk-NZO7GOXD.js → chunk-BFEMT5U3.js} +16 -16
  28. package/dist/cli-bundle/focused-chunks/{chunk-QOSVJDOO.js → chunk-FW7CSSKL.js} +61 -61
  29. package/dist/cli-bundle/focused-chunks/{chunk-AH6NX6GM.js → chunk-HYPRPSYD.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-RBLSY6ML.js → chunk-IRVL4UXR.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-RHTH5ILM.js → chunk-L55KQ2KT.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/{chunk-PYC7BF6Z.js → chunk-MASIOFPG.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-RJ3EIHDU.js +26 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-SEL4Z2OO.js +167 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-2IOHHNRT.js → chunk-TB7F4FCR.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-UNTQE37U.js → chunk-TZUIBG3P.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-E33QA7PK.js → chunk-Z7YIFCNE.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-SIGIGZCG.js → chunk-ZDBS2DCT.js} +2 -2
  39. package/dist/cli-bundle/main.js +2 -2
  40. package/dist/cli-bundle/sdk-authoring.js +1 -1
  41. package/dist/cli-bundle/sdk-contracts.js +1 -1
  42. package/dist/cli-bundle/sdk-core.js +16 -16
  43. package/dist/cli-bundle/sdk-governance.js +1 -1
  44. package/dist/cli-bundle/sdk-graph.js +1 -1
  45. package/dist/cli-bundle/sdk-merge.js +50 -49
  46. package/dist/cli-bundle/sdk-query.js +1 -1
  47. package/dist/cli-bundle/sdk-runtime.js +1 -1
  48. package/dist/cli-bundle/sdk-testing.js +1 -1
  49. package/dist/cli-bundle/sdk.js +1 -1
  50. package/dist/core/history/event-index.d.ts +8 -1
  51. package/dist/core/history/event-index.js +19 -18
  52. package/dist/core/item/item-format.js +1 -1
  53. package/dist/core/lock/lock.d.ts +8 -1
  54. package/dist/core/lock/lock.js +3 -3
  55. package/dist/core/output/output.js +2 -2
  56. package/dist/core/store/paths.js +1 -1
  57. package/dist/core/telemetry/policy.d.ts +2 -0
  58. package/dist/core/telemetry/policy.js +1 -1
  59. package/dist/core/telemetry/runtime.d.ts +5 -3
  60. package/dist/core/telemetry/runtime.js +3 -3
  61. package/dist/sdk/governance/health/projection.d.ts +37 -0
  62. package/dist/sdk/governance/health/projection.js +2 -0
  63. package/dist/sdk/governance/health.d.ts +7 -18
  64. package/dist/sdk/governance/health.js +2 -2
  65. package/dist/sdk/mutation-events.js +1 -1
  66. package/dist/sdk/public-surface.json +1 -1
  67. package/dist/sdk/query/list.d.ts +2 -0
  68. package/dist/sdk/query/list.js +1 -1
  69. package/dist/types.d.ts +2 -2
  70. package/dist/types.js +1 -1
  71. package/docs/COMMANDS.md +26 -0
  72. package/docs/CONFIGURATION.md +22 -1
  73. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +22 -3
  74. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +10 -0
  75. package/docs/RELEASING.md +8 -1
  76. package/docs/SDK_CONTEXT_COORDINATION.md +71 -7
  77. package/docs/SDK_STORAGE_LIFECYCLE.md +24 -2
  78. package/docs/TESTING.md +8 -0
  79. package/docs/examples/ci/github-actions-pm-extension-gate.yml +1 -1
  80. package/docs/examples/ci/gitlab-ci-pm-extension-gate.yml +1 -1
  81. package/docs/examples/ci/jenkins-pm-extension-gate.Jenkinsfile +1 -1
  82. package/marketplace.json +1 -1
  83. package/node_modules/@opentelemetry/core/package.json +2 -1
  84. package/node_modules/@opentelemetry/instrumentation/package.json +2 -1
  85. package/node_modules/@opentelemetry/resources/package.json +2 -1
  86. package/node_modules/@opentelemetry/sdk-trace/package.json +2 -1
  87. package/node_modules/@opentelemetry/sdk-trace-base/package.json +2 -1
  88. package/node_modules/@sentry/core/build/cjs/client.js +5 -4
  89. package/node_modules/@sentry/core/build/cjs/tracing/ai/gen-ai-attributes.js +0 -4
  90. package/node_modules/@sentry/core/build/cjs/tracing/ai/utils.js +33 -23
  91. package/node_modules/@sentry/core/build/cjs/tracing/anthropic-ai/index.js +7 -6
  92. package/node_modules/@sentry/core/build/cjs/tracing/anthropic-ai/streaming.js +3 -1
  93. package/node_modules/@sentry/core/build/cjs/tracing/google-genai/index.js +13 -14
  94. package/node_modules/@sentry/core/build/cjs/tracing/google-genai/streaming.js +6 -1
  95. package/node_modules/@sentry/core/build/cjs/tracing/langchain/utils.js +71 -21
  96. package/node_modules/@sentry/core/build/cjs/tracing/langgraph/utils.js +23 -33
  97. package/node_modules/@sentry/core/build/cjs/tracing/openai/streaming.js +6 -0
  98. package/node_modules/@sentry/core/build/cjs/tracing/openai/utils.js +11 -0
  99. package/node_modules/@sentry/core/build/cjs/tracing/workers-ai/utils.js +1 -1
  100. package/node_modules/@sentry/core/build/cjs/utils/eventUtils.js +4 -0
  101. package/node_modules/@sentry/core/build/cjs/utils/prepareEvent.js +2 -2
  102. package/node_modules/@sentry/core/build/cjs/utils/version.js +1 -1
  103. package/node_modules/@sentry/core/build/esm/client.js +6 -5
  104. package/node_modules/@sentry/core/build/esm/package.json +1 -1
  105. package/node_modules/@sentry/core/build/esm/tracing/ai/gen-ai-attributes.js +1 -3
  106. package/node_modules/@sentry/core/build/esm/tracing/ai/utils.js +34 -24
  107. package/node_modules/@sentry/core/build/esm/tracing/anthropic-ai/index.js +8 -7
  108. package/node_modules/@sentry/core/build/esm/tracing/anthropic-ai/streaming.js +3 -1
  109. package/node_modules/@sentry/core/build/esm/tracing/google-genai/index.js +15 -16
  110. package/node_modules/@sentry/core/build/esm/tracing/google-genai/streaming.js +6 -1
  111. package/node_modules/@sentry/core/build/esm/tracing/langchain/utils.js +73 -24
  112. package/node_modules/@sentry/core/build/esm/tracing/langgraph/utils.js +24 -34
  113. package/node_modules/@sentry/core/build/esm/tracing/openai/streaming.js +6 -0
  114. package/node_modules/@sentry/core/build/esm/tracing/openai/utils.js +11 -0
  115. package/node_modules/@sentry/core/build/esm/tracing/workers-ai/utils.js +2 -2
  116. package/node_modules/@sentry/core/build/esm/utils/eventUtils.js +4 -1
  117. package/node_modules/@sentry/core/build/esm/utils/prepareEvent.js +2 -2
  118. package/node_modules/@sentry/core/build/esm/utils/version.js +1 -1
  119. package/node_modules/@sentry/core/build/types/tracing/ai/utils.d.ts +3 -7
  120. package/node_modules/@sentry/core/build/types/tracing/anthropic-ai/types.d.ts +2 -2
  121. package/node_modules/@sentry/core/build/types/tracing/langchain/types.d.ts +15 -0
  122. package/node_modules/@sentry/core/build/types/tracing/langchain/utils.d.ts +1 -0
  123. package/node_modules/@sentry/core/build/types/tracing/langgraph/utils.d.ts +2 -0
  124. package/node_modules/@sentry/core/build/types/tracing/openai/types.d.ts +2 -0
  125. package/node_modules/@sentry/core/build/types/utils/eventUtils.d.ts +2 -1
  126. package/node_modules/@sentry/core/build/types-ts3.8/tracing/ai/utils.d.ts +3 -7
  127. package/node_modules/@sentry/core/build/types-ts3.8/tracing/anthropic-ai/types.d.ts +2 -2
  128. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langchain/types.d.ts +15 -0
  129. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langchain/utils.d.ts +1 -0
  130. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langgraph/utils.d.ts +2 -0
  131. package/node_modules/@sentry/core/build/types-ts3.8/tracing/openai/types.d.ts +2 -0
  132. package/node_modules/@sentry/core/build/types-ts3.8/utils/eventUtils.d.ts +2 -1
  133. package/node_modules/@sentry/core/package.json +1 -1
  134. package/node_modules/@sentry/node/build/esm/package.json +1 -1
  135. package/node_modules/@sentry/node/package.json +5 -5
  136. package/node_modules/@sentry/node-core/build/cjs/integrations/anr/index.js +1 -1
  137. package/node_modules/@sentry/node-core/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  138. package/node_modules/@sentry/node-core/build/esm/integrations/anr/index.js +1 -1
  139. package/node_modules/@sentry/node-core/build/esm/integrations/anr/worker-script.js +2 -2
  140. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  141. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/worker-script.js +1 -1
  142. package/node_modules/@sentry/node-core/build/esm/package.json +1 -1
  143. package/node_modules/@sentry/node-core/package.json +10 -4
  144. package/node_modules/@sentry/opentelemetry/build/esm/package.json +1 -1
  145. package/node_modules/@sentry/opentelemetry/package.json +5 -2
  146. package/node_modules/@sentry/server-utils/build/THIRD-PARTY-LICENSES.txt +55 -55
  147. package/node_modules/@sentry/server-utils/build/esm/package.json +1 -1
  148. package/node_modules/@sentry/server-utils/package.json +2 -2
  149. package/node_modules/@toon-format/toon/README.md +10 -41
  150. package/node_modules/@toon-format/toon/dist/index.d.mts +12 -36
  151. package/node_modules/@toon-format/toon/dist/index.mjs +134 -202
  152. package/node_modules/@toon-format/toon/package.json +2 -2
  153. package/node_modules/debug/package.json +3 -0
  154. package/node_modules/fdir/package.json +3 -0
  155. package/node_modules/has-flag/index.d.ts +39 -0
  156. package/node_modules/has-flag/index.js +8 -0
  157. package/node_modules/has-flag/license +9 -0
  158. package/node_modules/has-flag/package.json +46 -0
  159. package/node_modules/has-flag/readme.md +89 -0
  160. package/node_modules/supports-color/browser.js +5 -0
  161. package/node_modules/supports-color/index.js +135 -0
  162. package/node_modules/supports-color/license +9 -0
  163. package/node_modules/supports-color/package.json +53 -0
  164. package/node_modules/supports-color/readme.md +76 -0
  165. package/package.json +4 -4
  166. package/packages/pm-beads/package.json +1 -1
  167. package/packages/pm-calendar/package.json +1 -1
  168. package/packages/pm-command-kit/package.json +1 -1
  169. package/packages/pm-digital-twin/package.json +1 -1
  170. package/packages/pm-governance-audit/package.json +1 -1
  171. package/packages/pm-guide-shell/package.json +1 -1
  172. package/packages/pm-kanban/package.json +1 -1
  173. package/packages/pm-lifecycle-hooks/package.json +1 -1
  174. package/packages/pm-linked-test-adapters/package.json +1 -1
  175. package/packages/pm-search-advanced/package.json +1 -1
  176. package/packages/pm-templates/package.json +1 -1
  177. package/packages/pm-todos/package.json +1 -1
  178. package/packages/pm-vcs/package.json +1 -1
  179. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  180. package/plugins/pm-claude/package.json +1 -1
  181. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  182. package/plugins/pm-codex/package.json +1 -1
  183. package/plugins/pm-codex/plugin.json +1 -1
  184. package/runtime-dependencies.json +1 -1
  185. package/dist/cli-bundle/chunks/chunk-4PNPDT2N.js +0 -236
  186. package/dist/cli-bundle/chunks/chunk-X53HM753.js +0 -20
  187. package/dist/cli-bundle/focused-chunks/chunk-5JEFDEL3.js +0 -166
  188. package/dist/cli-bundle/focused-chunks/chunk-TRFVAWF2.js +0 -26
@@ -1,2 +1,2 @@
1
- import{R as o,T as r}from"./chunk-4PNPDT2N.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="be9abae1-85ae-5a68-96bc-c738218ace5e")}catch{}})();function u(n){return n instanceof r||n instanceof Error?n.message:"Unknown failure"}function d(n){if(typeof n!="object"||n===null||!("exitCode"in n))return;let e=n.exitCode;return typeof e=="number"&&Number.isFinite(e)?e:void 0}function f(n){let e=Math.trunc(n);return e>o.SUCCESS?e:o.GENERIC_FAILURE}function s(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="string"&&n.code.startsWith("commander.")}function l(n,e){if(n instanceof Error)return n;let t=new Error(e),i=d(n);return i!==void 0&&(t.exitCode=f(i)),t}export{u as a,d as b,f as c,s as d,l as e};
2
- //# sourceMappingURL=chunk-W3KZ22DW.js.map
1
+ import{R as o,T as r}from"./chunk-RHQJ6VWC.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="be9abae1-85ae-5a68-96bc-c738218ace5e")}catch{}})();function u(n){return n instanceof r||n instanceof Error?n.message:"Unknown failure"}function d(n){if(typeof n!="object"||n===null||!("exitCode"in n))return;let e=n.exitCode;return typeof e=="number"&&Number.isFinite(e)?e:void 0}function f(n){let e=Math.trunc(n);return e>o.SUCCESS?e:o.GENERIC_FAILURE}function s(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="string"&&n.code.startsWith("commander.")}function l(n,e){if(n instanceof Error)return n;let t=new Error(e),i=d(n);return i!==void 0&&(t.exitCode=f(i)),t}export{u as a,d as b,f as c,s as d,l as e};
2
+ //# sourceMappingURL=chunk-7WIEAGDS.js.map
@@ -1,3 +1,3 @@
1
- import{aa as c,ba as _,da as f,fa as p}from"./chunk-X53HM753.js";import{Hf as d}from"./chunk-4PNPDT2N.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="8467eccc-684d-56cc-8b18-5f2e940abb42")}catch{}})();var m="not-a-declared-intent",i="not-a-declared-field";function g(){let e={get:["pm-domain"],search:["Domain query"]},r=[...new Set(d.map(({command:o})=>o))].map(o=>{let a=d.filter(n=>n.command===o),s=a[0],u=e[s.command]??[];return{probe_id:`${s.command}-invalid-intent`,command:s.command,flag:"--for",rejected_value:m,refusal_args:[s.command,...u,"--for",m],allowed_values:a.map(({intent:n})=>n).sort(),suggested_retry_args:[s.command,...u,"--for",s.intent],error_code:"unknown_context_intent"}}),t=_(),l=Object.keys(c).map(o=>({probe_id:`${o}-invalid-field`,command:o,flag:"--fields",rejected_value:i,refusal_args:[o,"--fields",i],allowed_values:t,suggested_retry_args:[o,"--fields","id,title,status"],error_code:"unknown_field_projection"}));return[...r,...l,{probe_id:"get-invalid-field",command:"get",flag:"--fields",rejected_value:i,refusal_args:["get","pm-domain","--fields",i],allowed_values:f(),suggested_retry_args:["get","pm-domain","--fields","id,title,status"],error_code:"unknown_field_projection"},{probe_id:"list-mutually-exclusive-projection",command:"list",flag:"--projection",rejected_value:"--brief+--full",refusal_args:["list","--brief","--full"],allowed_values:[],suggested_retry_args:["list","--brief"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"get-mutually-exclusive-projection",command:"get",flag:"--projection",rejected_value:"--full+--fields",refusal_args:["get","pm-domain","--full","--fields","id"],allowed_values:[],suggested_retry_args:["get","pm-domain","--full"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"search-mutually-exclusive-projection",command:"search",flag:"--projection",rejected_value:"--full+--fields",refusal_args:["search","Domain query","--full","--fields","id"],allowed_values:[],suggested_retry_args:["search","Domain query","--full"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"package-upgrade-mutually-exclusive-modes",command:"package upgrade",flag:"--cli-only/--packages-only",rejected_value:"--cli-only+--packages-only",refusal_args:["package","upgrade","--cli-only","--packages-only","--dry-run"],allowed_values:[],suggested_retry_args:["package","upgrade","--packages-only","--dry-run"],error_code:"package_upgrade_modes_mutually_exclusive",allowed_values_required:!1},{probe_id:"search-invalid-field",command:"search",flag:"--fields",rejected_value:i,refusal_args:["search","Domain query","--fields",i],allowed_values:p(),suggested_retry_args:["search","Domain query","--fields","id,title,status,score"],error_code:"unknown_field_projection"}].sort((o,a)=>o.probe_id.localeCompare(a.probe_id))}function v(e,r){let t=g().find(a=>a.command===e&&a.flag===r);if(!t)return"No stable core values are declared.";let l=t.allowed_values.filter(a=>!a.startsWith("item.")),o=r==="--fields"?" item.<field> aliases and configured runtime metadata fields are also accepted.":" Configured package and workspace intents may extend this domain.";return`Allowed core values: ${l.join("|")}.${o}`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="1a6915d3-31fe-5269-b945-caef21172c86")}catch{}})();function y(e){return e.map((r,t)=>{if(typeof r!="object"||r===null||Array.isArray(r))throw new TypeError(`NDJSON row ${t} must be a non-null object.`);let l=JSON.stringify(r);if(l===void 0)throw new TypeError(`NDJSON row ${t} must serialize to a non-null object.`);let o=JSON.parse(l);if(typeof o!="object"||o===null||Array.isArray(o))throw new TypeError(`NDJSON row ${t} must serialize to a non-null object.`);return l}).join(`
1
+ import{aa as c,ba as _,da as f,fa as p}from"./chunk-7PATQWTH.js";import{Hf as d}from"./chunk-RHQJ6VWC.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="8467eccc-684d-56cc-8b18-5f2e940abb42")}catch{}})();var m="not-a-declared-intent",i="not-a-declared-field";function g(){let e={get:["pm-domain"],search:["Domain query"]},r=[...new Set(d.map(({command:o})=>o))].map(o=>{let a=d.filter(n=>n.command===o),s=a[0],u=e[s.command]??[];return{probe_id:`${s.command}-invalid-intent`,command:s.command,flag:"--for",rejected_value:m,refusal_args:[s.command,...u,"--for",m],allowed_values:a.map(({intent:n})=>n).sort(),suggested_retry_args:[s.command,...u,"--for",s.intent],error_code:"unknown_context_intent"}}),t=_(),l=Object.keys(c).map(o=>({probe_id:`${o}-invalid-field`,command:o,flag:"--fields",rejected_value:i,refusal_args:[o,"--fields",i],allowed_values:t,suggested_retry_args:[o,"--fields","id,title,status"],error_code:"unknown_field_projection"}));return[...r,...l,{probe_id:"get-invalid-field",command:"get",flag:"--fields",rejected_value:i,refusal_args:["get","pm-domain","--fields",i],allowed_values:f(),suggested_retry_args:["get","pm-domain","--fields","id,title,status"],error_code:"unknown_field_projection"},{probe_id:"list-mutually-exclusive-projection",command:"list",flag:"--projection",rejected_value:"--brief+--full",refusal_args:["list","--brief","--full"],allowed_values:[],suggested_retry_args:["list","--brief"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"get-mutually-exclusive-projection",command:"get",flag:"--projection",rejected_value:"--full+--fields",refusal_args:["get","pm-domain","--full","--fields","id"],allowed_values:[],suggested_retry_args:["get","pm-domain","--full"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"search-mutually-exclusive-projection",command:"search",flag:"--projection",rejected_value:"--full+--fields",refusal_args:["search","Domain query","--full","--fields","id"],allowed_values:[],suggested_retry_args:["search","Domain query","--full"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"package-upgrade-mutually-exclusive-modes",command:"package upgrade",flag:"--cli-only/--packages-only",rejected_value:"--cli-only+--packages-only",refusal_args:["package","upgrade","--cli-only","--packages-only","--dry-run"],allowed_values:[],suggested_retry_args:["package","upgrade","--packages-only","--dry-run"],error_code:"package_upgrade_modes_mutually_exclusive",allowed_values_required:!1},{probe_id:"search-invalid-field",command:"search",flag:"--fields",rejected_value:i,refusal_args:["search","Domain query","--fields",i],allowed_values:p(),suggested_retry_args:["search","Domain query","--fields","id,title,status,score"],error_code:"unknown_field_projection"}].sort((o,a)=>o.probe_id.localeCompare(a.probe_id))}function v(e,r){let t=g().find(a=>a.command===e&&a.flag===r);if(!t)return"No stable core values are declared.";let l=t.allowed_values.filter(a=>!a.startsWith("item.")),o=r==="--fields"?" item.<field> aliases and configured runtime metadata fields are also accepted.":" Configured package and workspace intents may extend this domain.";return`Allowed core values: ${l.join("|")}.${o}`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="1a6915d3-31fe-5269-b945-caef21172c86")}catch{}})();function y(e){return e.map((r,t)=>{if(typeof r!="object"||r===null||Array.isArray(r))throw new TypeError(`NDJSON row ${t} must be a non-null object.`);let l=JSON.stringify(r);if(l===void 0)throw new TypeError(`NDJSON row ${t} must serialize to a non-null object.`);let o=JSON.parse(l);if(typeof o!="object"||o===null||Array.isArray(o))throw new TypeError(`NDJSON row ${t} must serialize to a non-null object.`);return l}).join(`
2
2
  `)}function O(e,r){if(r.count!==e.length)throw new TypeError(`NDJSON trailer count ${r.count} does not match ${e.length} ${e.length===1?"row":"rows"}.`);for(let[t,l]of e.entries())if(typeof l=="object"&&l!==null&&!Array.isArray(l)&&Reflect.get(l,"record_type")==="pm.stream.trailer")throw new TypeError(`NDJSON row ${t} uses reserved record_type pm.stream.trailer`);return y([...e,{...r,record_type:"pm.stream.trailer"}])}export{g as a,v as b,y as c,O as d};
3
- //# sourceMappingURL=chunk-EA2CG7UM.js.map
3
+ //# sourceMappingURL=chunk-AETP4JEM.js.map
@@ -1,4 +1,4 @@
1
- import{a as ot,b as Cn,c as yc,d as bc,g as wc,i as zc}from"./chunk-X2ONXFBP.js";import{A as rl,P as er,Y as il,d as Eo,e as Hc,g as Wc,h as Vc,i as Bc,o as Kc,p as Mt,q as Ge,r as Zo,y as Qo}from"./chunk-JS3B2M4D.js";import{$c as nl,Aa as pc,Ba as uc,Ca as In,Da as _c,Ea as An,Fa as En,Ga as fc,Gb as Dc,Ia as tt,Id as tr,J as Le,Ja as hc,Jb as Mc,Ka as jo,Kb as jc,La as Tn,Ld as _l,Na as nt,Oc as Ho,Pb as Nt,Rc as Ie,Sc as Jc,Tc as Vo,Uc as Yc,Ud as fl,Vc as Xc,Vd as hl,Wa as gc,Wc as rt,Xc as Zc,_c as tl,ad as ol,b as No,bd as Jo,cd as Yo,dd as Xo,fc as On,ga as hn,gd as sl,ha as ac,hd as cl,i as Os,ia as et,id as ll,j as $s,ja as h,jd as dl,ka as sc,kd as ml,l as Fs,la as cc,mb as kc,mc as Uc,md as pl,na as Y,nb as Sc,nd as ul,oa as lc,oc as qc,pa as vn,qa as dc,ra as Do,sa as Lt,sb as Go,ta as kn,tb as Uo,ua as Me,ub as qo,va as mc,vc as Dt,wa as Sn,wb as Ic,xa as U,xb as Ac,ya as Mo,yb as zo,za as j}from"./chunk-O4YBC3OM.js";import{$ as Vs,$a as ic,D as Ls,F as Ne,G as Ns,H as yn,I as Ds,Ia as Qe,J as De,K as Ms,L as bn,M as js,Pa as oc,S as Gs,Ua as wn,V as Us,X as qs,Y as zs,Ya as rc,Z as Hs,_ as Ws,aa as Bs,ba as Ks,c as fa,ca as Js,da as Ys,ea as Xs,fa as Zs,ga as Qs,ha as ec,i as gn,ia as tc,ja as nc,x as Ps}from"./chunk-OZCSXX4D.js";import{$a as Ec,Ab as Nc,Eb as Se,Fb as Gc,Gb as xn,Kb as Wo,Vc as Bo,Yb as Qc,Zb as el,_c as Ko,bd as al,d as ua,f as _a,jb as Tc,kb as Cc,lb as Rc,na as de,ob as xc,pb as Oc,qb as $c,rb as Fc,tb as je,ua as vc,ub as Pc,vb as Lc,yb as Rn}from"./chunk-X53HM753.js";import{$ as oe,$c as en,$f as F,$i as Ze,$j as ba,A as _i,Al as cn,An as Fo,B as fi,Bf as Wi,Bi as aa,Bl as Ba,Bn as Cs,C as hi,Cg as Qi,Cj as an,Cl as Ka,D as gi,Dd as Pi,Di as Io,Ed as Li,Ei as Ao,Fj as $t,Fm as ds,G as yi,Gi as T,Gj as pa,Gl as ke,Hi as sa,Hl as E,Il as Ja,Ja as co,Jf as Vi,Jl as Ya,Jm as ms,Ka as lo,Kd as H,Kg as Fe,Kk as Ea,La as mo,Le as Di,Ma as po,Mf as Ke,Mg as Ye,Nk as Ta,Nm as ps,Oj as ha,Ok as Ca,Qb as vi,Qf as Bi,Qi as To,Qm as le,R as u,Rb as ki,Re as Mi,Rg as on,Ri as Co,Rl as Xa,Sg as Ct,Sl as ln,T as p,Tg as ko,Tl as dn,Tm as us,Ub as Si,Ue as ji,Ul as mn,Um as _s,V as ye,Va as P,Vl as pn,W as Be,Wa as Yt,Wd as tn,Wk as Ra,Wm as _n,X as ro,Xi as ca,Xj as ga,Xl as re,Xm as fs,Xo as Rs,Y as se,Yh as Rt,Yk as xa,Zc as Zt,Zh as xt,Zj as ya,Zl as Za,_c as Qt,_f as Ki,_j as sn,_l as Qa,aa as St,bb as A,bd as Oi,be as Ni,bm as Ft,bn as hs,ce as nn,cl as Oa,cm as es,cn as gs,df as Gi,dh as ea,dl as $a,dm as ts,eb as we,eh as ta,el as Fa,em as ns,eo as Po,f as J,fb as uo,fh as na,fk as wa,fm as os,gf as Ui,gn as xo,go as Lo,h as oo,ha as bi,hb as xe,hd as _o,hl as Pa,hp as xs,in as Oo,j as pi,ja as wi,jd as fo,jf as qi,jk as va,ka as be,kd as ho,km as Ro,ld as go,ll as La,lm as rs,mc as Ii,md as yo,ml as Na,mm as Pe,mn as ys,na as io,nc as Ai,nd as bo,ng as Je,nl as Da,nn as bs,oc as Ei,od as wo,of as S,og as Oe,ok as ka,ol as Ma,om as is,on as ws,p as Jt,pc as Ti,pd as vo,pg as Ji,pk as Sa,pl as ja,pm as as,pn as vs,qa as ao,qc as Ci,qd as $,qg as Yi,qn as ks,ra as It,rc as Ri,rg as $e,rj as la,rk as Ia,rl as Ga,rm as un,sc as xi,sf as zi,sg as Xi,si as oa,sl as Ua,sn as Ss,ta as so,tb as At,ti as Xe,tj as da,tl as qa,tm as ss,tn as Is,u as Ve,ub as Et,uf as Hi,uj as ma,uk as Aa,ul as za,um as cs,un as As,vd as $i,vf as ne,vg as V,vh as So,vj as ce,vl as Ha,vm as ls,vn as Pt,w as ui,wb as Xt,wd as Fi,wh as R,wi as rn,wj as ve,wl as Wa,wn as Es,xg as Tt,xn as fn,yg as Zi,yi as ra,yn as Ts,zd as G,zi as ia,zj as Ot,zl as Va,zn as $o}from"./chunk-4PNPDT2N.js";import{AsyncLocalStorage as Gg}from"node:async_hooks";import{readFile as hp}from"node:fs/promises";import gp 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]="20a3a324-d176-5918-8167-5e548be4abc9")}catch{}})();var nr="context-intents.json";function $n(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yp(e,t,n){if(!$n(e))throw new TypeError(`${t} context intent at index ${String(n)} must be an object`);let o=e.included_field_groups;if(typeof e.command!="string"||typeof e.intent!="string"||typeof e.description!="string"||!Array.isArray(o)||!o.every(r=>typeof r=="string")||typeof e.token_budget!="number")throw new TypeError(`${t} context intent at index ${String(n)} has an invalid contract shape`);return{command:e.command,intent:e.intent,description:e.description,included_field_groups:o,token_budget:e.token_budget}}function gl(e,t){let n=Array.isArray(e)?e:$n(e)&&Array.isArray(e.intents)?e.intents:void 0;if(!n)throw new TypeError(`${t} context intents must be an array or an object with an intents array`);return n.map((o,r)=>yp(o,t,r))}async function bp(e){let t=gp.join(e,nr),n;try{n=await hp(t,"utf8")}catch(r){if(Be(r))return[];throw await Ki(e),r}let o;try{o=JSON.parse(n)}catch(r){let i=r instanceof Error?r.message:String(r);throw new TypeError(`Invalid ${nr}: ${i}`,{cause:r})}return gl(o,nr)}function wp(e){if(!$n(e))return;let t=e.contextIntents??e.context_intents;if(t!==void 0)return t;let n=e.default;return $n(n)?n.contextIntents??n.context_intents:void 0}function vp(e){return e.flatMap(t=>{let n=wp(t.module);return n===void 0?[]:gl(n,`package ${t.name}`)})}async function kp(e){let t=await bp(e.pmRoot),n=vp(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function Fn(e,t){let n=await kp(e);return await Vi(n,t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0a4abc17-0fcb-573f-8f89-6e505e112261")}catch{}})();async function yl(e,t,n=Wi){try{await n({pmRoot:e,result:t})}catch{if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let o=t,r=Array.isArray(o.warnings)?o.warnings.filter(i=>typeof i=="string"):[];o.warnings=[...new Set([...r,"context_usage_feedback_write_failed"])].sort()}}}import{createHash as xp}from"node:crypto";import{constants as jt}from"node:fs";import{lstat as bl,mkdir as rr,open as wl}from"node:fs/promises";import me 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]="5434ff6f-95af-5983-88cb-fd360d95cb9e")}catch{}})();function or(e,t){if(typeof e!="string"||e.trim().length===0)throw new TypeError(`Relationship event ${t} must be non-empty`);return e.trim()}function ir(e,t){let n=t.require(e.kind),o=n.direction==="undirected"?[e.source,e.target].sort().join("\0"):`${e.source}\0${e.target}`;return`${n.kind}\0${o}`}function Sp(e){return Object.freeze({...e,...e.payload===void 0?{}:{payload:Object.freeze(structuredClone(e.payload))}})}function Ip(e,t,n,o){let r=n.require(e.kind),i=o.outgoingOne.get(`${r.kind}\0${e.source}`);if(i!==void 0&&i!==t)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let a=o.incomingOne.get(`${r.kind}\0${e.target}`);if(a!==void 0&&a!==t)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let s=ir(e,n),c=o.identities.get(s);if(c!==void 0&&c!==t)throw new TypeError(`Relationship edge already active: ${s}`)}function Ap(e){let t=new Map;for(let n of e)n.action==="remove"?t.delete(n.relationshipId):t.set(n.relationshipId,n.edge);return t}function Ep(e,t,n){if(e.expectedVersion!==void 0&&e.expectedVersion!==t)throw new TypeError(`Relationship event version conflict: expected ${e.expectedVersion}, current ${t}`);let o=or(e.eventId,"eventId");if(n.has(o))throw new TypeError(`Relationship event already exists: ${o}`);if(e.action!=="add"&&e.action!=="remove"&&e.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${e.action}`);if(!Number.isFinite(Date.parse(e.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:o,relationshipId:or(e.relationshipId,"relationshipId"),author:or(e.author,"author"),timestamp:new Date(e.timestamp).toISOString()}}function Tp(e,t,n,o,r,i){let a=n.has(t);if(e.action==="add"&&a)throw new TypeError(`Relationship is already active: ${t}`);if(e.action!=="add"&&!a)throw new TypeError(`Relationship is not active: ${t}`);if(e.action==="remove")return;if(!e.edge)throw new TypeError(`Relationship ${e.action} event requires an edge`);let s=typeof e.edge.source=="string"?e.edge.source.trim():"",c=typeof e.edge.target=="string"?e.edge.target.trim():"";if(!o.has(s)||!o.has(c))throw new TypeError(`Relationship endpoint not found: ${s} -> ${c}`);let l=new Ve([s,c],[e.edge],r).edges()[0];return Ip(l,t,r,i),Sp(l)}var Gt=class{#t;#n;#o=[];#i=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(t,n={}){this.#t=new Set([...t].filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean)),this.#n=n.registry??Jt()}get version(){return this.#o.length}events(){return Object.freeze([...this.#o])}*stream(t={}){let n=t.fromVersion??1,o=t.toVersion??this.version,r=t.batchSize??100;if(!Number.isInteger(n)||n<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${o}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(n>o+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let i=n-1;i<o;i+=r)yield Object.freeze(this.#o.slice(i,Math.min(i+r,o)))}project(t,n,o={}){if(typeof n!="function")throw new TypeError("Relationship event projection requires a reducer");let r=t,i=0,a;for(let s of this.stream({...o,batchSize:256}))for(let c of s)r=n(r,c),i+=1,a=c;return Object.freeze({state:r,version:a?.sequence??Math.max(0,(o.fromVersion??1)-1),processed:i,...a===void 0?{}:{asOf:a.timestamp}})}#a(t,n){let o=this.#n.require(n.kind);this.#r.identities.set(ir(n,this.#n),t),o.outgoing==="one"&&this.#r.outgoingOne.set(`${o.kind}\0${n.source}`,t),o.incoming==="one"&&this.#r.incomingOne.set(`${o.kind}\0${n.target}`,t)}#s(t){let n=this.#n.require(t.kind);this.#r.identities.delete(ir(t,this.#n)),n.outgoing==="one"&&this.#r.outgoingOne.delete(`${n.kind}\0${t.source}`),n.incoming==="one"&&this.#r.incomingOne.delete(`${n.kind}\0${t.target}`)}append(t){let n=Ep(t,this.version,this.#i),o=this.#e.get(n.relationshipId),r=Tp(t,n.relationshipId,this.#e,this.#t,this.#n,this.#r),i=Object.freeze({eventId:n.eventId,relationshipId:n.relationshipId,action:t.action,...r===void 0?{}:{edge:r},author:n.author,timestamp:n.timestamp,...t.reason?.trim()?{reason:t.reason.trim()}:{},sequence:this.version+1});return this.#o.push(i),this.#i.add(n.eventId),o&&this.#s(o),t.action==="remove"?this.#e.delete(n.relationshipId):(this.#e.set(n.relationshipId,r),this.#a(n.relationshipId,r)),i}snapshot(t={}){if(t.atVersion!==void 0&&t.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let n;if(t.atTimestamp!==void 0){let i=Date.parse(t.atTimestamp);if(!Number.isFinite(i))throw new TypeError("Relationship snapshot timestamp must be valid");n=this.#o.filter(a=>Date.parse(a.timestamp)<=i)}else{let i=t.atVersion??this.version;if(!Number.isInteger(i)||i<0||i>this.version)throw new TypeError(`Relationship snapshot version out of range: ${i}`);n=this.#o.slice(0,i)}let o=Ap(n),r=new Ve(this.#t,o.values(),this.#n);return Object.freeze({version:n.at(-1)?.sequence??0,...n.at(-1)?{asOf:n.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(t){if(!Number.isInteger(t.limit)||t.limit<1)throw new TypeError("Relationship event page limit must be positive");let n=Gi("relationship-events",{order:"append-sequence"}),o=t.cursor===void 0?this.version:Number(Ui(t.cursor,n).snapshot);if(!Number.isSafeInteger(o)||o<0||o>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=qi(this.#o.slice(0,o),{cursor:t.cursor,fingerprint:n,limit:t.limit,readId:i=>i.eventId,snapshot:String(o)});return{version:o,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},Cp="relationship-event-store",vl=jt.O_NOFOLLOW;function Pn(e){return ne(e,Cp,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function Ue(e,t="relationships/events.jsonl"){let n=me.resolve(e),o=me.resolve(n,t),r=me.relative(n,o);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${me.sep}`)||me.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await rr(n,{recursive:!0}),(await bl(n)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let i=n;for(let a of r.split(me.sep)){i=me.join(i,a);try{if((await bl(i)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(s){if(ro(s))break;throw s}}return o}async function Ln(e,t,n){let o=new Gt(t,{registry:n}),r,i;try{i=await wl(e,jt.O_RDONLY|vl),r=await i.readFile("utf8")}catch(s){if(ro(s))return{log:o,raw:""};throw s}finally{await i?.close()}let a=r.split(`
1
+ import{a as ot,b as Cn,c as yc,d as bc,g as wc,i as zc}from"./chunk-4V6ONLI6.js";import{A as rl,P as er,Y as il,d as Eo,e as Hc,g as Wc,h as Vc,i as Bc,o as Kc,p as Mt,q as Ge,r as Zo,y as Qo}from"./chunk-ZZED447K.js";import{$c as nl,Aa as pc,Ba as uc,Ca as In,Da as _c,Ea as An,Fa as En,Ga as fc,Gb as Dc,Ia as tt,Id as tr,J as Le,Ja as hc,Jb as Mc,Ka as jo,Kb as jc,La as Tn,Ld as _l,Na as nt,Oc as Ho,Pb as Nt,Rc as Ie,Sc as Jc,Tc as Vo,Uc as Yc,Ud as fl,Vc as Xc,Vd as hl,Wa as gc,Wc as rt,Xc as Zc,_c as tl,ad as ol,b as No,bd as Jo,cd as Yo,dd as Xo,fc as On,ga as hn,gd as sl,ha as ac,hd as cl,i as Os,ia as et,id as ll,j as $s,ja as h,jd as dl,ka as sc,kd as ml,l as Fs,la as cc,mb as kc,mc as Uc,md as pl,na as Y,nb as Sc,nd as ul,oa as lc,oc as qc,pa as vn,qa as dc,ra as Do,sa as Lt,sb as Go,ta as kn,tb as Uo,ua as Me,ub as qo,va as mc,vc as Dt,wa as Sn,wb as Ic,xa as U,xb as Ac,ya as Mo,yb as zo,za as j}from"./chunk-PYRREEUB.js";import{$ as Vs,$a as ic,D as Ls,F as Ne,G as Ns,H as yn,I as Ds,Ia as Qe,J as De,K as Ms,L as bn,M as js,Pa as oc,S as Gs,Ua as wn,V as Us,X as qs,Y as zs,Ya as rc,Z as Hs,_ as Ws,aa as Bs,ba as Ks,c as fa,ca as Js,da as Ys,ea as Xs,fa as Zs,ga as Qs,ha as ec,i as gn,ia as tc,ja as nc,x as Ps}from"./chunk-RNABUEFB.js";import{$a as Ec,Ab as Nc,Eb as Se,Fb as Gc,Gb as xn,Kb as Wo,Vc as Bo,Yb as Qc,Zb as el,_c as Ko,bd as al,d as ua,f as _a,jb as Tc,kb as Cc,lb as Rc,na as de,ob as xc,pb as Oc,qb as $c,rb as Fc,tb as je,ua as vc,ub as Pc,vb as Lc,yb as Rn}from"./chunk-7PATQWTH.js";import{$ as oe,$c as en,$f as F,$i as Ze,$j as ba,A as _i,Al as cn,An as Fo,B as fi,Bf as Wi,Bi as aa,Bl as Ba,Bn as Cs,C as hi,Cg as Qi,Cj as an,Cl as Ka,D as gi,Dd as Pi,Di as Io,Ed as Li,Ei as Ao,Fj as $t,Fm as ds,G as yi,Gi as T,Gj as pa,Gl as ke,Hi as sa,Hl as E,Il as Ja,Ja as co,Jf as Vi,Jl as Ya,Jm as ms,Ka as lo,Kd as H,Kg as Fe,Kk as Ea,La as mo,Le as Di,Ma as po,Mf as Ke,Mg as Ye,Nk as Ta,Nm as ps,Oj as ha,Ok as Ca,Qb as vi,Qf as Bi,Qi as To,Qm as le,R as u,Rb as ki,Re as Mi,Rg as on,Ri as Co,Rl as Xa,Sg as Ct,Sl as ln,T as p,Tg as ko,Tl as dn,Tm as us,Ub as Si,Ue as ji,Ul as mn,Um as _s,V as ye,Va as P,Vl as pn,W as Be,Wa as Yt,Wd as tn,Wk as Ra,Wm as _n,X as ro,Xi as ca,Xj as ga,Xl as re,Xm as fs,Xo as Rs,Y as se,Yh as Rt,Yk as xa,Zc as Zt,Zh as xt,Zj as ya,Zl as Za,_c as Qt,_f as Ki,_j as sn,_l as Qa,aa as St,bb as A,bd as Oi,be as Ni,bm as Ft,bn as hs,ce as nn,cl as Oa,cm as es,cn as gs,df as Gi,dh as ea,dl as $a,dm as ts,eb as we,eh as ta,el as Fa,em as ns,eo as Po,f as J,fb as uo,fh as na,fk as wa,fm as os,gf as Ui,gn as xo,go as Lo,h as oo,ha as bi,hb as xe,hd as _o,hl as Pa,hp as xs,in as Oo,j as pi,ja as wi,jd as fo,jf as qi,jk as va,ka as be,kd as ho,km as Ro,ld as go,ll as La,lm as rs,mc as Ii,md as yo,ml as Na,mm as Pe,mn as ys,na as io,nc as Ai,nd as bo,ng as Je,nl as Da,nn as bs,oc as Ei,od as wo,of as S,og as Oe,ok as ka,ol as Ma,om as is,on as ws,p as Jt,pc as Ti,pd as vo,pg as Ji,pk as Sa,pl as ja,pm as as,pn as vs,qa as ao,qc as Ci,qd as $,qg as Yi,qn as ks,ra as It,rc as Ri,rg as $e,rj as la,rk as Ia,rl as Ga,rm as un,sc as xi,sf as zi,sg as Xi,si as oa,sl as Ua,sn as Ss,ta as so,tb as At,ti as Xe,tj as da,tl as qa,tm as ss,tn as Is,u as Ve,ub as Et,uf as Hi,uj as ma,uk as Aa,ul as za,um as cs,un as As,vd as $i,vf as ne,vg as V,vh as So,vj as ce,vl as Ha,vm as ls,vn as Pt,w as ui,wb as Xt,wd as Fi,wh as R,wi as rn,wj as ve,wl as Wa,wn as Es,xg as Tt,xn as fn,yg as Zi,yi as ra,yn as Ts,zd as G,zi as ia,zj as Ot,zl as Va,zn as $o}from"./chunk-RHQJ6VWC.js";import{AsyncLocalStorage as Gg}from"node:async_hooks";import{readFile as hp}from"node:fs/promises";import gp 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]="20a3a324-d176-5918-8167-5e548be4abc9")}catch{}})();var nr="context-intents.json";function $n(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yp(e,t,n){if(!$n(e))throw new TypeError(`${t} context intent at index ${String(n)} must be an object`);let o=e.included_field_groups;if(typeof e.command!="string"||typeof e.intent!="string"||typeof e.description!="string"||!Array.isArray(o)||!o.every(r=>typeof r=="string")||typeof e.token_budget!="number")throw new TypeError(`${t} context intent at index ${String(n)} has an invalid contract shape`);return{command:e.command,intent:e.intent,description:e.description,included_field_groups:o,token_budget:e.token_budget}}function gl(e,t){let n=Array.isArray(e)?e:$n(e)&&Array.isArray(e.intents)?e.intents:void 0;if(!n)throw new TypeError(`${t} context intents must be an array or an object with an intents array`);return n.map((o,r)=>yp(o,t,r))}async function bp(e){let t=gp.join(e,nr),n;try{n=await hp(t,"utf8")}catch(r){if(Be(r))return[];throw await Ki(e),r}let o;try{o=JSON.parse(n)}catch(r){let i=r instanceof Error?r.message:String(r);throw new TypeError(`Invalid ${nr}: ${i}`,{cause:r})}return gl(o,nr)}function wp(e){if(!$n(e))return;let t=e.contextIntents??e.context_intents;if(t!==void 0)return t;let n=e.default;return $n(n)?n.contextIntents??n.context_intents:void 0}function vp(e){return e.flatMap(t=>{let n=wp(t.module);return n===void 0?[]:gl(n,`package ${t.name}`)})}async function kp(e){let t=await bp(e.pmRoot),n=vp(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function Fn(e,t){let n=await kp(e);return await Vi(n,t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0a4abc17-0fcb-573f-8f89-6e505e112261")}catch{}})();async function yl(e,t,n=Wi){try{await n({pmRoot:e,result:t})}catch{if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let o=t,r=Array.isArray(o.warnings)?o.warnings.filter(i=>typeof i=="string"):[];o.warnings=[...new Set([...r,"context_usage_feedback_write_failed"])].sort()}}}import{createHash as xp}from"node:crypto";import{constants as jt}from"node:fs";import{lstat as bl,mkdir as rr,open as wl}from"node:fs/promises";import me 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]="5434ff6f-95af-5983-88cb-fd360d95cb9e")}catch{}})();function or(e,t){if(typeof e!="string"||e.trim().length===0)throw new TypeError(`Relationship event ${t} must be non-empty`);return e.trim()}function ir(e,t){let n=t.require(e.kind),o=n.direction==="undirected"?[e.source,e.target].sort().join("\0"):`${e.source}\0${e.target}`;return`${n.kind}\0${o}`}function Sp(e){return Object.freeze({...e,...e.payload===void 0?{}:{payload:Object.freeze(structuredClone(e.payload))}})}function Ip(e,t,n,o){let r=n.require(e.kind),i=o.outgoingOne.get(`${r.kind}\0${e.source}`);if(i!==void 0&&i!==t)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let a=o.incomingOne.get(`${r.kind}\0${e.target}`);if(a!==void 0&&a!==t)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let s=ir(e,n),c=o.identities.get(s);if(c!==void 0&&c!==t)throw new TypeError(`Relationship edge already active: ${s}`)}function Ap(e){let t=new Map;for(let n of e)n.action==="remove"?t.delete(n.relationshipId):t.set(n.relationshipId,n.edge);return t}function Ep(e,t,n){if(e.expectedVersion!==void 0&&e.expectedVersion!==t)throw new TypeError(`Relationship event version conflict: expected ${e.expectedVersion}, current ${t}`);let o=or(e.eventId,"eventId");if(n.has(o))throw new TypeError(`Relationship event already exists: ${o}`);if(e.action!=="add"&&e.action!=="remove"&&e.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${e.action}`);if(!Number.isFinite(Date.parse(e.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:o,relationshipId:or(e.relationshipId,"relationshipId"),author:or(e.author,"author"),timestamp:new Date(e.timestamp).toISOString()}}function Tp(e,t,n,o,r,i){let a=n.has(t);if(e.action==="add"&&a)throw new TypeError(`Relationship is already active: ${t}`);if(e.action!=="add"&&!a)throw new TypeError(`Relationship is not active: ${t}`);if(e.action==="remove")return;if(!e.edge)throw new TypeError(`Relationship ${e.action} event requires an edge`);let s=typeof e.edge.source=="string"?e.edge.source.trim():"",c=typeof e.edge.target=="string"?e.edge.target.trim():"";if(!o.has(s)||!o.has(c))throw new TypeError(`Relationship endpoint not found: ${s} -> ${c}`);let l=new Ve([s,c],[e.edge],r).edges()[0];return Ip(l,t,r,i),Sp(l)}var Gt=class{#t;#n;#o=[];#i=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(t,n={}){this.#t=new Set([...t].filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean)),this.#n=n.registry??Jt()}get version(){return this.#o.length}events(){return Object.freeze([...this.#o])}*stream(t={}){let n=t.fromVersion??1,o=t.toVersion??this.version,r=t.batchSize??100;if(!Number.isInteger(n)||n<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${o}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(n>o+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let i=n-1;i<o;i+=r)yield Object.freeze(this.#o.slice(i,Math.min(i+r,o)))}project(t,n,o={}){if(typeof n!="function")throw new TypeError("Relationship event projection requires a reducer");let r=t,i=0,a;for(let s of this.stream({...o,batchSize:256}))for(let c of s)r=n(r,c),i+=1,a=c;return Object.freeze({state:r,version:a?.sequence??Math.max(0,(o.fromVersion??1)-1),processed:i,...a===void 0?{}:{asOf:a.timestamp}})}#a(t,n){let o=this.#n.require(n.kind);this.#r.identities.set(ir(n,this.#n),t),o.outgoing==="one"&&this.#r.outgoingOne.set(`${o.kind}\0${n.source}`,t),o.incoming==="one"&&this.#r.incomingOne.set(`${o.kind}\0${n.target}`,t)}#s(t){let n=this.#n.require(t.kind);this.#r.identities.delete(ir(t,this.#n)),n.outgoing==="one"&&this.#r.outgoingOne.delete(`${n.kind}\0${t.source}`),n.incoming==="one"&&this.#r.incomingOne.delete(`${n.kind}\0${t.target}`)}append(t){let n=Ep(t,this.version,this.#i),o=this.#e.get(n.relationshipId),r=Tp(t,n.relationshipId,this.#e,this.#t,this.#n,this.#r),i=Object.freeze({eventId:n.eventId,relationshipId:n.relationshipId,action:t.action,...r===void 0?{}:{edge:r},author:n.author,timestamp:n.timestamp,...t.reason?.trim()?{reason:t.reason.trim()}:{},sequence:this.version+1});return this.#o.push(i),this.#i.add(n.eventId),o&&this.#s(o),t.action==="remove"?this.#e.delete(n.relationshipId):(this.#e.set(n.relationshipId,r),this.#a(n.relationshipId,r)),i}snapshot(t={}){if(t.atVersion!==void 0&&t.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let n;if(t.atTimestamp!==void 0){let i=Date.parse(t.atTimestamp);if(!Number.isFinite(i))throw new TypeError("Relationship snapshot timestamp must be valid");n=this.#o.filter(a=>Date.parse(a.timestamp)<=i)}else{let i=t.atVersion??this.version;if(!Number.isInteger(i)||i<0||i>this.version)throw new TypeError(`Relationship snapshot version out of range: ${i}`);n=this.#o.slice(0,i)}let o=Ap(n),r=new Ve(this.#t,o.values(),this.#n);return Object.freeze({version:n.at(-1)?.sequence??0,...n.at(-1)?{asOf:n.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(t){if(!Number.isInteger(t.limit)||t.limit<1)throw new TypeError("Relationship event page limit must be positive");let n=Gi("relationship-events",{order:"append-sequence"}),o=t.cursor===void 0?this.version:Number(Ui(t.cursor,n).snapshot);if(!Number.isSafeInteger(o)||o<0||o>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=qi(this.#o.slice(0,o),{cursor:t.cursor,fingerprint:n,limit:t.limit,readId:i=>i.eventId,snapshot:String(o)});return{version:o,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},Cp="relationship-event-store",vl=jt.O_NOFOLLOW;function Pn(e){return ne(e,Cp,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function Ue(e,t="relationships/events.jsonl"){let n=me.resolve(e),o=me.resolve(n,t),r=me.relative(n,o);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${me.sep}`)||me.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await rr(n,{recursive:!0}),(await bl(n)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let i=n;for(let a of r.split(me.sep)){i=me.join(i,a);try{if((await bl(i)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(s){if(ro(s))break;throw s}}return o}async function Ln(e,t,n){let o=new Gt(t,{registry:n}),r,i;try{i=await wl(e,jt.O_RDONLY|vl),r=await i.readFile("utf8")}catch(s){if(ro(s))return{log:o,raw:""};throw s}finally{await i?.close()}let a=r.split(`
2
2
  `);for(let s=0;s<a.length;s+=1){let c=a[s].trim();if(!c)continue;let l;try{l=JSON.parse(c)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${s+1}`)}if(l.sequence!==o.version+1)throw new TypeError(`Invalid relationship event sequence at line ${s+1}`);o.append({eventId:l.eventId,relationshipId:l.relationshipId,action:l.action,...l.edge===void 0?{}:{edge:l.edge},author:l.author,timestamp:l.timestamp,...l.reason===void 0?{}:{reason:l.reason},expectedVersion:o.version})}return{log:o,raw:r}}function Rp(e,t,n,o){let r=Date.parse(t.timestamp),i;return t.action!=="remove"&&t.edge!==void 0&&(i=new Ve(n,[t.edge],o).edges()[0]),e.eventId===t.eventId.trim()&&e.relationshipId===t.relationshipId.trim()&&e.action===t.action&&e.author===t.author.trim()&&Number.isFinite(r)&&e.timestamp===new Date(r).toISOString()&&e.reason===(t.reason?.trim()||void 0)&&At(e.edge)===At(i)}var Nn=class e{#t;#n;#o;#i;#e;constructor(t,n,o,r){this.#t=t.pmRoot,this.#n=n,this.#o=t.registry,this.#i=o,this.#e=r}static async open(t){let n=Object.freeze([...t.nodes]),o=await Ue(t.pmRoot,t.relativePath),r=await Pn(t.pmRoot);try{await Ue(t.pmRoot,o);let{log:i}=await Ln(o,n,t.registry);return new e(t,n,o,i)}finally{await r()}}get path(){return this.#i}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(t){let n=await Pn(this.#t);try{let o=await Ue(this.#t,this.#i),{log:r}=await Ln(o,this.#n,this.#o),i=r.append(t);await rr(me.dirname(o),{recursive:!0}),await Ue(this.#t,o);let a=await wl(o,jt.O_APPEND|jt.O_CREAT|jt.O_WRONLY|vl);try{await a.appendFile(`${JSON.stringify(i)}
3
3
  `,"utf8")}finally{await a.close()}return this.#e=r,i}finally{await n()}}async appendBatch(t,n={}){let o=await Pn(this.#t);try{let r=await Ue(this.#t,this.#i),{log:i,raw:a}=await Ln(r,this.#n,this.#o),s=i.version,c=new Map(i.events().map(d=>[d.eventId,d])),l=[],m=[];for(let d of t){let _=d.eventId.trim(),f=c.get(_);if(f!==void 0){if(n.existingEventPolicy==="skip_identical"&&Rp(f,d,this.#n,this.#o)){m.push(f.eventId);continue}if(n.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${_}`)}let w=i.append(d);c.set(w.eventId,w),l.push(w)}if(l.length>0){let d=a.length===0||a.endsWith(`
4
4
  `)?a:`${a}
@@ -2245,4 +2245,4 @@ compdef _pm pm`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"
2245
2245
  `);M(e.progressEnabled,"writing keyword artifacts"),await oe(t,`${JSON.stringify(e.manifest,null,2)}
2246
2246
  `),await oe(n,`${r}
2247
2247
  `);let i=[];if(e.mode!=="keyword")try{M(e.progressEnabled,"writing vectorization status ledger"),await Cs(e.pmRoot,e.vectorizationLedgerEntries,e.vectorizationEmbeddingMetadata)}catch(a){i.push(`search_vectorization_status_ledger_write_failed:${a instanceof Error?a.message:String(a)}`)}return i}async function jg(e,t){let n=yg(e.mode),o=gg(e),r=e.full===!0;M(o,`start mode=${n}`);let i=A(process.cwd(),t.path);await F(i);let a=hs(await T(i)).settings,s=null;try{s=await ne(i,gs,a.locks.ttl_seconds,R(void 0,"pm-reindex"),!1,a.governance.force_required_for_stale_lock,a.locks.wait_ms)}catch(c){throw c instanceof p&&c.exitCode===u.CONFLICT?new p("Another pm reindex run is already active for this project. Wait for it to finish before starting a new keyword, semantic, or hybrid reindex.",u.CONFLICT,{code:"reindex_already_running",type:"urn:pm-cli:error:reindex_already_running",why:"Semantic reindex can be expensive and duplicate runs compete for the same local embedding model and vector store.",nextSteps:["Check active pm reindex processes before starting another reindex.","Rerun with --progress when you need non-interactive visibility."]}):c}try{let c=vg(a),l=kg(a),m=Cg({requestedMode:n,pmRoot:i,settings:a,extensionEmbedding:c,extensionVectorAdapter:l}),d=n;M(o,"loading item corpus");let _=await Rg({pmRoot:i,settings:a}),f=_.warnings,{documentCandidates:w,metadataDocuments:k}=_;M(o,`loaded_items=${k.length}`);let y=S(),v=Tg(d,y,k),g=Kt.join(i,ri),I=Kt.join(i,ii),x=d==="keyword"?await si(i,w,a.schema,f):k,N=[],W={},O=null,C=Eg(d);if(d==="keyword"&&await xg({pmRoot:i,settings:a,forceFullSemantic:r,extensionEmbedding:c,reindexWarnings:f}),d!=="keyword"){let te=await Dg({pmRoot:i,settings:a,requestedMode:n,activeEmbeddingProvider:m.activeEmbeddingProvider,activeVectorStore:m.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:l,documentCandidates:w,metadataDocuments:k,documentsForKeywordArtifacts:x,forceFullSemantic:r,reindexWarnings:f,semanticWarnings:N,semanticSummary:C,progressEnabled:o});x=te.documentsForKeywordArtifacts,W=te.vectorizationLedgerEntries,O=te.vectorizationEmbeddingMetadata}let ae=await Mg({pmRoot:i,mode:d,manifest:v,documentsForKeywordArtifacts:x,settings:a,vectorizationLedgerEntries:W,vectorizationEmbeddingMetadata:O,progressEnabled:o}),Re=[...await G({path:g,scope:"project",op:"reindex:manifest"}),...await G({path:I,scope:"project",op:"reindex:embeddings"}),...await Pi({mode:d,total_items:k.length})];return M(o,"done"),{ok:!0,mode:d,total_items:k.length,semantic:C,artifacts:{manifest:ri,embeddings:ii},warnings:[...f,...N,...ae,...Re],generated_at:y}}finally{await 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]="df97ccfc-a33f-595d-b4b7-673bfef412c9")}catch{}})();var pp=Symbol("pm.active-extension-host-context");function Q(e){return{fullChangedFields:!0,options:e}}var b=class e{defaults;constructor(t={}){this.defaults={...t.pmRoot===void 0?{}:{path:t.pmRoot},...t.cwd===void 0?{}:{cwd:t.cwd},...t.author===void 0?{}:{author:t.author},...t.noExtensions===void 0?{}:{noExtensions:t.noExtensions}}}static forActiveExtensionHost(t){let n=new e({...t,noExtensions:!0});return n.defaults[pp]=!0,n}run(t,n={}){return Hg({...this.defaults,...n,action:t})}runTyped(t,n={}){return this.run(t,n)}context(t={}){return this.runTyped("context",{options:t})}listAllItemMetadataLight(){return Il(this.defaults.path,this.defaults.cwd)}list(t={}){return this.runTyped("list",{options:t})}async listAllComplete(t={}){return Mn(await this.list(sr(t)))}search(t,n={}){return this.runTyped("search",{query:t,options:n})}get(t,n={}){return this.runTyped("get",{id:t,options:n})}next(t={}){return this.runTyped("next",{options:t})}aggregate(t={}){return this.runTyped("aggregate",{options:t})}stats(t={}){return this.runTyped("stats",{options:t})}duplicates(t={}){return this.runTyped("duplicates",{options:t})}comments(t,n={}){return this.runTyped("comments",{id:t,options:n})}notes(t,n={}){return this.runTyped("notes",{id:t,options:n})}learnings(t,n={}){return this.runTyped("learnings",{id:t,options:n})}files(t,n={}){return this.runTyped("files",{id:t,options:n})}filesDiscover(t,n={}){return this.runTyped("files-discover",{id:t,options:n})}filesLookup(t){return this.runTyped("files-lookup",{options:t})}docs(t,n={}){return this.runTyped("docs",{id:t,options:n})}deps(t,n={}){return this.runTyped("deps",{id:t,options:n})}graph(t,n={},o={}){return this.runTyped("graph",{subcommand:t,...n,options:o})}append(t,n,o={}){return this.runTyped("append",{id:t,...Q(et(o,{body:n}))})}init(t,n={}){return this.runTyped("init",{...t===void 0?{}:{prefix:t},options:n})}config(t,n,o,r,i={}){return this.runTyped("config",{scope:t,configAction:n,...o===void 0?{}:{key:o},...r===void 0?{}:{value:r},options:i})}schema(t,n={}){return this.runTyped("schema",{options:{...n,subcommand:t}})}workflowPolicy(t,n,o={}){return this.runTyped("schema",{name:n,options:{...o,subcommand:t}})}schemaList(){return this.runTyped("schema",{options:{subcommand:"list"}})}schemaShow(t){return this.runTyped("schema",{name:t,options:{subcommand:"show"}})}schemaAddType(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"add-type"}})}schemaRemoveType(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-type"}})}schemaAddStatus(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"add-status"}})}schemaRemoveStatus(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-status"}})}schemaAddField(t,n={}){let{type:o,...r}=n;return this.runTyped("schema",{name:t,options:{...r,fieldType:o,subcommand:"add-field"}})}schemaRemoveField(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-field"}})}schemaListFields(){return this.runTyped("schema",{options:{subcommand:"list-fields"}})}schemaShowField(t){return this.runTyped("schema",{name:t,options:{subcommand:"show-field"}})}schemaApplyPreset(t,n={}){return this.runTyped("schema",{typePreset:t,options:{...n,subcommand:"apply-preset"}})}schemaInferTypes(t={}){return this.runTyped("schema",{options:{...t,subcommand:"add-type",infer:!0}})}schemaRenameType(t,n,o){return this.runTyped("schema",{name:t,options:{...o,subcommand:"rename-type",to:n}})}schemaRenameField(t,n,o,r){return this.runTyped("schema",{name:t,options:{...o,subcommand:"rename-field",to:n,...r?{fieldTypeScope:r}:{}}})}schemaRemapStatus(t,n,o){return this.runTyped("schema",{name:t,options:{...o,subcommand:"remap-status",to:n}})}schemaShowStatus(t){return this.runTyped("schema",{name:t,options:{subcommand:"show-status"}})}profile(t,n={}){return this.runTyped("profile",{options:{...n,subcommand:t}})}profileList(){return this.runTyped("profile",{options:{subcommand:"list"}})}profileShow(t){return this.runTyped("profile",{name:t,options:{subcommand:"show"}})}profileApply(t,n={}){return this.runTyped("profile",{name:t,options:{...n,subcommand:"apply"}})}profileLint(t){return this.runTyped("profile",{name:t,options:{subcommand:"lint"}})}validate(t={}){return this.runTyped("validate",{options:t})}health(t={}){return this.runTyped("health",{options:t})}gc(t={}){return this.runTyped("gc",{options:t})}assurance(t){return this.runTyped("assurance",{options:{...t,subcommand:t.action}})}historyRedact(t,n){return this.runTyped("history-redact",{id:t,options:n})}historyRepair(t,n={}){return this.runTyped("history-repair",{id:t,options:n})}historyRepairAll(t={}){return this.runTyped("history-repair",{options:{...t,all:!0}})}historyAttest(t={}){return this.runTyped("history-attest",{options:t})}historyCompact(t,n={}){return this.runTyped("history-compact",{id:t,options:n})}historyCompactBulk(t){return this.runTyped("history-compact",{options:t})}historyAuthorAcknowledge(t){return this.runTyped("history-author-acknowledge",{historyEvent:(t.events??[]).map(n=>`${n.item_id}:${String(n.line)}`),allActionable:t.all_actionable===!0,dryRun:t.dry_run===!0,planFingerprint:t.plan_fingerprint,limit:t.coordinate_limit,attributedAuthor:t.attributed_author,reviewer:t.reviewer,reason:t.reason})}plan(t,n,o={},r,i){return this.runTyped("plan",{fullChangedFields:!0,...n===void 0?{}:{id:n},...r===void 0?{}:{stepRef:r},...i===void 0?{}:{reorderTo:i},options:et(o,{subcommand:t})})}planCreate(t){return this.plan("create",void 0,t)}planShow(t,n={}){return this.plan("show",t,n)}planAddStep(t,n){return this.plan("add-step",t,n)}planUpdateStep(t,n,o){return this.plan("update-step",t,o,n)}planCompleteStep(t,n,o={}){return this.plan("complete-step",t,o,n)}planBlockStep(t,n,o){return this.plan("block-step",t,o,n)}planReorderStep(t,n,o,r={}){return this.plan("reorder-step",t,r,n,o)}planRemoveStep(t,n,o={}){return this.plan("remove-step",t,o,n)}planLink(t,n,o){return this.plan("link",t,o,n)}planUnlink(t,n,o){return this.plan("unlink",t,o,n)}planDecision(t,n){return this.plan("decision",t,n)}planDiscovery(t,n){return this.plan("discovery",t,n)}planValidation(t,n){return this.plan("validation",t,n)}planResume(t,n){return this.plan("resume",t,n)}planApprove(t,n={}){return this.plan("approve",t,n)}planMaterialize(t,n){return this.plan("materialize",t,n)}create(t={}){return this.runTyped("create",Q(t))}update(t,n={}){return this.runTyped("update",{id:t,...Q(n)})}reopen(t,n,o={}){return this.runTyped("item-reopen",{id:t,reason:n,fullChangedFields:!0,options:o})}close(t,n,o={}){return this.runTyped("close",{id:t,reason:n,...Q(o)})}claim(t,n={}){return this.runTyped("claim",{id:t,...Q(n)})}claimNext(t={}){return this.runTyped("claim",{next:!0,...Q(t)})}release(t,n={}){return this.runTyped("release",{id:t,...Q(n)})}copy(t,n={}){return this.runTyped("copy",{id:t,...Q(n)})}delete(t,n={}){return this.runTyped("delete",{id:t,...Q(n)})}restore(t,n,o={}){return this.runTyped("restore",{fullChangedFields:!0,id:t,options:{...o,target:n}})}focus(t,n={}){return this.runTyped("focus",{...t===void 0?{}:{id:t},...Q(n)})}startTask(t,n={}){return this.runTyped("start-task",{id:t,...Q(n)})}pauseTask(t,n={}){return this.runTyped("pause-task",{id:t,...Q(n)})}closeTask(t,n,o={}){return this.runTyped("close-task",{id:t,reason:n,...Q(o)})}extension(t,n={}){return this.runTyped("extension",{...t===void 0?{}:{target:t},options:n})}extensionList(t={}){return this.extension("list",t)}extensionActivate(t,n={}){return this.runTyped("extension-activate",{target:t,options:n})}extensionDeactivate(t,n={}){return this.runTyped("extension-deactivate",{target:t,options:n})}package(t,n={}){return this.runTyped("package",{...t===void 0?{}:{target:t},options:{...n,vocabulary:"package"}})}packageList(t={}){return this.package("list",t)}packageInstall(t,n={}){return this.runTyped("package-install",{target:t,options:n})}packageUninstall(t,n={}){return this.runTyped("package-uninstall",{target:t,options:n})}packageDoctor(t={}){return this.runTyped("package-doctor",{options:t})}packageManage(t,n={}){return this.runTyped("package-manage",{...t===void 0?{}:{target:t},options:n})}packageDescribe(t,n={}){return this.runTyped("package-describe",{...t===void 0?{}:{target:t},options:n})}packageReload(t={}){return this.runTyped("package-reload",{options:t})}packageCatalog(t={}){return this.runTyped("package-catalog",{options:t})}packageActivate(t,n={}){return this.runTyped("package-activate",{target:t,options:n})}packageDeactivate(t,n={}){return this.runTyped("package-deactivate",{target:t,options:n})}packageMigrate(t={}){return this.package(void 0,{...t,migrate:!0})}upgrade(t,n={}){return this.runTyped("upgrade",{...t===void 0?{}:{target:t},options:n})}};function RT(e={},t={}){return new b(t).context(e)}function xT(e={},t={}){return new b(t).list(e)}function OT(e={},t={}){return new b(t).listAllComplete(e)}function $T(e,t={},n={}){return new b(n).search(e,t)}function FT(e,t={},n={}){return new b(n).get(e,t)}function PT(e={},t={}){return new b(t).next(e)}function LT(e={},t={}){return new b(t).aggregate(e)}function NT(e={},t={}){return new b(t).stats(e)}function DT(e={},t={}){return new b(t).duplicates(e)}function MT(e,t={},n={}){return new b(n).comments(e,t)}function jT(e,t={},n={}){return new b(n).notes(e,t)}function GT(e,t={},n={}){return new b(n).learnings(e,t)}function UT(e,t={},n={}){return new b(n).files(e,t)}function qT(e,t={},n={}){return new b(n).filesDiscover(e,t)}function zT(e,t={}){return new b(t).filesLookup(e)}function HT(e,t={},n={}){return new b(n).docs(e,t)}function WT(e,t={},n={}){return new b(n).deps(e,t)}function VT(e,t={},n={},o={}){return new b(o).graph(e,t,n)}function BT(e,t,n={},o={}){return new b(o).append(e,t,n)}function KT(e,t={},n={}){return new b(n).init(e,t)}function JT(e,t,n,o,r={},i={}){return new b(i).config(e,t,n,o,r)}function YT(e,t={},n={}){return new b(n).schema(e,t)}function XT(e={}){return new b(e).schemaList()}function ZT(e,t={}){return new b(t).schemaShow(e)}function QT(e,t={},n={}){return new b(n).schemaAddType(e,t)}function eC(e,t={},n={}){return new b(n).schemaRemoveType(e,t)}function tC(e,t={},n={}){return new b(n).schemaAddStatus(e,t)}function nC(e,t={},n={}){return new b(n).schemaRemoveStatus(e,t)}function oC(e,t={},n={}){return new b(n).schemaAddField(e,t)}function rC(e,t={},n={}){return new b(n).schemaRemoveField(e,t)}function iC(e={}){return new b(e).schemaListFields()}function aC(e,t={}){return new b(t).schemaShowField(e)}function sC(e,t={},n={}){return new b(n).schemaApplyPreset(e,t)}function cC(e={},t={}){return new b(t).schemaInferTypes(e)}function lC(e,t,n,o={}){return new b(o).schemaRenameType(e,t,n)}function dC(e,t,n,o,r={}){return new b(r).schemaRenameField(e,t,n,o)}function mC(e,t,n,o={}){return new b(o).schemaRemapStatus(e,t,n)}function pC(e,t={}){return new b(t).schemaShowStatus(e)}function uC(e,t={},n={}){return new b(n).profile(e,t)}function _C(e={}){return new b(e).profileList()}function fC(e,t={}){return new b(t).profileShow(e)}function hC(e,t={},n={}){return new b(n).profileApply(e,t)}function gC(e,t={}){return new b(t).profileLint(e)}function yC(e={},t={}){return new b(t).validate(e)}function bC(e={},t={}){return new b(t).health(e)}function wC(e={},t={}){return new b(t).gc(e)}function vC(e,t,n={}){return new b(n).historyRedact(e,t)}function kC(e,t={},n={}){return new b(n).historyRepair(e,t)}function SC(e={},t={}){return new b(t).historyRepairAll(e)}function IC(e,t={},n={}){return new b(n).historyCompact(e,t)}function AC(e,t={}){return new b(t).historyCompactBulk(e)}function EC(e={},t={}){return new b(t).create(e)}function TC(e,t={},n={}){return new b(n).update(e,t)}function CC(e,t,n={},o={}){return new b(o).reopen(e,t,n)}function RC(e,t,n={},o={}){return new b(o).close(e,t,n)}function xC(e,t={},n={}){return new b(n).claim(e,t)}function OC(e={},t={}){return new b(t).claimNext(e)}function $C(e,t={},n={}){return new b(n).release(e,t)}function FC(e,t={},n={}){return new b(n).copy(e,t)}function PC(e,t={},n={}){return new b(n).delete(e,t)}function LC(e,t,n={},o={}){return new b(o).restore(e,t,n)}function NC(e,t={},n={}){return new b(n).focus(e,t)}function DC(e,t={},n={}){return new b(n).startTask(e,t)}function MC(e,t={},n={}){return new b(n).pauseTask(e,t)}function jC(e,t,n={},o={}){return new b(o).closeTask(e,t,n)}function GC(e,t={},n={}){return new b(n).extension(e,t)}function UC(e={},t={}){return new b(t).extensionList(e)}function qC(e,t={},n={}){return new b(n).extensionActivate(e,t)}function zC(e,t={},n={}){return new b(n).extensionDeactivate(e,t)}function HC(e,t={},n={}){return new b(n).package(e,t)}function WC(e={},t={}){return new b(t).packageList(e)}function VC(e,t={},n={}){return new b(n).packageInstall(e,t)}function BC(e,t={},n={}){return new b(n).packageUninstall(e,t)}function KC(e={},t={}){return new b(t).packageDoctor(e)}function JC(e,t={},n={}){return new b(n).packageManage(e,t)}function YC(e,t={},n={}){return new b(n).packageDescribe(e,t)}function XC(e={},t={}){return new b(t).packageReload(e)}function ZC(e={},t={}){return new b(t).packageCatalog(e)}function QC(e,t={},n={}){return new b(n).packageActivate(e,t)}function eR(e,t={},n={}){return new b(n).packageDeactivate(e,t)}function tR(e,t={},n={}){return new b(n).upgrade(e,t)}async function nR(e,t={}){let n=typeof e=="string"?{...t,pmRoot:e}:e??t,o={json:!0,quiet:n.quiet??!0,noExtensions:n.noExtensions??!1,noPager:!0,profile:n.profile??!1,path:n.pmRoot};return hn(n,o)}var dp=Oi(),li=new Gg;function no(){fo(Ii()),ho(Ai()),go(Ei()),yo(Ti()),bo(Ci()),wo(Ri()),vo(xi())}async function up(e,t,n,o){return _o(()=>t===void 0?dp.read(()=>mp(e,n,o)):dp.write(()=>qg(t,()=>mp(e,n,o))))}async function oR(e,t){let n=e.cwd;if(li.getStore()===!0&&n===void 0&&e.noExtensions===!0){let r=A(process.cwd(),e.path);return _o(()=>Fn({pmRoot:r},t))}let o=n??process.cwd();return up(vn({path:e.path,noExtensions:e.noExtensions}),n,o,()=>li.run(!0,t))}async function mp(e,t,n){let o=A(t,e.path);if(e.noExtensions)return no(),Fn({pmRoot:o},()=>n(null));if(!await ye(we(o)))return no(),n(null);let r=null,i;try{let a=await T(o),s=await Zt({pmRoot:o,settings:a,cwd:t,noExtensions:!1}),c=await en({...s,loaded:s.loaded});i={loadResult:s,activationResult:c},fo(c.hooks),ho(c.commands),go(c.parsers),yo(c.preflight),bo(c.services),wo(c.renderers),vo(c.registrations),r={registrations:c.registrations,commands:c.commands,pmRoot:o,packages:s.loaded}}catch(a){no(),console.error("[pm-sdk] extension activation failed; continuing without active extensions:",a)}try{return await Fn({pmRoot:o,packages:r?.packages},()=>n(r))}finally{no(),i&&await Qt(i.loadResult,i.activationResult).catch(()=>{})}}function _p(e,t){let n=Me(e);return t?.registrations.commands.find(o=>Me(o.action)===n)?.command??t?.commands.handlers.find(o=>Me(o.command)===n)?.command}async function Ug(e,t,n,o,r){if(!r)throw new p(`Unsupported native pm action: ${e}`,u.USAGE);let i=_p(e,r);if(!i)throw new p(`Unsupported native pm action: ${e}`,u.USAGE);let a=typeof o.author=="string"&&o.author.trim()?o.author.trim():"pm-extension",s=await Li({command:Sn(i),args:U(n.args??t.args),options:Mo(t,n),global:o,pm_root:r.pmRoot,sdk:kl(r.pmRoot,b.forActiveExtensionHost({pmRoot:r.pmRoot,author:a}),a,Sn(i))});if(!s.handled){let c=s.warnings.length>0?` (${s.warnings.join(", ")})`:"";throw new p(`Unsupported native pm action: ${e}${c}`,u.USAGE)}return s.result}async function qg(e,t){let n=process.cwd();process.chdir(e);try{return await t()}finally{process.chdir(n)}}function zg(e){let t=K(e,"action"),n=Me(t),o=fe(cr,n),r=o?.action??n,i={...e,action:r};return o?.options!==void 0&&(i.options={...o.options,...ao(e.options)}),r==="package"&&(i.options={...ao(i.options),vocabulary:"package"}),{action:r,args:i}}async function Hg(e){let t=zg(e),n=vn(t.args),o=mc(t.action),r=h(t.args,"cwd"),i=r??process.cwd();t.action==="init"&&(n[rc]=i),(t.action!=="init"||n.path!==void 0||(process.env.PM_PATH?.trim().length??0)>0)&&(n.path=A(i,n.path));try{return t.action==="history-attest"?await ci(t.action,t.args,n,null):e[pp]===!0||li.getStore()===!0?await ci(t.action,t.args,n,null):await up(n,r,i,a=>ci(t.action,t.args,n,a))}finally{o&&Wr()}}function rR(e=Si){return e.map(t=>{let n=Me(t),o=fe(cr,n),r=o?.action??n,i=fe(Hr,r)!==void 0;return{action:t,resolved_action:r,covered:i,route:i?o?"alias":"native":"missing"}})}async function ci(e,t,n,o){let r=Do(t,e),i=fe(Hr,e),a=i?void 0:_p(e,o),s=a===void 0?e:`extension:${a}`;Mi(s,r),ji(s,r);let c={action:e,args:t,options:r,id:h(t,"id"),force:t.force===!0||r.force===!0,global:n,activeExtensions:o},l=i?await i(c):await Ug(e,t,r,n,o);if(e==="history-attest")return l;{r.resolvedOutputFormat="json";let m=Bi(s,r,l);return await yl(A(process.cwd(),n.path),m),m}}var Wg={closeManyOptionsFromFlat:In,extensionOptionsFromArgs:Mo,globalOptions:vn,mutationListOptions:pc,normalizeActionName:Me,normalizeCommandPath:Sn,normalizeMcpUpdateOptions:_c,normalizeMcpOptionsArrays:dc,optionsWithAuthor:Do,readRequiredString:K,readScalarString:sc,readScalarStringAllowBlank:cc,readStringArray:U,updateManyOptionsFromFlat:An,withAddNoteOption:Lt,withFilesDiscoveryOptions:kn,withMutationCompaction:j};(process.env.NODE_ENV==="test"||process.env.VITEST!==void 0||process.env.VITEST_WORKER_ID!==void 0)&&(globalThis.__pmCliActionRunnerTestHooks=Wg);export{nr as a,gl as b,bp as c,vp as d,kp as e,Fn as f,Gt as g,Nn as h,kl as i,$p as j,Dn as k,sr as l,Sl as m,Mn as n,jp as o,Tl as p,xl as q,$l as r,Nl as s,pr as t,ur as u,_r as v,fr as w,uu as x,ql as y,vr as z,ed as A,id as B,ad as C,st as D,$r as E,H_ as F,lw as G,dw as H,Lr as I,cd as J,Ew as K,Tw as L,dd as M,ud as N,Vw as O,cf as P,qr as Q,df as R,mf as S,Ed as T,Td as U,Cd as V,Rd as W,xd as X,gv as Y,yv as Z,bv as _,wv as $,Od as aa,$d as ba,Ld as ca,Md as da,jd as ea,Gd as fa,K as ga,Wr as ha,KS as ia,JS as ja,YS as ka,XS as la,ZS as ma,Xd as na,QS as oa,uh as pa,hh as qa,wh as ra,vh as sa,kh as ta,z as ua,Sh as va,Ih as wa,Ah as xa,Eh as ya,Br as za,tm as Aa,dt as Ba,Vr as Ca,nm as Da,Th as Ea,om as Fa,Ch as Ga,Rh as Ha,xh as Ia,Oh as Ja,$h as Ka,jh as La,sm as Ma,Gh as Na,Bh as Oa,eg as Pa,ng as Qa,_g as Ra,jg as Sa,b as Ta,RT as Ua,xT as Va,OT as Wa,$T as Xa,FT as Ya,PT as Za,LT as _a,NT as $a,DT as ab,MT as bb,jT as cb,GT as db,UT as eb,qT as fb,zT as gb,HT as hb,WT as ib,VT as jb,BT as kb,KT as lb,JT as mb,YT as nb,XT as ob,ZT as pb,QT as qb,eC as rb,tC as sb,nC as tb,oC as ub,rC as vb,iC as wb,aC as xb,sC as yb,cC as zb,lC as Ab,dC as Bb,mC as Cb,pC as Db,uC as Eb,_C as Fb,fC as Gb,hC as Hb,gC as Ib,yC as Jb,bC as Kb,wC as Lb,vC as Mb,kC as Nb,SC as Ob,IC as Pb,AC as Qb,EC as Rb,TC as Sb,CC as Tb,RC as Ub,xC as Vb,OC as Wb,$C as Xb,FC as Yb,PC as Zb,LC as _b,NC as $b,DC as ac,MC as bc,jC as cc,GC as dc,UC as ec,qC as fc,zC as gc,HC as hc,WC as ic,VC as jc,BC as kc,KC as lc,JC as mc,YC as nc,XC as oc,ZC as pc,QC as qc,eR as rc,tR as sc,nR as tc,oR as uc,Hg as vc,rR as wc};
2248
- //# sourceMappingURL=chunk-6ZDKKOKM.js.map
2248
+ //# sourceMappingURL=chunk-FIJOSX2C.js.map
@@ -1,2 +1,2 @@
1
- import{$d as C,Gl as y,R as g,T as b,Uf as z,Wd as I,Xd as k,Yd as D,Zd as O,_d as _,bc as M,cc as F,ce as V,g as N,h as p,hc as v,j as E,k as L,l as w,lf as $,mf as R,qf as B,rh as G,sh as T}from"./chunk-4PNPDT2N.js";import{Command as se}from"commander";(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]="df7f766c-1121-5712-b562-423d2cda95ce")}catch{}})();function Ke(e){return new se().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{z(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the result encoding for reads and mutations").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume continuation_kind=output_cursor").option("--output-row-contract","Include row selectors, encoding metadata, and read-output receipts").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--all","Reveal every public command and compatibility alias").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").exitOverride()}(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]="8efedca0-725e-520f-ad06-825a0cccddaa")}catch{}})();var U=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),W=new Map([["files","discover"],["item","complete"]]),re=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function j(e){let t=p(e?.trim().toLowerCase()??"");return U.has(t)||W.has(t)}function ae(e,t,n){let o=U.has(n)?t+1:void 0,i=_(e.slice(t+1));if(i===void 0)return o;let r=t+1+i,a=`${n} ${e[r]}`,s=p(a);return s===a?n==="item"&&e[r]==="complete"?r+1:o:j(s)?P(e,r,s):void 0}function P(e,t,n){if(["history","context","ctx","update","close","item"].includes(n))return ae(e,t,n);let o=W.get(n);if(o===void 0)return t+1;let i=e[t+1]?.toLowerCase()===o;return t+(i?2:1)}function le(e){let t=new Map;for(let n of y(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function ce(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function ue(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let o=n.get(e);return o!==void 0&&o.value_type!=="boolean"}function de(e,t,n,o,i){let r=0;for(let a=t;a<e.length;a+=1){let s=e[a];if(s==="--")break;if(s==="--id"){a+=1;continue}if(!s.startsWith("--id=")){if(!s.startsWith("-")){if(a<o)return!0;r+=1;continue}ue(s,e[a+1],i)&&(a+=1)}}return r>(re.get(p(n))??0)}function q(e){let t=_(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(n!=="context"&&n!=="ctx"&&!j(n))return{argv:[...e],changed:!1,conflict:!1};let o=P(e,t,n);if(o===void 0)return{argv:[...e],changed:!1,conflict:!1};let i=o>t+1?`${p(e.slice(t,o-1).join(" "))} ${e[o-1]}`:n,r=le(i),a=ce(e),s=a[0];if(!s||!s.value?.trim())return{argv:[...e],changed:!1,conflict:!1};if(a.length>1||de(e,o,i,s.index,r))return{argv:[...e],changed:!1,conflict:!0,itemId:s.value};let l=[...e.slice(0,s.index),...e.slice(s.index+s.consumed)],c=_(l),u=P(l,c,n);return l.splice(u,0,s.value),{argv:l,changed:!0,conflict:!1,itemId:s.value}}(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]="f05cec18-5e48-5151-8ada-577c9df5885d")}catch{}})();var fe=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),pe=new Set(["toon","json"]);function me(e,t,n){let o=e[t];if(k.has(o))return n.booleanFlags.add(o),1;let i=o.indexOf("="),r=i>0?o.slice(0,i):o;if(!I.has(r))return 1;let a=i>0?o.slice(i+1):void 0,s=a===void 0&&O(r,e[t+1]),l=a??(s?e[t+1]:void 0);return r==="--author"?n.author=l??"":typeof l=="string"&&l.length>0&&(fe.has(r)?n.outputValues:n.pathValues).set(r,l),s?2:1}function he(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=me(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions")||["history attest","history-attest"].includes(J(e)??""),noPager:t.booleanFlags.has("--no-pager"),json:t.booleanFlags.has("--json")?t.outputValues.get("--output-format")!=="toon":t.outputValues.get("--output-format")==="json",quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...pe.has(t.outputValues.get("--output-format"))?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function X(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(k.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(I.has(o)){n+=O(o,e[n+1])?2:1;continue}if(D(o)){n+=1;continue}t.push(o),n+=1}return t}function ge(e){let t=X(e);if(t[0]?.trim().toLowerCase()==="help"){let o=[];for(let i=1;i<t.length;i+=1){let r=t[i];if(r.startsWith("-"))break;o.push(r.trim().toLowerCase())}return{requested:!0,commandPathTokens:o}}if(t.findIndex(o=>o==="--help"||o==="-h")<0)return{requested:!1,commandPathTokens:[]};let n=[];for(let o of t){if(o.startsWith("-"))break;n.push(o.trim().toLowerCase())}return{requested:!0,commandPathTokens:n}}function S(e){return _(e)}function be(e){return C(e)}function ye(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:ge(e).requested}function lt(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(r=>process.env[r]),o=()=>{for(let[r,a]of t.entries()){let s=n[r];s===void 0?delete process.env[a]:process.env[a]=s}},i=he(e);return ye(e,i)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var _e=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function Ie(e){let t=S(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!_e.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var we=new Set(["pm","pm-cli"]);function ve(e,t){let n=S(e);if(n===void 0)return e;let o=e[n];return we.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function ke(e,t){let n=S(e);if(n!==void 0&&e[n]==="help"){let s=S(e.slice(n+1));n=s===void 0?void 0:n+1+s}if(n===void 0)return e;let o=e[n],i=L[o.trim().toLowerCase()];if(!i)return e;let r=i.split(" "),a=[...e.slice(0,n),...r,...e.slice(n+1)];return t.push({from:o,to:r,reason:"command_alias",confidence:"high"}),a}function x(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function K(e){return x(e).replace(/-/g,"")}function Y(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function Ce(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function Te(e,t){let n=t??y(e),o=new Map,i=new Map,r=new Map,a=new Set;for(let s of n){let l=Ce(s);if(l.length===0)continue;let c=`--${x(l[0])}`;for(let f of l)Y(o,x(f),c),Y(i,K(f),c);let u=K(c);r.has(c)||r.set(c,u),s.list===!0&&a.add(c)}return{canonicalByNormalized:o,canonicalByCompact:i,canonicalComparables:[...r.entries()].map(([s,l])=>({canonicalFlag:s,comparable:l})),listCanonicalFlags:a}}function Z(e,t){let n=x(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let i=n.replace(/-/g,""),r=t.canonicalByCompact.get(i);if(typeof r=="string")return{flag:r,reason:"flag_alias",confidence:"high"};let a=i.length>=8?2:1,s=Number.POSITIVE_INFINITY,l,c=!1;for(let u of t.canonicalComparables){let f=v(i,u.comparable,a);if(f!==null){if(f<s){s=f,l=u.canonicalFlag,c=!1;continue}f===s&&l!==u.canonicalFlag&&(c=!0)}}return!l||c||!Number.isFinite(s)||s<=0?null:{flag:l,reason:"flag_typo",confidence:s>=2?"medium":"high"}}function ct(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function Se(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],i=n[3];return i.length===0?null:{key:o,value:i}}function xe(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),i=o>=0?e.slice(0,o):e,r=o>=0?e.slice(o+1):void 0,a=Z(i,t);if(!a)return{tokens:[e]};let s=r===void 0?a.flag:`${a.flag}=${r}`;return s===e?{tokens:[e]}:{tokens:[s],event:{from:e,to:[s],reason:a.reason,confidence:a.confidence}}}function Ae(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let i=e[o];n=i==="--path"||i==="--pm-path"}return t}function Ee(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function Oe(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function Pe(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let i=[],r=t+1;for(;r<e.length&&e[r]!=="--"&&!e[r].startsWith("-")&&(i.length===0||o.has(n.flag));)i.push(e[r]),r+=1;let a=i.length===0?1:1+i.length;return{originalTokens:e.slice(t,t+a),value:i.length===0?void 0:i.join(","),consumed:a}}function Ne(e,t,n,o){let i=e.get(n);if(i){i.values.push(o.value),i.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function Le(e,t){let n=[],o=[];for(let[i,r]of e){if(!(r.occurrences>=2||t.has(i)&&r.originalTokens.length>2)){o.push({outputIndex:r.outputIndex,tokens:r.originalTokens});continue}let a=`${i}=${r.values.join(",")}`;o.push({outputIndex:r.outputIndex,tokens:[a]}),n.push({from:`${i} (x${r.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function Me(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function Fe(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let i=[],r=new Map,a=0;for(;a<e.length;){let c=e[a];if(c==="--"){i.push(...e.slice(a));break}if(n.has(c)){a=Oe(e,a,i);continue}let u=Ee(c);if(!u||!t.has(u.flag)){i.push(c),a+=1;continue}let f=Pe(e,a,u,o);if(f.value===void 0){i.push(c),a+=f.consumed;continue}Ne(r,i,u.flag,{originalTokens:f.originalTokens,value:f.value}),a+=f.consumed}let{events:s,splices:l}=Le(r,o);return Me(i,l),{argv:i,events:s}}var H=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function De(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],i=H.get(o);return i!==void 0&&i.has(n)}function Ve(e,t,n){if(t!=="test")return e;let o=[],i=0;for(;i<e.length;){let r=e[i];if(r==="--")return o.push(...e.slice(i)),o;let a=H.get(r),s=a?e[i+1]:void 0;if(!a||typeof s!="string"||!a.has(s)){o.push(r),i+=1;continue}let l=i+2;for(;l<e.length&&!e[l].startsWith("-");)l+=1;if(l-(i+2)!==1){o.push(r),i+=1;continue}let c=e[i+2],u=`${s}=${c}`;o.push(r,u),n.push({from:`${r} ${s} ${c}`,to:[r,u],reason:"bare_key_value",confidence:"high"}),i+=3}return o}function $e(e,t,n,o){let i=[],r=Ae(e);for(let a=0;a<e.length;a+=1){let s=e[a];if(s==="--"){i.push(...e.slice(a));break}let l=r.has(a),c=i[i.length-1];if(s.startsWith("--")){let h=xe(s,t,l);i.push(...h.tokens),h.event&&o.push(h.event);continue}let u=Se(s,l);if(!u||typeof c=="string"&&c.startsWith("-")&&!c.includes("=")||["search","comments","notes","learnings"].includes(n)||De(n,i)){i.push(s);continue}let f=Z(u.key,t);if(!f){i.push(s);continue}let m=u.value.startsWith("-")?[`${f.flag}=${u.value}`]:[f.flag,u.value];i.push(...m),o.push({from:s,to:m,reason:"bare_key_value",confidence:f.confidence})}return i}function Re(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--verify"){let o=e[t+1];if(o===void 0||o==="--")throw new b("history attest --verify requires a bundle file.",g.USAGE);e.splice(t,2,`--verify=${o}`)}else(I.has(n)||n==="--output"||n==="--hash-algorithm")&&(t+=1)}}function Be(e,t){if(!e.some(o=>o==="--help"||o==="-h"))return;let n=new Set(y(t).flatMap(o=>[o.flag,...o.aliases??[],...o.short===void 0?[]:[o.short]]));for(let o=0;o<e.length;o+=1){let i=e[o];if(i==="--")break;i!=="--help"&&i!=="-h"||n.has(e[o-1])&&!k.has(e[o-1])&&(e[o-1]=i)}}function ut(e){let t=[],n=ve(e,t),o=Ie(n);(o.length!==n.length||o.some((h,ie)=>h!==n[ie]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let i=ke(o,t),r=q(i);if(r.conflict)throw new b("Provide the item id either positionally or with --id, not both.",g.USAGE);r.changed&&t.push({from:`--id ${r.itemId}`,to:[r.itemId],reason:"item_id_alias",confidence:"high"});let a=be(r.argv),s=J(r.argv),l=p(s??a??""),c=Te(s??a),u=$e(r.argv,c,l,t),f=Ve(u,l,t),m=Fe(f,c.listCanonicalFlags,I,a==="create"?new Set(["--tags"]):new Set);for(let h of m.events)t.push(h);return Be(m.argv,s??a),s==="history attest"&&Re(m.argv),{argv:m.argv,commandName:a,trace:t}}function J(e){let t=X(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase(),i=N(t);return i?i.canonical:(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function dt(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}(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]="fb625cd9-f8a8-56cf-88ab-abef64051497")}catch{}})();function gt(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new b("--author requires a non-empty value.",g.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=G();T(t);let o=!1;return()=>{o||(o=!0,n===void 0?T(void 0):T(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]="d0e60f7e-e0a8-5ef4-9af7-4a1f102ccb7d")}catch{}})();var d=Object.freeze({clock:"PM_CLOCK",tickMs:"PM_CLOCK_TICK_MS",seed:"PM_SEED"});function A(e,t,n,o){return new b(e,g.USAGE,{code:"invalid_reproducible_process_environment",reason:t,field:n,required:`${d.clock} and ${d.seed}; ${d.tickMs} is optional`,nextSteps:[`Set ${d.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${d.seed} to a non-empty reproducibility seed.`,`Optionally set ${d.tickMs} to a non-negative integer; it defaults to 1.`,"Unset all three variables to retain normal wall-clock and cryptographic-random behavior."],recovery:{recovery_mode:"compact",provided_fields:o,missing_required_fields:t==="incomplete"?[d.clock,d.seed].filter(i=>!o.includes(i)):void 0}})}function ze(e){let t=e[d.clock],n=e[d.tickMs],o=e[d.seed],i=[[d.clock,t],[d.tickMs,n],[d.seed,o]].filter(a=>a[1]!==void 0).map(([a])=>a);if(i.length===0)return;if(t===void 0||o===void 0)throw A("Reproducible process execution requires PM_CLOCK and PM_SEED together.","incomplete",t===void 0?d.clock:d.seed,i);if(o.trim().length===0)throw A(`${d.seed} must not be empty.`,"invalid_value",d.seed,i);if(!B(t))throw A(`${d.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`,"invalid_value",d.clock,i);let r=n===void 0?1:Number(n);if(n?.trim().length===0||!Number.isSafeInteger(r)||r<0)throw A(`${d.tickMs} must be a non-negative integer.`,"invalid_value",d.tickMs,i);return $({clock:t,seed:o,tickMs:r})}function Ge(e){let t=ze(e);return t===void 0?n=>n():R(t)}async function vt(e,t){return Ge(e)(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]="7249e95a-4744-55b8-8b83-2d84f3e48805")}catch{}})();var Q=new Set([...Object.values(M),...F,"--full","--brief","--compact","--summary","--fields","--section","--token-budget"]),ee=new Set(["--full-changed-fields","--no-changed-fields","--id-only"]);function te(e){let t=e.split("=",1)[0].replaceAll("_","-");return Q.has(t)||t.length>=5&&[...Q].some(n=>n.startsWith(t))}function At(e,t){let n=e.split("=",1)[0].replaceAll("_","-");return te(n)?!ee.has(t):ee.has(n)?!te(t):!0}function ne(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function Et(e){if(!(!Array.isArray(e)||e.length===0))return C(e)}function Ue(e,t){let n=ne(t);if(!n)return;let o=y(e).find(i=>i.flag===n||i.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function Ot(e,t,n){let o=[...e],i=o.indexOf("--"),r=i<0?o.length:i;for(let a of n){let s=ne(a);if(!s||o.slice(0,r).some(u=>u===s||u.startsWith(`${s}=`)))continue;let l=Ue(t,s),c=l?[s,l]:[s];o.splice(r,0,...c),r+=c.length}return o.length===e.length?void 0:V(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]="bd9a8d3b-bc6f-5309-a3fb-7e5f41ef9dab")}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]="12066389-daef-5fce-b7a6-0ecffa926d66")}catch{}})();function Vt(e,t){let n=e.trim().split(/\s+/u);if(!(n.length<2||t.includes(n.join(" "))))for(let o=1;o<n.length;o+=1){if(!t.includes(n.slice(0,o).join(" ")))return;let i=n.slice(o).join(" "),r=w(i),a=new Set(t.filter(s=>s===i||s.endsWith(` ${i}`)||s===r?.canonical).map(s=>w(s)?.canonical??s).filter(s=>t.includes(s)));if(a.size>0)return a.size===1?[...a][0]:void 0}}var We={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"],start:["start-task"]};function oe(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let i=n.split(" "),r=We[o]?.indexOf(p(n));if(r!==void 0&&r>=0)return r;if(n===o)return 10;if(i.includes(o))return 11;if(i.some(l=>l.startsWith(o)))return 12;let a=o.length>=5?2:1,s=Number.POSITIVE_INFINITY;for(let l of i){let c=v(l,o,a);c!==null&&(s=Math.min(s,c))}return Number.isFinite(s)?20+s:n.includes(o)?30:Number.POSITIVE_INFINITY}function $t(e,t){return e.map(n=>({path:n,score:oe(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}function Rt(e,t,n){let o=new Set(t),i=E.filter(s=>s.lifecycle==="deprecated").slice().sort((s,l)=>l.alias.length-s.alias.length),r=[],a=e.flatMap(s=>{let l=i.find(u=>s===u.alias||s.startsWith(`${u.alias} `)),c=s;if(l){let u=s.slice(l.alias.length);if(!o.has(`${l.canonical}${u}`))return[];c=`${l.canonical_argv.join(" ")}${u}`}return n!==void 0&&oe(s,n)<10&&r.push(c),[c]});return[...new Set(r.length>0?r:a)]}export{Ke as a,j as b,q as c,he as d,X as e,ge as f,S as g,be as h,lt as i,Ie as j,ct as k,Fe as l,Ve as m,ut as n,dt as o,gt as p,d as q,ze as r,Ge as s,vt as t,te as u,At as v,Et as w,Ue as x,Ot as y,Vt as z,oe as A,$t as B,Rt as C};
2
- //# sourceMappingURL=chunk-VMCSTFSO.js.map
1
+ import{$d as C,Gl as y,R as g,T as b,Uf as z,Wd as I,Xd as k,Yd as D,Zd as O,_d as _,bc as M,cc as F,ce as V,g as N,h as p,hc as v,j as E,k as L,l as w,lf as $,mf as R,qf as B,rh as G,sh as T}from"./chunk-RHQJ6VWC.js";import{Command as se}from"commander";(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]="df7f766c-1121-5712-b562-423d2cda95ce")}catch{}})();function Ke(e){return new se().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{z(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the result encoding for reads and mutations").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume continuation_kind=output_cursor").option("--output-row-contract","Include row selectors, encoding metadata, and read-output receipts").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--all","Reveal every public command and compatibility alias").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").exitOverride()}(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]="8efedca0-725e-520f-ad06-825a0cccddaa")}catch{}})();var U=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),W=new Map([["files","discover"],["item","complete"]]),re=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function j(e){let t=p(e?.trim().toLowerCase()??"");return U.has(t)||W.has(t)}function ae(e,t,n){let o=U.has(n)?t+1:void 0,i=_(e.slice(t+1));if(i===void 0)return o;let r=t+1+i,a=`${n} ${e[r]}`,s=p(a);return s===a?n==="item"&&e[r]==="complete"?r+1:o:j(s)?P(e,r,s):void 0}function P(e,t,n){if(["history","context","ctx","update","close","item"].includes(n))return ae(e,t,n);let o=W.get(n);if(o===void 0)return t+1;let i=e[t+1]?.toLowerCase()===o;return t+(i?2:1)}function le(e){let t=new Map;for(let n of y(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function ce(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function ue(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let o=n.get(e);return o!==void 0&&o.value_type!=="boolean"}function de(e,t,n,o,i){let r=0;for(let a=t;a<e.length;a+=1){let s=e[a];if(s==="--")break;if(s==="--id"){a+=1;continue}if(!s.startsWith("--id=")){if(!s.startsWith("-")){if(a<o)return!0;r+=1;continue}ue(s,e[a+1],i)&&(a+=1)}}return r>(re.get(p(n))??0)}function q(e){let t=_(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(n!=="context"&&n!=="ctx"&&!j(n))return{argv:[...e],changed:!1,conflict:!1};let o=P(e,t,n);if(o===void 0)return{argv:[...e],changed:!1,conflict:!1};let i=o>t+1?`${p(e.slice(t,o-1).join(" "))} ${e[o-1]}`:n,r=le(i),a=ce(e),s=a[0];if(!s||!s.value?.trim())return{argv:[...e],changed:!1,conflict:!1};if(a.length>1||de(e,o,i,s.index,r))return{argv:[...e],changed:!1,conflict:!0,itemId:s.value};let l=[...e.slice(0,s.index),...e.slice(s.index+s.consumed)],c=_(l),u=P(l,c,n);return l.splice(u,0,s.value),{argv:l,changed:!0,conflict:!1,itemId:s.value}}(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]="f05cec18-5e48-5151-8ada-577c9df5885d")}catch{}})();var fe=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),pe=new Set(["toon","json"]);function me(e,t,n){let o=e[t];if(k.has(o))return n.booleanFlags.add(o),1;let i=o.indexOf("="),r=i>0?o.slice(0,i):o;if(!I.has(r))return 1;let a=i>0?o.slice(i+1):void 0,s=a===void 0&&O(r,e[t+1]),l=a??(s?e[t+1]:void 0);return r==="--author"?n.author=l??"":typeof l=="string"&&l.length>0&&(fe.has(r)?n.outputValues:n.pathValues).set(r,l),s?2:1}function he(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=me(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions")||["history attest","history-attest"].includes(J(e)??""),noPager:t.booleanFlags.has("--no-pager"),json:t.booleanFlags.has("--json")?t.outputValues.get("--output-format")!=="toon":t.outputValues.get("--output-format")==="json",quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...pe.has(t.outputValues.get("--output-format"))?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function X(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(k.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(I.has(o)){n+=O(o,e[n+1])?2:1;continue}if(D(o)){n+=1;continue}t.push(o),n+=1}return t}function ge(e){let t=X(e);if(t[0]?.trim().toLowerCase()==="help"){let o=[];for(let i=1;i<t.length;i+=1){let r=t[i];if(r.startsWith("-"))break;o.push(r.trim().toLowerCase())}return{requested:!0,commandPathTokens:o}}if(t.findIndex(o=>o==="--help"||o==="-h")<0)return{requested:!1,commandPathTokens:[]};let n=[];for(let o of t){if(o.startsWith("-"))break;n.push(o.trim().toLowerCase())}return{requested:!0,commandPathTokens:n}}function S(e){return _(e)}function be(e){return C(e)}function ye(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:ge(e).requested}function lt(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(r=>process.env[r]),o=()=>{for(let[r,a]of t.entries()){let s=n[r];s===void 0?delete process.env[a]:process.env[a]=s}},i=he(e);return ye(e,i)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var _e=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function Ie(e){let t=S(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!_e.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var we=new Set(["pm","pm-cli"]);function ve(e,t){let n=S(e);if(n===void 0)return e;let o=e[n];return we.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function ke(e,t){let n=S(e);if(n!==void 0&&e[n]==="help"){let s=S(e.slice(n+1));n=s===void 0?void 0:n+1+s}if(n===void 0)return e;let o=e[n],i=L[o.trim().toLowerCase()];if(!i)return e;let r=i.split(" "),a=[...e.slice(0,n),...r,...e.slice(n+1)];return t.push({from:o,to:r,reason:"command_alias",confidence:"high"}),a}function x(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function K(e){return x(e).replace(/-/g,"")}function Y(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function Ce(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function Te(e,t){let n=t??y(e),o=new Map,i=new Map,r=new Map,a=new Set;for(let s of n){let l=Ce(s);if(l.length===0)continue;let c=`--${x(l[0])}`;for(let f of l)Y(o,x(f),c),Y(i,K(f),c);let u=K(c);r.has(c)||r.set(c,u),s.list===!0&&a.add(c)}return{canonicalByNormalized:o,canonicalByCompact:i,canonicalComparables:[...r.entries()].map(([s,l])=>({canonicalFlag:s,comparable:l})),listCanonicalFlags:a}}function Z(e,t){let n=x(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let i=n.replace(/-/g,""),r=t.canonicalByCompact.get(i);if(typeof r=="string")return{flag:r,reason:"flag_alias",confidence:"high"};let a=i.length>=8?2:1,s=Number.POSITIVE_INFINITY,l,c=!1;for(let u of t.canonicalComparables){let f=v(i,u.comparable,a);if(f!==null){if(f<s){s=f,l=u.canonicalFlag,c=!1;continue}f===s&&l!==u.canonicalFlag&&(c=!0)}}return!l||c||!Number.isFinite(s)||s<=0?null:{flag:l,reason:"flag_typo",confidence:s>=2?"medium":"high"}}function ct(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function Se(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],i=n[3];return i.length===0?null:{key:o,value:i}}function xe(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),i=o>=0?e.slice(0,o):e,r=o>=0?e.slice(o+1):void 0,a=Z(i,t);if(!a)return{tokens:[e]};let s=r===void 0?a.flag:`${a.flag}=${r}`;return s===e?{tokens:[e]}:{tokens:[s],event:{from:e,to:[s],reason:a.reason,confidence:a.confidence}}}function Ae(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let i=e[o];n=i==="--path"||i==="--pm-path"}return t}function Ee(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function Oe(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function Pe(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let i=[],r=t+1;for(;r<e.length&&e[r]!=="--"&&!e[r].startsWith("-")&&(i.length===0||o.has(n.flag));)i.push(e[r]),r+=1;let a=i.length===0?1:1+i.length;return{originalTokens:e.slice(t,t+a),value:i.length===0?void 0:i.join(","),consumed:a}}function Ne(e,t,n,o){let i=e.get(n);if(i){i.values.push(o.value),i.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function Le(e,t){let n=[],o=[];for(let[i,r]of e){if(!(r.occurrences>=2||t.has(i)&&r.originalTokens.length>2)){o.push({outputIndex:r.outputIndex,tokens:r.originalTokens});continue}let a=`${i}=${r.values.join(",")}`;o.push({outputIndex:r.outputIndex,tokens:[a]}),n.push({from:`${i} (x${r.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function Me(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function Fe(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let i=[],r=new Map,a=0;for(;a<e.length;){let c=e[a];if(c==="--"){i.push(...e.slice(a));break}if(n.has(c)){a=Oe(e,a,i);continue}let u=Ee(c);if(!u||!t.has(u.flag)){i.push(c),a+=1;continue}let f=Pe(e,a,u,o);if(f.value===void 0){i.push(c),a+=f.consumed;continue}Ne(r,i,u.flag,{originalTokens:f.originalTokens,value:f.value}),a+=f.consumed}let{events:s,splices:l}=Le(r,o);return Me(i,l),{argv:i,events:s}}var H=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function De(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],i=H.get(o);return i!==void 0&&i.has(n)}function Ve(e,t,n){if(t!=="test")return e;let o=[],i=0;for(;i<e.length;){let r=e[i];if(r==="--")return o.push(...e.slice(i)),o;let a=H.get(r),s=a?e[i+1]:void 0;if(!a||typeof s!="string"||!a.has(s)){o.push(r),i+=1;continue}let l=i+2;for(;l<e.length&&!e[l].startsWith("-");)l+=1;if(l-(i+2)!==1){o.push(r),i+=1;continue}let c=e[i+2],u=`${s}=${c}`;o.push(r,u),n.push({from:`${r} ${s} ${c}`,to:[r,u],reason:"bare_key_value",confidence:"high"}),i+=3}return o}function $e(e,t,n,o){let i=[],r=Ae(e);for(let a=0;a<e.length;a+=1){let s=e[a];if(s==="--"){i.push(...e.slice(a));break}let l=r.has(a),c=i[i.length-1];if(s.startsWith("--")){let h=xe(s,t,l);i.push(...h.tokens),h.event&&o.push(h.event);continue}let u=Se(s,l);if(!u||typeof c=="string"&&c.startsWith("-")&&!c.includes("=")||["search","comments","notes","learnings"].includes(n)||De(n,i)){i.push(s);continue}let f=Z(u.key,t);if(!f){i.push(s);continue}let m=u.value.startsWith("-")?[`${f.flag}=${u.value}`]:[f.flag,u.value];i.push(...m),o.push({from:s,to:m,reason:"bare_key_value",confidence:f.confidence})}return i}function Re(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--verify"){let o=e[t+1];if(o===void 0||o==="--")throw new b("history attest --verify requires a bundle file.",g.USAGE);e.splice(t,2,`--verify=${o}`)}else(I.has(n)||n==="--output"||n==="--hash-algorithm")&&(t+=1)}}function Be(e,t){if(!e.some(o=>o==="--help"||o==="-h"))return;let n=new Set(y(t).flatMap(o=>[o.flag,...o.aliases??[],...o.short===void 0?[]:[o.short]]));for(let o=0;o<e.length;o+=1){let i=e[o];if(i==="--")break;i!=="--help"&&i!=="-h"||n.has(e[o-1])&&!k.has(e[o-1])&&(e[o-1]=i)}}function ut(e){let t=[],n=ve(e,t),o=Ie(n);(o.length!==n.length||o.some((h,ie)=>h!==n[ie]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let i=ke(o,t),r=q(i);if(r.conflict)throw new b("Provide the item id either positionally or with --id, not both.",g.USAGE);r.changed&&t.push({from:`--id ${r.itemId}`,to:[r.itemId],reason:"item_id_alias",confidence:"high"});let a=be(r.argv),s=J(r.argv),l=p(s??a??""),c=Te(s??a),u=$e(r.argv,c,l,t),f=Ve(u,l,t),m=Fe(f,c.listCanonicalFlags,I,a==="create"?new Set(["--tags"]):new Set);for(let h of m.events)t.push(h);return Be(m.argv,s??a),s==="history attest"&&Re(m.argv),{argv:m.argv,commandName:a,trace:t}}function J(e){let t=X(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase(),i=N(t);return i?i.canonical:(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function dt(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}(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]="fb625cd9-f8a8-56cf-88ab-abef64051497")}catch{}})();function gt(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new b("--author requires a non-empty value.",g.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=G();T(t);let o=!1;return()=>{o||(o=!0,n===void 0?T(void 0):T(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]="d0e60f7e-e0a8-5ef4-9af7-4a1f102ccb7d")}catch{}})();var d=Object.freeze({clock:"PM_CLOCK",tickMs:"PM_CLOCK_TICK_MS",seed:"PM_SEED"});function A(e,t,n,o){return new b(e,g.USAGE,{code:"invalid_reproducible_process_environment",reason:t,field:n,required:`${d.clock} and ${d.seed}; ${d.tickMs} is optional`,nextSteps:[`Set ${d.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${d.seed} to a non-empty reproducibility seed.`,`Optionally set ${d.tickMs} to a non-negative integer; it defaults to 1.`,"Unset all three variables to retain normal wall-clock and cryptographic-random behavior."],recovery:{recovery_mode:"compact",provided_fields:o,missing_required_fields:t==="incomplete"?[d.clock,d.seed].filter(i=>!o.includes(i)):void 0}})}function ze(e){let t=e[d.clock],n=e[d.tickMs],o=e[d.seed],i=[[d.clock,t],[d.tickMs,n],[d.seed,o]].filter(a=>a[1]!==void 0).map(([a])=>a);if(i.length===0)return;if(t===void 0||o===void 0)throw A("Reproducible process execution requires PM_CLOCK and PM_SEED together.","incomplete",t===void 0?d.clock:d.seed,i);if(o.trim().length===0)throw A(`${d.seed} must not be empty.`,"invalid_value",d.seed,i);if(!B(t))throw A(`${d.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`,"invalid_value",d.clock,i);let r=n===void 0?1:Number(n);if(n?.trim().length===0||!Number.isSafeInteger(r)||r<0)throw A(`${d.tickMs} must be a non-negative integer.`,"invalid_value",d.tickMs,i);return $({clock:t,seed:o,tickMs:r})}function Ge(e){let t=ze(e);return t===void 0?n=>n():R(t)}async function vt(e,t){return Ge(e)(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]="7249e95a-4744-55b8-8b83-2d84f3e48805")}catch{}})();var Q=new Set([...Object.values(M),...F,"--full","--brief","--compact","--summary","--fields","--section","--token-budget"]),ee=new Set(["--full-changed-fields","--no-changed-fields","--id-only"]);function te(e){let t=e.split("=",1)[0].replaceAll("_","-");return Q.has(t)||t.length>=5&&[...Q].some(n=>n.startsWith(t))}function At(e,t){let n=e.split("=",1)[0].replaceAll("_","-");return te(n)?!ee.has(t):ee.has(n)?!te(t):!0}function ne(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function Et(e){if(!(!Array.isArray(e)||e.length===0))return C(e)}function Ue(e,t){let n=ne(t);if(!n)return;let o=y(e).find(i=>i.flag===n||i.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function Ot(e,t,n){let o=[...e],i=o.indexOf("--"),r=i<0?o.length:i;for(let a of n){let s=ne(a);if(!s||o.slice(0,r).some(u=>u===s||u.startsWith(`${s}=`)))continue;let l=Ue(t,s),c=l?[s,l]:[s];o.splice(r,0,...c),r+=c.length}return o.length===e.length?void 0:V(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]="bd9a8d3b-bc6f-5309-a3fb-7e5f41ef9dab")}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]="12066389-daef-5fce-b7a6-0ecffa926d66")}catch{}})();function Vt(e,t){let n=e.trim().split(/\s+/u);if(!(n.length<2||t.includes(n.join(" "))))for(let o=1;o<n.length;o+=1){if(!t.includes(n.slice(0,o).join(" ")))return;let i=n.slice(o).join(" "),r=w(i),a=new Set(t.filter(s=>s===i||s.endsWith(` ${i}`)||s===r?.canonical).map(s=>w(s)?.canonical??s).filter(s=>t.includes(s)));if(a.size>0)return a.size===1?[...a][0]:void 0}}var We={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"],start:["start-task"]};function oe(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let i=n.split(" "),r=We[o]?.indexOf(p(n));if(r!==void 0&&r>=0)return r;if(n===o)return 10;if(i.includes(o))return 11;if(i.some(l=>l.startsWith(o)))return 12;let a=o.length>=5?2:1,s=Number.POSITIVE_INFINITY;for(let l of i){let c=v(l,o,a);c!==null&&(s=Math.min(s,c))}return Number.isFinite(s)?20+s:n.includes(o)?30:Number.POSITIVE_INFINITY}function $t(e,t){return e.map(n=>({path:n,score:oe(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}function Rt(e,t,n){let o=new Set(t),i=E.filter(s=>s.lifecycle==="deprecated").slice().sort((s,l)=>l.alias.length-s.alias.length),r=[],a=e.flatMap(s=>{let l=i.find(u=>s===u.alias||s.startsWith(`${u.alias} `)),c=s;if(l){let u=s.slice(l.alias.length);if(!o.has(`${l.canonical}${u}`))return[];c=`${l.canonical_argv.join(" ")}${u}`}return n!==void 0&&oe(s,n)<10&&r.push(c),[c]});return[...new Set(r.length>0?r:a)]}export{Ke as a,j as b,q as c,he as d,X as e,ge as f,S as g,be as h,lt as i,Ie as j,ct as k,Fe as l,Ve as m,ut as n,dt as o,gt as p,d as q,ze as r,Ge as s,vt as t,te as u,At as v,Et as w,Ue as x,Ot as y,Vt as z,oe as A,$t as B,Rt as C};
2
+ //# sourceMappingURL=chunk-LUKVNL72.js.map
@@ -1,8 +1,8 @@
1
- import{M as fe,Ta as pe,i as se}from"./chunk-6ZDKKOKM.js";import{Ja as le,o as R}from"./chunk-OZCSXX4D.js";import{$c as oe,$l as ce,Bc as H,Cc as K,E as C,Hc as q,Ic as U,Jc as V,Kc as z,Lc as W,Mc as G,Nc as Y,Oc as X,Pc as J,Qc as Q,Rc as Z,Sc as ee,Tc as re,Uc as te,Zl as de,_c as ne,_i as ae,_l as me,ec as v,fd as ie,ic as x,jc as D,oa as w,pa as B,vc as L}from"./chunk-4PNPDT2N.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="52f6eff3-e226-56d9-893a-f16997d11c50")}catch{}})();function Ir(r){return r}function Mr(r){return r}function Ce(r,e){for(let t of e.commands??[])r.registerCommand(t);for(let[t,n]of Object.entries(e.commandOverrides??{}))r.registerCommand(t,n);for(let[t,n]of Object.entries(e.flags??{}))r.registerFlags(t,n);for(let[t,n]of Object.entries(e.parsers??{}))r.registerParser(t,n);for(let[t,n]of Object.entries(e.renderers??{}))if(typeof n=="function")r.registerRenderer(t,n);else{let{run:a,...i}=n;r.registerRenderer(t,a,i)}for(let[t,n]of Object.entries(e.services??{}))r.registerService(t,n)}function Re(r,e){for(let i of e.preflights??[])r.registerPreflight(i);let t=e.itemTypes??[];t.length>0&&r.registerItemTypes(t);let n=e.itemFields??[];n.length>0&&r.registerItemFields(n);let a=e.relationshipKinds??[];a.length>0&&r.registerRelationshipKinds(a);for(let i of e.migrations??[])r.registerMigration(i);for(let i of e.profiles??[])r.registerProfile(i)}function Ne(r,e){for(let t of e.searchProviders??[])r.registerSearchProvider(t);for(let t of e.vectorStoreAdapters??[])r.registerVectorStoreAdapter(t);for(let t of e.assuranceProviders??[])r.registerAssuranceMeasurementProvider(t);for(let t of e.importers??[])r.registerImporter(t.name,t.importer,t.options);for(let t of e.exporters??[])r.registerExporter(t.name,t.exporter,t.options)}function Se(r,e){for(let t of e.beforeCommand??[])r.hooks.beforeCommand(t);for(let t of e.beforeMutation??[])r.hooks.beforeMutation(t);for(let t of e.afterCommand??[])r.hooks.afterCommand(t);for(let t of e.onWrite??[])r.hooks.onWrite(t);for(let t of e.onRead??[])r.hooks.onRead(t);for(let t of e.onIndex??[])r.hooks.onIndex(t)}function Oe(r){let e={activate:async t=>{Ce(t,r),Re(t,r),Ne(t,r),Se(t,r.hooks??{}),await r.activate?.(t)}};return r.manifest&&(e.manifest=r.manifest),r.deactivate&&(e.deactivate=r.deactivate),e}function h(r){let e=r.flatMap(t=>t??[]);return e.length>0?e:void 0}function _(r){let e=Object.assign({},...r.map(t=>t??{}));return Object.keys(e).length>0?e:void 0}function Ae(r){let e={};for(let t of r)for(let[n,a]of Object.entries(t??{}))e[n]=[...e[n]??[],...a];return Object.keys(e).length>0?e:void 0}var Fe=["beforeCommand","beforeMutation","afterCommand","onWrite","onRead","onIndex"];function Pe(r,e,t){let n=e.map(i=>i?.[t]),a=h(n);if(a!==void 0){let i=r;i[t]=a}}function Te(r){let e={};for(let t of Fe)Pe(e,r,t);return Object.keys(e).length>0?e:void 0}function jr(...r){let e={},t=(o,s)=>{s!==void 0&&(e[o]=s)};t("commands",h(r.map(o=>o.commands))),t("commandOverrides",_(r.map(o=>o.commandOverrides))),t("flags",Ae(r.map(o=>o.flags))),t("parsers",_(r.map(o=>o.parsers))),t("renderers",_(r.map(o=>o.renderers))),t("services",_(r.map(o=>o.services))),t("preflights",h(r.map(o=>o.preflights))),t("itemTypes",h(r.map(o=>o.itemTypes))),t("itemFields",h(r.map(o=>o.itemFields))),t("relationshipKinds",h(r.map(o=>o.relationshipKinds))),t("migrations",h(r.map(o=>o.migrations))),t("profiles",h(r.map(o=>o.profiles))),t("searchProviders",h(r.map(o=>o.searchProviders))),t("vectorStoreAdapters",h(r.map(o=>o.vectorStoreAdapters))),t("assuranceProviders",h(r.map(o=>o.assuranceProviders))),t("importers",h(r.map(o=>o.importers))),t("exporters",h(r.map(o=>o.exporters))),t("hooks",Te(r.map(o=>o.hooks)));let n;for(let o of r)o.manifest&&(n=o.manifest);t("manifest",n);let a=r.some(o=>o.activate);t("activate",a?async o=>{for(let s of r)s.activate&&await s.activate(o)}:void 0);let i=r.some(o=>o.deactivate);return t("deactivate",i?async()=>{let o=[];for(let s of[...r].reverse())if(s.deactivate)try{await s.deactivate()}catch(d){o.push(d)}if(o.length>0)throw o.length>1?new AggregateError(o,"Multiple extension blueprint deactivate hooks failed."):o[0]}:void 0),e}var Ie=[["commands","commands"],["commandOverrides","commands"],["flags","schema"],["itemTypes","schema"],["itemFields","schema"],["relationshipKinds","schema"],["migrations","schema"],["profiles","schema"],["parsers","parser"],["renderers","renderers"],["services","services"],["preflights","preflight"],["searchProviders","search"],["vectorStoreAdapters","search"],["assuranceProviders","services"],["importers","importers"],["exporters","importers"]];function $(r){return r?Array.isArray(r)?r.length>0:Object.keys(r).length>0:!1}function N(r){let e=new Set;for(let[a,i]of Ie)$(r[a])&&e.add(i);(r.commands??[]).filter(b).some(a=>a.flags!==void 0)&&e.add("schema");let t=[...r.importers??[],...r.exporters??[]].filter(b);t.some(a=>a?.options?.flags!==void 0)&&e.add("schema"),t.some(a=>typeof a=="object")&&e.add("commands");let n=r.hooks??{};return[n.beforeCommand,n.beforeMutation,n.afterCommand,n.onWrite,n.onRead,n.onIndex].some($)&&e.add("hooks"),[...e].sort((a,i)=>a.localeCompare(i))}var Me=[["beforeCommand","before_command"],["beforeMutation","before_mutation"],["afterCommand","after_command"],["onWrite","on_write"],["onRead","on_read"],["onIndex","on_index"]];function f(r){return[...new Set(r)].sort((e,t)=>e.localeCompare(t))}function b(r){return r!=null}function S(r){return v(`${r.name} import`)}function O(r){return v(`${r.name} export`)}function je(r,e,t){return[...r.map(n=>v(n.name)),...e.filter(n=>n.options!==void 0).map(S),...t.filter(n=>n.options!==void 0).map(O)]}function Be(r,e,t,n){return[...Object.keys(r.flags??{}).map(a=>v(a)),...e.filter(a=>a.flags!==void 0).map(a=>v(a.name)),...t.filter(a=>a.options?.flags!==void 0).map(S),...n.filter(a=>a.options?.flags!==void 0).map(O)]}function De(r){return Me.filter(([e])=>(r[e]?.length??0)>0).map(([,e])=>e)}function Le(r){let e=Object.entries(r??{}).filter(([,t])=>typeof t!="function"&&((t.commands?.length??0)>0||t.resultDiscriminator!==void 0)).map(([t,n])=>{let a=n;return{format:t,commands:f((a.commands??[]).map(i=>v(i))),result_discriminator:a.resultDiscriminator!==void 0}}).sort((t,n)=>t.format.localeCompare(n.format));return e.length>0?{renderer_ownership:e}:{}}function He(r){return!r||r.length===0?{}:{assurance_providers:f(r.map(e=>e.id))}}function Ke(r,e,t){return{item_types:f((r.itemTypes??[]).map(n=>n.name)),item_fields:f((r.itemFields??[]).map(n=>n.name)),...(r.relationshipKinds?.length??0)>0?{relationship_kinds:f(r.relationshipKinds.map(n=>n.kind))}:{},migrations:f((r.migrations??[]).flatMap(n=>typeof n.id=="string"?[n.id]:[])),profiles:f((r.profiles??[]).map(n=>n.name)),importers:f(e.map(n=>v(n.name))),exporters:f(t.map(n=>v(n.name))),search_providers:f((r.searchProviders??[]).map(n=>n.name)),vector_store_adapters:f((r.vectorStoreAdapters??[]).map(n=>n.name)),...He(r.assuranceProviders),parser_overrides:f(Object.keys(r.parsers??{}).map(n=>v(n))),service_overrides:f(Object.keys(r.services??{}).map(n=>String(n).trim().toLowerCase())),renderer_overrides:f(Object.keys(r.renderers??{}).map(n=>String(n).trim().toLowerCase())),...Le(r.renderers),preflight_overrides:(r.preflights??[]).length,preflight_ownership:(r.preflights??[]).map(n=>({commands:[...n.commands??[]]}))}}function qe(r){let e=(r.commands??[]).filter(b),t=(r.importers??[]).filter(b),n=(r.exporters??[]).filter(b),a=t.map(S),i=n.map(O),o=je(e,t,n),s=Be(r,e,t,n),d=r.hooks??{},l=Ke(r,t,n);return{capabilities:N(r),commands:f(o),command_overrides:f(Object.keys(r.commandOverrides??{}).map(E=>v(E))),command_handlers:f([...o,...a,...i]),hooks:De(d),flag_commands:f(s),...l}}var Ue=["commands","commandOverrides","flags","parsers","renderers","services","preflights","itemTypes","itemFields","relationshipKinds","migrations","profiles","searchProviders","vectorStoreAdapters","assuranceProviders","importers","exporters"];function Ve(r){return(r.itemFields??[]).filter(e=>typeof e?.name=="string"&&ae.has(e.name.trim())).map(e=>({code:"reserved_item_field",severity:"error",message:`Item field "${e.name}" collides with reserved item metadata; rename it with an extension-specific prefix before publishing.`,field:e.name}))}function ze(r){return[...Object.values(r.flags??{}).flat(),...(r.commands??[]).flatMap(e=>e.flags??[]),...(r.importers??[]).flatMap(e=>e.options?.flags??[]),...(r.exporters??[]).flatMap(e=>e.options?.flags??[])].flatMap(e=>{if(typeof e?.long!="string"&&typeof e?.short!="string")return[];let t=H(e.long,e.short);if(t===null)return[];let{token:n,failure:a}=t;return[{code:a,severity:"error",message:`Flag "${n}" ${K(n,a)}.`,field:n}]})}function ue(r){let e=new Set;for(let t of r){let n=D(t)??x(t);n!==null&&e.add(n)}return[...e].sort((t,n)=>t.localeCompare(n))}function We(r,e){let t=[];if(e===null)return r.length>0&&t.push({code:"manifest_capabilities_absent",severity:"warning",message:`Blueprint exercises ${r.length===1?"capability":"capabilities"} [${r.join(", ")}] but declares none; set capabilities to deriveExtensionCapabilities(blueprint) so the manifest grant matches.`}),t;let n=new Set(e),a=new Set(r);for(let i of r)n.has(i)||t.push({code:"capability_undeclared",severity:"error",message:`Blueprint exercises capability "${i}" but it is absent from the declared capabilities; activation throws extension_capability_missing \u2014 add "${i}" to the manifest capabilities.`,capability:i});for(let i of e)a.has(i)||t.push({code:"capability_unused",severity:"warning",message:`Capability "${i}" is declared but no blueprint surface exercises it; drop it to keep the manifest least-privilege (pm package doctor reports this as extension_capability_unused).`,capability:i});return t}function Ge(r){let e=[],t=new Map;for(let a of r.commands??[]){let i=v(a.name);t.set(i,(t.get(i)??0)+1)}for(let[a,i]of t)i>1&&e.push({code:"duplicate_command",severity:"warning",message:`Command "${a}" is declared ${i} times in commands; the later registration shadows the earlier one at dispatch.`,command:a});let n=new Set(Object.keys(r.commandOverrides??{}).map(a=>v(a)));for(let a of t.keys())n.has(a)&&e.push({code:"command_override_conflict",severity:"warning",message:`Command "${a}" is declared both as a new command definition and as a command override; register one or the other.`,command:a});return e}function Ye(r){let e=[];for(let t of Ue)t in r&&!$(r[t])&&e.push({code:"empty_surface",severity:"warning",message:`Blueprint field "${t}" is present but empty; remove it or populate it.`,field:t});if("hooks"in r){let t=r.hooks??{};[t.beforeCommand,t.beforeMutation,t.afterCommand,t.onWrite,t.onRead,t.onIndex].some($)||e.push({code:"empty_surface",severity:"warning",message:'Blueprint field "hooks" is present but registers no lifecycle hooks; remove it or populate it.',field:"hooks"})}return e}function k(r,e={}){let t=N(r),n=e.declaredCapabilities??r.manifest?.capabilities,a=Array.isArray(n)?ue(n):null,i=[...We(t,a),...Ge(r),...ze(r),...Ve(r),...Ye(r)];return{ok:i.every(o=>o.severity!=="error"),findings:i,used:t,declared:a}}function ve(r,e){let{additionalCapabilities:t,...n}=e,a=Array.isArray(t)?ue(t):[],i=[...new Set([...N(r),...a])].sort((o,s)=>o.localeCompare(s));return{...n,capabilities:i}}function Br(r,e){let t=ve(r,e);return{module:Oe({...r,manifest:t}),manifest:t}}function ge(r,e){if(r.status==="absent"||r.status==="ok")return null;let t=`${r.kind}_${r.status}`,n="";switch(t){case"pm_min_version_invalid":n=`pm_min_version "${r.required}" is not a valid version; the extension is treated as incompatible and the loader skips it.`;break;case"pm_min_version_unchecked":n=`pm_min_version "${r.required}" could not be compared against pm ${e}; compatibility is unverified.`;break;case"pm_min_version_unmet":n=`Requires pm >= ${r.required} but the target is pm ${e}; the loader skips the extension.`;break;case"pm_max_version_invalid":n=`pm_max_version "${r.required}" is not a valid inclusive upper bound (version ranges are not allowed); the extension is treated as incompatible and the loader skips it.`;break;case"pm_max_version_unchecked":n=`pm_max_version "${r.required}" could not be compared against pm ${e}; compatibility is unverified.`;break;case"pm_max_version_exceeded":n=`Allows pm <= ${r.required} but the target is pm ${e}; the loader skips the extension.`;break;case"pm_max_version_exceeded_warn":n=`Target pm ${e} is newer than pm_max_version ${r.required}, but the "warn" exceeded mode lets it load with a warning.`;break}return{code:t,severity:r.allowed?"warning":"error",constraint:r.kind,required:r.required,current:e,message:n}}function A(r,e){let t=q(r.pm_min_version,e.pmVersion),n=U(r.pm_max_version,e.pmVersion,e.pmMaxVersionExceededMode??"block"),a=L(r).findings.map(d=>({code:d.code,severity:"warning",constraint:"manifest",required:d.code==="manifest_unknown_key"?d.path:"pm_min_version",current:e.pmVersion,path:d.path,...d.suggested_key?{suggested_key:d.suggested_key}:{},message:d.message})),i=[],o=ge(t,e.pmVersion);o!==null&&i.push(o);let s=ge(n,e.pmVersion);return s!==null&&i.push(s),{compatible:t.allowed&&n.allowed,findings:[...a,...i],pmVersion:e.pmVersion}}var Xe=new Set(["capability_undeclared","capability_unused","manifest_capabilities_absent"]);function he(r,e={}){let t=k(r,{declaredCapabilities:e.declaredCapabilities}),n=e.identity?ve(r,e.identity):null,a=e.target?A(n??r.manifest??{},e.target):null,i=[...(n!==null&&e.declaredCapabilities===void 0?t.findings.filter(o=>!Xe.has(o.code)):t.findings).map(o=>({source:"blueprint",severity:o.severity,code:o.code,message:o.message})),...(a?.findings??[]).map(o=>({source:"compatibility",severity:o.severity,code:o.code,message:o.message}))];return{ok:i.every(o=>o.severity!=="error"),capabilities:t.used,blueprint:t,manifest:n,compatibility:a,findings:i}}import{decode as Zr,encode as et}from"@toon-format/toon";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="0b5eab16-4305-5dfd-902c-fefc7ee0de2b")}catch{}})();function u(r,e){return r.name??e??""}var Je={before_command:"beforeCommand",before_mutation:"beforeMutation",after_command:"afterCommand",on_read:"onRead",on_write:"onWrite",on_index:"onIndex"},F={before_command:"beforeCommand",after_command:"afterCommand",on_read:"onRead",on_write:"onWrite",on_index:"onIndex"};function p(r){return r.trim().toLowerCase()}function ye(r){return p(r).replaceAll("-","_")}function g(r){return r?` from extension "${r}"`:""}function c(r){return[...new Set(r)].sort((e,t)=>e.localeCompare(t))}function y(r){if(typeof r!="string")throw new Error('A command name string is required. Pass it via the options object, e.g. runRegisteredCommandForTest(activation, { command: "my command" }) \u2014 positional command arguments are not supported.');return r.trim().toLowerCase().split(/\s+/).filter(e=>e.length>0).join(" ")}function m(r){return r.length>0?r.join(", "):"(none)"}function we(r,e,t){let n=new Set(r??[]),a=c(e.filter(i=>!n.has(i)));if(a.length>0)throw new Error(`Expected package manifest ${t} to include ${a.join(", ")}; available: ${m(c(r??[]))}`)}function be(r){let e=new Set;for(let t of r)typeof t.long=="string"&&t.long.trim().length>0&&e.add(t.long.trim()),typeof t.short=="string"&&t.short.trim().length>0&&e.add(t.short.trim());return e}function P(r){let e=w(r);if(!e)return{};let t=w(e.manifest);if(t)return t;let n=w(e.default);return w(n?.manifest)||(n&&typeof e.default!="function"&&("name"in n||"capabilities"in n)?n:typeof r!="function"&&("name"in e||"capabilities"in e)?e:{})}function T(r,e){return e??(typeof r.name=="string"&&r.name.trim().length>0?r.name.trim():"test-extension")}function Ee(r,e){return Array.isArray(e.capabilities)?[...e.capabilities]:Array.isArray(r.capabilities)?r.capabilities.filter(t=>typeof t=="string"):[]}function xe(r,e,t){return{disabled_by_flag:!1,roots:{global:"",project:""},configured_enabled:[],configured_disabled:[],discovered:[],effective:[],warnings:[],policy:t.policy,failed:[],loaded:[{layer:t.layer,directory:"",manifest_path:"",name:t.name,version:typeof e.version=="string"?e.version:"0.0.0",entry:typeof e.entry=="string"?e.entry:"./index.js",priority:typeof e.priority=="number"?e.priority:0,entry_path:"",capabilities:t.capabilities,manifest_version:typeof e.manifest_version=="number"?e.manifest_version:void 0,pm_min_version:typeof e.pm_min_version=="string"?e.pm_min_version:void 0,pm_max_version:typeof e.pm_max_version=="string"?e.pm_max_version:void 0,engines:e.engines,trusted:e.trusted,provenance:e.provenance,sandbox_profile:e.sandbox_profile,permissions:e.permissions,activation:e.activation,module:r}]}}async function Qe(r,e={}){let t=P(r);return oe(xe(r,t,{name:T(t,e.name),layer:e.layer??"project",capabilities:Ee(t,e),policy:e.policy??C()}))}async function Ze(r,e={}){let t=P(r);return ne(xe(r,t,{name:T(t,e.name),layer:e.layer??"project",capabilities:Ee(t,{}),policy:C()}),e.activation,e.deactivateTimeoutMs===void 0?{}:{deactivate_timeout_ms:e.deactivateTimeoutMs})}async function I(r,e){let t=y(e.command);if(t.length===0)throw new Error("Expected command name must be a non-empty string");if(!r.handlers.some(o=>o.command===t)){let o=c(r.handlers.map(s=>s.command));throw new Error(`Expected a registered command handler for "${t}" to invoke. Available command handlers: ${m(o)}`)}if(e.sdk!==void 0&&e.sdkFactory!==void 0)throw new TypeError("runRegisteredCommandForTest accepts sdk or sdkFactory, not both");let n=e.pmRoot??"",a={json:!0,quiet:!0,noPager:!0,...e.global},i=e.sdk??e.sdkFactory?.({pmRoot:n,global:a})??(n.length>0?se(n,new pe({pmRoot:n}),void 0,t):void 0);return J(r,{command:t,args:e.args?[...e.args]:[],options:e.options?{...e.options}:{},global:a,pm_root:n,...i===void 0?{}:{sdk:i}})}async function er(r,e){if((r.beforeMutation?.length??0)===0)throw new Error("Expected a registered before_mutation hook to invoke");await z(r,e.context)}async function rr(r,e){let t=e.kind;if(t==="before_mutation")throw new Error("Invoke before_mutation hooks with runRegisteredMutationGuardForTest so denials and failures retain fail-closed semantics.");if((r[F[t]]?.length??0)===0){let n=c(Object.keys(F).filter(a=>(r[F[a]]?.length??0)>0));throw new Error(`Expected a registered "${t}" hook to invoke. Hook kinds with registrations: ${m(n)}`)}switch(e.kind){case"before_command":return V(r,e.context);case"after_command":return W(r,e.context);case"on_read":return Y(r,e.context);case"on_write":return G(r,e.context);case"on_index":return X(r,e.context)}}async function tr(r,e){let t=y(e.command);if(!r.overrides.some(n=>n.command===t))throw new Error(`Expected a registered parser override for command "${t}" to invoke. Available parser override commands: ${m(c(r.overrides.map(n=>n.command)))}`);return Q(r,e)}async function nr(r,e){if(r.overrides.length===0)throw new Error("Expected a registered preflight override to invoke, but none are registered.");return Z(r,e)}async function or(r,e){let t=y(e.command);if(!r.overrides.some(n=>n.command===t))throw new Error(`Expected a registered command override for command "${t}" to invoke. Available command override commands: ${m(c(r.overrides.map(n=>n.command)))}`);return re(r,e)}async function ir(r,e){if(!r.overrides.some(t=>t.format===e.format))throw new Error(`Expected a registered renderer override for format "${e.format}" to invoke. Available renderer override formats: ${m(c(r.overrides.map(t=>t.format)))}`);return te(r,e)}async function ar(r,e){if(!r.overrides.some(t=>t.service===e.service))throw new Error(`Expected a registered service override for service "${e.service}" to invoke. Available service override services: ${m(c(r.overrides.map(t=>t.service)))}`);return ee(r,e)}var sr={query:["query"],embed:["embed"],embedBatch:["embedBatch","embed_batch"],queryExpansion:["queryExpansion","query_expansion"],rerank:["rerank"]};async function dr(r,e){let t=de(r,e.provider);if(!t){let i=c(r.search_providers.map(o=>o.definition.name));throw new Error(`Expected a registered search provider "${e.provider}" to invoke. Available search providers: ${m(i)}`)}let n=t.runtime_definition,a=sr[e.operation].map(i=>n[i]).find(i=>typeof i=="function");if(typeof a!="function")throw new Error(`Registered search provider "${e.provider}" does not implement the "${e.operation}" operation.`);return await a(e.context)}async function mr(r,e){let t=me(r,e.adapter);if(!t){let a=c(r.vector_store_adapters.map(i=>i.definition.name));throw new Error(`Expected a registered vector store adapter "${e.adapter}" to invoke. Available vector store adapters: ${m(a)}`)}let n=t.runtime_definition[e.operation];if(typeof n!="function")throw new Error(`Registered vector store adapter "${e.adapter}" does not implement the "${e.operation}" operation.`);return await n(e.context)}async function cr(r,e){let t=ke(r,{migration:e.migration,extensionName:e.extensionName}),n=ce(t).run;if(typeof n!="function")throw new Error(`Registered migration "${e.migration}" does not implement a run function to invoke.`);let a=t.definition.status,i={id:t.definition.id,command:"migration",layer:t.layer,extension:t.name,pm_root:e.pmRoot??"",status:(typeof a=="string"?a.trim().toLowerCase():"")||"pending"};return await n(i)}async function lr(r,e){let t=_e(r.registrations,{importer:e.importer,extensionName:e.extensionName});return I(r.commands,{command:`${t.importer} import`,args:e.args,options:e.options,global:e.global,pmRoot:e.pmRoot})}async function fr(r,e){let t=$e(r.registrations,{exporter:e.exporter,extensionName:e.extensionName});return I(r.commands,{command:`${t.exporter} export`,args:e.args,options:e.options,global:e.global,pmRoot:e.pmRoot})}function rt(r,e={}){let t=e.deactivated??1;if(r.deactivated!==t)throw new Error(`Expected ${t} extension${t===1?"":"s"} to deactivate cleanly, but ${r.deactivated} did.`);let n=e.failed??0;if(r.failed.length!==n){let a=r.failed.map(i=>`${i.layer}:${i.name} (${i.error})`).join(", ");throw new Error(`Expected ${n} teardown failure${n===1?"":"s"}, but observed ${r.failed.length}${a.length>0?`: ${a}`:""}.`)}return r}function tt(r,e){if(e.packageName!==void 0&&r.package_name!==e.packageName)throw new Error(`Expected package manifest package_name to be "${e.packageName}"; received "${r.package_name??"(none)"}"`);if(e.aliases!==void 0&&we(r.aliases,e.aliases,"aliases"),e.resources!==void 0)for(let[t,n]of Object.entries(e.resources))we(r.resources[t],n,`pm.${t}`);return r}function pr(r,e){let t=y(u(e,e.command));if(t.length===0)throw new Error("Expected command name must be a non-empty string");let n=r.commands.filter(o=>o.command===t),a=e.extensionName?n.find(o=>o.name===e.extensionName):n[0];if(!a){let o=r.commands.map(d=>d.command).sort((d,l)=>d.localeCompare(l)),s=e.extensionName?` from extension "${e.extensionName}"`:"";throw new Error(`Expected extension command "${t}"${s} to be registered. Available commands: ${m(o)}`)}if(e.action!==void 0&&a.action!==e.action)throw new Error(`Expected extension command "${t}" action "${e.action}", received "${a.action}"`);if(e.arguments!==void 0){let o=(a.arguments??[]).map(d=>d.name),s=e.arguments.filter(d=>!o.includes(d));if(s.length>0)throw new Error(`Expected extension command "${t}" arguments ${m(e.arguments)}; missing ${m(s)}; available ${m(o)}`)}let i=r.flags.filter(o=>o.target_command===t&&(e.extensionName===void 0||o.name===e.extensionName)).flatMap(o=>o.flags);if(e.flags!==void 0){let o=be(i),s=e.flags.filter(d=>!o.has(d));if(s.length>0)throw new Error(`Expected extension command "${t}" flags ${m(e.flags)}; missing ${m(s)}; available ${m([...o].sort((d,l)=>d.localeCompare(l)))}`)}return{command:a,flags:i}}function gr(r,e){let t=y(u(e,e.targetCommand));if(t.length===0)throw new Error("Expected target command name must be a non-empty string");let n=r.flags.filter(i=>i.target_command===t),a;if(e.extensionName)a=n.find(i=>i.name===e.extensionName);else if(n.length===1)a=n[0];else if(n.length>1){let i=c(n.map(o=>o.name));throw new Error(`Expected flags for target command "${t}" matched multiple extensions: ${m(i)}. Specify extensionName to choose one registration.`)}if(!a){let i=c(r.flags.map(s=>s.target_command)),o=c(n.map(s=>s.name));throw new Error(`Expected flags for target command "${t}"${g(e.extensionName)} to be registered. Available flag target commands: ${m(i)}; matching extensions: ${m(o)}`)}if(e.flags!==void 0){let i=be(a.flags),o=e.flags.filter(s=>!i.has(s));if(o.length>0)throw new Error(`Expected flags for target command "${t}" to include ${m(e.flags)}; missing ${m(o)}; available ${m([...i].sort((s,d)=>s.localeCompare(d)))}`)}return a}function ur(r,e){let t=Je[e.kind],n=r[t]??[],a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(n.map(o=>o.name));throw new Error(`Expected a "${e.kind}" hook${g(e.extensionName)} to be registered. Available "${e.kind}" hooks: ${m(i)}`)}return a}function vr(r,e){let t=p(u(e,e.provider));if(t.length===0)throw new Error("Expected search provider name must be a non-empty string");let n=r.search_providers.filter(i=>p(i.definition.name)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.search_providers.map(o=>o.definition.name));throw new Error(`Expected search provider "${t}"${g(e.extensionName)} to be registered. Available search providers: ${m(i)}`)}return a}function hr(r,e){let t=p(u(e,e.adapter));if(t.length===0)throw new Error("Expected vector store adapter name must be a non-empty string");let n=r.vector_store_adapters.filter(i=>p(i.definition.name)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.vector_store_adapters.map(o=>o.definition.name));throw new Error(`Expected vector store adapter "${t}"${g(e.extensionName)} to be registered. Available vector store adapters: ${m(i)}`)}return a}function _e(r,e){let t=p(u(e,e.importer));if(t.length===0)throw new Error("Expected importer name must be a non-empty string");let n=r.importers.filter(i=>p(i.importer)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.importers.map(o=>o.importer));throw new Error(`Expected importer "${t}"${g(e.extensionName)} to be registered. Available importers: ${m(i)}`)}return a}function $e(r,e){let t=p(u(e,e.exporter));if(t.length===0)throw new Error("Expected exporter name must be a non-empty string");let n=r.exporters.filter(i=>p(i.exporter)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.exporters.map(o=>o.exporter));throw new Error(`Expected exporter "${t}"${g(e.extensionName)} to be registered. Available exporters: ${m(i)}`)}return a}function yr(r,e){let t=p(u(e,e.field));if(t.length===0)throw new Error("Expected item field name must be a non-empty string");let n=r.item_fields.filter(a=>e.extensionName===void 0||a.name===e.extensionName).map(a=>({registration:a,field:a.fields.find(i=>p(i.name)===t)})).filter(a=>a.field!==void 0).find(a=>e.type===void 0||a.field.type===e.type);if(!n){let a=c(r.item_fields.flatMap(i=>i.fields.map(o=>`${o.name}:${o.type}`)));throw new Error(`Expected item field "${t}"${g(e.extensionName)} to be registered. Available item fields: ${m(a)}`)}return n}function wr(r,e){let t=p(u(e,e.itemType));if(t.length===0)throw new Error("Expected item type name must be a non-empty string");let n=r.item_types.filter(a=>e.extensionName===void 0||a.name===e.extensionName).map(a=>({registration:a,itemType:a.types.find(i=>p(i.name)===t)})).filter(a=>a.itemType!==void 0).find(a=>e.folder===void 0||a.itemType.folder===e.folder);if(!n){let a=c(r.item_types.flatMap(i=>i.types.map(o=>`${o.name}:${o.folder}`)));throw new Error(`Expected item type "${t}"${g(e.extensionName)} to be registered. Available item types: ${m(a)}`)}return n}function br(r,e){let t=ye(u(e,e.profile));if(t.length===0)throw new Error("Expected profile name must be a non-empty string");let n=r.profiles.filter(a=>e.extensionName===void 0||a.name===e.extensionName).find(a=>ye(a.profile.name)===t);if(!n){let a=c(r.profiles.map(i=>i.profile.name));throw new Error(`Expected profile "${t}"${g(e.extensionName)} to be registered. Available profiles: ${m(a)}`)}return{registration:n,profile:n.profile}}function Er(r,e){let t=y(u(e,e.command));if(t.length===0)throw new Error("Expected command name must be a non-empty string");let n=r.overrides.filter(i=>i.command===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.overrides.map(o=>o.command));throw new Error(`Expected command override "${t}"${g(e.extensionName)} to be registered. Available command overrides: ${m(i)}`)}return a}function xr(r,e){let t=y(u(e,e.command));if(t.length===0)throw new Error("Expected command name must be a non-empty string");let n=r.overrides.filter(i=>i.command===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.overrides.map(o=>o.command));throw new Error(`Expected parser override "${t}"${g(e.extensionName)} to be registered. Available parser overrides: ${m(i)}`)}return a}function _r(r,e={}){let t=e.extensionName?r.overrides.find(n=>n.name===e.extensionName):r.overrides[0];if(!t){let n=c(r.overrides.map(a=>a.name));throw new Error(`Expected a preflight override${g(e.extensionName)} to be registered. Available preflight overrides: ${m(n)}`)}return t}function $r(r,e){let t=p(u(e,e.format));if(t.length===0)throw new Error("Expected renderer format must be a non-empty string");let n=r.overrides.filter(i=>i.format===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.overrides.map(o=>o.format));throw new Error(`Expected renderer override "${t}"${g(e.extensionName)} to be registered. Available renderer overrides: ${m(i)}`)}return a}function kr(r,e){let t=p(u(e,e.service));if(t.length===0)throw new Error("Expected service name must be a non-empty string");let n=r.overrides.filter(i=>p(i.service)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.overrides.map(o=>o.service));throw new Error(`Expected service override "${t}"${g(e.extensionName)} to be registered. Available service overrides: ${m(i)}`)}return a}function ke(r,e){let t=p(u(e,e.migration));if(t.length===0)throw new Error("Expected migration id must be a non-empty string");let n=r.migrations.filter(s=>(e.extensionName===void 0||s.name===e.extensionName)&&typeof s.definition.id=="string"&&p(s.definition.id)===t),a=n.find(s=>e.mandatory===void 0||(s.definition.mandatory??!1)===e.mandatory);if(a)return a;let i=n[0];if(i!==void 0)throw new Error(`Expected migration "${t}"${g(e.extensionName)} to have mandatory=${e.mandatory}, but it is mandatory=${i.definition.mandatory??!1}.`);let o=c(r.migrations.map(s=>`${typeof s.definition.id=="string"&&s.definition.id.trim().length>0?s.definition.id.trim():"(unnamed)"}:${s.definition.mandatory===!0}`));throw new Error(`Expected migration "${t}"${g(e.extensionName)} to be registered. Available migrations: ${m(o)}`)}function Cr(r,e){let t=(d,l)=>{let E=new Set;for(let M of d){let j=x(M);if(j===null)throw new Error(`Expected ${l} capability "${M}" to be a known extension capability. Use canonical capability names (see manifest.capabilities).`);E.add(j)}return E},n=[...t(e.declared,"declared")].sort((d,l)=>d.localeCompare(l)),a=t(e.allowUnused??[],"allowUnused"),i=ie(r,{extensionName:e.extensionName}),o=new Set(i),s=n.filter(d=>!o.has(d)&&!a.has(d));if(s.length>0){let d=g(e.extensionName);throw new Error(`Expected every declared capability${d} to be exercised, but [${s.join(", ")}] ${s.length===1?"is":"are"} declared yet never registered against. Remove ${s.length===1?"it":"them"} from manifest.capabilities for least privilege, or pass allowUnused for capabilities registered only behind a runtime flag.`)}return{declared:n,used:i,unused:s}}function nt(r,e={}){let t=k(r,e);if(!t.ok){let n=t.findings.filter(a=>a.severity==="error");throw new Error(`Extension blueprint failed preflight with ${n.length} ${n.length===1?"error":"errors"}:
1
+ import{M as fe,Ta as pe,i as se}from"./chunk-FIJOSX2C.js";import{Ja as le,o as R}from"./chunk-RNABUEFB.js";import{$c as oe,$l as ce,Bc as H,Cc as K,E as C,Hc as q,Ic as U,Jc as V,Kc as z,Lc as W,Mc as G,Nc as Y,Oc as X,Pc as J,Qc as Q,Rc as Z,Sc as ee,Tc as re,Uc as te,Zl as de,_c as ne,_i as ae,_l as me,ec as v,fd as ie,ic as x,jc as D,oa as w,pa as B,vc as L}from"./chunk-RHQJ6VWC.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="52f6eff3-e226-56d9-893a-f16997d11c50")}catch{}})();function Ir(r){return r}function Mr(r){return r}function Ce(r,e){for(let t of e.commands??[])r.registerCommand(t);for(let[t,n]of Object.entries(e.commandOverrides??{}))r.registerCommand(t,n);for(let[t,n]of Object.entries(e.flags??{}))r.registerFlags(t,n);for(let[t,n]of Object.entries(e.parsers??{}))r.registerParser(t,n);for(let[t,n]of Object.entries(e.renderers??{}))if(typeof n=="function")r.registerRenderer(t,n);else{let{run:a,...i}=n;r.registerRenderer(t,a,i)}for(let[t,n]of Object.entries(e.services??{}))r.registerService(t,n)}function Re(r,e){for(let i of e.preflights??[])r.registerPreflight(i);let t=e.itemTypes??[];t.length>0&&r.registerItemTypes(t);let n=e.itemFields??[];n.length>0&&r.registerItemFields(n);let a=e.relationshipKinds??[];a.length>0&&r.registerRelationshipKinds(a);for(let i of e.migrations??[])r.registerMigration(i);for(let i of e.profiles??[])r.registerProfile(i)}function Ne(r,e){for(let t of e.searchProviders??[])r.registerSearchProvider(t);for(let t of e.vectorStoreAdapters??[])r.registerVectorStoreAdapter(t);for(let t of e.assuranceProviders??[])r.registerAssuranceMeasurementProvider(t);for(let t of e.importers??[])r.registerImporter(t.name,t.importer,t.options);for(let t of e.exporters??[])r.registerExporter(t.name,t.exporter,t.options)}function Se(r,e){for(let t of e.beforeCommand??[])r.hooks.beforeCommand(t);for(let t of e.beforeMutation??[])r.hooks.beforeMutation(t);for(let t of e.afterCommand??[])r.hooks.afterCommand(t);for(let t of e.onWrite??[])r.hooks.onWrite(t);for(let t of e.onRead??[])r.hooks.onRead(t);for(let t of e.onIndex??[])r.hooks.onIndex(t)}function Oe(r){let e={activate:async t=>{Ce(t,r),Re(t,r),Ne(t,r),Se(t,r.hooks??{}),await r.activate?.(t)}};return r.manifest&&(e.manifest=r.manifest),r.deactivate&&(e.deactivate=r.deactivate),e}function h(r){let e=r.flatMap(t=>t??[]);return e.length>0?e:void 0}function _(r){let e=Object.assign({},...r.map(t=>t??{}));return Object.keys(e).length>0?e:void 0}function Ae(r){let e={};for(let t of r)for(let[n,a]of Object.entries(t??{}))e[n]=[...e[n]??[],...a];return Object.keys(e).length>0?e:void 0}var Fe=["beforeCommand","beforeMutation","afterCommand","onWrite","onRead","onIndex"];function Pe(r,e,t){let n=e.map(i=>i?.[t]),a=h(n);if(a!==void 0){let i=r;i[t]=a}}function Te(r){let e={};for(let t of Fe)Pe(e,r,t);return Object.keys(e).length>0?e:void 0}function jr(...r){let e={},t=(o,s)=>{s!==void 0&&(e[o]=s)};t("commands",h(r.map(o=>o.commands))),t("commandOverrides",_(r.map(o=>o.commandOverrides))),t("flags",Ae(r.map(o=>o.flags))),t("parsers",_(r.map(o=>o.parsers))),t("renderers",_(r.map(o=>o.renderers))),t("services",_(r.map(o=>o.services))),t("preflights",h(r.map(o=>o.preflights))),t("itemTypes",h(r.map(o=>o.itemTypes))),t("itemFields",h(r.map(o=>o.itemFields))),t("relationshipKinds",h(r.map(o=>o.relationshipKinds))),t("migrations",h(r.map(o=>o.migrations))),t("profiles",h(r.map(o=>o.profiles))),t("searchProviders",h(r.map(o=>o.searchProviders))),t("vectorStoreAdapters",h(r.map(o=>o.vectorStoreAdapters))),t("assuranceProviders",h(r.map(o=>o.assuranceProviders))),t("importers",h(r.map(o=>o.importers))),t("exporters",h(r.map(o=>o.exporters))),t("hooks",Te(r.map(o=>o.hooks)));let n;for(let o of r)o.manifest&&(n=o.manifest);t("manifest",n);let a=r.some(o=>o.activate);t("activate",a?async o=>{for(let s of r)s.activate&&await s.activate(o)}:void 0);let i=r.some(o=>o.deactivate);return t("deactivate",i?async()=>{let o=[];for(let s of[...r].reverse())if(s.deactivate)try{await s.deactivate()}catch(d){o.push(d)}if(o.length>0)throw o.length>1?new AggregateError(o,"Multiple extension blueprint deactivate hooks failed."):o[0]}:void 0),e}var Ie=[["commands","commands"],["commandOverrides","commands"],["flags","schema"],["itemTypes","schema"],["itemFields","schema"],["relationshipKinds","schema"],["migrations","schema"],["profiles","schema"],["parsers","parser"],["renderers","renderers"],["services","services"],["preflights","preflight"],["searchProviders","search"],["vectorStoreAdapters","search"],["assuranceProviders","services"],["importers","importers"],["exporters","importers"]];function $(r){return r?Array.isArray(r)?r.length>0:Object.keys(r).length>0:!1}function N(r){let e=new Set;for(let[a,i]of Ie)$(r[a])&&e.add(i);(r.commands??[]).filter(b).some(a=>a.flags!==void 0)&&e.add("schema");let t=[...r.importers??[],...r.exporters??[]].filter(b);t.some(a=>a?.options?.flags!==void 0)&&e.add("schema"),t.some(a=>typeof a=="object")&&e.add("commands");let n=r.hooks??{};return[n.beforeCommand,n.beforeMutation,n.afterCommand,n.onWrite,n.onRead,n.onIndex].some($)&&e.add("hooks"),[...e].sort((a,i)=>a.localeCompare(i))}var Me=[["beforeCommand","before_command"],["beforeMutation","before_mutation"],["afterCommand","after_command"],["onWrite","on_write"],["onRead","on_read"],["onIndex","on_index"]];function f(r){return[...new Set(r)].sort((e,t)=>e.localeCompare(t))}function b(r){return r!=null}function S(r){return v(`${r.name} import`)}function O(r){return v(`${r.name} export`)}function je(r,e,t){return[...r.map(n=>v(n.name)),...e.filter(n=>n.options!==void 0).map(S),...t.filter(n=>n.options!==void 0).map(O)]}function Be(r,e,t,n){return[...Object.keys(r.flags??{}).map(a=>v(a)),...e.filter(a=>a.flags!==void 0).map(a=>v(a.name)),...t.filter(a=>a.options?.flags!==void 0).map(S),...n.filter(a=>a.options?.flags!==void 0).map(O)]}function De(r){return Me.filter(([e])=>(r[e]?.length??0)>0).map(([,e])=>e)}function Le(r){let e=Object.entries(r??{}).filter(([,t])=>typeof t!="function"&&((t.commands?.length??0)>0||t.resultDiscriminator!==void 0)).map(([t,n])=>{let a=n;return{format:t,commands:f((a.commands??[]).map(i=>v(i))),result_discriminator:a.resultDiscriminator!==void 0}}).sort((t,n)=>t.format.localeCompare(n.format));return e.length>0?{renderer_ownership:e}:{}}function He(r){return!r||r.length===0?{}:{assurance_providers:f(r.map(e=>e.id))}}function Ke(r,e,t){return{item_types:f((r.itemTypes??[]).map(n=>n.name)),item_fields:f((r.itemFields??[]).map(n=>n.name)),...(r.relationshipKinds?.length??0)>0?{relationship_kinds:f(r.relationshipKinds.map(n=>n.kind))}:{},migrations:f((r.migrations??[]).flatMap(n=>typeof n.id=="string"?[n.id]:[])),profiles:f((r.profiles??[]).map(n=>n.name)),importers:f(e.map(n=>v(n.name))),exporters:f(t.map(n=>v(n.name))),search_providers:f((r.searchProviders??[]).map(n=>n.name)),vector_store_adapters:f((r.vectorStoreAdapters??[]).map(n=>n.name)),...He(r.assuranceProviders),parser_overrides:f(Object.keys(r.parsers??{}).map(n=>v(n))),service_overrides:f(Object.keys(r.services??{}).map(n=>String(n).trim().toLowerCase())),renderer_overrides:f(Object.keys(r.renderers??{}).map(n=>String(n).trim().toLowerCase())),...Le(r.renderers),preflight_overrides:(r.preflights??[]).length,preflight_ownership:(r.preflights??[]).map(n=>({commands:[...n.commands??[]]}))}}function qe(r){let e=(r.commands??[]).filter(b),t=(r.importers??[]).filter(b),n=(r.exporters??[]).filter(b),a=t.map(S),i=n.map(O),o=je(e,t,n),s=Be(r,e,t,n),d=r.hooks??{},l=Ke(r,t,n);return{capabilities:N(r),commands:f(o),command_overrides:f(Object.keys(r.commandOverrides??{}).map(E=>v(E))),command_handlers:f([...o,...a,...i]),hooks:De(d),flag_commands:f(s),...l}}var Ue=["commands","commandOverrides","flags","parsers","renderers","services","preflights","itemTypes","itemFields","relationshipKinds","migrations","profiles","searchProviders","vectorStoreAdapters","assuranceProviders","importers","exporters"];function Ve(r){return(r.itemFields??[]).filter(e=>typeof e?.name=="string"&&ae.has(e.name.trim())).map(e=>({code:"reserved_item_field",severity:"error",message:`Item field "${e.name}" collides with reserved item metadata; rename it with an extension-specific prefix before publishing.`,field:e.name}))}function ze(r){return[...Object.values(r.flags??{}).flat(),...(r.commands??[]).flatMap(e=>e.flags??[]),...(r.importers??[]).flatMap(e=>e.options?.flags??[]),...(r.exporters??[]).flatMap(e=>e.options?.flags??[])].flatMap(e=>{if(typeof e?.long!="string"&&typeof e?.short!="string")return[];let t=H(e.long,e.short);if(t===null)return[];let{token:n,failure:a}=t;return[{code:a,severity:"error",message:`Flag "${n}" ${K(n,a)}.`,field:n}]})}function ue(r){let e=new Set;for(let t of r){let n=D(t)??x(t);n!==null&&e.add(n)}return[...e].sort((t,n)=>t.localeCompare(n))}function We(r,e){let t=[];if(e===null)return r.length>0&&t.push({code:"manifest_capabilities_absent",severity:"warning",message:`Blueprint exercises ${r.length===1?"capability":"capabilities"} [${r.join(", ")}] but declares none; set capabilities to deriveExtensionCapabilities(blueprint) so the manifest grant matches.`}),t;let n=new Set(e),a=new Set(r);for(let i of r)n.has(i)||t.push({code:"capability_undeclared",severity:"error",message:`Blueprint exercises capability "${i}" but it is absent from the declared capabilities; activation throws extension_capability_missing \u2014 add "${i}" to the manifest capabilities.`,capability:i});for(let i of e)a.has(i)||t.push({code:"capability_unused",severity:"warning",message:`Capability "${i}" is declared but no blueprint surface exercises it; drop it to keep the manifest least-privilege (pm package doctor reports this as extension_capability_unused).`,capability:i});return t}function Ge(r){let e=[],t=new Map;for(let a of r.commands??[]){let i=v(a.name);t.set(i,(t.get(i)??0)+1)}for(let[a,i]of t)i>1&&e.push({code:"duplicate_command",severity:"warning",message:`Command "${a}" is declared ${i} times in commands; the later registration shadows the earlier one at dispatch.`,command:a});let n=new Set(Object.keys(r.commandOverrides??{}).map(a=>v(a)));for(let a of t.keys())n.has(a)&&e.push({code:"command_override_conflict",severity:"warning",message:`Command "${a}" is declared both as a new command definition and as a command override; register one or the other.`,command:a});return e}function Ye(r){let e=[];for(let t of Ue)t in r&&!$(r[t])&&e.push({code:"empty_surface",severity:"warning",message:`Blueprint field "${t}" is present but empty; remove it or populate it.`,field:t});if("hooks"in r){let t=r.hooks??{};[t.beforeCommand,t.beforeMutation,t.afterCommand,t.onWrite,t.onRead,t.onIndex].some($)||e.push({code:"empty_surface",severity:"warning",message:'Blueprint field "hooks" is present but registers no lifecycle hooks; remove it or populate it.',field:"hooks"})}return e}function k(r,e={}){let t=N(r),n=e.declaredCapabilities??r.manifest?.capabilities,a=Array.isArray(n)?ue(n):null,i=[...We(t,a),...Ge(r),...ze(r),...Ve(r),...Ye(r)];return{ok:i.every(o=>o.severity!=="error"),findings:i,used:t,declared:a}}function ve(r,e){let{additionalCapabilities:t,...n}=e,a=Array.isArray(t)?ue(t):[],i=[...new Set([...N(r),...a])].sort((o,s)=>o.localeCompare(s));return{...n,capabilities:i}}function Br(r,e){let t=ve(r,e);return{module:Oe({...r,manifest:t}),manifest:t}}function ge(r,e){if(r.status==="absent"||r.status==="ok")return null;let t=`${r.kind}_${r.status}`,n="";switch(t){case"pm_min_version_invalid":n=`pm_min_version "${r.required}" is not a valid version; the extension is treated as incompatible and the loader skips it.`;break;case"pm_min_version_unchecked":n=`pm_min_version "${r.required}" could not be compared against pm ${e}; compatibility is unverified.`;break;case"pm_min_version_unmet":n=`Requires pm >= ${r.required} but the target is pm ${e}; the loader skips the extension.`;break;case"pm_max_version_invalid":n=`pm_max_version "${r.required}" is not a valid inclusive upper bound (version ranges are not allowed); the extension is treated as incompatible and the loader skips it.`;break;case"pm_max_version_unchecked":n=`pm_max_version "${r.required}" could not be compared against pm ${e}; compatibility is unverified.`;break;case"pm_max_version_exceeded":n=`Allows pm <= ${r.required} but the target is pm ${e}; the loader skips the extension.`;break;case"pm_max_version_exceeded_warn":n=`Target pm ${e} is newer than pm_max_version ${r.required}, but the "warn" exceeded mode lets it load with a warning.`;break}return{code:t,severity:r.allowed?"warning":"error",constraint:r.kind,required:r.required,current:e,message:n}}function A(r,e){let t=q(r.pm_min_version,e.pmVersion),n=U(r.pm_max_version,e.pmVersion,e.pmMaxVersionExceededMode??"block"),a=L(r).findings.map(d=>({code:d.code,severity:"warning",constraint:"manifest",required:d.code==="manifest_unknown_key"?d.path:"pm_min_version",current:e.pmVersion,path:d.path,...d.suggested_key?{suggested_key:d.suggested_key}:{},message:d.message})),i=[],o=ge(t,e.pmVersion);o!==null&&i.push(o);let s=ge(n,e.pmVersion);return s!==null&&i.push(s),{compatible:t.allowed&&n.allowed,findings:[...a,...i],pmVersion:e.pmVersion}}var Xe=new Set(["capability_undeclared","capability_unused","manifest_capabilities_absent"]);function he(r,e={}){let t=k(r,{declaredCapabilities:e.declaredCapabilities}),n=e.identity?ve(r,e.identity):null,a=e.target?A(n??r.manifest??{},e.target):null,i=[...(n!==null&&e.declaredCapabilities===void 0?t.findings.filter(o=>!Xe.has(o.code)):t.findings).map(o=>({source:"blueprint",severity:o.severity,code:o.code,message:o.message})),...(a?.findings??[]).map(o=>({source:"compatibility",severity:o.severity,code:o.code,message:o.message}))];return{ok:i.every(o=>o.severity!=="error"),capabilities:t.used,blueprint:t,manifest:n,compatibility:a,findings:i}}import{decode as Zr,encode as et}from"@toon-format/toon";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="0b5eab16-4305-5dfd-902c-fefc7ee0de2b")}catch{}})();function u(r,e){return r.name??e??""}var Je={before_command:"beforeCommand",before_mutation:"beforeMutation",after_command:"afterCommand",on_read:"onRead",on_write:"onWrite",on_index:"onIndex"},F={before_command:"beforeCommand",after_command:"afterCommand",on_read:"onRead",on_write:"onWrite",on_index:"onIndex"};function p(r){return r.trim().toLowerCase()}function ye(r){return p(r).replaceAll("-","_")}function g(r){return r?` from extension "${r}"`:""}function c(r){return[...new Set(r)].sort((e,t)=>e.localeCompare(t))}function y(r){if(typeof r!="string")throw new Error('A command name string is required. Pass it via the options object, e.g. runRegisteredCommandForTest(activation, { command: "my command" }) \u2014 positional command arguments are not supported.');return r.trim().toLowerCase().split(/\s+/).filter(e=>e.length>0).join(" ")}function m(r){return r.length>0?r.join(", "):"(none)"}function we(r,e,t){let n=new Set(r??[]),a=c(e.filter(i=>!n.has(i)));if(a.length>0)throw new Error(`Expected package manifest ${t} to include ${a.join(", ")}; available: ${m(c(r??[]))}`)}function be(r){let e=new Set;for(let t of r)typeof t.long=="string"&&t.long.trim().length>0&&e.add(t.long.trim()),typeof t.short=="string"&&t.short.trim().length>0&&e.add(t.short.trim());return e}function P(r){let e=w(r);if(!e)return{};let t=w(e.manifest);if(t)return t;let n=w(e.default);return w(n?.manifest)||(n&&typeof e.default!="function"&&("name"in n||"capabilities"in n)?n:typeof r!="function"&&("name"in e||"capabilities"in e)?e:{})}function T(r,e){return e??(typeof r.name=="string"&&r.name.trim().length>0?r.name.trim():"test-extension")}function Ee(r,e){return Array.isArray(e.capabilities)?[...e.capabilities]:Array.isArray(r.capabilities)?r.capabilities.filter(t=>typeof t=="string"):[]}function xe(r,e,t){return{disabled_by_flag:!1,roots:{global:"",project:""},configured_enabled:[],configured_disabled:[],discovered:[],effective:[],warnings:[],policy:t.policy,failed:[],loaded:[{layer:t.layer,directory:"",manifest_path:"",name:t.name,version:typeof e.version=="string"?e.version:"0.0.0",entry:typeof e.entry=="string"?e.entry:"./index.js",priority:typeof e.priority=="number"?e.priority:0,entry_path:"",capabilities:t.capabilities,manifest_version:typeof e.manifest_version=="number"?e.manifest_version:void 0,pm_min_version:typeof e.pm_min_version=="string"?e.pm_min_version:void 0,pm_max_version:typeof e.pm_max_version=="string"?e.pm_max_version:void 0,engines:e.engines,trusted:e.trusted,provenance:e.provenance,sandbox_profile:e.sandbox_profile,permissions:e.permissions,activation:e.activation,module:r}]}}async function Qe(r,e={}){let t=P(r);return oe(xe(r,t,{name:T(t,e.name),layer:e.layer??"project",capabilities:Ee(t,e),policy:e.policy??C()}))}async function Ze(r,e={}){let t=P(r);return ne(xe(r,t,{name:T(t,e.name),layer:e.layer??"project",capabilities:Ee(t,{}),policy:C()}),e.activation,e.deactivateTimeoutMs===void 0?{}:{deactivate_timeout_ms:e.deactivateTimeoutMs})}async function I(r,e){let t=y(e.command);if(t.length===0)throw new Error("Expected command name must be a non-empty string");if(!r.handlers.some(o=>o.command===t)){let o=c(r.handlers.map(s=>s.command));throw new Error(`Expected a registered command handler for "${t}" to invoke. Available command handlers: ${m(o)}`)}if(e.sdk!==void 0&&e.sdkFactory!==void 0)throw new TypeError("runRegisteredCommandForTest accepts sdk or sdkFactory, not both");let n=e.pmRoot??"",a={json:!0,quiet:!0,noPager:!0,...e.global},i=e.sdk??e.sdkFactory?.({pmRoot:n,global:a})??(n.length>0?se(n,new pe({pmRoot:n}),void 0,t):void 0);return J(r,{command:t,args:e.args?[...e.args]:[],options:e.options?{...e.options}:{},global:a,pm_root:n,...i===void 0?{}:{sdk:i}})}async function er(r,e){if((r.beforeMutation?.length??0)===0)throw new Error("Expected a registered before_mutation hook to invoke");await z(r,e.context)}async function rr(r,e){let t=e.kind;if(t==="before_mutation")throw new Error("Invoke before_mutation hooks with runRegisteredMutationGuardForTest so denials and failures retain fail-closed semantics.");if((r[F[t]]?.length??0)===0){let n=c(Object.keys(F).filter(a=>(r[F[a]]?.length??0)>0));throw new Error(`Expected a registered "${t}" hook to invoke. Hook kinds with registrations: ${m(n)}`)}switch(e.kind){case"before_command":return V(r,e.context);case"after_command":return W(r,e.context);case"on_read":return Y(r,e.context);case"on_write":return G(r,e.context);case"on_index":return X(r,e.context)}}async function tr(r,e){let t=y(e.command);if(!r.overrides.some(n=>n.command===t))throw new Error(`Expected a registered parser override for command "${t}" to invoke. Available parser override commands: ${m(c(r.overrides.map(n=>n.command)))}`);return Q(r,e)}async function nr(r,e){if(r.overrides.length===0)throw new Error("Expected a registered preflight override to invoke, but none are registered.");return Z(r,e)}async function or(r,e){let t=y(e.command);if(!r.overrides.some(n=>n.command===t))throw new Error(`Expected a registered command override for command "${t}" to invoke. Available command override commands: ${m(c(r.overrides.map(n=>n.command)))}`);return re(r,e)}async function ir(r,e){if(!r.overrides.some(t=>t.format===e.format))throw new Error(`Expected a registered renderer override for format "${e.format}" to invoke. Available renderer override formats: ${m(c(r.overrides.map(t=>t.format)))}`);return te(r,e)}async function ar(r,e){if(!r.overrides.some(t=>t.service===e.service))throw new Error(`Expected a registered service override for service "${e.service}" to invoke. Available service override services: ${m(c(r.overrides.map(t=>t.service)))}`);return ee(r,e)}var sr={query:["query"],embed:["embed"],embedBatch:["embedBatch","embed_batch"],queryExpansion:["queryExpansion","query_expansion"],rerank:["rerank"]};async function dr(r,e){let t=de(r,e.provider);if(!t){let i=c(r.search_providers.map(o=>o.definition.name));throw new Error(`Expected a registered search provider "${e.provider}" to invoke. Available search providers: ${m(i)}`)}let n=t.runtime_definition,a=sr[e.operation].map(i=>n[i]).find(i=>typeof i=="function");if(typeof a!="function")throw new Error(`Registered search provider "${e.provider}" does not implement the "${e.operation}" operation.`);return await a(e.context)}async function mr(r,e){let t=me(r,e.adapter);if(!t){let a=c(r.vector_store_adapters.map(i=>i.definition.name));throw new Error(`Expected a registered vector store adapter "${e.adapter}" to invoke. Available vector store adapters: ${m(a)}`)}let n=t.runtime_definition[e.operation];if(typeof n!="function")throw new Error(`Registered vector store adapter "${e.adapter}" does not implement the "${e.operation}" operation.`);return await n(e.context)}async function cr(r,e){let t=ke(r,{migration:e.migration,extensionName:e.extensionName}),n=ce(t).run;if(typeof n!="function")throw new Error(`Registered migration "${e.migration}" does not implement a run function to invoke.`);let a=t.definition.status,i={id:t.definition.id,command:"migration",layer:t.layer,extension:t.name,pm_root:e.pmRoot??"",status:(typeof a=="string"?a.trim().toLowerCase():"")||"pending"};return await n(i)}async function lr(r,e){let t=_e(r.registrations,{importer:e.importer,extensionName:e.extensionName});return I(r.commands,{command:`${t.importer} import`,args:e.args,options:e.options,global:e.global,pmRoot:e.pmRoot})}async function fr(r,e){let t=$e(r.registrations,{exporter:e.exporter,extensionName:e.extensionName});return I(r.commands,{command:`${t.exporter} export`,args:e.args,options:e.options,global:e.global,pmRoot:e.pmRoot})}function rt(r,e={}){let t=e.deactivated??1;if(r.deactivated!==t)throw new Error(`Expected ${t} extension${t===1?"":"s"} to deactivate cleanly, but ${r.deactivated} did.`);let n=e.failed??0;if(r.failed.length!==n){let a=r.failed.map(i=>`${i.layer}:${i.name} (${i.error})`).join(", ");throw new Error(`Expected ${n} teardown failure${n===1?"":"s"}, but observed ${r.failed.length}${a.length>0?`: ${a}`:""}.`)}return r}function tt(r,e){if(e.packageName!==void 0&&r.package_name!==e.packageName)throw new Error(`Expected package manifest package_name to be "${e.packageName}"; received "${r.package_name??"(none)"}"`);if(e.aliases!==void 0&&we(r.aliases,e.aliases,"aliases"),e.resources!==void 0)for(let[t,n]of Object.entries(e.resources))we(r.resources[t],n,`pm.${t}`);return r}function pr(r,e){let t=y(u(e,e.command));if(t.length===0)throw new Error("Expected command name must be a non-empty string");let n=r.commands.filter(o=>o.command===t),a=e.extensionName?n.find(o=>o.name===e.extensionName):n[0];if(!a){let o=r.commands.map(d=>d.command).sort((d,l)=>d.localeCompare(l)),s=e.extensionName?` from extension "${e.extensionName}"`:"";throw new Error(`Expected extension command "${t}"${s} to be registered. Available commands: ${m(o)}`)}if(e.action!==void 0&&a.action!==e.action)throw new Error(`Expected extension command "${t}" action "${e.action}", received "${a.action}"`);if(e.arguments!==void 0){let o=(a.arguments??[]).map(d=>d.name),s=e.arguments.filter(d=>!o.includes(d));if(s.length>0)throw new Error(`Expected extension command "${t}" arguments ${m(e.arguments)}; missing ${m(s)}; available ${m(o)}`)}let i=r.flags.filter(o=>o.target_command===t&&(e.extensionName===void 0||o.name===e.extensionName)).flatMap(o=>o.flags);if(e.flags!==void 0){let o=be(i),s=e.flags.filter(d=>!o.has(d));if(s.length>0)throw new Error(`Expected extension command "${t}" flags ${m(e.flags)}; missing ${m(s)}; available ${m([...o].sort((d,l)=>d.localeCompare(l)))}`)}return{command:a,flags:i}}function gr(r,e){let t=y(u(e,e.targetCommand));if(t.length===0)throw new Error("Expected target command name must be a non-empty string");let n=r.flags.filter(i=>i.target_command===t),a;if(e.extensionName)a=n.find(i=>i.name===e.extensionName);else if(n.length===1)a=n[0];else if(n.length>1){let i=c(n.map(o=>o.name));throw new Error(`Expected flags for target command "${t}" matched multiple extensions: ${m(i)}. Specify extensionName to choose one registration.`)}if(!a){let i=c(r.flags.map(s=>s.target_command)),o=c(n.map(s=>s.name));throw new Error(`Expected flags for target command "${t}"${g(e.extensionName)} to be registered. Available flag target commands: ${m(i)}; matching extensions: ${m(o)}`)}if(e.flags!==void 0){let i=be(a.flags),o=e.flags.filter(s=>!i.has(s));if(o.length>0)throw new Error(`Expected flags for target command "${t}" to include ${m(e.flags)}; missing ${m(o)}; available ${m([...i].sort((s,d)=>s.localeCompare(d)))}`)}return a}function ur(r,e){let t=Je[e.kind],n=r[t]??[],a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(n.map(o=>o.name));throw new Error(`Expected a "${e.kind}" hook${g(e.extensionName)} to be registered. Available "${e.kind}" hooks: ${m(i)}`)}return a}function vr(r,e){let t=p(u(e,e.provider));if(t.length===0)throw new Error("Expected search provider name must be a non-empty string");let n=r.search_providers.filter(i=>p(i.definition.name)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.search_providers.map(o=>o.definition.name));throw new Error(`Expected search provider "${t}"${g(e.extensionName)} to be registered. Available search providers: ${m(i)}`)}return a}function hr(r,e){let t=p(u(e,e.adapter));if(t.length===0)throw new Error("Expected vector store adapter name must be a non-empty string");let n=r.vector_store_adapters.filter(i=>p(i.definition.name)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.vector_store_adapters.map(o=>o.definition.name));throw new Error(`Expected vector store adapter "${t}"${g(e.extensionName)} to be registered. Available vector store adapters: ${m(i)}`)}return a}function _e(r,e){let t=p(u(e,e.importer));if(t.length===0)throw new Error("Expected importer name must be a non-empty string");let n=r.importers.filter(i=>p(i.importer)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.importers.map(o=>o.importer));throw new Error(`Expected importer "${t}"${g(e.extensionName)} to be registered. Available importers: ${m(i)}`)}return a}function $e(r,e){let t=p(u(e,e.exporter));if(t.length===0)throw new Error("Expected exporter name must be a non-empty string");let n=r.exporters.filter(i=>p(i.exporter)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.exporters.map(o=>o.exporter));throw new Error(`Expected exporter "${t}"${g(e.extensionName)} to be registered. Available exporters: ${m(i)}`)}return a}function yr(r,e){let t=p(u(e,e.field));if(t.length===0)throw new Error("Expected item field name must be a non-empty string");let n=r.item_fields.filter(a=>e.extensionName===void 0||a.name===e.extensionName).map(a=>({registration:a,field:a.fields.find(i=>p(i.name)===t)})).filter(a=>a.field!==void 0).find(a=>e.type===void 0||a.field.type===e.type);if(!n){let a=c(r.item_fields.flatMap(i=>i.fields.map(o=>`${o.name}:${o.type}`)));throw new Error(`Expected item field "${t}"${g(e.extensionName)} to be registered. Available item fields: ${m(a)}`)}return n}function wr(r,e){let t=p(u(e,e.itemType));if(t.length===0)throw new Error("Expected item type name must be a non-empty string");let n=r.item_types.filter(a=>e.extensionName===void 0||a.name===e.extensionName).map(a=>({registration:a,itemType:a.types.find(i=>p(i.name)===t)})).filter(a=>a.itemType!==void 0).find(a=>e.folder===void 0||a.itemType.folder===e.folder);if(!n){let a=c(r.item_types.flatMap(i=>i.types.map(o=>`${o.name}:${o.folder}`)));throw new Error(`Expected item type "${t}"${g(e.extensionName)} to be registered. Available item types: ${m(a)}`)}return n}function br(r,e){let t=ye(u(e,e.profile));if(t.length===0)throw new Error("Expected profile name must be a non-empty string");let n=r.profiles.filter(a=>e.extensionName===void 0||a.name===e.extensionName).find(a=>ye(a.profile.name)===t);if(!n){let a=c(r.profiles.map(i=>i.profile.name));throw new Error(`Expected profile "${t}"${g(e.extensionName)} to be registered. Available profiles: ${m(a)}`)}return{registration:n,profile:n.profile}}function Er(r,e){let t=y(u(e,e.command));if(t.length===0)throw new Error("Expected command name must be a non-empty string");let n=r.overrides.filter(i=>i.command===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.overrides.map(o=>o.command));throw new Error(`Expected command override "${t}"${g(e.extensionName)} to be registered. Available command overrides: ${m(i)}`)}return a}function xr(r,e){let t=y(u(e,e.command));if(t.length===0)throw new Error("Expected command name must be a non-empty string");let n=r.overrides.filter(i=>i.command===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.overrides.map(o=>o.command));throw new Error(`Expected parser override "${t}"${g(e.extensionName)} to be registered. Available parser overrides: ${m(i)}`)}return a}function _r(r,e={}){let t=e.extensionName?r.overrides.find(n=>n.name===e.extensionName):r.overrides[0];if(!t){let n=c(r.overrides.map(a=>a.name));throw new Error(`Expected a preflight override${g(e.extensionName)} to be registered. Available preflight overrides: ${m(n)}`)}return t}function $r(r,e){let t=p(u(e,e.format));if(t.length===0)throw new Error("Expected renderer format must be a non-empty string");let n=r.overrides.filter(i=>i.format===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.overrides.map(o=>o.format));throw new Error(`Expected renderer override "${t}"${g(e.extensionName)} to be registered. Available renderer overrides: ${m(i)}`)}return a}function kr(r,e){let t=p(u(e,e.service));if(t.length===0)throw new Error("Expected service name must be a non-empty string");let n=r.overrides.filter(i=>p(i.service)===t),a=e.extensionName?n.find(i=>i.name===e.extensionName):n[0];if(!a){let i=c(r.overrides.map(o=>o.service));throw new Error(`Expected service override "${t}"${g(e.extensionName)} to be registered. Available service overrides: ${m(i)}`)}return a}function ke(r,e){let t=p(u(e,e.migration));if(t.length===0)throw new Error("Expected migration id must be a non-empty string");let n=r.migrations.filter(s=>(e.extensionName===void 0||s.name===e.extensionName)&&typeof s.definition.id=="string"&&p(s.definition.id)===t),a=n.find(s=>e.mandatory===void 0||(s.definition.mandatory??!1)===e.mandatory);if(a)return a;let i=n[0];if(i!==void 0)throw new Error(`Expected migration "${t}"${g(e.extensionName)} to have mandatory=${e.mandatory}, but it is mandatory=${i.definition.mandatory??!1}.`);let o=c(r.migrations.map(s=>`${typeof s.definition.id=="string"&&s.definition.id.trim().length>0?s.definition.id.trim():"(unnamed)"}:${s.definition.mandatory===!0}`));throw new Error(`Expected migration "${t}"${g(e.extensionName)} to be registered. Available migrations: ${m(o)}`)}function Cr(r,e){let t=(d,l)=>{let E=new Set;for(let M of d){let j=x(M);if(j===null)throw new Error(`Expected ${l} capability "${M}" to be a known extension capability. Use canonical capability names (see manifest.capabilities).`);E.add(j)}return E},n=[...t(e.declared,"declared")].sort((d,l)=>d.localeCompare(l)),a=t(e.allowUnused??[],"allowUnused"),i=ie(r,{extensionName:e.extensionName}),o=new Set(i),s=n.filter(d=>!o.has(d)&&!a.has(d));if(s.length>0){let d=g(e.extensionName);throw new Error(`Expected every declared capability${d} to be exercised, but [${s.join(", ")}] ${s.length===1?"is":"are"} declared yet never registered against. Remove ${s.length===1?"it":"them"} from manifest.capabilities for least privilege, or pass allowUnused for capabilities registered only behind a runtime flag.`)}return{declared:n,used:i,unused:s}}function nt(r,e={}){let t=k(r,e);if(!t.ok){let n=t.findings.filter(a=>a.severity==="error");throw new Error(`Extension blueprint failed preflight with ${n.length} ${n.length===1?"error":"errors"}:
2
2
  `+n.map(a=>` - [${a.code}] ${a.message}`).join(`
3
3
  `))}return t}function ot(r,e={}){let t=fe(r),n=t.findings.filter(a=>a.severity==="error"||e.strict===!0&&a.severity==="warning");if(n.length>0)throw new Error(`Project profile "${t.profile}" failed lint with ${n.length} ${n.length===1?"issue":"issues"}:
4
4
  `+n.map(a=>` - ${a.severity} [${a.code}] ${a.message}`).join(`
5
5
  `));return t}function it(r,e){let t=Array.isArray(r.capabilities)?r.capabilities:[],n=k(e,{declaredCapabilities:t}),a=n.declared,i=new Set(a),o=new Set(n.used),s=n.used.filter(l=>!i.has(l)),d=a.filter(l=>!o.has(l));if(s.length>0||d.length>0){let l=[];throw s.length>0&&l.push(`missing [${s.join(", ")}] (the blueprint registers ${s.length===1?"a surface":"surfaces"} requiring ${s.length===1?"it":"them"}; activation throws extension_capability_missing)`),d.length>0&&l.push(`unused [${d.join(", ")}] (declared but no surface exercises ${d.length===1?"it":"them"}; drop for least privilege)`),new Error(`Manifest capabilities do not match the blueprint: ${l.join("; ")}. Set capabilities to synthesizeExtensionManifest(blueprint, identity).capabilities to stay in sync.`)}return{used:n.used,declared:a,missing:s,unused:d,findings:n.findings}}function at(r,e){let t=A(r,e),n=t.findings.filter(a=>a.severity==="error");if(n.length>0)throw new Error(`Extension manifest is not compatible with pm ${t.pmVersion}: ${n.map(a=>a.message).join("; ")}`);return t}function st(r,e={}){let t=he(r,e);if(!t.ok){let n=t.findings.filter(a=>a.severity==="error");throw new Error(`Extension failed preflight with ${n.length} ${n.length===1?"error":"errors"}:
6
6
  `+n.map(a=>` - [${a.source}:${a.code}] ${a.message}`).join(`
7
7
  `))}return t}function Rr(r){if(!B(r))throw new Error("createExtensionTestHarness received a module with no activate export. Pass the extension module (with an activate(api) function on the module or its default export) as the first argument, and options second.")}async function dt(r,e={}){Rr(r);let t=P(r),n=T(t,e.name),a=e.layer??"project",i=await Qe(r,e);if(i.failed.length>0){let o=i.failed.map(s=>{let d=s.trace?.missing_capability,l=d?`${s.error}; missing capability "${d}"`:s.error;return`${s.layer}:${s.name} (${l})`}).join(", ");throw new Error(`createExtensionTestHarness could not activate the extension cleanly: ${o}. Declare the required capability in the manifest (or pass it via options.capabilities), or use activateExtensionForTest directly to inspect a failed activation.`)}return{module:r,name:n,layer:a,activation:i,activationSummary(o){return R(i,o)},renderMarkdown(o={}){let{extensionName:s,...d}=o??{};return le(R(i,{extensionName:s}),d)},assertCommandContract(o){return pr(i.registrations,o)},assertFlags(o){return gr(i.registrations,o)},assertItemField(o){return yr(i.registrations,o)},assertItemType(o){return wr(i.registrations,o)},assertProfile(o){return br(i.registrations,o)},assertHook(o){return ur(i.hooks,o)},assertCommandOverride(o){return Er(i.commands,o)},assertParserOverride(o){return xr(i.parsers,o)},assertPreflightOverride(o){return _r(i.preflight,o)},assertRendererOverride(o){return $r(i.renderers,o)},assertServiceOverride(o){return kr(i.services,o)},assertSearchProvider(o){return vr(i.registrations,o)},assertVectorStoreAdapter(o){return hr(i.registrations,o)},assertImporter(o){return _e(i.registrations,o)},assertExporter(o){return $e(i.registrations,o)},assertMigration(o){return ke(i.registrations,o)},assertCapabilityUsage(o){return Cr(i,o)},runCommand(o){return I(i.commands,o)},runHook(o){return rr(i.hooks,o)},runMutationGuard(o){return er(i.hooks,o)},runCommandOverride(o){return or(i.commands,o)},runParserOverride(o){return tr(i.parsers,o)},runPreflightOverride(o){return nr(i.preflight,o)},runRendererOverride(o){return ir(i.renderers,o)},runServiceOverride(o){return ar(i.services,o)},runSearchProvider(o){return dr(i.registrations,o)},runVectorStoreAdapter(o){return mr(i.registrations,o)},runMigration(o){return cr(i.registrations,o)},runImporter(o){return lr(i,o)},runExporter(o){return fr(i,o)},deactivate(o={}){return Ze(r,{name:n,layer:a,activation:i,deactivateTimeoutMs:o.deactivateTimeoutMs})}}}export{Ir as a,Mr as b,Oe as c,jr as d,N as e,qe as f,k as g,ve as h,Br as i,A as j,he as k,Zr as l,et as m,Qe as n,Ze as o,I as p,er as q,rr as r,tr as s,nr as t,or as u,ir as v,ar as w,dr as x,mr as y,cr as z,lr as A,fr as B,rt as C,tt as D,pr as E,gr as F,ur as G,vr as H,hr as I,_e as J,$e as K,yr as L,wr as M,br as N,Er as O,xr as P,_r as Q,$r as R,kr as S,ke as T,Cr as U,nt as V,ot as W,it as X,at as Y,st as Z,dt as _};
8
- //# sourceMappingURL=chunk-J4LPQCET.js.map
8
+ //# sourceMappingURL=chunk-OJ77ZQN3.js.map