@unbrained/pm-cli 2026.8.28 → 2026.8.29

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 (98) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +24 -0
  3. package/dist/cli-bundle/bundle-manifest.json +125 -125
  4. package/dist/cli-bundle/chunks/{chunk-E73FDIWT.js → chunk-2MKLQL2E.js} +2 -2
  5. package/dist/cli-bundle/chunks/{chunk-NTXZHRKA.js → chunk-2UETTHY6.js} +46 -46
  6. package/dist/cli-bundle/chunks/{chunk-FEVBFFCQ.js → chunk-3TEF3HM5.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-BY2FQ2NI.js → chunk-7SKMLSMX.js} +2 -2
  8. package/dist/cli-bundle/chunks/chunk-7X6OZEIV.js +34 -0
  9. package/dist/cli-bundle/chunks/{chunk-M7OXRQE3.js → chunk-CMIEDWAY.js} +50 -50
  10. package/dist/cli-bundle/chunks/{chunk-XWEQGHHG.js → chunk-GNWPTEBW.js} +64 -61
  11. package/dist/cli-bundle/chunks/{chunk-X2RROGZE.js → chunk-MTTKAUBX.js} +2 -2
  12. package/dist/cli-bundle/chunks/chunk-N6OR6FAR.js +13 -0
  13. package/dist/cli-bundle/chunks/{chunk-NBCBFVZI.js → chunk-TGNAA66W.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-QE6WQXFO.js → chunk-WS2GJQVG.js} +2 -2
  15. package/dist/cli-bundle/chunks/{register-list-query-J35ZPQQ5.js → register-list-query-OMKJ5ONN.js} +2 -2
  16. package/dist/cli-bundle/chunks/{register-mutation-J6XJJOGU.js → register-mutation-QBSNCOY3.js} +2 -2
  17. package/dist/cli-bundle/chunks/{register-operations-AE3JEMFT.js → register-operations-UC77FQZC.js} +2 -2
  18. package/dist/cli-bundle/chunks/{register-setup-OQERLLWE.js → register-setup-GLQ5SYV3.js} +2 -2
  19. package/dist/cli-bundle/focused-chunks/{chunk-HC7ODMH3.js → chunk-3AVAWVZA.js} +2 -2
  20. package/dist/cli-bundle/focused-chunks/chunk-3UMBF26I.js +158 -0
  21. package/dist/cli-bundle/focused-chunks/{chunk-YVVZ3LQ6.js → chunk-73EDXGYE.js} +16 -15
  22. package/dist/cli-bundle/focused-chunks/chunk-AXZ5AJAF.js +50 -0
  23. package/dist/cli-bundle/focused-chunks/{chunk-AHAM2HAU.js → chunk-G6PATS5E.js} +3 -3
  24. package/dist/cli-bundle/focused-chunks/chunk-RKOKG43G.js +2 -0
  25. package/dist/cli-bundle/focused-chunks/chunk-TDK3OCX3.js +2 -0
  26. package/dist/cli-bundle/focused-chunks/{chunk-FC2AXLB5.js → chunk-XXOWRJZ5.js} +2 -2
  27. package/dist/cli-bundle/main.js +2 -2
  28. package/dist/cli-bundle/sdk-contracts.js +1 -1
  29. package/dist/cli-bundle/sdk-core.js +31 -32
  30. package/dist/cli-bundle/sdk-governance.js +1 -1
  31. package/dist/cli-bundle/sdk-graph.js +1 -1
  32. package/dist/cli-bundle/sdk-merge.js +34 -32
  33. package/dist/cli-bundle/sdk-query.js +1 -1
  34. package/dist/cli-bundle/sdk-runtime.js +1 -1
  35. package/dist/cli-bundle/sdk-testing.js +1 -1
  36. package/dist/cli-bundle/sdk.js +8 -8
  37. package/dist/core/diagnostics/remediation.js +16 -6
  38. package/dist/core/history/drift-scan.d.ts +2 -0
  39. package/dist/core/history/drift-scan.js +72 -36
  40. package/dist/core/history/history.d.ts +3 -3
  41. package/dist/core/history/history.js +5 -5
  42. package/dist/core/history/replay.d.ts +1 -1
  43. package/dist/core/history/replay.js +50 -19
  44. package/dist/core/item/actionability.d.ts +7 -1
  45. package/dist/core/item/actionability.js +44 -11
  46. package/dist/core/item/dependency-reference.d.ts +10 -0
  47. package/dist/core/item/dependency-reference.js +21 -0
  48. package/dist/core/item/parse.d.ts +4 -0
  49. package/dist/core/item/parse.js +38 -16
  50. package/dist/core/shared/author.js +69 -17
  51. package/dist/sdk/dependency-provenance.d.ts +51 -2
  52. package/dist/sdk/dependency-provenance.js +91 -7
  53. package/dist/sdk/extension/install-sources.d.ts +1 -7
  54. package/dist/sdk/extension/install-sources.js +94 -33
  55. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +50 -14
  56. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +62 -26
  57. package/dist/sdk/governance/health.js +86 -22
  58. package/dist/sdk/governance/validate-history-drift.js +5 -2
  59. package/dist/sdk/graph/assembly.js +51 -22
  60. package/dist/sdk/history-repair.d.ts +1 -1
  61. package/dist/sdk/history-repair.js +20 -10
  62. package/dist/sdk/lifecycle/create.js +43 -19
  63. package/dist/sdk/linked-artifacts.js +21 -31
  64. package/dist/sdk/merge/reconcile.js +3 -16
  65. package/dist/sdk/query/next.d.ts +6 -0
  66. package/dist/sdk/query/next.js +7 -2
  67. package/dist/sdk/test/entry.d.ts +1 -1
  68. package/dist/sdk/test/entry.js +5 -9
  69. package/dist/sdk/test/execution.d.ts +3 -0
  70. package/dist/sdk/test/execution.js +54 -13
  71. package/docs/CONTEXT_RECOVERY_PRIMITIVES.md +67 -0
  72. package/docs/MERGE_SAFETY.md +23 -10
  73. package/docs/README.md +1 -0
  74. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +10 -4
  75. package/marketplace.json +2 -2
  76. package/package.json +7 -7
  77. package/packages/pm-beads/package.json +1 -1
  78. package/packages/pm-calendar/package.json +1 -1
  79. package/packages/pm-command-kit/package.json +1 -1
  80. package/packages/pm-digital-twin/package.json +1 -1
  81. package/packages/pm-governance-audit/package.json +1 -1
  82. package/packages/pm-guide-shell/package.json +1 -1
  83. package/packages/pm-kanban/package.json +1 -1
  84. package/packages/pm-lifecycle-hooks/package.json +1 -1
  85. package/packages/pm-linked-test-adapters/package.json +1 -1
  86. package/packages/pm-search-advanced/package.json +1 -1
  87. package/packages/pm-templates/package.json +1 -1
  88. package/packages/pm-todos/package.json +1 -1
  89. package/packages/pm-vcs/package.json +1 -1
  90. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  91. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  92. package/sdk/public-surface.json +100 -11
  93. package/dist/cli-bundle/chunks/chunk-TIQ6AMH2.js +0 -13
  94. package/dist/cli-bundle/chunks/chunk-XRVVYRRO.js +0 -35
  95. package/dist/cli-bundle/focused-chunks/chunk-4ZDRZYYJ.js +0 -50
  96. package/dist/cli-bundle/focused-chunks/chunk-XDPYBQCF.js +0 -156
  97. package/dist/cli-bundle/focused-chunks/chunk-Y5A7SJJ7.js +0 -2
  98. package/dist/cli-bundle/focused-chunks/chunk-YJLDHJOD.js +0 -2
@@ -1,2 +1,2 @@
1
- import{a as L,h as T}from"./chunk-E73FDIWT.js";import{Ia as I,Ma as j,Oa as P,ta as O,wa as R}from"./chunk-NTXZHRKA.js";import"./chunk-WYRZZ5ZE.js";import{C as d,E as m,Fg as S,Hg as w,Ig as h,Im as b,Lm as x,Wa as $,ci as U,lf as G,mf as D}from"./chunk-XWEQGHHG.js";import C from"node:fs/promises";import W 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]="054789eb-fabe-5042-8166-19961f30ebf1")}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]="3e4ba524-10cf-58e7-81ea-f48f30ca1250")}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]="defd826a-ac9b-54e4-b2a3-00d022090a10")}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]="4344c493-be53-584f-b25d-4b41bfee5079")}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]="08f5b31f-c756-577c-94e8-7b4268ba12ab")}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]="59c52ff5-9763-5244-bed3-146a547c3551")}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]="feb682f9-344c-569e-bbab-861fe20f08f1")}catch{}})();var H={extension:"extension",package:void 0};async function v(e,t){if(!e)return;let o=G(e),n=b(t);await U($(process.cwd(),n.path)).then(i=>i.ux.deprecation_hints)&&h(D(o))}var V={init:"init",install:"install",uninstall:"uninstall",explore:"explore",manage:"manage",describe:"describe",reload:"reload",doctor:"doctor",catalog:"catalog",adopt:"adopt","adopt-all":"adoptAll",activate:"activate",deactivate:"deactivate",migrate:"migrate"};function X(e){let t=e.capability,o=typeof t=="string"?[t]:Array.isArray(t)?t.filter(a=>typeof a=="string"):[],n=[...new Set(o.map(a=>a.trim().toLowerCase()).filter(a=>a.length>0))];if(n.length>1)throw new m(`Multiple scaffold capabilities cannot be combined yet: ${n.join(", ")}. Choose one capability per scaffold.`,d.USAGE);return n[0]}function A(e,t,o="extension"){let n={...e};t!==void 0&&(n[V[t]]=!0);let a=(...c)=>c.some(s=>n[s]===!0),i=(...c)=>{for(let s of c)if(typeof n[s]=="string")return n[s]};return{init:a("init"),scaffold:a("scaffold"),install:a("install"),uninstall:a("uninstall"),explore:a("explore","list"),manage:a("manage"),describe:a("describe"),markdown:a("markdown"),reload:a("reload"),doctor:a("doctor"),catalog:a("catalog"),adopt:a("adopt"),adoptAll:a("adoptAll","adopt_all","adopt-all"),activate:a("activate"),deactivate:a("deactivate"),migrate:a("migrate"),project:a("project"),local:a("local"),global:a("global"),gh:i("gh"),github:i("github"),ref:i("ref"),capability:X(e),declarative:a("declarative"),fields:i("fields"),detail:i("detail"),output:i("output"),trace:a("trace"),watch:a("watch"),runtimeProbe:a("runtimeProbe","runtime_probe","runtime-probe"),fixManagedState:a("fixManagedState","fix_managed_state","fix-managed-state"),isolated:a("isolated"),ignoreGlobal:a("ignoreGlobal","ignore_global","ignore-global"),strictExit:a("strictExit","strict_exit","strict-exit"),failOnWarn:a("failOnWarn","fail_on_warn","fail-on-warn"),dryRun:a("dryRun","dry_run","dry-run"),vocabulary:o}}async function Y(e){let t=(await C.readdir(process.cwd())).filter(n=>!n.startsWith(".")).sort((n,a)=>n.localeCompare(a)),o=[...e].sort((n,a)=>n.localeCompare(a));return t.length===o.length&&t.every((n,a)=>n===o[a])}async function J(e){let t=(e??[]).map(o=>o.trim()).filter(o=>o.length>0);return t.length<=1?t.length===0?void 0:t:await Y(t)?["*"]:t}function M(e,t,o){let n=e.markdown===!0;if(o!==void 0&&o==="")throw new m("--output requires a non-empty file path.",d.USAGE);if(o!==void 0&&!n)throw new m("--output is only supported with --markdown describe output.",d.USAGE);if(n){if(t.json)throw new m("Cannot combine --json with --markdown.",d.USAGE);if(e.describe!==!0)throw new m("--markdown is only supported by the describe action.",d.USAGE)}}async function Q(e){let t=R(e.result.details,e.vocabulary);if(e.outputPath!==void 0){let o=W.resolve(e.outputPath);await C.mkdir(W.dirname(o),{recursive:!0}),await C.writeFile(o,t,"utf8")}if(!e.globalOptions.quiet){for(let o of e.result.warnings)h(`warning: ${o}`);e.outputPath===void 0&&S(t)}}function Z(e,t){let o=!!t.strictExit||!!t.failOnWarn;if(e.action!=="doctor"||!o)return;let n=e.details!==null&&typeof e.details=="object"?e.details:{},a=n.summary!==null&&typeof n.summary=="object"?n.summary:null,i=a&&typeof a.status=="string"?a.status:void 0;(e.warnings.length>0||i!==void 0&&i!=="ok")&&(process.exitCode=d.GENERIC_FAILURE)}async function p(e,t,o,n,a="extension"){let i=b(o),c=Date.now(),s=a==="extension"?"package":a;await v(H[a],o);let r=A(t,n,s),u=(typeof r.output=="string"?r.output:void 0)?.trim();M(r,i,u);let g=await I(e,r,i);r.markdown===!0?await Q({result:g,vocabulary:s,outputPath:u,globalOptions:i}):w(g,i),Z(g,r),g.ok===!1&&(process.exitCode=d.GENERIC_FAILURE),i.profile&&h(`profile:command=extension took_ms=${Date.now()-c}`)}function ee(e){return e.details!==null&&typeof e.details=="object"?e.details:{}}function te(e){return e instanceof m?{message:e.message,exit_code:e.exitCode,...e.context}:{message:e instanceof Error?e.message:String(e),exit_code:d.GENERIC_FAILURE}}async function oe(e,t,o){let n=[],a=[],i=d.GENERIC_FAILURE;for(let c of e)try{let s=await I(c,t,o),r=ee(s),l=Array.isArray(s.warnings)?s.warnings:[];a.push(...l);let u=s.ok===!0;n.push({target:c,ok:u,extension:r.extension,source:r.source,destination_path:r.destination_path,activated:r.activated,settings_changed:r.settings_changed,command_paths:r.command_paths,action_paths:r.action_paths,runtime_activation_status:r.runtime_activation_status,activation_diagnostics:r.activation_diagnostics,command_discovery:r.command_discovery,verification:r.verification,warnings:l,...u?{}:{error:{message:"Extension install returned ok=false without throwing an error.",exit_code:d.GENERIC_FAILURE,code:"extension_install_soft_failed"}}})}catch(s){let r=te(s),l=r.exit_code;typeof l=="number"&&i===d.GENERIC_FAILURE&&l!==d.GENERIC_FAILURE&&(i=l),n.push({target:c,ok:!1,error:r})}return{rows:n,warnings:a,failureExitCode:i}}async function z(e,t,o,n){let a=n==="extension"?"package":n;await v(H[n],o);let i=await J(e);if(i===void 0||i.length<=1){await p(i?.[0],t,o,"install",a);return}let c=b(o),s=Date.now(),r=A(t,"install",a);if(M(r,c,void 0),[r.gh,r.github].some(y=>typeof y=="string"&&y.trim().length>0))throw new m("Multiple install targets cannot be combined with --gh/--github. Install one GitHub source per command, or pass multiple explicit local, bundled, or npm: targets.",d.USAGE,{code:"multi_target_github_install_ambiguous",required:"Use exactly one positional target with --gh/--github, or omit --gh/--github when installing multiple targets.",examples:["pm install --gh owner/repo","pm install npm:pm-guide-shell pm-todos"]});let{rows:u,warnings:g,failureExitCode:E}=await oe(i,r,c),k=u.filter(y=>y.ok!==!0).length,K={ok:k===0,action:"install",scope:r.global===!0?"global":"project",installed_count:u.length-k,failed_count:k,targets:u,warnings:[...new Set(g)].sort((y,B)=>y.localeCompare(B))};w(K,c),k>0&&(process.exitCode=E),c.profile&&h(`profile:command=extension took_ms=${Date.now()-s}`)}function ne(e){return e.option("--project","Use project extension scope (default)").option("--local","Alias for --project").option("--global","Use global extension scope")}function _(e){return e.option("--project","Use project package scope (default)").option("--local","Alias for --project").option("--global","Use global package scope")}function f(e,t){return t==="package"?_(e):ne(e)}function N(e){return e.option("--dry-run","Plan CLI/package upgrades without running npm or reinstalling packages").option("--cli-only","Upgrade only the pm CLI/SDK npm package").option("--packages-only","Upgrade only managed pm packages").option("--repair","Force npm global reinstall when upgrading the pm CLI/SDK").option("--tag <value>","npm dist-tag/version for CLI and registry package upgrades").option("--package-name <value>","Override the CLI package name for self-upgrade testing")}async function q(e,t,o){let n=b(t),a=Date.now();o&&await v("upgrade",t);let i=await L(e,t.opts(),n);w(i,n),i.ok||(process.exitCode=d.GENERIC_FAILURE),n.profile&&h(`profile:command=package-upgrade took_ms=${Date.now()-a}`)}function F(e,t){let o=t==="package"?"package":"extension",n=t==="package"?"packages":"extensions",a=t,i=e.command(a,{hidden:t==="extension"}).argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} source, name, or scaffold path`).option("--init",`Generate a starter ${o} scaffold at target path`).option("--scaffold","Alias for --init").option("--capability <kind>","Starter capability for --init (default: commands)",x).option("--install",`Install a ${o} source`).option("--uninstall",`Uninstall an installed ${o}`).option("--explore",`List discovered ${n} in selected scope`).option("--list","Alias for --explore").option("--manage",`List managed ${n} with update-check metadata`).option("--describe",`Map every surface a loaded ${o} registers (optionally one by name)`).option("--markdown","Render describe output as a Markdown reference document (describe only)").option("--output <path>","Write describe Markdown to a file (requires --markdown)").option("--reload",`Reload ${n} with cache-busted module imports`).option("--watch","Use watch mode with --reload").option("--doctor",`Run consolidated ${o} diagnostics (summary/deep modes)`).option("--catalog",`List bundled first-party ${o} catalog metadata`).option("--adopt",`Adopt an existing unmanaged ${o} into managed metadata`).option("--adopt-all",`Adopt all unmanaged ${n} into managed metadata`).option("--activate",`Activate a ${o} in selected scope settings`).option("--deactivate",`Deactivate a ${o} in selected scope settings`).option("--project",`Use project ${o} scope (default)`).option("--local","Alias for --project").option("--global",`Use global ${o} scope`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").option("--detail <mode>",`${o[0].toUpperCase()}${o.slice(1)} diagnostics detail mode (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${n} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${n} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(t==="package"?"Manage package lifecycle in project or global scope.":"Manage extension lifecycle in project or global scope.").action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,void 0,t)});t==="package"&&(i.alias("packages"),i.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"));let c=i.command("init").alias("scaffold").argument("<target>","Scaffold target directory path").option("--capability <kind>",`Capability the starter targets (${O.join("|")}; default commands)`,x).description(t==="package"?"Generate a starter package scaffold with package metadata, manifest, and entrypoint.":"Generate a starter extension scaffold with manifest and entrypoint.");t==="package"&&c.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"),f(c,t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"init",t)}),f(i.command("install").argument("[targets...]",`${o[0].toUpperCase()}${o.slice(1)} source (local path, bundled alias, npm: source, wildcard, or GitHub source)`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description(`Install ${o} from local path, bundled alias, npm: source, wildcard, or GitHub source.`),t).action(async(s,r,l)=>{await z(s,l.optsWithGlobals(),l,t)}),f(i.command("uninstall").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Uninstall an installed ${o}.`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"uninstall",t)}),f(i.command("explore").description(`List discovered ${n} in selected scope.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"explore",t)}),f(i.command("manage").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${n} before diagnostics/update checks`).description(`List managed ${n} with update-check metadata.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"manage",t)}),f(i.command("describe").argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} name to describe (omit for every loaded ${o})`).option("--markdown","Render the surface map as a Markdown reference document instead of toon/json").option("--output <path>","Write Markdown output to a file (requires --markdown)").description(`Map every surface a loaded ${o} registers (commands, hooks, item types, providers, overrides, ...).`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"describe",t)}),f(i.command("reload").option("--watch","Use watch mode for repeated reload checks").description(`Reload ${n} with cache-busted module imports.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"reload",t)}),f(i.command("doctor").option("--detail <mode>",`Detail mode for ${o} diagnostics (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--fix-managed-state",`Adopt unmanaged ${n} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${n} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(`Run consolidated ${o} diagnostics (summary/deep modes).`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"doctor",t)}),f(i.command("catalog").alias("list").option("--fields <value>","Render compact comma-separated catalog fields, for example: alias,installed,install_command").description(`List bundled first-party ${o} catalog metadata.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"catalog",t)}),f(i.command("adopt").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).option("--gh <owner/repo[/path]>",`GitHub provenance shorthand for adopted ${o}`).option("--github <owner/repo[/path]>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub shorthand source").description(`Adopt an existing unmanaged ${o} into managed metadata.`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"adopt",t)}),f(i.command("adopt-all").description(`Adopt all unmanaged ${n} into managed metadata.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"adopt-all",t)}),f(i.command("migrate").option("--dry-run","Plan active migrations without invoking extension code").description(`Plan or apply active ${o} migrations with durable receipts.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"migrate",t)}),f(i.command("activate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Activate a ${o} in selected scope settings.`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"activate",t)}),f(i.command("deactivate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Deactivate a ${o} in selected scope settings.`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"deactivate",t)}),t==="package"&&N(_(i.command("upgrade").argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(s,r,l)=>{await q(s,l,!1)})}async function ae(e,t,o){let n=b(o),a=Date.now(),i=await P(e,n,{idPrefix:typeof t.idPrefix=="string"?t.idPrefix:void 0,preset:typeof t.preset=="string"?t.preset:void 0,defaults:t.defaults===!0||t.yes===!0,author:typeof t.author=="string"?t.author:void 0,agentGuidance:typeof t.agentGuidance=="string"?t.agentGuidance:void 0,typePreset:typeof t.typePreset=="string"?t.typePreset:void 0,withPackages:t.withPackages===!0,mergeFence:t.mergeFence!==!1,force:t.force===!0,workspace:typeof t.workspace=="string"?t.workspace:void 0}),s=t.verbose===!0||n.json===!0;w(s?i:j(i),n),n.profile&&h(`profile:command=init took_ms=${Date.now()-a}`)}function ie(e,t,o,n){let i=e!==void 0&&new Set(["get","set","list","export"]).has(e);return{resolvedScope:i?"project":e??"project",resolvedAction:i?e:t??"list",resolvedKey:i?t:o,resolvedValue:i?o:n}}function re(e){return{criterion:Array.isArray(e.criterion)?e.criterion:[],format:typeof e.format=="string"?e.format:void 0,policy:typeof e.policy=="string"?e.policy:void 0,value:typeof e.value=="string"?e.value:void 0,clearCriteria:e.clearCriteria===!0,defaultDepth:typeof e.defaultDepth=="string"?e.defaultDepth:void 0,activityLimit:typeof e.activityLimit=="string"?e.activityLimit:void 0,staleThresholdDays:typeof e.staleThresholdDays=="string"?e.staleThresholdDays:void 0,sectionHierarchy:typeof e.sectionHierarchy=="string"?e.sectionHierarchy:void 0,sectionActivity:typeof e.sectionActivity=="string"?e.sectionActivity:void 0,sectionProgress:typeof e.sectionProgress=="string"?e.sectionProgress:void 0,sectionBlockers:typeof e.sectionBlockers=="string"?e.sectionBlockers:void 0,sectionFiles:typeof e.sectionFiles=="string"?e.sectionFiles:void 0,sectionWorkload:typeof e.sectionWorkload=="string"?e.sectionWorkload:void 0,sectionStaleness:typeof e.sectionStaleness=="string"?e.sectionStaleness:void 0,sectionTests:typeof e.sectionTests=="string"?e.sectionTests:void 0}}async function se(e,t,o,n,a,i){let c=b(i),s=Date.now(),{resolvedScope:r,resolvedAction:l,resolvedKey:u,resolvedValue:g}=ie(e,t,o,n),E=await T(r,l,u,re(a),c,typeof g=="string"?g:void 0);w(E,c),c.profile&&h(`profile:command=config took_ms=${Date.now()-s}`)}var Se={normalizeExtensionOptions:A};function Ue(e){e.command("init").argument("[prefix-or-path]","Optional id prefix, or path-like tracker target such as ./pm-sandbox").option("--prefix, --id-prefix <value>","Set the item ID prefix (alias for the positional prefix)").option("--preset <value>","Governance preset for new setups: minimal|default|strict").option("--defaults","Use non-interactive setup defaults without opening the wizard").option("-y, --yes","Alias for --defaults (non-interactive setup)").option("--author <value>","Set the default mutation author for this project").option("--agent-guidance <mode>","Agent guidance mode: ask|add|skip|status").option("--type-preset <name>","Register domain item types during init: agile|ops|research").option("--with-packages","Install all bundled first-party packages during initialization").option("--no-merge-fence","Skip automatic merge-driver installation for a fresh Git-backed tracker").option("--workspace <dir>","Initialize repository-local tracker storage at <dir>/.agents/pm").option("--force","Allow initializing tracker files directly in a directory that looks like a workspace root").option("--verbose","Include the full resolved settings tree in the output (default output is a concise summary)").description("Initialize pm storage and defaults for the current workspace or a path-like tracker target.").action(async(t,o,n)=>{await ae(t,o,n)}),e.command("config").argument("[scope]","Config scope: project|global, or action shorthand list|export|get|set for project scope").argument("[action]","Config action: get|set|list|export").argument("[key]","Config key for get|set; use `pm config project list` for the complete typed inventory, including mutation-guard-* policies").argument("[value]",'Optional value for set: routed to the right typed flag by key (e.g. config set telemetry-tracking off, config set item-format toon, config set definition-of-done "Tests pass"). Equivalent to --policy/--format/--criterion. context keys still require --default-depth/--section-* flags.').option("--criterion <text>","Criteria value for definition-of-done, metadata-required-fields, or lifecycle pattern keys (repeatable for set)",x).option("--clear-criteria","Clear criteria-list keys for config set operations").option("--format <value>","Item format for item-format key: toon").option("--policy <value>","Policy key values: history-missing-stream-policy=auto_create|strict_error; sprint-release-format-policy=warn|strict_error; parent-reference-policy=warn|strict_error; governance-preset=minimal|default|strict|custom; governance-ownership-enforcement=none|warn|strict; governance-create-mode-default=progressive|strict; governance-close-validation-default=off|warn|strict; governance-require-close-reason=enabled|disabled; governance-parent-reference-policy=warn|strict_error; governance-metadata-validation-profile=core|strict|custom; governance-force-required-for-stale-lock=enabled|disabled; governance-duplicate-detection-mode=off|advisory|strict; test-result-tracking=enabled|disabled; untrusted-linked-test-execution=enabled|disabled; telemetry-tracking=enabled|disabled").option("--value <value>","Typed nested setting value. Mutation guards: require-attributed-author=true|false, secret-guard=off|advise|block, stale-in-progress-hours=integer>=1. Kebab-case is preferred; underscore aliases remain accepted.").option("--default-depth <value>","Context default depth: brief|standard|deep").option("--activity-limit <n>","Context default activity limit").option("--stale-threshold-days <n>","Context staleness cutoff in days").option("--section-hierarchy <value>","Enable/disable context hierarchy section (true|false)").option("--section-activity <value>","Enable/disable context activity section (true|false)").option("--section-progress <value>","Enable/disable context progress section (true|false)").option("--section-blockers <value>","Enable/disable context blockers section (true|false)").option("--section-files <value>","Enable/disable context files section (true|false)").option("--section-workload <value>","Enable/disable context workload section (true|false)").option("--section-staleness <value>","Enable/disable context staleness section (true|false)").option("--section-tests <value>","Enable/disable context tests section (true|false)").description("Read or update pm settings for the current workspace or global profile.").action(async(t,o,n,a,i,c)=>{await se(t,o,n,a,i,c)}),F(e,"extension"),F(e,"package"),_(e.command("install",{hidden:!0}).argument("[targets...]","Package source (local path, bundled alias, npm: source, wildcard, or GitHub source)").option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description("Install a pm package into the project package scope by default.")).action(async(t,o,n)=>{await v("install",n),await z(t,n.optsWithGlobals(),n,"package")}),N(_(e.command("upgrade",{hidden:!0}).argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(t,o,n)=>{await q(t,n,!0)})}export{Se as _testOnlyRegisterSetup,Ue as registerSetupCommands};
2
- //# sourceMappingURL=register-setup-OQERLLWE.js.map
1
+ import{a as L,h as T}from"./chunk-2MKLQL2E.js";import{Ia as I,Ma as j,Oa as P,ta as O,wa as R}from"./chunk-2UETTHY6.js";import"./chunk-WYRZZ5ZE.js";import{C as d,E as m,Hg as S,Jg as w,Kg as h,Km as b,Nm as x,Wa as $,ei as U,nf as G,of as D}from"./chunk-GNWPTEBW.js";import C from"node:fs/promises";import W 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]="054789eb-fabe-5042-8166-19961f30ebf1")}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]="3e4ba524-10cf-58e7-81ea-f48f30ca1250")}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]="defd826a-ac9b-54e4-b2a3-00d022090a10")}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]="4344c493-be53-584f-b25d-4b41bfee5079")}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]="08f5b31f-c756-577c-94e8-7b4268ba12ab")}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]="59c52ff5-9763-5244-bed3-146a547c3551")}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]="feb682f9-344c-569e-bbab-861fe20f08f1")}catch{}})();var H={extension:"extension",package:void 0};async function v(e,t){if(!e)return;let o=G(e),n=b(t);await U($(process.cwd(),n.path)).then(i=>i.ux.deprecation_hints)&&h(D(o))}var V={init:"init",install:"install",uninstall:"uninstall",explore:"explore",manage:"manage",describe:"describe",reload:"reload",doctor:"doctor",catalog:"catalog",adopt:"adopt","adopt-all":"adoptAll",activate:"activate",deactivate:"deactivate",migrate:"migrate"};function X(e){let t=e.capability,o=typeof t=="string"?[t]:Array.isArray(t)?t.filter(a=>typeof a=="string"):[],n=[...new Set(o.map(a=>a.trim().toLowerCase()).filter(a=>a.length>0))];if(n.length>1)throw new m(`Multiple scaffold capabilities cannot be combined yet: ${n.join(", ")}. Choose one capability per scaffold.`,d.USAGE);return n[0]}function A(e,t,o="extension"){let n={...e};t!==void 0&&(n[V[t]]=!0);let a=(...c)=>c.some(s=>n[s]===!0),i=(...c)=>{for(let s of c)if(typeof n[s]=="string")return n[s]};return{init:a("init"),scaffold:a("scaffold"),install:a("install"),uninstall:a("uninstall"),explore:a("explore","list"),manage:a("manage"),describe:a("describe"),markdown:a("markdown"),reload:a("reload"),doctor:a("doctor"),catalog:a("catalog"),adopt:a("adopt"),adoptAll:a("adoptAll","adopt_all","adopt-all"),activate:a("activate"),deactivate:a("deactivate"),migrate:a("migrate"),project:a("project"),local:a("local"),global:a("global"),gh:i("gh"),github:i("github"),ref:i("ref"),capability:X(e),declarative:a("declarative"),fields:i("fields"),detail:i("detail"),output:i("output"),trace:a("trace"),watch:a("watch"),runtimeProbe:a("runtimeProbe","runtime_probe","runtime-probe"),fixManagedState:a("fixManagedState","fix_managed_state","fix-managed-state"),isolated:a("isolated"),ignoreGlobal:a("ignoreGlobal","ignore_global","ignore-global"),strictExit:a("strictExit","strict_exit","strict-exit"),failOnWarn:a("failOnWarn","fail_on_warn","fail-on-warn"),dryRun:a("dryRun","dry_run","dry-run"),vocabulary:o}}async function Y(e){let t=(await C.readdir(process.cwd())).filter(n=>!n.startsWith(".")).sort((n,a)=>n.localeCompare(a)),o=[...e].sort((n,a)=>n.localeCompare(a));return t.length===o.length&&t.every((n,a)=>n===o[a])}async function J(e){let t=(e??[]).map(o=>o.trim()).filter(o=>o.length>0);return t.length<=1?t.length===0?void 0:t:await Y(t)?["*"]:t}function M(e,t,o){let n=e.markdown===!0;if(o!==void 0&&o==="")throw new m("--output requires a non-empty file path.",d.USAGE);if(o!==void 0&&!n)throw new m("--output is only supported with --markdown describe output.",d.USAGE);if(n){if(t.json)throw new m("Cannot combine --json with --markdown.",d.USAGE);if(e.describe!==!0)throw new m("--markdown is only supported by the describe action.",d.USAGE)}}async function Q(e){let t=R(e.result.details,e.vocabulary);if(e.outputPath!==void 0){let o=W.resolve(e.outputPath);await C.mkdir(W.dirname(o),{recursive:!0}),await C.writeFile(o,t,"utf8")}if(!e.globalOptions.quiet){for(let o of e.result.warnings)h(`warning: ${o}`);e.outputPath===void 0&&S(t)}}function Z(e,t){let o=!!t.strictExit||!!t.failOnWarn;if(e.action!=="doctor"||!o)return;let n=e.details!==null&&typeof e.details=="object"?e.details:{},a=n.summary!==null&&typeof n.summary=="object"?n.summary:null,i=a&&typeof a.status=="string"?a.status:void 0;(e.warnings.length>0||i!==void 0&&i!=="ok")&&(process.exitCode=d.GENERIC_FAILURE)}async function p(e,t,o,n,a="extension"){let i=b(o),c=Date.now(),s=a==="extension"?"package":a;await v(H[a],o);let r=A(t,n,s),u=(typeof r.output=="string"?r.output:void 0)?.trim();M(r,i,u);let g=await I(e,r,i);r.markdown===!0?await Q({result:g,vocabulary:s,outputPath:u,globalOptions:i}):w(g,i),Z(g,r),g.ok===!1&&(process.exitCode=d.GENERIC_FAILURE),i.profile&&h(`profile:command=extension took_ms=${Date.now()-c}`)}function ee(e){return e.details!==null&&typeof e.details=="object"?e.details:{}}function te(e){return e instanceof m?{message:e.message,exit_code:e.exitCode,...e.context}:{message:e instanceof Error?e.message:String(e),exit_code:d.GENERIC_FAILURE}}async function oe(e,t,o){let n=[],a=[],i=d.GENERIC_FAILURE;for(let c of e)try{let s=await I(c,t,o),r=ee(s),l=Array.isArray(s.warnings)?s.warnings:[];a.push(...l);let u=s.ok===!0;n.push({target:c,ok:u,extension:r.extension,source:r.source,destination_path:r.destination_path,activated:r.activated,settings_changed:r.settings_changed,command_paths:r.command_paths,action_paths:r.action_paths,runtime_activation_status:r.runtime_activation_status,activation_diagnostics:r.activation_diagnostics,command_discovery:r.command_discovery,verification:r.verification,warnings:l,...u?{}:{error:{message:"Extension install returned ok=false without throwing an error.",exit_code:d.GENERIC_FAILURE,code:"extension_install_soft_failed"}}})}catch(s){let r=te(s),l=r.exit_code;typeof l=="number"&&i===d.GENERIC_FAILURE&&l!==d.GENERIC_FAILURE&&(i=l),n.push({target:c,ok:!1,error:r})}return{rows:n,warnings:a,failureExitCode:i}}async function z(e,t,o,n){let a=n==="extension"?"package":n;await v(H[n],o);let i=await J(e);if(i===void 0||i.length<=1){await p(i?.[0],t,o,"install",a);return}let c=b(o),s=Date.now(),r=A(t,"install",a);if(M(r,c,void 0),[r.gh,r.github].some(y=>typeof y=="string"&&y.trim().length>0))throw new m("Multiple install targets cannot be combined with --gh/--github. Install one GitHub source per command, or pass multiple explicit local, bundled, or npm: targets.",d.USAGE,{code:"multi_target_github_install_ambiguous",required:"Use exactly one positional target with --gh/--github, or omit --gh/--github when installing multiple targets.",examples:["pm install --gh owner/repo","pm install npm:pm-guide-shell pm-todos"]});let{rows:u,warnings:g,failureExitCode:E}=await oe(i,r,c),k=u.filter(y=>y.ok!==!0).length,K={ok:k===0,action:"install",scope:r.global===!0?"global":"project",installed_count:u.length-k,failed_count:k,targets:u,warnings:[...new Set(g)].sort((y,B)=>y.localeCompare(B))};w(K,c),k>0&&(process.exitCode=E),c.profile&&h(`profile:command=extension took_ms=${Date.now()-s}`)}function ne(e){return e.option("--project","Use project extension scope (default)").option("--local","Alias for --project").option("--global","Use global extension scope")}function _(e){return e.option("--project","Use project package scope (default)").option("--local","Alias for --project").option("--global","Use global package scope")}function f(e,t){return t==="package"?_(e):ne(e)}function N(e){return e.option("--dry-run","Plan CLI/package upgrades without running npm or reinstalling packages").option("--cli-only","Upgrade only the pm CLI/SDK npm package").option("--packages-only","Upgrade only managed pm packages").option("--repair","Force npm global reinstall when upgrading the pm CLI/SDK").option("--tag <value>","npm dist-tag/version for CLI and registry package upgrades").option("--package-name <value>","Override the CLI package name for self-upgrade testing")}async function q(e,t,o){let n=b(t),a=Date.now();o&&await v("upgrade",t);let i=await L(e,t.opts(),n);w(i,n),i.ok||(process.exitCode=d.GENERIC_FAILURE),n.profile&&h(`profile:command=package-upgrade took_ms=${Date.now()-a}`)}function F(e,t){let o=t==="package"?"package":"extension",n=t==="package"?"packages":"extensions",a=t,i=e.command(a,{hidden:t==="extension"}).argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} source, name, or scaffold path`).option("--init",`Generate a starter ${o} scaffold at target path`).option("--scaffold","Alias for --init").option("--capability <kind>","Starter capability for --init (default: commands)",x).option("--install",`Install a ${o} source`).option("--uninstall",`Uninstall an installed ${o}`).option("--explore",`List discovered ${n} in selected scope`).option("--list","Alias for --explore").option("--manage",`List managed ${n} with update-check metadata`).option("--describe",`Map every surface a loaded ${o} registers (optionally one by name)`).option("--markdown","Render describe output as a Markdown reference document (describe only)").option("--output <path>","Write describe Markdown to a file (requires --markdown)").option("--reload",`Reload ${n} with cache-busted module imports`).option("--watch","Use watch mode with --reload").option("--doctor",`Run consolidated ${o} diagnostics (summary/deep modes)`).option("--catalog",`List bundled first-party ${o} catalog metadata`).option("--adopt",`Adopt an existing unmanaged ${o} into managed metadata`).option("--adopt-all",`Adopt all unmanaged ${n} into managed metadata`).option("--activate",`Activate a ${o} in selected scope settings`).option("--deactivate",`Deactivate a ${o} in selected scope settings`).option("--project",`Use project ${o} scope (default)`).option("--local","Alias for --project").option("--global",`Use global ${o} scope`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").option("--detail <mode>",`${o[0].toUpperCase()}${o.slice(1)} diagnostics detail mode (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${n} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${n} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(t==="package"?"Manage package lifecycle in project or global scope.":"Manage extension lifecycle in project or global scope.").action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,void 0,t)});t==="package"&&(i.alias("packages"),i.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"));let c=i.command("init").alias("scaffold").argument("<target>","Scaffold target directory path").option("--capability <kind>",`Capability the starter targets (${O.join("|")}; default commands)`,x).description(t==="package"?"Generate a starter package scaffold with package metadata, manifest, and entrypoint.":"Generate a starter extension scaffold with manifest and entrypoint.");t==="package"&&c.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"),f(c,t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"init",t)}),f(i.command("install").argument("[targets...]",`${o[0].toUpperCase()}${o.slice(1)} source (local path, bundled alias, npm: source, wildcard, or GitHub source)`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description(`Install ${o} from local path, bundled alias, npm: source, wildcard, or GitHub source.`),t).action(async(s,r,l)=>{await z(s,l.optsWithGlobals(),l,t)}),f(i.command("uninstall").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Uninstall an installed ${o}.`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"uninstall",t)}),f(i.command("explore").description(`List discovered ${n} in selected scope.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"explore",t)}),f(i.command("manage").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${n} before diagnostics/update checks`).description(`List managed ${n} with update-check metadata.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"manage",t)}),f(i.command("describe").argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} name to describe (omit for every loaded ${o})`).option("--markdown","Render the surface map as a Markdown reference document instead of toon/json").option("--output <path>","Write Markdown output to a file (requires --markdown)").description(`Map every surface a loaded ${o} registers (commands, hooks, item types, providers, overrides, ...).`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"describe",t)}),f(i.command("reload").option("--watch","Use watch mode for repeated reload checks").description(`Reload ${n} with cache-busted module imports.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"reload",t)}),f(i.command("doctor").option("--detail <mode>",`Detail mode for ${o} diagnostics (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--fix-managed-state",`Adopt unmanaged ${n} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${n} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(`Run consolidated ${o} diagnostics (summary/deep modes).`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"doctor",t)}),f(i.command("catalog").alias("list").option("--fields <value>","Render compact comma-separated catalog fields, for example: alias,installed,install_command").description(`List bundled first-party ${o} catalog metadata.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"catalog",t)}),f(i.command("adopt").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).option("--gh <owner/repo[/path]>",`GitHub provenance shorthand for adopted ${o}`).option("--github <owner/repo[/path]>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub shorthand source").description(`Adopt an existing unmanaged ${o} into managed metadata.`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"adopt",t)}),f(i.command("adopt-all").description(`Adopt all unmanaged ${n} into managed metadata.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"adopt-all",t)}),f(i.command("migrate").option("--dry-run","Plan active migrations without invoking extension code").description(`Plan or apply active ${o} migrations with durable receipts.`),t).action(async(s,r)=>{await p(void 0,r.optsWithGlobals(),r,"migrate",t)}),f(i.command("activate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Activate a ${o} in selected scope settings.`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"activate",t)}),f(i.command("deactivate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Deactivate a ${o} in selected scope settings.`),t).action(async(s,r,l)=>{await p(s,l.optsWithGlobals(),l,"deactivate",t)}),t==="package"&&N(_(i.command("upgrade").argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(s,r,l)=>{await q(s,l,!1)})}async function ae(e,t,o){let n=b(o),a=Date.now(),i=await P(e,n,{idPrefix:typeof t.idPrefix=="string"?t.idPrefix:void 0,preset:typeof t.preset=="string"?t.preset:void 0,defaults:t.defaults===!0||t.yes===!0,author:typeof t.author=="string"?t.author:void 0,agentGuidance:typeof t.agentGuidance=="string"?t.agentGuidance:void 0,typePreset:typeof t.typePreset=="string"?t.typePreset:void 0,withPackages:t.withPackages===!0,mergeFence:t.mergeFence!==!1,force:t.force===!0,workspace:typeof t.workspace=="string"?t.workspace:void 0}),s=t.verbose===!0||n.json===!0;w(s?i:j(i),n),n.profile&&h(`profile:command=init took_ms=${Date.now()-a}`)}function ie(e,t,o,n){let i=e!==void 0&&new Set(["get","set","list","export"]).has(e);return{resolvedScope:i?"project":e??"project",resolvedAction:i?e:t??"list",resolvedKey:i?t:o,resolvedValue:i?o:n}}function re(e){return{criterion:Array.isArray(e.criterion)?e.criterion:[],format:typeof e.format=="string"?e.format:void 0,policy:typeof e.policy=="string"?e.policy:void 0,value:typeof e.value=="string"?e.value:void 0,clearCriteria:e.clearCriteria===!0,defaultDepth:typeof e.defaultDepth=="string"?e.defaultDepth:void 0,activityLimit:typeof e.activityLimit=="string"?e.activityLimit:void 0,staleThresholdDays:typeof e.staleThresholdDays=="string"?e.staleThresholdDays:void 0,sectionHierarchy:typeof e.sectionHierarchy=="string"?e.sectionHierarchy:void 0,sectionActivity:typeof e.sectionActivity=="string"?e.sectionActivity:void 0,sectionProgress:typeof e.sectionProgress=="string"?e.sectionProgress:void 0,sectionBlockers:typeof e.sectionBlockers=="string"?e.sectionBlockers:void 0,sectionFiles:typeof e.sectionFiles=="string"?e.sectionFiles:void 0,sectionWorkload:typeof e.sectionWorkload=="string"?e.sectionWorkload:void 0,sectionStaleness:typeof e.sectionStaleness=="string"?e.sectionStaleness:void 0,sectionTests:typeof e.sectionTests=="string"?e.sectionTests:void 0}}async function se(e,t,o,n,a,i){let c=b(i),s=Date.now(),{resolvedScope:r,resolvedAction:l,resolvedKey:u,resolvedValue:g}=ie(e,t,o,n),E=await T(r,l,u,re(a),c,typeof g=="string"?g:void 0);w(E,c),c.profile&&h(`profile:command=config took_ms=${Date.now()-s}`)}var Se={normalizeExtensionOptions:A};function Ue(e){e.command("init").argument("[prefix-or-path]","Optional id prefix, or path-like tracker target such as ./pm-sandbox").option("--prefix, --id-prefix <value>","Set the item ID prefix (alias for the positional prefix)").option("--preset <value>","Governance preset for new setups: minimal|default|strict").option("--defaults","Use non-interactive setup defaults without opening the wizard").option("-y, --yes","Alias for --defaults (non-interactive setup)").option("--author <value>","Set the default mutation author for this project").option("--agent-guidance <mode>","Agent guidance mode: ask|add|skip|status").option("--type-preset <name>","Register domain item types during init: agile|ops|research").option("--with-packages","Install all bundled first-party packages during initialization").option("--no-merge-fence","Skip automatic merge-driver installation for a fresh Git-backed tracker").option("--workspace <dir>","Initialize repository-local tracker storage at <dir>/.agents/pm").option("--force","Allow initializing tracker files directly in a directory that looks like a workspace root").option("--verbose","Include the full resolved settings tree in the output (default output is a concise summary)").description("Initialize pm storage and defaults for the current workspace or a path-like tracker target.").action(async(t,o,n)=>{await ae(t,o,n)}),e.command("config").argument("[scope]","Config scope: project|global, or action shorthand list|export|get|set for project scope").argument("[action]","Config action: get|set|list|export").argument("[key]","Config key for get|set; use `pm config project list` for the complete typed inventory, including mutation-guard-* policies").argument("[value]",'Optional value for set: routed to the right typed flag by key (e.g. config set telemetry-tracking off, config set item-format toon, config set definition-of-done "Tests pass"). Equivalent to --policy/--format/--criterion. context keys still require --default-depth/--section-* flags.').option("--criterion <text>","Criteria value for definition-of-done, metadata-required-fields, or lifecycle pattern keys (repeatable for set)",x).option("--clear-criteria","Clear criteria-list keys for config set operations").option("--format <value>","Item format for item-format key: toon").option("--policy <value>","Policy key values: history-missing-stream-policy=auto_create|strict_error; sprint-release-format-policy=warn|strict_error; parent-reference-policy=warn|strict_error; governance-preset=minimal|default|strict|custom; governance-ownership-enforcement=none|warn|strict; governance-create-mode-default=progressive|strict; governance-close-validation-default=off|warn|strict; governance-require-close-reason=enabled|disabled; governance-parent-reference-policy=warn|strict_error; governance-metadata-validation-profile=core|strict|custom; governance-force-required-for-stale-lock=enabled|disabled; governance-duplicate-detection-mode=off|advisory|strict; test-result-tracking=enabled|disabled; untrusted-linked-test-execution=enabled|disabled; telemetry-tracking=enabled|disabled").option("--value <value>","Typed nested setting value. Mutation guards: require-attributed-author=true|false, secret-guard=off|advise|block, stale-in-progress-hours=integer>=1. Kebab-case is preferred; underscore aliases remain accepted.").option("--default-depth <value>","Context default depth: brief|standard|deep").option("--activity-limit <n>","Context default activity limit").option("--stale-threshold-days <n>","Context staleness cutoff in days").option("--section-hierarchy <value>","Enable/disable context hierarchy section (true|false)").option("--section-activity <value>","Enable/disable context activity section (true|false)").option("--section-progress <value>","Enable/disable context progress section (true|false)").option("--section-blockers <value>","Enable/disable context blockers section (true|false)").option("--section-files <value>","Enable/disable context files section (true|false)").option("--section-workload <value>","Enable/disable context workload section (true|false)").option("--section-staleness <value>","Enable/disable context staleness section (true|false)").option("--section-tests <value>","Enable/disable context tests section (true|false)").description("Read or update pm settings for the current workspace or global profile.").action(async(t,o,n,a,i,c)=>{await se(t,o,n,a,i,c)}),F(e,"extension"),F(e,"package"),_(e.command("install",{hidden:!0}).argument("[targets...]","Package source (local path, bundled alias, npm: source, wildcard, or GitHub source)").option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description("Install a pm package into the project package scope by default.")).action(async(t,o,n)=>{await v("install",n),await z(t,n.optsWithGlobals(),n,"package")}),N(_(e.command("upgrade",{hidden:!0}).argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(t,o,n)=>{await q(t,n,!0)})}export{Se as _testOnlyRegisterSetup,Ue as registerSetupCommands};
2
+ //# sourceMappingURL=register-setup-GLQ5SYV3.js.map
@@ -1,8 +1,8 @@
1
- import{w as D,x as q}from"./chunk-FC2AXLB5.js";import{Mb as N,Sb as z,Ub as O,da as j}from"./chunk-XDPYBQCF.js";import{fa as S,ka as m,t as b,v as k}from"./chunk-AD6ULRAF.js";import{aa as _,bb as x,eb as C,hb as L}from"./chunk-Z2USIBR2.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-XXOWRJZ5.js";import{Ob as N,Ub as z,Wb as O,da as j}from"./chunk-3UMBF26I.js";import{fa as S,ka as m,t as b,v as k}from"./chunk-AD6ULRAF.js";import{aa as _,bb as x,eb as C,hb as L}from"./chunk-Z2USIBR2.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-HC7ODMH3.js.map
8
+ //# sourceMappingURL=chunk-3AVAWVZA.js.map