@unbrained/pm-cli 2026.9.3 → 2026.9.4

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 (120) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +27 -0
  3. package/dist/cli-bundle/bundle-manifest.json +146 -146
  4. package/dist/cli-bundle/chunks/{chunk-E5RBBCXO.js → chunk-6XSKPNCF.js} +75 -75
  5. package/dist/cli-bundle/chunks/chunk-A24WAVE6.js +8 -0
  6. package/dist/cli-bundle/chunks/{chunk-DKGP3QLE.js → chunk-HI6BHPCU.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-Y4PJ6HPK.js → chunk-I2AS367G.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-IEHHE6GA.js → chunk-OGBVU67G.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-EDPIS7EB.js → chunk-RI4XNOYS.js} +2 -2
  10. package/dist/cli-bundle/chunks/chunk-TXW6VL33.js +38 -0
  11. package/dist/cli-bundle/chunks/{chunk-LENC656S.js → chunk-V72UV7QS.js} +76 -79
  12. package/dist/cli-bundle/chunks/chunk-VGLHECAP.js +9 -0
  13. package/dist/cli-bundle/chunks/{chunk-34HASX3S.js → chunk-X6CMGV6L.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-UPPM2FOZ.js → chunk-YW4QK2G7.js} +2 -2
  15. package/dist/cli-bundle/chunks/{register-list-query-W2ZTOMKP.js → register-list-query-Z5YYSJJG.js} +2 -2
  16. package/dist/cli-bundle/chunks/{register-mutation-RVND5NCG.js → register-mutation-ELSP6I4I.js} +2 -2
  17. package/dist/cli-bundle/chunks/{register-operations-TTROIVC4.js → register-operations-OH7R3ZT4.js} +2 -2
  18. package/dist/cli-bundle/chunks/{register-setup-D3ZFHY3L.js → register-setup-E2AE72QG.js} +2 -2
  19. package/dist/cli-bundle/focused-chunks/{chunk-Q45NHPF2.js → chunk-25UJBH4M.js} +2 -2
  20. package/dist/cli-bundle/focused-chunks/{chunk-4HJFY4MB.js → chunk-3646BZ4W.js} +2 -2
  21. package/dist/cli-bundle/focused-chunks/{chunk-TXE4TSHM.js → chunk-4YRAVI43.js} +2 -2
  22. package/dist/cli-bundle/focused-chunks/{chunk-M5M6SVHS.js → chunk-53IHPICX.js} +2 -2
  23. package/dist/cli-bundle/focused-chunks/chunk-5P4HVOWG.js +176 -0
  24. package/dist/cli-bundle/focused-chunks/chunk-636VVQ7F.js +54 -0
  25. package/dist/cli-bundle/focused-chunks/{chunk-D7KXFBXV.js → chunk-6PWPQKDN.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/{chunk-S27XMBIN.js → chunk-7N2TV7WZ.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/{chunk-5RFXUPN5.js → chunk-AJR3OP2E.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/{chunk-KZ2NB3ET.js → chunk-B3A6MJYE.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-BWKHEIVF.js → chunk-BFDDJ2T2.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-4WR46RMG.js → chunk-BHUIRZWQ.js} +8 -8
  31. package/dist/cli-bundle/focused-chunks/{chunk-4RRHC3S4.js → chunk-JADHHPY6.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/{chunk-GT7MXDLW.js → chunk-MHKUIPJW.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-NBMJD6MK.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-NSKBLHVI.js +20 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-OL5EH6I3.js → chunk-P2GOAOQN.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-UCLO3XDU.js → chunk-YARWJM2B.js} +2 -2
  37. package/dist/cli-bundle/main.js +2 -2
  38. package/dist/cli-bundle/sdk-authoring.js +1 -1
  39. package/dist/cli-bundle/sdk-contracts.js +1 -1
  40. package/dist/cli-bundle/sdk-core.js +28 -31
  41. package/dist/cli-bundle/sdk-governance.js +1 -1
  42. package/dist/cli-bundle/sdk-graph.js +1 -1
  43. package/dist/cli-bundle/sdk-merge.js +42 -37
  44. package/dist/cli-bundle/sdk-query.js +1 -1
  45. package/dist/cli-bundle/sdk-runtime.js +1 -1
  46. package/dist/cli-bundle/sdk-testing.js +1 -1
  47. package/dist/cli-bundle/sdk.js +10 -10
  48. package/dist/core/diagnostics/remediation.js +4 -4
  49. package/dist/core/history/history.d.ts +37 -1
  50. package/dist/core/history/history.js +278 -58
  51. package/dist/core/history/replay.js +68 -34
  52. package/dist/core/lock/lock.d.ts +10 -0
  53. package/dist/core/lock/lock.js +42 -3
  54. package/dist/core/shared/author.d.ts +3 -1
  55. package/dist/core/shared/author.js +111 -23
  56. package/dist/sdk/environment/agent-environment.d.ts +296 -0
  57. package/dist/sdk/environment/agent-environment.js +467 -0
  58. package/dist/sdk/environment/project-runtime-compatibility.d.ts +19 -1
  59. package/dist/sdk/environment/project-runtime-compatibility.js +118 -21
  60. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +14 -2
  61. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +14 -14
  62. package/dist/sdk/governance/health.js +13 -44
  63. package/dist/sdk/governance/merge-receipt-history.d.ts +62 -0
  64. package/dist/sdk/governance/merge-receipt-history.js +207 -0
  65. package/dist/sdk/governance/provenance-health.js +9 -3
  66. package/dist/sdk/history-compact.js +14 -5
  67. package/dist/sdk/history-redact.js +58 -23
  68. package/dist/sdk/history-repair.js +16 -6
  69. package/dist/sdk/index.d.ts +2 -0
  70. package/dist/sdk/index.js +4 -2
  71. package/dist/sdk/merge/driver.d.ts +3 -1
  72. package/dist/sdk/merge/driver.js +9 -9
  73. package/dist/sdk/merge/index.d.ts +1 -1
  74. package/dist/sdk/merge/index.js +3 -3
  75. package/dist/sdk/merge/receipts.d.ts +17 -6
  76. package/dist/sdk/merge/receipts.js +246 -75
  77. package/dist/sdk/merge/reconcile.d.ts +9 -7
  78. package/dist/sdk/merge/reconcile.js +175 -12
  79. package/dist/sdk/merge/three-way.d.ts +22 -2
  80. package/dist/sdk/merge/three-way.js +92 -25
  81. package/dist/sdk/runtime-primitives.d.ts +2 -2
  82. package/dist/sdk/runtime-primitives.js +4 -4
  83. package/dist/types.d.ts +25 -0
  84. package/dist/types.js +2 -2
  85. package/docs/AGENT_ENVIRONMENTS.md +47 -0
  86. package/docs/AGENT_PROVENANCE_ADR.md +17 -2
  87. package/docs/CONTEXT_INTEGRITY_CONTRACTS.md +38 -1
  88. package/docs/MERGE_SAFETY.md +119 -23
  89. package/docs/README.md +1 -0
  90. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +24 -2
  91. package/docs/SDK_RUNTIME_BOUNDARIES.md +17 -1
  92. package/docs/examples/sdk-agent-environment/README.md +14 -0
  93. package/docs/examples/sdk-agent-environment/package.json +8 -0
  94. package/docs/examples/sdk-agent-environment/run-agent-environment.mjs +154 -0
  95. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  96. package/marketplace.json +2 -2
  97. package/package.json +2 -2
  98. package/packages/pm-beads/package.json +1 -1
  99. package/packages/pm-calendar/package.json +1 -1
  100. package/packages/pm-command-kit/package.json +1 -1
  101. package/packages/pm-digital-twin/package.json +1 -1
  102. package/packages/pm-governance-audit/package.json +1 -1
  103. package/packages/pm-guide-shell/package.json +1 -1
  104. package/packages/pm-kanban/package.json +1 -1
  105. package/packages/pm-lifecycle-hooks/package.json +1 -1
  106. package/packages/pm-linked-test-adapters/package.json +1 -1
  107. package/packages/pm-search-advanced/package.json +1 -1
  108. package/packages/pm-templates/package.json +1 -1
  109. package/packages/pm-todos/package.json +1 -1
  110. package/packages/pm-vcs/package.json +1 -1
  111. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  112. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  113. package/sdk/public-surface.json +534 -24
  114. package/dist/cli-bundle/chunks/chunk-AY324UJ5.js +0 -9
  115. package/dist/cli-bundle/chunks/chunk-L7B7343B.js +0 -8
  116. package/dist/cli-bundle/chunks/chunk-LISESA7W.js +0 -35
  117. package/dist/cli-bundle/focused-chunks/chunk-3ZBI35HU.js +0 -176
  118. package/dist/cli-bundle/focused-chunks/chunk-GHCZ3YFR.js +0 -20
  119. package/dist/cli-bundle/focused-chunks/chunk-KBLZRU62.js +0 -2
  120. package/dist/cli-bundle/focused-chunks/chunk-QKHCSUGJ.js +0 -51
@@ -1,6 +1,6 @@
1
- import{c as T}from"./chunk-M5M6SVHS.js";import{e as a,g as x}from"./chunk-5RFXUPN5.js";import{$ as f,P as w,aa as u,ja as m,qa as v,r as h,s as b,t as E}from"./chunk-4RRHC3S4.js";import C from"node:fs/promises";import p 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]="6fc24a7c-a359-51fd-a432-4c8037d10e9e")}catch{}})();var z=["extensions","docs","examples","assets","prompts"],R=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function q(e){return z.includes(e)}function G(e,t){if(t==null)return[];let n=Array.isArray(t)?t:[t],r=[];for(let i of n){if(typeof i!="string"||i.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,f.USAGE);r.push(i.trim())}return[...new Set(r)].sort((i,o)=>i.localeCompare(o))}function J(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",f.USAGE);let t={},n=e;for(let[r,i]of Object.entries(n)){if(!q(r))continue;let o=G(r,i);o.length>0&&(t[r]=o)}return t}function c(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n.trim():void 0}function S(e){if(!Array.isArray(e))return;let t=e.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0);return t.length>0?[...new Set(t)].sort((n,r)=>n.localeCompare(r)):void 0}function I(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={docs:c(t,"docs"),npm:c(t,"npm"),repository:c(t,"repository"),report:c(t,"report")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={image:c(t,"image"),video:c(t,"video")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function Y(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={display_name:c(t,"display_name")??c(t,"displayName"),category:c(t,"category"),summary:c(t,"summary"),links:K(t.links),media:V(t.media),tags:S(t.tags)};return Object.values(n).some(r=>r!==void 0)?n:void 0}async function B(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let n;try{n=JSON.parse(await C.readFile(t,"utf8"))}catch(d){throw new u(`Failed to parse package manifest at "${t}": ${String(d)}`,f.USAGE)}if(typeof n!="object"||n===null||Array.isArray(n))throw new u(`Package manifest at "${t}" must be a JSON object.`,f.USAGE);let r=n,i=r.pm,o=i!=null,s=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:{};return{source:o?"pm":"convention",package_json_path:t,package_name:typeof r.name=="string"?r.name:void 0,package_version:typeof r.version=="string"?r.version:void 0,package_private:r.private===!0,package_description:typeof r.description=="string"?r.description:void 0,package_keywords:S(r.keywords),package_homepage:typeof r.homepage=="string"?r.homepage:void 0,package_repository_url:I(r.repository),package_bugs_url:I(r.bugs),aliases:S(s.aliases),resources:J(i),catalog:Y(s.catalog)}}async function j(e){if(!await m(e))return[];let t=await C.readdir(e,{withFileTypes:!0}),n=[];for(let r of t){if(!r.isDirectory())continue;let i=p.join(e,r.name);await m(p.join(i,"manifest.json"))&&n.push(i)}return n.sort((r,i)=>r.localeCompare(i))}async function _e(e){if(await m(p.join(e,"manifest.json")))return[e];let n=(await B(e)).resources.extensions??[],r=new Set;for(let i of n){if(i.includes("*")||i.startsWith("!"))throw new u(`Package extension entry "${i}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,f.USAGE);let o=p.resolve(e,i);if(!v(e,o))throw new u(`Package extension entry "${i}" resolves outside package root.`,f.USAGE);if(await m(p.join(o,"manifest.json"))){r.add(o);continue}for(let s of await j(o))r.add(s)}if(n.length===0)for(let i of R.extensions)for(let o of await j(p.join(e,i)))r.add(o);return[...r].sort((i,o)=>i.localeCompare(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="48c3e62a-8085-5215-a692-4c03792022ce")}catch{}})();var D=1,A=6,$=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function k(e){return"#".repeat(e)}function F(e){if(!e.includes("`"))return`\`${e}\``;let t=0,n=0;for(let o of e)n=o==="`"?n+1:0,t=Math.max(t,n);let r="`".repeat(t+1),i=e.startsWith("`")||e.endsWith("`")?" ":"";return`${r}${i}${e}${i}${r}`}function W(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(F).join(", ")}`}function H(e,t,n){let r=[`${k(t)} ${e}`,""];return n.length===0?(r.push("_None._",""),r):(r.push(...n.map(i=>`- ${F(i)}`),""),r)}function X(e,t,n){return e===0&&!n?[]:[`${k(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function Ee(e,t={}){let n=t.headingLevel??2;if(!Number.isInteger(n)||n<D||n>A)throw new RangeError(`headingLevel must be an integer in [${D}, ${A}], received ${String(t.headingLevel)}`);let r=Math.min(n+1,A),i=t.includeEmpty===!0,o=t.title??"Extension surfaces",s=[`${k(n)} ${o}`,""];(i||e.capabilities.length>0)&&s.push(W(e.capabilities),"");for(let[l,y]of $){let g=e[l]??[];g.length===0&&!i||s.push(...H(y,r,g))}return s.push(...X(e.preflight_overrides,r,i)),!(e.preflight_overrides>0||$.some(([l])=>(e[l]?.length??0)>0))&&!i&&s.push("_This extension registers no surfaces._",""),`${s.join(`
1
+ import{c as T}from"./chunk-53IHPICX.js";import{e as a,g as x}from"./chunk-AJR3OP2E.js";import{$ as f,P as w,aa as u,ja as m,qa as v,r as h,s as b,t as E}from"./chunk-JADHHPY6.js";import C from"node:fs/promises";import p 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]="6fc24a7c-a359-51fd-a432-4c8037d10e9e")}catch{}})();var z=["extensions","docs","examples","assets","prompts"],R=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function q(e){return z.includes(e)}function G(e,t){if(t==null)return[];let n=Array.isArray(t)?t:[t],r=[];for(let i of n){if(typeof i!="string"||i.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,f.USAGE);r.push(i.trim())}return[...new Set(r)].sort((i,o)=>i.localeCompare(o))}function J(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",f.USAGE);let t={},n=e;for(let[r,i]of Object.entries(n)){if(!q(r))continue;let o=G(r,i);o.length>0&&(t[r]=o)}return t}function c(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n.trim():void 0}function S(e){if(!Array.isArray(e))return;let t=e.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0);return t.length>0?[...new Set(t)].sort((n,r)=>n.localeCompare(r)):void 0}function I(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={docs:c(t,"docs"),npm:c(t,"npm"),repository:c(t,"repository"),report:c(t,"report")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={image:c(t,"image"),video:c(t,"video")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function Y(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={display_name:c(t,"display_name")??c(t,"displayName"),category:c(t,"category"),summary:c(t,"summary"),links:K(t.links),media:V(t.media),tags:S(t.tags)};return Object.values(n).some(r=>r!==void 0)?n:void 0}async function B(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let n;try{n=JSON.parse(await C.readFile(t,"utf8"))}catch(d){throw new u(`Failed to parse package manifest at "${t}": ${String(d)}`,f.USAGE)}if(typeof n!="object"||n===null||Array.isArray(n))throw new u(`Package manifest at "${t}" must be a JSON object.`,f.USAGE);let r=n,i=r.pm,o=i!=null,s=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:{};return{source:o?"pm":"convention",package_json_path:t,package_name:typeof r.name=="string"?r.name:void 0,package_version:typeof r.version=="string"?r.version:void 0,package_private:r.private===!0,package_description:typeof r.description=="string"?r.description:void 0,package_keywords:S(r.keywords),package_homepage:typeof r.homepage=="string"?r.homepage:void 0,package_repository_url:I(r.repository),package_bugs_url:I(r.bugs),aliases:S(s.aliases),resources:J(i),catalog:Y(s.catalog)}}async function j(e){if(!await m(e))return[];let t=await C.readdir(e,{withFileTypes:!0}),n=[];for(let r of t){if(!r.isDirectory())continue;let i=p.join(e,r.name);await m(p.join(i,"manifest.json"))&&n.push(i)}return n.sort((r,i)=>r.localeCompare(i))}async function _e(e){if(await m(p.join(e,"manifest.json")))return[e];let n=(await B(e)).resources.extensions??[],r=new Set;for(let i of n){if(i.includes("*")||i.startsWith("!"))throw new u(`Package extension entry "${i}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,f.USAGE);let o=p.resolve(e,i);if(!v(e,o))throw new u(`Package extension entry "${i}" resolves outside package root.`,f.USAGE);if(await m(p.join(o,"manifest.json"))){r.add(o);continue}for(let s of await j(o))r.add(s)}if(n.length===0)for(let i of R.extensions)for(let o of await j(p.join(e,i)))r.add(o);return[...r].sort((i,o)=>i.localeCompare(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="48c3e62a-8085-5215-a692-4c03792022ce")}catch{}})();var D=1,A=6,$=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function k(e){return"#".repeat(e)}function F(e){if(!e.includes("`"))return`\`${e}\``;let t=0,n=0;for(let o of e)n=o==="`"?n+1:0,t=Math.max(t,n);let r="`".repeat(t+1),i=e.startsWith("`")||e.endsWith("`")?" ":"";return`${r}${i}${e}${i}${r}`}function W(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(F).join(", ")}`}function H(e,t,n){let r=[`${k(t)} ${e}`,""];return n.length===0?(r.push("_None._",""),r):(r.push(...n.map(i=>`- ${F(i)}`),""),r)}function X(e,t,n){return e===0&&!n?[]:[`${k(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function Ee(e,t={}){let n=t.headingLevel??2;if(!Number.isInteger(n)||n<D||n>A)throw new RangeError(`headingLevel must be an integer in [${D}, ${A}], received ${String(t.headingLevel)}`);let r=Math.min(n+1,A),i=t.includeEmpty===!0,o=t.title??"Extension surfaces",s=[`${k(n)} ${o}`,""];(i||e.capabilities.length>0)&&s.push(W(e.capabilities),"");for(let[l,y]of $){let g=e[l]??[];g.length===0&&!i||s.push(...H(y,r,g))}return s.push(...X(e.preflight_overrides,r,i)),!(e.preflight_overrides>0||$.some(([l])=>(e[l]?.length??0)>0))&&!i&&s.push("_This extension registers no surfaces._",""),`${s.join(`
2
2
  `).trimEnd()}
3
3
  `}(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]="e3f016bb-8add-5765-bb1a-a7b22423f8d1")}catch{}})();var Q=["agile","ops","research"],Z={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function ke(e){if(e===void 0)return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length===0)throw new Error("Type preset name must not be empty.");if(t==="agile"||t==="ops"||t==="research")return t;throw new Error(`Invalid type preset "${e}". Allowed: ${Q.join(", ")}.`)}function we(e){return Z[e].map(t=>T(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]="2b5a573e-1e36-58b9-b93b-4a4088f71e9a")}catch{}})();var ee=new Set(b),te=new Set(E),N=new Set([...w.filter(e=>e!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),ne=["create","update"];function P(e){if(typeof e!="string")return"";let t=e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return t.startsWith("--")?t.slice(2):t}function O(e){return e.replaceAll("_","-")}function re(e,t){let n=new Set;for(let r of e){let i=P(r);i.length>0&&i!==t&&n.add(i)}return[...n].sort((r,i)=>r.localeCompare(i))}function ie(e){let t=new Set;for(let n of e??[]){let r=n.trim();r.length>0&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function oe(e){let t=new Set,n=[];for(let r of e??[]){let i=r.trim().toLowerCase();if(i.length!==0){if(!te.has(i))throw new Error(`Invalid field command "${r}". Allowed: ${E.join(", ")}.`);t.has(i)||(t.add(i),n.push(i))}}return e===void 0||n.length===0?[...ne]:n}function je(e){let t=a(e.key);if(t.length===0)throw new Error("Field key must not be empty.");if(N.has(t))throw new Error(`Cannot define custom field "${t}": custom schema field "${t}" collides with built-in item metadata "${t}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...N].sort((g,U)=>g.localeCompare(U)).join(", ")}.`);let n=typeof e.type=="string"&&e.type.trim().length>0?e.type.trim().toLowerCase():"string";if(!ee.has(n))throw new Error(`Invalid field type "${e.type}". Allowed: ${b.join(", ")}.`);let r=n,i=oe(e.commands),o=P(e.cliFlag),s=o.length>0&&o!==O(t)?o:void 0,d=s??O(t),l=re(e.aliases??[],d),y=e.description?.trim();return{key:t,type:r,commands:i,description:y&&y.length>0?y:void 0,cliFlag:s,cliAliases:l,required:e.required===!0,requiredOnCreate:e.requiredOnCreate===!0,allowUnset:e.allowUnset!==!1,requiredTypes:ie(e.requiredTypes)}}function se(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function ae(e){let t=se(e);if(!t)return[];let n=[];for(let r of t){if(typeof r!="object"||r===null||Array.isArray(r))continue;let i=r;typeof i.key!="string"||i.key.trim().length===0||n.push(i)}return n}function Ce(e){if(e==null||e.trim().length===0)return{fields:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:ae(t)}}function De(e){return`${JSON.stringify({fields:e.fields},null,2)}
4
4
  `}function $e(e,t){let n=e.fields.find(s=>a(s.key)===t.key),r=n!==void 0,i=e.fields.filter(s=>a(s.key)!==t.key),o={...n,key:t.key,type:t.type,commands:[...t.commands]};return L(o,"description",t.description),L(o,"cli_flag",t.cliFlag),t.cliAliases.length>0?o.cli_aliases=[...t.cliAliases]:delete o.cli_aliases,M(o,"required",t.required),M(o,"required_on_create",t.requiredOnCreate),t.allowUnset===!1?o.allow_unset=!1:delete o.allow_unset,t.requiredTypes.length>0?o.required_types=[...t.requiredTypes]:delete o.required_types,i.push(o),i.sort((s,d)=>a(s.key).localeCompare(a(d.key))),{file:{fields:i},definition:o,replaced:r}}function Fe(e,t){let n=a(t);if(n.length===0)throw new Error("Field key must not be empty.");let r=[],i=e.fields.filter(o=>a(o.key)===n?(r.push(o),!1):!0);return r.length===0?{file:{fields:i},removed:!1}:{file:{fields:i},removed:!0,definition:r[0]}}function L(e,t,n){let r=e;n!==void 0&&n.length>0?r[t]=n:delete r[t]}function M(e,t,n){let r=e;n?r[t]=!0:delete r[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]="ec456832-5120-5171-93fd-861ea4125acb")}catch{}})();var de=new Set(h),_=new Set(x.map(e=>a(e.id)).filter(e=>e.length>0));function le(e){let t=new Set;for(let n of e){let r=a(n);r.length>0&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function Ue(e){let t=a(e.id);if(t.length===0)throw new Error("Status id must not be empty.");if(_.has(t))throw new Error(`Cannot add-status the built-in status "${t}". Built-in statuses are reserved: ${[..._].join(", ")}.`);let n;if(e.roles!==void 0){n=[];let s=new Set;for(let d of e.roles){let l=typeof d=="string"?d.trim().toLowerCase():"";if(l.length!==0){if(!de.has(l))throw new Error(`Invalid status role "${d}". Allowed roles: ${h.join(", ")}.`);s.has(l)||(s.add(l),n.push(l))}}if(n.length===0)throw new Error(`Status role must include at least one lifecycle role. Allowed roles: ${h.join(", ")}.`)}let r=e.aliases===void 0?void 0:le(e.aliases).filter(s=>s!==t),i=e.description?.trim(),o=typeof e.order=="number"&&Number.isFinite(e.order)?Math.trunc(e.order):void 0;return{id:t,roles:n,aliases:r,description:i&&i.length>0?i:void 0,order:o}}function ce(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function fe(e){let t=ce(e);if(!t)return[];let n=[];for(let r of t){if(typeof r!="object"||r===null||Array.isArray(r))continue;let i=r;typeof i.id!="string"||i.id.trim().length===0||n.push(i)}return n}function ze(e){if(e==null||e.trim().length===0)return{statuses:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:fe(t)}}function Re(e){return`${JSON.stringify({statuses:e.statuses},null,2)}
5
5
  `}function qe(e,t,n){let r=e.statuses.slice(),i=r.findIndex(d=>a(d.id)===t.id),o=i>=0?r[i]:n,s={...o,id:t.id};return t.roles!==void 0&&(t.roles.length>0?s.roles=[...t.roles]:s.roles!==void 0&&delete s.roles),t.aliases!==void 0&&(t.aliases.length>0?s.aliases=[...t.aliases]:s.aliases!==void 0&&delete s.aliases),t.description!==void 0&&(s.description=t.description),t.order!==void 0&&(s.order=t.order),i>=0?r[i]=s:r.push(s),{file:{statuses:r},definition:s,replaced:o!==void 0}}function Ge(e,t){let n=a(t);if(n.length===0)throw new Error("Status id must not be empty.");if(_.has(n))throw new Error(`Cannot remove built-in status "${n}". Built-in statuses are reserved: ${[..._].join(", ")}.`);let r=e.statuses.slice(),i=r.findIndex(s=>a(s.id)===n);if(i<0)return{file:{statuses:r},removed:!1};let[o]=r.splice(i,1);return{file:{statuses:r},removed:!0,definition:o}}function Je(e,t){let n=[e.id,...e.aliases??[]];for(let r of n){let i=a(r);if(i.length===0)continue;let o=t.get(i);if(o!==void 0&&o!==e.id)throw new Error(`Status token "${i}" already belongs to status "${o}". Choose a different id/alias to avoid shadowing it.`)}}export{z as a,R as b,B as c,_e as d,Q as e,Z as f,ke as g,we as h,je as i,Ce as j,De as k,$e as l,Fe as m,_ as n,Ue as o,ze as p,Re as q,qe as r,Ge as s,Je as t,Ee as u};
6
- //# sourceMappingURL=chunk-D7KXFBXV.js.map
6
+ //# sourceMappingURL=chunk-6PWPQKDN.js.map
@@ -1,8 +1,8 @@
1
- import{w as D,x as q}from"./chunk-KBLZRU62.js";import{ob as N,ub as z,wb as O}from"./chunk-3ZBI35HU.js";import{M as j}from"./chunk-4WR46RMG.js";import{Ec as x,Hc as C,Kc as L,Za as S,cb as m,la as b,na as k,nb as _}from"./chunk-4RRHC3S4.js";import{constants as u}from"node:fs";import{lstat as M,mkdir as $,open as F}from"node:fs/promises";import h from"node:path";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="bb5dfa6f-b60f-55f2-ae17-3dbcaaff1b47")}catch{}})();function E(i,e){if(typeof i!="string"||i.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return i.trim()}function I(i,e){let t=e.require(i.kind),n=t.direction==="undirected"?[i.source,i.target].sort().join("\0"):`${i.source}\0${i.target}`;return`${t.kind}\0${n}`}function H(i){return Object.freeze({...i,...i.payload===void 0?{}:{payload:Object.freeze(structuredClone(i.payload))}})}function J(i,e,t,n){let r=t.require(i.kind),o=n.outgoingOne.get(`${r.kind}\0${i.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=n.incomingOne.get(`${r.kind}\0${i.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let c=I(i,t),d=n.identities.get(c);if(d!==void 0&&d!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function K(i){let e=new Map;for(let t of i)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function G(i,e,t){if(i.expectedVersion!==void 0&&i.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${i.expectedVersion}, current ${e}`);let n=E(i.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(i.action!=="add"&&i.action!=="remove"&&i.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${i.action}`);if(!Number.isFinite(Date.parse(i.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(i.relationshipId,"relationshipId"),author:E(i.author,"author"),timestamp:new Date(i.timestamp).toISOString()}}function Q(i,e,t,n,r,o){let s=t.has(e);if(i.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(i.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(i.action==="remove")return;if(!i.edge)throw new TypeError(`Relationship ${i.action} event requires an edge`);let c=typeof i.edge.source=="string"?i.edge.source.trim():"",d=typeof i.edge.target=="string"?i.edge.target.trim():"";if(!n.has(c)||!n.has(d))throw new TypeError(`Relationship endpoint not found: ${c} -> ${d}`);let a=new m([c,d],[i.edge],r).edges()[0];return J(a,e,r,o),H(a)}var T=class{#t;#n;#i=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#n=t.registry??S()}get version(){return this.#i.length}events(){return Object.freeze([...this.#i])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,r=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=r)yield Object.freeze(this.#i.slice(o,Math.min(o+r,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let r=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let d of c)r=t(r,d),o+=1,s=d;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#n.require(t.kind);this.#r.identities.set(I(t,this.#n),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#n.require(e.kind);this.#r.identities.delete(I(e,this.#n)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=G(e,this.version,this.#o),n=this.#e.get(t.relationshipId),r=Q(e,t.relationshipId,this.#e,this.#t,this.#n,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...r===void 0?{}:{edge:r},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#i.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,r),this.#s(t.relationshipId,r)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#i.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#i.slice(0,o)}let n=K(t),r=new m(this.#t,n.values(),this.#n);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=x("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(C(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=L(this.#i.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},Y="relationship-event-store",A=u.O_NOFOLLOW;function g(i){return j(i,Y,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function l(i,e="relationships/events.jsonl"){let t=h.resolve(i),n=h.resolve(t,e),r=h.relative(t,n);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${h.sep}`)||h.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await $(t,{recursive:!0}),(await M(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let s=t;for(let c of r.split(h.sep)){s=h.join(s,c);try{if((await M(s)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(d){if(b(d))break;throw d}}return n}async function w(i,e,t){let n=new T(e,{registry:t}),r,o;try{o=await F(i,u.O_RDONLY|A),r=await o.readFile("utf8")}catch(c){if(b(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=r.split(`
1
+ import{w as D,x as q}from"./chunk-NBMJD6MK.js";import{Bb as O,tb as N,zb as z}from"./chunk-5P4HVOWG.js";import{M as j}from"./chunk-BHUIRZWQ.js";import{Ec as x,Hc as C,Kc as L,Za as S,cb as m,la as b,na as k,nb as _}from"./chunk-JADHHPY6.js";import{constants as u}from"node:fs";import{lstat as M,mkdir as $,open as F}from"node:fs/promises";import h from"node:path";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="bb5dfa6f-b60f-55f2-ae17-3dbcaaff1b47")}catch{}})();function E(i,e){if(typeof i!="string"||i.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return i.trim()}function I(i,e){let t=e.require(i.kind),n=t.direction==="undirected"?[i.source,i.target].sort().join("\0"):`${i.source}\0${i.target}`;return`${t.kind}\0${n}`}function H(i){return Object.freeze({...i,...i.payload===void 0?{}:{payload:Object.freeze(structuredClone(i.payload))}})}function J(i,e,t,n){let r=t.require(i.kind),o=n.outgoingOne.get(`${r.kind}\0${i.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=n.incomingOne.get(`${r.kind}\0${i.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let c=I(i,t),d=n.identities.get(c);if(d!==void 0&&d!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function K(i){let e=new Map;for(let t of i)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function G(i,e,t){if(i.expectedVersion!==void 0&&i.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${i.expectedVersion}, current ${e}`);let n=E(i.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(i.action!=="add"&&i.action!=="remove"&&i.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${i.action}`);if(!Number.isFinite(Date.parse(i.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(i.relationshipId,"relationshipId"),author:E(i.author,"author"),timestamp:new Date(i.timestamp).toISOString()}}function Q(i,e,t,n,r,o){let s=t.has(e);if(i.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(i.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(i.action==="remove")return;if(!i.edge)throw new TypeError(`Relationship ${i.action} event requires an edge`);let c=typeof i.edge.source=="string"?i.edge.source.trim():"",d=typeof i.edge.target=="string"?i.edge.target.trim():"";if(!n.has(c)||!n.has(d))throw new TypeError(`Relationship endpoint not found: ${c} -> ${d}`);let a=new m([c,d],[i.edge],r).edges()[0];return J(a,e,r,o),H(a)}var T=class{#t;#n;#i=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#n=t.registry??S()}get version(){return this.#i.length}events(){return Object.freeze([...this.#i])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,r=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=r)yield Object.freeze(this.#i.slice(o,Math.min(o+r,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let r=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let d of c)r=t(r,d),o+=1,s=d;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#n.require(t.kind);this.#r.identities.set(I(t,this.#n),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#n.require(e.kind);this.#r.identities.delete(I(e,this.#n)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=G(e,this.version,this.#o),n=this.#e.get(t.relationshipId),r=Q(e,t.relationshipId,this.#e,this.#t,this.#n,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...r===void 0?{}:{edge:r},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#i.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,r),this.#s(t.relationshipId,r)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#i.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#i.slice(0,o)}let n=K(t),r=new m(this.#t,n.values(),this.#n);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=x("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(C(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=L(this.#i.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},Y="relationship-event-store",A=u.O_NOFOLLOW;function g(i){return j(i,Y,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function l(i,e="relationships/events.jsonl"){let t=h.resolve(i),n=h.resolve(t,e),r=h.relative(t,n);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${h.sep}`)||h.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await $(t,{recursive:!0}),(await M(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let s=t;for(let c of r.split(h.sep)){s=h.join(s,c);try{if((await M(s)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(d){if(b(d))break;throw d}}return n}async function w(i,e,t){let n=new T(e,{registry:t}),r,o;try{o=await F(i,u.O_RDONLY|A),r=await o.readFile("utf8")}catch(c){if(b(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=r.split(`
2
2
  `);for(let c=0;c<s.length;c+=1){let d=s[c].trim();if(!d)continue;let a;try{a=JSON.parse(d)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${c+1}`)}if(a.sequence!==n.version+1)throw new TypeError(`Invalid relationship event sequence at line ${c+1}`);n.append({eventId:a.eventId,relationshipId:a.relationshipId,action:a.action,...a.edge===void 0?{}:{edge:a.edge},author:a.author,timestamp:a.timestamp,...a.reason===void 0?{}:{reason:a.reason},expectedVersion:n.version})}return{log:n,raw:r}}function U(i,e,t,n){let r=Date.parse(e.timestamp),o;return e.action!=="remove"&&e.edge!==void 0&&(o=new m(t,[e.edge],n).edges()[0]),i.eventId===e.eventId.trim()&&i.relationshipId===e.relationshipId.trim()&&i.action===e.action&&i.author===e.author.trim()&&Number.isFinite(r)&&i.timestamp===new Date(r).toISOString()&&i.reason===(e.reason?.trim()||void 0)&&_(i.edge)===_(o)}var V=class i{#t;#n;#i;#o;#e;constructor(e,t,n,r){this.#t=e.pmRoot,this.#n=t,this.#i=e.registry,this.#o=n,this.#e=r}static async open(e){let t=Object.freeze([...e.nodes]),n=await l(e.pmRoot,e.relativePath),r=await g(e.pmRoot);try{await l(e.pmRoot,n);let{log:o}=await w(n,t,e.registry);return new i(e,t,n,o)}finally{await r()}}get path(){return this.#o}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(e){let t=await g(this.#t);try{let n=await l(this.#t,this.#o),{log:r}=await w(n,this.#n,this.#i),o=r.append(e);await $(h.dirname(n),{recursive:!0}),await l(this.#t,n);let s=await F(n,u.O_APPEND|u.O_CREAT|u.O_WRONLY|A);try{await s.appendFile(`${JSON.stringify(o)}
3
3
  `,"utf8")}finally{await s.close()}return this.#e=r,o}finally{await t()}}async appendBatch(e,t={}){let n=await g(this.#t);try{let r=await l(this.#t,this.#o),{log:o,raw:s}=await w(r,this.#n,this.#i),c=o.version,d=new Map(o.events().map(f=>[f.eventId,f])),a=[],R=[];for(let f of e){let p=f.eventId.trim(),y=d.get(p);if(y!==void 0){if(t.existingEventPolicy==="skip_identical"&&U(y,f,this.#n,this.#i)){R.push(y.eventId);continue}if(t.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${p}`)}let v=o.append(f);d.set(v.eventId,v),a.push(v)}if(a.length>0){let f=s.length===0||s.endsWith(`
4
4
  `)?s:`${s}
5
5
  `;await $(h.dirname(r),{recursive:!0}),await l(this.#t,r),await k(r,`${f}${a.map(p=>JSON.stringify(p)).join(`
6
6
  `)}
7
7
  `)}return this.#e=o,Object.freeze({version_before:c,version_after:o.version,appended:Object.freeze(a),skipped_event_ids:Object.freeze(R)})}finally{await n()}}async snapshot(e={}){return this.#e=await this.#r(),this.#e.snapshot(e)}async page(e){return this.#e=await this.#r(),this.#e.page(e)}async*stream(e={}){this.#e=await this.#r(),yield*this.#e.stream(e)}async project(e,t,n={}){return this.#e=await this.#r(),this.#e.project(e,t,n)}async#r(){let e=await g(this.#t);try{let t=await l(this.#t,this.#o);return(await w(t,this.#n,this.#i)).log}finally{await e()}}};(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="94e8b95b-35fa-5fc7-843a-481497e09b54")}catch{}})();function P(i){return[...i].sort().join("\0")}function X(i,e,t){let n=i.successors.get(e);n?n.push(t):i.successors.set(e,[t]);let r=i.predecessors.get(t);r?r.push(e):i.predecessors.set(t,[e])}function W(i,e,t,n,r){let o=e.resolve(r);if(o?.ordering!==!0)return;let s=z(n),c=s===void 0?void 0:i.canonicalIds.get(s.toLowerCase());if(c===void 0)return;let d=(o.precedence??"source_before_target")==="source_before_target";X(i,d?t:c,d?c:t)}function Z(i,e){let t={successors:new Map,predecessors:new Map,canonicalIds:new Map},n=i.filter(r=>typeof r?.id=="string"&&r.id.trim().length>0);for(let r of n){let o=r.id.trim();t.canonicalIds.set(o.toLowerCase(),o)}for(let r of n){let o=r.id.trim();W(t,e,o,r.blocked_by,"blocked_by");for(let s of r.dependencies??[])typeof s!="object"||s===null||W(t,e,o,s.id,typeof s.kind=="string"?s.kind:"related")}for(let r of[t.successors,t.predecessors])for(let o of r.values())o.sort();return t}function ee(i,e){let t=new Set([e]),n=[e];for(;n.length>0;){let r=n.pop();for(let o of[i.successors,i.predecessors])for(let s of o.get(r)??[])t.has(s)||(t.add(s),n.push(s))}return t}function te(i,e){let t=new Map;for(let n of e){let r=(i.successors.get(n)??[]).filter(o=>e.has(o));r.length>0&&t.set(n,r)}return t}function B(i,e,t){let n=Z(i,e),r=n.canonicalIds.get(t.trim().toLowerCase());if(r===void 0)return{cycles:[],successors:new Map,canonical:t};let o=te(n,ee(n,r));return{cycles:D(o).filter(s=>s.includes(r)),successors:o,canonical:r}}function ne(i,e,t){let n=new Set(e),r=n.has(t)?t:e[0];if(i.get(r)?.includes(r))return[r,r];for(let o of i.get(r)??[]){if(!n.has(o))continue;let s=ie(i,n,r,o);if(s)return s}return[...e,e[0]]}function ie(i,e,t,n){let r=[[n]],o=new Set([t,n]);for(;r.length>0;){let s=r.shift(),c=s.at(-1);for(let d of i.get(c)??[]){if(d===t)return[t,...s,t];!e.has(d)||o.has(d)||(o.add(d),r.push([...s,d]))}}}function me(i,e,t){let n=N(),r=B(i,n,t),o=B(e,n,t),s=new Set(r.cycles.map(P)),c=new Set(O(i,void 0,n).map(a=>`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`));return[...O(e,void 0,n).filter(a=>a.holder_id.toLowerCase()===t.trim().toLowerCase()&&!c.has(`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`)).map(a=>`ordering_storage_contradiction_created:${q(a)}:remove_contradicting_dependency_row:run_pm_graph_audit`),...o.cycles.filter(a=>!s.has(P(a))).map(a=>`ordering_cycle_created:${ne(o.successors,a,o.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)]}export{T as a,V as b,me as c};
8
- //# sourceMappingURL=chunk-S27XMBIN.js.map
8
+ //# sourceMappingURL=chunk-7N2TV7WZ.js.map
@@ -1,3 +1,3 @@
1
- import{$ as p,Kb as B,O as V,P as W,Q as K,R as G,aa as _,ja as J,ma as H,na as Y,q as C,r as v,s as $,t as P,u as q}from"./chunk-4RRHC3S4.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]="ce320988-b999-57c9-a786-a94ac66c5628")}catch{}})();var F=new Set(W),D=Object.freeze({get size(){return F.size},has(e){return F.has(e)},entries(){return F.entries()},keys(){return F.keys()},values(){return F.values()},forEach(e,t){F.forEach(n=>e.call(t,n,n,D))},[Symbol.iterator](){return F.values()}});function X(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Z(e){return typeof e!="string"?null:V(e)}function de(e){try{return structuredClone(e)}catch{return e}}function ue(e){let t=e.trim(),n=t.indexOf("=");if(n<=0)throw new _(`--field entries must use name=value syntax, received: ${e}`,p.USAGE);let r=t.slice(0,n).trim(),s=t.slice(n+1);return{key:r,value:s}}function fe(e){return`--${e.replaceAll("_","-")}`}function ce(e,t,n){try{let r=JSON.parse(e);if(n==="array"&&Array.isArray(r)||n==="object"&&typeof r=="object"&&r!==null&&!Array.isArray(r))return r}catch{}throw new _(`--field ${t}=... must be valid JSON ${n}`,p.USAGE)}function me(e,t,n){if(t==="string")return n;if(t==="number"){let r=n.trim();if(r.length===0)throw new _(`--field ${e}=... must be a number`,p.USAGE);let s=Number(r);if(!Number.isFinite(s))throw new _(`--field ${e}=... must be a number`,p.USAGE);return s}if(t==="boolean"){let r=n.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1;throw new _(`--field ${e}=... must be one of true|false|1|0|yes|no`,p.USAGE)}return t==="string_array"?n.split(/[\n,|]/u).map(r=>r.trim()).filter(r=>r.length>0):ce(n,e,t)}function M(e){let t=new Map;if(!e)return t;for(let n of e.item_fields)for(let r of n.fields){let s=X(r.name),i=Z(r.type);if(!s||!i)continue;let l=t.get(s);if(l&&l.type!==i)throw new _(`Extension item field "${s}" is declared with conflicting types: ${l.type}, ${i}`,p.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(s,{name:s,type:i})}return t}function Q(e){if(D.has(e))throw new _(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...D].sort((t,n)=>t.localeCompare(n)).join(", ")}.`,p.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function Ze(e){return[...M(e).keys()].sort((t,n)=>t.localeCompare(n))}function Qe(e,t){if(!e||e.length===0)return{};let n=M(t),r={};for(let s of e){let{key:i,value:l}=ue(s),a=n.get(i);if(!a){if(D.has(i)){let d=fe(i);throw new _(`--field ${i} is a core item field, not an extension field`,p.USAGE,{code:"core_item_field_requires_dedicated_flag",field:i,recovery:{provided_fields:[i],suggested_flags:[d]},nextSteps:[`Set the core field with its dedicated flag: pm update <id> ${d} <value>`,`When closing an item, pm close <id> also accepts ${d} <value>.`]})}let o=[...n.keys()].sort((d,f)=>d.localeCompare(f));throw new _(`--field ${i} is not declared by an active extension item-field registration`,p.USAGE,{code:"extension_item_field_unknown",recovery:{provided_fields:o},nextSteps:o.length>0?[`Use one of the declared fields: ${o.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}Q(a.name),r[a.name]=me(a.name,a.type,l)}return r}function pe(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(n=>typeof n=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function _e(e,t){return!t||t.length===0?!0:t.some(n=>Object.is(n,e))}function et(e,t,n={}){if(t){M(t);for(let r of t.item_fields)for(let s of r.fields){let i=X(s.name);if(!i)continue;Q(i),!(i in e)&&!n.skipDefaultFields?.has(i)&&Object.prototype.hasOwnProperty.call(s,"default")&&(e[i]=de(s.default));let l=e[i];if(l===void 0)continue;let a=Z(s.type);if(a&&!pe(l,a))throw new TypeError(`Item field "${i}" must be of type ${a}`);let o=Array.isArray(s.values)?s.values:void 0;if(!_e(l,o))throw new TypeError(`Item field "${i}" must match one of the configured allowed values`)}}}(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]="d6056922-237d-525a-b354-687493a4e123")}catch{}})();var ye=2e3,R=new Map;function A(e){if(typeof e!="string")return"";let t=R.get(e);if(t!==void 0)return t;let n=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return R.size>=ye&&B(R),R.set(e,n),n}import ee 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]="633ef301-42a3-5b73-a4ed-7af0e0e40371")}catch{}})();var y=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),re=G,L=K,we=["create","update"],he=new Set(v),Se=new Set($),ge=new Set(P),Ae=new Set(q),be=new Set(["string","number","boolean","array","object"]),Ee=16;function se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ke=[e=>e.type===void 0||typeof e.type=="string"&&be.has(e.type),e=>!Object.hasOwn(e,"const")||O(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>O(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||se(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function O(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);let n=Array.isArray(e)?e.every(r=>O(r,t)):Object.values(e).every(r=>O(r,t));return t.delete(e),n}function N(e,t=0,n=new Set){if(!se(e)||t>Ee||n.has(e))return;n.add(e);let r=e,s=r.type,i=r.enum,l=r.one_of,a=r.properties,o=r.items,d=r.required,f=r.min_length,u=r.min_items,w=r.format,S=r.additional_properties;if(!ke.every(m=>m(r))){n.delete(e);return}let b=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([m,U])=>[m,N(U,t+1,n)])),E=o===void 0?void 0:N(o,t+1,n),k=l===void 0?void 0:l.map(m=>N(m,t+1,n));if([...Object.values(b??{}),...o===void 0?[]:[E],...k??[]].some(m=>m===void 0)){n.delete(e);return}return n.delete(e),Object.fromEntries(Object.entries({type:s,const:Object.hasOwn(r,"const")?r.const:void 0,enum:i,min_length:f,min_items:u,format:w,properties:b,required:d===void 0?void 0:[...new Set(d)],additional_properties:S,items:E,one_of:k}).filter(([,m])=>m!==void 0))}function I(e){let t=Array.isArray(e)?e:[];return[...new Set(t.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function c(e){if(typeof e!="string"||e.length===0)return;let t=A(e);return t.length>0?t:void 0}function Fe(e){return e.startsWith("--")?e.slice(2):e}function te(e){return typeof e=="string"?Fe(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function ie(e){return e.replaceAll("_","-")}function Te(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(s=>s.length>0).map(s=>s.toLowerCase());if(t.length===0)return e;let[n,...r]=t;return`${n}${r.map(s=>`${s.slice(0,1).toUpperCase()}${s.slice(1)}`).join("")}`}function x(e,t){let n=c(e.id);if(!n)return null;let r=[...new Set(I(e.aliases).map(A).filter(a=>a.length>0))].sort((a,o)=>a.localeCompare(o)),s=I(e.roles).filter(a=>he.has(a)),i=e.description?.trim(),l=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:n,aliases:r,roles:s,description:i&&i.length>0?i:void 0,order:l}}function Ie(e){return{draft_status:c(e?.draft_status),open_status:c(e?.open_status),in_progress_status:c(e?.in_progress_status),blocked_status:c(e?.blocked_status),close_status:c(e?.close_status),canceled_status:c(e?.canceled_status)}}function oe(e,t){if(!Array.isArray(t)||t.length!==2)return;let n=A(t[0]),r=A(t[1]);n.length===0||r.length===0||e.pairs.some(s=>s[0]===n&&s[1]===r)||e.pairs.push([n,r])}function ze(e){let t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;let n={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(let r of e.allowed_transitions)oe(n,r);return{typeKey:t.toLowerCase(),record:n}}function De(e){if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let r of e){let s=ze(r);if(s===null)continue;let i=t.get(s.typeKey)??s.record;i.denyAll||=s.record.denyAll;for(let l of s.record.pairs)oe(i,l);t.set(s.typeKey,i)}let n=[];for(let r of t.values())(r.pairs.length>0||r.denyAll)&&n.push({type:r.type,allowed_transitions:r.pairs});return n.sort((r,s)=>r.type.localeCompare(s.type)),n.length>0?n:void 0}function ae(e){let t=A(e.key??"");if(!t)return null;let n=A(e.metadata_key??e.front_matter_key??t),r=te(e.cli_flag??ie(t));if(!r)return null;let s=I(e.cli_aliases).map(u=>te(u)).filter(u=>u.length>0&&u!==r),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",l=Se.has(i)?i:"string",a=(()=>{let u=I(e.commands).filter(w=>ge.has(w));return u.length>0?u:[...we]})(),o=e.description?.trim(),d=I(e.required_types),f=e.value_schema===void 0?void 0:N(e.value_schema);return e.value_schema!==void 0&&f===void 0?null:{key:t,metadata_key:n,cli_flag:r,cli_aliases:s,description:o&&o.length>0?o:void 0,type:l,commands:a,repeatable:[e.repeatable===!0,l==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:d,allow_unset:e.allow_unset!==!1,value_schema:f}}function Re(e){let t=new Map;for(let[r,s]of e.entries()){let i=x(s,r);i&&t.set(i.id,i)}let n=ne([...t.values()]);return n.length>0?n:ne(L.map((r,s)=>x(r,s)).filter(r=>r!==null))}function ne(e){return e.sort((t,n)=>t.order===n.order?t.id.localeCompare(n.id):t.order-n.order)}function Ne(e){let t=new Map;for(let n of e??[]){let r=ae(n);r&&t.set(r.key,r)}return[...t.values()].sort((n,r)=>n.key.localeCompare(r.key))}function Oe(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function Ue(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==ie(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function Me(e){let t=typeof e=="string"?e.trim().toLowerCase():"allow";return Ae.has(t)?t:"allow"}function z(e){let t={...y,...e?.files},n=e?.statuses&&e.statuses.length>0?e.statuses:L,r=Re(n),s=Ne(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:r.map(Oe),fields:s.map(Ue),workflow:{...re,...Ie(e?.workflow)},type_workflows:De(e?.type_workflows),unknown_field_policy:Me(e?.unknown_field_policy)}}function xe(e){return`${JSON.stringify(e,null,2)}
1
+ import{$ as p,Kb as B,O as V,P as W,Q as K,R as G,aa as _,ja as J,ma as H,na as Y,q as C,r as v,s as $,t as P,u as q}from"./chunk-JADHHPY6.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]="ce320988-b999-57c9-a786-a94ac66c5628")}catch{}})();var F=new Set(W),D=Object.freeze({get size(){return F.size},has(e){return F.has(e)},entries(){return F.entries()},keys(){return F.keys()},values(){return F.values()},forEach(e,t){F.forEach(n=>e.call(t,n,n,D))},[Symbol.iterator](){return F.values()}});function X(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Z(e){return typeof e!="string"?null:V(e)}function de(e){try{return structuredClone(e)}catch{return e}}function ue(e){let t=e.trim(),n=t.indexOf("=");if(n<=0)throw new _(`--field entries must use name=value syntax, received: ${e}`,p.USAGE);let r=t.slice(0,n).trim(),s=t.slice(n+1);return{key:r,value:s}}function fe(e){return`--${e.replaceAll("_","-")}`}function ce(e,t,n){try{let r=JSON.parse(e);if(n==="array"&&Array.isArray(r)||n==="object"&&typeof r=="object"&&r!==null&&!Array.isArray(r))return r}catch{}throw new _(`--field ${t}=... must be valid JSON ${n}`,p.USAGE)}function me(e,t,n){if(t==="string")return n;if(t==="number"){let r=n.trim();if(r.length===0)throw new _(`--field ${e}=... must be a number`,p.USAGE);let s=Number(r);if(!Number.isFinite(s))throw new _(`--field ${e}=... must be a number`,p.USAGE);return s}if(t==="boolean"){let r=n.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1;throw new _(`--field ${e}=... must be one of true|false|1|0|yes|no`,p.USAGE)}return t==="string_array"?n.split(/[\n,|]/u).map(r=>r.trim()).filter(r=>r.length>0):ce(n,e,t)}function M(e){let t=new Map;if(!e)return t;for(let n of e.item_fields)for(let r of n.fields){let s=X(r.name),i=Z(r.type);if(!s||!i)continue;let l=t.get(s);if(l&&l.type!==i)throw new _(`Extension item field "${s}" is declared with conflicting types: ${l.type}, ${i}`,p.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(s,{name:s,type:i})}return t}function Q(e){if(D.has(e))throw new _(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...D].sort((t,n)=>t.localeCompare(n)).join(", ")}.`,p.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function Ze(e){return[...M(e).keys()].sort((t,n)=>t.localeCompare(n))}function Qe(e,t){if(!e||e.length===0)return{};let n=M(t),r={};for(let s of e){let{key:i,value:l}=ue(s),a=n.get(i);if(!a){if(D.has(i)){let d=fe(i);throw new _(`--field ${i} is a core item field, not an extension field`,p.USAGE,{code:"core_item_field_requires_dedicated_flag",field:i,recovery:{provided_fields:[i],suggested_flags:[d]},nextSteps:[`Set the core field with its dedicated flag: pm update <id> ${d} <value>`,`When closing an item, pm close <id> also accepts ${d} <value>.`]})}let o=[...n.keys()].sort((d,f)=>d.localeCompare(f));throw new _(`--field ${i} is not declared by an active extension item-field registration`,p.USAGE,{code:"extension_item_field_unknown",recovery:{provided_fields:o},nextSteps:o.length>0?[`Use one of the declared fields: ${o.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}Q(a.name),r[a.name]=me(a.name,a.type,l)}return r}function pe(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(n=>typeof n=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function _e(e,t){return!t||t.length===0?!0:t.some(n=>Object.is(n,e))}function et(e,t,n={}){if(t){M(t);for(let r of t.item_fields)for(let s of r.fields){let i=X(s.name);if(!i)continue;Q(i),!(i in e)&&!n.skipDefaultFields?.has(i)&&Object.prototype.hasOwnProperty.call(s,"default")&&(e[i]=de(s.default));let l=e[i];if(l===void 0)continue;let a=Z(s.type);if(a&&!pe(l,a))throw new TypeError(`Item field "${i}" must be of type ${a}`);let o=Array.isArray(s.values)?s.values:void 0;if(!_e(l,o))throw new TypeError(`Item field "${i}" must match one of the configured allowed values`)}}}(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]="d6056922-237d-525a-b354-687493a4e123")}catch{}})();var ye=2e3,R=new Map;function A(e){if(typeof e!="string")return"";let t=R.get(e);if(t!==void 0)return t;let n=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return R.size>=ye&&B(R),R.set(e,n),n}import ee 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]="633ef301-42a3-5b73-a4ed-7af0e0e40371")}catch{}})();var y=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),re=G,L=K,we=["create","update"],he=new Set(v),Se=new Set($),ge=new Set(P),Ae=new Set(q),be=new Set(["string","number","boolean","array","object"]),Ee=16;function se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ke=[e=>e.type===void 0||typeof e.type=="string"&&be.has(e.type),e=>!Object.hasOwn(e,"const")||O(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>O(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||se(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function O(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);let n=Array.isArray(e)?e.every(r=>O(r,t)):Object.values(e).every(r=>O(r,t));return t.delete(e),n}function N(e,t=0,n=new Set){if(!se(e)||t>Ee||n.has(e))return;n.add(e);let r=e,s=r.type,i=r.enum,l=r.one_of,a=r.properties,o=r.items,d=r.required,f=r.min_length,u=r.min_items,w=r.format,S=r.additional_properties;if(!ke.every(m=>m(r))){n.delete(e);return}let b=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([m,U])=>[m,N(U,t+1,n)])),E=o===void 0?void 0:N(o,t+1,n),k=l===void 0?void 0:l.map(m=>N(m,t+1,n));if([...Object.values(b??{}),...o===void 0?[]:[E],...k??[]].some(m=>m===void 0)){n.delete(e);return}return n.delete(e),Object.fromEntries(Object.entries({type:s,const:Object.hasOwn(r,"const")?r.const:void 0,enum:i,min_length:f,min_items:u,format:w,properties:b,required:d===void 0?void 0:[...new Set(d)],additional_properties:S,items:E,one_of:k}).filter(([,m])=>m!==void 0))}function I(e){let t=Array.isArray(e)?e:[];return[...new Set(t.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function c(e){if(typeof e!="string"||e.length===0)return;let t=A(e);return t.length>0?t:void 0}function Fe(e){return e.startsWith("--")?e.slice(2):e}function te(e){return typeof e=="string"?Fe(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function ie(e){return e.replaceAll("_","-")}function Te(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(s=>s.length>0).map(s=>s.toLowerCase());if(t.length===0)return e;let[n,...r]=t;return`${n}${r.map(s=>`${s.slice(0,1).toUpperCase()}${s.slice(1)}`).join("")}`}function x(e,t){let n=c(e.id);if(!n)return null;let r=[...new Set(I(e.aliases).map(A).filter(a=>a.length>0))].sort((a,o)=>a.localeCompare(o)),s=I(e.roles).filter(a=>he.has(a)),i=e.description?.trim(),l=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:n,aliases:r,roles:s,description:i&&i.length>0?i:void 0,order:l}}function Ie(e){return{draft_status:c(e?.draft_status),open_status:c(e?.open_status),in_progress_status:c(e?.in_progress_status),blocked_status:c(e?.blocked_status),close_status:c(e?.close_status),canceled_status:c(e?.canceled_status)}}function oe(e,t){if(!Array.isArray(t)||t.length!==2)return;let n=A(t[0]),r=A(t[1]);n.length===0||r.length===0||e.pairs.some(s=>s[0]===n&&s[1]===r)||e.pairs.push([n,r])}function ze(e){let t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;let n={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(let r of e.allowed_transitions)oe(n,r);return{typeKey:t.toLowerCase(),record:n}}function De(e){if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let r of e){let s=ze(r);if(s===null)continue;let i=t.get(s.typeKey)??s.record;i.denyAll||=s.record.denyAll;for(let l of s.record.pairs)oe(i,l);t.set(s.typeKey,i)}let n=[];for(let r of t.values())(r.pairs.length>0||r.denyAll)&&n.push({type:r.type,allowed_transitions:r.pairs});return n.sort((r,s)=>r.type.localeCompare(s.type)),n.length>0?n:void 0}function ae(e){let t=A(e.key??"");if(!t)return null;let n=A(e.metadata_key??e.front_matter_key??t),r=te(e.cli_flag??ie(t));if(!r)return null;let s=I(e.cli_aliases).map(u=>te(u)).filter(u=>u.length>0&&u!==r),i=typeof e.type=="string"?e.type.trim().toLowerCase():"string",l=Se.has(i)?i:"string",a=(()=>{let u=I(e.commands).filter(w=>ge.has(w));return u.length>0?u:[...we]})(),o=e.description?.trim(),d=I(e.required_types),f=e.value_schema===void 0?void 0:N(e.value_schema);return e.value_schema!==void 0&&f===void 0?null:{key:t,metadata_key:n,cli_flag:r,cli_aliases:s,description:o&&o.length>0?o:void 0,type:l,commands:a,repeatable:[e.repeatable===!0,l==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:d,allow_unset:e.allow_unset!==!1,value_schema:f}}function Re(e){let t=new Map;for(let[r,s]of e.entries()){let i=x(s,r);i&&t.set(i.id,i)}let n=ne([...t.values()]);return n.length>0?n:ne(L.map((r,s)=>x(r,s)).filter(r=>r!==null))}function ne(e){return e.sort((t,n)=>t.order===n.order?t.id.localeCompare(n.id):t.order-n.order)}function Ne(e){let t=new Map;for(let n of e??[]){let r=ae(n);r&&t.set(r.key,r)}return[...t.values()].sort((n,r)=>n.key.localeCompare(r.key))}function Oe(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function Ue(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==ie(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function Me(e){let t=typeof e=="string"?e.trim().toLowerCase():"allow";return Ae.has(t)?t:"allow"}function z(e){let t={...y,...e?.files},n=e?.statuses&&e.statuses.length>0?e.statuses:L,r=Re(n),s=Ne(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:r.map(Oe),fields:s.map(Ue),workflow:{...re,...Ie(e?.workflow)},type_workflows:De(e?.type_workflows),unknown_field_policy:Me(e?.unknown_field_policy)}}function xe(e){return`${JSON.stringify(e,null,2)}
2
2
  `}function Le(){return{definitions:[]}}function je(){return{statuses:L}}function Ce(){return{fields:[]}}function ve(){return{workflow:re}}function $e(e,t,n){try{return JSON.parse(e)}catch{n.push(t);return}}function Pe(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let n=t.item_types;if(Array.isArray(n.definitions))return n.definitions}}function qe(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function Ve(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function We(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;return typeof t.workflow=="object"&&t.workflow!==null&&!Array.isArray(t.workflow)?t.workflow:typeof t.workflows=="object"&&t.workflows!==null&&!Array.isArray(t.workflows)?t.workflows:t}function Ke(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e;if(Array.isArray(t.type_workflows))return t.type_workflows}function h(e,t,n){let r=t?.trim()||n;return ee.isAbsolute(r)?r:ee.join(e,r)}function dt(e,t){return h(e,t.files.types,y.types)}async function ut(e,t){let n=z(t),r=[{path:h(e,n.files.types,y.types),seed:Le()},{path:h(e,n.files.statuses,y.statuses),seed:je()},{path:h(e,n.files.fields,y.fields),seed:Ce()},{path:h(e,n.files.workflows,y.workflows),seed:ve()}],s=[];for(let i of r)await J(i.path)||(await Y(i.path,xe(i.seed)),s.push(i.path));return{created_paths:s}}async function ft(e,t){let n=z(t),r=[],s=h(e,n.files.types,y.types),i=h(e,n.files.statuses,y.statuses),l=h(e,n.files.fields,y.fields),a=h(e,n.files.workflows,y.workflows),o,d,f,u,w,S=async(U,le)=>{let j=await H(U);if(j!==null)return $e(j,le,r)},b=await S(s,"runtime_schema_types_invalid_json");b!==void 0&&(o=Pe(b),o===void 0&&r.push("runtime_schema_types_invalid_shape"));let E=await S(i,"runtime_schema_statuses_invalid_json");E!==void 0&&(d=qe(E),d===void 0&&r.push("runtime_schema_statuses_invalid_shape"));let k=await S(l,"runtime_schema_fields_invalid_json");k!==void 0&&(f=Ve(k),f===void 0&&r.push("runtime_schema_fields_invalid_shape"));let g=await S(a,"runtime_schema_workflows_invalid_json");return g!==void 0&&(u=We(g),u===void 0&&r.push("runtime_schema_workflows_invalid_shape"),w=Ke(g)),{schema:z({...n,statuses:[...n.statuses,...d??[]],fields:[...n.fields,...f??[]],workflow:{...n.workflow,...u},type_workflows:[...n.type_workflows??[],...w??[]]}),type_definitions_from_file:o,warnings:r,created_paths:[]}}function T(e,t,n,r=!1){let i=n.map(a=>c(a)).filter(a=>typeof a=="string").find(a=>e.some(o=>o.id===a));if(r&&i!==void 0)return i;let l=e.find(a=>a.roles.includes(t));return l!==void 0?l.id:i??e[0]?.id}function Ge(e){let t=new Map,n=new Map;for(let r of e){n.set(r.id,r),t.set(r.id,r.id),t.set(r.id.replaceAll("_","-"),r.id),t.set(r.id.replaceAll("_"," "),r.id);for(let s of r.aliases)t.set(s,r.id),t.set(s.replaceAll("_","-"),r.id),t.set(s.replaceAll("_"," "),r.id)}return{aliasToId:t,byId:n}}function Je(e){let t={activeStatuses:new Set,blockedStatuses:new Set,draftStatuses:new Set,terminalCanceledStatuses:new Set,terminalDoneStatuses:new Set,terminalStatuses:new Set};for(let n of e){let r=new Set(n.roles);(r.has("terminal")||r.has("terminal_done")||r.has("terminal_canceled"))&&t.terminalStatuses.add(n.id),r.has("terminal_done")&&t.terminalDoneStatuses.add(n.id),r.has("terminal_canceled")&&t.terminalCanceledStatuses.add(n.id),r.has("active")&&t.activeStatuses.add(n.id),r.has("blocked")&&t.blockedStatuses.add(n.id),r.has("draft")&&t.draftStatuses.add(n.id)}return t}function ct(e){let t=z(e),n=t.statuses.map((g,m)=>x(g,m)).filter(g=>g!==null),{aliasToId:r,byId:s}=Ge(n),{activeStatuses:i,blockedStatuses:l,draftStatuses:a,terminalCanceledStatuses:o,terminalDoneStatuses:d,terminalStatuses:f}=Je(n),u=t.workflow,w=c(u.open_status)??T(n,"default_open",["open","in_progress",C[0]]),S=c(u.in_progress_status)??T(n,"active",["in_progress","in-progress",w],!0),b=c(u.blocked_status)??T(n,"blocked",["blocked"]),E=c(u.close_status)??T(n,"default_close",["closed","done","complete"]),k=c(u.canceled_status)??T(n,"default_cancel",["canceled","cancelled"]);return{definitions:n,by_id:s,alias_to_id:r,terminal_statuses:f,terminal_done_statuses:d,terminal_canceled_statuses:o,active_statuses:i,blocked_statuses:l,draft_statuses:a,open_status:w,in_progress_status:S,blocked_status:b,close_status:E,canceled_status:k}}function He(e,t){let n=A(e);if(n)return t.alias_to_id.get(n)}function mt(e){let t=z(e),n=new Map,r=t.fields.map(o=>ae(o)).filter(o=>o!==null);for(let o of r)n.set(o.key,o);let s=[...n.values()].sort((o,d)=>o.key.localeCompare(d.key)),i=new Map,l=new Map,a=new Map;for(let o of s){i.set(o.key,o),l.set(o.cli_flag,o);for(let d of o.cli_aliases)l.set(d,o);for(let d of o.commands){let f=a.get(d)??[];f.push(o),a.set(d,f)}}for(let[o,d]of a.entries())d.sort((f,u)=>f.key.localeCompare(u.key)),a.set(o,d);return{definitions:s,by_key:i,by_cli_token:l,command_to_fields:a}}function pt(e){return Te(e.key)}function _t(e,t){let n=He(e,t);return n?t.terminal_statuses.has(n):!1}export{D as a,Ze as b,Qe as c,et as d,A as e,y as f,L as g,z as h,h as i,dt as j,ut as k,ft as l,ct as m,He as n,mt as o,pt as p,_t as q};
3
- //# sourceMappingURL=chunk-5RFXUPN5.js.map
3
+ //# sourceMappingURL=chunk-AJR3OP2E.js.map
@@ -1,2 +1,2 @@
1
- import{P as I,Q as b,kb as k,lb as m}from"./chunk-3ZBI35HU.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0605f770-d868-5fe9-a186-45f00d2e93b4")}catch{}})();var h="blocked_by",E="blocks",A=Object.freeze([h,E]),_="no-active-blocker";function l(e){return e.trim().toLowerCase()}function y(e,n){return n?`external:${e}`:`local:${l(e)}`}function p(e){let n=new Map,t=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(t.length>0&&l(t)!==_){let o=k(t);n.set(y(t,o),o?t:l(t))}for(let o of e.dependencies??[]){let c=typeof o.id=="string"?o.id.trim():"";if(o.kind===h&&c.length>0&&l(c)!==_){let s=k(c)||m(o.source_kind);n.set(y(c,s),s?c:l(c))}}return[...n.values()].sort((o,c)=>o.localeCompare(c))}function B(e){let n=new Map;for(let t of e){let o=l(t.id);o.length!==0&&n.set(o,new Set(p(t)))}for(let t of e){let o=l(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=c.kind===E&&typeof c.id=="string"?l(c.id):"";if(s.length===0||s===_)continue;let d=n.get(s)??new Set;d.add(o),n.set(s,d)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function C(e,n){let t=l(e.id);return t.length>0?B(n).get(t)??p(e):p(e)}function g(e,n,t,o){let c=e,s=typeof c.id=="string"?o?.get(l(c.id))??C(c,[...n.values()]):p(e),d=new Set((e.dependencies??[]).filter(r=>r.kind===h&&m(r.source_kind)&&typeof r.id=="string"&&r.id.trim().length>0).map(r=>y(r.id.trim(),!0)));return s.map(r=>{if(k(r)||d.has(y(r,!0)))return{id:r,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let i=n.get(l(r));return i?{id:r,title:i.title,status:i.status,resolved:b(i.status,t)}:{id:r,title:null,status:null,resolved:!1}})}function L(e,n,t){return g(e,n,t)}function M(e,n){let t=new Map(e.map(d=>[l(d.id),d])),o=B(e),c=new Set([...N(n),...n.blocked_statuses]),s=new Set;for(let d of e){let r=I(d.status,n);if(!c.has(r))continue;(n.blocked_statuses.has(r)||g(d,t,n,o).some(f=>!f.resolved))&&s.add(l(d.id))}return s}function N(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function z(e,n,t){let o=[l(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let d of n.get(s)??[]){if(!b(d.status,t))return!0;o.push(l(d.id))}}}return!1}function Y(e){let n=new Map,t=new Map,o=new Map,c=B(e);for(let s of e){n.set(l(s.id),s);let d=typeof s.parent=="string"?s.parent.trim():"";if(d.length>0){let r=l(d),i=t.get(r)??[];i.push(s),t.set(r,i)}for(let r of c.get(l(s.id))){let i=l(r),f=o.get(i)??[];f.push(s.id),o.set(i,f)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function P(e,n,t){let{itemsById:o,childrenByParent:c,blockedByReverse:s,blockerIdsByItem:d}=Y(n),r=new Set([...N(t),...t.blocked_statuses]),i=new Set(n.filter(a=>!b(a.status,t)).map(a=>l(a.id))),f=[],w=[],v=0,D=0;for(let a of e){if(!r.has(I(a.status,t)))continue;if(v+=1,z(a.id,c,t)){D+=1;continue}let S=g(a,o,t,d).filter(u=>!u.resolved),T=(s.get(l(a.id))??[]).filter(u=>i.has(l(u))).sort((u,O)=>u.localeCompare(O)),x={item:a,open_blockers:S,unblocks:T},K=t.blocked_statuses.has(I(a.status,t));S.length===0&&!K?f.push(x):w.push(x)}return{ready:f,blocked:w,active_count:v,container_count:D}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cc271a73-9767-54bb-a142-d4d4569e3c6a")}catch{}})();export{A as a,p as b,B as c,C as d,L as e,M as f,P as g};
2
- //# sourceMappingURL=chunk-KZ2NB3ET.js.map
1
+ import{P as I,Q as b,pb as k,qb as m}from"./chunk-5P4HVOWG.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0605f770-d868-5fe9-a186-45f00d2e93b4")}catch{}})();var h="blocked_by",E="blocks",A=Object.freeze([h,E]),_="no-active-blocker";function l(e){return e.trim().toLowerCase()}function y(e,n){return n?`external:${e}`:`local:${l(e)}`}function p(e){let n=new Map,t=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(t.length>0&&l(t)!==_){let o=k(t);n.set(y(t,o),o?t:l(t))}for(let o of e.dependencies??[]){let c=typeof o.id=="string"?o.id.trim():"";if(o.kind===h&&c.length>0&&l(c)!==_){let s=k(c)||m(o.source_kind);n.set(y(c,s),s?c:l(c))}}return[...n.values()].sort((o,c)=>o.localeCompare(c))}function B(e){let n=new Map;for(let t of e){let o=l(t.id);o.length!==0&&n.set(o,new Set(p(t)))}for(let t of e){let o=l(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=c.kind===E&&typeof c.id=="string"?l(c.id):"";if(s.length===0||s===_)continue;let d=n.get(s)??new Set;d.add(o),n.set(s,d)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function C(e,n){let t=l(e.id);return t.length>0?B(n).get(t)??p(e):p(e)}function g(e,n,t,o){let c=e,s=typeof c.id=="string"?o?.get(l(c.id))??C(c,[...n.values()]):p(e),d=new Set((e.dependencies??[]).filter(r=>r.kind===h&&m(r.source_kind)&&typeof r.id=="string"&&r.id.trim().length>0).map(r=>y(r.id.trim(),!0)));return s.map(r=>{if(k(r)||d.has(y(r,!0)))return{id:r,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let i=n.get(l(r));return i?{id:r,title:i.title,status:i.status,resolved:b(i.status,t)}:{id:r,title:null,status:null,resolved:!1}})}function L(e,n,t){return g(e,n,t)}function M(e,n){let t=new Map(e.map(d=>[l(d.id),d])),o=B(e),c=new Set([...N(n),...n.blocked_statuses]),s=new Set;for(let d of e){let r=I(d.status,n);if(!c.has(r))continue;(n.blocked_statuses.has(r)||g(d,t,n,o).some(f=>!f.resolved))&&s.add(l(d.id))}return s}function N(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function z(e,n,t){let o=[l(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let d of n.get(s)??[]){if(!b(d.status,t))return!0;o.push(l(d.id))}}}return!1}function Y(e){let n=new Map,t=new Map,o=new Map,c=B(e);for(let s of e){n.set(l(s.id),s);let d=typeof s.parent=="string"?s.parent.trim():"";if(d.length>0){let r=l(d),i=t.get(r)??[];i.push(s),t.set(r,i)}for(let r of c.get(l(s.id))){let i=l(r),f=o.get(i)??[];f.push(s.id),o.set(i,f)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function P(e,n,t){let{itemsById:o,childrenByParent:c,blockedByReverse:s,blockerIdsByItem:d}=Y(n),r=new Set([...N(t),...t.blocked_statuses]),i=new Set(n.filter(a=>!b(a.status,t)).map(a=>l(a.id))),f=[],w=[],v=0,D=0;for(let a of e){if(!r.has(I(a.status,t)))continue;if(v+=1,z(a.id,c,t)){D+=1;continue}let S=g(a,o,t,d).filter(u=>!u.resolved),T=(s.get(l(a.id))??[]).filter(u=>i.has(l(u))).sort((u,O)=>u.localeCompare(O)),x={item:a,open_blockers:S,unblocks:T},K=t.blocked_statuses.has(I(a.status,t));S.length===0&&!K?f.push(x):w.push(x)}return{ready:f,blocked:w,active_count:v,container_count:D}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cc271a73-9767-54bb-a142-d4d4569e3c6a")}catch{}})();export{A as a,p as b,B as c,C as d,L as e,M as f,P as g};
2
+ //# sourceMappingURL=chunk-B3A6MJYE.js.map