@unbrained/pm-cli 2026.11.5 → 2026.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +7 -0
  3. package/dist/cli/register-operations.js +1 -1
  4. package/dist/cli-bundle/bundle-manifest.json +1 -1
  5. package/dist/cli-bundle/chunks/{chunk-XLSHFYXZ.js → chunk-PE3ASURT.js} +2 -2
  6. package/dist/cli-bundle/chunks/{chunk-2RPORE7M.js → chunk-QNWUIPBO.js} +3 -3
  7. package/dist/cli-bundle/chunks/{chunk-HRCMORE7.js → chunk-SLC5UWCM.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-OJDMJT7Y.js → chunk-TSQCUBUX.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-F6NDMKZ4.js → chunk-WC4M2H6R.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-JI2GDE4I.js → chunk-X3URBPMV.js} +3 -3
  11. package/dist/cli-bundle/chunks/{item-transaction-QEPBUCMY.js → item-transaction-TBKEATN6.js} +2 -2
  12. package/dist/cli-bundle/chunks/{register-mutation-WC7OSQID.js → register-mutation-MDSUU3G7.js} +2 -2
  13. package/dist/cli-bundle/chunks/register-operations-WJHZJFK2.js +2 -0
  14. package/dist/cli-bundle/focused-chunks/{chunk-5PMJOJCZ.js → chunk-2KTJY7BV.js} +3 -3
  15. package/dist/cli-bundle/focused-chunks/{chunk-NQ7GYFOX.js → chunk-WSOAASCY.js} +4 -4
  16. package/dist/cli-bundle/focused-chunks/{item-transaction-AEAYVVHA.js → item-transaction-H2XACBOP.js} +2 -2
  17. package/dist/cli-bundle/main.js +2 -2
  18. package/dist/cli-bundle/sdk-core.js +1 -1
  19. package/dist/cli-bundle/sdk-governance.js +1 -1
  20. package/dist/cli-bundle/sdk-merge.js +3 -3
  21. package/dist/cli-bundle/sdk-runtime.js +1 -1
  22. package/dist/cli-bundle/sdk-testing.js +1 -1
  23. package/dist/cli-bundle/sdk.js +1 -1
  24. package/dist/sdk/governance/health/projection.js +1 -1
  25. package/dist/sdk/governance/health.d.ts +3 -3
  26. package/dist/sdk/governance/health.js +2 -2
  27. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +7 -0
  28. package/docs/RELEASING.md +24 -6
  29. package/marketplace.json +1 -1
  30. package/package.json +1 -1
  31. package/packages/pm-beads/package.json +1 -1
  32. package/packages/pm-calendar/package.json +1 -1
  33. package/packages/pm-command-kit/package.json +1 -1
  34. package/packages/pm-digital-twin/package.json +1 -1
  35. package/packages/pm-governance-audit/package.json +1 -1
  36. package/packages/pm-guide-shell/package.json +1 -1
  37. package/packages/pm-kanban/package.json +1 -1
  38. package/packages/pm-lifecycle-hooks/package.json +1 -1
  39. package/packages/pm-linked-test-adapters/package.json +1 -1
  40. package/packages/pm-search-advanced/package.json +1 -1
  41. package/packages/pm-templates/package.json +1 -1
  42. package/packages/pm-todos/package.json +1 -1
  43. package/packages/pm-vcs/package.json +1 -1
  44. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  45. package/plugins/pm-claude/package.json +1 -1
  46. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  47. package/plugins/pm-codex/package.json +1 -1
  48. package/plugins/pm-codex/plugin.json +1 -1
  49. package/runtime-dependencies.json +1 -1
  50. package/dist/cli-bundle/chunks/register-operations-PO63DBZH.js +0 -2
@@ -1,2 +1,2 @@
1
- import{a as f,b as I,f as T,i as _,j as M,l as y}from"./chunk-XLSHFYXZ.js";import{Vi as g,Zd as l,_d as p}from"./chunk-7ZRCYESH.js";import{A as c,C as u}from"./chunk-O4ZLEN4T.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4175f7f5-a689-5d05-982a-f92e21bc83e7")}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]="3041c268-69c8-58e5-8a68-eaaa3c0dbd3b")}catch{}})();async function ce(e){let{plan:t}=e,r=await y({pmRoot:e.pmRoot,author:e.author,transactionId:t.transaction_id,mutations:t.mutations}),o=new Map(r.warnings.map(i=>[i.index,i.warnings])),s=t.rows.map(i=>{let n={...i};delete n.warnings;let a=o.get(i.index);return a!==void 0&&(n.warnings=a),n});return{validation:r,rows:s}}async function ue(e){let t=e.upsertKey?.trim();if(t!==void 0&&t.length===0)throw new u("Upsert key must be a non-empty field name.",c.USAGE);let r=e.settings??await g(e.pmRoot),o=e.transactionId?.trim()??"",s=o.length>0?o:I(e.input),i=await _(e.pmRoot,r),n=l(i.schema).definitions,a=(n.find(m=>m.metadata_key===t)??n.find(m=>m.key===t||p(m)===t))?.metadata_key??f(t),d=a===void 0?void 0:{key:a,existing:await M(e.pmRoot,r,i,a)};return{...T(e.input,{transactionId:s,idPrefix:r.id_prefix,runtimeFields:n,...d===void 0?{}:{upsert:d}}),transaction_id:s,transaction_id_source:o.length>0?"explicit":"derived",...d===void 0?{}:{upsert_key:d.key}}}export{ce as a,ue as b};
2
- //# sourceMappingURL=chunk-HRCMORE7.js.map
1
+ import{a as f,b as I,f as T,i as _,j as M,l as y}from"./chunk-PE3ASURT.js";import{Vi as g,Zd as l,_d as p}from"./chunk-7ZRCYESH.js";import{A as c,C as u}from"./chunk-O4ZLEN4T.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4175f7f5-a689-5d05-982a-f92e21bc83e7")}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]="3041c268-69c8-58e5-8a68-eaaa3c0dbd3b")}catch{}})();async function ce(e){let{plan:t}=e,r=await y({pmRoot:e.pmRoot,author:e.author,transactionId:t.transaction_id,mutations:t.mutations}),o=new Map(r.warnings.map(i=>[i.index,i.warnings])),s=t.rows.map(i=>{let n={...i};delete n.warnings;let a=o.get(i.index);return a!==void 0&&(n.warnings=a),n});return{validation:r,rows:s}}async function ue(e){let t=e.upsertKey?.trim();if(t!==void 0&&t.length===0)throw new u("Upsert key must be a non-empty field name.",c.USAGE);let r=e.settings??await g(e.pmRoot),o=e.transactionId?.trim()??"",s=o.length>0?o:I(e.input),i=await _(e.pmRoot,r),n=l(i.schema).definitions,a=(n.find(m=>m.metadata_key===t)??n.find(m=>m.key===t||p(m)===t))?.metadata_key??f(t),d=a===void 0?void 0:{key:a,existing:await M(e.pmRoot,r,i,a)};return{...T(e.input,{transactionId:s,idPrefix:r.id_prefix,runtimeFields:n,...d===void 0?{}:{upsert:d}}),transaction_id:s,transaction_id_source:o.length>0?"explicit":"derived",...d===void 0?{}:{upsert_key:d.key}}}export{ce as a,ue as b};
2
+ //# sourceMappingURL=chunk-SLC5UWCM.js.map
@@ -1,2 +1,2 @@
1
- import{Ec as o}from"./chunk-2RPORE7M.js";import{ra as d}from"./chunk-5GWEY4P6.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="41b0b451-a696-5d06-a19d-df1d6b28963c")}catch{}})();function i(e,t,n){return o(e,d(t),n)}export{i as a};
2
- //# sourceMappingURL=chunk-OJDMJT7Y.js.map
1
+ import{Ec as o}from"./chunk-QNWUIPBO.js";import{ra as d}from"./chunk-5GWEY4P6.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="41b0b451-a696-5d06-a19d-df1d6b28963c")}catch{}})();function i(e,t,n){return o(e,d(t),n)}export{i as a};
2
+ //# sourceMappingURL=chunk-TSQCUBUX.js.map
@@ -1,8 +1,8 @@
1
- import{N as fe,Ua as pe,k as ce}from"./chunk-JI2GDE4I.js";import{m as R,ra as le}from"./chunk-LS3GI3H4.js";import{R as ae,Y as se,Z as de,_ as me}from"./chunk-5GWEY4P6.js";import{Dc as q,Ec as U,Ic as V,Jc as z,Kc as W,Lc as G,Mc as Y,Nc as X,Oc as J,Pc as Q,Qc as Z,Rc as ee,Sc as re,Tc as te,Zc as ne,_c as oe,ed as ie,ic as v,lc as x,mc as H,nb as B,ob as D,yb as w,yc as K,zb as L}from"./chunk-7ZRCYESH.js";import{k as C}from"./chunk-O4ZLEN4T.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=B(e.long,e.short);if(t===null)return[];let{token:n,failure:a}=t;return[{code:a,severity:"error",message:`Flag "${n}" ${D(n,a)}.`,field:n}]})}function ue(r){let e=new Set;for(let t of r){let n=H(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=K(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?ce(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=se(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=de(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=me(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{N as fe,Ua as pe,k as ce}from"./chunk-X3URBPMV.js";import{m as R,ra as le}from"./chunk-LS3GI3H4.js";import{R as ae,Y as se,Z as de,_ as me}from"./chunk-5GWEY4P6.js";import{Dc as q,Ec as U,Ic as V,Jc as z,Kc as W,Lc as G,Mc as Y,Nc as X,Oc as J,Pc as Q,Qc as Z,Rc as ee,Sc as re,Tc as te,Zc as ne,_c as oe,ed as ie,ic as v,lc as x,mc as H,nb as B,ob as D,yb as w,yc as K,zb as L}from"./chunk-7ZRCYESH.js";import{k as C}from"./chunk-O4ZLEN4T.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=B(e.long,e.short);if(t===null)return[];let{token:n,failure:a}=t;return[{code:a,severity:"error",message:`Flag "${n}" ${D(n,a)}.`,field:n}]})}function ue(r){let e=new Set;for(let t of r){let n=H(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=K(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?ce(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=se(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=de(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=me(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(!L(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-F6NDMKZ4.js.map
8
+ //# sourceMappingURL=chunk-WC4M2H6R.js.map
@@ -1,4 +1,4 @@
1
- import{a as it,b as Pn,c as Bc,d as Kc,g as Jc,i as bl}from"./chunk-OH6WQ7VT.js";import{L as _r,U as Nl,a as wl,c as vl,d as kl,e as Sl,k as Il,l as Ut,m as mr,n as pr,u as ur,w as Ll}from"./chunk-AUEKTX7V.js";import{$a as el,Ac as rr,Bc as ir,Cc as El,Dc as Tl,Ec as at,Ed as Vl,Fc as Cl,Fd as Bl,J as Me,Jb as Dn,Jc as Ol,Kc as $l,Lc as Fl,Mc as Pl,Nc as cr,Oc as lr,Pc as dr,Qa as Xc,Qb as gl,Ra as Zc,Sb as yl,Sc as Ml,Tc as jl,Uc as Gl,Vc as Ul,Wa as Zo,Wc as ql,Xa as Qo,Ya as er,Yb as Mn,Yc as zl,Zc as Hl,_a as Qc,_b as Gt,ab as tr,b as Yo,ga as Tn,ha as $n,i as fc,ia as Hc,ib as ul,j as hc,ka as ot,l as gc,la as Wc,lb as _l,ma as Xo,mb as fl,na as Fn,pa as rt,rb as jt,rc as nr,sd as fr,uc as Ce,vc as Al,vd as Wl,ya as Vc}from"./chunk-2RPORE7M.js";import{A as cc,B as lc,C as Ko,D as Mt,E as Sn,F as De,G as dc,H as In,I as U,J as Jo,K as j,L as mc,M as pc,N as An,O as uc,P as En,Q as _c,m as Dt,n as tc,o as nc,p as oc,r as rc,s as tt,t as f,u as ic,v as ac,x as Y,y as sc,z as kn}from"./chunk-6VRX2CM7.js";import{A as Ic,D as Ac,Da as On,F as Ec,G as Tc,H as Cc,Ha as qc,I as Rc,J as xc,K as Oc,Ka as zc,L as $c,M as Fc,N as Pc,O as Lc,P as Nc,Q as Dc,R as Mc,S as jc,T as Gc,c as gs,l as Cn,n as je,o as wc,p as Rn,q as vc,qa as nt,r as Ge,s as kc,t as xn,u as Sc,ya as Uc}from"./chunk-LS3GI3H4.js";import{i as yc,o as bc}from"./chunk-DAX3AOFI.js";import{$a as Ue,Dc as ar,Gb as Rl,Ha as tl,Hb as xl,Ic as sr,Lc as Dl,Ra as nl,Sa as ol,Ta as rl,U as _e,Wa as il,Xa as al,Ya as sl,Za as cl,aa as Yc,ab as ll,b as hs,bb as dl,db as ml,fb as Ln,hb as pl,lb as Te,mb as hl,nb as Nn,rb as or}from"./chunk-S4LPZ4TN.js";import{a as _s,b as fs}from"./chunk-UEGXWXUZ.js";import{$a as Ee,A as ks,Ca as Ns,E as Ss,Ga as Ds,Ha as Ms,Ia as js,J as Is,Ja as Gs,K as As,Ka as Us,M as Es,Ma as qs,Na as zs,Oa as Hs,P as Ts,Pa as Ws,Qa as Vs,Ra as Bs,Ua as Ks,Va as vn,Vb as ec,Wa as Js,Xa as Ys,ab as T,bb as Xs,cb as Zs,da as Cs,ga as Rs,h as ys,ha as xs,mb as Qs,pa as Os,q as bs,ra as $s,s as ws,t as wn,u as vs,xa as Fs,ya as Ps,za as Ls}from"./chunk-HNGLDMSZ.js";import{r as et}from"./chunk-FRNMQM45.js";import{$ as _a,$b as ss,Aa as Da,B as Wi,Cb as Pt,Cc as ds,Da as pe,Dc as ms,Fb as yn,Ga as Ma,Gb as Xa,Ha as ja,Ib as Lt,Ja as fn,Jb as Za,K as rn,Ka as Ga,L as an,Lb as Uo,M as sn,N as cn,Nb as qo,O as Xi,Q as ie,Qa as Ha,Ra as Wa,Rb as Qa,S as me,Sb as es,Tb as ts,Ub as ns,Vb as os,W as ma,Xb as rs,Y as pa,Ya as Go,Yb as is,Z as ua,Zb as as,_b as Nt,a as Ni,aa as fa,ac as bn,bc as cs,cc as zo,db as Va,dc as Ho,ec as ls,ed as Vo,gd as Bo,i as Et,j as Di,ja as No,jd as ps,k as Mi,ka as Do,kd as us,l as ji,m as Gi,ob as gn,qa as _n,r as Ui,s as fo,t as qi,u as ce,ub as Ba,w as zi,wa as Na,wb as Ka,x as Hi,xb as Ja,yb as ue,yc as Wo,z as tn,zb as Ae}from"./chunk-5GWEY4P6.js";import{$e as Sa,Ab as Rt,Ad as G,Cf as H,Dg as Ea,Ed as la,Fa as N,Fd as da,Fi as La,Ga as nn,Gb as S,Gi as Qe,Ih as Po,J as Fi,Jg as Ta,K as Pi,Kb as Ji,Ki as hn,Mb as Yi,Mg as Ca,Mi as Ua,N as Li,Na as A,Ni as Ft,Pd as Je,Pi as qa,Qa as Se,Qd as Pe,Ra as ko,Rd as ha,Re as ne,Sd as ga,Si as Mo,Ta as de,Td as Le,Ti as jo,Ub as ln,Ud as ya,Vi as E,Wi as za,X as en,Xd as V,Xg as Ra,Yc as dn,Zb as Ke,Zc as mn,Zd as Ye,Ze as va,_c as pn,_d as ba,_e as ka,_g as xa,a as At,ad as aa,b as oe,ba as Ct,bh as Oa,d as Qt,da as go,ec as Zi,ej as Ya,fb as Vi,fj as F,gb as on,gd as Io,hb as Bi,he as wa,id as Ao,ih as $a,jd as Eo,kd as To,ki as Ot,ld as Co,lg as Aa,li as $t,md as Ro,nd as xo,od as Oo,pc as Qi,pd as x,pe as Ne,pf as Fo,qc as ea,qf as C,rb as Ki,rc as ta,re as Xe,rh as Fa,ri as Lo,s as J,sc as na,sf as Ia,ta as yo,tc as oa,u as _o,ua as bo,ub as Ie,uc as ra,uh as Ze,va as wo,vc as ia,w as $i,wa as vo,wd as sa,we as un,xb as So,xd as ca,xe as xt,ye as $o,yh as Pa}from"./chunk-7ZRCYESH.js";import{A as u,C as p,E as ke,F as Be,G as ho,H as le,K as re,M as Tt,a as Ei,e as Ti,f as Ci,g as Ri,i as xi,m as Oi}from"./chunk-O4ZLEN4T.js";import{AsyncLocalStorage as Sy}from"node:async_hooks";import{readFile as Jp}from"node:fs/promises";import Yp 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 hr="context-intents.json";function jn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xp(e,t,n){if(!jn(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 Kl(e,t){let n=Array.isArray(e)?e:jn(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)=>Xp(o,t,r))}async function Zp(e){let t=Yp.join(e,hr),n;try{n=await Jp(t,"utf8")}catch(r){if(Be(r))return[];throw await Ya(e),r}let o;try{o=JSON.parse(n)}catch(r){let i=r instanceof Error?r.message:String(r);throw new TypeError(`Invalid ${hr}: ${i}`,{cause:r})}return Kl(o,hr)}function Qp(e){if(!jn(e))return;let t=e.contextIntents??e.context_intents;if(t!==void 0)return t;let n=e.default;return jn(n)?n.contextIntents??n.context_intents:void 0}function eu(e){return e.flatMap(t=>{let n=Qp(t.module);return n===void 0?[]:Kl(n,`package ${t.name}`)})}async function tu(e){let t=await Zp(e.pmRoot),n=eu(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function Gn(e,t){let n=await tu(e);return await Fa(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 Jl(e,t,n=$a){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 du}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f698608a-2f39-5972-b24b-93287af6b373")}catch{}})();var qt=class extends RangeError{code;work;minimum_tokens;constructor(t,n,o){super(t),this.name="OutputEnvelopeFitError",this.code=t,this.work=Object.freeze({...n}),this.minimum_tokens=o}};function gr(e,t){if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`${t} must be a positive safe integer`)}function nu(e,t,n,o){return t.map(([r,i])=>{if(o.render_calls>=o.max_render_calls)throw new qt("output_envelope_work_limit",o);o.render_calls+=1;let a=i(e);if(typeof a!="string")throw new TypeError("Envelope renderers must return strings");let s=n(a);if(!Number.isSafeInteger(s)||s<0)throw new RangeError("Envelope token estimates must be non-negative safe integers");return{name:r,text:a,bytes:Buffer.byteLength(a,"utf8"),estimated_tokens:s}})}function Yl(e,t,n,o){let r=t,i=Object.entries(n.renderers),a=n.estimateTokens??(s=>Aa(Buffer.byteLength(s,"utf8")));for(let s=0;s<(n.maxStabilizationPasses??16);s+=1){let c=Object.freeze({...r}),l={...n.buildEnvelope(e,c),output_fit:c},d=nu(l,i,a,o),m=Math.max(...d.map(y=>y.bytes)),_=Math.max(...d.map(y=>y.estimated_tokens));if(m===r.output_bytes&&_===r.estimated_tokens)return{envelope:l,renderings:d};r={...r,output_bytes:m,estimated_tokens:_}}throw new qt("output_envelope_unstable",o)}function Xl(e,t){gr(t.tokenBudget,"tokenBudget"),gr(t.maxRenderCalls??1e4,"maxRenderCalls"),gr(t.maxStabilizationPasses??16,"maxStabilizationPasses");let n=t.policy??"prefix";if(n!=="prefix"&&n!=="skip")throw new TypeError("Unknown output envelope fit policy");if(Object.entries(t.renderers).length===0||Object.entries(t.renderers).some(([c,l])=>!c.trim()||typeof l!="function"))throw new TypeError("Envelope fitting requires named callable renderers");let o={evaluated_candidates:0,render_calls:0,max_render_calls:t.maxRenderCalls??1e4},r=[],i=[],a=c=>({version:1,policy:n,total_candidates:e.length,included_indices:Object.freeze([...c]),omitted_count:e.length-c.length,token_budget:t.tokenBudget,estimated_tokens:0,output_bytes:0}),s=Yl(r,a(i),t,o);if(s.envelope.output_fit.estimated_tokens>t.tokenBudget)throw new qt("output_envelope_infeasible",o,s.envelope.output_fit.estimated_tokens);for(let[c,l]of e.entries()){o.evaluated_candidates+=1;let d=[...r,l],m=[...i,c],_=Yl(d,a(m),t,o);if(_.envelope.output_fit.estimated_tokens<=t.tokenBudget)r=d,i=m,s=_;else if(n==="prefix")break}return{rows:r,...s,complete:r.length===e.length,work:Object.freeze({...o})}}import{constants as zt}from"node:fs";import{lstat as Zl,mkdir as br,open as Ql}from"node:fs/promises";import fe 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 yr(e,t){if(typeof e!="string"||e.trim().length===0)throw new TypeError(`Relationship event ${t} must be non-empty`);return e.trim()}function wr(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 ou(e){return Object.freeze({...e,...e.payload===void 0?{}:{payload:Object.freeze(structuredClone(e.payload))}})}function ru(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=wr(e,n),c=o.identities.get(s);if(c!==void 0&&c!==t)throw new TypeError(`Relationship edge already active: ${s}`)}function iu(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 au(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=yr(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:yr(e.relationshipId,"relationshipId"),author:yr(e.author,"author"),timestamp:new Date(e.timestamp).toISOString()}}function su(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 Ke([s,c],[e.edge],r).edges()[0];return ru(l,t,r,i),ou(l)}var Ht=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??ln()}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(wr(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(wr(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=au(t,this.version,this.#i),o=this.#e.get(n.relationshipId),r=su(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=iu(n),r=new Ke(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=Ra("relationship-events",{order:"append-sequence"}),o=t.cursor===void 0?this.version:Number(xa(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=Oa(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}:{}}}},cu="relationship-event-store",ed=zt.O_NOFOLLOW;function Un(e){return ne(e,cu,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function qe(e,t="relationships/events.jsonl"){let n=fe.resolve(e),o=fe.resolve(n,t),r=fe.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(`..${fe.sep}`)||fe.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await br(n,{recursive:!0}),(await Zl(n)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let i=n;for(let a of r.split(fe.sep)){i=fe.join(i,a);try{if((await Zl(i)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(s){if(ho(s))break;throw s}}return o}async function qn(e,t,n){let o=new Ht(t,{registry:n}),r,i;try{i=await Ql(e,zt.O_RDONLY|ed),r=await i.readFile("utf8")}catch(s){if(ho(s))return{log:o,raw:""};throw s}finally{await i?.close()}let a=r.split(`
1
+ import{a as it,b as Pn,c as Bc,d as Kc,g as Jc,i as bl}from"./chunk-OH6WQ7VT.js";import{L as _r,U as Nl,a as wl,c as vl,d as kl,e as Sl,k as Il,l as Ut,m as mr,n as pr,u as ur,w as Ll}from"./chunk-AUEKTX7V.js";import{$a as el,Ac as rr,Bc as ir,Cc as El,Dc as Tl,Ec as at,Ed as Vl,Fc as Cl,Fd as Bl,J as Me,Jb as Dn,Jc as Ol,Kc as $l,Lc as Fl,Mc as Pl,Nc as cr,Oc as lr,Pc as dr,Qa as Xc,Qb as gl,Ra as Zc,Sb as yl,Sc as Ml,Tc as jl,Uc as Gl,Vc as Ul,Wa as Zo,Wc as ql,Xa as Qo,Ya as er,Yb as Mn,Yc as zl,Zc as Hl,_a as Qc,_b as Gt,ab as tr,b as Yo,ga as Tn,ha as $n,i as fc,ia as Hc,ib as ul,j as hc,ka as ot,l as gc,la as Wc,lb as _l,ma as Xo,mb as fl,na as Fn,pa as rt,rb as jt,rc as nr,sd as fr,uc as Ce,vc as Al,vd as Wl,ya as Vc}from"./chunk-QNWUIPBO.js";import{A as cc,B as lc,C as Ko,D as Mt,E as Sn,F as De,G as dc,H as In,I as U,J as Jo,K as j,L as mc,M as pc,N as An,O as uc,P as En,Q as _c,m as Dt,n as tc,o as nc,p as oc,r as rc,s as tt,t as f,u as ic,v as ac,x as Y,y as sc,z as kn}from"./chunk-6VRX2CM7.js";import{A as Ic,D as Ac,Da as On,F as Ec,G as Tc,H as Cc,Ha as qc,I as Rc,J as xc,K as Oc,Ka as zc,L as $c,M as Fc,N as Pc,O as Lc,P as Nc,Q as Dc,R as Mc,S as jc,T as Gc,c as gs,l as Cn,n as je,o as wc,p as Rn,q as vc,qa as nt,r as Ge,s as kc,t as xn,u as Sc,ya as Uc}from"./chunk-LS3GI3H4.js";import{i as yc,o as bc}from"./chunk-DAX3AOFI.js";import{$a as Ue,Dc as ar,Gb as Rl,Ha as tl,Hb as xl,Ic as sr,Lc as Dl,Ra as nl,Sa as ol,Ta as rl,U as _e,Wa as il,Xa as al,Ya as sl,Za as cl,aa as Yc,ab as ll,b as hs,bb as dl,db as ml,fb as Ln,hb as pl,lb as Te,mb as hl,nb as Nn,rb as or}from"./chunk-S4LPZ4TN.js";import{a as _s,b as fs}from"./chunk-UEGXWXUZ.js";import{$a as Ee,A as ks,Ca as Ns,E as Ss,Ga as Ds,Ha as Ms,Ia as js,J as Is,Ja as Gs,K as As,Ka as Us,M as Es,Ma as qs,Na as zs,Oa as Hs,P as Ts,Pa as Ws,Qa as Vs,Ra as Bs,Ua as Ks,Va as vn,Vb as ec,Wa as Js,Xa as Ys,ab as T,bb as Xs,cb as Zs,da as Cs,ga as Rs,h as ys,ha as xs,mb as Qs,pa as Os,q as bs,ra as $s,s as ws,t as wn,u as vs,xa as Fs,ya as Ps,za as Ls}from"./chunk-HNGLDMSZ.js";import{r as et}from"./chunk-FRNMQM45.js";import{$ as _a,$b as ss,Aa as Da,B as Wi,Cb as Pt,Cc as ds,Da as pe,Dc as ms,Fb as yn,Ga as Ma,Gb as Xa,Ha as ja,Ib as Lt,Ja as fn,Jb as Za,K as rn,Ka as Ga,L as an,Lb as Uo,M as sn,N as cn,Nb as qo,O as Xi,Q as ie,Qa as Ha,Ra as Wa,Rb as Qa,S as me,Sb as es,Tb as ts,Ub as ns,Vb as os,W as ma,Xb as rs,Y as pa,Ya as Go,Yb as is,Z as ua,Zb as as,_b as Nt,a as Ni,aa as fa,ac as bn,bc as cs,cc as zo,db as Va,dc as Ho,ec as ls,ed as Vo,gd as Bo,i as Et,j as Di,ja as No,jd as ps,k as Mi,ka as Do,kd as us,l as ji,m as Gi,ob as gn,qa as _n,r as Ui,s as fo,t as qi,u as ce,ub as Ba,w as zi,wa as Na,wb as Ka,x as Hi,xb as Ja,yb as ue,yc as Wo,z as tn,zb as Ae}from"./chunk-5GWEY4P6.js";import{$e as Sa,Ab as Rt,Ad as G,Cf as H,Dg as Ea,Ed as la,Fa as N,Fd as da,Fi as La,Ga as nn,Gb as S,Gi as Qe,Ih as Po,J as Fi,Jg as Ta,K as Pi,Kb as Ji,Ki as hn,Mb as Yi,Mg as Ca,Mi as Ua,N as Li,Na as A,Ni as Ft,Pd as Je,Pi as qa,Qa as Se,Qd as Pe,Ra as ko,Rd as ha,Re as ne,Sd as ga,Si as Mo,Ta as de,Td as Le,Ti as jo,Ub as ln,Ud as ya,Vi as E,Wi as za,X as en,Xd as V,Xg as Ra,Yc as dn,Zb as Ke,Zc as mn,Zd as Ye,Ze as va,_c as pn,_d as ba,_e as ka,_g as xa,a as At,ad as aa,b as oe,ba as Ct,bh as Oa,d as Qt,da as go,ec as Zi,ej as Ya,fb as Vi,fj as F,gb as on,gd as Io,hb as Bi,he as wa,id as Ao,ih as $a,jd as Eo,kd as To,ki as Ot,ld as Co,lg as Aa,li as $t,md as Ro,nd as xo,od as Oo,pc as Qi,pd as x,pe as Ne,pf as Fo,qc as ea,qf as C,rb as Ki,rc as ta,re as Xe,rh as Fa,ri as Lo,s as J,sc as na,sf as Ia,ta as yo,tc as oa,u as _o,ua as bo,ub as Ie,uc as ra,uh as Ze,va as wo,vc as ia,w as $i,wa as vo,wd as sa,we as un,xb as So,xd as ca,xe as xt,ye as $o,yh as Pa}from"./chunk-7ZRCYESH.js";import{A as u,C as p,E as ke,F as Be,G as ho,H as le,K as re,M as Tt,a as Ei,e as Ti,f as Ci,g as Ri,i as xi,m as Oi}from"./chunk-O4ZLEN4T.js";import{AsyncLocalStorage as Sy}from"node:async_hooks";import{readFile as Jp}from"node:fs/promises";import Yp 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 hr="context-intents.json";function jn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xp(e,t,n){if(!jn(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 Kl(e,t){let n=Array.isArray(e)?e:jn(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)=>Xp(o,t,r))}async function Zp(e){let t=Yp.join(e,hr),n;try{n=await Jp(t,"utf8")}catch(r){if(Be(r))return[];throw await Ya(e),r}let o;try{o=JSON.parse(n)}catch(r){let i=r instanceof Error?r.message:String(r);throw new TypeError(`Invalid ${hr}: ${i}`,{cause:r})}return Kl(o,hr)}function Qp(e){if(!jn(e))return;let t=e.contextIntents??e.context_intents;if(t!==void 0)return t;let n=e.default;return jn(n)?n.contextIntents??n.context_intents:void 0}function eu(e){return e.flatMap(t=>{let n=Qp(t.module);return n===void 0?[]:Kl(n,`package ${t.name}`)})}async function tu(e){let t=await Zp(e.pmRoot),n=eu(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function Gn(e,t){let n=await tu(e);return await Fa(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 Jl(e,t,n=$a){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 du}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f698608a-2f39-5972-b24b-93287af6b373")}catch{}})();var qt=class extends RangeError{code;work;minimum_tokens;constructor(t,n,o){super(t),this.name="OutputEnvelopeFitError",this.code=t,this.work=Object.freeze({...n}),this.minimum_tokens=o}};function gr(e,t){if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`${t} must be a positive safe integer`)}function nu(e,t,n,o){return t.map(([r,i])=>{if(o.render_calls>=o.max_render_calls)throw new qt("output_envelope_work_limit",o);o.render_calls+=1;let a=i(e);if(typeof a!="string")throw new TypeError("Envelope renderers must return strings");let s=n(a);if(!Number.isSafeInteger(s)||s<0)throw new RangeError("Envelope token estimates must be non-negative safe integers");return{name:r,text:a,bytes:Buffer.byteLength(a,"utf8"),estimated_tokens:s}})}function Yl(e,t,n,o){let r=t,i=Object.entries(n.renderers),a=n.estimateTokens??(s=>Aa(Buffer.byteLength(s,"utf8")));for(let s=0;s<(n.maxStabilizationPasses??16);s+=1){let c=Object.freeze({...r}),l={...n.buildEnvelope(e,c),output_fit:c},d=nu(l,i,a,o),m=Math.max(...d.map(y=>y.bytes)),_=Math.max(...d.map(y=>y.estimated_tokens));if(m===r.output_bytes&&_===r.estimated_tokens)return{envelope:l,renderings:d};r={...r,output_bytes:m,estimated_tokens:_}}throw new qt("output_envelope_unstable",o)}function Xl(e,t){gr(t.tokenBudget,"tokenBudget"),gr(t.maxRenderCalls??1e4,"maxRenderCalls"),gr(t.maxStabilizationPasses??16,"maxStabilizationPasses");let n=t.policy??"prefix";if(n!=="prefix"&&n!=="skip")throw new TypeError("Unknown output envelope fit policy");if(Object.entries(t.renderers).length===0||Object.entries(t.renderers).some(([c,l])=>!c.trim()||typeof l!="function"))throw new TypeError("Envelope fitting requires named callable renderers");let o={evaluated_candidates:0,render_calls:0,max_render_calls:t.maxRenderCalls??1e4},r=[],i=[],a=c=>({version:1,policy:n,total_candidates:e.length,included_indices:Object.freeze([...c]),omitted_count:e.length-c.length,token_budget:t.tokenBudget,estimated_tokens:0,output_bytes:0}),s=Yl(r,a(i),t,o);if(s.envelope.output_fit.estimated_tokens>t.tokenBudget)throw new qt("output_envelope_infeasible",o,s.envelope.output_fit.estimated_tokens);for(let[c,l]of e.entries()){o.evaluated_candidates+=1;let d=[...r,l],m=[...i,c],_=Yl(d,a(m),t,o);if(_.envelope.output_fit.estimated_tokens<=t.tokenBudget)r=d,i=m,s=_;else if(n==="prefix")break}return{rows:r,...s,complete:r.length===e.length,work:Object.freeze({...o})}}import{constants as zt}from"node:fs";import{lstat as Zl,mkdir as br,open as Ql}from"node:fs/promises";import fe 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 yr(e,t){if(typeof e!="string"||e.trim().length===0)throw new TypeError(`Relationship event ${t} must be non-empty`);return e.trim()}function wr(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 ou(e){return Object.freeze({...e,...e.payload===void 0?{}:{payload:Object.freeze(structuredClone(e.payload))}})}function ru(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=wr(e,n),c=o.identities.get(s);if(c!==void 0&&c!==t)throw new TypeError(`Relationship edge already active: ${s}`)}function iu(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 au(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=yr(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:yr(e.relationshipId,"relationshipId"),author:yr(e.author,"author"),timestamp:new Date(e.timestamp).toISOString()}}function su(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 Ke([s,c],[e.edge],r).edges()[0];return ru(l,t,r,i),ou(l)}var Ht=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??ln()}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(wr(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(wr(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=au(t,this.version,this.#i),o=this.#e.get(n.relationshipId),r=su(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=iu(n),r=new Ke(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=Ra("relationship-events",{order:"append-sequence"}),o=t.cursor===void 0?this.version:Number(xa(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=Oa(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}:{}}}},cu="relationship-event-store",ed=zt.O_NOFOLLOW;function Un(e){return ne(e,cu,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function qe(e,t="relationships/events.jsonl"){let n=fe.resolve(e),o=fe.resolve(n,t),r=fe.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(`..${fe.sep}`)||fe.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await br(n,{recursive:!0}),(await Zl(n)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let i=n;for(let a of r.split(fe.sep)){i=fe.join(i,a);try{if((await Zl(i)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(s){if(ho(s))break;throw s}}return o}async function qn(e,t,n){let o=new Ht(t,{registry:n}),r,i;try{i=await Ql(e,zt.O_RDONLY|ed),r=await i.readFile("utf8")}catch(s){if(ho(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 lu(e,t,n,o){let r=Date.parse(t.timestamp),i;return t.action!=="remove"&&t.edge!==void 0&&(i=new Ke(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 zn=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 qe(t.pmRoot,t.relativePath),r=await Un(t.pmRoot);try{await qe(t.pmRoot,o);let{log:i}=await qn(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 Un(this.#t);try{let o=await qe(this.#t,this.#i),{log:r}=await qn(o,this.#n,this.#o),i=r.append(t);await br(fe.dirname(o),{recursive:!0}),await qe(this.#t,o);let a=await Ql(o,zt.O_APPEND|zt.O_CREAT|zt.O_WRONLY|ed);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 Un(this.#t);try{let r=await qe(this.#t,this.#i),{log:i,raw:a}=await qn(r,this.#n,this.#o),s=i.version,c=new Map(i.events().map(m=>[m.eventId,m])),l=[],d=[];for(let m of t){let _=m.eventId.trim(),y=c.get(_);if(y!==void 0){if(n.existingEventPolicy==="skip_identical"&&lu(y,m,this.#n,this.#o)){d.push(y.eventId);continue}if(n.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${_}`)}let g=i.append(m);c.set(g.eventId,g),l.push(g)}if(l.length>0){let m=a.length===0||a.endsWith(`
4
4
  `)?a:`${a}
@@ -2254,5 +2254,5 @@ compdef _pm pm`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"
2254
2254
  `)}catch{}}function ty(e){let t=(e??"keyword").trim().toLowerCase();if(t==="keyword")return"keyword";if(t==="semantic"||t==="hybrid")return t;throw new p("Reindex mode must be one of keyword|semantic|hybrid",u.USAGE)}async function ny(e,t,n,o){let r=[];return{candidates:await Ja(e,t,n,r,o),warnings:r}}async function ki(e,t,n,o,r){let i=me(x()),a=[];for(let s of t)if(!(r&&!r.has(s.metadata.id))){if(typeof s.body=="string"){a.push({metadata:s.metadata,body:s.body});continue}try{let c=await Zg.readFile(s.item_path,"utf8"),l=un(c,{format:s.item_format,schema:n,extensionFieldNames:i,onWarning:d=>o.push(d)});a.push({metadata:s.metadata,body:l.body})}catch{o.push(`item_list_item_read_failed:${Zt.relative(e,s.item_path)}`),a.push({metadata:s.metadata,body:""})}}return a}function oy(e,t,n){let o=e.metadata;return{id:o.id,mode:t,updated_at:o.updated_at,corpus:Qa(e,{fields:n})}}var It=Ki;function ry(e){let t=x(),n=It(e.search?.provider);if(!n)return null;let o=pa(t,n);if(!o)return null;let r=o.runtime_definition??o.definition,i=It(r.name)??It(o.definition.name);if(!i)return null;let a=r.embedBatch,s=r.embed_batch,c=r.embed,l=typeof a=="function"?a:typeof s=="function"?s:void 0,d=typeof c=="function"?c:void 0;return!l&&!d?null:{name:i,embedBatch:l,embed:d}}function iy(e){let t=x(),n=It(e.vector_store?.adapter);if(!n)return null;let o=ua(t,n);if(!o)return null;let r=o.runtime_definition??o.definition,i=It(r.name)??It(o.definition.name);if(!i)return null;let a=r.upsert,s=r.delete;return{adapterName:i,...typeof a=="function"?{upsert:a}:{},...typeof s=="function"?{delete:s}:{}}}function vi(e,t){if(!Array.isArray(e)||e.some(n=>typeof n!="number"||!Number.isFinite(n)))throw new p(`Invalid vector returned by ${t}`,u.GENERIC_FAILURE);return e}async function ay(e,t,n){let o=t.search?.embedding_model?.trim()||"text-embedding-3-small";if(e.embedBatch){let i=await Promise.resolve(e.embedBatch({inputs:n,settings:t,model:o}));if(!Array.isArray(i))throw new p(`Extension search provider "${e.name}" embedBatch must return an array of vectors`,u.GENERIC_FAILURE);return i.map((a,s)=>vi(a,`extension search provider "${e.name}" embedBatch output at index ${s}`))}if(!e.embed)throw new p(`Extension search provider "${e.name}" does not implement embed/embedBatch`,u.GENERIC_FAILURE);let r=[];for(let[i,a]of n.entries()){let s=await Promise.resolve(e.embed({input:a,settings:t,model:o}));r.push(vi(s,`extension search provider "${e.name}" embed output at index ${i}`))}return r}function jp(e){return e.search?.embedding_model?.trim()||"text-embedding-3-small"}function Gp(e,t,n){let o=n?Nt(n.name,jp(e)):t?Nt(t.name,t.model):null;if(!o)throw new p("No embedding identity available for semantic reindex mode",u.USAGE);return o}function sy(e,t){return Object.keys(e).filter(n=>!t.has(n)).sort((n,o)=>n.localeCompare(o))}async function Up(e,t,n,o,r,i,a,s){let c=o?.name??n?.name,l=es(c,e.search.embedding_corpus_max_characters).maxCharacters,d=qo(e),m=r.map(g=>ts(g,{providerName:c,maxCharacters:l,fields:d})),_=[],y=null;if(o)try{_=await ay(o,e,m),y=Nt(o.name,jp(e))}catch(g){if(!n)throw new p(`Extension search provider "${o.name}" failed to generate embeddings: ${g instanceof Error?g.message:String(g)}`,u.GENERIC_FAILURE);i.push(`Extension search provider "${o.name}" failed; falling back to built-in provider (${g instanceof Error?g.message:String(g)})`)}if(_.length===0){if(!n)throw new p(`No embedding executor available for reindex mode '${t}'`,u.USAGE);let g=await ns(n,e,m,{onProgress:k=>{k.phase==="complete"&&(a.batches_completed=k.batch_index),M(s,`embedding_batch_${k.phase} batch=${k.batch_index}/${k.batch_total} size=${k.batch_size} completed_inputs=${k.completed_inputs}/${k.total_inputs}`)}});i.push(...g.warnings),a.batching=g.receipt,_=g.vectors,y=Nt(n.name,n.model)}if(M(s,`embedding_complete vectors=${_.length}`),_.length!==r.length)throw new p(`Embedding output size mismatch (expected ${r.length}, received ${_.length})`,u.GENERIC_FAILURE);if(!y)throw new p(`No embedding identity available for reindex mode '${t}'`,u.USAGE);return{vectors:_,embeddingIdentity:y}}async function cy(e,t,n,o,r,i){let a=Object.keys(n);if(t){if(a.length>0&&t.delete)try{await Promise.resolve(t.delete({ids:a.sort((s,c)=>s.localeCompare(c)),settings:o}))}catch(s){throw new p(`Extension vector adapter "${t.adapterName}" failed to delete vectors during reindex reset: ${s instanceof Error?s.message:String(s)}`,u.GENERIC_FAILURE)}else a.length>0&&r.push(`search_semantic_reindex_reset_skipped:adapter=${t.adapterName}:known_ids=${a.length}`);if(!e)return}e&&await as(e,a,{},i)}async function qp(e,t,n,o,r){if(n.length!==0){if(t){if(t.delete)try{await Promise.resolve(t.delete({ids:n,settings:o}))}catch(i){throw new p(`Extension vector adapter "${t.adapterName}" failed to delete orphan vectors during reindex: ${i instanceof Error?i.message:String(i)}`,u.GENERIC_FAILURE)}else r.push(`search_semantic_reindex_orphan_prune_skipped:adapter=${t.adapterName}:count=${n.length}`);if(!e)return}e&&await is(e,n)}}function ly(e){return{enabled:e!=="keyword",stale_items:0,unchanged_items:0,embedded_items:0,vector_upserted:0,batches_completed:0}}function dy(e,t,n){return{version:1,mode:e,generated_at:t,total_items:n.length,items:n.map(o=>({id:o.metadata.id,type:o.metadata.type,status:o.metadata.status,priority:o.metadata.priority,updated_at:o.metadata.updated_at}))}}function my(e){if(e.requestedMode==="keyword")return{activeEmbeddingProvider:null,activeVectorStore:null};let t=Uo(e.settings);if(!t.active&&!e.extensionEmbedding)throw new p(`Reindex mode '${e.requestedMode}' requires a configured embedding provider in settings.providers.openai/settings.providers.ollama or an extension provider selected by settings.search.provider`,u.USAGE);let n=os(e.settings,e.pmRoot);if(!n.active&&!e.extensionVectorAdapter)throw new p(`Reindex mode '${e.requestedMode}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,u.USAGE);return{activeEmbeddingProvider:t.active,activeVectorStore:n.active}}async function py(e){let t=N(e.settings,x()),n=await ny(e.pmRoot,e.settings.item_format,t.type_to_folder,e.settings.schema);return{documentCandidates:n.candidates,warnings:[...n.warnings],metadataDocuments:n.candidates.map(o=>({metadata:o.metadata,body:typeof o.body=="string"?o.body:""}))}}async function uy(e){let t=await Ho(e.pmRoot);if(e.reindexWarnings.push(...t.warnings),e.forceFullSemantic&&e.reindexWarnings.push("search_semantic_reindex_full_ignored:mode_keyword"),!t.embedding)return;let n=(()=>{try{return Gp(e.settings,Uo(e.settings).active,e.extensionEmbedding)}catch{return null}})();n&&bn(t.embedding,n)&&(e.reindexWarnings.push("search_semantic_reindex_requires_rebuild:embedding_identity_changed"),e.reindexWarnings.push(Qg))}async function _y(e){let t=await Ho(e.pmRoot);e.semanticWarnings.push(...t.warnings);let n=Gp(e.settings,e.activeEmbeddingProvider,e.extensionEmbedding),o=new Set(e.metadataDocuments.map(l=>l.metadata.id)),r=sy(t.entries,o),i=bn(t.embedding,n);e.forceFullSemantic&&!i&&e.semanticWarnings.push("search_semantic_reindex_full_rebuild_forced");let a=e.forceFullSemantic||i?e.metadataDocuments:e.metadataDocuments.filter(l=>t.entries[l.metadata.id]!==l.metadata.updated_at),s=new Set(a.map(l=>l.metadata.id)),c=s.size>0?await ki(e.pmRoot,e.documentCandidates,e.settings.schema,e.reindexWarnings,s):[];return{ledgerEntries:t.entries,ledgerEmbedding:t.embedding,orphanIds:r,resetRequired:i,staleDocuments:c,freshDocuments:e.metadataDocuments.length-c.length}}async function fy(e){let t=new Set(e.metadataDocuments.map(r=>r.metadata.id)),n=await ki(e.pmRoot,e.documentCandidates,e.settings.schema,e.reindexWarnings,t);e.semanticSummary.stale_items=n.length,e.semanticSummary.unchanged_items=0,M(e.progressEnabled,`embedding_dimension_changed reset_items=${n.length}`);let o=await Up(e.settings,e.requestedMode,e.activeEmbeddingProvider,e.extensionEmbedding,n,e.semanticWarnings,e.semanticSummary,e.progressEnabled);return{...o,staleDocuments:n,vectorDimension:zo(o.vectors,"Reindex embeddings")}}async function hy(e){let t=await Up(e.settings,e.requestedMode,e.activeEmbeddingProvider,e.extensionEmbedding,e.staleDocuments,e.semanticWarnings,e.semanticSummary,e.progressEnabled),n=t.vectors,o=t.embeddingIdentity,r=zo(n,"Reindex embeddings");if(!(!e.resetRequired&&(bn(e.ledgerEmbedding,o)||cs(e.ledgerEmbedding,r))))return{vectors:n,embeddingIdentity:o,staleDocuments:e.staleDocuments,vectorDimension:r,resetRequired:e.resetRequired};let i=await fy(e);return n=i.vectors,o=i.embeddingIdentity,r=i.vectorDimension,{vectors:n,embeddingIdentity:o,staleDocuments:i.staleDocuments,vectorDimension:r,resetRequired:!0}}async function gy(e){if(e.extensionVectorAdapter)try{let t=e.extensionVectorAdapter.adapterName;if(M(e.progressEnabled,`vector_upsert_start adapter=${t} points=${e.points.length}`),typeof e.extensionVectorAdapter.upsert!="function")throw new p(`Extension vector adapter "${t}" does not support upserting vectors.`,u.USAGE);await Promise.resolve(e.extensionVectorAdapter.upsert({points:e.points,settings:e.settings})),e.semanticSummary.vector_upserted=e.points.length,M(e.progressEnabled,`vector_upsert_complete adapter=${t}`);return}catch(t){if(t instanceof p)throw t;if(!e.activeVectorStore)throw new p(`Extension vector adapter "${e.extensionVectorAdapter.adapterName}" failed to upsert vectors: ${t instanceof Error?t.message:String(t)}`,u.GENERIC_FAILURE);e.semanticWarnings.push(`Extension vector adapter "${e.extensionVectorAdapter.adapterName}" failed; falling back to built-in vector store (${t instanceof Error?t.message:String(t)})`),M(e.progressEnabled,"vector_upsert_fallback built_in_store")}if(e.activeVectorStore){M(e.progressEnabled,`vector_upsert_start adapter=${e.activeVectorStore.name} points=${e.points.length}`),await rs(e.activeVectorStore,e.points),e.semanticSummary.vector_upserted=e.points.length,M(e.progressEnabled,`vector_upsert_complete adapter=${e.activeVectorStore.name}`);return}throw new p(`No vector upsert executor available for reindex mode '${e.requestedMode}'`,u.USAGE)}function yy(e,t){return e.map((n,o)=>({id:n.metadata.id,vector:vi(t[o],`reindex embeddings output at index ${o}`),payload:{id:n.metadata.id,type:n.metadata.type,status:n.metadata.status,priority:n.metadata.priority,updated_at:n.metadata.updated_at}}))}async function by(e){M(e.progressEnabled,`embedding_start items=${e.plan.staleDocuments.length} unchanged_items=${e.plan.freshDocuments}`);let t=await hy({pmRoot:e.pmRoot,settings:e.settings,requestedMode:e.requestedMode,activeEmbeddingProvider:e.activeEmbeddingProvider,extensionEmbedding:e.extensionEmbedding,documentCandidates:e.documentCandidates,metadataDocuments:e.metadataDocuments,staleDocuments:e.plan.staleDocuments,ledgerEmbedding:e.plan.ledgerEmbedding,resetRequired:e.plan.resetRequired,semanticWarnings:e.semanticWarnings,reindexWarnings:e.reindexWarnings,semanticSummary:e.semanticSummary,progressEnabled:e.progressEnabled});t.resetRequired?(M(e.progressEnabled,"vector_reset_start"),await cy(e.activeVectorStore,e.extensionVectorAdapter,e.plan.ledgerEntries,e.settings,e.semanticWarnings,e.plan.ledgerEmbedding?t.vectorDimension:void 0),M(e.progressEnabled,"vector_reset_complete")):await qp(e.activeVectorStore,e.extensionVectorAdapter,e.plan.orphanIds,e.settings,e.semanticWarnings);let n=yy(t.staleDocuments,t.vectors);return e.semanticSummary.embedded_items=t.vectors.length,await gy({requestedMode:e.requestedMode,activeVectorStore:e.activeVectorStore,extensionVectorAdapter:e.extensionVectorAdapter,settings:e.settings,points:n,semanticWarnings:e.semanticWarnings,semanticSummary:e.semanticSummary,progressEnabled:e.progressEnabled}),{staleDocuments:t.staleDocuments,embeddingMetadata:ss(t.embeddingIdentity,t.vectorDimension)}}async function wy(e){let t=await _y(e);e.semanticSummary.stale_items=t.staleDocuments.length,e.semanticSummary.unchanged_items=t.freshDocuments;let n=Object.fromEntries(e.metadataDocuments.map(i=>[i.metadata.id,i.metadata.updated_at]));if(M(e.progressEnabled,`semantic_stale_items stale=${t.staleDocuments.length} total=${e.metadataDocuments.length} unchanged=${t.freshDocuments} full=${e.forceFullSemantic||t.resetRequired}`),t.staleDocuments.length===0)return M(e.progressEnabled,`embedding_skipped unchanged_items=${t.freshDocuments}`),e.semanticWarnings.push(`search_semantic_reindex_skipped_unchanged:count=${t.freshDocuments}`),await qp(e.activeVectorStore,e.extensionVectorAdapter,t.orphanIds,e.settings,e.semanticWarnings),{documentsForKeywordArtifacts:e.documentsForKeywordArtifacts,vectorizationLedgerEntries:n,vectorizationEmbeddingMetadata:t.ledgerEmbedding};let o=await by({...e,plan:t});t.freshDocuments>0&&e.semanticWarnings.push(`search_semantic_reindex_skipped_unchanged:count=${t.freshDocuments}`);let r=new Map(o.staleDocuments.map(i=>[i.metadata.id,i]));return{documentsForKeywordArtifacts:e.metadataDocuments.map(i=>r.get(i.metadata.id)??i),vectorizationLedgerEntries:n,vectorizationEmbeddingMetadata:o.embeddingMetadata}}async function vy(e){let t=Zt.join(e.pmRoot,bi),n=Zt.join(e.pmRoot,wi),o=qo(e.settings),r=e.documentsForKeywordArtifacts.map(a=>JSON.stringify(oy(a,e.mode,o))).join(`
2255
2255
  `);M(e.progressEnabled,"writing keyword artifacts"),await re(t,`${JSON.stringify(e.manifest,null,2)}
2256
2256
  `),await re(n,`${r}
2257
- `);let i=[];if(e.mode!=="keyword")try{M(e.progressEnabled,"writing vectorization status ledger"),await ls(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 ky(e,t){let n=ty(e.mode),o=ey(e),r=e.full===!0;M(o,`start mode=${n}`);let i=A(process.cwd(),t.path);await F(i);let a=Ha(await E(i)).settings,s=null;try{s=await ne(i,Wa,a.locks.ttl_seconds,C(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=ry(a),l=iy(a),d=my({requestedMode:n,pmRoot:i,settings:a,extensionEmbedding:c,extensionVectorAdapter:l}),m=n;M(o,"loading item corpus");let _=await py({pmRoot:i,settings:a}),y=_.warnings,{documentCandidates:g,metadataDocuments:k}=_;M(o,`loaded_items=${k.length}`);let b=S(),v=dy(m,b,k),h=Zt.join(i,bi),I=Zt.join(i,wi),P=m==="keyword"?await ki(i,g,a.schema,y):k,O=[],W={},$=null,R=ly(m);if(m==="keyword"&&await uy({pmRoot:i,settings:a,forceFullSemantic:r,extensionEmbedding:c,reindexWarnings:y}),m!=="keyword"){let te=await wy({pmRoot:i,settings:a,requestedMode:n,activeEmbeddingProvider:d.activeEmbeddingProvider,activeVectorStore:d.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:l,documentCandidates:g,metadataDocuments:k,documentsForKeywordArtifacts:P,forceFullSemantic:r,reindexWarnings:y,semanticWarnings:O,semanticSummary:R,progressEnabled:o});P=te.documentsForKeywordArtifacts,W=te.vectorizationLedgerEntries,$=te.vectorizationEmbeddingMetadata}let se=await vy({pmRoot:i,mode:m,manifest:v,documentsForKeywordArtifacts:P,settings:a,vectorizationLedgerEntries:W,vectorizationEmbeddingMetadata:$,progressEnabled:o}),Fe=[...await G({path:h,scope:"project",op:"reindex:manifest"}),...await G({path:I,scope:"project",op:"reindex:embeddings"}),...await la({mode:m,total_items:k.length})];return M(o,"done"),{ok:!0,mode:m,total_items:k.length,semantic:R,artifacts:{manifest:bi,embeddings:wi},warnings:[...y,...O,...se,...Fe],generated_at:b}}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]="f513a760-1161-53ac-ae6f-854930b8d891")}catch{}})();var Si=Symbol("pm.active-extension-host-context");function Q(e){return{fullChangedFields:!0,options:e}}var w=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[Si]=!0,n}run(t,n={}){return Ry({...this.defaults,...n,action:t})}runTyped(t,n={}){return this.run(t,n)}async withItemTransactionContext(t,n=!1){let o=A(this.defaults.cwd??process.cwd(),this.defaults.path),r=async()=>{let a=await Ft(o,()=>E(o));return t({pmRoot:o,author:C(this.defaults.author,a.author_default)})};if(this.defaults[Si]===!0||uo.getStore()===!0)return r();let i=()=>Iy({...this.defaults,path:o},r);return n?Ft(o,i):i()}previewItemMutations(t){return this.withItemTransactionContext(async n=>(await import("./item-transaction-QEPBUCMY.js")).previewItemMutations({...t,...n}),!0)}commitItemMutations(t){return this.withItemTransactionContext(async n=>(await import("./item-transaction-QEPBUCMY.js")).commitItemMutations({...t,...n}))}get itemTransactions(){let t=(n,o)=>this.withItemTransactionContext(async r=>(await import("./item-transaction-QEPBUCMY.js")).abandonItemTransaction({...o,...r,transactionId:n}));return{status:n=>this.withItemTransactionContext(async o=>(await import("./item-transaction-QEPBUCMY.js")).readItemTransaction(o.pmRoot,n),!0),abandon:t,supersede:(n,o,r)=>t(n,{...r,supersededBy:o})}}readItemRevision(t){return this.withItemTransactionContext(async({pmRoot:n})=>(await import("./item-revision-OJJVPQY7.js")).readItemRevision(t,{pmRoot:n}))}async withExpectedItemRevisions(t,n){let o=await import("./item-revision-OJJVPQY7.js"),r=await this.withItemTransactionContext(({pmRoot:i})=>o.bindExpectedItemRevisions(t,{pmRoot:i}));return o.runWithBoundItemRevisionScope(r,n)}context(t={}){return this.runTyped("context",{options:t})}listAllItemMetadataLight(){return od(this.defaults.path,this.defaults.cwd)}list(t={}){return this.runTyped("list",{options:t})}async listAllComplete(t={}){return Wn(await this.list(kr(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})}async append(t,n,o={}){return tc(o,"append"),await this.runTyped("append",{id:t,...Q(tt(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:tt(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 iR(e={},t={}){return new w(t).context(e)}function aR(e={},t={}){return new w(t).list(e)}function sR(e={},t={}){return new w(t).listAllComplete(e)}function cR(e,t={},n={}){return new w(n).search(e,t)}function lR(e,t={},n={}){return new w(n).get(e,t)}function dR(e={},t={}){return new w(t).next(e)}function mR(e={},t={}){return new w(t).aggregate(e)}function pR(e={},t={}){return new w(t).stats(e)}function uR(e={},t={}){return new w(t).duplicates(e)}function _R(e,t={},n={}){return new w(n).comments(e,t)}function fR(e,t={},n={}){return new w(n).notes(e,t)}function hR(e,t={},n={}){return new w(n).learnings(e,t)}function gR(e,t={},n={}){return new w(n).files(e,t)}function yR(e,t={},n={}){return new w(n).filesDiscover(e,t)}function bR(e,t={}){return new w(t).filesLookup(e)}function wR(e,t={},n={}){return new w(n).docs(e,t)}function vR(e,t={},n={}){return new w(n).deps(e,t)}function kR(e,t={},n={},o={}){return new w(o).graph(e,t,n)}function SR(e,t,n={},o={}){return new w(o).append(e,t,n)}function IR(e,t={},n={}){return new w(n).init(e,t)}function AR(e,t,n,o,r={},i={}){return new w(i).config(e,t,n,o,r)}function ER(e,t={},n={}){return new w(n).schema(e,t)}function TR(e={}){return new w(e).schemaList()}function CR(e,t={}){return new w(t).schemaShow(e)}function RR(e,t={},n={}){return new w(n).schemaAddType(e,t)}function xR(e,t={},n={}){return new w(n).schemaRemoveType(e,t)}function OR(e,t={},n={}){return new w(n).schemaAddStatus(e,t)}function $R(e,t={},n={}){return new w(n).schemaRemoveStatus(e,t)}function FR(e,t={},n={}){return new w(n).schemaAddField(e,t)}function PR(e,t={},n={}){return new w(n).schemaRemoveField(e,t)}function LR(e={}){return new w(e).schemaListFields()}function NR(e,t={}){return new w(t).schemaShowField(e)}function DR(e,t={},n={}){return new w(n).schemaApplyPreset(e,t)}function MR(e={},t={}){return new w(t).schemaInferTypes(e)}function jR(e,t,n,o={}){return new w(o).schemaRenameType(e,t,n)}function GR(e,t,n,o,r={}){return new w(r).schemaRenameField(e,t,n,o)}function UR(e,t,n,o={}){return new w(o).schemaRemapStatus(e,t,n)}function qR(e,t={}){return new w(t).schemaShowStatus(e)}function zR(e,t={},n={}){return new w(n).profile(e,t)}function HR(e={}){return new w(e).profileList()}function WR(e,t={}){return new w(t).profileShow(e)}function VR(e,t={},n={}){return new w(n).profileApply(e,t)}function BR(e,t={}){return new w(t).profileLint(e)}function KR(e={},t={}){return new w(t).validate(e)}function JR(e={},t={}){return new w(t).health(e)}function YR(e={},t={}){return new w(t).gc(e)}function XR(e,t,n={}){return new w(n).historyRedact(e,t)}function ZR(e,t={},n={}){return new w(n).historyRepair(e,t)}function QR(e={},t={}){return new w(t).historyRepairAll(e)}function ex(e,t={},n={}){return new w(n).historyCompact(e,t)}function tx(e,t={}){return new w(t).historyCompactBulk(e)}function nx(e={},t={}){return new w(t).create(e)}function ox(e,t={},n={}){return new w(n).update(e,t)}function rx(e,t,n={},o={}){return new w(o).reopen(e,t,n)}function ix(e,t,n={},o={}){return new w(o).close(e,t,n)}function ax(e,t={},n={}){return new w(n).claim(e,t)}function sx(e={},t={}){return new w(t).claimNext(e)}function cx(e,t={},n={}){return new w(n).release(e,t)}function lx(e,t={},n={}){return new w(n).copy(e,t)}function dx(e,t={},n={}){return new w(n).delete(e,t)}function mx(e,t,n={},o={}){return new w(o).restore(e,t,n)}function px(e,t={},n={}){return new w(n).focus(e,t)}function ux(e,t={},n={}){return new w(n).startTask(e,t)}function _x(e,t={},n={}){return new w(n).pauseTask(e,t)}function fx(e,t,n={},o={}){return new w(o).closeTask(e,t,n)}function hx(e,t={},n={}){return new w(n).extension(e,t)}function gx(e={},t={}){return new w(t).extensionList(e)}function yx(e,t={},n={}){return new w(n).extensionActivate(e,t)}function bx(e,t={},n={}){return new w(n).extensionDeactivate(e,t)}function wx(e,t={},n={}){return new w(n).package(e,t)}function vx(e={},t={}){return new w(t).packageList(e)}function kx(e,t={},n={}){return new w(n).packageInstall(e,t)}function Sx(e,t={},n={}){return new w(n).packageUninstall(e,t)}function Ix(e={},t={}){return new w(t).packageDoctor(e)}function Ax(e,t={},n={}){return new w(n).packageManage(e,t)}function Ex(e,t={},n={}){return new w(n).packageDescribe(e,t)}function Tx(e={},t={}){return new w(t).packageReload(e)}function Cx(e={},t={}){return new w(t).packageCatalog(e)}function Rx(e,t={},n={}){return new w(n).packageActivate(e,t)}function xx(e,t={},n={}){return new w(n).packageDeactivate(e,t)}function Ox(e,t={},n={}){return new w(n).upgrade(e,t)}async function $x(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 Tn(n,o)}var zp=aa(),uo=new Sy;function po(){Ao(Qi()),Eo(ea()),To(ta()),Co(na()),Ro(oa()),xo(ra()),Oo(ia())}async function Vp(e,t,n,o){return Io(()=>t===void 0?zp.read(()=>Hp(e,n,o)):zp.write(()=>Ty(t,()=>Hp(e,n,o))))}async function Iy(e,t){let n=e.cwd;if(uo.getStore()===!0&&n===void 0&&e.noExtensions===!0){let r=A(process.cwd(),e.path);return Io(()=>Gn({pmRoot:r},t))}let o=n??process.cwd();return Vp(kn({path:e.path,noExtensions:e.noExtensions}),n,o,()=>uo.run(!0,t))}function Ay(e){try{let t=e instanceof Error?e.stack:void 0,n=typeof t=="string"?t:ms(e);return typeof n=="string"?n:"Unknown failure"}catch{return"Unknown failure"}}async function Hp(e,t,n){let o=A(t,e.path);if(e.noExtensions)return po(),Gn({pmRoot:o},()=>n(null));if(!await ke(Se(o)))return po(),n(null);let r=null,i;try{let a=await E(o),s=await dn({pmRoot:o,settings:a,cwd:t,noExtensions:!1}),c=await pn({...s,loaded:s.loaded});i={loadResult:s,activationResult:c},Ao(c.hooks),Eo(c.commands),To(c.parsers),Co(c.preflight),Ro(c.services),xo(c.renderers),Oo(c.registrations),r={registrations:c.registrations,commands:c.commands,pmRoot:o,packages:s.loaded}}catch(a){po(),console.error("[pm-sdk] extension activation failed; continuing without active extensions:",Ay(a))}try{return await Gn({pmRoot:o,packages:r?.packages},()=>n(r))}finally{po(),i&&await mn(i.loadResult,i.activationResult).catch(()=>{})}}function Bp(e,t){let n=De(e);return t?.registrations.commands.find(o=>De(o.action)===n)?.command??t?.commands.handlers.find(o=>De(o.command)===n)?.command}async function Ey(e,t,n,o,r){if(!r)throw new p(`Unsupported native pm action: ${e}`,u.USAGE);let i=Bp(e,r);if(!i)throw new p(`Unsupported native pm action: ${e}`,u.USAGE);let a=typeof n.author=="string"?n.author:o.author,s=await da({command:In(i),args:U(n.args??t.args),options:Jo(t,n),global:{...o,author:a},pm_root:r.pmRoot,sdk:td(r.pmRoot,w.forActiveExtensionHost({pmRoot:r.pmRoot,author:a}),a,In(i))});if(!s.handled){if(Object.hasOwn(s,"cause"))throw ds(i,s);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 Ty(e,t){let n=process.cwd();process.chdir(e);try{return await t()}finally{process.chdir(n)}}function Cy(e){let t=K(e,"action"),n=De(t),o=be(Sr,n),r=o?.action??n,i={...e,action:r};return o?.options!==void 0&&(i.options={...o.options,...Rt(e.options)}),r==="package"&&(i.options={...Rt(i.options),vocabulary:"package"}),{action:r,args:i}}async function Ry(e){let t=Cy(e),n=kn(t.args);Bi(n);let o=dc(t.action),r=f(t.args,"cwd"),i=r??process.cwd();t.action==="init"&&(n[qc]=i),(t.action!=="init"||n.path!==void 0||(process.env.PM_PATH?.trim().length??0)>0)&&(n.path=A(i,n.path));let{expectHash:a,dispatchArgs:s}=_c(t.args),c=async l=>{if(a===void 0)return Wp(t.action,s,n,l);let{dispatchWithExpectedItemRevisions:d}=await import("./item-revision-OJJVPQY7.js");return d({action:t.action,expectHash:a,defaultId:f(s,"id")??f(Rt(s.options),"id"),options:Rt(s.options),background:s.background,pmRoot:A(i,n.path),run:()=>Wp(t.action,s,n,l)})};try{return t.action==="history-attest"?await c(null):e[Si]===!0||uo.getStore()===!0?await c(null):await Vp(n,r,i,l=>c(l))}finally{o&&ai()}}function Fx(e=Li){return e.map(t=>{let n=De(t),o=be(Sr,n),r=o?.action??n,i=be(ii,r)!==void 0;return{action:t,resolved_action:r,covered:i,route:i?o?"alias":"native":"missing"}})}async function Wp(e,t,n,o){let r=Ko(t,e);if(e==="create"||e==="update"){let{assertNativeMutationOptions:d}=await import("./mutation-admission-INMM3HHG.js");await d(e,t,r,n.path,cc[e])}let i=be(ii,e),a=i?void 0:Bp(e,o),s=a===void 0?e:`extension:${a}`;Ta(s,r),Ca(s,r);let c={action:e,args:t,options:r,id:f(t,"id"),force:t.force===!0||r.force===!0,global:n,activeExtensions:o},l=i?await i(c):await Ey(e,t,r,n,o);if(e==="history-attest")return l;{let d=Pa(s,r,l);return await Jl(A(process.cwd(),n.path),d),d}}var xy={closeManyOptionsFromFlat:An,extensionOptionsFromArgs:Jo,globalOptions:kn,mutationListOptions:mc,normalizeActionName:De,normalizeCommandPath:In,normalizeMcpUpdateOptions:uc,normalizeMcpOptionsArrays:lc,optionsWithAuthor:Ko,readRequiredString:K,readScalarString:ic,readScalarStringAllowBlank:ac,readStringArray:U,updateManyOptionsFromFlat:En,withAddNoteOption:Mt,withFilesDiscoveryOptions:Sn,withMutationCompaction:j};(process.env.NODE_ENV==="test"||process.env.VITEST!==void 0||process.env.VITEST_WORKER_ID!==void 0)&&(globalThis.__pmCliActionRunnerTestHooks=xy);export{hr as a,Kl as b,Zp as c,eu as d,tu as e,Gn as f,qt as g,Xl as h,Ht as i,zn as j,td as k,pu as l,Hn as m,kr as n,nd as o,Wn as p,bu as q,ad as r,ld as s,md as t,fd as u,Tr as v,Cr as w,Rr as x,xr as y,Xu as z,Nr as A,$d as B,Dd as C,Md as D,lt as E,Br as F,Tf as G,Sv as H,Iv as I,Yr as J,Gd as K,Gv as L,Uv as M,qd as N,Wd as O,sk as P,Hf as Q,oi as R,Vf as S,Bf as T,rm as U,im as V,am as W,sm as X,cm as Y,$k as Z,Fk as _,Pk as $,Lk as aa,lm as ba,pm as ca,eo as da,gm as ea,ym as fa,bm as ga,K as ha,ai as ia,dA as ja,mA as ka,pA as la,uA as ma,_A as na,xm as oa,fA as pa,Yh as qa,Qh as ra,og as sa,rg as ta,ig as ua,z as va,ag as wa,sg as xa,cg as ya,lg as za,ci as Aa,Pm as Ba,pt as Ca,si as Da,Lm as Ea,dg as Fa,Nm as Ga,mg as Ha,pg as Ia,ug as Ja,_g as Ka,fg as La,kg as Ma,Gm as Na,Sg as Oa,xg as Pa,Dg as Qa,jg as Ra,Xg as Sa,ky as Ta,w as Ua,iR as Va,aR as Wa,sR as Xa,cR as Ya,lR as Za,dR as _a,mR as $a,pR as ab,uR as bb,_R as cb,fR as db,hR as eb,gR as fb,yR as gb,bR as hb,wR as ib,vR as jb,kR as kb,SR as lb,IR as mb,AR as nb,ER as ob,TR as pb,CR as qb,RR as rb,xR as sb,OR as tb,$R as ub,FR as vb,PR as wb,LR as xb,NR as yb,DR as zb,MR as Ab,jR as Bb,GR as Cb,UR as Db,qR as Eb,zR as Fb,HR as Gb,WR as Hb,VR as Ib,BR as Jb,KR as Kb,JR as Lb,YR as Mb,XR as Nb,ZR as Ob,QR as Pb,ex as Qb,tx as Rb,nx as Sb,ox as Tb,rx as Ub,ix as Vb,ax as Wb,sx as Xb,cx as Yb,lx as Zb,dx as _b,mx as $b,px as ac,ux as bc,_x as cc,fx as dc,hx as ec,gx as fc,yx as gc,bx as hc,wx as ic,vx as jc,kx as kc,Sx as lc,Ix as mc,Ax as nc,Ex as oc,Tx as pc,Cx as qc,Rx as rc,xx as sc,Ox as tc,$x as uc,Iy as vc,Ry as wc,Fx as xc};
2258
- //# sourceMappingURL=chunk-JI2GDE4I.js.map
2257
+ `);let i=[];if(e.mode!=="keyword")try{M(e.progressEnabled,"writing vectorization status ledger"),await ls(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 ky(e,t){let n=ty(e.mode),o=ey(e),r=e.full===!0;M(o,`start mode=${n}`);let i=A(process.cwd(),t.path);await F(i);let a=Ha(await E(i)).settings,s=null;try{s=await ne(i,Wa,a.locks.ttl_seconds,C(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=ry(a),l=iy(a),d=my({requestedMode:n,pmRoot:i,settings:a,extensionEmbedding:c,extensionVectorAdapter:l}),m=n;M(o,"loading item corpus");let _=await py({pmRoot:i,settings:a}),y=_.warnings,{documentCandidates:g,metadataDocuments:k}=_;M(o,`loaded_items=${k.length}`);let b=S(),v=dy(m,b,k),h=Zt.join(i,bi),I=Zt.join(i,wi),P=m==="keyword"?await ki(i,g,a.schema,y):k,O=[],W={},$=null,R=ly(m);if(m==="keyword"&&await uy({pmRoot:i,settings:a,forceFullSemantic:r,extensionEmbedding:c,reindexWarnings:y}),m!=="keyword"){let te=await wy({pmRoot:i,settings:a,requestedMode:n,activeEmbeddingProvider:d.activeEmbeddingProvider,activeVectorStore:d.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:l,documentCandidates:g,metadataDocuments:k,documentsForKeywordArtifacts:P,forceFullSemantic:r,reindexWarnings:y,semanticWarnings:O,semanticSummary:R,progressEnabled:o});P=te.documentsForKeywordArtifacts,W=te.vectorizationLedgerEntries,$=te.vectorizationEmbeddingMetadata}let se=await vy({pmRoot:i,mode:m,manifest:v,documentsForKeywordArtifacts:P,settings:a,vectorizationLedgerEntries:W,vectorizationEmbeddingMetadata:$,progressEnabled:o}),Fe=[...await G({path:h,scope:"project",op:"reindex:manifest"}),...await G({path:I,scope:"project",op:"reindex:embeddings"}),...await la({mode:m,total_items:k.length})];return M(o,"done"),{ok:!0,mode:m,total_items:k.length,semantic:R,artifacts:{manifest:bi,embeddings:wi},warnings:[...y,...O,...se,...Fe],generated_at:b}}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]="f513a760-1161-53ac-ae6f-854930b8d891")}catch{}})();var Si=Symbol("pm.active-extension-host-context");function Q(e){return{fullChangedFields:!0,options:e}}var w=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[Si]=!0,n}run(t,n={}){return Ry({...this.defaults,...n,action:t})}runTyped(t,n={}){return this.run(t,n)}async withItemTransactionContext(t,n=!1){let o=A(this.defaults.cwd??process.cwd(),this.defaults.path),r=async()=>{let a=await Ft(o,()=>E(o));return t({pmRoot:o,author:C(this.defaults.author,a.author_default)})};if(this.defaults[Si]===!0||uo.getStore()===!0)return r();let i=()=>Iy({...this.defaults,path:o},r);return n?Ft(o,i):i()}previewItemMutations(t){return this.withItemTransactionContext(async n=>(await import("./item-transaction-TBKEATN6.js")).previewItemMutations({...t,...n}),!0)}commitItemMutations(t){return this.withItemTransactionContext(async n=>(await import("./item-transaction-TBKEATN6.js")).commitItemMutations({...t,...n}))}get itemTransactions(){let t=(n,o)=>this.withItemTransactionContext(async r=>(await import("./item-transaction-TBKEATN6.js")).abandonItemTransaction({...o,...r,transactionId:n}));return{status:n=>this.withItemTransactionContext(async o=>(await import("./item-transaction-TBKEATN6.js")).readItemTransaction(o.pmRoot,n),!0),abandon:t,supersede:(n,o,r)=>t(n,{...r,supersededBy:o})}}readItemRevision(t){return this.withItemTransactionContext(async({pmRoot:n})=>(await import("./item-revision-OJJVPQY7.js")).readItemRevision(t,{pmRoot:n}))}async withExpectedItemRevisions(t,n){let o=await import("./item-revision-OJJVPQY7.js"),r=await this.withItemTransactionContext(({pmRoot:i})=>o.bindExpectedItemRevisions(t,{pmRoot:i}));return o.runWithBoundItemRevisionScope(r,n)}context(t={}){return this.runTyped("context",{options:t})}listAllItemMetadataLight(){return od(this.defaults.path,this.defaults.cwd)}list(t={}){return this.runTyped("list",{options:t})}async listAllComplete(t={}){return Wn(await this.list(kr(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})}async append(t,n,o={}){return tc(o,"append"),await this.runTyped("append",{id:t,...Q(tt(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:tt(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 iR(e={},t={}){return new w(t).context(e)}function aR(e={},t={}){return new w(t).list(e)}function sR(e={},t={}){return new w(t).listAllComplete(e)}function cR(e,t={},n={}){return new w(n).search(e,t)}function lR(e,t={},n={}){return new w(n).get(e,t)}function dR(e={},t={}){return new w(t).next(e)}function mR(e={},t={}){return new w(t).aggregate(e)}function pR(e={},t={}){return new w(t).stats(e)}function uR(e={},t={}){return new w(t).duplicates(e)}function _R(e,t={},n={}){return new w(n).comments(e,t)}function fR(e,t={},n={}){return new w(n).notes(e,t)}function hR(e,t={},n={}){return new w(n).learnings(e,t)}function gR(e,t={},n={}){return new w(n).files(e,t)}function yR(e,t={},n={}){return new w(n).filesDiscover(e,t)}function bR(e,t={}){return new w(t).filesLookup(e)}function wR(e,t={},n={}){return new w(n).docs(e,t)}function vR(e,t={},n={}){return new w(n).deps(e,t)}function kR(e,t={},n={},o={}){return new w(o).graph(e,t,n)}function SR(e,t,n={},o={}){return new w(o).append(e,t,n)}function IR(e,t={},n={}){return new w(n).init(e,t)}function AR(e,t,n,o,r={},i={}){return new w(i).config(e,t,n,o,r)}function ER(e,t={},n={}){return new w(n).schema(e,t)}function TR(e={}){return new w(e).schemaList()}function CR(e,t={}){return new w(t).schemaShow(e)}function RR(e,t={},n={}){return new w(n).schemaAddType(e,t)}function xR(e,t={},n={}){return new w(n).schemaRemoveType(e,t)}function OR(e,t={},n={}){return new w(n).schemaAddStatus(e,t)}function $R(e,t={},n={}){return new w(n).schemaRemoveStatus(e,t)}function FR(e,t={},n={}){return new w(n).schemaAddField(e,t)}function PR(e,t={},n={}){return new w(n).schemaRemoveField(e,t)}function LR(e={}){return new w(e).schemaListFields()}function NR(e,t={}){return new w(t).schemaShowField(e)}function DR(e,t={},n={}){return new w(n).schemaApplyPreset(e,t)}function MR(e={},t={}){return new w(t).schemaInferTypes(e)}function jR(e,t,n,o={}){return new w(o).schemaRenameType(e,t,n)}function GR(e,t,n,o,r={}){return new w(r).schemaRenameField(e,t,n,o)}function UR(e,t,n,o={}){return new w(o).schemaRemapStatus(e,t,n)}function qR(e,t={}){return new w(t).schemaShowStatus(e)}function zR(e,t={},n={}){return new w(n).profile(e,t)}function HR(e={}){return new w(e).profileList()}function WR(e,t={}){return new w(t).profileShow(e)}function VR(e,t={},n={}){return new w(n).profileApply(e,t)}function BR(e,t={}){return new w(t).profileLint(e)}function KR(e={},t={}){return new w(t).validate(e)}function JR(e={},t={}){return new w(t).health(e)}function YR(e={},t={}){return new w(t).gc(e)}function XR(e,t,n={}){return new w(n).historyRedact(e,t)}function ZR(e,t={},n={}){return new w(n).historyRepair(e,t)}function QR(e={},t={}){return new w(t).historyRepairAll(e)}function ex(e,t={},n={}){return new w(n).historyCompact(e,t)}function tx(e,t={}){return new w(t).historyCompactBulk(e)}function nx(e={},t={}){return new w(t).create(e)}function ox(e,t={},n={}){return new w(n).update(e,t)}function rx(e,t,n={},o={}){return new w(o).reopen(e,t,n)}function ix(e,t,n={},o={}){return new w(o).close(e,t,n)}function ax(e,t={},n={}){return new w(n).claim(e,t)}function sx(e={},t={}){return new w(t).claimNext(e)}function cx(e,t={},n={}){return new w(n).release(e,t)}function lx(e,t={},n={}){return new w(n).copy(e,t)}function dx(e,t={},n={}){return new w(n).delete(e,t)}function mx(e,t,n={},o={}){return new w(o).restore(e,t,n)}function px(e,t={},n={}){return new w(n).focus(e,t)}function ux(e,t={},n={}){return new w(n).startTask(e,t)}function _x(e,t={},n={}){return new w(n).pauseTask(e,t)}function fx(e,t,n={},o={}){return new w(o).closeTask(e,t,n)}function hx(e,t={},n={}){return new w(n).extension(e,t)}function gx(e={},t={}){return new w(t).extensionList(e)}function yx(e,t={},n={}){return new w(n).extensionActivate(e,t)}function bx(e,t={},n={}){return new w(n).extensionDeactivate(e,t)}function wx(e,t={},n={}){return new w(n).package(e,t)}function vx(e={},t={}){return new w(t).packageList(e)}function kx(e,t={},n={}){return new w(n).packageInstall(e,t)}function Sx(e,t={},n={}){return new w(n).packageUninstall(e,t)}function Ix(e={},t={}){return new w(t).packageDoctor(e)}function Ax(e,t={},n={}){return new w(n).packageManage(e,t)}function Ex(e,t={},n={}){return new w(n).packageDescribe(e,t)}function Tx(e={},t={}){return new w(t).packageReload(e)}function Cx(e={},t={}){return new w(t).packageCatalog(e)}function Rx(e,t={},n={}){return new w(n).packageActivate(e,t)}function xx(e,t={},n={}){return new w(n).packageDeactivate(e,t)}function Ox(e,t={},n={}){return new w(n).upgrade(e,t)}async function $x(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 Tn(n,o)}var zp=aa(),uo=new Sy;function po(){Ao(Qi()),Eo(ea()),To(ta()),Co(na()),Ro(oa()),xo(ra()),Oo(ia())}async function Vp(e,t,n,o){return Io(()=>t===void 0?zp.read(()=>Hp(e,n,o)):zp.write(()=>Ty(t,()=>Hp(e,n,o))))}async function Iy(e,t){let n=e.cwd;if(uo.getStore()===!0&&n===void 0&&e.noExtensions===!0){let r=A(process.cwd(),e.path);return Io(()=>Gn({pmRoot:r},t))}let o=n??process.cwd();return Vp(kn({path:e.path,noExtensions:e.noExtensions}),n,o,()=>uo.run(!0,t))}function Ay(e){try{let t=e instanceof Error?e.stack:void 0,n=typeof t=="string"?t:ms(e);return typeof n=="string"?n:"Unknown failure"}catch{return"Unknown failure"}}async function Hp(e,t,n){let o=A(t,e.path);if(e.noExtensions)return po(),Gn({pmRoot:o},()=>n(null));if(!await ke(Se(o)))return po(),n(null);let r=null,i;try{let a=await E(o),s=await dn({pmRoot:o,settings:a,cwd:t,noExtensions:!1}),c=await pn({...s,loaded:s.loaded});i={loadResult:s,activationResult:c},Ao(c.hooks),Eo(c.commands),To(c.parsers),Co(c.preflight),Ro(c.services),xo(c.renderers),Oo(c.registrations),r={registrations:c.registrations,commands:c.commands,pmRoot:o,packages:s.loaded}}catch(a){po(),console.error("[pm-sdk] extension activation failed; continuing without active extensions:",Ay(a))}try{return await Gn({pmRoot:o,packages:r?.packages},()=>n(r))}finally{po(),i&&await mn(i.loadResult,i.activationResult).catch(()=>{})}}function Bp(e,t){let n=De(e);return t?.registrations.commands.find(o=>De(o.action)===n)?.command??t?.commands.handlers.find(o=>De(o.command)===n)?.command}async function Ey(e,t,n,o,r){if(!r)throw new p(`Unsupported native pm action: ${e}`,u.USAGE);let i=Bp(e,r);if(!i)throw new p(`Unsupported native pm action: ${e}`,u.USAGE);let a=typeof n.author=="string"?n.author:o.author,s=await da({command:In(i),args:U(n.args??t.args),options:Jo(t,n),global:{...o,author:a},pm_root:r.pmRoot,sdk:td(r.pmRoot,w.forActiveExtensionHost({pmRoot:r.pmRoot,author:a}),a,In(i))});if(!s.handled){if(Object.hasOwn(s,"cause"))throw ds(i,s);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 Ty(e,t){let n=process.cwd();process.chdir(e);try{return await t()}finally{process.chdir(n)}}function Cy(e){let t=K(e,"action"),n=De(t),o=be(Sr,n),r=o?.action??n,i={...e,action:r};return o?.options!==void 0&&(i.options={...o.options,...Rt(e.options)}),r==="package"&&(i.options={...Rt(i.options),vocabulary:"package"}),{action:r,args:i}}async function Ry(e){let t=Cy(e),n=kn(t.args);Bi(n);let o=dc(t.action),r=f(t.args,"cwd"),i=r??process.cwd();t.action==="init"&&(n[qc]=i),(t.action!=="init"||n.path!==void 0||(process.env.PM_PATH?.trim().length??0)>0)&&(n.path=A(i,n.path));let{expectHash:a,dispatchArgs:s}=_c(t.args),c=async l=>{if(a===void 0)return Wp(t.action,s,n,l);let{dispatchWithExpectedItemRevisions:d}=await import("./item-revision-OJJVPQY7.js");return d({action:t.action,expectHash:a,defaultId:f(s,"id")??f(Rt(s.options),"id"),options:Rt(s.options),background:s.background,pmRoot:A(i,n.path),run:()=>Wp(t.action,s,n,l)})};try{return t.action==="history-attest"?await c(null):e[Si]===!0||uo.getStore()===!0?await c(null):await Vp(n,r,i,l=>c(l))}finally{o&&ai()}}function Fx(e=Li){return e.map(t=>{let n=De(t),o=be(Sr,n),r=o?.action??n,i=be(ii,r)!==void 0;return{action:t,resolved_action:r,covered:i,route:i?o?"alias":"native":"missing"}})}async function Wp(e,t,n,o){let r=Ko(t,e);if(e==="create"||e==="update"){let{assertNativeMutationOptions:d}=await import("./mutation-admission-INMM3HHG.js");await d(e,t,r,n.path,cc[e])}let i=be(ii,e),a=i?void 0:Bp(e,o),s=a===void 0?e:`extension:${a}`;Ta(s,r),Ca(s,r);let c={action:e,args:t,options:r,id:f(t,"id"),force:t.force===!0||r.force===!0,global:n,activeExtensions:o},l=i?await i(c):await Ey(e,t,r,n,o);if(e==="history-attest")return l;{let d=Pa(s,r,l);return await Jl(A(process.cwd(),n.path),d),d}}var xy={closeManyOptionsFromFlat:An,extensionOptionsFromArgs:Jo,globalOptions:kn,mutationListOptions:mc,normalizeActionName:De,normalizeCommandPath:In,normalizeMcpUpdateOptions:uc,normalizeMcpOptionsArrays:lc,optionsWithAuthor:Ko,readRequiredString:K,readScalarString:ic,readScalarStringAllowBlank:ac,readStringArray:U,updateManyOptionsFromFlat:En,withAddNoteOption:Mt,withFilesDiscoveryOptions:Sn,withMutationCompaction:j};(process.env.NODE_ENV==="test"||process.env.VITEST!==void 0||process.env.VITEST_WORKER_ID!==void 0)&&(globalThis.__pmCliActionRunnerTestHooks=xy);export{hr as a,Kl as b,Zp as c,eu as d,tu as e,Gn as f,qt as g,Xl as h,Ht as i,zn as j,td as k,pu as l,Hn as m,kr as n,nd as o,Wn as p,bu as q,ad as r,ld as s,md as t,fd as u,Tr as v,Cr as w,Rr as x,xr as y,Xu as z,Nr as A,$d as B,Dd as C,Md as D,lt as E,Br as F,Tf as G,Sv as H,Iv as I,Yr as J,Gd as K,Gv as L,Uv as M,qd as N,Wd as O,sk as P,Hf as Q,oi as R,Vf as S,Bf as T,rm as U,im as V,am as W,sm as X,cm as Y,$k as Z,Fk as _,Pk as $,Lk as aa,lm as ba,pm as ca,eo as da,gm as ea,ym as fa,bm as ga,K as ha,ai as ia,dA as ja,mA as ka,pA as la,uA as ma,_A as na,xm as oa,fA as pa,Yh as qa,Qh as ra,og as sa,rg as ta,ig as ua,z as va,ag as wa,sg as xa,cg as ya,lg as za,ci as Aa,Pm as Ba,pt as Ca,si as Da,Lm as Ea,dg as Fa,Nm as Ga,mg as Ha,pg as Ia,ug as Ja,_g as Ka,fg as La,kg as Ma,Gm as Na,Sg as Oa,xg as Pa,Dg as Qa,jg as Ra,Xg as Sa,ky as Ta,w as Ua,iR as Va,aR as Wa,sR as Xa,cR as Ya,lR as Za,dR as _a,mR as $a,pR as ab,uR as bb,_R as cb,fR as db,hR as eb,gR as fb,yR as gb,bR as hb,wR as ib,vR as jb,kR as kb,SR as lb,IR as mb,AR as nb,ER as ob,TR as pb,CR as qb,RR as rb,xR as sb,OR as tb,$R as ub,FR as vb,PR as wb,LR as xb,NR as yb,DR as zb,MR as Ab,jR as Bb,GR as Cb,UR as Db,qR as Eb,zR as Fb,HR as Gb,WR as Hb,VR as Ib,BR as Jb,KR as Kb,JR as Lb,YR as Mb,XR as Nb,ZR as Ob,QR as Pb,ex as Qb,tx as Rb,nx as Sb,ox as Tb,rx as Ub,ix as Vb,ax as Wb,sx as Xb,cx as Yb,lx as Zb,dx as _b,mx as $b,px as ac,ux as bc,_x as cc,fx as dc,hx as ec,gx as fc,yx as gc,bx as hc,wx as ic,vx as jc,kx as kc,Sx as lc,Ix as mc,Ax as nc,Ex as oc,Tx as pc,Cx as qc,Rx as rc,xx as sc,Ox as tc,$x as uc,Iy as vc,Ry as wc,Fx as xc};
2258
+ //# sourceMappingURL=chunk-X3URBPMV.js.map
@@ -1,2 +1,2 @@
1
- import{i as a,j as b,k as c,l as d,m as e,n as f,o as g,p as h,q as i,r as j}from"./chunk-XLSHFYXZ.js";import"./chunk-JI2GDE4I.js";import"./chunk-OH6WQ7VT.js";import"./chunk-AUEKTX7V.js";import"./chunk-2RPORE7M.js";import"./chunk-UJMQP2HP.js";import"./chunk-6VRX2CM7.js";import"./chunk-LS3GI3H4.js";import"./chunk-DAX3AOFI.js";import"./chunk-S4LPZ4TN.js";import"./chunk-UEGXWXUZ.js";import"./chunk-HNGLDMSZ.js";import"./chunk-FRNMQM45.js";import"./chunk-HRFGFIYU.js";import"./chunk-IB7UB5TE.js";import"./chunk-5GWEY4P6.js";import"./chunk-7ZRCYESH.js";import"./chunk-SPPHDVZE.js";import"./chunk-RSAN2YUU.js";import"./chunk-VS565KBX.js";import"./chunk-O4ZLEN4T.js";import"./chunk-XAWE4EAK.js";export{h as _testOnlyItemTransaction,j as abandonItemTransaction,f as buildItemCompletionMutations,g as commitItemCompletion,e as commitItemMutations,b as listUpsertKeyCandidates,c as loadGuardedRuntimeSchema,d as previewItemMutations,i as readItemTransaction,a as resolveTransactionSchema};
2
- //# sourceMappingURL=item-transaction-QEPBUCMY.js.map
1
+ import{i as a,j as b,k as c,l as d,m as e,n as f,o as g,p as h,q as i,r as j}from"./chunk-PE3ASURT.js";import"./chunk-X3URBPMV.js";import"./chunk-OH6WQ7VT.js";import"./chunk-AUEKTX7V.js";import"./chunk-QNWUIPBO.js";import"./chunk-UJMQP2HP.js";import"./chunk-6VRX2CM7.js";import"./chunk-LS3GI3H4.js";import"./chunk-DAX3AOFI.js";import"./chunk-S4LPZ4TN.js";import"./chunk-UEGXWXUZ.js";import"./chunk-HNGLDMSZ.js";import"./chunk-FRNMQM45.js";import"./chunk-HRFGFIYU.js";import"./chunk-IB7UB5TE.js";import"./chunk-5GWEY4P6.js";import"./chunk-7ZRCYESH.js";import"./chunk-SPPHDVZE.js";import"./chunk-RSAN2YUU.js";import"./chunk-VS565KBX.js";import"./chunk-O4ZLEN4T.js";import"./chunk-XAWE4EAK.js";export{h as _testOnlyItemTransaction,j as abandonItemTransaction,f as buildItemCompletionMutations,g as commitItemCompletion,e as commitItemMutations,b as listUpsertKeyCandidates,c as loadGuardedRuntimeSchema,d as previewItemMutations,i as readItemTransaction,a as resolveTransactionSchema};
2
+ //# sourceMappingURL=item-transaction-TBKEATN6.js.map