@unbrained/pm-cli 2026.8.21 → 2026.8.22
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.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +16 -0
- package/dist/cli/error-guidance.d.ts +9 -4
- package/dist/cli/error-guidance.js +16 -15
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +40 -7
- package/dist/cli-bundle/bundle-manifest.json +153 -153
- package/dist/cli-bundle/chunks/{chunk-BKYB45NQ.js → chunk-BWX4SK46.js} +48 -48
- package/dist/cli-bundle/chunks/chunk-EMWDM5FI.js +13 -0
- package/dist/cli-bundle/chunks/chunk-HYG6LRL4.js +200 -0
- package/dist/cli-bundle/chunks/{chunk-LARJJ3RK.js → chunk-MYYI3ZOA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BUNIEJNE.js → chunk-MZTZQTMS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LOVTQ52Z.js → chunk-QI2CT3IX.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-SMWXHMVB.js +35 -0
- package/dist/cli-bundle/chunks/{chunk-N3DSV4CH.js → chunk-U6GQ4VMV.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-3AFAUHUE.js → chunk-VMMIL3SI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WG4STC36.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-JSLOFXGA.js → chunk-YBPJAOQQ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-F57EWDEF.js → register-list-query-HZKBQNWW.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-7IY2D5KO.js → register-mutation-HTKEEGRD.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-FALL3YTU.js → register-operations-6EMRWJJY.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-HXU7IZZD.js → register-setup-QK4OTOXN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FJ22HNRP.js → chunk-2ARQGDDW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-CKKQSJNN.js → chunk-2AZT5WXZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-F4YEW5I2.js → chunk-2POVTNLY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3LKU6PTJ.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-5SHSBMX2.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-FH6DYED3.js → chunk-6S2MO3Q3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UZE7XUZK.js → chunk-A2BC5PQL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-C4S4A4JJ.js +5 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KDNG7TKQ.js → chunk-D6RBZEJJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-E2EWYPY6.js +16 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4ERLO7QD.js → chunk-GMYPD4FX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-L5LDSRO2.js +155 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ZOSEELYJ.js → chunk-MB37AYN6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MCOR37QK.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2NIY5NKG.js → chunk-PH2OXXVZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YKBKIEAJ.js → chunk-PMGJUFNQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-R6SR45XU.js +50 -0
- package/dist/cli-bundle/focused-chunks/chunk-WZE4LIPW.js +8 -0
- package/dist/cli-bundle/main.js +13 -13
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +40 -40
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +32 -32
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +5 -5
- package/dist/core/extensions/extension-hook-runtime.js +22 -20
- package/dist/core/extensions/extension-types.d.ts +8 -1
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/loader.js +7 -3
- package/dist/core/extensions/service-ownership.d.ts +8 -0
- package/dist/core/extensions/service-ownership.js +20 -0
- package/dist/core/item/id.js +20 -5
- package/dist/core/item/item-format.js +27 -2
- package/dist/core/shared/errors.d.ts +4 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
- package/dist/sdk/authoring.d.ts +1 -1
- package/dist/sdk/authoring.js +2 -2
- package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +77 -0
- package/dist/sdk/cli-contracts/agent-output-contracts.js +324 -2
- package/dist/sdk/cli-contracts/commander-mutation-options.js +3 -3
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +4 -3
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +3 -3
- package/dist/sdk/extension/install-sources.d.ts +1 -1
- package/dist/sdk/extension/install-sources.js +6 -3
- package/dist/sdk/extension/output-ownership.d.ts +1 -0
- package/dist/sdk/extension/output-ownership.js +3 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +38 -14
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +14 -2
- package/dist/sdk/governance/health.d.ts +3 -0
- package/dist/sdk/governance/health.js +39 -7
- package/dist/sdk/governance/hierarchy-validation.d.ts +29 -0
- package/dist/sdk/governance/hierarchy-validation.js +109 -0
- package/dist/sdk/governance/validate.d.ts +1 -7
- package/dist/sdk/governance/validate.js +47 -99
- package/dist/sdk/graph/assembly.d.ts +6 -1
- package/dist/sdk/graph/assembly.js +16 -22
- package/dist/sdk/graph/governance-contracts.d.ts +1 -1
- package/dist/sdk/graph/governance-contracts.js +8 -2
- package/dist/sdk/graph/governance.js +46 -2
- package/dist/sdk/graph/hierarchy-integrity.d.ts +94 -0
- package/dist/sdk/graph/hierarchy-integrity.js +311 -0
- package/dist/sdk/graph/index.d.ts +2 -1
- package/dist/sdk/graph/index.js +3 -2
- package/dist/sdk/graph/remediation.js +32 -2
- package/dist/sdk/graph/run.d.ts +31 -2
- package/dist/sdk/graph/run.js +80 -31
- package/dist/sdk/graph/workspace-relationship-kind-registry.d.ts +8 -0
- package/dist/sdk/graph/workspace-relationship-kind-registry.js +28 -0
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/index.js +3 -3
- package/dist/sdk/item-children.js +21 -8
- package/dist/sdk/lifecycle/create.js +125 -96
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.d.ts +15 -0
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +25 -0
- package/dist/sdk/lifecycle/update.d.ts +2 -0
- package/dist/sdk/lifecycle/update.js +171 -83
- package/dist/sdk/query/complete-list.d.ts +3 -3
- package/dist/sdk/query/complete-list.js +46 -3
- package/dist/sdk/query/list.d.ts +4 -3
- package/dist/sdk/query/list.js +89 -49
- package/dist/sdk/read-output-contracts.d.ts +5 -1
- package/dist/sdk/read-output-contracts.js +87 -22
- package/dist/sdk/relationship-context.js +3 -4
- package/dist/sdk/relationships.js +17 -10
- package/dist/sdk/runtime.d.ts +3 -2
- package/dist/sdk/runtime.js +3 -2
- package/dist/sdk/test/batch.js +13 -5
- package/dist/sdk/test/execution.js +10 -2
- package/dist/types.d.ts +11 -0
- package/dist/types.js +2 -2
- package/docs/AGENT_UX_CONTRACTS.md +20 -4
- package/docs/COMMANDS.md +29 -14
- package/docs/DEPENDENCY_KIND_CONTRACT.md +31 -3
- package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +98 -0
- package/docs/EXTENSIONS.md +2 -1
- package/docs/README.md +1 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +9 -2
- package/docs/RELATIONSHIP_GRAPH.md +6 -3
- package/docs/TESTING.md +15 -0
- package/marketplace.json +2 -2
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +593 -35
- package/dist/cli-bundle/chunks/chunk-2MA6ZQVZ.js +0 -197
- package/dist/cli-bundle/chunks/chunk-7VHZS727.js +0 -5
- package/dist/cli-bundle/chunks/chunk-OCLPLFAY.js +0 -35
- package/dist/cli-bundle/chunks/chunk-S4IRYKBU.js +0 -13
- package/dist/cli-bundle/focused-chunks/chunk-7WZRLCYF.js +0 -50
- package/dist/cli-bundle/focused-chunks/chunk-EEFKYMDR.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-F2A56DHV.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-FV5ACOK7.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-JEAVFOWM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-NJ63LOP6.js +0 -155
- package/dist/cli-bundle/focused-chunks/chunk-NXRTQ7HI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-TJ7EMJ46.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as w,i as f,j as B,k as j,l as U,o as y,p as X,q as W,r as Y}from"./chunk-
|
|
1
|
+
import{f as w,i as f,j as B,k as j,l as U,o as y,p as X,q as W,r as Y}from"./chunk-D6RBZEJJ.js";import{C as H,a as P,b as D}from"./chunk-2AZT5WXZ.js";import{c as u,f as M,g as z,i as q}from"./chunk-2POVTNLY.js";import{Ua as F,q as L,t as R}from"./chunk-2ARQGDDW.js";import{Ka as g,Ma as K,Z as k}from"./chunk-3LKU6PTJ.js";import{a as N,e as x,f as O,g as A,i as C,l as $}from"./chunk-C4S4A4JJ.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bb16b445-3bd4-520d-becf-c55621bfa186")}catch{}})();var Ce=N,$e=x,Pe=C,De=O,Le=A;function G(e,t,n,s){let r=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),o=n.has(r);return{long:t,...s?{short:s}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:o?"string":"boolean",...o?{value_name:e.value_name??"value"}:{}}}function Q(e,t=[]){let n=new Set(t.flatMap(r=>r.keys)),s=[];for(let r of L(e.map(o=>({...o})))){s.push(G(r,r.flag,n,r.short));for(let o of r.aliases??[])s.push(G(r,o,n))}return s}var Re=Q(R,P),Fe=Q(F,D);(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bed1d1d4-0c1d-59e5-8267-fbe800dfd83b")}catch{}})();var _=["agile","ops","research"],I={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:w.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
|
|
2
2
|
|
|
3
3
|
## I want
|
|
4
4
|
|
|
@@ -23,4 +23,4 @@ import{f as w,i as f,j as B,k as j,l as U,o as y,p as X,q as W,r as Y}from"./chu
|
|
|
23
23
|
|
|
24
24
|
## Conclusion
|
|
25
25
|
`}}],packages:[{spec:"search-advanced",reason:"Semantic retrieval over experiments and findings."},{spec:"templates",reason:"Consistent experiment and hypothesis scaffolds."},{spec:"beads",reason:"Import structured prior work into the tracker."}]}};function ne(e){if(e===void 0)return;let t=p(e);if(t.length===0)throw new Error("Profile name must not be empty.");if(_.includes(t))return t;throw new Error(`Invalid profile "${e}". Allowed: ${_.join(", ")}.`)}function qe(e){let t=ne(e);if(t===void 0)throw new Error(`Profile name is required. Allowed: ${_.join(", ")}.`);return I[t]}function Be(){return _.map(e=>I[e])}function p(e){return e.trim().toLowerCase().replaceAll("-","_")}function J(e){return e.map(t=>t.definition.name).join(", ")}function se(e=[]){let t=_.map(o=>({definition:I[o],source:"builtin"})),n=new Set(_.map(o=>p(o))),s=new Set(n),r=[];for(let o of e){let i=p(o.profile.name);if(n.has(i)){r.push(`Extension "${o.name}" profile "${o.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(s.has(i)){r.push(`Profile "${o.profile.name}" from extension "${o.name}" duplicates an already-registered profile and was ignored.`);continue}s.add(i),t.push({definition:o.profile,source:"extension",package:o.name})}return{profiles:t,warnings:r}}function je(e,t=[]){let{profiles:n,warnings:s}=se(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${J(n)}.`);let r=p(e),o=n.find(i=>p(i.definition.name)===r);if(o===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${J(n)}.`);return{resolved:o,warnings:s}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="933d8f74-c4aa-58d0-bd3b-8932a35d3702")}catch{}})();function re(e){return{types:e.types.length,statuses:e.statuses.length,fields:e.fields.length,workflows:e.workflows.length,config:e.config.length,templates:e.templates.length,packages:e.packages.length}}function Ye(e){return{name:e.name,title:e.title,summary:e.summary,composition:re(e),types:e.types.map(t=>S(()=>u(t).name,()=>String(t.name??""))),statuses:e.statuses.map(t=>S(()=>y(t).id,()=>String(t.id??""))),fields:e.fields.map(t=>S(()=>f(t).key,()=>String(t.key??""))),workflows:e.workflows.map(t=>t.type),config:e.config.map(t=>`${t.key}=${t.value}`),templates:e.templates.map(t=>t.name),packages:e.packages.map(t=>({spec:t.spec,reason:t.reason}))}}function S(e,t){try{return e()}catch{return t()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be95f220-5f66-5e8c-8447-996696d02e43")}catch{}})();var oe=[{key:"search_provider",path:"search.provider",kind:"string",summary:"Search embedding provider name (e.g. openai, ollama, or an extension provider)."},{key:"search_mutation_refresh_policy",path:"search.mutation_refresh_policy",kind:"string",choices:["cache_only","semantic_configured","semantic_auto"],summary:"Mutation-time search refresh policy: cache_only, semantic_configured, or semantic_auto."},{key:"search_query_expansion_enabled",path:"search.query_expansion.enabled",kind:"boolean",summary:"Enable or disable query expansion for semantic/hybrid search."},{key:"search_query_expansion_provider",path:"search.query_expansion.provider",kind:"string",summary:"Query expansion provider name (built-in openai/ollama or extension provider)."},{key:"search_rerank_enabled",path:"search.rerank.enabled",kind:"boolean",summary:"Enable or disable post-retrieval reranking for hybrid search."},{key:"search_rerank_model",path:"search.rerank.model",kind:"string",summary:"Rerank model name override used by built-in providers."},{key:"search_rerank_top_k",path:"search.rerank.top_k",kind:"integer",min:1,summary:"Number of top hybrid candidates to rerank when rerank is enabled."},{key:"search_embedding_model",path:"search.embedding_model",kind:"string",summary:"Default embedding model name (overrides provider-specific model when set)."},{key:"search_embedding_corpus_max_characters",path:"search.embedding_corpus_max_characters",kind:"integer",min:1,summary:"Maximum semantic corpus characters per item before truncation."},{key:"search_embedding_batch_size",path:"search.embedding_batch_size",kind:"integer",min:1,summary:"Number of items embedded per request batch."},{key:"search_embedding_timeout_ms",path:"search.embedding_timeout_ms",kind:"integer",min:1,summary:"Per-request embedding timeout in milliseconds."},{key:"search_score_threshold",path:"search.score_threshold",kind:"number",summary:"Minimum score for a hit to be returned (0 keeps all matches)."},{key:"search_hybrid_semantic_weight",path:"search.hybrid_semantic_weight",kind:"ratio",summary:"Hybrid mode semantic weight in [0, 1] (1-weight goes to keyword)."},{key:"search_max_results",path:"search.max_results",kind:"integer",min:1,summary:"Default upper bound on search hits when --limit is not supplied."},{key:"search_bm25_k1",path:"search.bm25.k1",kind:"number",min:0,summary:"Offline BM25 term-frequency saturation (k1); higher saturates repeated terms slower (default 1.2)."},{key:"search_bm25_b",path:"search.bm25.b",kind:"ratio",summary:"Offline BM25 document-length normalization (b) in [0, 1]; 0 disables, 1 fully normalizes (default 0.75)."},{key:"openai_base_url",path:"providers.openai.base_url",kind:"string",summary:"OpenAI-compatible API base URL (LM Studio/vLLM also use this)."},{key:"openai_api_key",path:"providers.openai.api_key",kind:"string",summary:"OpenAI-compatible API key."},{key:"openai_model",path:"providers.openai.model",kind:"string",summary:"OpenAI-compatible embedding model name."},{key:"ollama_base_url",path:"providers.ollama.base_url",kind:"string",summary:"Ollama API base URL (typically http://localhost:11434)."},{key:"ollama_model",path:"providers.ollama.model",kind:"string",summary:"Ollama embedding model name (e.g. nomic-embed-text)."},{key:"vector_store_adapter",path:"vector_store.adapter",kind:"string",summary:"Vector store adapter name (lancedb, qdrant, or an extension adapter)."},{key:"vector_store_collection_name",path:"vector_store.collection_name",kind:"string",non_empty:!0,summary:"Vector collection/table name shared by Qdrant and LanceDB adapters."},{key:"qdrant_url",path:"vector_store.qdrant.url",kind:"string",summary:"Qdrant HTTP API URL."},{key:"qdrant_api_key",path:"vector_store.qdrant.api_key",kind:"string",summary:"Qdrant API key (empty if running unauthenticated)."},{key:"lancedb_path",path:"vector_store.lancedb.path",kind:"string",summary:"LanceDB storage path (relative to pm root or absolute)."},{key:"id_prefix",path:"id_prefix",kind:"string",non_empty:!0,summary:'Prefix for generated item IDs (e.g. "pm" produces pm-xxxx).'},{key:"author_default",path:"author_default",kind:"string",non_empty:!0,summary:"Default author recorded on mutations when --author is not supplied."},{key:"mutation_guard_require_attributed_author",path:"mutation_guard.require_attributed_author",kind:"boolean",summary:"Reject mutations whose effective author resolves to unknown."},{key:"mutation_guard_secret_guard",path:"mutation_guard.secret_guard",kind:"string",choices:["off","advise","block"],summary:"Detect credential-shaped mutation content: off, advise, or block."},{key:"mutation_guard_stale_in_progress_hours",path:"mutation_guard.stale_in_progress_hours",kind:"integer",min:1,summary:"Age threshold for unclaimed in-progress work surfaced by health."},{key:"governance_duplicate_detection_mode",path:"governance.duplicate_detection_mode",kind:"string",choices:["off","advisory","strict"],summary:"Create/copy duplicate governance: off, advisory, or strict explicit-bypass enforcement."},{key:"governance_duplicate_detection_threshold",path:"governance.duplicate_detection_threshold",kind:"ratio",summary:"Minimum shared similarity score in [0, 1] for create/copy duplicate governance."},{key:"governance_duplicate_detection_limit",path:"governance.duplicate_detection_limit",kind:"integer",min:0,max:20,summary:"Maximum likely duplicates returned by create/copy governance (0-20)."},{key:"output_default_format",path:"output.default_format",kind:"string",choices:["toon","json"],summary:"Default output format for commands that support it: toon or json."},{key:"ux_deprecation_hints",path:"ux.deprecation_hints",kind:"boolean",summary:"Emit one stderr migration hint for deprecated command aliases."},{key:"locks_ttl_seconds",path:"locks.ttl_seconds",kind:"integer",min:1,summary:"Claim/lock time-to-live in seconds before a stale lock can be reclaimed."},{key:"locks_wait_ms",path:"locks.wait_ms",kind:"integer",min:0,summary:"Bounded jittered wait in milliseconds before a contended item mutation fails with lock_conflict; 0 fails fast. PM_LOCK_WAIT_MS overrides per invocation."},{key:"ids_token_length",path:"ids.token_length",kind:"integer",min:4,max:12,summary:"Random base36 token length for newly minted item ids (4-12, default 4). Raise it to shrink cross-branch id collision odds in concurrent multi-agent workflows (pm-pibw)."},{key:"checkpoints_retention_days",path:"checkpoints.retention_days",kind:"integer",min:1,summary:"Age in days above which pm gc --scope checkpoints prunes bulk-mutation rollback checkpoints."},{key:"schema_unknown_field_policy",path:"schema.unknown_field_policy",kind:"string",choices:["allow","warn","reject"],summary:"How item I/O handles metadata keys not in the field registry: allow, warn, or reject."},{key:"history_compact_policy_enabled",path:"history.compact_policy.enabled",kind:"boolean",summary:"Enable the history-compaction advisory: pm health warns on over-threshold streams."},{key:"history_compact_policy_max_entries",path:"history.compact_policy.max_entries",kind:"integer",min:1,summary:"Entry count above which a history stream is flagged (and the default pm history-compact --all-over threshold)."},{key:"history_compact_policy_trigger",path:"history.compact_policy.trigger",kind:"string",choices:["health_warn","auto"],summary:"History-compaction policy intent: health_warn (advisory only) or auto (scheduled sweeps expected)."}],ie=new Map(oe.flatMap(e=>[[e.key,e],[e.path.toLowerCase().replaceAll("-","_"),e]]));function b(e){if(typeof e!="string")return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length!==0)return ie.get(t)}function ae(e,t){let n=t.trim().toLowerCase();return n==="true"||n==="1"||n==="yes"||n==="on"?{ok:!0,parsed:{descriptor:e,value:!0}}:n==="false"||n==="0"||n==="no"||n==="off"?{ok:!0,parsed:{descriptor:e,value:!1}}:{ok:!1,error:{message:`Config set ${e.key} requires a boolean value (true|false), got "${t}"`}}}function le(e,t,n){return e.non_empty===!0&&n.length===0?{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}}:e.choices&&!e.choices.includes(n)?{ok:!1,error:{message:`Config set ${e.key} must be one of ${e.choices.join("|")}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function de(e,t,n){if(n.length===0)return{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}};let s=Number(n);return Number.isFinite(s)?{ok:!0,value:s}:{ok:!1,error:{message:`Config set ${e.key} requires a finite number, got "${t}"`}}}function ce(e,t,n){return!Number.isInteger(n)||n<0?{ok:!1,error:{message:`Config set ${e.key} requires a non-negative integer, got "${t}"`}}:e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires an integer >= ${e.min}, got "${t}" (the runtime silently ignores 0 here and falls back to the default)`}}:e.max!==void 0&&n>e.max?{ok:!1,error:{message:`Config set ${e.key} requires an integer <= ${e.max}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function me(e,t,n){return n<0||n>1?{ok:!1,error:{message:`Config set ${e.key} requires a number in [0, 1], got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function pe(e,t,n){return e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires a number >= ${e.min}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function v(e,t){if(typeof t!="string")return{ok:!1,error:{message:`Config set ${e.key} requires a string value`}};let n=t.trim();if(e.kind==="boolean")return ae(e,t);if(e.kind==="string")return le(e,t,n);let s=de(e,t,n);return s.ok?e.kind==="integer"?ce(e,t,s.value):e.kind==="ratio"?me(e,t,s.value):pe(e,t,s.value):{ok:!1,error:s.error}}function V(e,t){let n=t.path.split("."),s=e;for(let r of n){if(typeof s!="object"||s===null)return null;s=s[r]}return typeof s=="string"||typeof s=="number"||typeof s=="boolean"?s:null}function Ge(e,t,n){let s=t.path.split("."),r=e;for(let a=0;a<s.length-1;a+=1){let c=s[a],d=r[c];if(typeof d!="object"||d===null||Array.isArray(d)){let l={};r[c]=l,r=l}else r=d}let o=s[s.length-1];return r[o]===n?!1:(r[o]=n,!0)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f9b22df0-7ec2-5d72-bc88-3eb7201a6051")}catch{}})();var at=["profile","types","statuses","fields","workflows","config","templates","packages"],lt=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],ue=new Set(K.flatMap(e=>[g(e.id),...(e.aliases??[]).map(t=>g(t))]).filter(e=>e.length>0)),Z=new Set($.map(e=>e.toLowerCase()));function fe(e,t){e.name.trim().length===0?t.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):e.name!==p(e.name)&&t.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:e.name,message:`Profile name "${e.name}" is not in canonical form; resolution folds it to "${p(e.name)}" (lowercase, hyphens as underscores).`}),e.title.trim().length===0&&t.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),e.summary.trim().length===0&&t.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function ye(e,t){let n=new Set,s=new Set;for(let[r,o]of e.types.entries()){let i;try{i=u(o).name}catch(c){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof o.name=="string"?o.name:`#${r}`,message:k(c)});continue}let a=i.toLowerCase();if(s.has(a)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:i,message:`Item type "${i}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}s.add(a),n.add(a)}return n}function he(e,t){let n=new Set,s=new Set;for(let[r,o]of e.statuses.entries()){let i;try{i=y(o)}catch(a){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof o.id=="string"?o.id:`#${r}`,message:k(a)});continue}if(s.has(i.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:i.id,message:`Status "${i.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}s.add(i.id),n.add(i.id);for(let a of i.aliases??[])n.add(g(a))}return n}function ge(e,t){let n=new Set;for(let[s,r]of e.fields.entries()){let o;try{o=f(r).key}catch(a){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof r.key=="string"?r.key:`#${s}`,message:k(a)});continue}if(n.has(o)){t.push({severity:"error",code:"field_duplicate",dimension:"fields",target:o,message:`Field "${o}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}n.add(o);let i=H(o);i&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:o,message:`Field "${o}" collides with canonical MCP property "${i.property}" owned by ${i.owner}; callers must pass the custom value through ${i.nested_path}.`})}}function _e(e,t,n,s){let r=new Set;for(let[o,i]of e.workflows.entries()){let a=i.type.trim().toLowerCase();if(a.length===0){s.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${o}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}let c=r.has(a);r.add(a),c?s.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:i.type,message:`Workflow type "${i.type}" is declared more than once; the later transition set wins.`}):!Z.has(a)&&!t.has(a)&&s.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:i.type,message:`Workflow governs type "${i.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});let d=new Set;for(let l of i.allowed_transitions){let m=g(l[0]),T=g(l[1]);if(m.length===0||T.length===0){s.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:i.type,message:`Workflow "${i.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(let h of[m,T])ue.has(h)||n.has(h)||d.has(h)||(d.add(h),s.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:h,message:`Workflow "${i.type}" references status "${h}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function ke(e,t){let n=new Set;for(let s of e.config){let r=b(s.key);if(r===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:s.key,message:`Config knob "${s.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}n.has(r.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:r.key,message:`Config knob "${r.key}" is set more than once; the later value silently overwrites the earlier one.`}):n.add(r.key);let o=v(r,s.value);o.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:s.key,message:o.error.message})}}function we(e,t,n){for(let s of e.templates){let r=s.options.type;if(typeof r!="string"||r.trim().length===0)continue;let o=r.trim().toLowerCase();!Z.has(o)&&!t.has(o)&&n.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:s.name,message:`Template "${s.name}" creates type "${r}" which is neither a built-in type nor declared by this profile.`})}}function be(e,t){for(let[n,s]of e.packages.entries())s.spec.trim().length===0&&t.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${n}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function dt(e){let t=[];fe(e,t);let n=ye(e,t),s=he(e,t);ge(e,t),_e(e,n,s,t),ke(e,t),we(e,n,t),be(e,t);let r=t.filter(i=>i.severity==="error").length,o=t.length-r;return{profile:e.name,ok:r===0,findings:t,errorCount:r,warningCount:o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ead1caea-8e8b-5208-9fba-23fb114044b5")}catch{}})();function E(e,t,n,s,r){let o=e,i=[];for(let a of t){let c=s(o),d=r(o,a),l=s(d.file);o=d.file;let m=c===l?"unchanged":d.replaced?"update":"add";i.push({key:n(a),status:m})}return{file:o,changes:i,changed:i.some(a=>a.status!=="unchanged")}}function ee(e){return JSON.stringify(e.map(t=>t.join("\0")).sort())}function ve(e,t){let n=e.map(r=>({...r})),s=[];for(let r of t){let o=n.findIndex(a=>a.type===r.type),i={type:r.type,allowed_transitions:r.allowed_transitions};o<0?(n.push(i),s.push({type:r.type,status:"add"})):ee(n[o].allowed_transitions)===ee(r.allowed_transitions)?s.push({type:r.type,status:"unchanged"}):(n[o]=i,s.push({type:r.type,status:"update"}))}return{changes:s,result:n,changed:s.some(r=>r.status!=="unchanged")}}function Ie(e,t){let n=[];for(let s of e.config){let r=b(s.key);if(r===void 0)throw new Error(`Profile "${e.name}" references unknown config key "${s.key}".`);let o=v(r,s.value);if(!o.ok)throw new Error(`Profile "${e.name}" config ${s.key}: ${o.error.message}`);let i=V(t,r),a=i===null?"add":i===o.parsed.value?"unchanged":"update";n.push({key:r.key,path:r.path,value:o.parsed.value,status:a})}return{changes:n,changed:n.some(s=>s.status!=="unchanged")}}function te(e){let t=Object.entries(e).sort(([n],[s])=>n.localeCompare(s));return JSON.stringify(t)}function Se(e,t){let n=[];for(let s of e.templates){let r=t.get(s.name),o;r===void 0?o="add":te(r)===te(s.options)?o="unchanged":o="update",n.push({name:s.name,options:s.options,status:o})}return{changes:n,changed:n.some(s=>s.status!=="unchanged")}}function yt(e,t){let n=E(M(t.typesRaw),e.types,l=>u(l).name,q,(l,m)=>z(l,u(m))),s=E(X(t.statusesRaw),e.statuses,l=>y(l).id,W,(l,m)=>Y(l,y(m))),r=E(B(t.fieldsRaw),e.fields,l=>f(l).key,j,(l,m)=>U(l,f(m))),o=ve(t.workflows,e.workflows),i=Ie(e,t.settings),a=Se(e,t.templates),c=e.packages.map(l=>({spec:l.spec,reason:l.reason,status:t.installedPackages.has(l.spec)?"installed":"recommended"})),d=n.changed||s.changed||r.changed||o.changed||i.changed||a.changed;return{profile:{name:e.name,title:e.title,summary:e.summary},types:n,statuses:s,fields:r,workflows:o,config:i,templates:a,packages:c,changed:d}}export{Ce as a,$e as b,Pe as c,De as d,Le as e,Q as f,Re as g,Fe as h,_ as i,I as j,ne as k,qe as l,Be as m,se as n,je as o,re as p,Ye as q,oe as r,b as s,v as t,V as u,Ge as v,at as w,lt as x,dt as y,yt as z};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-MB37AYN6.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Db as ot,Hb as ie,Qb as ct,Sb as se,Tb as A,_ as rt,ab as te,l as ee,la as S,sb as ne,tb as it,ub as st,va as De,wb as re}from"./chunk-L5LDSRO2.js";import{G as V,M as X,Sa as Y,ea as C,t as G,u as Ce,w as Ze}from"./chunk-3LKU6PTJ.js";import{d as Z,f as Se}from"./chunk-6S2MO3Q3.js";import{Ra as J,Y as w,Ya as Q,Z as v,Za as B,aa as et,ab as tt,bb as nt,pa as Te}from"./chunk-C4S4A4JJ.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]="3167c288-0bcc-5a66-8aa0-ca5876ed7d36")}catch{}})();function dn(e,t,r,n,i,s){if(e.seen.has(t))return"skip";if(e.cursorFound&&e.affected.length>=s)return"truncate";e.seen.add(t),e.parents.set(t,r.id);let o=r.depth+1;return e.queue.push({id:t,depth:o}),e.cursorFound?(e.affected.push({id:t,distance:o,path:hn(n,t,e.parents)}),"continue"):(e.cursorFound=t===i,"skip")}function at(e,t,r,n){let i=Q("graph impact",{root:e,direction:r,kinds:[...t.kinds??[]].sort(),max_depth:Number.isFinite(n)?n:"unbounded"});return{fingerprint:i,after:t.after===void 0?void 0:tt(t.after,i)}}function N(e,t,r){e.get(t).add(r)}function U(e){return new Map(e.map(t=>[t,new Set]))}function ut(e){for(let t of e)t.sort();return e.sort((t,r)=>r.length-t.length||t[0].localeCompare(r[0]))}function oe(e){if(Array.isArray(e))return e.map(r=>oe(r));if(e===null||typeof e!="object")return e;let t=e.toJSON;return typeof t=="function"?oe(t.call(e)):Object.fromEntries(Object.entries(e).sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>[r,oe(n)]))}function dt(e){return JSON.stringify(oe(e))}function an(e,t,r,n){let i=[{id:e,expanded:!1}];for(;i.length>0;){let s=i.pop();if(s.expanded){n.push(s.id);continue}if(r.has(s.id))continue;r.add(s.id),i.push({id:s.id,expanded:!0});let o=[...t.get(s.id)].sort().reverse();for(let c of o)r.has(c)||i.push({id:c,expanded:!1})}}function un(e,t){let r=new Set,n=[];for(let i of e)r.has(i)||an(i,t,r,n);return n}function ln(e,t){let r=new Set,n=[];for(let i of[...e].reverse()){if(r.has(i))continue;let s=[],o=[i];for(r.add(i);o.length>0;){let c=o.pop();s.push(c);for(let d of t.get(c))r.has(d)||(r.add(d),o.push(d))}n.push(s)}return ut(n)}function lt(e,t){let r=U(e);for(let[n,i]of t)for(let s of i)N(r,s,n);return ln(un(e,t),r)}function fn(e,t){let r=U(e.nodes());for(let n of e.edges()){let i=t.require(n.kind);if(!i.ordering)continue;let s=(i.precedence??"source_before_target")==="source_before_target";N(r,s?n.source:n.target,s?n.target:n.source)}return r}function gn(e,t){let r=new Map(e.map(s=>[s,0]));for(let s of t.values())for(let o of s)r.set(o,r.get(o)+1);let n=e.filter(s=>r.get(s)===0).sort(),i=[];for(;n.length>0;){i.push(n);let s=[];for(let o of n)for(let c of t.get(o)){let d=r.get(c)-1;r.set(c,d),d===0&&s.push(c)}n=s.sort()}return i}function pn(e,t){let r=new Map(e.map(o=>[o,0])),n=new Map;for(let o of e)for(let c of t.get(o)){if(!r.has(c))continue;let d=r.get(o)+1,a=n.get(c);(d>r.get(c)||d===r.get(c)&&(a===void 0||o.localeCompare(a)<0))&&(r.set(c,d),n.set(c,o))}let i=[...e].sort((o,c)=>r.get(c)-r.get(o)||o.localeCompare(c))[0],s=i===void 0?[]:[i];for(;s[0]!==void 0&&n.has(s[0]);)s.unshift(n.get(s[0]));return{depth:Object.fromEntries(r),path:s}}function hn(e,t,r){let n=[t],i=t;for(;i!==e;)i=r.get(i),n.push(i);return n.reverse()}function de(e,t={}){let r=t.registry??C(),n=[...e.nodes()],i=fn(e,r),s=gn(n,i),o=s.flat(),c=o.length===n.length,d=c?[]:lt(n,i).filter(u=>u.length>1||i.get(u[0]).has(u[0])),a=pn(o,i);return{exact:!0,acyclic:c,order:o,layers:s,frontier:s[0]??[],depth:a.depth,criticalPath:a.path,criticalPathLength:Math.max(0,a.path.length-1),cycles:d,provenance:{algorithm:"kahn-longest-path",edgeFamily:"ordering"}}}function mn(e,t,r){let n=U(e.nodes()),i=r===void 0?void 0:new Set(r.map(o=>e.registry().require(o).kind)),s=e.edges();for(let o of s){let c=e.registry().require(o.kind);i!==void 0&&!i.has(o.kind)&&(c.inverse===void 0||!i.has(c.inverse))||N(n,t==="incoming"?o.target:o.source,t==="incoming"?o.source:o.target)}return{adjacency:n,inspectedEdges:s.length}}function _n(e,t,r,n,i,s){let o=ce(e,t,{...r,after:void 0,direction:"incoming",limit:void 0}),c=ce(e,t,{...r,after:void 0,direction:"outgoing",limit:void 0}),d=new Map,a=[...o.affected,...c.affected].sort((g,h)=>g.distance-h.distance||g.id.localeCompare(h.id)||g.path.join("\0").localeCompare(h.path.join("\0")));for(let g of a)d.has(g.id)||d.set(g.id,g);let u=[...d.values()].sort((g,h)=>g.distance-h.distance||g.id.localeCompare(h.id)),f=n===void 0||n===t?-1:u.findIndex(g=>g.id===n);if(n!==void 0&&n!==t&&f<0)throw new TypeError(`Unknown impact cursor item: ${n}`);let l=u.slice(f+1,f+1+i),p=f+1+l.length<u.length;return{root:t,affected:l,exact:!0,truncated:o.truncated||c.truncated||p,...p?{nextCursor:B(s,l.at(-1)?.id??t)}:{},cost:{visitedNodes:o.cost.visitedNodes+c.cost.visitedNodes,inspectedEdges:o.cost.inspectedEdges+c.cost.inspectedEdges}}}function yn(e,t,r){let n=r.direction,i=r.maxDepth??Number.POSITIVE_INFINITY,s=r.limit??Number.POSITIVE_INFINITY,{fingerprint:o,after:c}=at(t,r,n,i),{adjacency:d,inspectedEdges:a}=mn(e,n,r.kinds),u={queue:[{id:t,depth:0}],seen:new Set([t]),parents:new Map,affected:[],cursorFound:c===void 0||c===t},f=0,l=!1,p=!1;e:for(let g=0;g<u.queue.length;g+=1){r.signal?.throwIfAborted();let h=u.queue[g];f+=1;let _=[...d.get(h.id)].sort();if(h.depth>=i){_.some(b=>!u.seen.has(b))&&(l=!0);continue}for(let b of _)if(dn(u,b,h,t,c,s)==="truncate"){l=!0,p=!0;break e}}if(!u.cursorFound)throw new TypeError(`Unknown impact cursor item: ${c}`);return{root:t,affected:u.affected,exact:!0,truncated:l,...p?{nextCursor:B(o,u.affected.at(-1)?.id??t)}:{},cost:{visitedNodes:f,inspectedEdges:a}}}function ce(e,t,r={}){let n=r.direction??"outgoing";if(n!=="both")return yn(e,t,{...r,direction:n});let i=r.maxDepth??Number.POSITIVE_INFINITY,s=r.limit??Number.POSITIVE_INFINITY,{fingerprint:o,after:c}=at(t,r,n,i);return _n(e,t,r,c,s,o)}function ft(e){let t=[...e.nodes()],r=U(t),n=U(t);for(let d of e.edges())N(r,d.source,d.target),N(r,d.target,d.source),N(n,d.source,d.target);let i=[],s=new Set;for(let d of t){if(s.has(d))continue;let a=[],u=[d];for(s.add(d);u.length>0;){let f=u.pop();a.push(f);for(let l of r.get(f))s.has(l)||(s.add(l),u.push(l))}i.push(a)}let o=t.map(d=>({id:d,degree:r.get(d).size})),c=Math.max(0,...o.map(({degree:d})=>d));return{components:ut(i),stronglyConnected:lt(t,n),orphans:o.filter(({degree:d})=>d===0).map(({id:d})=>d),hubs:o.filter(({degree:d})=>d>0&&d===c),exact:!0,provenance:{algorithm:"component-degree",edgeFamily:"all"}}}function zi(e,t){let r=new Map(e.edges.map(i=>[dt(i),i])),n=new Map(t.edges.map(i=>[dt(i),i]));return{fromVersion:e.version,toVersion:t.version,added:[...n].filter(([i])=>!r.has(i)).map(([,i])=>i),removed:[...r].filter(([i])=>!n.has(i)).map(([,i])=>i),unchangedCount:[...r.keys()].filter(i=>n.has(i)).length,exact:!0}}import{createHash as bn}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dea35fb9-9f9f-56ce-afc0-f4dc993012c3")}catch{}})();var wn=64,vn=8;function kn(e,t){let r=(e.dependencies??[]).map(n=>{if(typeof n!="object"||n===null)return"";let i=n;return`${typeof i.kind=="string"?i.kind:"related"}:${typeof i.id=="string"?i.id:""}`}).sort().join(",");return[e.id,e.title,e.status,t(e.status)?"1":"0",typeof e.type=="string"?e.type.trim():"",e.parent??"",e.blocked_by??"",r].join("\0")}function ae(e,t=n=>n==="closed"||n==="canceled",r=C()){let n=e.filter(s=>typeof s?.id=="string"&&s.id.trim().length>0).map(s=>kn(s,t)).sort(),i=r.list().map(s=>et(s)).sort();return bn("sha256").update(n.join("")).update("").update(i.join("")).digest("hex")}function gt(e,t,r){let n=t??r;if(!Number.isInteger(n)||n<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`);return n}var Re=class{#e=new Map;#t;#n;constructor(t={}){this.#t=gt("maxResultsPerWorkspace",t.maxResultsPerWorkspace,wn),this.#n=gt("maxWorkspaces",t.maxWorkspaces,vn)}lookup(t,r,n){let i=this.#e.get(t),s=!0;(i===void 0||i.fingerprint!==r)&&(i={fingerprint:r,assembly:n(),results:new Map},s=!1,!this.#e.has(t)&&this.#e.size>=this.#n&&this.#e.delete(this.#e.keys().next().value)),this.#e.delete(t),this.#e.set(t,i);let o=i,c=this.#t;return{assembly:o.assembly,assemblyReused:s,fingerprint:r,memoize(d,a){let u=o.results.get(d);if(u!==void 0||o.results.has(d))return o.results.delete(d),o.results.set(d,u),{value:structuredClone(u),reused:!0};let f=a();return o.results.size>=c&&o.results.delete(o.results.keys().next().value),o.results.set(d,structuredClone(f)),{value:f,reused:!1}}}}clear(){this.#e.clear()}},pt=new Re;function ue(){return pt}function Xi(){pt.clear()}(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]="afdba960-ae43-52be-b21d-282dac1f22ff")}catch{}})();var xn=["prerequisite","dependent","ancestor","descendant","provenance","related"],En=new TextEncoder;function Ae(e,t,r){let n=e??t;if(!Number.isInteger(n)||n<1)throw new TypeError(`Relationship context ${r} must be positive`);return n}function le(e){return Math.max(1,Math.ceil(En.encode(JSON.stringify(e)).byteLength/4))}function Ne(e,t,r){let n=r.resolve(e.kind);if(n?.ordering){let s=(n.precedence??"source_before_target")==="source_before_target"?e.source:e.target;return t===s?"prerequisite":"dependent"}if(n?.hierarchy){let s=n.hierarchyDirection==="source_parent"?e.source:e.target;return t===s?"ancestor":"descendant"}return e.kind==="discovered_from"||e.kind==="incident_from"?"provenance":"related"}function In(e,t,r,n){let i=e.filter(s=>s.source===t&&s.target===r||s.target===t&&s.source===r).map(s=>Ne(s,r,n));return[...new Set(i)].sort()}function Cn(e){return xn.find(t=>e.includes(t))}function Tn(e,t,r,n){let i=n.direction??"both",s=n.maxDepth??3;if(!Number.isInteger(s)||s<0)throw new TypeError("Relationship context maxDepth must be non-negative");let o=new Set([t]),c=[{id:t,distance:0}],d=[],a=0,u=!1;for(let f=0;f<c.length;f+=1){n.signal?.throwIfAborted();let l=c[f];if(l.distance>=s&&u)continue;let p=e.neighborEdges(l.id,{direction:i,kinds:n.kinds,signal:n.signal});if(a+=p.meta.inspectedEdges,l.distance>=s){p.value.some(g=>!o.has(g.id))&&(u=!0);continue}for(let{id:g,edge:h}of p.value){if(o.has(g))continue;o.add(g);let _={id:g,distance:l.distance+1,via:l.id,role:Ne(h,g,r)};d.push(_),c.push(_)}}return d.sort((f,l)=>f.distance-l.distance||f.id.localeCompare(l.id)),{rows:d,visitedNodes:c.length,inspectedEdges:a,depthTruncated:u}}function Sn(e,t,r,n){let i={prerequisite:0,dependent:0,ancestor:0,descendant:0,provenance:0,related:0},s=e.neighborEdges(t,{direction:n.direction??"both",kinds:n.kinds,signal:n.signal}).value;for(let{id:o,edge:c}of s)i[Ne(c,o,r)]+=1;return{directEdges:i,directTotal:s.length,rootEdges:s.map(({edge:o})=>o)}}function Dn(e){let t=[],r=e.initialTokens;for(let n of e.candidates){if(t.length>=e.nodeLimit)break;let i=n.distance===1?In(e.rootEdges,e.rootId,n.id,e.registry):[],s={...e.details.get(n.id)??{id:n.id},distance:n.distance,role:i.length>0?Cn(i):n.role,via:n.via,reasons:i.length>0?i:[`${n.role} via ${n.via} (depth ${n.distance})`]},o=le(s);if(r+o>e.tokenBudget)break;t.push(s),r+=o}if(e.candidates.length>0&&t.length===0)throw new TypeError("Relationship context tokenBudget cannot fit one node");return{nodes:t,usedTokens:r}}function Rn(e){let t=e.options.kinds?new Set(e.options.kinds.map(s=>e.registry.require(s).kind)):void 0,r=e.graph.edges().filter(s=>{if(!e.included.has(s.source)||!e.included.has(s.target))return!1;if(t===void 0||t.has(s.kind))return!0;let o=e.registry.resolve(s.kind)?.inverse;return o!==void 0&&t.has(o)}),n=[],i=e.initialTokens;for(let s of r){if(n.length>=e.edgeLimit)break;let o=le(s);if(i+o>e.tokenBudget)break;n.push(s),i+=o}return{edges:n,usedTokens:i,candidateCount:r.length}}function ht(e,t,r,n={}){if(!e.nodes().includes(t))throw new TypeError(`Relationship node not found: ${t}`);let i=Ae(n.nodeLimit,20,"nodeLimit"),s=Ae(n.edgeLimit,40,"edgeLimit"),o=Ae(n.tokenBudget,1200,"tokenBudget"),c=n.registry??C(),d=new Map(r.map(R=>[R.id,R])),a=d.get(t)??{id:t},{evidence:u=[],...f}=a,l=[...u],p=Tn(e,t,c,n),{rootEdges:g,...h}=Sn(e,t,c,n),_=Q("relationship-context",{rootId:t,direction:n.direction??"both",kinds:[...n.kinds??[]].sort(),maxDepth:n.maxDepth??3}),b=nt(p.rows,n.cursor,_,({id:R})=>R),m=p.rows.slice(b),y=le(f)+le(l);if(y>o)throw new TypeError("Relationship context tokenBudget cannot fit root and evidence");let I=Dn({candidates:m,details:d,rootEdges:g,rootId:t,registry:c,nodeLimit:i,tokenBudget:o,initialTokens:y}),{nodes:k}=I,H=new Set([t,...k.map(({id:R})=>R)]),$=Rn({graph:e,included:H,options:n,registry:c,edgeLimit:s,tokenBudget:o,initialTokens:I.usedTokens}),{edges:F,usedTokens:on}=$,W=b+k.length,Ee=W<p.rows.length,Je=k.at(-1),Ie=$.candidateCount-F.length,Qe=p.depthTruncated||Ee||Ie>0,cn={rootId:t,...f.status===void 0?{}:{rootStatus:f.status},...h,discoveredNodes:p.rows.length,returnedNodes:k.length,returnedEdges:F.length,omittedNodes:p.rows.length-W,omittedEdges:Ie,evidenceCount:l.length,hasMore:Ee};return{root:f,summary:cn,nodes:k,edges:F,evidence:l,meta:{exact:!0,truncated:Qe,completeness:Qe?"truncated":"complete",nodeLimit:i,edgeLimit:s,tokenBudget:o,usedTokens:on,visitedNodes:p.visitedNodes,inspectedEdges:p.inspectedEdges,omittedNodes:p.rows.length-W,omittedEdges:Ie,...Ee&&Je?{nextCursor:B(_,Je.id,W-1)}:{}}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ac2b3cd9-5a98-5fea-888c-e96de8cd593d")}catch{}})();var An=5,Nn=1e4,Ln=8;function Le(e,t){if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new TypeError(`Invalid path ${e} bound: ${String(t)}`)}function fe(e,t){return t.hierarchyDirection==="target_parent"?e.target:e.source}function q(e,t){return(t.precedence??"source_before_target")==="target_before_source"?e.target:e.source}function ge(e,t){let r=q(e,t);return{predecessor:r,successor:r===e.source?e.target:e.source}}function On(e,t,r){if(t===void 0)return;let n=e.registry(),i=new Set;for(let s of t){let o=n.require(s),c=o.traversal;if(c==="association")throw new TypeError(`Relationship kind ${o.kind} uses association traversal; use graph impact --direction both`);if(c!==r&&c!=="semantic"){let d=c==="hierarchy"?"graph ancestors or graph descendants":"graph predecessors or graph successors";throw new TypeError(`Relationship kind ${o.kind} uses ${c} traversal; use ${d}`)}i.add(o.kind)}return i}function Mn(e,t,r,n,i){let s=e.registry(),o=e.neighborEdges(t,{direction:"both",...r===void 0?{}:{kinds:[...r]}}),c=[],d=new Set;for(let a of o.value){let u=s.require(a.edge.kind);r===void 0&&!u[n]||i(a,u,t)&&(d.has(a.id)||(d.add(a.id),c.push(a.id)))}return{neighbors:c,inspectedEdges:o.meta.inspectedEdges}}function Pn(e,t,r,n,i,s){if(t>=r)return e.neighbors.some(o=>!s.seen.has(o))&&(s.truncated=!0),!1;for(let o of e.neighbors)if(!s.seen.has(o)){if(s.seen.add(o),s.queue.push({id:o,depth:t+1}),!s.resumed){o===i&&(s.resumed=!0);continue}if(s.value.length>=n)return s.truncated=!0,!0;s.value.push(o)}return!1}function pe(e,t,r,n,i){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);let s=On(e,r.kinds,n),o=r.limit??Number.POSITIVE_INFINITY,c=r.maxDepth??Number.POSITIVE_INFINITY,d=r.after,a={seen:new Set([t]),value:[],queue:[{id:t,depth:0}],resumed:d===void 0,truncated:!1},u=0,f=0;for(let l=0;l<a.queue.length;l+=1){r.signal?.throwIfAborted();let p=a.queue[l];u+=1;let g=Mn(e,p.id,s,n,i);if(f+=g.inspectedEdges,Pn(g,p.depth,c,o,d,a))break}if(!a.resumed)throw new TypeError(`Traversal cursor not found in sequence: ${d}`);return{value:a.value,meta:{visitedNodes:u,inspectedEdges:f,truncated:a.truncated,nextCursor:a.value.at(-1)}}}function mt(e,t){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`)}function _t(e,t,r,n,i){let s=e.neighborEdges(t.nodes.at(-1),{direction:n,...r.kinds===void 0?{}:{kinds:r.kinds}});return i.inspectedEdges+=s.meta.inspectedEdges,s.value.filter(o=>!t.nodeSet.has(o.id))}function jn(e,t,r,n,i,s,o){for(let c of _t(e,t,n,i,o)){let d=[...t.nodes,c.id],a=new Set(t.nodeSet).add(c.id),u=[...t.edges,c.edge];if(c.id===r){if(o.value.push({nodes:d,edges:u,length:u.length}),o.value.length>=s)return!0}else o.queue.push({nodes:d,nodeSet:a,edges:u})}return!1}function yt(e,t,r={}){return pe(e,t,r,"hierarchy",(n,i)=>fe(n.edge,i)===n.id)}function bt(e,t,r={}){return pe(e,t,r,"hierarchy",(n,i,s)=>fe(n.edge,i)===s)}function wt(e,t,r={}){return pe(e,t,r,"ordering",(n,i)=>q(n.edge,i)===n.id)}function vt(e,t,r={}){return pe(e,t,r,"ordering",(n,i,s)=>q(n.edge,i)===s)}function $n(e,t,r,n,i,s,o,c){let d={value:[],queue:[{nodes:[t],nodeSet:new Set([t]),edges:[]}],inspectedEdges:0},a=0,u=!1,f=i+1;for(let l=0;l<d.queue.length;l+=1){if(n.signal?.throwIfAborted(),d.value.length>=f||a>=s){u=!0;break}let p=d.queue[l];if(a+=1,p.edges.length>=o){_t(e,p,n,c,d).length>0&&(u=!0);continue}if(jn(e,p,r,n,c,f,d)){u=!0;break}}return{value:d.value.slice(0,i),meta:{visitedNodes:a,inspectedEdges:d.inspectedEdges,truncated:u}}}function kt(e,t,r,n={}){mt(e,t),mt(e,r);let i=n.maxPaths??An,s=n.maxVisitedPaths??Nn,o=n.maxDepth??Ln;Le("maxPaths",i),Le("maxVisitedPaths",s),Le("maxDepth",o);let c=n.direction??"outgoing";n.signal?.throwIfAborted();for(let d of n.kinds??[])e.registry().require(d);return t===r?i===0?{value:[],meta:{visitedNodes:1,inspectedEdges:0,truncated:!0}}:{value:[{nodes:[t],edges:[],length:0}],meta:{visitedNodes:1,inspectedEdges:0,truncated:!1}}:$n(e,t,r,n,i,s,o,c)}(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]="24898402-1568-5b05-9072-f89dd91f25a6")}catch{}})();var Fn=16,Gn=2,Bn=8;function he(e,t){if(!Number.isInteger(t)||t<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`)}function me(e,t,r){let n=e.registry(),i=t===void 0?void 0:new Set(t.map(s=>n.require(s).kind));for(let s of e.edges()){if(s.source===s.target)continue;let o=n.require(s.kind);i!==void 0&&!(i.has(o.kind)||o.inverse!==void 0&&i.has(o.inverse))||r(s,o)}}function Un(e,t){let r=new Map;me(e,t,n=>{xt(r,n.source,n.target),xt(r,n.target,n.source)});for(let n of r.values())n.sort();return r}function xt(e,t,r){let n=e.get(t);n===void 0?e.set(t,[r]):n.push(r)}function qn(e,t){let r=new Map;for(let s of e){let o=t.get(s);r.set(o,(r.get(o)??0)+1)}let n,i=0;for(let[s,o]of r)(o>i||o===i&&s<n)&&(n=s,i=o);return n}function zn(e,t){let r=new Map;for(let[i,s]of e){let o=r.get(s);o===void 0?r.set(s,[i]):o.push(i)}let n=[];for(let i of r.values())i.length<t||(i.sort(),n.push({representative:i[0],size:i.length,members:i}));return n.sort((i,s)=>s.size-i.size||i.representative.localeCompare(s.representative))}function Et(e,t={}){let r=t.maxIterations??Fn,n=t.minSize??Gn;he("maxIterations",r),he("minSize",n);let i=Un(e,t.kinds),s=e.nodes(),o=new Map(s.map(f=>[f,f])),c=0,d=!1,a=0,u=0;for(;c<r&&!d;){t.signal?.throwIfAborted(),c+=1,d=!0;for(let f of s){a+=1;let l=i.get(f);if(l===void 0)continue;u+=l.length;let p=qn(l,o);p!==o.get(f)&&(o.set(f,p),d=!1)}}return{value:{communities:zn(o,n),iterations:c,converged:d},meta:{visitedNodes:a,inspectedEdges:u,truncated:!d}}}function _e(e){return e.direction==="directed"&&(e.ordering||e.hierarchy)}function ye(e){return e.inverse!==void 0&&e.inverse<e.kind?e.inverse:e.kind}function Oe(e,t){return(t.hierarchy?fe(e,t):e.source===q(e,t)?e.target:e.source)===e.target?{from:e.source,to:e.target}:{from:e.target,to:e.source}}function Kn(e,t){if(t===void 0)return;let r=e.registry(),n=new Set;for(let i of t){let s=r.require(i);if(!_e(s))throw new TypeError(`Relationship kind ${s.kind} is not a directed ordering or hierarchy kind`);n.add(ye(s))}return n}function Hn(e,t){let r=e.registry(),n=new Map;for(let i of e.edges()){let s=r.require(i.kind);if(!_e(s))continue;let o=ye(s);if(t!==void 0&&!t.has(o))continue;let c=Oe(i,s);if(c.from===c.to)continue;let d=n.get(o);d===void 0&&(d={adjacency:new Map,records:[]},n.set(o,d));let a=d.adjacency.get(c.from);a===void 0?d.adjacency.set(c.from,new Set([c.to])):a.add(c.to),d.records.push({...c,edge:i})}return n}function Wn(e){let t=new Map;for(let[r,n]of e.adjacency)t.set(r,[...n].sort());return t}function Vn(e,t,r,n){let i=[n];for(let s=r;s!==t;s=e.get(s))i.push(s);return i.push(t),i.reverse()}function Xn(e,t,r,n,i,s){for(let o of e.get(r.id)??[])if(s.inspectedEdges+=1,!(r.depth===0&&o===t.to)&&!n.has(o)){if(n.set(o,r.id),o===t.to)return Vn(n,t.from,r.id,o);i.push({id:o,depth:r.depth+1})}}function Yn(e,t,r,n){let i=new Map([[t.from,t.from]]),s=[{id:t.from,depth:0}];for(let o=0;o<s.length;o+=1){let c=s[o];if(n.visitedNodes+=1,c.depth>=r)continue;let d=Xn(e,t,c,i,s,n);if(d!==void 0)return d}}function L(e,t={}){let r=t.maxDepth??Bn;he("maxDepth",r),t.limit!==void 0&&he("limit",t.limit);let n=t.limit??Number.POSITIVE_INFINITY,i=Kn(e,t.kinds),s=Hn(e,i),o=[],c={visitedNodes:0,inspectedEdges:0},d=!1;e:for(let a of[...s.keys()].sort()){let u=s.get(a),f=Wn(u);for(let l of u.records){t.signal?.throwIfAborted();let p=Yn(f,l,r,c);if(p!==void 0){if(o.length>=n){d=!0;break e}o.push({edge:l.edge,witness:p})}}}return{value:o,meta:{visitedNodes:c.visitedNodes,inspectedEdges:c.inspectedEdges,truncated:d}}}function Jn(e,t,r,n,i){let s=new Set,o=[];for(let c of r){if(c.id===e||s.has(c.id))continue;if(!i.seen.has(c.id)){if(t>=n){i.truncated=!0;continue}i.seen.add(c.id),i.queue.push({id:c.id,depth:t+1})}s.add(c.id),o.push(c.id);let d=i.predecessors.get(c.id);d===void 0&&(d=new Set,i.predecessors.set(c.id,d)),d.add(e)}return o}function Qn(e,t,r){let n=r.direction??"outgoing",i=r.maxDepth??Number.POSITIVE_INFINITY,s=[],o=new Map,c={seen:new Set([t]),queue:[{id:t,depth:0}],predecessors:new Map,truncated:!1},d=0;for(let a=0;a<c.queue.length;a+=1){r.signal?.throwIfAborted();let{id:u,depth:f}=c.queue[a];s.push(u);let l=e.neighborEdges(u,{direction:n,...r.kinds===void 0?{}:{kinds:r.kinds}});d+=l.meta.inspectedEdges,o.set(u,Jn(u,f,l.value,i,c))}return{order:s,successors:o,predecessors:c.predecessors,inspectedEdges:d,truncated:c.truncated}}function Zn(e,t){let r=[],n=new Set([t]),i=[{id:t,index:0}];for(;i.length>0;){let s=i.at(-1),o=e.successors.get(s.id);if(s.index<o.length){let c=o[s.index];s.index+=1,n.has(c)||(n.add(c),i.push({id:c,index:0}))}else r.push(s.id),i.pop()}return r.reverse()}function er(e,t,r,n){let i=e,s=t;for(;i!==s;){for(;n.get(i)>n.get(s);)i=r.get(i);for(;n.get(s)>n.get(i);)s=r.get(s)}return i}function tr(e,t,r){let n;for(let i of[...e].sort())t.has(i)&&(n=n===void 0?i:er(n,i,t,r));return n}function nr(e,t,r,n,i){let s=new Map([[t,t]]),o=!0;for(;o;){o=!1;for(let c of r){if(i?.throwIfAborted(),c===t)continue;let d=tr(e.predecessors.get(c),s,n);d!==void 0&&s.get(c)!==d&&(s.set(c,d),o=!0)}}return s}function It(e,t,r={}){if(!e.hasNode(t))throw new TypeError(`Relationship node not found: ${t}`);if(r.maxDepth!==void 0&&(!Number.isInteger(r.maxDepth)||r.maxDepth<0))throw new TypeError(`Invalid maxDepth bound: ${String(r.maxDepth)}`);let n=Qn(e,t,r),i=Zn(n,t),s=new Map(i.map((a,u)=>[a,u])),o=nr(n,t,i,s,r.signal),c=new Map(i.map(a=>[a,1]));for(let a=i.length-1;a>=0;a-=1){let u=i[a];if(u===t)continue;let f=o.get(u);c.set(f,c.get(f)+c.get(u))}let d=i.filter(a=>a!==t).map(a=>({id:a,idom:o.get(a),dominatedCount:c.get(a)-1})).sort((a,u)=>u.dominatedCount-a.dominatedCount||a.id.localeCompare(u.id));return{value:{root:t,reachableCount:n.order.length,rows:d},meta:{visitedNodes:n.order.length,inspectedEdges:n.inspectedEdges,truncated:n.truncated}}}(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]="348c9246-2fb9-529e-b627-f60c901a6cf2")}catch{}})();function Ct(e){return Math.round(e*1e6)/1e6}function Tt(e,t,r){let n=e.get(t);n===void 0?e.set(t,new Set([r])):n.add(r)}function St(e,t){let r=new Map(e.nodes().map(i=>[i,new Set]));me(e,t,i=>{r.get(i.source).add(i.target),r.get(i.target).add(i.source)});let n=new Map;for(let[i,s]of r)n.set(i,[...s].sort());return n}function rr(e,t){let r=new Map,n=new Map;return me(e,t,(i,s)=>{if(!s.ordering)return;let{predecessor:o,successor:c}=ge(i,s);Tt(n,o,c),Tt(r,c,o)}),{incoming:r,outgoing:n}}function ir(e,t,r){let n=new Map([[e,0]]),i=new Map([[e,1]]),s=new Map,o=[],c=[e],d=0,a=0;for(let u=0;u<c.length;u+=1){let f=c[u];r.visitedNodes+=1,o.push(f);let l=n.get(f);f!==e&&(d+=1,a+=l);for(let p of t.get(f))if(r.inspectedEdges+=1,n.has(p)||(n.set(p,l+1),c.push(p)),n.get(p)===l+1){i.set(p,(i.get(p)??0)+i.get(f));let g=s.get(p);g===void 0?s.set(p,[f]):g.push(f)}}return{stack:o,sigma:i,predecessors:s,reachableCount:d,distanceSum:a}}function sr(e,t,r){let n=new Map;for(let i=e.stack.length-1;i>=0;i-=1){let s=e.stack[i],o=(1+(n.get(s)??0))/e.sigma.get(s);for(let c of e.predecessors.get(s)??[])n.set(c,(n.get(c)??0)+e.sigma.get(c)*o);s!==t&&r.set(s,(r.get(s)??0)+(n.get(s)??0))}}function or(e,t){return t<=1||e.reachableCount===0?0:e.reachableCount/(t-1)*(e.reachableCount/e.distanceSum)}function cr(e,t,r,n,i){return{id:e,degree:t.get(e).length,inDegree:r.incoming.get(e)?.size??0,outDegree:r.outgoing.get(e)?.size??0,betweenness:Ct((n.get(e)??0)/2),closeness:Ct(i.get(e))}}function Dt(e,t={}){let r=St(e,t.kinds),n=rr(e,t.kinds),i=e.nodes(),s=new Map,o=new Map,c={visitedNodes:0,inspectedEdges:0};for(let u of i){t.signal?.throwIfAborted();let f=ir(u,r,c);o.set(u,or(f,i.length)),sr(f,u,s)}let d=0;for(let u of r.values())d+=u.length;let a=i.map(u=>cr(u,r,n,s,o)).sort((u,f)=>f.betweenness-u.betweenness||f.degree-u.degree||u.id.localeCompare(f.id));return{value:{nodeCount:i.length,edgeCount:d/2,rows:a},meta:{visitedNodes:c.visitedNodes,inspectedEdges:c.inspectedEdges,truncated:!1}}}function dr(e,t){return e<=t?{source:e,target:t}:{source:t,target:e}}function ar(e,t,r){let i=t.get(e.node)[e.neighborIndex];if(e.neighborIndex+=1,r.inspectedEdges+=1,i!==e.parent){if(r.discovery.has(i)){r.low.set(e.node,Math.min(r.low.get(e.node),r.discovery.get(i)));return}return e.children+=1,r.discovery.set(i,r.timer),r.low.set(i,r.timer),r.timer+=1,{node:i,parent:e.node,neighborIndex:0,children:0}}}function ur(e,t,r){if(e.parent===null){e.children>1&&r.articulation.add(e.node);return}let n=e.parent,i=r.low.get(e.node);r.low.set(n,Math.min(r.low.get(n),i)),n!==t&&i>=r.discovery.get(n)&&r.articulation.add(n),i>r.discovery.get(n)&&r.bridges.push(dr(n,e.node))}function lr(e,t,r,n){r.discovery.set(e,r.timer),r.low.set(e,r.timer),r.timer+=1;let i=[{node:e,parent:null,neighborIndex:0,children:0}];for(;i.length>0;){n?.throwIfAborted();let s=i.at(-1);if(s.neighborIndex<t.get(s.node).length){let o=ar(s,t,r);o!==void 0&&i.push(o)}else ur(s,e,r),i.pop()}}function be(e,t={}){let r=St(e,t.kinds),n={discovery:new Map,low:new Map,timer:0,articulation:new Set,bridges:[],inspectedEdges:0};for(let i of e.nodes())n.discovery.has(i)||lr(i,r,n,t.signal);return{value:{articulationPoints:[...n.articulation].sort(),bridges:n.bridges.sort((i,s)=>i.source.localeCompare(s.source)||i.target.localeCompare(s.target))},meta:{visitedNodes:n.discovery.size,inspectedEdges:n.inspectedEdges,truncated:!1}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f155ac72-64eb-5316-b016-954abd48c0e7")}catch{}})();function fr(e){let t=e.registry(),r=new Map,n=new Set;for(let i of e.edges()){let s=t.require(i.kind);if(!s.ordering)continue;let{predecessor:o,successor:c}=ge(i,s);if(n.add(o),n.add(c),o===c)continue;let d=r.get(o);d===void 0?r.set(o,new Set([c])):d.add(c)}return{forward:r,participants:n}}function gr(e,t,r,n){if(e===void 0)return n;let i=n;for(let s of e)t.has(s)&&(i=Math.min(i,r.get(s)));return i}function pr(e,t,r){let n=r-t;return{id:e,earliestStart:t,earliestFinish:t+1,latestStart:r,latestFinish:r+1,slack:n,critical:n===0}}function hr(e,t,r,n,i){let s=new Map;for(let o=e.length-1;o>=0;o-=1){let c=e[o],d=gr(t.forward.get(c),n,s,i);s.set(c,d-1)}return e.map(o=>pr(o,r[o],s.get(o))).sort((o,c)=>o.slack-c.slack||o.earliestStart-c.earliestStart||o.id.localeCompare(c.id))}function Rt(e,t={}){t.signal?.throwIfAborted();let r=de(e,{registry:e.registry()}),n=fr(e),i=new Set(r.order),s=r.order.filter(a=>n.participants.has(a)),o=s.reduce((a,u)=>Math.max(a,r.depth[u]+1),0),c=hr(s,n,r.depth,i,o),d=c.length>0;return{exact:!0,acyclic:r.acyclic,makespan:o,scheduledCount:c.length,criticalPath:d?r.criticalPath:[],criticalPathLength:d?r.criticalPathLength:0,cycles:r.cycles,rows:c,provenance:{algorithm:"critical-path-method",edgeFamily:"ordering",weighting:"unit"}}}(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]="a8bc0ebd-e5e4-57f3-8e6c-417f9809eb72")}catch{}})();var O=["missing_reference_active","missing_reference_terminal","legacy_no_blocker_sentinel","ordering_cycle","legacy_ordering_cycle","ordering_storage_contradiction","legacy_ordering_storage_contradiction","hierarchy_cycle","legacy_hierarchy_cycle","hierarchy_cardinality_violation","legacy_hierarchy_cardinality_violation","hierarchy_direction_violation","legacy_hierarchy_direction_violation","duplicate_edge","legacy_duplicate_edge","duplicate_dependency_row","legacy_duplicate_dependency_row","stale_lifecycle_block","isolated_active_node","sparse_active_node"];(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]="27de9c62-434c-566d-a000-54eddb9a16a9")}catch{}})();var mr=25,_r="milestone",yr="outcome milestone:",br=new Set(["discovered_from","incident_from","recurs_from","supersedes","verifies"]);function $e(e){return br.has(e)}var At={error:0,warning:1,info:2};function Nt(e){return new Set((e??[]).filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()))}function M(e,t,r,n,i,s,o,c){let d=[...i].sort((a,u)=>a.localeCompare(u));return{code:e,severity:t,policy:r,message:n(d.length),count:d.length,sample:d.slice(0,s),sample_truncated:d.length>s,remediation:o,...c===void 0?{}:{evidence:[...c].sort((a,u)=>a.localeCompare(u)).slice(0,s)}}}function wr(e,t){return e.cycles.map(r=>M(r.legacy_terminal?"legacy_hierarchy_cycle":"hierarchy_cycle",r.legacy_terminal?"info":"error","Structural hierarchy must be acyclic across scalar and registered dependency relationships.",n=>`${n} items participate in one hierarchy cycle.`,r.item_ids,t,r.legacy_terminal?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove or retype one exact hierarchy relation before continuing mutation."))}function Lt(e,t,r){let n=e.cardinality_violations.filter(i=>i.legacy_terminal===r);return n.length===0?[]:[M(r?"legacy_hierarchy_cardinality_violation":"hierarchy_cardinality_violation",r?"info":"error","Every structural child must resolve to at most one logical parent across all hierarchy spellings.",i=>`${i} child item${i===1?"":"s"} resolve to multiple hierarchy parents.`,n.map(i=>i.child_id),t,r?"Preserve historical rows unless an explicit legacy repair is approved.":"Remove the exact surplus hierarchy rows so each child has one parent.",n.map(i=>`${i.child_id} <- ${i.parent_ids.join(", ")}`))]}function Ot(e,t,r){let n=e.divergences.filter(i=>i.legacy_terminal===r);return n.length===0?[]:[M(r?"legacy_hierarchy_direction_violation":"hierarchy_direction_violation",r?"info":"error","Scalar parent metadata and dependency-backed hierarchy rows must resolve to the same logical parent.",i=>`${i} child item${i===1?"":"s"} have divergent hierarchy storage surfaces.`,n.map(i=>i.child_id),t,r?"Preserve historical rows unless an explicit legacy repair is approved.":"Align the scalar parent and exact dependency rows to one canonical parent.",n.map(i=>`${i.child_id}: scalar=${i.scalar_parent_id} dependencies=${i.dependency_parent_ids.join(",")}`))]}function vr(e,t){let r=se(e);return r?[...wr(r,t),...Lt(r,t,!1),...Lt(r,t,!0),...Ot(r,t,!1),...Ot(r,t,!0)]:[]}function kr(e){let t=e.graph.registry(),r=new Map;for(let n of e.graph.edges()){let i=t.require(n.kind);if(!i.ordering)continue;let[s,o]=(i.precedence??"source_before_target")==="target_before_source"?[n.target,n.source]:[n.source,n.target],c=r.get(s);c?c.push(o):r.set(s,[o])}for(let n of r.values())n.sort((i,s)=>i.localeCompare(s));return r}function Pt(e,t){t.indexes.set(e,t.nextIndex),t.lowLinks.set(e,t.nextIndex),t.nextIndex+=1,t.stack.push(e),t.onStack.add(e)}function xr(e,t,r,n){let i=r.get(e.node)??[];if(e.neighborIndex>=i.length)return!1;let s=i[e.neighborIndex];return e.neighborIndex+=1,n.indexes.has(s)?n.onStack.has(s)&&n.lowLinks.set(e.node,Math.min(n.lowLinks.get(e.node),n.indexes.get(s))):(Pt(s,n),t.push({node:s,neighborIndex:0})),!0}function Er(e,t,r,n){t.pop();let i=t.at(-1);if(i&&n.lowLinks.set(i.node,Math.min(n.lowLinks.get(i.node),n.lowLinks.get(e.node))),n.lowLinks.get(e.node)!==n.indexes.get(e.node))return;let s=[];for(;;){let o=n.stack.pop();if(n.onStack.delete(o),s.push(o),o===e.node)break}(s.length>1||s.length===1&&r.get(s[0])?.includes(s[0]))&&n.components.push(s.sort((o,c)=>o.localeCompare(c)))}function Ir(e){let t={indexes:new Map,lowLinks:new Map,onStack:new Set,stack:[],components:[],nextIndex:0},r=[...e.keys()].sort((n,i)=>n.localeCompare(i));for(let n of r){if(t.indexes.has(n))continue;let i=[{node:n,neighborIndex:0}];for(Pt(n,t);i.length>0;){let s=i.at(-1);xr(s,i,e,t)||Er(s,i,e,t)}}return t.components.sort((n,i)=>n[0].localeCompare(i[0]))}function Me(e){return`${e.holder_id} -> ${e.target_id} (${e.kind})`}function x(e,t,r,n,i,s,o,c){t.length!==0&&e.push(M(n,i,s,o,t,r,c))}function Cr(e,t,r){let n=[],i=[...e.dangling.active,...e.dangling.legacy_terminal].filter(s=>!s.no_active_blocker_sentinel);return x(n,i.filter(s=>!t(s.holder_status)).map(Me),r,"missing_reference_active","error","Active items must not reference absent targets; missing prerequisites distort scheduling.",s=>`${s} active dangling reference(s) to absent items`,"Restore or re-create the referenced item, or remove/retype the reference on the holder."),x(n,i.filter(s=>t(s.holder_status)).map(Me),r,"missing_reference_terminal","info","Terminal items may retain historical references, but absent targets remain unexplainable context.",s=>`${s} terminal dangling reference(s) to absent items`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),x(n,e.dangling.no_active_blocker_sentinels.map(Me),r,"legacy_no_blocker_sentinel","info","The pre-structured-dependency no-active-blocker sentinel is retired; real edges carry blocker state.",s=>`${s} legacy no-active-blocker sentinel reference(s)`,"Delete the sentinel reference; blocker state is derived from blocked_by edges."),n}function je(e,t){let r=t.get(e);return r?!r.terminal:!0}function jt(e){return`${e.holder_id} -> ${e.target_id} (blocked_by scalar + ${e.dependency_kind} dependency)`}function Tr(e,t){let r=[],n=[];for(let s of e.orderingContradictions??[])(s.legacy_terminal?n:r).push(jt(s));let i=[];return x(i,r,t,"ordering_storage_contradiction","error","A scalar blocker and same-target structured ordering row must not assert opposite precedence.",s=>`${s} active scalar-versus-structured ordering contradiction(s)`,"Remove the structured dependency row that points the holder before its scalar blocker, or replace both representations with one unambiguous ordering edge."),x(i,n,t,"legacy_ordering_storage_contradiction","info","Terminal scalar-versus-structured ordering contradictions are exact historical storage defects with no live scheduling effect.",s=>`${s} terminal scalar-versus-structured ordering contradiction(s)`,"Remove the contradictory blocks dependency row in a dedicated changelog-safe closed-item batch; preserve the scalar blocker as the historical precedence record."),i}function Sr(e,t,r,n){let i=[],s=kr(e);for(let d of Ir(s)){let a=d.some(l=>je(l,t)),u=new Set(d.map(l=>l.toLowerCase())),f=(e.orderingContradictions??[]).filter(l=>u.has(l.holder_id.toLowerCase())&&u.has(l.target_id.toLowerCase())).map(jt);i.push(a?M("ordering_cycle","error","Order-bearing relationship kinds must stay acyclic; a cycle makes every member unschedulable.",l=>`execution-order cycle across ${l} item(s)`,d,n,"Remove or retype one ordering edge inside the cycle, or split the work so precedence is linear.",f.length===0?void 0:f):M("legacy_ordering_cycle","info","Ordering cycles between exclusively terminal items are historical contradictions with no scheduling effect.",l=>`terminal-only execution-order cycle across ${l} item(s)`,d,n,"Leave as history debt, or clean up in a dedicated changelog-safe closed-item batch; never repair closed items ad hoc.",f.length===0?void 0:f))}let o=new Map;for(let[d,a]of s)for(let u of a){let f=o.get(u);f?f.push(d):o.set(u,[d])}let c=[...t.values()].filter(d=>!d.missing&&!d.terminal&&r(d.status)&&!(o.get(d.id)??[]).some(a=>{let u=t.get(a);return u===void 0||!u.terminal})).map(d=>d.id);return x(i,c,n,"stale_lifecycle_block","warning","A blocked lifecycle status must be backed by at least one open ordering predecessor.",d=>`${d} status-blocked item(s) with no open blocker edge`,'Add a local blocker edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status.'),i}function we(e){let t=e.edges.map(r=>r.kind).sort((r,n)=>r.localeCompare(n));return`${e.from} -> ${e.to} (${t.join(" + ")})`}function Fe(e){let t=e.graph.registry(),r=new Map;for(let i of e.graph.edges()){let s=t.require(i.kind);if(!_e(s))continue;let o=Oe(i,s);if(o.from===o.to)continue;let c=`${ye(s)}::${o.from}::${o.to}`,d=r.get(c);d?d.edges.push(i):r.set(c,{...o,edges:[i]})}let n=[...r.values()].filter(i=>i.edges.length>=2);for(let i of n)i.edges.sort((s,o)=>s.kind.localeCompare(o.kind));return n.sort((i,s)=>i.from.localeCompare(s.from)||i.to.localeCompare(s.to))}function Dr(e,t,r){let n=[],i=[];for(let o of Fe(e))(je(o.from,t)||je(o.to,t)?n:i).push(we(o));let s=[];return x(s,n,r,"duplicate_edge","info","One semantic relationship should be stored once; parallel same-family spellings (reciprocal inverse pairs included) add no information and skew degree metrics.",o=>`${o} duplicated relationship(s) between active endpoints`,"Remove all but one stored spelling of the relationship; keep the canonical direction the holder declared first."),x(s,i,r,"legacy_duplicate_edge","info","Duplicated spellings between exclusively terminal items are historical noise with no scheduling effect.",o=>`${o} duplicated relationship(s) between terminal endpoints`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),s}function Rr(e,t){let r=[],n=[];for(let s of e.duplicateRows??[])(s.legacy_terminal?n:r).push(`${s.holder_id} -> ${s.target_id} (${s.kind} x${s.occurrences})`);let i=[];return x(i,r,t,"duplicate_dependency_row","warning","One dependency row must be stored once per holder; identical repeated rows are a storage-layer defect invisible to the assembled graph.",s=>`${s} exactly duplicated stored dependency row(s) on active holder(s)`,"Remove the repeated rows so the dependency is stored exactly once; graph semantics are unchanged."),x(i,n,t,"legacy_duplicate_dependency_row","info","Identical repeated dependency rows on terminal holders are historical storage noise with no scheduling effect.",s=>`${s} exactly duplicated stored dependency row(s) on terminal holder(s)`,"Leave as history debt or clean up in a dedicated changelog-safe closed-item batch."),i}function Ar(e,t){let r=new Map,n={source_to_target:[],target_to_source:[],both:[]};for(let o of e.graph.registry().list())o.outcomeTraversal!==void 0&&n[o.outcomeTraversal].push(o.kind);let i={source_to_target:n.source_to_target.join(","),target_to_source:n.target_to_source.join(","),both:n.both.join(",")},s=(o,c)=>{let d=r.get(c)??new Set;d.add(o),r.set(c,d)};for(let o of e.graph.edges()){t?.throwIfAborted();let c=e.graph.registry().require(o.kind);(c.outcomeTraversal==="source_to_target"||c.outcomeTraversal==="both")&&s(o.source,o.target),(c.outcomeTraversal==="target_to_source"||c.outcomeTraversal==="both")&&s(o.target,o.source)}return{basis:i,reverse:r}}function Nr(e,t,r){let n=new Set(e),i=[...e].sort();for(let s=0;s<i.length;s+=1){r?.throwIfAborted();for(let o of[...t.get(i[s])??[]].sort())n.has(o)||(n.add(o),i.push(o))}return n}function Lr(e,t,r,n){let i=0,s=0,o=0,c=0;for(let p of e.values())if(n?.throwIfAborted(),!t.has(p.id)&&!(p.missing||p.status==="external")){if(p.terminal){o+=1,r.has(p.id)&&(c+=1);continue}r.has(p.id)?i+=1:s+=1}let d=i+s,a=o-c,u=i+c,f=s+a,l=u+f;return{active_outcome_reachable_nodes:i,active_outcome_unreachable_nodes:s,active_outcome_reachability_basis_points:d===0?0:Math.floor(i*1e4/d),terminal_nodes:o,terminal_outcome_reachable_nodes:c,terminal_outcome_unreachable_nodes:a,terminal_outcome_reachability_basis_points:o===0?0:Math.floor(c*1e4/o),outcome_reachable_nodes:u,outcome_unreachable_nodes:f,outcome_reachability_basis_points:l===0?0:Math.floor(u*1e4/l)}}function Or(e,t,r){let n=new Set(e.details.filter(c=>c.type?.toLowerCase()===_r&&c.title.trim().toLowerCase().startsWith(yr)).map(c=>c.id)),{basis:i,reverse:s}=Ar(e,r),o=Nr(n,s,r);return{outcome_nodes:n.size,outcome_reachability_basis:i,...Lr(t,n,o,r)}}function Mr(e,t,r,n,i){e.active+=1;let s=t.type??"(untyped)",o=e.byType.get(s);o||(o={active:0,isolated:0,degree_leq_one:0},e.byType.set(s,o)),o.active+=1,!(r>1)&&(e.degreeLeqOne+=1,o.degree_leq_one+=1,r===0&&(e.isolated+=1,o.isolated+=1),!(n.has(t.id.toLowerCase())||i.has(s.toLowerCase()))&&(r===0?e.isolates.push(t.id):e.sparse.push(t.id)))}function Pr(e,t,r,n,i,s,o){let c={active:0,missing:0,isolated:0,degreeLeqOne:0,isolates:[],sparse:[],byType:new Map};for(let m of e.graph.nodes()){o?.throwIfAborted();let y=t.get(m);if(y){if(y.missing){c.missing+=1;continue}y.terminal||Mr(c,y,e.graph.incidentEdges(m).length,r,n)}}let{isolates:d,sparse:a}=c,u=[];x(u,d,i,"isolated_active_node","warning","Active work should be reachable from the graph unless explicitly declared a valid isolate.",m=>`${m} active item(s) with no relationships`,"Link the item to its parent, prerequisite, or origin \u2014 or register it as an exempt isolate."),x(u,a,i,"sparse_active_node","info","Active items with a single edge often miss an honest semantic partner; sparse is not automatically defective.",m=>`${m} active item(s) with exactly one relationship`,"Investigate for an honest second edge (story->task, defect family, cross-epic complement); do not fabricate one.");let f=e.graph.edges().length,l=L(e.graph,{signal:o}).value,p=new Set(l.map(({edge:m})=>`${m.source.toLowerCase()}\0${m.target.toLowerCase()}\0${m.kind}`));for(let m of e.orderingContradictions??[])p.add(`${m.holder_id.toLowerCase()}\0${m.target_id.toLowerCase()}\0${m.dependency_kind}`);let g=Object.fromEntries(Object.entries(s).sort(([m],[y])=>m.localeCompare(y))),h=Object.entries(g).reduce((m,[y,I])=>m+($e(y)?I:0),0),_=be(e.graph,{signal:o}).value,b=Or(e,t,o);return{findings:u,profile:{nodes:e.graph.nodes().length,recorded_nodes:e.details.filter(m=>m.status!=="missing"&&m.status!=="external").length,edges:f,informative_edges:f-p.size,redundant_edges:l.length,ordering_contradiction_edges:e.orderingContradictions?.length??0,edge_basis:"deduplicated_directed",edges_by_kind:g,edge_share_by_kind:Object.fromEntries(Object.entries(g).map(([m,y])=>[m,y/f])),semantic_edges:h,semantic_edge_share:f===0?0:h/f,active_nodes:c.active,missing_nodes:c.missing,isolated_active_nodes:c.isolated,degree_leq_one_active_nodes:c.degreeLeqOne,coverage_by_type:Object.fromEntries([...c.byType.entries()].sort(([m],[y])=>m<y?-1:1)),articulation_points:_.articulationPoints.length,bridge_edges:_.bridges.length,...b,finding_subjects_by_code:Object.fromEntries(O.map(m=>[m,0]))}}}function ve(e,t={}){let r=t.isTerminal??(l=>l==="closed"||l==="canceled"),n=t.isBlocked??(l=>l==="blocked"),i=t.maxSampleSize??mr;if(!Number.isInteger(i)||i<1)throw new TypeError(`Invalid audit sample bound: ${String(t.maxSampleSize)}`);let s=Nt(t.exemptIsolates),o=Nt(t.isolateExemptTypes),c=new Map(e.details.map(l=>[l.id,{id:l.id,status:l.status,missing:e.missingIdSet.has(l.id.toLowerCase()),terminal:r(l.status),...l.type===void 0?{}:{type:l.type}}]));t.signal?.throwIfAborted();let d={};for(let l of e.graph.edges())d[l.kind]=(d[l.kind]??0)+1;let a=Cr(e,r,i);a.push(...vr(e,i)),t.signal?.throwIfAborted(),a.push(...Tr(e,i)),t.signal?.throwIfAborted(),a.push(...Sr(e,c,n,i)),t.signal?.throwIfAborted(),a.push(...Dr(e,c,i),...Rr(e,i)),t.signal?.throwIfAborted();let u=Pr(e,c,s,o,i,d,t.signal);a.push(...u.findings),a.sort((l,p)=>At[l.severity]-At[p.severity]||l.code.localeCompare(p.code)||l.sample[0].localeCompare(p.sample[0]));let f=u.profile.finding_subjects_by_code;for(let l of a)f[l.code]+=l.count;return{findings:a,profile:{...u.profile,finding_subjects_by_code:f}}}function Pe(e,t){let r=[...new Set([...Object.keys(e),...Object.keys(t)])].sort(),n={};for(let i of r){let s=(t[i]??0)-(e[i]??0);s!==0&&(n[i]=s)}return n}function Mt(e){return e.profile.coverage_by_type??{}}function jr(e,t){let r={},n=Mt(e),i=Mt(t),s=[...new Set([...Object.keys(n),...Object.keys(i)])].sort();for(let o of s){let c=Object.assign({active:0,isolated:0,degree_leq_one:0},n[o]),d=Object.assign({active:0,isolated:0,degree_leq_one:0},i[o]),a={active:d.active-c.active,isolated:d.isolated-c.isolated,degree_leq_one:d.degree_leq_one-c.degree_leq_one};Object.values(a).some(u=>u!==0)&&(r[o]=a)}return r}function $t(e,t){let r=jr(e,t),{edge_share_by_kind:n={},semantic_edges:i=0,semantic_edge_share:s=0}=e.profile,{edge_share_by_kind:o={},semantic_edges:c=0,semantic_edge_share:d=0}=t.profile,a=e.profile.recorded_nodes??e.profile.nodes,u=t.profile.recorded_nodes??t.profile.nodes,f=e.profile.informative_edges??e.profile.edges,l=t.profile.informative_edges??t.profile.edges,p=e.profile.redundant_edges??0,g=t.profile.redundant_edges??0,h=e.profile.ordering_contradiction_edges??0,_=t.profile.ordering_contradiction_edges??0;return{baseline_saved_at:e.saved_at,same_snapshot:e.fingerprint===t.fingerprint,affected_subjects_by_code:Pe(e.affected_subjects_by_code,t.affected_subjects_by_code),profile:{nodes:t.profile.nodes-e.profile.nodes,recorded_nodes:u-a,edges:t.profile.edges-e.profile.edges,informative_edges:l-f,redundant_edges:g-p,ordering_contradiction_edges:_-h,active_nodes:t.profile.active_nodes-e.profile.active_nodes,missing_nodes:t.profile.missing_nodes-e.profile.missing_nodes,isolated_active_nodes:t.profile.isolated_active_nodes-e.profile.isolated_active_nodes,degree_leq_one_active_nodes:t.profile.degree_leq_one_active_nodes-e.profile.degree_leq_one_active_nodes,edges_by_kind:Pe(e.profile.edges_by_kind,t.profile.edges_by_kind),edge_share_by_kind:Pe(n,o),semantic_edges:c-i,semantic_edge_share:d-s,coverage_by_type:r}}}import Ft 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]="9e4aa41d-fca4-5e55-ab2b-d99f06d90ae2")}catch{}})();var Gt=1,Ge=500,$r=64,Fr="graph-durable-cache";function Bt(e){return rt(e,Fr,30,`graph-cache:${process.pid}`,!1,!1,3e3)}function K(e){return Ft.join(e,"runtime","graph-cache.json")}function Ut(e){return Ft.join(e,"runtime","graph-audit-baseline.json")}function Be(e){if(e!==null)try{let t=JSON.parse(e);return typeof t!="object"||t===null||t.version!==Gt||typeof t.fingerprint!="string"||typeof t.saved_at!="string"||typeof t.results!="object"||t.results===null||Array.isArray(t.results)?void 0:t}catch{return}}async function Ue(e,t){let r=await G(K(e)),n=Be(r),i=n?.fingerprint===t;return{exists:r!==null,fresh:i,results:i?n.results:{}}}async function qe(e,t,r,n,i){let s=await Bt(e);try{let o=Be(await G(K(e))),c=o?.fingerprint===t?o.results:{};delete c[n],c[n]=i;let d=Object.keys(c);for(let a of d.slice(0,Math.max(0,d.length-$r)))delete c[a];await Ce(K(e),JSON.stringify({version:Gt,fingerprint:t,saved_at:new Date().toISOString(),results:c})),r.results=c}finally{await s()}}async function ze(e){let t=await Bt(e);try{await Ze(K(e))}finally{await t()}}async function qt(e,t){let r=K(e),n=await G(r),i=Be(n);return i===void 0?{exists:n!==null,fresh:!1,entry_count:0}:{exists:!0,fresh:i.fingerprint===t,entry_count:Object.keys(i.results).length,fingerprint:i.fingerprint.slice(0,12),saved_at:i.saved_at,bytes:Buffer.byteLength(n,"utf8")}}function Ke(e,t){return t||e>=Ge}function ke(e){return P(e)&&Object.values(e).every(D)}function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function D(e){return Number.isInteger(e)&&Number(e)>=0}function zt(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function z(e,t){return e===void 0||t(e)}function Gr(e){return P(e)&&Object.values(e).every(zt)}function Br(e){return P(e)?Object.values(e).every(t=>P(t)&&[t.active,t.isolated,t.degree_leq_one].every(D)):!1}function Ur(e,t,r){let n=["recorded_nodes","informative_edges","redundant_edges","ordering_contradiction_edges"],i=n.filter(o=>e[o]!==void 0).length;if(i!==0&&i!==n.length||!n.every(o=>z(e[o],D)))return;let s={recorded_nodes:e.recorded_nodes??t,informative_edges:e.informative_edges??r,redundant_edges:e.redundant_edges??0,ordering_contradiction_edges:e.ordering_contradiction_edges??0};return s.recorded_nodes<=t&&s.informative_edges<=r&&s.redundant_edges<=r&&s.ordering_contradiction_edges<=r?s:void 0}function qr(e,t,r){let n=[...t,...r,"finding_subjects_by_code"],i=n.filter(s=>e[s]!==void 0).length;return i!==0&&i!==n.length?!1:t.every(s=>z(e[s],D))&&r.every(s=>z(e[s],D)&&(e[s]===void 0||Number(e[s])<=1e4))&&z(e.finding_subjects_by_code,ke)}function zr(e,t,r,n){let i=Ur(e,r,n);if(i===void 0)return;let s=["articulation_points","bridge_edges","outcome_nodes","active_outcome_reachable_nodes","active_outcome_unreachable_nodes","terminal_nodes","terminal_outcome_reachable_nodes","terminal_outcome_unreachable_nodes","outcome_reachable_nodes","outcome_unreachable_nodes"],o=["active_outcome_reachability_basis_points","terminal_outcome_reachability_basis_points","outcome_reachability_basis_points"];if(!qr(e,s,o)||e.edge_basis!==void 0&&e.edge_basis!=="deduplicated_directed")return;let c=ke(e.finding_subjects_by_code)?e.finding_subjects_by_code:{};return{edge_basis:"deduplicated_directed",...i,...Object.fromEntries(s.map(d=>[d,e[d]??0])),...Object.fromEntries(o.map(d=>[d,e[d]??0])),finding_subjects_by_code:Object.fromEntries(O.map(d=>[d,c[d]??t[d]??0]))}}function Kr(e,t,r,n,i){let s=[r,n,i],o=s.filter(a=>a!==void 0).length;if(o===0)return{edge_share_by_kind:{},semantic_edges:0,semantic_edge_share:0};if(o!==s.length||!Gr(r)||!D(n)||!zt(i))return;let c=Object.entries(t);if(c.reduce((a,[,u])=>a+u,0)!==e||Object.keys(r).length!==c.length||c.some(([a,u])=>r[a]!==(e===0?0:u/e)))return;let d=c.reduce((a,[u,f])=>a+($e(u)?f:0),0);if(!(n!==d||i!==(e===0?0:d/e)))return{edge_share_by_kind:r,semantic_edges:n,semantic_edge_share:i}}function Hr(e){if(e!==null)try{let t=JSON.parse(e);if(!P(t))return;let r=t,n=r.profile;if(typeof r.saved_at!="string"||typeof r.fingerprint!="string")return;let i=r.affected_subjects_by_code;if(!ke(i)||!P(n)||![n.nodes,n.edges,n.active_nodes,n.missing_nodes,n.isolated_active_nodes,n.degree_leq_one_active_nodes].every(D)||!ke(n.edges_by_kind)||!z(n.coverage_by_type,Br))return;let s=Kr(n.edges,n.edges_by_kind,n.edge_share_by_kind,n.semantic_edges,n.semantic_edge_share);if(s===void 0)return;let o=zr(n,i,n.nodes,n.edges);if(o===void 0)return;let{coverage_by_type:c={}}=n;return{...r,profile:{...n,...s,...o,coverage_by_type:c}}}catch{return}}async function Kt(e){return Hr(await G(Ut(e)))}async function Ht(e,t){await Ce(Ut(e),JSON.stringify(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]="7054952e-444a-5be2-b0c1-fcc3b72afde5")}catch{}})();var Wr={missing_reference_active:{op:"investigate",confidence:"medium",rationale:"Restore or re-create the referenced item, or remove/retype the reference on the active holder; the correct fix depends on why the target is absent."},missing_reference_terminal:{op:"waive",confidence:"high",rationale:"Terminal-holder reference to an absent item is historical debt; waive it or clean it up only in a dedicated changelog-safe closed-item batch."},legacy_no_blocker_sentinel:{op:"remove",confidence:"high",rationale:"The pre-structured-dependency no-active-blocker sentinel is retired and carries no information; blocker state derives from blocked_by edges."},ordering_cycle:{op:"investigate",confidence:"low",rationale:"Every cycle member is unschedulable until one ordering edge is removed or retyped; the planner never chooses which edge to cut."},legacy_ordering_cycle:{op:"waive",confidence:"high",rationale:"Terminal-only ordering cycles have no scheduling effect; repairing them would mutate closed history (changelog drag)."},ordering_storage_contradiction:{op:"remove",confidence:"high",rationale:"The structured ordering row asserts the opposite precedence from the same-target scalar blocker; remove that exact dependency row or replace both representations with one unambiguous edge."},legacy_ordering_storage_contradiction:{op:"remove",confidence:"high",rationale:"The terminal holder contains a proven contradictory structured ordering row; remove it in a dedicated changelog-safe batch while preserving the scalar blocker as history."},hierarchy_cycle:{op:"investigate",confidence:"low",rationale:"Cut or retype one exact structural relation in the cycle; the planner preserves every evidence row because intent determines the correct parent."},legacy_hierarchy_cycle:{op:"waive",confidence:"high",rationale:"Terminal-only hierarchy cycles are historical debt; waive them unless an explicit closed-history repair is approved."},hierarchy_cardinality_violation:{op:"investigate",confidence:"medium",rationale:"Choose the canonical parent and remove or retype the exact surplus hierarchy rows; the planner cannot infer ownership intent."},legacy_hierarchy_cardinality_violation:{op:"waive",confidence:"high",rationale:"Multiple parents confined to terminal items are historical debt; waive them unless a dedicated history repair is approved."},hierarchy_direction_violation:{op:"investigate",confidence:"medium",rationale:"Align the scalar parent and dependency-backed hierarchy rows to the intended canonical parent."},legacy_hierarchy_direction_violation:{op:"waive",confidence:"high",rationale:"Divergent hierarchy storage confined to terminal items is historical debt; waive it unless a dedicated history repair is approved."},duplicate_edge:{op:"remove",confidence:"high",rationale:"Parallel same-family spellings state one relationship twice; remove all but one stored spelling, keeping the holder's canonical direction."},legacy_duplicate_edge:{op:"waive",confidence:"high",rationale:"Duplicated spellings between terminal items are historical noise; waive or batch changelog-safe cleanup."},duplicate_dependency_row:{op:"remove",confidence:"high",rationale:"The identical dependency row is stored more than once on the holder; drop the repeats so the row exists exactly once \u2014 graph semantics are unchanged."},legacy_duplicate_dependency_row:{op:"waive",confidence:"high",rationale:"Repeated identical rows on terminal holders are storage noise; waive or clean up only in a changelog-safe closed-item batch."},stale_lifecycle_block:{op:"investigate",confidence:"medium",rationale:`Add a local ordering edge, declare an external blocker with --dep "id=<external-ref>,kind=blocked_by,source_kind=external", or move the item back to an active status; only the holder's owner knows which is true.`},isolated_active_node:{op:"investigate",confidence:"medium",rationale:"Link the item to its parent, prerequisite, or origin \u2014 or register it as an explicitly exempt isolate; the audit never fabricates an edge."},sparse_active_node:{op:"investigate",confidence:"low",rationale:"Investigate for an honest second edge (story-to-task, defect family, cross-epic complement); sparse is not automatically defective."}};function Wt(e){return`${e.source} -${e.kind}-> ${e.target}`}function Vr(e){let[t,...r]=e.edges;return r.map(n=>({op:"remove",code:"duplicate_edge",subject:Wt(n),rationale:"This stored spelling restates the kept canonical edge of the same semantic family; removing it leaves the relationship stated exactly once.",evidence:[`keep: ${Wt(t)}`,`group: ${we(e)}`],confidence:"high"}))}function Xr(e,t){if(e.code==="duplicate_edge")return e.sample.flatMap(n=>Vr(t.get(n)));let r=Wr[e.code];return e.sample.map(n=>({op:r.op,code:e.code,subject:n,rationale:r.rationale,evidence:[e.policy],confidence:r.confidence}))}function Vt(e,t={}){let{redundancyLimit:r,...n}=t,i=ve(e,n),s=new Map(Fe(e).map(a=>[we(a),a])),o=i.findings.flatMap(a=>Xr(a,s)),c=i.findings.some(a=>a.sample_truncated);t.signal?.throwIfAborted();let d=L(e.graph,{limit:r??t.maxSampleSize??25,...t.signal===void 0?{}:{signal:t.signal}});for(let a of d.value)o.push({op:"remove",code:"redundant_edge",subject:`${a.edge.source} -> ${a.edge.target} (${a.edge.kind})`,rationale:"The stored edge is implied by a longer same-family witness path; shortcut edges are sometimes deliberate emphasis, so confirm intent before removing.",evidence:[`witness: ${a.witness.join(" -> ")}`],confidence:"medium"});return c=c||d.meta.truncated,{steps:o,report:i,truncated:c,cost:{visitedNodes:d.meta.visitedNodes,inspectedEdges:d.meta.inspectedEdges}}}(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]="74a825f3-1301-5dc5-a887-c6ff68f6d7ec")}catch{}})();var Yr=["tree","graph","context"],Jr=["none","repeated"],Qr=["outgoing","incoming","both"],Zr=32,ei=200,ti=400,ni=16e3;function ri(e){let t=e?.trim().toLowerCase()??"tree";if(Yr.includes(t))return t;throw new v(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,w.USAGE)}function E(e,t){if(e===void 0)return;let r=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(r)||r<1)throw new v(`Invalid --${t} value "${e}". Use a positive integer.`,w.USAGE);return r}function xe(e){if(e===void 0)return;let t=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(t)||t<0)throw new v(`Invalid --max-depth value "${e}". Use a non-negative integer.`,w.USAGE);return t}function ii(e){let t=e?.trim().toLowerCase()??"none";if(Jr.includes(t))return t;throw new v(`Invalid --collapse value "${e}". Use "none" or "repeated".`,w.USAGE)}function We(e){let t=e?.trim().toLowerCase()??"both";if(Qr.includes(t))return t;throw new v(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,w.USAGE)}function Ve(e,t=C()){if(e===void 0)return;let r=(Array.isArray(e)?e:[e]).flatMap(i=>i.split(",")).map(i=>i.trim()).filter(i=>i.length>0);if(r.length===0)return;let n=new Set;for(let i of r){let s=t.resolve(i);if(!s){let o=t.list().map(c=>c.kind).join(", ");throw new v(`Invalid --kind value "${i}". Registered kinds: ${o}.`,w.USAGE)}n.add(s.kind)}return[...n].sort()}function si(e){if(!e||e.length===0)return[];let t=e.map(({id:n,kind:i})=>({id:n.trim(),kind:i.trim().toLowerCase()})).sort((n,i)=>{let s=n.kind.localeCompare(i.kind);return s!==0?s:n.id.localeCompare(i.id)}),r=new Map;for(let n of t){let i=`${n.kind.toLowerCase()}::${n.id.toLowerCase()}`;r.has(i)||r.set(i,{id:n.id,kind:n.kind})}return[...r.values()]}function oi(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:si(e.dependencies)}}function ci(e){return J(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function di(e,t,r,n,i,s,o,c,d){for(let a of t.dependencies){let u=Math.max(1,Math.ceil(JSON.stringify({from:e.id,to:a.id,kind:a.kind}).length/3));if(c.nodes>=c.nodeLimit){e.truncated=!0,c.reasons.add("node_limit");break}if(c.edges>=c.edgeLimit){e.truncated=!0,c.reasons.add("edge_limit");break}if(c.estimatedTokens+u>=c.tokenBudget){e.truncated=!0,c.reasons.add("token_budget");break}c.edges+=1,c.estimatedTokens+=u,e.dependencies.push(Yt(a.id,r,n,i,s,o,c,d+1,a.kind))}}function ai(e,t,r,n,i,s,o,c){return o.estimatedTokens>=o.tokenBudget&&t?.dependencies.length?(e.truncated=!0,o.reasons.add("token_budget"),!0):!t||e.cycle?!0:n!==void 0&&c>=n?(t.dependencies.length>0&&(e.truncated=!0,o.reasons.add("max_depth")),!0):i==="repeated"&&s.has(r)?(e.collapsed=!0,!0):!1}function Yt(e,t,r,n,i,s,o,c=0,d){let a=e.trim().toLowerCase(),u=t.get(a),f={id:u?.id??e,title:u?.title,type:u?.type,status:u?.status,via:d,missing:!u,cycle:r.has(a),dependencies:[]};if(o.nodes+=1,o.estimatedTokens+=ci(f),ai(f,u,a,n,i,s,o,c))return f;i==="repeated"&&s.add(a);let l=new Set(r);return l.add(a),di(f,u,t,l,n,i,s,o,c),f}function Xt(e,t){return!e||e.missing&&!t.missing?t:{...e,title:e.title??t.title,type:e.type??t.type,status:e.status??t.status}}function ui(e){let t=new Map,r=new Map,n=[e];for(;n.length>0;){let c=n.pop();t.set(c.id,Xt(t.get(c.id),{id:c.id,title:c.title,type:c.type,status:c.status,missing:c.missing}));for(let d of c.dependencies){t.set(d.id,Xt(t.get(d.id),{id:d.id,title:d.title,type:d.type,status:d.status,missing:d.missing}));let a=d.via??"related",u=`${c.id}::${d.id}::${a}`;r.has(u)||r.set(u,{from:c.id,to:d.id,kind:a}),d.cycle||n.push(d)}}let i=[...t.values()].sort((c,d)=>c.id.localeCompare(d.id)),s=[...r.values()].sort((c,d)=>{let a=c.from.localeCompare(d.from);if(a!==0)return a;let u=c.to.localeCompare(d.to);return u!==0?u:c.kind.localeCompare(d.kind)}),o=i.filter(c=>c.missing).map(c=>c.id);return{root_id:e.id,nodes:i,edges:s,missing_ids:o}}function Jt(e,t,r){let n=new Set,i=new Set,s=new Set,o=new Set,c=[{id:e,depth:0}],d=0;for(;d<c.length;){let a=c[d++],u=a.id.trim().toLowerCase();n.add(u);let f=t.get(u);if(!f){s.add(u);continue}if(!(r!==void 0&&a.depth>=r)&&!o.has(u)){o.add(u);for(let l of f.dependencies)i.add(`${u}::${l.id.trim().toLowerCase()}::${l.kind}`),c.push({id:l.id,depth:a.depth+1})}}return{node_count:n.size,edge_count:i.size,edge_basis:"deduplicated_directed",missing_count:s.size}}function li(e,t=C()){let r=xe(e.maxDepth),n=E(e.nodeLimit,"node-limit"),i=E(e.edgeLimit,"edge-limit"),s=E(e.tokenBudget,"token-budget"),o=Ve(e.kind,t);return{direction:We(e.direction),...o===void 0?{}:{kinds:o},...r===void 0?{}:{maxDepth:r},...n===void 0?{}:{nodeLimit:n},...i===void 0?{}:{edgeLimit:i},...s===void 0?{}:{tokenBudget:s},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function fi(e,t,r,n){return ht(e.graph,t,e.details.map(i=>i.id===t&&n.length>0?{...i,evidence:n}:i),r)}function He(e,t,r,n){for(let i of r.slice(0,n)){let s=i?.trim();s&&e.push(`${t}:${s}`)}}async function gi(e,t,r,n){let i=await it(e,t,r.id_prefix,r.item_format,n);if(!i)return[];let{document:s}=await st(i,{schema:r.schema}),o=s.metadata,c=o.files??[],d=o.tests??[],a=o.docs??[],u=[["files",c.length],["tests",d.length],["docs",a.length],["comments",(o.comments??[]).length],["notes",(o.notes??[]).length],["learnings",(o.learnings??[]).length]];if(u.every(([,l])=>l===0))return[];let f=[`linked:${u.map(([l,p])=>`${l}=${p}`).join(",")}`];return He(f,"file",c.map(l=>l.path),3),He(f,"test",d.map(l=>l.command??l.path),2),He(f,"doc",a.map(l=>l.path),2),f}function pi(e){let{canonicalId:t,context:r,missingCount:n,missingReferences:i,referenceLimit:s,summaryOnly:o}=e;return{id:t,format:"context",node_count:r.nodes.length+1,edge_count:r.edges.length,edge_basis:"deduplicated_directed",missing_count:n,missing_scope:"traversal",missing_reference_count:i.length,...o?{}:{missing_references:i.slice(0,s),context:r}}}function hi(e){let{row:t,missingReachableSet:r,packetIds:n,filteredKinds:i,registry:s}=e;if(t.no_active_blocker_sentinel||!r.has(t.target_id.trim().toLowerCase())||!n.has(t.holder_id))return!1;if(i===void 0)return!0;let o=s.resolve(t.kind);return o!==void 0&&(i.has(o.kind)||o.inverse!==void 0&&i.has(o.inverse))}function Qt(e,t,r){let n;for(;;){let i=J(new TextEncoder().encode(De(Se("deps",e),t)).byteLength);if(i===n)return i;r(i),n=i}}function mi(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function _i(e){try{return fi(e.assembly,e.canonicalId,{...e.contextOptions,...e.internalTokenBudget===void 0?{}:{tokenBudget:e.internalTokenBudget}},e.rootEvidence)}catch(t){if(e.smallestResult!==void 0&&mi(t))return e.smallestResult;throw t}}function yi(e){let{assembly:t,canonicalId:r,contextOptions:n,rootEvidence:i,summaryOnly:s,outputFormat:o,missingCount:c,missingReferences:d}=e,u=n.edgeLimit??40,f=n.tokenBudget,l,p;for(;;){let g=_i({assembly:t,canonicalId:r,contextOptions:n,internalTokenBudget:f,rootEvidence:i,smallestResult:p});if("format"in g)return g;let h=g;l??=h.meta.tokenBudget,f??=l;let _=pi({canonicalId:r,context:h,missingCount:c,missingReferences:d,referenceLimit:u,summaryOnly:s});if(p=_,s||(h.meta.tokenBudget=l,h.meta.usedTokens=Qt(j(_,!1),o,y=>{h.meta.usedTokens=y}),h.meta.usedTokens<=l))return _;if(u>0){u-=1;continue}let b=f,m=b*l/h.meta.usedTokens;f=Math.min(b-1,Math.max(1,Math.floor(m*.9)))}}function bi(e){let{assembly:t,canonicalId:r,options:n,rootEvidence:i,summaryOnly:s,outputFormat:o}=e,c=li(n,t.graph.registry()),d=t.graph.closure(r,{direction:c.direction,...c.kinds===void 0?{}:{kinds:c.kinds},maxDepth:c.maxDepth??3}),a=d.value.filter(h=>t.missingIdSet.has(h.toLowerCase())),u=new Set(a.map(h=>h.toLowerCase())),f=t.graph.registry(),l=c.kinds?new Set(c.kinds.map(h=>f.require(h).kind)):void 0,p=new Set([r,...d.value]),g=[...t.dangling.active,...t.dangling.legacy_terminal].filter(h=>hi({row:h,missingReachableSet:u,packetIds:p,filteredKinds:l,registry:f}));return yi({assembly:t,canonicalId:r,contextOptions:c,rootEvidence:i,summaryOnly:s,outputFormat:o,missingCount:a.length,missingReferences:g})}function wi(e){let t=[e],r;for(;t.length>0;){let n=t.pop();n.dependencies.length>0&&(r=n,t.push(...n.dependencies))}return r?(r.dependencies.pop(),r.truncated=!0,!0):!1}function vi(e,t,r,n,i,s,o){let c=i??Zr,d=E(r.nodeLimit,"node-limit")??ei,a=E(r.edgeLimit,"edge-limit")??ti,u=E(r.tokenBudget,"token-budget")??ni,f={nodeLimit:d,edgeLimit:a,tokenBudget:u,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},l=Yt(e,n,new Set,c,t==="graph"?"repeated":s,new Set,f),p=Jt(e,n,void 0),g;for(;;){let h=ui(l),_=f.reasons.size===0?void 0:{reasons:[...f.reasons].sort(),limits:{max_depth:c,node_limit:d,edge_limit:a,token_budget:u},estimated_tokens:0,total_node_count:p.node_count,total_edge_count:p.edge_count,omitted_node_count:Math.max(0,p.node_count-h.nodes.length),omitted_edge_count:Math.max(0,p.edge_count-h.edges.length)},b={id:e,format:t,node_count:h.nodes.length,edge_count:h.edges.length,edge_basis:"deduplicated_directed",missing_count:h.missing_ids.length,..._?{truncation:_}:{}};if(g=t==="tree"?{...b,tree:l}:{...b,graph:h},(g.truncation===void 0?J(new TextEncoder().encode(De(Se("deps",j(g,!1)),o)).byteLength):Qt(j(g,!1),o,y=>{g.truncation.estimated_tokens=y}))<=u)return g;if(!wi(l))return f.reasons.add("token_budget"),g;f.reasons.add("token_budget")}}function j(e,t,r={}){let n={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"};return{...e,legacy_alias_counts:r,projection:{mode:t?"summary":"full",declared_field_groups:[n],included_field_groups:t?[]:[n.name]}}}async function Bs(e,t,r){let n=X(process.cwd(),r.path);await ne(n);let i=ri(t.format),s=xe(t.maxDepth),o=ii(t.collapse);Z(t.summary===!0,t.full===!0,"--summary");let c=t.summary===!0,d=await te(n),a=V(d,ee()),u=await re(n,d.item_format,a.type_to_folder,void 0,d.schema),f=Y(d.schema),l=new Map(u.map(g=>[g.id.trim().toLowerCase(),oi(g)])),p=ct(u,g=>S(g,f));for(let g of[...p.active,...p.legacy_terminal]){let h=l.get(g.holder_id.trim().toLowerCase()),_=g.kind.trim().toLowerCase();h&&!h.dependencies.some(b=>b.id.trim().toLowerCase()===g.target_id.trim().toLowerCase()&&b.kind===_)&&h.dependencies.push({id:g.target_id,kind:_})}if(!l.has(e.trim().toLowerCase()))throw new v(`Item ${e} not found`,w.NOT_FOUND);if(i==="context"){let g=l.get(e.trim().toLowerCase()).id,h=c?[]:await gi(n,g,d,a.type_to_folder),_=y=>S(y,f),b=ie(),m=ue().lookup(n,ae(u,_,b),()=>A(u,_,b));return j(bi({assembly:m.assembly,canonicalId:g,options:t,rootEvidence:h,summaryOnly:c,outputFormat:r.json===!0?"json":"toon"}),c,m.assembly.legacyAliasCounts)}return c?j({id:e,format:i,...Jt(e,l,s)},!0,Object.fromEntries(Object.entries(A(u,g=>S(g,f)).legacyAliasCounts))):j(vi(e,i,t,l,s,o,r.json===!0?"json":"toon"),!1,Object.fromEntries(Object.entries(A(u,g=>S(g,f)).legacyAliasCounts)))}(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]="8797dddf-3643-554b-ba7f-4c513535c154")}catch{}})();var nn=new Set(["ancestors","descendants","predecessors","successors","paths","impact","dominators"]),T=10;function Zt(e,t,r){return{...e,projection:{mode:t?"summary":"full",declared_field_groups:r===void 0?[]:[{name:r,restore_with:"--full"}],included_field_groups:r===void 0||t?[]:[r]}}}function en(e){return e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(t=>t.split(",")).map(t=>t.trim()).filter(t=>t.length>0)}function ki(e,t,r){let n=e.trim().toLowerCase();if(!Te.includes(n))throw ot({command_path:"graph",token:n||"<empty>",allowed:Te});let i=n;if(nn.has(i)&&!t?.trim())throw new v(`graph ${i} requires an item id.`,w.USAGE);if(i==="paths"&&!r?.trim())throw new v("graph paths requires a source and a target item id.",w.USAGE);return i}function Xe(e){throw e instanceof TypeError?new v(e.message,w.USAGE):e}function Ye(e){return{truncated:e.truncated,cost:{visited_nodes:e.visitedNodes,inspected_edges:e.inspectedEdges}}}function tn(e,t){let r=t.trim().toLowerCase();for(let n of e.details)if(n.id.trim().toLowerCase()===r&&!e.missingIdSet.has(n.id.toLowerCase()))return n.id;throw new v(`Item ${t} not found`,w.NOT_FOUND)}function xi(e,t,r){let n={ancestors:yt,descendants:bt,predecessors:wt,successors:vt}[e],i;try{i=n(r.assembly.graph,t,{...r.kinds===void 0?{}:{kinds:r.kinds},...r.maxDepth===void 0?{}:{maxDepth:r.maxDepth},...r.limit===void 0?{}:{limit:r.limit},...r.after===void 0?{}:{after:r.after}})}catch(o){Xe(o)}let s=Ye(i.meta);return{subcommand:e,root:t,count:i.value.length,...s,...i.meta.nextCursor===void 0?{}:{next_cursor:i.meta.nextCursor},...r.summary?{}:{ids:i.value}}}function Ei(e,t,r){let n=kt(r.assembly.graph,e,t,{direction:r.direction,...r.kinds===void 0?{}:{kinds:r.kinds},...r.maxDepth===void 0?{}:{maxDepth:r.maxDepth},...r.maxPaths===void 0?{}:{maxPaths:r.maxPaths}});return{subcommand:"paths",root:e,target:t,direction:r.direction,count:n.value.length,...Ye(n.meta),...r.summary?{}:{paths:n.value.map(i=>({nodes:i.nodes,kinds:i.edges.map(s=>s.kind),length:i.length}))}}}function Ii(e,t){let r;try{r=ce(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth},...t.unbounded?{}:{limit:t.limit??T},...t.after===void 0?{}:{after:t.after}})}catch(n){Xe(n)}return{subcommand:"impact",root:e,direction:t.direction,count:r.affected.length,truncated:r.truncated,...r.nextCursor===void 0?{}:{next_cursor:r.nextCursor},cost:{visited_nodes:r.cost.visitedNodes,inspected_edges:r.cost.inspectedEdges},...t.summary?{}:{affected:r.affected}}}function Ci(e,t,r){return{acyclic:e.acyclic,ordered_node_count:e.order.length,layer_count:e.layers.length,frontier_count:e.frontier.length,critical_path_length:e.criticalPathLength,cycle_count:e.cycles.length,...t?{}:{frontier:e.frontier.slice(0,r),critical_path:e.criticalPath.slice(0,r),cycles:e.cycles.slice(0,r)}}}function Ti(e,t,r){return{component_count:e.components.length,largest_component_size:e.components[0]?.length??0,orphan_count:e.orphans.length,...t?{}:{orphans:e.orphans.slice(0,r),hubs:e.hubs.slice(0,r)}}}function Si(e,t,r){let n=0,i=0,s=0;for(let o of e.cycles)n+=Number(o.legacy_terminal);for(let o of e.cardinality_violations)i+=Number(o.legacy_terminal);for(let o of e.divergences)s+=Number(o.legacy_terminal);return{acyclic:e.cycles.length===0,relation_count:e.relations.length,cycle_count:e.cycles.length,active_cycle_count:e.cycles.length-n,legacy_cycle_count:n,cardinality_violation_count:e.cardinality_violations.length,active_cardinality_violation_count:e.cardinality_violations.length-i,legacy_cardinality_violation_count:i,parent_divergence_count:e.divergences.length,active_parent_divergence_count:e.divergences.length-s,legacy_parent_divergence_count:s,...t?{}:{cycles:e.cycles.slice(0,r).map(o=>o.item_ids)}}}function Di(e){let t=e.assembly.graph,r=e.limit??T,n=de(t,{registry:t.registry()}),i=ft(t);return{subcommand:"analyze",node_count:t.nodes().length,edge_count:t.edges().length,edge_basis:"deduplicated_directed",sample_limit:r,execution:Ci(n,e.summary,r),knowledge:Ti(i,e.summary,r),hierarchy:Si(se(e.assembly),e.summary,r)}}function Ri(e,t){let r=ve(e.assembly,{isTerminal:t,...e.sample===void 0?{}:{maxSampleSize:e.sample},...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),n={},i={},s={},o={};for(let a of r.findings)n[a.severity]=(n[a.severity]??0)+1,i[a.code]=(i[a.code]??0)+1,s[a.severity]=(s[a.severity]??0)+a.count,o[a.code]=(o[a.code]??0)+a.count;let{finding_subjects_by_code:c,...d}=r.profile;return{subcommand:"audit",finding_count:r.findings.length,findings_by_severity:n,findings_by_code:i,affected_subjects_by_severity:s,affected_subjects_by_code:o,profile:e.summary?d:r.profile,legacy_alias_counts:e.assembly.legacyAliasCounts,...e.summary?{}:{findings:r.findings}}}function Ai(e){let t=e.limit??T,r={};e.kinds!==void 0&&(r.kinds=e.kinds);let n=Et(e.assembly.graph,r),i=n.value;return{subcommand:"communities",community_count:i.communities.length,largest_community_size:i.communities[0]?.size??0,iterations:i.iterations,converged:i.converged,truncated:!i.converged||i.communities.length>t,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...e.summary?{}:{communities:i.communities.slice(0,t).map(s=>({representative:s.representative,size:s.size,members:s.members.slice(0,t)}))}}}function Ni(e){let t;try{t=L(e.assembly.graph,{...e.kinds===void 0?{}:{kinds:e.kinds},...e.maxDepth===void 0?{}:{maxDepth:e.maxDepth},...e.limit===void 0?{}:{limit:e.limit}})}catch(r){Xe(r)}return{subcommand:"redundancy",redundant_count:t.value.length,...Ye(t.meta),...e.summary?{}:{redundant:t.value.map(r=>({source:r.edge.source,target:r.edge.target,kind:r.edge.kind,witness:r.witness}))}}}function Li(e,t){let r=t.limit??T,n=It(t.assembly.graph,e,{direction:t.direction,...t.kinds===void 0?{}:{kinds:t.kinds},...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth}}),i=n.value.rows.filter(s=>s.dominatedCount>0);return{subcommand:"dominators",root:e,direction:t.direction,reachable_count:n.value.reachableCount,bottleneck_count:i.length,truncated:n.meta.truncated||i.length>r,cost:{visited_nodes:n.meta.visitedNodes,inspected_edges:n.meta.inspectedEdges},...t.summary?{}:{bottlenecks:i.slice(0,r).map(s=>({id:s.id,idom:s.idom,dominated_count:s.dominatedCount}))}}}function Oi(e){let t=e.limit??T,r=Rt(e.assembly.graph),n=r.rows.filter(i=>i.critical).length;return{subcommand:"slack",acyclic:r.acyclic,makespan:r.makespan,scheduled_count:r.scheduledCount,critical_count:n,critical_path_length:r.criticalPathLength,cycle_count:r.cycles.length,truncated:r.rows.length>t,...e.summary?{}:{critical_path:r.criticalPath,rows:r.rows.slice(0,t).map(i=>({id:i.id,earliest_start:i.earliestStart,latest_start:i.latestStart,slack:i.slack,critical:i.critical}))}}}function Mi(e){let t=e.limit??T,r=Dt(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),n=r.value;return{subcommand:"centrality",node_count:n.nodeCount,edge_count:n.edgeCount,edge_basis:"simple_undirected",truncated:n.rows.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{rows:n.rows.slice(0,t).map(i=>({id:i.id,degree:i.degree,in_degree:i.inDegree,out_degree:i.outDegree,betweenness:i.betweenness,closeness:i.closeness}))}}}function Pi(e){let t=e.limit??T,r=be(e.assembly.graph,e.kinds===void 0?{}:{kinds:e.kinds}),{articulationPoints:n,bridges:i}=r.value;return{subcommand:"articulation",articulation_count:n.length,bridge_count:i.length,truncated:n.length>t||i.length>t,cost:{visited_nodes:r.meta.visitedNodes,inspected_edges:r.meta.inspectedEdges},...e.summary?{}:{articulation_points:n.slice(0,t),bridges:i.slice(0,t)}}}function ji(e,t){let r=e.limit??T,n=Vt(e.assembly,{isTerminal:t,redundancyLimit:r,...e.sample===void 0?{}:{maxSampleSize:e.sample},...e.exemptIsolates.length===0?{}:{exemptIsolates:e.exemptIsolates},...e.exemptIsolateTypes.length===0?{}:{isolateExemptTypes:e.exemptIsolateTypes}}),i={},s={};for(let o of n.steps)i[o.op]=(i[o.op]??0)+1,s[o.code]=(s[o.code]??0)+1;return{subcommand:"plan",step_count:n.steps.length,steps_by_op:i,steps_by_code:s,finding_count:n.report.findings.length,truncated:n.truncated||n.steps.length>r,cost:{visited_nodes:n.cost.visitedNodes,inspected_edges:n.cost.inspectedEdges},...e.summary?{}:{steps:n.steps.slice(0,r)}}}function rn(e,t,r,n){return JSON.stringify({subcommand:e,root:t??null,target:r??null,kinds:n.kinds??null,maxDepth:n.maxDepth??null,limit:n.limit??null,after:n.after??null,direction:n.direction,maxPaths:n.maxPaths??null,sample:n.sample??null,exemptIsolates:[...new Set(n.exemptIsolates.map(i=>i.toLowerCase()))].sort(),exemptIsolateTypes:[...new Set(n.exemptIsolateTypes.map(i=>i.toLowerCase()))].sort(),summary:n.summary,unbounded:n.unbounded})}function sn(e,t,r,n,i){return e==="analyze"?Di(n):e==="audit"?Ri(n,i):e==="plan"?ji(n,i):e==="communities"?Ai(n):e==="redundancy"?Ni(n):e==="dominators"?Li(t,n):e==="slack"?Oi(n):e==="centrality"?Mi(n):e==="articulation"?Pi(n):e==="paths"?Ei(t,r,n):e==="impact"?Ii(t,n):xi(e,t,n)}function $i(e,t){if(e!=="index"&&(t.rebuild===!0||t.clear===!0))throw new v("--rebuild and --clear apply only to graph index.",w.USAGE);if(e!=="audit"&&t.saveBaseline===!0)throw new v("--save-baseline applies only to graph audit.",w.USAGE);if(e==="slack"&&t.kind!==void 0)throw new v("graph slack analyzes every ordering kind; --kind is not supported.",w.USAGE);if(t.rebuild===!0&&t.clear===!0)throw new v("graph index accepts either --rebuild or --clear, not both.",w.USAGE);if(e==="impact"&&t.full===!0&&t.limit!==void 0)throw new v("graph impact accepts either --full or --limit, not both.",w.USAGE)}async function Fi(e,t,r,n,i,s){let o="status";if(s.clear===!0&&(await ze(e),o="cleared"),s.rebuild===!0){await ze(e);let d=await Ue(e,t),a={assembly:r.assembly,direction:"both",exemptIsolates:[],exemptIsolateTypes:[],saveBaseline:!1,summary:!0,unbounded:!1};for(let u of["analyze","audit"])await qe(e,t,d,rn(u,void 0,void 0,a),sn(u,void 0,void 0,a,i));o="rebuilt"}let c=await qt(e,t);return{subcommand:"index",action:o,state:c.exists?c.fresh?"fresh":"stale":"absent",entry_count:c.entry_count,item_count:n,min_items_threshold:Ge,persist_enabled:Ke(n,c.exists),current_fingerprint:t.slice(0,12),...c.saved_at===void 0?{}:{saved_at:c.saved_at},...c.bytes===void 0?{}:{bytes:c.bytes}}}async function Gi(e,t,r,n){let i={saved_at:new Date().toISOString(),fingerprint:t,affected_subjects_by_code:r.affected_subjects_by_code,profile:{...r.profile,finding_subjects_by_code:Object.fromEntries(O.map(o=>[o,r.affected_subjects_by_code[o]??0]))}},s=await Kt(e);return n&&await Ht(e,i),s===void 0?r:{...r,baseline:$t(s,i)}}async function Bi(e,t,r,n,i){try{await qe(e,t,r,n,i)}catch{}}async function ho(e,t,r,n,i){let s=ki(e,t,r);Z(n.summary===!0,n.full===!0,"--summary");let o=X(process.cwd(),i.path);await ne(o);let c=await te(o),d=V(c,ee()),a=await re(o,c.item_format,d.type_to_folder,void 0,c.schema),u=Y(c.schema),f=F=>S(F,u);$i(s,n);let l=ie(),p=Ve(n.kind,l),g=ue().lookup(o,ae(a,f,l),()=>A(a,f,l)),h={assembly:g.assembly,...p===void 0?{}:{kinds:p},maxDepth:xe(n.maxDepth),limit:E(n.limit,"limit"),after:n.after?.trim()||void 0,direction:We(n.direction),maxPaths:E(n.maxPaths,"max-paths"),sample:E(n.sample,"sample"),exemptIsolates:en(n.exemptIsolate),exemptIsolateTypes:en(n.exemptIsolateType),saveBaseline:n.saveBaseline===!0,summary:n.summary===!0,unbounded:n.full===!0};if(s==="index")return Zt(await Fi(o,g.fingerprint,h,a.length,f,n),!1);let _=nn.has(s)?tn(h.assembly,t):void 0,b=s==="paths"?tn(h.assembly,r):void 0,m=rn(s,_,b,h),y=await Ue(o,g.fingerprint),I=y.results[m],k=g.memoize(m,()=>I!==void 0?structuredClone(I):sn(s,_,b,h,f)),H=Ke(a.length,y.exists);!k.reused&&I===void 0&&H&&await Bi(o,g.fingerprint,y,m,k.value);let $=k.value.subcommand==="audit"?await Gi(o,g.fingerprint,k.value,h.saveBaseline):k.value;return $.cache={fingerprint:g.fingerprint.slice(0,12),assembly:g.assemblyReused?"hit":"miss",result:k.reused?"hit":"miss",durable:I!==void 0?"hit":H?"miss":"off"},Zt($,h.summary,"result_rows")}export{de as a,ce as b,ft as c,zi as d,ae as e,Re as f,ue as g,Xi as h,ht as i,Bs as j,yt as k,bt as l,wt as m,vt as n,kt as o,me as p,Et as q,L as r,It as s,Dt as t,be as u,Rt as v,Ir as w,jt as x,we as y,Fe as z,ve as A,$t as B,Gt as C,Ge as D,K as E,Ut as F,Ue as G,qe as H,ze as I,qt as J,Ke as K,Kt as L,Ht as M,Vt as N,ki as O,ho as P};
|
|
2
|
+
//# sourceMappingURL=chunk-MCOR37QK.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as At,$a as ae,Ga as vt,Ma as Lt,V as M,aa as Ct,ab as L,bb as ce,gb as de,ja as Q,kb as Ve,l as Pe,la as $e,o as se,oa as ze,ob as qe,pa as Fe,ra as Ue,tb as je,ub as He,wb as le}from"./chunk-
|
|
1
|
+
import{$ as At,$a as ae,Ga as vt,Ma as Lt,V as M,aa as Ct,ab as L,bb as ce,gb as de,ja as Q,kb as Ve,l as Pe,la as $e,o as se,oa as ze,ob as qe,pa as Fe,ra as Ue,tb as je,ub as He,wb as le}from"./chunk-L5LDSRO2.js";import{$ as It,G as U,M as W,O as Me,P as ke,Q as Ne,R as xt,Sa as ie,V as g,X as K,Y as V,Z as b,a as De,q as F,s as G,t as T,u as S,w as oe}from"./chunk-3LKU6PTJ.js";import{S as Re,Y as f,Z as m,ba as Oe}from"./chunk-C4S4A4JJ.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function tn(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new m(`${t} must be a non-negative number`,f.USAGE);return Math.floor(r)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var rn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,nn=/\bnpm_[A-Za-z0-9]{36}\b/,on=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,sn=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,an=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,Dt=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,cn=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],Be=new Map(cn.map(e=>[e.action,e]));function dn(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function Ye(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>Ye(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>Ye(o,`${t}.${n}`,r)))}function Rt(e){let t=[];for(let r of Ye(e)){rn.test(r.value)&&t.push({rule:"github_token",path:r.path}),nn.test(r.value)&&t.push({rule:"npm_token",path:r.path}),on.test(r.value)&&t.push({rule:"slack_token",path:r.path}),sn.test(r.value)&&t.push({rule:"private_key",path:r.path}),an.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),Dt.lastIndex=0;for(let n of r.value.matchAll(Dt)){let o=n[1];if(dn(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function ln(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new m("Mutation author is required by workspace policy.",f.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=Rt(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new m(`Mutation blocked by secret guard (${n}). No detected value was logged.`,f.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function un(e){return Be.has(e.trim().toLowerCase())}function fn(){return[...Be.keys()].sort((e,t)=>e.localeCompare(t))}function fa(e){return Be.get(e.trim().toLowerCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3ad30a32-0f83-5473-b0a3-349e271d8378")}catch{}})();function mn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function pa(e){return mn(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function X(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dff9b113-2b29-5154-afbf-f191f2f556a6")}catch{}})();var pn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function ue(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function Z(e){return[...new Set(ue(e).match(/[\p{L}\p{N}]+/gu)??[])]}function J(e){let t=ue(e);return{normalized:t,tokens:Z(t),issueCodes:[...new Set(t.match(pn)?.map(r=>r.toLowerCase())??[])]}}function fe(e,t){return me(J(e),J(t))}function me(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:X(e.tokens,t.tokens),reason:"title_token_jaccard"}}import _n from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function pe(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function hn(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function Mt(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=pe(t.in_progress_status),i=[];for(let s of e){if(pe(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=hn(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function gn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>pe(String(o.status))===pe(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Ue(_n.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),Mt(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as yn,readFile as wn}from"node:fs/promises";import kt from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function En(e){let t=e.trim();if(!t)throw new m("--rollback requires a non-empty checkpoint ID",f.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new m("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",f.USAGE);return t}function bn(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function Nt(e,t){return kt.join(e,"checkpoints",t)}function Ot(e,t,r){return kt.join(Nt(e,t),`${r}.json`)}async function Sn(e,t,r,n){let o=Nt(e,t);await yn(o,{recursive:!0});let i=Ot(e,t,r);return await S(i,`${JSON.stringify(n,null,2)}
|
|
2
2
|
`),i}function Tn(e,t){if(!Array.isArray(e.items))throw new m(`Checkpoint ${t} is missing items`,f.GENERIC_FAILURE);return e.items.map(r=>{if(!r||typeof r!="object")throw new m(`Checkpoint ${t} contains an invalid item entry`,f.GENERIC_FAILURE);let n=r;if(typeof n.id!="string"||n.id.trim().length===0)throw new m(`Checkpoint ${t} contains an item entry without ID`,f.GENERIC_FAILURE);if(typeof n.target_updated_at!="string"||n.target_updated_at.trim().length===0)throw new m(`Checkpoint ${t} contains an item entry without target_updated_at`,f.GENERIC_FAILURE);return{id:n.id.trim(),target_updated_at:n.target_updated_at.trim()}})}async function xn(e,t,r,n){let o=En(r),i=Ot(e,t,o);if(!await F(i))throw new m(`Checkpoint ${o} not found`,f.NOT_FOUND);let s=await wn(i,"utf8"),a;try{a=JSON.parse(s)}catch(l){throw new m(`Checkpoint ${o} contains invalid JSON: ${b(l)}`,f.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new m(`Checkpoint ${o} is invalid`,f.GENERIC_FAILURE);let c=a;if(c.schema_version!==n)throw new m(`Checkpoint ${o} has unsupported schema version`,f.GENERIC_FAILURE);let d=Tn(c,o);return{record:c,items:d,path:i,id:typeof c.id=="string"?c.id:o,created_at:typeof c.created_at=="string"?c.created_at:M(),author:typeof c.author=="string"?c.author:"unknown"}}async function In(e,t){let r=[],n=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);r.push({id:o.id,status:"restored",changed_fields:i.changed_fields,warnings:i.warnings}),n.push(o.id)}catch(i){r.push({id:o.id,status:"failed",error:b(i)})}return{rows:r,restored_ids:n,failed_count:r.filter(o=>o.status==="failed").length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ab276268-7a98-5f97-b3f5-300dfd1b5ed5")}catch{}})();function k(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function Da(e,t){let r=k(t);return!e||!r?null:[...e.assurance_providers??[]].reverse().find(n=>k(n.definition.id)===r)??null}function An(e,t){let r=k(t);return!e||!r?null:[...e.search_providers].reverse().find(o=>(k(o.runtime_definition?.name)??k(o.definition?.name))===r)??null}function Cn(e,t){let r=k(t);return!e||!r?null:[...e.vector_store_adapters].reverse().find(o=>(k(o.runtime_definition?.name)??k(o.definition?.name))===r)??null}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="19ff592c-0746-54e8-a304-2006f4845da2")}catch{}})();function Pt(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function Ge(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let r=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return r?Pt(r):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?Pt(t):"root"}function _e(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function vn(e,t){let r=t?.windowStartIndex??0,n=t?.field;if(e.length===0||r>=e.length)return[];let o=vt(),i=[];for(let s=0;s<e.length;s+=1){let a=e[s],c=o,d=Lt(o,a.patch),l;d.ok?(l=d.document,o=l):l=c;let u=new Set;for(let p of a.patch)u.add(Ge(p.path)),p.from!==void 0&&u.add(Ge(p.from));let _=[...u].sort((p,h)=>p.localeCompare(h));if(s>=r)if(n!==void 0){if(!u.has(n))continue;let p={field:n,before:_e(c,n),after:_e(l,n)};i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:[n],changes:[p]})}else{let p=_.map(h=>({field:h,before:_e(c,h),after:_e(l,h)}));i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:_,changes:p})}}return i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7426082f-94a6-5b4e-9748-d3faab2fe1d4")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4a376062-2e23-5991-80a5-27183909caf3")}catch{}})();var Ln=new Set(["none","null","undefined"]);function Ua(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new m("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",f.USAGE)}function Dn(e){if(typeof e!="string")throw new m("--parent must be a string. Use --unset parent to clear this field.",f.USAGE);let t=e.trim();if(t.length===0)throw new m("--parent must not be empty. Use --parent none to unset.",f.USAGE);if($t(t))throw new m(`--parent must not use placeholder token "${t}". Use --unset parent to clear this field.`,f.USAGE);return t}function $t(e){return Ln.has(e.trim().toLowerCase())}function Rn(e,t){if(t==="strict_error")throw new m(`Parent item "${e}" was not found. Create it first or use --parent none.`,f.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function Mn(e,t,r){let n=de(e,r),o=de(t,r);if(n!==o)return;let i=t!==o||e!==n?` (normalized from parent "${t}" and item "${e}")`:"";throw new m(`Parent item "${o}" cannot be the same as item "${n}"${i}. Use --unset parent to clear this field.`,f.USAGE)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d5003dd5-f208-5734-9711-dff935d8c851")}catch{}})();var q="-",zt=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function Ft(e){let t=e.trim();if(t==="")return[];let n=($n(t)??t.split(",")).map(o=>o.trim()).filter(Boolean).map(o=>o.toLowerCase());return Array.from(new Set(n)).sort((o,i)=>o.localeCompare(i))}function Ut(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of Ft(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function Vt(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function kn(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function Nn(e,t,r){let n=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new m('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',f.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});a.length>0&&!n.includes(a)&&n.push(a)}let o=[],i=n;for(let s of r??[]){let a=s.trim();if(a.length!==0){if(!i.includes(a)){o.push(a);continue}i=i.filter(c=>c!==a)}}return{criteria:i,unmatchedRemovals:o}}function On(e,t){let r=Vt(e);if(!t||t.length===0)return Array.from(new Set(r)).sort((o,i)=>o.localeCompare(i));let n=new Set(r);for(let o of Ut(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function Pn(e,t){let r=Array.from(new Set(Vt(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(Ut(t));return n.size===0?r:r.filter(o=>!n.has(o))}function $n(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):"").filter(n=>n.length>0)}function We(e){return e.replace(/\r\n/g,`
|
|
3
3
|
`)}function qt(e){let t=We(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
|
|
4
4
|
`);return r.length<2||r.at(-1)?.trim()!=="```"?e:r.slice(1,-1).join(`
|
|
@@ -15,4 +15,4 @@ ${i}`;continue}return null}return r}function jn(e,t){let r=qt(e).trim();if(!r)th
|
|
|
15
15
|
`)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=zs(o)),t.push(o))}catch{}}return t}function Fs(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let r=Date.parse(e.enqueued_at);return Number.isNaN(r)?!1:r<t}function Yr(e,t){let r=Vr(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>Ir||Fs(i,r)||i.attempts>=Ar){o+=1;continue}n.push(i)}if(n.length>yr){let i=n.length-yr;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function Us(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
|
|
16
16
|
`),n=r.length>0?`${r}
|
|
17
17
|
`:"";for(let o=0;;o+=1)try{await S(wt(e),n);return}catch(i){let s=Cr[o];if(s===void 0||!qr(i))throw i;await jr(s)}}async function Tr(e,t,r,n){return bt(async()=>{let o=await T(wt(e)),i=o===null?[]:Hr(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=Yr(s,t);return await Us(e,a),a.length})}async function Vs(e,t){let r=await T(wt(e));if(r===null||r.trim().length===0){await v(e,{pending_otel_spans:0});return}let n=Hr(r),{entries:o,prunedCount:i}=Yr(n,t),s=o.filter(h=>Ur(h.next_attempt_after)).slice(0,as);if(s.length===0){let h=i>0?await Tr(e,t,new Set,new Map):o.length;await v(e,{pending_otel_spans:h});return}let a=M(),c=new Set,d=new Map,l=0,u;await Promise.all(s.map(async h=>{try{let y=await $r(h.endpoint,{"content-type":"application/json"},JSON.stringify(h.payload));if(y<200||y>=300)throw new Error(`local_otel_export_http_${y}`);c.add(h.id),l+=1}catch(y){u=y instanceof Error?ht(y.message,"redacted"):"local_otel_export_failed";let w=h.attempts+1;d.set(h.id,{attempts:w,next_attempt_after:Fr(w)})}}));let _=await Tr(e,t,c,d),p={pending_otel_spans:_,last_otel_attempt_at:a};l>0&&(p.last_otel_success_at=a),u!==void 0?(p.last_otel_failure_at=a,p.last_otel_failure_error=u):_===0&&(p.last_otel_failure_at=void 0,p.last_otel_failure_error=void 0),await v(e,p)}async function qs(e,t,r){try{await Bs(e,t,r)}catch{}try{await Vs(e,r)}catch{}}async function js(e,t=_s){try{let r=Cs(e),n=await ts(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=x.join(r,i.name);(await xr(s)).mtimeMs<o&&await yt(s,{force:!0})}))}catch{}}async function bt(e){let t=br.catch(()=>{}).then(e);return br=t.catch(()=>{}),t}async function St(e){let t=await T(ve(e));return t===null||t.trim().length===0?[]:zr(t)}async function Hs(e,t,r){return bt(async()=>{let n=await St(e),{entries:o}=Et(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await Ce(e,i),i})}async function Ys(e,t,r,n){return bt(async()=>{let o=await St(e),{entries:i}=Et(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:Fr(c)}});return await Ce(e,s),s})}async function Bs(e,t,r){await js(e);let n=t.trim();if(n.length===0)return;let o=await T(ve(e));if(o===null||o.trim().length===0){await v(e,{endpoint:n,queue_entries:0});return}let i=zr(o);if(i.length===0){await v(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=Et(i,r);if(s.length===0){await Ce(e,[]),await v(e,{endpoint:n,queue_entries:0});return}let c=s.filter(p=>Ps(p)).slice(0,ds);if(c.length===0){a>0&&await Ce(e,s),await v(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(p=>p.event.event_id)),l=M(),u={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(u["x-pm-telemetry-key"]=_);try{let p=await $r(n,u,JSON.stringify({schema_version:cs,events:c.map(h=>h.event)}));if(p<200||p>=300)throw new Error(`telemetry_flush_http_${p}`)}catch(p){let h=await Ys(e,d,l,r),y=p instanceof Error?ht(p.message,"redacted"):"telemetry_flush_failed";await v(e,{endpoint:n,queue_entries:h.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:y});return}try{let p=await Hs(e,d,r);await v(e,{endpoint:n,queue_entries:p.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(p){let h=p instanceof Error?ht(p.message,"redacted"):"telemetry_flush_failed",y=await St(e).catch(()=>s);await v(e,{endpoint:n,queue_entries:y.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:h})}}async function Gs(e){let t=Dr(e);await _t(x.dirname(t),{recursive:!0});try{return await _t(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await xr(t);return Date.now()-r.mtimeMs<hs?!1:(await yt(t,{recursive:!0,force:!0}),await _t(t),!0)}catch{return!1}}function Ws(e){try{es(e,{recursive:!0,force:!0})}catch{}}function Ks(e){Ws(vs(e))}async function Qs(e,t,r){let n=await Gs(e);if(Ks(e),!!n)try{await qs(e,t,r)}finally{try{await yt(Dr(e),{recursive:!0,force:!0})}catch{}}}async function cl(e=Me(process.cwd())){if(!Ns())try{if(!(await L(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await Os(e);await Qs(e,r,n)}catch{}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1bcfba24-e761-571c-96e6-36bbc12d2814")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="13c02696-29a7-598e-888a-3502fd88bfbe")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="33a43890-abcf-58fc-bf9d-bf2619d4cf35")}catch{}})();var Xs=3,Br=20,Js=.8,Zs=100,Gr=1e3,Wr=1e6;function Ip(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`,`likely_duplicate_recovery:${e.recovery.action}:${e.recovery.item_id}`]}async function ea(e,t){let r=e.items[0],n=W(t.cwd??process.cwd(),t.pmRoot),o=ie((await L(n)).schema);return $e(r.status,o)?{action:"reopen",item_id:r.id,command:`pm item reopen ${r.id} "<recurrence reason>"`,args:["item","reopen",r.id,"<recurrence reason>"]}:{action:"reuse",item_id:r.id,command:`pm get ${r.id} --full`,args:["get",r.id,"--full"]}}function Kr(e){let t=e.limit??Xs,r=e.threshold??Js;if(!Number.isSafeInteger(t)||t<0||t>Br)throw new m(`Similarity limit must be an integer from 0 to ${Br}.`,f.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new m("Similarity threshold must be a number from 0 to 1.",f.USAGE);return{limit:t,threshold:r}}function ta(e){let t=e.limit??Zs;if(!Number.isSafeInteger(t)||t<0||t>Gr)throw new m(`Duplicate cluster limit must be an integer from 0 to ${Gr}.`,f.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new m("Duplicate cluster --since must be a valid ISO timestamp.",f.USAGE);return{limit:t,since:r}}async function ra(e,t){let r=W(e.cwd??process.cwd(),e.pmRoot),n=await L(r),o=U(n),i=e.statuses?.map(u=>u.trim().toLowerCase()).filter(Boolean);if(e.statuses!==void 0&&i?.length===0)throw new m("Duplicate cluster statuses must include at least one lifecycle status or all.",f.USAGE);let s=ie(n.schema),a=i?.map(u=>{if(u==="all")return u;let _=Q(u,s);if(!_)throw new m(`Unknown duplicate-cluster status "${u}". Allowed: all, ${s.definitions.map(p=>p.id).join(", ")}.`,f.USAGE);return _}),c=a?.includes("all")===!0;if(c&&a?.some(u=>u!=="all"))throw new m('The "all" status cannot be combined with other statuses.',f.USAGE);let d=c?void 0:a,l=d?new Set(d):void 0;return{items:(await le(r,n.item_format,o.type_to_folder,void 0,n.schema)).filter(u=>(!l||l.has(u.status))&&(!t||new Date(u.created_at).getTime()>=t.getTime())).sort((u,_)=>u.id.localeCompare(_.id)).map(u=>({item:u,prepared:J(u.title)})),statuses:d}}function Qr(e,t=Wr){let r=new Set,n=[new Map,new Map,new Map];for(let[o,i]of e.entries()){let s=[[i.prepared.normalized],i.prepared.issueCodes,i.prepared.tokens];for(let[a,c]of s.entries())for(let d of c){let l=n[a].get(d)??[];for(let u of l)r.add(`${u}:${o}`);if(r.size>t)throw new m(`Duplicate sweep exceeded ${Wr} candidate pairs; narrow it with statuses or since.`,f.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the batch duplicate query until its deterministic candidate set fits the disclosed safety bound."});l.push(o),n[a].set(d,l)}}return r}var Ap={buildDuplicateClusters:Jr,collectDuplicateCandidatePairs:Qr,createDuplicateUnionFind:Xr};function Xr(e){let t=Array.from({length:e},(n,o)=>o);return{parent:t,findRoot:n=>{let o=n;for(;t[o]!==o;)o=t[o];for(;t[n]!==n;){let i=t[n];t[n]=o,n=i}return o}}}function na(e,t,r,n){let o=[];for(let i of t){let[s,a]=i.split(":").map(u=>Number.parseInt(u,10)),c=me(e[s].prepared,e[a].prepared);if(c.score<r)continue;let d=n.findRoot(s),l=n.findRoot(a);d!==l&&(n.parent[l]=d),o.push({left_id:e[s].item.id,right_id:e[a].item.id,...c})}return o}function Jr(e,t,r,n){let o=new Map;for(let i of e.keys()){let s=r.findRoot(i),a=o.get(s)??[];a.push(i),o.set(s,a)}return[...o.values()].filter(i=>i.length>1).map(i=>{let s=new Set(i.map(c=>e[c].item.id)),a=t.filter(c=>s.has(c.left_id)&&s.has(c.right_id)).sort((c,d)=>d.score-c.score||c.left_id.localeCompare(d.left_id)||c.right_id.localeCompare(d.right_id));return{id:e[i[0]].item.id,items:i.map(c=>{let d=e[c].item;return{id:d.id,title:d.title,status:d.status,type:d.type}}),matches:a,max_score:a[0]?.score??0}}).sort((i,s)=>s.max_score-i.max_score||i.id.localeCompare(s.id)).slice(0,n)}function oa(e,t,r,n,o){return t.filter(i=>!r.has(i.id)).map(i=>({id:i.id,title:i.title,status:i.status,type:i.type,...fe(e,i.title)})).filter(i=>i.score>=n).sort((i,s)=>s.score-i.score||i.id.localeCompare(s.id)).slice(0,o)}async function ia(e,t={}){let r=e.title.trim();if(r.length===0)throw new m("Similarity candidate title must not be empty.",f.USAGE);let{limit:n,threshold:o}=Kr(t),i=W(t.cwd??process.cwd(),t.pmRoot),s=await L(i),a=U(s),c=await qe(i,Object.values(a.type_to_folder)),d=Z(r),l=c&&d.length>0?await Ve({pmRoot:i,expectedSourceCursor:c.source_cursor,query:d.map(p=>`"${p.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(n*10,50)}):null,u=l===null?await le(i,s.item_format,a.type_to_folder,void 0,s.schema):l.items,_=oa(r,u,new Set(e.excludeIds??[]),o,n);return{items:_,count:_.length,threshold:o,source:l?"persistent_index":"metadata_fallback"}}async function Cp(e={}){let{threshold:t}=Kr({...e,limit:void 0}),{limit:r,since:n}=ta(e),{items:o,statuses:i}=await ra(e,n),s=Qr(o),a=Xr(o.length),c=na(o,s,t,a),d=Jr(o,c,a,r);return{clusters:d,count:d.length,threshold:t,source:"metadata_scan",filters:{statuses:i??null,since:e.since??null},cost:{item_count:o.length,candidate_pairs:s.size,scored_pairs:s.size}}}async function vp(e,t){if(t.mode==="off")return;let r=await ia(e,t);if(r.count===0)return;let n=await ea(r,t),o=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!o){let i=r.items.map(a=>`${a.id} (${a.status}): ${a.title}`).join("; "),s=n.action==="reopen"?"Reopen the canonical item":"Reuse the canonical item";throw new m(`Likely duplicate item(s) found: ${i}. ${s} or pass --allow-duplicate with explicit intent.`,f.CONFLICT,{code:"likely_duplicate",required:`${s}, or explicitly acknowledge the duplicate with --allow-duplicate.`,recovery:{suggested_flags:["--allow-duplicate"],suggested_retry:n.command,suggested_retry_args:n.args}})}return{mode:t.mode,bypassed:o,result:r,recovery:n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="412fc2d2-daee-5d87-82ab-5411a1503087")}catch{}})();function Rp(e,t){let r=t??{};return e.filter(n=>r[n.id]!==n.updated_at).map(n=>n.id).sort((n,o)=>n.localeCompare(o))}export{bn as a,Sn as b,xn as c,In as d,Da as e,An as f,Cn as g,Ge as h,vn as i,Ua as j,Dn as k,$t as l,Rn as m,Mn as n,Ft as o,kn as p,Nn as q,On as r,Pn as s,jn as t,Bn as u,Gn as v,Kn as w,Qn as x,Xn as y,eo as z,Qa as A,no as B,rc as C,ao as D,lo as E,tn as F,uo as G,fo as H,ge as I,Po as J,xc as K,Qe as L,Zt as M,Xe as N,Wo as O,Ko as P,Cc as Q,er as R,j as S,Ze as T,tt as U,dt as V,zc as W,lt as X,xe as Y,ar as Z,Ie as _,ut as $,ft as aa,mt as ba,pt as ca,mr as da,pr as ea,id as fa,cn as ga,Rt as ha,ln as ia,un as ja,fn as ka,fa as la,pa as ma,X as na,ue as oa,Z as pa,J as qa,fe as ra,me as sa,Mt as ta,gn as ua,Yi as va,Wi as wa,Qi as xa,Xi as ya,cs as za,Ar as Aa,bs as Ba,cl as Ca,Rp as Da,Ip as Ea,Ap as Fa,ia as Ga,Cp as Ha,vp as Ia};
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
18
|
+
//# sourceMappingURL=chunk-PH2OXXVZ.js.map
|