@unbrained/pm-cli 2026.10.8 → 2026.10.10
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 +36 -0
- package/dist/cli/register-list-query.js +2 -2
- package/dist/cli/register-mutation.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +150 -150
- package/dist/cli-bundle/chunks/{chunk-MJVRF67I.js → chunk-2JYTSTQP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UGFN5NJ2.js → chunk-BXSXT5Z6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HFCIAXLP.js → chunk-ESRACL6K.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-34L2BS2Z.js → chunk-K2UTE75T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZHIMZ65M.js → chunk-KNW3RSLS.js} +30 -30
- package/dist/cli-bundle/chunks/chunk-MEWBSWE3.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-RCFZ6H2Y.js → chunk-OBLO45UM.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FOLSEOJ2.js → chunk-RBPOO46D.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TNU56MZI.js → chunk-RUT3CCAG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-K6E2FFUT.js → chunk-S445XEYT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZBVAZ7XX.js → chunk-SSY4OSJR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OG66KEOF.js → chunk-YMLF6QT7.js} +75 -79
- package/dist/cli-bundle/chunks/{chunk-L7U5FSZ5.js → chunk-ZWRLAOA4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-PYVSPGPV.js → register-list-query-T6BOR67M.js} +7 -7
- package/dist/cli-bundle/chunks/register-mutation-6NXR7SAJ.js +20 -0
- package/dist/cli-bundle/chunks/{register-operations-WL25C3NP.js → register-operations-PDOBQZUJ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-PFKYNEQI.js → register-setup-MAYFPKBX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6TKAFFEB.js → chunk-2CJWTLQG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EOUORVJA.js → chunk-52UJEHEV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-V3EPBB6V.js → chunk-AU6VJGTY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-L3CZNKZE.js → chunk-B3YW6H2I.js} +16 -20
- package/dist/cli-bundle/focused-chunks/{chunk-XT7JAVHI.js → chunk-DMSADMEU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-A3W6HFFO.js → chunk-EIOQNLBQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OLCJ2PJS.js → chunk-GVGFUD52.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2KSPGWLH.js → chunk-JGFSSR3G.js} +16 -16
- package/dist/cli-bundle/focused-chunks/{chunk-MW2TQHZ3.js → chunk-KNJR2WUO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MJQ253F3.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-F2ME5MJY.js → chunk-PBCYGO7X.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PBPPIGUL.js → chunk-PLTTMQAW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SIEGIPNT.js +165 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DRHJOG5X.js → chunk-W5AE7GKZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LZQGEVKT.js → chunk-WAOXID5J.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BDT5EALU.js → chunk-WOEZJUA2.js} +2 -2
- package/dist/cli-bundle/main.js +2 -2
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +22 -22
- 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 +50 -50
- 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 +9 -9
- package/dist/core/history/event-index.d.ts +1 -2
- package/dist/core/history/event-index.js +2 -2
- package/dist/core/item/item-format.d.ts +2 -0
- package/dist/core/item/item-format.js +3 -3
- package/dist/core/output/output.d.ts +16 -14
- package/dist/core/output/output.js +6 -10
- package/dist/core/schema/runtime-field-values.d.ts +2 -2
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/store/item-format-migration.js +1 -1
- package/dist/core/store/item-metadata-query-index.d.ts +1 -2
- package/dist/core/store/item-metadata-query-index.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/store/sqlite-runtime.d.ts +15 -0
- package/dist/core/store/sqlite-runtime.js +2 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/governance/reliability.d.ts +74 -0
- package/dist/sdk/governance/reliability.js +2 -0
- package/dist/sdk/governance.d.ts +1 -0
- package/dist/sdk/governance.js +1 -1
- package/dist/sdk/output/table-rows.d.ts +37 -0
- package/dist/sdk/output/table-rows.js +2 -0
- package/dist/sdk/output.d.ts +1 -0
- package/dist/sdk/output.js +2 -2
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output-contracts.d.ts +3 -3
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/structured-mutations.d.ts +5 -1
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/test/workspace-snapshot.d.ts +1 -1
- package/dist/sdk/test/workspace-snapshot.js +1 -1
- package/docs/AGENT_OUTPUT_ENCODINGS.md +119 -0
- package/docs/PACKAGE_GATE_ACCEPTANCE.md +56 -0
- package/docs/QUALITY_EVIDENCE.md +52 -1
- package/docs/README.md +2 -0
- package/docs/RELEASE_RELIABILITY.md +54 -3
- package/docs/SDK.md +16 -2
- package/docs/TESTING.md +47 -3
- package/docs/agent-task-token-baseline.json +15 -14
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
- 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-claude/package.json +2 -2
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +2 -2
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +2 -2
- package/dist/cli-bundle/chunks/chunk-JDTBPW4Y.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-WXP3YLIN.js +0 -20
- package/dist/cli-bundle/focused-chunks/chunk-OSKXYRYZ.js +0 -165
- package/dist/cli-bundle/focused-chunks/chunk-PEBOVLEG.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as w,i as y,j,k as B,l as U,o as f,p as X,q as W,r as Y}from"./chunk-
|
|
1
|
+
import{f as w,i as y,j,k as B,l as U,o as f,p as X,q as W,r as Y}from"./chunk-W5AE7GKZ.js";import{M as H,a as $,b as D}from"./chunk-2CJWTLQG.js";import{c as u,f as M,g as z,i as q}from"./chunk-PLTTMQAW.js";import{Va as F,q as L,t as R}from"./chunk-WOEZJUA2.js";import{e as g,h as K}from"./chunk-PBCYGO7X.js";import{Ia as k,a as N,e as O,f as A,g as x,h as C,o as P}from"./chunk-B3YW6H2I.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]="3ec1f825-59d1-5ce2-ac76-c628264bd8be")}catch{}})();var Ce=N,Pe=O,$e=C,De=A,Le=x;function G(e,t,n,r){let s=e.flag.slice(2).replace(/[-_]([a-z])/gu,(a,i)=>i.toUpperCase()),o=n.has(s);return{long:t,...r?{short:r}:{},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(s=>s.keys)),r=[];for(let s of L(e.map(o=>({...o})))){r.push(G(s,s.flag,n,s.short));for(let o of s.aliases??[])r.push(G(s,o,n))}return r}var Re=Q(R,$),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]="59d16a38-d6df-5695-96e3-28b6e384f76b")}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 y,j,k as B,l as U,o as f,p as X,q as W,r as Y}from"./chunk-DR
|
|
|
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 je(){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 re(e=[]){let t=_.map(o=>({definition:I[o],source:"builtin"})),n=new Set(_.map(o=>p(o))),r=new Set(n),s=[];for(let o of e){let a=p(o.profile.name);if(n.has(a)){s.push(`Extension "${o.name}" profile "${o.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(r.has(a)){s.push(`Profile "${o.profile.name}" from extension "${o.name}" duplicates an already-registered profile and was ignored.`);continue}r.add(a),t.push({definition:o.profile,source:"extension",package:o.name})}return{profiles:t,warnings:s}}function Be(e,t=[]){let{profiles:n,warnings:r}=re(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${J(n)}.`);let s=p(e),o=n.find(a=>p(a.definition.name)===s);if(o===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${J(n)}.`);return{resolved:o,warnings: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]="ab26bcb3-fb2a-5f2f-96e7-7965787b924e")}catch{}})();function se(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:se(e),types:e.types.map(t=>S(()=>u(t).name,()=>String(t.name??""))),statuses:e.statuses.map(t=>S(()=>f(t).id,()=>String(t.id??""))),fields:e.fields.map(t=>S(()=>y(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]="2ae4f6da-17c5-5024-89a2-bb0a4be9a683")}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_default_mode",path:"search.default_mode",kind:"string",choices:["auto","keyword","semantic","hybrid"],summary:"Mode a bare pm search runs in: auto (hybrid when semantic search is explicitly configured and runnable, else keyword), or a pinned keyword, semantic, or hybrid."},{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:"agent_identity_probes_enabled",path:"agent_identity.probes_enabled",kind:"boolean",summary:"Allow privacy-bounded local harness provenance probes; no network or subprocess access is permitted."},{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)."}],ae=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 ae.get(t)}function ie(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 r=Number(n);return Number.isFinite(r)?{ok:!0,value:r}:{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 ie(e,t);if(e.kind==="string")return le(e,t,n);let r=de(e,t,n);return r.ok?e.kind==="integer"?ce(e,t,r.value):e.kind==="ratio"?me(e,t,r.value):pe(e,t,r.value):{ok:!1,error:r.error}}function V(e,t){let n=t.path.split("."),r=e;for(let s of n){if(typeof r!="object"||r===null)return null;let o=Object.getOwnPropertyDescriptor(r,s);if(!o||!Object.hasOwn(o,"value"))return null;r=o.value}return typeof r=="string"||typeof r=="number"||typeof r=="boolean"?r:null}function Ge(e,t,n){let r=t.path.split(".");if(r.some(a=>a.length===0||["__proto__","constructor","prototype"].includes(a)))throw new Error("Unsafe settings path");let s=e;for(let a=0;a<r.length-1;a+=1){let i=r[a],d=Object.getOwnPropertyDescriptor(s,i)?.value;if(typeof d!="object"||d===null||Array.isArray(d)){let c={};Object.defineProperty(s,i,{value:c,writable:!0,enumerable:!0,configurable:!0}),s=c}else s=d}let o=r[r.length-1];return Object.getOwnPropertyDescriptor(s,o)?.value===n?!1:(Object.defineProperty(s,o,{value:n,writable:!0,enumerable:!0,configurable:!0}),!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]="0b04624c-2096-55dc-9dde-b8c76ead72d6")}catch{}})();var it=["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(P.map(e=>e.toLowerCase()));function ye(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 fe(e,t){let n=new Set,r=new Set;for(let[s,o]of e.types.entries()){let a;try{a=u(o).name}catch(d){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof o.name=="string"?o.name:`#${s}`,message:k(d)});continue}let i=a.toLowerCase();if(r.has(i)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:a,message:`Item type "${a}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}r.add(i),n.add(i)}return n}function he(e,t){let n=new Set,r=new Set;for(let[s,o]of e.statuses.entries()){let a;try{a=f(o)}catch(i){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof o.id=="string"?o.id:`#${s}`,message:k(i)});continue}if(r.has(a.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:a.id,message:`Status "${a.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}r.add(a.id),n.add(a.id);for(let i of a.aliases??[])n.add(g(i))}return n}function ge(e,t){let n=new Set;for(let[r,s]of e.fields.entries()){let o;try{o=y(s).key}catch(i){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof s.key=="string"?s.key:`#${r}`,message:k(i)});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 a=H(o);a&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:o,message:`Field "${o}" collides with canonical MCP property "${a.property}" owned by ${a.owner}; callers must pass the custom value through ${a.nested_path}.`})}}function _e(e,t,n,r){let s=new Set;for(let[o,a]of e.workflows.entries()){let i=a.type.trim().toLowerCase();if(i.length===0){r.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 d=s.has(i);s.add(i),d?r.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:a.type,message:`Workflow type "${a.type}" is declared more than once; the later transition set wins.`}):!Z.has(i)&&!t.has(i)&&r.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:a.type,message:`Workflow governs type "${a.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});let c=new Set;for(let l of a.allowed_transitions){let m=g(l[0]),T=g(l[1]);if(m.length===0||T.length===0){r.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:a.type,message:`Workflow "${a.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)||c.has(h)||(c.add(h),r.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:h,message:`Workflow "${a.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 r of e.config){let s=b(r.key);if(s===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:r.key,message:`Config knob "${r.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}n.has(s.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:s.key,message:`Config knob "${s.key}" is set more than once; the later value silently overwrites the earlier one.`}):n.add(s.key);let o=v(s,r.value);o.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:r.key,message:o.error.message})}}function we(e,t,n){for(let r of e.templates){let s=r.options.type;if(typeof s!="string"||s.trim().length===0)continue;let o=s.trim().toLowerCase();!Z.has(o)&&!t.has(o)&&n.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:r.name,message:`Template "${r.name}" creates type "${s}" which is neither a built-in type nor declared by this profile.`})}}function be(e,t){for(let[n,r]of e.packages.entries())r.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=[];ye(e,t);let n=fe(e,t),r=he(e,t);ge(e,t),_e(e,n,r,t),ke(e,t),we(e,n,t),be(e,t);let s=t.filter(a=>a.severity==="error").length,o=t.length-s;return{profile:e.name,ok:s===0,findings:t,errorCount:s,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]="be2b507d-2797-570c-b211-46d950edcbde")}catch{}})();function E(e,t,n,r,s){let o=e,a=[];for(let i of t){let d=r(o),c=s(o,i),l=r(c.file);o=c.file;let m=d===l?"unchanged":c.replaced?"update":"add";a.push({key:n(i),status:m})}return{file:o,changes:a,changed:a.some(i=>i.status!=="unchanged")}}function ee(e){return JSON.stringify(e.map(t=>t.join("\0")).sort())}function ve(e,t){let n=e.map(s=>({...s})),r=[];for(let s of t){let o=n.findIndex(i=>i.type===s.type),a={type:s.type,allowed_transitions:s.allowed_transitions};o<0?(n.push(a),r.push({type:s.type,status:"add"})):ee(n[o].allowed_transitions)===ee(s.allowed_transitions)?r.push({type:s.type,status:"unchanged"}):(n[o]=a,r.push({type:s.type,status:"update"}))}return{changes:r,result:n,changed:r.some(s=>s.status!=="unchanged")}}function Ie(e,t){let n=[];for(let r of e.config){let s=b(r.key);if(s===void 0)throw new Error(`Profile "${e.name}" references unknown config key "${r.key}".`);let o=v(s,r.value);if(!o.ok)throw new Error(`Profile "${e.name}" config ${r.key}: ${o.error.message}`);let a=V(t,s),i=a===null?"add":a===o.parsed.value?"unchanged":"update";n.push({key:s.key,path:s.path,value:o.parsed.value,status:i})}return{changes:n,changed:n.some(r=>r.status!=="unchanged")}}function te(e){let t=Object.entries(e).sort(([n],[r])=>n.localeCompare(r));return JSON.stringify(t)}function Se(e,t){let n=[];for(let r of e.templates){let s=t.get(r.name),o;s===void 0?o="add":te(s)===te(r.options)?o="unchanged":o="update",n.push({name:r.name,options:r.options,status:o})}return{changes:n,changed:n.some(r=>r.status!=="unchanged")}}function ft(e,t){let n=E(M(t.typesRaw),e.types,l=>u(l).name,q,(l,m)=>z(l,u(m))),r=E(X(t.statusesRaw),e.statuses,l=>f(l).id,W,(l,m)=>Y(l,f(m))),s=E(j(t.fieldsRaw),e.fields,l=>y(l).key,B,(l,m)=>U(l,y(m))),o=ve(t.workflows,e.workflows),a=Ie(e,t.settings),i=Se(e,t.templates),d=e.packages.map(l=>({spec:l.spec,reason:l.reason,status:t.installedPackages.has(l.spec)?"installed":"recommended"})),c=n.changed||r.changed||s.changed||o.changed||a.changed||i.changed;return{profile:{name:e.name,title:e.title,summary:e.summary},types:n,statuses:r,fields:s,workflows:o,config:a,templates:i,packages:d,changed:c}}export{Ce as a,Pe as b,$e 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,je as m,re as n,Be as o,se as p,Ye as q,oe as r,b as s,v as t,V as u,Ge as v,it as w,lt as x,dt as y,ft as z};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-DMSADMEU.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as ft,E as Xt,F as gi,Ia as Ai,O as st,Q as ue,Qa as q,R as at,Ra as Mi,S as ct,Sa as $i,T as bi,Ua as Te,V as Ei,Va as Oi,W as Ci,Wa as Li,X as lt,Xa as Ni,Y as Ii,Ya as Pi,Z as ut,Za as ji,_ as mt,aa as xi,ab as Ui,bb as Bi,db as Wi,ea as Ti,eb as zi,fa as Jt,g as pi,h as hi,hb as Vi,ib as Zt,jb as en,kb as W,oa as Ri,ob as Ki,pb as Yi,ub as Qi,wb as Ji,za as fe}from"./chunk-2KSPGWLH.js";import{e as it,f as Yt,g as ti,h as ni}from"./chunk-V3EPBB6V.js";import{Na as jr,Va as Ur}from"./chunk-BDT5EALU.js";import{$a as _i,Ab as G,Ba as ui,Bb as ne,Cb as re,D as ee,Eb as ki,Fb as me,Ia as ot,Ib as Si,Ja as mi,Ka as fi,Mb as Ce,Ob as Ie,Rb as xe,Sb as Di,T as L,Tb as Fi,U as R,Ub as pt,V as J,Xa as M,Y as di,Yb as Gi,Zb as Hi,_a as yi,aa as te,ac as qi,cb as wi,eb as Qt,f as ri,fa as li,g as ii,h as oi,i as si,j as ai,n as Ee,oc as Xi,w as ci,wb as dt,yb as vi}from"./chunk-OSKXYRYZ.js";import{b as Ar,n as P,p as Q}from"./chunk-F2ME5MJY.js";import{$ as f,$a as T,$c as le,$d as Xr,Ab as Pr,Ba as zt,Bd as Vr,Cd as Kr,Ea as ke,Fa as Ye,Ge as Kt,H as de,Hd as Yr,Ka as $r,La as Or,M as Wt,Mc as C,Me as Zr,N as Ve,Ne as ei,Rc as Se,V as Tr,Va as D,Vc as Br,Yd as F,Z as Rr,aa as h,ad as Gr,ae as E,bb as Lr,be as Qr,cd as Qe,ce as H,db as Vt,ed as Je,fb as Xe,fd as Ze,gd as Hr,i as xr,ie as et,jd as qr,kd as Wr,ke as tt,ld as zr,me as nt,pe as Jr,qe as rt,sa as Dr,ta as Ke,tb as Nr,ua as Fr,ya as Mr}from"./chunk-L3CZNKZE.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]="7dd9061f-1b49-5ecb-a306-74f09283fe57")}catch{}})();var Qs="PmCliError";function Jm(e){if(!Zs(e)||e.code!=="item_already_exists"||e.exitCode!==f.CONFLICT)return!1;let t=e.context;return typeof t=="object"&&t!==null&&t.code==="item_already_exists"&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.path=="string"&&t.path.trim().length>0}function Js(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=f.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function Zi(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new h(e,Js(t.exitCode??f.USAGE),t.context??{});return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function Zs(e){if(!(e instanceof Error)||e.name!==Qs)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)}(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]="b70f6764-9f83-5371-8ebc-1d0d5703bc1f")}catch{}})();var ea=["invalid_envelope","source_incomplete","source_unchecked","filtered_corpus","terminal_items_excluded","strict_read_unproven","page_incomplete","count_mismatch","projection_incomplete","field_omission","omission_receipt_missing","omission_receipt_invalid","read_output_missing","read_output_invalid","read_output_dimensions_incomplete","budget_compaction","budget_omission","session_projection","invalid_item_id","duplicate_item_id"],tn=class extends Error{receipt;constructor(t){super(`Complete-list certification failed: ${t.map(n=>n.code).join(", ")}.`),this.name="PmCompleteListValidationError",this.receipt={contract_version:1,contract:"complete_list",findings:t,recovery:{suggested_retry:"pm list --all --output-include full --strict-read --no-truncate --output-budget unbounded --output-limit unbounded --json",sdk:"await client.listAllComplete()"}}}};function tf(e={}){return Yr({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e,t,n,r){t&&e.push({code:n,message:r})}function ta(e,t){let n=z(e.completeness)?e.completeness:{};I(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),I(t,n.status!=="complete"&&n.status!=="partial","source_unchecked","The source scan did not prove completeness.");let r=n.unreadable_item_count,i=n.unreadable_directory_count;I(t,n.status==="complete"&&(r!==0||i!==0)&&Number.isSafeInteger(r)&&Number.isSafeInteger(i),"source_incomplete","The source scan reports unreadable tracker artifacts despite a complete status."),I(t,n.status==="complete"&&(!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||Number(r)<0||Number(i)<0),"source_unchecked","The source scan did not report safe non-negative unreadable counts.");let o=z(e.filters)?e.filters:{},s=z(o.runtime_filters)?o.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return I(t,o.status!=="all"||Object.keys(s).length>0||Object.keys(o).some(d=>!a.has(d)),"filtered_corpus","The list did not explicitly select every lifecycle status."),I(t,o.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),I(t,o.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),o}function na(e,t,n){I(n,e.has_more!==!1||e.next_cursor!==null||e.truncated!==!1||e.applied_limit!==void 0||t.no_truncate!==!0,"page_incomplete","Pagination or a row ceiling may have withheld items."),I(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let r=z(e.projection)?e.projection:{};I(n,r.mode!=="full"||r.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let i=z(e.omission_receipt)?e.omission_receipt:void 0;I(n,i===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),I(n,i!==void 0&&(i.has_omissions!==!1||i.omitted_field_group_count!==0||!Number.isSafeInteger(i.omitted_field_group_count)||!Array.isArray(i.omitted_field_groups)||i.omitted_field_groups.length!==0),"omission_receipt_invalid","The field-omission receipt is malformed or contradicts its no-omission claim."),I(n,i?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function ra(e){return e.contract_version!==1||e.command!=="list"||e.within_budget!==!0||e.strings_compacted!==!1||e.rows_compacted!==!1||e.result_omitted!==!1}function ia(e){if(!Array.isArray(e.requested_dimensions))return!1;let t=new Set(e.requested_dimensions);return["include","amount","cost"].every(n=>t.has(n))}function oa(e,t){let n=z(e.read_output)?e.read_output:void 0;I(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),I(t,n!==void 0&&ra(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),I(t,n!==void 0&&!ia(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),I(t,n?.strings_compacted===!0||n?.rows_compacted===!0||e.output_budget_truncation!==void 0,"budget_compaction","Universal output shaping compacted the result.");let r=z(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;I(t,n?.result_omitted===!0||r?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),I(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function sa(e,t){let n=e.map(r=>z(r)&&typeof r.id=="string"?r.id.trim():"");I(t,n.some(r=>r.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),I(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function aa(e){if(!z(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:ea[0],message:"The result must be an object with an items array."}]};let t=e,n=[],r=ta(t,n);return na(t,r,n),oa(t,n),sa(t.items,n),{ok:n.length===0,findings:n}}function ca(e){let t=aa(e);if(!t.ok)throw new tn(t.findings);let n=e;return{...n,complete_list:{contract_version:1,item_count:n.items.length,unique_item_id_count:new Set(n.items.map(r=>r.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function nf(e){ca(e)}(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]="499dfc08-cf70-55fe-8868-65c3107e3a91")}catch{}})();async function af(e,t={}){let n=await Qi({pmRoot:T(process.cwd(),e.path),exhaustive:t.exhaustive,...t.status===void 0?{}:{statuses:t.status.flatMap(r=>r.split(",").map(i=>i.trim()).filter(Boolean))},...t.since===void 0?{}:{since:t.since},...t.threshold===void 0?{}:{threshold:t.threshold},...t.limit===void 0?{}:{limit:t.limit}});return{...n,clusters:n.clusters.map(r=>{let i=r.id;return{...r,canonical_id:i,close_command:`pm close <duplicate-id> --duplicate-of ${i}`}}),guidance:{strategy:"review_then_close_duplicate",command:"pm close <duplicate-id> --duplicate-of <canonical-id>"}}}(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]="1433b417-e41f-5963-a551-094132afd717")}catch{}})();var eo=16;async function to(e,t,n){let r=D(t,C()).type_to_folder,i=[],o=new Set,s=n;for(;s&&i.length<eo;){let a=s.trim().toLowerCase();if(!a||o.has(a))break;o.add(a);let d=await ne(e,s,t.id_prefix,t.item_format,r);if(!d)break;let c=await re(d,{schema:t.schema});i.push(c.document.metadata.id),s=c.document.metadata.parent}return i}async function ff(e){await oi({pmRoot:e.pmRoot,principal:e.principal,itemId:e.itemId,lineageIds:await to(e.pmRoot,e.settings,e.itemId)})}async function pf(e){await si(e)}async function hf(e){await ai({pmRoot:e.pmRoot,principal:e.principal,...e.itemId?{itemId:e.itemId,lineageIds:await to(e.pmRoot,e.settings,e.itemId)}:{}})}var gf={lineage_depth:eo,active_items:64,evidence_rows:32};function no(e){if(!e)return;let t={};for(let n of e.active_item_ids)t[n]=1;e.focused_item_id&&(t[e.focused_item_id]=1);for(let n of e.evidence){let r=/^lineage:(.+)$/u.exec(n)?.[1];r&&t[r]===void 0&&(t[r]=.75)}return Object.keys(t).length>0?t:void 0}import{encode as da}from"@toon-format/toon";(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]="809a4d75-4915-585d-9fc8-ad3e9ef15b1f")}catch{}})();var nn=["agenda","day","week","month"],rn=["markdown","toon","json"],la=["sun","mon","tue","wed","thu","fri","sat"],ua=365,ma=365,oo=28,fa=1e3;function on(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new h(`${t} must be a non-negative integer`,f.USAGE);return n}function pa(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw new h("Calendar include filter must not be empty",f.USAGE);let r=new Set;for(let i of n){if(i==="deadlines"||i==="deadline"){r.add("deadlines");continue}if(i==="reminders"||i==="reminder"){r.add("reminders");continue}if(i==="events"||i==="event"||i==="scheduled"){r.add("events");continue}throw new h("Calendar include filter must be deadlines|reminders|events|scheduled|all",f.USAGE)}return r}function so(e,t){let n;for(let r of t){let i=xr(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function ha(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!nn.includes(t)){let n=so(t,nn);throw new h(`Calendar view must be one of ${nn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function ga(e){if(!e)return;let t=e.trim().toLowerCase();if(!rn.includes(t)){let n=so(t,rn);throw new h(`Calendar format must be one of ${rn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function Sf(e,t){let n=ga(e.format);if(t.json&&n&&n!=="json")throw new h("Cannot combine --json with --format markdown|toon",f.USAGE);return t.json?"json":n??"markdown"}function ya(e,t){if(e===void 0)return;let n=L(e,t);if(!n){let r=t.definitions.map(i=>i.id);throw new h(`Calendar status filter must be one of ${r.join("|")}`,f.USAGE)}return n}function _a(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new h("Calendar assignee filter must be one of assigned|unassigned",f.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new h(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,f.USAGE);return t}function ht(e){return new Date(e).toISOString().slice(0,10)}function ao(e,t){if(!t||t==="UTC")return ht(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,i=n.find(s=>s.type==="month")?.value,o=n.find(s=>s.type==="day")?.value;if(r&&i&&o)return`${r}-${i}-${o}`}catch{}return ht(e)}function dn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function V(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function co(e){let t=new Date(dn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return V(t.toISOString(),r)}function wa(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function ba(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function va(e,t){return E(e,t)>=0?e:t}function ro(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function io(e,t){e.set(t,(e.get(t)??0)+1)}function ka(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,i)=>de(r)-de(i));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,i)=>r-i);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,i)=>r.localeCompare(i));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function lo(e,t,n,r){let i=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==t||i.getUTCDate()!==n))return i.toISOString()}function uo(e){return la[new Date(e).getUTCDay()]}function Sa(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function Ea(e){let t=new Set;for(let n of e??[]){let r=Sa(n);r&&t.add(r)}return t}function Ca(e,t,n,r,i){let o=e??V(n,-(r??ma)),s=t??V(e??n,i??ua);return{start:o,end:E(s,o)>0?s:V(o,1)}}function Ia(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[uo(e)],o=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??fa,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:Ea(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(i)].sort((s,a)=>de(s)-de(a)),sortedMonthDays:[...new Set(o)].sort((s,a)=>s-a),occurrences:[],produced:0}}function gt(e,t){return E(t,e.startAt)<0?"continue":e.until&&E(t,e.until)>0||E(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,E(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function yt(e,t){let n=uo(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function xa(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(yt(e,t)&>(e,t)==="stop");n+=1)t=V(t,e.interval);return e.occurrences}function Ta(e,t,n){let r=de(n),i=V(t,r),o=new Date(i);return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function Ra(e){let t=co(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=V(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=Ta(e,r,i);if(yt(e,o)&>(e,o)==="stop")return e.occurrences}}return e.occurrences}function Aa(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let o of e.sortedMonthDays){let s=lo(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!yt(e,s))&>(e,s)==="stop")return e.occurrences}}return e.occurrences}function Da(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=t+r*e.interval;for(let o of e.sortedMonthDays){let s=lo(i,n,o,e.startDate);if(!(!s||!yt(e,s))&>(e,s)==="stop")return e.occurrences}}return e.occurrences}function Fa(e,t,n,r){let i=Ia(e,t,n,r);return t.freq==="daily"?xa(i):t.freq==="weekly"?Ra(i):t.freq==="monthly"?Aa(i):Da(i)}function mo(e){return[...e].sort((t,n)=>{let r=E(t.at,n.at);if(r!==0)return r;let i=t.item_priority-n.item_priority;if(i!==0)return i;let o=t.item_id.localeCompare(n.item_id);if(o!==0)return o;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function ln(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Ma(e){return e.deadline?{at:e.deadline,date:ht(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...ln(e),item_deadline:e.deadline}:null}function $a(e){return(e.reminders??[]).map(t=>({at:t.at,date:ht(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...ln(e)}))}function Oa(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function La(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Na(e,t,n,r){let i=ka(t.recurrence),o=Oa(t.start_at,t.end_at);return(t.recurrence?Fa(t.start_at,t.recurrence,n,r):[t.start_at]).map(s=>({at:s,date:t.all_day===!0?s.slice(0,10):ao(s,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:La(s,t,o),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:i,...ln(e)}))}function Pa(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Ma(o):null;s&&i.push(s),n.has("reminders")&&i.push(...$a(o));for(let a of n.has("events")?o.events??[]:[])i.push(...Na(o,a,t,r))}return mo(i)}function ja(e,t,n,r,i){let o=$i(t.type,n),s=t.tag?.trim().toLowerCase(),a=Mi(t.priority),d=ya(t.status,r),c=t.assignee?.trim(),l=_a(t.assigneeFilter),u=t.sprint?.trim(),m=t.release?.trim();if(c&&(c.toLowerCase()==="none"||c.toLowerCase()==="null"))throw new h('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',f.USAGE);if(c!==void 0&&l==="unassigned")throw new h("Cannot combine --assignee with --assignee-filter unassigned",f.USAGE);return e.filter(p=>Ua(p,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:d,assigneeFilter:c,assigneeModeFilter:l,sprintFilter:u,releaseFilter:m,runtimeFieldFilters:i}))}function Ua(e,t){return Ba(e,t)&&Ga(e,t)&&ct(e,t.runtimeFieldFilters)}function Ba(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function Ga(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function Ha(e,t,n){return!(t&&E(e.at,t)<0||n&&E(e.at,n)>=0)}function sn(e,t,n){return e.trim().toLowerCase()==="today"?dn(t):H(e,new Date(t),n)}function qa(e,t,n){let r=t.date?sn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?sn(t.from,n,"--from"):void 0,a=t.to?sn(t.to,n,"--to"):void 0;if(s&&a&&E(s,a)>=0)throw new h("Calendar --from must be before --to",f.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new h("--from and --to are only supported for --view agenda",f.USAGE);if(e==="agenda")return Wa(r,t,n,i,o,s,a);if(e==="day"){let c=dn(r);return an(r,n,i,o,c,V(c,1))}if(e==="week"){let c=co(r);return an(r,n,i,o,c,V(c,7))}let d=wa(r);return an(r,n,i,o,d,ba(r))}function Wa(e,t,n,r,i,o,s){if(i)throw new h("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",f.USAGE);return{anchor:e,start:o??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function an(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:va(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function za(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:mo(r)}))}function Va(e){let t=new Set,n=new Map,r=new Map,i=0,o=0,s=0,a=0;for(let d of e)t.add(d.item_id),io(n,d.item_type),io(r,d.item_status),d.kind==="deadline"?i+=1:d.kind==="reminder"?o+=1:(s+=1,d.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:i,reminders:o,scheduled:s,by_kind:{deadline:i,reminder:o,event:s},by_type:ro(n),by_status:ro(r),recurring_events:a}}function Ka(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function fo(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(o=>o.type==="hour")?.value,i=n.find(o=>o.type==="minute")?.value;if(r&&i)return`${r}:${i}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function cn(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function Ya(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===ao(e.event_end,e.event_timezone)?fo(e.event_end,e.event_timezone):e.event_end:null}function Xa(e){let t=`${fo(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let i=Ya(e);return i&&n.push(`end=${i}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function Ef(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${Ka(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- by-kind: ${cn(e.summary.by_kind)}`),t.push(`- by-type: ${cn(e.summary.by_type)}`),t.push(`- by-status: ${cn(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),t.join(`
|
|
1
|
+
import{$ as ft,E as Xt,F as gi,Ia as Ai,O as st,Q as ue,Qa as q,R as at,Ra as Mi,S as ct,Sa as $i,T as bi,Ua as Te,V as Ei,Va as Oi,W as Ci,Wa as Li,X as lt,Xa as Ni,Y as Ii,Ya as Pi,Z as ut,Za as ji,_ as mt,aa as xi,ab as Ui,bb as Bi,db as Wi,ea as Ti,eb as zi,fa as Jt,g as pi,h as hi,hb as Vi,ib as Zt,jb as en,kb as W,oa as Ri,ob as Ki,pb as Yi,ub as Qi,wb as Ji,za as fe}from"./chunk-JGFSSR3G.js";import{e as it,f as Yt,g as ti,h as ni}from"./chunk-AU6VJGTY.js";import{Na as jr,Va as Ur}from"./chunk-WOEZJUA2.js";import{$a as _i,Ab as G,Ba as ui,Bb as ne,Cb as re,D as ee,Eb as ki,Fb as me,Ia as ot,Ib as Si,Ja as mi,Ka as fi,Mb as Ce,Ob as Ie,Rb as xe,Sb as Di,T as L,Tb as Fi,U as R,Ub as pt,V as J,Xa as M,Y as di,Yb as Gi,Zb as Hi,_a as yi,aa as te,ac as qi,cb as wi,eb as Qt,f as ri,fa as li,g as ii,h as oi,i as si,j as ai,n as Ee,oc as Xi,w as ci,wb as dt,yb as vi}from"./chunk-SIEGIPNT.js";import{b as Ar,n as P,p as Q}from"./chunk-PBCYGO7X.js";import{$ as f,$a as T,$c as le,$d as Xr,Ab as Pr,Ba as zt,Bd as Vr,Cd as Kr,Ea as ke,Fa as Ye,Ge as Kt,H as de,Hd as Yr,Ka as $r,La as Or,M as Wt,Mc as C,Me as Zr,N as Ve,Ne as ei,Rc as Se,V as Tr,Va as D,Vc as Br,Yd as F,Z as Rr,aa as h,ad as Gr,ae as E,bb as Lr,be as Qr,cd as Qe,ce as H,db as Vt,ed as Je,fb as Xe,fd as Ze,gd as Hr,i as xr,ie as et,jd as qr,kd as Wr,ke as tt,ld as zr,me as nt,pe as Jr,qe as rt,sa as Dr,ta as Ke,tb as Nr,ua as Fr,ya as Mr}from"./chunk-B3YW6H2I.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]="7dd9061f-1b49-5ecb-a306-74f09283fe57")}catch{}})();var Qs="PmCliError";function Jm(e){if(!Zs(e)||e.code!=="item_already_exists"||e.exitCode!==f.CONFLICT)return!1;let t=e.context;return typeof t=="object"&&t!==null&&t.code==="item_already_exists"&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.path=="string"&&t.path.trim().length>0}function Js(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=f.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function Zi(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new h(e,Js(t.exitCode??f.USAGE),t.context??{});return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function Zs(e){if(!(e instanceof Error)||e.name!==Qs)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)}(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]="b70f6764-9f83-5371-8ebc-1d0d5703bc1f")}catch{}})();var ea=["invalid_envelope","source_incomplete","source_unchecked","filtered_corpus","terminal_items_excluded","strict_read_unproven","page_incomplete","count_mismatch","projection_incomplete","field_omission","omission_receipt_missing","omission_receipt_invalid","read_output_missing","read_output_invalid","read_output_dimensions_incomplete","budget_compaction","budget_omission","session_projection","invalid_item_id","duplicate_item_id"],tn=class extends Error{receipt;constructor(t){super(`Complete-list certification failed: ${t.map(n=>n.code).join(", ")}.`),this.name="PmCompleteListValidationError",this.receipt={contract_version:1,contract:"complete_list",findings:t,recovery:{suggested_retry:"pm list --all --output-include full --strict-read --no-truncate --output-budget unbounded --output-limit unbounded --json",sdk:"await client.listAllComplete()"}}}};function tf(e={}){return Yr({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e,t,n,r){t&&e.push({code:n,message:r})}function ta(e,t){let n=z(e.completeness)?e.completeness:{};I(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),I(t,n.status!=="complete"&&n.status!=="partial","source_unchecked","The source scan did not prove completeness.");let r=n.unreadable_item_count,i=n.unreadable_directory_count;I(t,n.status==="complete"&&(r!==0||i!==0)&&Number.isSafeInteger(r)&&Number.isSafeInteger(i),"source_incomplete","The source scan reports unreadable tracker artifacts despite a complete status."),I(t,n.status==="complete"&&(!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||Number(r)<0||Number(i)<0),"source_unchecked","The source scan did not report safe non-negative unreadable counts.");let o=z(e.filters)?e.filters:{},s=z(o.runtime_filters)?o.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return I(t,o.status!=="all"||Object.keys(s).length>0||Object.keys(o).some(d=>!a.has(d)),"filtered_corpus","The list did not explicitly select every lifecycle status."),I(t,o.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),I(t,o.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),o}function na(e,t,n){I(n,e.has_more!==!1||e.next_cursor!==null||e.truncated!==!1||e.applied_limit!==void 0||t.no_truncate!==!0,"page_incomplete","Pagination or a row ceiling may have withheld items."),I(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let r=z(e.projection)?e.projection:{};I(n,r.mode!=="full"||r.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let i=z(e.omission_receipt)?e.omission_receipt:void 0;I(n,i===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),I(n,i!==void 0&&(i.has_omissions!==!1||i.omitted_field_group_count!==0||!Number.isSafeInteger(i.omitted_field_group_count)||!Array.isArray(i.omitted_field_groups)||i.omitted_field_groups.length!==0),"omission_receipt_invalid","The field-omission receipt is malformed or contradicts its no-omission claim."),I(n,i?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function ra(e){return e.contract_version!==1||e.command!=="list"||e.within_budget!==!0||e.strings_compacted!==!1||e.rows_compacted!==!1||e.result_omitted!==!1}function ia(e){if(!Array.isArray(e.requested_dimensions))return!1;let t=new Set(e.requested_dimensions);return["include","amount","cost"].every(n=>t.has(n))}function oa(e,t){let n=z(e.read_output)?e.read_output:void 0;I(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),I(t,n!==void 0&&ra(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),I(t,n!==void 0&&!ia(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),I(t,n?.strings_compacted===!0||n?.rows_compacted===!0||e.output_budget_truncation!==void 0,"budget_compaction","Universal output shaping compacted the result.");let r=z(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;I(t,n?.result_omitted===!0||r?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),I(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function sa(e,t){let n=e.map(r=>z(r)&&typeof r.id=="string"?r.id.trim():"");I(t,n.some(r=>r.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),I(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function aa(e){if(!z(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:ea[0],message:"The result must be an object with an items array."}]};let t=e,n=[],r=ta(t,n);return na(t,r,n),oa(t,n),sa(t.items,n),{ok:n.length===0,findings:n}}function ca(e){let t=aa(e);if(!t.ok)throw new tn(t.findings);let n=e;return{...n,complete_list:{contract_version:1,item_count:n.items.length,unique_item_id_count:new Set(n.items.map(r=>r.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function nf(e){ca(e)}(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]="499dfc08-cf70-55fe-8868-65c3107e3a91")}catch{}})();async function af(e,t={}){let n=await Qi({pmRoot:T(process.cwd(),e.path),exhaustive:t.exhaustive,...t.status===void 0?{}:{statuses:t.status.flatMap(r=>r.split(",").map(i=>i.trim()).filter(Boolean))},...t.since===void 0?{}:{since:t.since},...t.threshold===void 0?{}:{threshold:t.threshold},...t.limit===void 0?{}:{limit:t.limit}});return{...n,clusters:n.clusters.map(r=>{let i=r.id;return{...r,canonical_id:i,close_command:`pm close <duplicate-id> --duplicate-of ${i}`}}),guidance:{strategy:"review_then_close_duplicate",command:"pm close <duplicate-id> --duplicate-of <canonical-id>"}}}(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]="1433b417-e41f-5963-a551-094132afd717")}catch{}})();var eo=16;async function to(e,t,n){let r=D(t,C()).type_to_folder,i=[],o=new Set,s=n;for(;s&&i.length<eo;){let a=s.trim().toLowerCase();if(!a||o.has(a))break;o.add(a);let d=await ne(e,s,t.id_prefix,t.item_format,r);if(!d)break;let c=await re(d,{schema:t.schema});i.push(c.document.metadata.id),s=c.document.metadata.parent}return i}async function ff(e){await oi({pmRoot:e.pmRoot,principal:e.principal,itemId:e.itemId,lineageIds:await to(e.pmRoot,e.settings,e.itemId)})}async function pf(e){await si(e)}async function hf(e){await ai({pmRoot:e.pmRoot,principal:e.principal,...e.itemId?{itemId:e.itemId,lineageIds:await to(e.pmRoot,e.settings,e.itemId)}:{}})}var gf={lineage_depth:eo,active_items:64,evidence_rows:32};function no(e){if(!e)return;let t={};for(let n of e.active_item_ids)t[n]=1;e.focused_item_id&&(t[e.focused_item_id]=1);for(let n of e.evidence){let r=/^lineage:(.+)$/u.exec(n)?.[1];r&&t[r]===void 0&&(t[r]=.75)}return Object.keys(t).length>0?t:void 0}import{encode as da}from"@toon-format/toon";(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]="809a4d75-4915-585d-9fc8-ad3e9ef15b1f")}catch{}})();var nn=["agenda","day","week","month"],rn=["markdown","toon","json"],la=["sun","mon","tue","wed","thu","fri","sat"],ua=365,ma=365,oo=28,fa=1e3;function on(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new h(`${t} must be a non-negative integer`,f.USAGE);return n}function pa(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw new h("Calendar include filter must not be empty",f.USAGE);let r=new Set;for(let i of n){if(i==="deadlines"||i==="deadline"){r.add("deadlines");continue}if(i==="reminders"||i==="reminder"){r.add("reminders");continue}if(i==="events"||i==="event"||i==="scheduled"){r.add("events");continue}throw new h("Calendar include filter must be deadlines|reminders|events|scheduled|all",f.USAGE)}return r}function so(e,t){let n;for(let r of t){let i=xr(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function ha(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!nn.includes(t)){let n=so(t,nn);throw new h(`Calendar view must be one of ${nn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function ga(e){if(!e)return;let t=e.trim().toLowerCase();if(!rn.includes(t)){let n=so(t,rn);throw new h(`Calendar format must be one of ${rn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function Sf(e,t){let n=ga(e.format);if(t.json&&n&&n!=="json")throw new h("Cannot combine --json with --format markdown|toon",f.USAGE);return t.json?"json":n??"markdown"}function ya(e,t){if(e===void 0)return;let n=L(e,t);if(!n){let r=t.definitions.map(i=>i.id);throw new h(`Calendar status filter must be one of ${r.join("|")}`,f.USAGE)}return n}function _a(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new h("Calendar assignee filter must be one of assigned|unassigned",f.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new h(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,f.USAGE);return t}function ht(e){return new Date(e).toISOString().slice(0,10)}function ao(e,t){if(!t||t==="UTC")return ht(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,i=n.find(s=>s.type==="month")?.value,o=n.find(s=>s.type==="day")?.value;if(r&&i&&o)return`${r}-${i}-${o}`}catch{}return ht(e)}function dn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function V(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function co(e){let t=new Date(dn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return V(t.toISOString(),r)}function wa(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function ba(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function va(e,t){return E(e,t)>=0?e:t}function ro(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function io(e,t){e.set(t,(e.get(t)??0)+1)}function ka(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,i)=>de(r)-de(i));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,i)=>r-i);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,i)=>r.localeCompare(i));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function lo(e,t,n,r){let i=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==t||i.getUTCDate()!==n))return i.toISOString()}function uo(e){return la[new Date(e).getUTCDay()]}function Sa(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function Ea(e){let t=new Set;for(let n of e??[]){let r=Sa(n);r&&t.add(r)}return t}function Ca(e,t,n,r,i){let o=e??V(n,-(r??ma)),s=t??V(e??n,i??ua);return{start:o,end:E(s,o)>0?s:V(o,1)}}function Ia(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[uo(e)],o=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??fa,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:Ea(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(i)].sort((s,a)=>de(s)-de(a)),sortedMonthDays:[...new Set(o)].sort((s,a)=>s-a),occurrences:[],produced:0}}function gt(e,t){return E(t,e.startAt)<0?"continue":e.until&&E(t,e.until)>0||E(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,E(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function yt(e,t){let n=uo(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function xa(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(yt(e,t)&>(e,t)==="stop");n+=1)t=V(t,e.interval);return e.occurrences}function Ta(e,t,n){let r=de(n),i=V(t,r),o=new Date(i);return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function Ra(e){let t=co(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=V(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=Ta(e,r,i);if(yt(e,o)&>(e,o)==="stop")return e.occurrences}}return e.occurrences}function Aa(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let o of e.sortedMonthDays){let s=lo(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!yt(e,s))&>(e,s)==="stop")return e.occurrences}}return e.occurrences}function Da(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=t+r*e.interval;for(let o of e.sortedMonthDays){let s=lo(i,n,o,e.startDate);if(!(!s||!yt(e,s))&>(e,s)==="stop")return e.occurrences}}return e.occurrences}function Fa(e,t,n,r){let i=Ia(e,t,n,r);return t.freq==="daily"?xa(i):t.freq==="weekly"?Ra(i):t.freq==="monthly"?Aa(i):Da(i)}function mo(e){return[...e].sort((t,n)=>{let r=E(t.at,n.at);if(r!==0)return r;let i=t.item_priority-n.item_priority;if(i!==0)return i;let o=t.item_id.localeCompare(n.item_id);if(o!==0)return o;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function ln(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Ma(e){return e.deadline?{at:e.deadline,date:ht(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...ln(e),item_deadline:e.deadline}:null}function $a(e){return(e.reminders??[]).map(t=>({at:t.at,date:ht(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...ln(e)}))}function Oa(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function La(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Na(e,t,n,r){let i=ka(t.recurrence),o=Oa(t.start_at,t.end_at);return(t.recurrence?Fa(t.start_at,t.recurrence,n,r):[t.start_at]).map(s=>({at:s,date:t.all_day===!0?s.slice(0,10):ao(s,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:La(s,t,o),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:i,...ln(e)}))}function Pa(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Ma(o):null;s&&i.push(s),n.has("reminders")&&i.push(...$a(o));for(let a of n.has("events")?o.events??[]:[])i.push(...Na(o,a,t,r))}return mo(i)}function ja(e,t,n,r,i){let o=$i(t.type,n),s=t.tag?.trim().toLowerCase(),a=Mi(t.priority),d=ya(t.status,r),c=t.assignee?.trim(),l=_a(t.assigneeFilter),u=t.sprint?.trim(),m=t.release?.trim();if(c&&(c.toLowerCase()==="none"||c.toLowerCase()==="null"))throw new h('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',f.USAGE);if(c!==void 0&&l==="unassigned")throw new h("Cannot combine --assignee with --assignee-filter unassigned",f.USAGE);return e.filter(p=>Ua(p,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:d,assigneeFilter:c,assigneeModeFilter:l,sprintFilter:u,releaseFilter:m,runtimeFieldFilters:i}))}function Ua(e,t){return Ba(e,t)&&Ga(e,t)&&ct(e,t.runtimeFieldFilters)}function Ba(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function Ga(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function Ha(e,t,n){return!(t&&E(e.at,t)<0||n&&E(e.at,n)>=0)}function sn(e,t,n){return e.trim().toLowerCase()==="today"?dn(t):H(e,new Date(t),n)}function qa(e,t,n){let r=t.date?sn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?sn(t.from,n,"--from"):void 0,a=t.to?sn(t.to,n,"--to"):void 0;if(s&&a&&E(s,a)>=0)throw new h("Calendar --from must be before --to",f.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new h("--from and --to are only supported for --view agenda",f.USAGE);if(e==="agenda")return Wa(r,t,n,i,o,s,a);if(e==="day"){let c=dn(r);return an(r,n,i,o,c,V(c,1))}if(e==="week"){let c=co(r);return an(r,n,i,o,c,V(c,7))}let d=wa(r);return an(r,n,i,o,d,ba(r))}function Wa(e,t,n,r,i,o,s){if(i)throw new h("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",f.USAGE);return{anchor:e,start:o??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function an(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:va(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function za(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:mo(r)}))}function Va(e){let t=new Set,n=new Map,r=new Map,i=0,o=0,s=0,a=0;for(let d of e)t.add(d.item_id),io(n,d.item_type),io(r,d.item_status),d.kind==="deadline"?i+=1:d.kind==="reminder"?o+=1:(s+=1,d.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:i,reminders:o,scheduled:s,by_kind:{deadline:i,reminder:o,event:s},by_type:ro(n),by_status:ro(r),recurring_events:a}}function Ka(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function fo(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(o=>o.type==="hour")?.value,i=n.find(o=>o.type==="minute")?.value;if(r&&i)return`${r}:${i}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function cn(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function Ya(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===ao(e.event_end,e.event_timezone)?fo(e.event_end,e.event_timezone):e.event_end:null}function Xa(e){let t=`${fo(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let i=Ya(e);return i&&n.push(`end=${i}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function Ef(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${Ka(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- by-kind: ${cn(e.summary.by_kind)}`),t.push(`- by-type: ${cn(e.summary.by_type)}`),t.push(`- by-status: ${cn(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),t.join(`
|
|
2
2
|
`);for(let n of e.days){t.push(`## ${n.date} (${n.count})`);for(let r of n.events)t.push(`- ${Xa(r)}`);t.push("")}if(e.warnings&&e.warnings.length>0){t.push("### warnings");for(let n of e.warnings)t.push(`- ${n}`);t.push("")}return Qa(t.join(`
|
|
3
3
|
`))}function Cf(e){return da(e)}function Qa(e){let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
4
|
`;)t-=1;return e.slice(0,t)}function Ja(e){let t=F(),n=ha(e.view),r=qa(n,e,t),i=q(e.limit),o=pa(e.include),s=on(e.recurrenceLookaheadDays,"Calendar recurrence lookahead days"),a=on(e.recurrenceLookbackDays,"Calendar recurrence lookback days"),d=on(e.occurrenceLimit,"Calendar occurrence limit");if(d!==void 0&&d<1)throw new h("Calendar occurrence limit must be >= 1",f.USAGE);let c=o.has("events")&&!o.has("deadlines")&&!o.has("reminders"),l=e.to!==void 0||s!==void 0||a!==void 0||d!==void 0,u=c&&!l;return{nowValue:t,view:n,rangeBounds:r,limit:i,includeSources:o,occurrenceLimit:d,recurrenceLookaheadDays:u?oo:s,recurrenceLookbackWindowDays:u&&a===void 0?0:a,eventsOnlyCapApplied:u}}function Za(e,t){t&&e.push(`recurring_events_default_cap_applied:lookback=0d,lookahead=${oo}d -- use --recurrence-lookback-days/--recurrence-lookahead-days or --to for wider range`)}function ec(e,t){return{type:e.type??null,tag:e.tag??null,priority:e.priority??null,status:e.status??null,assignee:e.assignee??null,assignee_filter:e.assigneeFilter??null,sprint:e.sprint??null,release:e.release??null,runtime_filters:t,limit:e.limit??null,include:e.include??null,full_period:e.fullPeriod===!0?"true":null,recurrence_lookahead_days:e.recurrenceLookaheadDays??null,recurrence_lookback_days:e.recurrenceLookbackDays??null,occurrence_limit:e.occurrenceLimit??null}}function tc(e,t){return{start:t.start??null,end:t.end??null,period_start:t.periodStart??null,period_end:t.periodEnd??null,full_period:t.fullPeriod,past:e.past===!0,from:e.from??null,to:e.to??null}}async function po(e,t){let n=T(process.cwd(),t.path);await G(n);let r=Ja(e),i=await M(n),o=P(i.schema),s=Q(i.schema),a=at(e,s,"calendar"),d=D(i,C()),c=[];Za(c,r.eventsOnlyCapApplied);let l=await me(n,i.item_format,d.type_to_folder,c,i.schema),u=ja(l,e,d,o,a),m=Ca(r.rangeBounds.start,r.rangeBounds.end,r.nowValue,r.recurrenceLookbackWindowDays,r.recurrenceLookaheadDays),p=Pa(u,m,r.includeSources,r.occurrenceLimit).filter(w=>Ha(w,r.rangeBounds.start,r.rangeBounds.end)),g=r.limit===void 0?p:p.slice(0,r.limit),_=za(g),y=[...new Set(c)].sort((w,S)=>w.localeCompare(S));return{view:r.view,output_default:"markdown",now:r.nowValue,anchor:r.rangeBounds.anchor,range:tc(e,r.rangeBounds),filters:ec(e,a),summary:Va(g),events:g,days:_,...y.length>0?{warnings:y}:{}}}import rc from"node:fs/promises";import _o 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]="2e0c4f91-ea56-5bec-b071-448eff719fec")}catch{}})();var un={version:1,aliases:{}};function _t(e=[]){let t=new Set(Ee),n=r=>{/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(r)&&t.add(r)};for(let r of e){for(let i of Object.keys(r.provenance_environment_keys??{}))n(i);for(let i of Object.keys(r.provenance_resolvers??{}))n(i);for(let i of r.provenance_unavailable_dimensions??[])n(i)}return[...t].sort()}function ho(e){if(e===void 0)return;let t=(typeof e=="string"?[e]:e).flatMap(n=>n.split(",")).map(n=>n.trim()).filter(n=>n.length>0);return t.length===0?void 0:new Set(t)}function mn(e,t){if(e.agent_harness?.trim())return{agent_harness:e.agent_harness,harness_source:"recorded"};let n=t.aliases[e.author];return n?{agent_harness:n,harness_source:"vocabulary"}:{harness_source:"unresolved"}}function nc(e,t=Ee){let n=new Set(t),r=new Map,i=e.provenance===void 0?[]:typeof e.provenance=="string"?[e.provenance]:e.provenance;for(let o of i.flatMap(s=>s.split(","))){let s=o.indexOf("=");if(s<0)throw new h(`Provenance predicate must use dimension=value; received "${o.trim()}".`,f.USAGE,{code:"invalid_provenance_predicate"});let a=o.slice(0,s).trim().toLowerCase(),d=o.slice(s+1).trim();if(!n.has(a))throw new h(`Unknown provenance dimension "${a||o.trim()}". Declared dimensions: ${[...n].sort().join(", ")}.`,f.USAGE,{code:"unknown_provenance_dimension"});if(d.length===0)throw new h(`Provenance predicate must use dimension=value; received "${o.trim()}".`,f.USAGE,{code:"invalid_provenance_predicate"});let c=r.get(a)??new Set;c.add(d),r.set(a,c)}return r}function wt(e,t=un,n={}){let r=mn(e,t);return{...n.itemId===void 0?{}:{item_id:n.itemId},...n.version===void 0?{}:{version:n.version},ts:e.ts,op:e.op,author:e.author,...e.author_source===void 0?{}:{author_source:e.author_source},...r,vocabulary_version:t.version,...e.agent_instance===void 0?{}:{agent_instance:e.agent_instance},agent_provenance:e.agent_provenance??{},...e.message===void 0?{}:{message:e.message}}}function bt(e,t=un,n=Ee){let r=ho(e.harness),i=ho(e.agentInstance),o=nc(e,n);return s=>{let a=mn(s,t).agent_harness;if(r&&(!a||!r.has(a))||i&&!i.has(s.agent_instance??""))return!1;for(let[d,c]of o){let l=s.agent_provenance?.[d];if(!l||!c.has(l.value))return!1}return!0}}function vt(e,t=un,n=Ee){let r=new Set(n),i=new Map,o=0;for(let s of e){for(let a of Object.keys(s.agent_provenance??{}))r.add(a);mn(s,t).agent_harness?o+=1:i.set(s.author,(i.get(s.author)??0)+1)}return{entries:e.length,vocabulary_version:t.version,harness:{resolved:o,unresolved:e.length-o,unresolved_authors:[...i].map(([s,a])=>({author:s,entries:a})).sort((s,a)=>a.entries-s.entries||s.author.localeCompare(a.author)).slice(0,20)},dimensions:[...r].sort().map(s=>{let a=0,d=0;for(let c of e){let l=c.agent_provenance?.[s];l===null?d+=1:l!==void 0&&(a+=1)}return{dimension:s,observed:a,unavailable:d,legacy_missing:e.length-a-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]="a4394793-55d4-5049-ab20-707c1c3d9f2c")}catch{}})();var ic=20,oc=5,sc=15,ac="-24h";function Uf(e){let t={...e};return t.full===!0?(t.raw=!0,t.compact=!1):t.raw===!0&&t.compact===void 0&&(t.compact=!0),delete t.full,t}var cc={digest:"activity_digest",compact:"compact_activity",provenance:"provenance_activity",full:"activity"};function fn(e,t){if(e===void 0)return;let n=e.trim();if(n.length===0)throw new h(`${t} must not be empty`,f.USAGE);return n}function go(e,t,n){if(e===void 0)return;let r=e.trim();if(r.length===0)throw new h("Activity time bounds must not be empty",f.USAGE);let i=n==="--from"&&/^\d+[hdwm]$/iu.test(r)?`-${r}`:r;return H(i,new Date(t),n)}function dc(e,t,n){return!(e.ts.length===0&&(t||n)||t&&E(e.ts,t)<0||n&&E(e.ts,n)>=0)}function yo(e,t){return t===void 0?e:e.slice(0,t)}function Re(e,t=""){return typeof e=="string"?e:t}function lc(e,t){return{...t,id:e,ts:Re(t.ts),author:Re(t.author,"unknown"),op:Re(t.op,"unknown"),patch:Array.isArray(t.patch)?t.patch:[],before_hash:Re(t.before_hash),after_hash:Re(t.after_hash)}}function uc(e){return[...e].sort((t,n)=>{let r=n.ts.localeCompare(t.ts);if(r!==0)return r;let i=t.id.localeCompare(n.id);return i!==0?i:t.op.localeCompare(n.op)})}async function mc(e){try{return(await rc.readdir(e)).filter(t=>t.endsWith(".jsonl")).sort((t,n)=>t.localeCompare(n))}catch(t){if(Fr(t))return[];throw t}}function fc(e){return e.raw!==!0&&e.compact!==!0&&e.provenance!==!0?"digest":e.provenance===!0?"provenance":e.compact===!0||e.raw===!0&&e.compact!==!1?"compact":"full"}function pc(e,t,n){if(e.unbounded!==!0)return t!==void 0?t:n==="digest"?sc:n==="compact"?ic:oc}function hc(e,t){let n=F(),r=t==="digest",i=go(e.to??(r?n:void 0),n,"--to"),o=go(e.from??(r?ac:void 0),e.from===void 0&&r?i:n,"--from");if(o&&i&&E(o,i)>=0)throw new h("Activity --from must be before --to",f.USAGE);let s=ue(e.limit);if(e.unbounded===!0&&s!==void 0)throw new h("Activity --unbounded cannot be combined with --limit",f.USAGE);return{id:fn(e.id,"Activity --id"),op:fn(e.op,"Activity --op"),author:fn(e.author,"Activity --author"),from:o,to:i,limit:pc(e,s,t),limitSource:e.unbounded===!0||s!==void 0?"explicit":"default",harness:e.harness,agentInstance:e.agentInstance,provenance:e.provenanceFilter}}async function gc(e){let t=T(process.cwd(),e.path);return await G(t),{pmRoot:t,settings:await M(t)}}async function yc(e){let t=D(e.settings,C()),n=await me(e.pmRoot,e.settings.item_format,t.type_to_folder,void 0,e.settings.schema);await _i({pmRoot:e.pmRoot,settings:e.settings,itemIds:n.map(i=>i.id),commandLabel:"activity"});let r=_o.join(e.pmRoot,"history");return await Se({path:r,scope:"project"}),{historyDir:r,itemsById:new Map(n.map(i=>[i.id,{title:i.title,type:i.type,status:i.status}]))}}function _c(e,t,n){return n.op&&e.op!==n.op||n.author&&e.author!==n.author?!1:dc(t,n.from,n.to)}async function wc(e,t){let n=[];for(let r of await mc(e)){let i=r.slice(0,-6);if(t.id&&i!==t.id)continue;let o=await te(_o.join(e,r),i);for(let s of o){let a=lc(i,s);_c(s,a,t)&&n.push(a)}}return n}function bc(e){return e.map(t=>({id:t.id,op:t.op,ts:t.ts,author:t.author,...t.message?{msg:t.message}:{}}))}function vc(e){let t=[...e.entries()].sort(([r,i],[o,s])=>s-i||r.localeCompare(o)),n=t.slice(0,4).map(([r,i])=>`${r}:${i}`);return t.length>n.length&&n.push(`+${t.length-n.length}`),n.join(",")}function kc(e,t){let n=new Map;for(let r of e){let i=n.get(r.id);if(i===void 0){n.set(r.id,{firstTs:r.ts,lastTs:r.ts,eventCount:1,operations:new Map([[r.op,1]])});continue}i.eventCount+=1,E(r.ts,i.firstTs)<0&&(i.firstTs=r.ts),E(r.ts,i.lastTs)>0&&(i.lastTs=r.ts),i.operations.set(r.op,(i.operations.get(r.op)??0)+1)}return[...n.entries()].map(([r,i])=>{let o=t.get(r);return{id:r,type:o?.type??"unknown",status:o?.status??"unknown",title:(o?.title??"(item metadata unavailable)").slice(0,160),event_count:i.eventCount,first_ts:i.firstTs,last_ts:i.lastTs,operations:vc(i.operations)}}).sort((r,i)=>E(i.last_ts,r.last_ts)||r.id.localeCompare(i.id))}function Sc(e){let t=new Map;for(let i of e)t.set(i.op,(t.get(i.op)??0)+1);let n=[...t.entries()].sort((i,o)=>o[1]-i[1]||i[0].localeCompare(o[0])),r=n.slice(0,8);return r.length<n.length&&r.push([`+${String(n.length-r.length)}`,n.slice(r.length).reduce((i,[,o])=>i+o,0)]),Object.fromEntries(r)}function Ec(e,t,n,r,i){if(e==="digest"){let s=kc(t,r),a=yo(s,n);return{rows:{activity_digest:a},compact:!1,totalRows:s.length,returnedRows:a.length}}let o=yo(t,n);return e==="compact"?{rows:{compact_activity:bc(o)},compact:!0,totalRows:t.length,returnedRows:o.length}:e==="provenance"?{rows:{provenance_activity:o.map(i)},compact:!1,totalRows:t.length,returnedRows:o.length}:{rows:{activity:o},compact:!1,totalRows:t.length,returnedRows:o.length}}async function wo(e,t){let n=await gc(t),r=fc(e),i=hc(e,r),o=await yc(n),s=_t(n.settings.agent_identity.harness_signals),a=n.settings.agent_identity.identity_vocabulary,d=bt({harness:i.harness,agentInstance:i.agentInstance,provenance:i.provenance},a,s),c=uc(await wc(o.historyDir,i)).filter(d),l=Ec(r,c,i.limit,o.itemsById,m=>wt(m,a,{itemId:m.id})),u=l.totalRows-l.returnedRows;return{...l.rows,compact:l.compact,projection:{mode:r,row_key:cc[r]},omission_receipt:Qe("activity",r),count:l.returnedRows,total_count:l.totalRows,limit:i.limit??null,omitted_count:u,has_more:u>0,...r==="digest"?{activity_summary:{window:{from:i.from,to:i.to},event_count:c.length,item_count:l.totalRows,author_count:new Set(c.map(m=>m.author)).size,operation_counts:Sc(c)}}:{},...e.provenanceSummary===!0?{provenance_summary:vt(c,a,s)}:{},applied_bound:{kind:i.limit===void 0?"unbounded":"limit",source:i.limitSource,value:i.limit??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]="9cdfc765-7370-57bb-a4dc-be2df8aa1e6f")}catch{}})();var bo="1970-01-01T00:00:00.000Z";function Ae(e){if(typeof e!="string")return null;let t=e.trim();if(!Xr(t)&&!/^\d{4}-\d{2}-\d{2}$/u.test(t))return null;try{return H(t,new Date(Number.NaN),"context signal recency coordinate")}catch{return 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]="e750a203-8bef-5bfd-85a5-a584c2105472")}catch{}})();var pn=["structural","recency","activity_density","graph_proximity","claim_focus","priority_pressure","risk_pressure","deadline_pressure","knowledge_density","author_affinity","usage_affinity","semantic_similarity"],Cc=Symbol("no-context-author"),Ic=Symbol("no-item-assignee");function vo(e,t){if(typeof e!="string")return t;let n=e.trim().toLowerCase();return n.length>0?n:t}function xc(e){if(typeof e!="string")return;let t=/^v?(\d{4})\.(\d{1,2})\.(\d{1,2})(?:$|[-+])/u.exec(e.trim());if(!t)return;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),o=new Date(Date.UTC(n,r-1,i));return o.getUTCFullYear()===n&&o.getUTCMonth()===r-1&&o.getUTCDate()===i?o.toISOString():void 0}function Tc(e){let t=xc(e.release);return t!==void 0?{source:"release_cohort",coordinate:t}:{source:"created_at",coordinate:Ae(e.created_at)??bo}}function Rc(e){if(!["substantive_history","release_cohort","created_at"].includes(e.source)||(e.source==="substantive_history"?e.history_op!==void 0&&typeof e.history_op!="string"||e.event_class!==void 0&&e.event_class!=="substantive":e.history_op!==void 0||e.event_class!==void 0))throw new TypeError("Context signal recency provenance must match its source");let t=Ae(e.coordinate);if(t===null)throw new TypeError("Context signal recency coordinate must be a valid absolute timestamp with millisecond precision");return{...e,coordinate:t}}function Ac(e,t){let n=typeof e=="number"?e:typeof e=="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)?1-Math.min(Math.max(n,0),t)/t:0}function Dc(e,t){let n=typeof e=="string"?Date.parse(e):e instanceof Date?e.getTime():typeof e=="number"?e:Number.NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return 0;let r=(n-t)/864e5;return r<=0?1:1/(1+r/30)}function Fc(e){let t=typeof e=="string"?e.trim().toLowerCase():void 0;return t==="critical"||t==="high"?1:t==="medium"?.5:t==="low"?.1:0}function kt(e,t,n){return e?.[t]??n}function St(e,t){let n=new Map(e.map(c=>{let l=t.recencyEvidence?.[c.id];return[c.id,l===void 0?Tc(c):Rc(l)]})),r=[...e].sort((c,l)=>{let u=n.get(c.id).coordinate,m=n.get(l.id).coordinate;return E(m,u)||c.id.localeCompare(l.id)}),i=new Map(r.map((c,l)=>[c.id,l])),o=Math.max(e.length-1,1),s=vo(t.author,Cc),a=L("in_progress",t.statusRegistry),d=Date.parse(t.now);return e.map(c=>{let l=vo(c.assignee,Ic)===s,u=(c.comments?.length??0)+(c.notes?.length??0)+(c.learnings?.length??0);return{id:c.id,item:c,signal_provenance:{recency:n.get(c.id)},signals:{recency:e.length===1?1:1-i.get(c.id)/o,activity_density:t.activityDensity?.[c.id],graph_proximity:kt(t.graphProximity,c.id,c.parent?.3:0),claim_focus:kt(t.claimFocus,c.id,R(c.status,t.statusRegistry)===a?1:l?.75:0),priority_pressure:Ac(c.priority,4),risk_pressure:Fc(c.risk),deadline_pressure:Dc(c.deadline,d),knowledge_density:kt(t.knowledgeDensity,c.id,Math.min(u/5,1)),author_affinity:kt(t.authorAffinity,c.id,l?1:0),usage_affinity:t.usageAffinity?.[c.id],semantic_similarity:t.semanticSimilarity?.[c.id]}}})}var Mc="context_relevance",$c={structural:.4,recency:.35,activity_density:.25,graph_proximity:.15,claim_focus:.6,priority_pressure:.35,risk_pressure:.2,deadline_pressure:.45,knowledge_density:.25,author_affinity:.2,usage_affinity:.3,semantic_similarity:.5},Oc=new TextEncoder;function Lc(e){let t=new Set;for(let n of e){if(typeof n.id!="string"||n.id.trim().length===0||t.has(n.id))throw new TypeError("Context relevance candidates require unique non-empty ids");t.add(n.id);for(let[r,i]of Object.entries(n.signals??{})){if(r==="structural"||!pn.includes(r))throw new TypeError(`Unknown context relevance signal: ${r}`);if(i!==void 0&&(!Number.isFinite(i)||i<0||i>1))throw new TypeError(`Context relevance signal ${r} must be a finite number from 0 to 1`)}}}function Nc(e){let t={...$c};for(let[n,r]of Object.entries(e??{}))r!==void 0&&pn.includes(n)&&(t[n]=r);for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<0)throw new TypeError(`Context relevance weight ${n} must be a finite non-negative number`);return t}function So(e,t={}){Lc(e);let n=Nc(t.weights),r=Math.max(e.length-1,1),i=new Set(["structural"]);for(let a of e)for(let[d,c]of Object.entries(a.signals??{}))c!==void 0&&i.add(d);let o=pn.filter(a=>i.has(a)),s=e.map((a,d)=>{let c={structural:e.length===1?1:1-d/r,...a.signals},l={},u=0,m=0;for(let p of o){let g=c[p];if(g===void 0)continue;let _=g*n[p];l[p]=_,u+=_,m+=n[p]}return{...a,baseline_rank:d+1,rank:0,score:m===0?0:u/m,contributions:l}});return s.sort((a,d)=>d.score-a.score||a.baseline_rank-d.baseline_rank),s.forEach((a,d)=>{a.rank=d+1}),{model:"default-weighted-v1",available_signals:o,ranked:s}}async function Pc(e,t={}){let n=So(e,t);if(!t.scorer)return n;let r=await t.scorer({candidates:e,default_report:n}),i=new Map;for(let s of r){if(i.has(s.id)||!Number.isFinite(s.score))throw new TypeError("Context relevance scorer must return one finite score for every candidate");i.set(s.id,s.score)}if(i.size!==e.length||e.some(s=>!i.has(s.id)))throw new TypeError("Context relevance scorer must return one finite score for every candidate");let o=n.ranked.map(s=>{let a=i.get(s.id);return{...s,score:a,contributions:{custom:a}}});return o.sort((s,a)=>a.score-s.score||s.baseline_rank-a.baseline_rank),o.forEach((s,a)=>{s.rank=a+1}),{model:"custom",available_signals:n.available_signals,ranked:o}}async function Et(e,t,n={}){let r=So(t,n),i=await Br(Mc,{surface:e,candidates:t,default_report:r});if(!i.handled)return i.warnings.length>0?{...r,warnings:i.warnings}:r;if(!Array.isArray(i.result)||!i.result.every(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.score=="number"&&Number.isFinite(o.score)))return{...r,warnings:[...i.warnings,"extension_context_relevance_invalid_result"]};try{let o=await Pc(t,{...n,scorer:()=>i.result});return i.warnings.length>0?{...o,warnings:i.warnings}:o}catch{return{...r,warnings:[...i.warnings,"extension_context_relevance_invalid_result"]}}}var jc=["ndcg","reciprocal_rank","required_recall","continuity_coverage","token_budget_adherence"];function ko(e,t){return e.length===0?1:e.filter(n=>t.has(n)).length/e.length}function Uc(e){if(!Number.isFinite(e.actual_tokens)||e.actual_tokens<0||!Number.isFinite(e.token_budget)||e.token_budget<=0)throw new TypeError("Context ranking token counts require actual_tokens >= 0 and token_budget > 0");let t=e.judgments??{},n=e.ranked_ids.map(c=>Math.max(0,t[c]??0)),r=Object.values(t).map(c=>Math.max(0,c)).sort((c,l)=>l-c).slice(0,n.length||1),i=c=>c.reduce((l,u,m)=>l+(2**u-1)/Math.log2(m+2),0),o=i(r),s=n.findIndex(c=>c>0),a=new Set(e.ranked_ids),d=e.actual_tokens<=e.token_budget;return{ndcg:o===0?1:i(n)/o,reciprocal_rank:s<0?0:1/(s+1),required_recall:ko(e.required_ids??[],a),continuity_coverage:ko(e.continuity_ids??[],a),token_budget_adherence:d?1:e.token_budget/e.actual_tokens,within_token_budget:d}}function Bc(e){return Math.ceil(Oc.encode(JSON.stringify(e)).byteLength/4)}function Gc(e){return Math.round(e*1e4)/1e4}function Hc(e,t){let n=t==="context"?[...e.high_level??[],...e.low_level??[],...e.blocked_fallback??[]].map(o=>o.id):[...e.recommended?[e.recommended]:[],...e.ready??[]].map(o=>o.id),r=new Set(n),i=(e.ranking?.items??[]).filter(o=>r.has(o.id)).map(o=>({id:o.id,contributions:o.contributions}));return{rankedIds:n,attribution:i}}async function qc(e,t){if(e.id.trim().length===0||e.rationale.trim().length===0)throw new TypeError("Context evaluation scenarios require non-empty id and rationale values");let n=e.surface==="context"?await t.context({...e.options,explainRanking:!0,outputBudget:e.options?.outputBudget??"unbounded"}):await t.next({...e.options,explainRanking:!0,outputBudget:e.options?.outputBudget??"unbounded"}),{rankedIds:r,attribution:i}=Hc(n,e.surface),o={...n,ranking:void 0},s=Bc(o);return{id:e.id,surface:e.surface,rationale:e.rationale,ranked_ids:r,actual_tokens:s,metrics:Uc({ranked_ids:r,judgments:e.judgments,required_ids:e.required_ids,continuity_ids:e.continuity_ids,actual_tokens:s,token_budget:e.token_budget}),attribution:i}}function Wc(e,t){if(e.length===0)throw new TypeError("Context evaluation requires at least one scenario report");let n=jc;for(let o of n)if(!Number.isFinite(t[o]))throw new TypeError(`Context evaluation threshold ${o} must be a finite number`);let r=Object.fromEntries(n.map(o=>[o,Gc(e.reduce((s,a)=>s+a.metrics[o],0)/e.length)])),i=n.filter(o=>r[o]<t[o]).map(o=>`${o}:${r[o]}<${t[o]}`);return{scenario_count:e.length,aggregate:r,scenarios:[...e],passed:i.length===0,failures:i}}async function Kf(e,t,n){let r=[];for(let i of e)r.push(await qc(i,t));return Wc(r,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]="d07ec2dc-762a-58ab-83ee-734ca1bf76a7")}catch{}})();var zc={balanced:{redundancyPenalty:.35,uncertaintyPenalty:.2},context:{redundancyPenalty:.45,uncertaintyPenalty:.15},next:{redundancyPenalty:.25,uncertaintyPenalty:.3}},Vc=["identity","summary","full"];function Kc(e){if(!e.id.trim()||!Number.isInteger(e.rank)||e.rank<1)throw new TypeError("Context packing candidates require a non-empty id and positive integer rank");if(!Number.isFinite(e.score)||e.score<0)throw new TypeError("Context packing candidate scores must be finite and non-negative");let t=Vc.map(n=>e.token_costs[n]);if(t.some(n=>!Number.isInteger(n)||n<1)||t[0]>t[1]||t[1]>t[2])throw new TypeError("Context projection costs must be positive monotone integers");if(e.uncertainty!==void 0&&(!Number.isFinite(e.uncertainty)||e.uncertainty<0))throw new TypeError("Context packing uncertainty must be finite and non-negative")}function Yc(e){if(!Number.isInteger(e.tokenBudget)||e.tokenBudget<1)throw new TypeError("Context packing tokenBudget must be a positive integer");let t=e.profile??"balanced",n=zc[t];if(!n)throw new TypeError("Unknown context packing profile");let r=e.redundancyPenalty??n.redundancyPenalty,i=e.uncertaintyPenalty??n.uncertaintyPenalty;if(!Number.isFinite(r)||r<0||r>1||!Number.isFinite(i)||i<0)throw new TypeError("Context packing penalties must be finite and within their supported ranges");if(e.latencyBudgetMs!==void 0&&(!Number.isFinite(e.latencyBudgetMs)||e.latencyBudgetMs<=0))throw new TypeError("Context packing latencyBudgetMs must be positive");return{redundancy:r,uncertainty:i,profile:t}}function Xc(e){let t=new Set;for(let n of e){if(Kc(n),t.has(n.id))throw new TypeError("Context packing candidates require unique ids");t.add(n.id)}return[...e].sort((n,r)=>n.rank-r.rank||n.id.localeCompare(r.id))}function Qc(e,t,n,r,i){let o=-1,s=0;for(let a=0;a<e.length;a+=1){if(a%128===0&&i()>=r)return{index:o,evaluated:s,timedOut:!0};let d=e[a];if(d.token_costs.identity>t)continue;s+=1;let c=o<0?void 0:e[o],l=n(d)/d.token_costs.identity,u=c===void 0?Number.NEGATIVE_INFINITY:n(c)/c.token_costs.identity;(l>u||l===u&&c!==void 0&&(d.rank<c.rank||d.rank===c.rank&&d.id.localeCompare(c.id)<0))&&(o=a)}return{index:o,evaluated:s,timedOut:!1}}function Jc(e){let t=new Set,n=[],r=e.tokenBudget,i=c=>{let l=c.lineage??c.cluster,u=l&&t.has(l)?1-e.redundancyPenalty:1;return Math.max(0,(c.score-e.uncertaintyPenalty*(c.uncertainty??0))*u)},o=c=>{let l=c.token_costs.identity;n.push({...c,projection:"identity",tokens:l,marginal_value:i(c)}),r-=l;let u=c.lineage??c.cluster;u&&t.add(u)};for(let c of e.ordered.filter(l=>l.required))c.token_costs.identity<=r&&o(c);let s=e.ordered.filter(c=>!c.required),a=!0,d=0;for(;s.length>0;){let c=Qc(s,r,i,e.deadline,e.readClock);if(d+=c.evaluated,c.timedOut&&(a=!1),c.index<0||c.timedOut)break;o(s.splice(c.index,1)[0])}return{included:n,remaining:r,selectionComplete:a,evaluatedCandidates:d}}function Zc(e,t){let n=t;for(let r of["summary","full"]){let i=r==="summary"?"identity":"summary",o=[...e].sort((s,a)=>{let d=s.token_costs[r]-s.token_costs[i],c=a.token_costs[r]-a.token_costs[i];return a.marginal_value/Math.max(c,1)-s.marginal_value/Math.max(d,1)||s.rank-a.rank||s.id.localeCompare(a.id)});for(let s of o){if(s.projection!==i)continue;let a=s.token_costs[r]-s.tokens;a>n||(s.projection=r,s.tokens+=a,n-=a)}}return n}function Eo(e,t){let n=Yc(t),r=Xc(e),i=t.readClock??performance.now.bind(performance),o=t.latencyBudgetMs===void 0?Number.POSITIVE_INFINITY:i()+t.latencyBudgetMs,s=Jc({ordered:r,tokenBudget:t.tokenBudget,redundancyPenalty:n.redundancy,uncertaintyPenalty:n.uncertainty,deadline:o,readClock:i}),{included:a}=s,d=Zc(a,s.remaining);a.sort((l,u)=>l.rank-u.rank||l.id.localeCompare(u.id));let c=new Set(a.map(l=>l.id));return{included:a,omitted_ids:r.filter(l=>!c.has(l.id)).map(l=>l.id),token_budget:t.tokenBudget,used_tokens:t.tokenBudget-d,remaining_tokens:d,complete:s.selectionComplete&&a.length===e.length&&a.every(l=>l.projection==="full"),selection_complete:s.selectionComplete,termination_reason:s.selectionComplete?"exhausted":"latency_budget",evaluated_candidates:s.evaluatedCandidates,latency_budget_ms:t.latencyBudgetMs??null,profile:n.profile,degradation_ladder:["full","summary","identity"]}}import De from"node:fs/promises";import Fe from"node:path";import{createHash as Co,randomUUID as ed}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]="01eff51c-7656-5c3f-b0c0-28594fca8a1e")}catch{}})();var hn=3,gn=2,Io=["recency","activity_density","graph_proximity","priority_pressure","risk_pressure","knowledge_density"],td=new Set(["substantive_history","release_cohort","created_at"]),nd={context_signal_store_invalid:{code:"context_signal_store_invalid",meaning:"The persisted context-signal snapshot was unreadable or invalid and was rebuilt from authoritative items.",recovery_command:"pm context",recovery_effect:"Re-read context and confirm the rebuilt snapshot can be loaded without the warning."},context_signal_store_stale:{code:"context_signal_store_stale",meaning:"The persisted context-signal snapshot did not match the authoritative cursor or item corpus and was rebuilt.",recovery_command:"pm context",recovery_effect:"Re-read context and confirm the rebuilt snapshot is now fresh."},context_signal_store_write_failed:{code:"context_signal_store_write_failed",meaning:"Context signals were rebuilt in memory, but the derived snapshot could not be persisted.",recovery_command:"pm context",recovery_effect:"Retry the derived snapshot write and confirm the warning clears after storage access is restored."}};function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xo(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function rd(e){let t={};for(let n of Io){let r=e[n];if(r!==void 0){if(!xo(r))throw new TypeError(`Context relevance signal ${n} must be a finite number from 0 to 1`);t[n]=r}}return t}function id(e,t){let n=e.map(i=>[i.id,t(i)]),r=Math.max(0,...n.map(([,i])=>i));return Object.fromEntries(n.map(([i,o])=>[i,r===0?0:o/r]))}function od(e){let t=new Map(e.map(i=>[i.id,0])),n=i=>{t.set(i,(t.get(i)??0)+1)};for(let i of e){typeof i.parent=="string"&&i.parent.trim()&&(n(i.id),n(i.parent.trim()));for(let o of i.dependencies??[])typeof o.id!="string"||!o.id.trim()||(n(i.id),n(o.id.trim()))}let r=Math.max(0,...t.values());return Object.fromEntries(e.map(i=>[i.id,r===0?0:t.get(i.id)/r]))}function To(e,t){return{...t,activityDensity:t.activityDensity??id(e,n=>(n.comments?.length??0)+(n.notes?.length??0)+(n.learnings?.length??0)+(n.test_runs?.length??0)),graphProximity:t.graphProximity??od(e)}}function wn(e){let t=Co("sha256");for(let{id:n,signal_provenance:{recency:r}}of[...e].sort((i,o)=>i.id.localeCompare(o.id)))t.update(JSON.stringify([n,r.source,r.coordinate,r.history_op??null,r.event_class??null]));return`sha256:${t.digest("hex")}`}function sd(e){if(!pe(e))return null;let t=e.signal_provenance;if(![typeof e.id=="string",pe(e.signals),pe(t)].every(Boolean))return null;let n=t.recency;if(!pe(n))return null;let r=Ae(n.coordinate);if(r===null)return null;let i=new Set(Io),o=Object.entries(e.signals);return!o.every(([s,a])=>i.has(s)&&xo(a))||![typeof n.source=="string"&&td.has(n.source),["undefined","string"].includes(typeof n.history_op),[void 0,"substantive","maintenance"].includes(n.event_class),n.source==="substantive_history"?n.event_class===void 0||n.event_class==="substantive":n.history_op===void 0&&n.event_class===void 0].every(Boolean)?null:{id:e.id,signals:Object.fromEntries(o),signal_provenance:{recency:{source:n.source,coordinate:r,history_op:n.history_op,event_class:n.event_class}}}}function ad(e,t){let n=Array.from(e,sd);if(n.some(i=>i===null))return null;let r=n;return new Set(r.map(i=>i.id)).size!==r.length||r.some(i=>i.id.trim().length===0)||t!==wn(r)?null:r.sort((i,o)=>i.id.localeCompare(o.id))}function cd(e){if(!pe(e)||e.format_version!==hn||e.signal_set_version!==gn||typeof e.source_cursor!="string"||e.source_cursor.trim().length===0||typeof e.recency_evidence_fingerprint!="string"||!/^sha256:[a-f0-9]{64}$/u.test(e.recency_evidence_fingerprint)||typeof e.generated_at!="string"||!Number.isFinite(Date.parse(e.generated_at))||e.source!=="derived_index"&&e.source!=="scan_fallback"||!Array.isArray(e.items))return null;let t=ad(e.items,e.recency_evidence_fingerprint);return t===null?null:{format_version:hn,signal_set_version:gn,source_cursor:e.source_cursor,recency_evidence_fingerprint:e.recency_evidence_fingerprint,generated_at:e.generated_at,source:e.source,items:t}}function Ro(e){if(typeof e.sourceCursor!="string"||e.sourceCursor.trim().length===0)throw new TypeError("Context signal source cursor must be non-empty");if(!Number.isFinite(Date.parse(e.now)))throw new TypeError("Context signal snapshot clock must be a valid timestamp");if(e.source!=="derived_index"&&e.source!=="scan_fallback")throw new TypeError("Context signal snapshot source must be derived_index or scan_fallback")}function Ao(e,t,n=wn(e)){let r=e.map(({id:o})=>o);if(new Set(r).size!==r.length||r.some(o=>o.trim().length===0))throw new TypeError("Context signal snapshot item IDs must be unique and non-empty");let i=e.map(({id:o,signals:s,signal_provenance:a})=>({id:o,signals:rd(s),signal_provenance:a})).sort((o,s)=>o.id.localeCompare(s.id));return Object.freeze({format_version:hn,signal_set_version:gn,source_cursor:t.sourceCursor,recency_evidence_fingerprint:n,generated_at:t.now,source:t.source,items:Object.freeze(i.map(o=>Object.freeze(o)))})}function op(e,t){return Ro(t),Ao(St(e,To(e,t)),t)}var yn=class{filePath;constructor(t){if(typeof t!="string"||t.trim().length===0)throw new TypeError("Context signal store path must be non-empty");this.filePath=Fe.resolve(t)}async read(){try{return JSON.parse(await De.readFile(this.filePath,"utf8"))}catch(t){if(pe(t)&&Ke(t))return null;throw t}}async write(t){let n=Fe.dirname(this.filePath);await De.mkdir(n,{recursive:!0});let r=Fe.join(n,`.${Fe.basename(this.filePath)}.${ed()}.tmp`);try{await De.writeFile(r,`${JSON.stringify(t)}
|
|
@@ -9,4 +9,4 @@ import{$ as ft,E as Xt,F as gi,Ia as Ai,O as st,Q as ue,Qa as q,R as at,Ra as Mi
|
|
|
9
9
|
`)}catch{}}function Ls(e,t){return[`vector_index_stale:${e}`,`vector_index_recovery:${t.args.join(" ")}`,...t.follow_up_args?[`vector_index_recovery_follow_up:${t.follow_up_args.join(" ")}`]:[]]}function Ut(e,t,n,r){if(!t.active)throw new h(`Search mode '${e}' requires a configured embedding provider in settings.providers.openai or settings.providers.ollama`,f.USAGE);if(!n.active&&!r)throw new h(`Search mode '${e}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,f.USAGE);return{provider:t.active,vectorStore:n.active??null}}var B=Ye;function He(e){let t=C(),n=pi(t,e);if(!n)return null;let r=n.runtime_definition??n.definition,i=r.query,o=r.queryExpansion??r.query_expansion,s=r.rerank,a=B(r.name)??B(n.definition.name)??e;if(!a)return null;let d={providerName:a,...typeof i=="function"?{query:i}:{},...typeof o=="function"?{queryExpansion:o}:{},...typeof s=="function"?{rerank:s}:{}};return!d.query&&!d.queryExpansion&&!d.rerank?null:d}function rr(e){let t=B(e.search?.provider),n=He(t);return n?.query?{providerName:n.providerName,query:n.query}:null}function ir(e){let t=C(),n=B(e.vector_store?.adapter),r=hi(t,n);if(!r)return null;let i=r.runtime_definition??r.definition,o=i.query;if(typeof o!="function")return null;let s=i.upsert;return{adapterName:B(i.name)??B(r.definition.name)??n??"extension",query:o,...typeof s=="function"?{upsert:s}:{}}}function or(e,t,n){let r=Array.isArray(t)?t:t?.hits;if(!Array.isArray(r))throw new h(`Extension search provider "${e}" must return an array of hits or { hits: [...] }`,f.GENERIC_FAILURE);let i=new Set,o=[];for(let s of r){if(typeof s!="object"||s===null)continue;let a=B(s.id),d=s.score;if(!a||typeof d!="number"||!Number.isFinite(d)||i.has(a))continue;let c=n.get(a);if(!c)continue;let l=s.matched_fields,u=Array.isArray(l)&&l.every(m=>typeof m=="string")?[...new Set(l.map(m=>m.trim()).filter(m=>m.length>0))].sort((m,p)=>m.localeCompare(p)):[`provider:${e}`];i.add(a),o.push({item:c.metadata,score:d,matched_fields:u})}return o}function sr(e,t){let n=[],r=new Map;for(let i of e){if(r.has(i.id))continue;let o=t.get(i.id);o&&(r.set(i.id,i.score),n.push({item:o.metadata,score:i.score,matched_fields:["semantic"]}))}return{semanticHits:n,semanticScores:r}}function Nt(e,t){let n=t.filter(d=>d.exact_id_match===!0);if(n.length===0)return e;let r=new Set(n.map(d=>d.item.id)),i=e.filter(d=>!r.has(d.item.id)),o=i.reduce((d,c)=>Math.max(d,c.score),0),s=n.sort((d,c)=>c.score-d.score),a=o+s.length+1;return[...s.map((d,c)=>({...d,score:a-c,matched_fields:["id"]})),...i]}function Bt(e,t,n,r,i="semantic"){let o=new Map(n.map(u=>[u.item.id,u.score])),s=new Map(n.map(u=>[u.item.id,u.matched_fields])),a=Ge(t),d=Ge(o),c=new Set([...t.keys(),...o.keys()]),l=1-r;return[...c].map(u=>{let m=e.get(u),p=a.get(u)??0,g=d.get(u)??0,_=p*r+g*l;if(_<=0)return null;let y=new Set;t.has(u)&&y.add(i);for(let w of s.get(u)??[])y.add(w);return{item:m.metadata,score:_,matched_fields:[...y].sort((w,S)=>w.localeCompare(S))}}).filter(u=>u!==null)}function ar(e){let t=e.configuredProvider?.trim().toLowerCase();return t==="bm25"?"explicit":t==="auto"&&!e.hasEmbeddingProvider&&!e.hasExtensionSearchProvider?"auto-fallback":null}function cr(e){let t=e.filteredDocuments.map(s=>({id:s.metadata.id,text:Ss(xi(s,{fields:e.corpusFields}))})),n=vs(t),r=ks(n,Hn(e.query),e.bm25Params),i=new Map(e.filteredDocuments.map(s=>[s.metadata.id,s]));if(e.requestedMode==="semantic"){let s=[...r].map(([a,d])=>({item:i.get(a).metadata,score:d,matched_fields:["bm25"]}));return Nt(s,e.keywordHits)}let o=Bt(i,r,e.keywordHits,e.hybridSemanticWeight,"bm25");return Nt(o,e.keywordHits)}function dr(e){let t=new Map;for(let r of e)for(let i of r){let o=t.get(i.id);(!o||i.score>o.score)&&t.set(i.id,i)}let n=[...t.values()];return n.sort((r,i)=>r.score!==i.score?i.score-r.score:r.id.localeCompare(i.id)),n}function lr(e){let t=e.metadata,n=Array.isArray(t?.tags)?t.tags.join(" "):"";return[t?.title,t?.description,t?.type,t?.status,n,e.body].map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0).join(`
|
|
10
10
|
`)}async function Mm(e,t){let n=e.queryExpansion.enabled?Cs(t,e.queryExpansion.max_queries):[t],r=n.length>0?n:[t];if(!e.queryExpansion.enabled)return r;if(e.queryExpansionExtension?.expand)try{let i=await Promise.resolve(e.queryExpansionExtension.expand({query:t,mode:e.requestedMode,settings:e.settings}));return xs(r,Is(i),e.queryExpansion.max_queries)}catch{return e.warnings.push(`search_query_expansion_provider_failed:${e.queryExpansionExtension.providerName}:using_builtin`),r}return e.queryExpansion.provider&&e.queryExpansion.provider!=="openai"&&e.queryExpansion.provider!=="ollama"&&e.warnings.push(`search_query_expansion_provider_unavailable:${e.queryExpansion.provider}:using_builtin`),r}async function $m(e,t,n,r){if(e.extensionVectorAdapter?.query)try{return await Promise.resolve(e.extensionVectorAdapter.query({vector:t,limit:n,settings:e.settings}))}catch(i){if(!e.vectorStore)throw new h(`Extension vector adapter query failed and no built-in fallback store is configured (${i instanceof Error?i.message:String(i)})`,f.GENERIC_FAILURE);return e.warnings.push(`search_vector_adapter_failed:${e.extensionVectorAdapter.adapterName}:using_builtin`),await Jt(e.vectorStore,t,n,r)}if(e.vectorStore)return await Jt(e.vectorStore,t,n,r);throw new h("Semantic search requires either a configured vector store or an extension vector adapter query handler",f.USAGE)}function Om(e,t,n){return[...e].sort((r,i)=>r.score!==i.score?i.score-r.score:r.item.id.localeCompare(i.item.id)).slice(0,n).map(r=>{let i=t.get(r.item.id);return i?{hit:r,text:lr(i)}:null}).filter(r=>r!==null)}async function Lm(e,t,n){if(!e.rerankExtension?.rerank)return null;try{let r=await Promise.resolve(e.rerankExtension.rerank({query:t,mode:"hybrid",model:e.rerank.model,top_k:e.rerank.top_k,settings:e.settings,candidates:n.map(o=>({id:o.hit.item.id,text:o.text,score:o.hit.score}))})),i=As(r);return i.length>0?new Map(i.map(o=>[o.id,o.score])):(e.warnings.push(`search_rerank_provider_invalid_response:${e.rerankExtension.providerName}:using_builtin`),null)}catch{return e.warnings.push(`search_rerank_provider_failed:${e.rerankExtension.providerName}:using_builtin`),null}}async function Nm(e,t,n){let r=await Lm(e,t,n);if(r)return r;let i=n.map(o=>({id:o.hit.item.id,text:o.text}));try{return await Fs(e.provider,e.rerank.model,t,i,e.embeddingTimeoutMs)}catch{return e.warnings.push("search_rerank_failed:using_hybrid_scores"),null}}function Pm(e,t){let n=new Set(t.keys()),r=e.map(i=>{let o=t.get(i.item.id);if(o===void 0)return i;let s=new Set(i.matched_fields);return s.add("rerank"),{...i,score:o,matched_fields:[...s].sort((a,d)=>a.localeCompare(d))}});return r.sort((i,o)=>{let s=n.has(i.item.id),a=n.has(o.item.id);return s!==a?s?-1:1:i.score!==o.score?o.score-i.score:i.item.id.localeCompare(o.item.id)}),r}async function jm(e,t,n,r){if(!e.rerank.enabled||n.length<=1)return n;let i=Om(n,r,e.rerank.top_k),o=await Nm(e,t,i);return o&&o.size>0?Pm(n,o):n}async function ur(e){let t=Math.max(e.limit??e.maxResults,e.maxResults),n=e.embeddingTimeoutMs!==void 0?{timeout_ms:e.embeddingTimeoutMs}:{},r=e.vectorQueryTimeoutMs!==void 0?{timeout_ms:e.vectorQueryTimeoutMs}:{},i=e.query.trim(),o=await Mm(e,i),s=await lt(e.provider,o,n),a=await Promise.all(s.map(async g=>await $m(e,g,t,r))),d=dr(a),c=new Map(e.filteredDocuments.map(g=>[g.metadata.id,g])),{semanticHits:l,semanticScores:u}=sr(d,c),m=u.size;if(e.requestedMode==="semantic")return{hits:Nt(l,e.keywordHits),vectorMatchCount:m};let p=await jm(e,i,Bt(c,u,e.keywordHits,e.hybridSemanticWeight),c);return{hits:Nt(p,e.keywordHits),vectorMatchCount:m}}function Ns(e){let t=He(e.provider??void 0);return t?.queryExpansion?{providerName:t.providerName,expand:t.queryExpansion}:null}function Ps(e){let t=He(B(e.search?.provider));return t?.rerank?{providerName:t.providerName,rerank:t.rerank}:null}import Gt from"node:fs/promises";import mr 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]="de9a1cbd-f277-52ef-adc6-66225f2d2f4f")}catch{}})();function fr(e){let t=(e.files??[]).map(s=>({scope:s.scope,path:s.path.trim()})),n=(e.docs??[]).map(s=>({scope:s.scope,path:s.path.trim()})),r=(e.tests??[]).filter(s=>typeof s.path=="string"&&s.path.trim().length>0).map(s=>({scope:s.scope,path:s.path.trim()})),i=[...t,...n,...r].filter(s=>s.path.length>0).sort((s,a)=>s.scope.localeCompare(a.scope)||s.path.localeCompare(a.path)),o=new Map;for(let s of i)o.set(`${s.scope}:${s.path}`,s);return[...o.values()]}async function js(e){let t=mr.resolve(e);try{let n=await Gt.realpath(t);return{resolved:t,realpath:n}}catch{return null}}async function pr(e,t){let[n,r]=await Promise.all([js(e),js(t)]);return{projectContainmentRoot:n,globalContainmentRoot:r}}async function hr(e,t){let n=fr(e.metadata),r=[];for(let i of n){let o=i.scope==="global"?t.globalContainmentRoot:t.projectContainmentRoot;if(!o)continue;let s=mr.resolve(o.resolved,i.path);if(!zt(o.resolved,s))continue;let a;try{a=await Gt.realpath(s)}catch{continue}if(zt(o.realpath,a))try{await Se({path:s,scope:i.scope}),r.push(await Gt.readFile(s,"utf8"))}catch{}}return r.join(`
|
|
11
11
|
`)}async function gr(e,t,n,r){let i=Ar(C()),o=async(c,l,u)=>{let m=async(p,g)=>{await Se({path:p,scope:"project"});let _=await Gt.readFile(p,"utf8");return di(_,{format:g,schema:r,extensionFieldNames:i,onWarning:y=>s.push(y)}).body};try{return await m(l,u)}catch{let p=u==="toon"?"json_markdown":"toon",g=Vt(e,c.type,c.id,p,n);try{return await m(g,p)}catch{return s.push(`item_list_item_read_failed:${mr.relative(e,g)}`),""}}},s=[],a=await vi(e,t,n,s,r),d=[];if(a.length===0){let c=await ki(e,t,n,s,r);for(let l of c){let u=Vt(e,l.type,l.id,t,n),m=await o(l,u,t);d.push({metadata:l,body:m})}return{documents:d,warnings:[...new Set(s)].sort((l,u)=>l.localeCompare(u))}}for(let c of a){if(typeof c.body=="string"){d.push({metadata:c.metadata,body:c.body});continue}let l=await o(c.metadata,c.item_path,c.item_format);d.push({metadata:c.metadata,body:l})}return{documents:d,warnings:[...new Set(s)].sort((c,l)=>c.localeCompare(l))}}async function Us(e,t,n){let r=new Map;if(!e||t!=="keyword"&&t!=="hybrid")return r;let i=process.cwd(),o=await pr(i,Lr(i)),s=await Promise.all(n.map(async a=>[a.metadata.id,await hr(a,o)]));for(let[a,d]of s)r.set(a,d);return 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]="17122985-4157-5732-9142-444327cb273d")}catch{}})();var Bs=["tag","status","type","priority"];function yr(e){let t={},n=[];for(let r of e.split(/\s+/).filter(i=>i.length>0)){let i=r.indexOf(":"),o=i>0?r.slice(0,i).toLowerCase():"",s=i>0?r.slice(i+1):"",a=Bs.includes(o)?o:void 0;if(a&&s.length>0&&t[a]===void 0){t[a]=s;continue}n.push(r)}return{residualQuery:n.join(" "),inlineFilters:t}}function _r(e,t,n){let r={...e};for(let i of Bs){let o=t[i];if(o!==void 0){if(Ye(r[i])!==void 0){n.push(`search_inline_filter_ignored:${i}:flag_takes_precedence`);continue}r[i]=o}}return r}function Gs(e,t){let n=[],r=yr(e),i=Object.keys(r.inlineFilters).length>0;if(i&&r.residualQuery.trim().length===0)throw new h("Inline field:value tokens consumed the entire query, leaving no search terms.",f.USAGE,{examples:["pm search auth tag:area:search","pm list --tag area:search --status open"],nextSteps:["Add keyword terms alongside the inline filters, or use pm list for pure tag/status/type/priority filtering."]});let o=i?r.residualQuery:e,s=_r(t,r.inlineFilters,n);return{query:o,options:s,inlineWarnings:n,highlight:s.highlight===!0,includeLinked:Ft(s.includeLinked),titleExact:Ft(s.titleExact),phraseExact:Ft(s.phraseExact),matchMode:gs(typeof s.matchMode=="string"?s.matchMode:void 0),minScoreOverride:ys(s.minScore),countOnly:s.count===!0,tokens:$t(o),normalizedQuery:U(o),limit:ue(s.limit),projection:Mt(s,e),modeWasExplicit:typeof s.mode=="string"&&s.mode.trim().length>0}}function Hs(e){if(e.after!==void 0&&e.count===!0)throw new h("Search --after cannot be combined with --count.",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]="d7beacb7-66a5-581f-93f0-68ceb4b8e41e")}catch{}})();function br(e,t,n,r,i,o,s,a,d,c,l,u,m,p){let g=m?{total:0,count_only:!0}:{};if(c.mode==="compact"&&r.compact===!0){let y=ye({mode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,runtimeFieldFilters:u});return{query:e.trim(),mode:t,...Er(p),items:[],count:0,...g,filters:y,...l.length>0?{warnings:l}:{}}}let _=c.mode==="full"?null:[...c.fields];return{query:e.trim(),mode:t,mode_source:p,items:[],count:0,...g,filters:_e({effectiveMode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,queryExpansion:a,rerank:d,runtimeFieldFilters:u??{}}),projection:{mode:c.mode,fields:_},now:F(),...l.length>0?{warnings:l}:{}}}function vr(e,t){let n=t.trim();if(n.length===0)return null;if(n==="score")return e.score;if(n==="matched_fields")return e.matched_fields;if(n.startsWith("item.")){let o=n.slice(5);return o.length===0?null:e.item[o]??null}let r=e,i=e.item;return Object.prototype.hasOwnProperty.call(i,n)?i[n]??null:Object.prototype.hasOwnProperty.call(r,n)?r[n]??null:null}function kr(e,t){return t.mode==="full"?e.map(({matched_all_terms:n,exact_id_match:r,...i})=>i):e.map(n=>{let r={};for(let i of t.fields)r[i]=vr(n,i);return r})}function Sr(e,t){return br(e.query,e.effectiveMode,e.matchMode,e.options,e.includeLinked,e.scoreThreshold,e.hybridSemanticWeight,e.queryExpansion,e.rerank,e.projection,e.warnings,e.runtimeFieldFilters,t,e.modeSource)}function qs(e,t){if(e.projection.mode==="compact"&&e.options.compact===!0)return wr({query:e.query.trim(),mode:e.effectiveMode,...Er(e.modeSource),items:[],count:t,total:t,count_only:!0,filters:ye({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let n=e.projection.mode==="full"?null:[...e.projection.fields];return wr({query:e.query.trim(),mode:e.effectiveMode,mode_source:e.modeSource,items:[],count:t,total:t,count_only:!0,filters:_e({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:e.projection.mode,fields:n},now:F()},e.warnings)}function Er(e){return e==="settings"?{mode_source:e}:{}}function wr(e,t){return t.length===0?e:{...e,warnings:t}}function qe(e,t){return t?{...e,workspace_memory:t}:e}function Ws(e,t,n){if(!e.highlight)return{hits:n,projection:e.projection};let r=new Map(t.map(o=>[o.metadata.id,o])),i=n.map(o=>({...o,highlights:Lt(r.get(o.item.id),o.matched_fields,e.tokens)}));return e.projection.mode==="full"||e.projection.fields.includes("highlights")?{hits:i,projection:e.projection}:{hits:i,projection:{mode:e.projection.mode,fields:[...e.projection.fields,"highlights"]}}}function zs(e,t,n,r,i,o){let s=r<n?{total:n}:{};if(e.projection.mode==="compact"&&e.options.compact===!0)return wr({query:e.query.trim(),mode:e.effectiveMode,...Er(e.modeSource),items:t,count:t.length,...s,...o,filters:ye({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let a=i.mode==="full"?null:[...i.fields];return{query:e.query.trim(),mode:e.effectiveMode,mode_source:e.modeSource,items:t,count:t.length,...s,...o,filters:_e({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:i.mode,fields:a},now:F(),...e.warnings.length>0?{warnings:e.warnings}:{}}}(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]="3bfd872f-6ed7-551c-a027-3748493de3e9")}catch{}})();var Vy={applyFilters:Yn,applyExactQueryFilters:Kn,applyInlineQueryFilters:_r,buildHitHighlights:Lt,buildVerboseSearchFilters:_e,buildExplicitSemanticFallbackWarning:tr,buildCompactSearchFilterSummary:ye,buildHybridLexicalScore:er,buildRerankCorpus:lr,buildSemanticHits:sr,classifyImplicitSemanticFallbackReason:jt,collectErrorCauseCodes:Pt,collectExactPhraseFields:zn,collectLinkedPaths:fr,combineHybridHits:Bt,computeBuiltInBm25Hits:cr,computeSemanticOrHybridHits:ur,resolveBuiltInBm25Mode:ar,countOccurrences:Ot,dependencyEntries:Be,documentContainsExactPhrase:Vn,emptySearchResult:br,highlightFieldSnippet:Qn,loadDocuments:gr,markTokenRuns:Xn,parseInlineQueryFilters:yr,maybeEmitVectorIndexStaleWarning:nr,loadLinkedCorpus:hr,mergeVectorHitsById:dr,normalizeExtensionProviderHits:or,normalizeScoreMap:Ge,parseProjectionConfig:Mt,parseTimestampWindow:oe,parseTokens:$t,projectSearchHits:kr,readSearchFieldValue:vr,requireSemanticDependencies:Ut,resolveExtensionSearchProvider:rr,resolveExtensionSearchProviderByName:He,resolveExtensionVectorAdapter:ir,resolveLinkedCorpusRoots:pr,scoreDocument:Jn,sortHits:Zn,stringArray:we,textEntries:K,validateSearchProjectionFields:Ln};async function Um(e,t){let n=T(process.cwd(),t.path);await G(n);let r=await M(n),i=bi(r).settings,o=P(i.schema),s=Q(i.schema);Ln(e.projection,s,e.query);let a=at(e.options,s,"search"),d=D(i,C()),c=Ci(i),l=Ti(i,n),u=rr(i),m=ir(i),p=hs(e.options.semanticWeight),g=Ts(i,c.active?.name??null),_=Rs(i,c.active?.model??B(i.search?.embedding_model)??"text-embedding-3-small");return{pmRoot:n,settings:i,statusRegistry:o,runtimeFieldRegistry:s,runtimeFieldFilters:a,typeRegistry:d,maxResults:Nn(i),scoreThreshold:e.minScoreOverride??jn(i),semanticWeightProvided:e.options.semanticWeight!==void 0,semanticWeightOverride:p,hybridSemanticWeight:p??Un(i),tuning:Bn(i),providerResolution:c,vectorResolution:l,extensionSearchProvider:u,extensionVectorAdapter:m,bm25Mode:ar({configuredProvider:B(i.search?.provider),hasEmbeddingProvider:c.active!==null,hasExtensionSearchProvider:u!==null}),queryExpansion:g,queryExpansionExtension:Ns(g),rerank:_,rerankExtension:Ps(i),...Bm({requested:e.options.mode,settings:i,configuredProvider:r.search?.provider??null,providerResolution:c,vectorResolution:l,extensionSearchProvider:u,extensionVectorAdapter:m})}}function Bm(e){let t=Ei(e.providerResolution.active?.name,e.configuredProvider)==="configured"&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null),n=e.extensionSearchProvider!==null||t,r=Pn({requested:e.requested,settings:e.settings,semanticRunnable:n});return{effectiveMode:r.mode,modeSource:r.source}}async function Gm(e,t){let n=await gr(t.pmRoot,t.settings.item_format??"toon",t.typeRegistry.type_to_folder,t.settings.schema),r=st(typeof e.options.status=="string"?e.options.status:void 0,t.statusRegistry,{strict:!0}),i=Ni(t.statusRegistry),o=Yn(n.documents,e.options,t.typeRegistry,t.runtimeFieldFilters,r,i);return{warnings:n.warnings,allDocuments:n.documents,filteredDocuments:Kn(o,e.normalizedQuery,{titleExact:e.titleExact,phraseExact:e.phraseExact||e.matchMode==="exact"})}}async function Hm(e,t,n){let r=await Us(e.includeLinked,t.effectiveMode,n),i=e.matchMode==="or";return n.map(o=>er(o,e.tokens,e.normalizedQuery,e.includeLinked,r,t.tuning,t.settings.id_prefix,i)).filter(o=>o!==null).filter(o=>e.matchMode!=="and"||o.matched_all_terms===!0)}async function qm(e,t,n,r,i){if(t.bm25Mode===null||t.effectiveMode==="keyword")return null;let o=cr({requestedMode:t.effectiveMode,query:e.query,filteredDocuments:n,keywordHits:r,corpusFields:Ii(t.settings),bm25Params:Es(t.settings),hybridSemanticWeight:t.hybridSemanticWeight});return t.bm25Mode==="auto-fallback"&&i.push(`search_${t.effectiveMode}_offline_bm25:no_embedding_provider:using_lexical_bm25`),o}async function Wm(e,t,n,r){if(!t.extensionSearchProvider)return null;let i=t.providerResolution.active!==null&&(t.vectorResolution.active!==null||t.extensionVectorAdapter!==null);try{let o=await Promise.resolve(t.extensionSearchProvider.query({query:e.query,mode:t.effectiveMode,tokens:e.tokens,options:e.options,settings:t.settings,documents:n}));return or(t.extensionSearchProvider.providerName,o,r)}catch(o){if(!i)throw new h(`Extension search provider "${t.extensionSearchProvider.providerName}" failed: ${o instanceof Error?o.message:String(o)}`,f.GENERIC_FAILURE);return null}}function zm(e,t,n,r){return t.vectorMatchCount>0?t.hits:(r.push(`search_${e}_degraded:no_vector_matches:results_are_lexical`),e==="semantic"?n:t.hits)}async function Vm(e,t,n,r,i){let o=!e.extensionSearchProvider&&e.providerResolution.active!==null&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null);i&&o&&await nr(e.pmRoot,n,r),e.extensionSearchProvider||Ut(t,e.providerResolution,e.vectorResolution,e.extensionVectorAdapter!==null)}async function Km(e){let{prepared:t,runtime:n,filteredDocuments:r,keywordHits:i,warnings:o,modeWasExplicit:s}=e,a=i,d=await qm(t,n,r,i,o),c=n.effectiveMode;if(d!==null||c==="keyword")return{effectiveMode:n.effectiveMode,hits:d??a};try{if(await Vm(n,c,r,o,s),r.length===0||t.limit===0)return{effectiveMode:n.effectiveMode,hits:[]};let l=new Map(r.map(u=>[u.metadata.id,u]));if(a=await Wm(t,n,r,l)??a,a===i){let{provider:u,vectorStore:m}=Ut(c,n.providerResolution,n.vectorResolution,n.extensionVectorAdapter!==null),p=await ur({requestedMode:c,query:t.query,filteredDocuments:r,keywordHits:i,hybridSemanticWeight:n.hybridSemanticWeight,limit:t.limit,maxResults:n.maxResults,provider:u,vectorStore:m,extensionVectorAdapter:n.extensionVectorAdapter,queryExpansion:n.queryExpansion,queryExpansionExtension:n.queryExpansionExtension,rerank:n.rerank,rerankExtension:n.rerankExtension,warnings:o,settings:n.settings});a=zm(c,p,i,o)}return{effectiveMode:n.effectiveMode,hits:a}}catch(l){return o.push(tr(n.effectiveMode,l)),{effectiveMode:"keyword",hits:i}}}function Vs(e){e.searchOptions.after!==void 0&&qr(e.searchOptions.after,Gn(e))}async function Ky(e,t,n){Hs(t);let r=Gs(e,t),i=await Um(r,n),o=await Gm(r,i),s=o.warnings;s.push(...r.inlineWarnings);let a=await It(o.allDocuments.map(k=>k.metadata),{pmRoot:i.pmRoot,statusRegistry:i.statusRegistry,now:F()});s.push(...a.warnings);let d=Oo(a,r.query);i.effectiveMode==="hybrid"&&i.semanticWeightProvided&&i.semanticWeightOverride===void 0&&s.push("search_hybrid_semantic_weight_override_invalid:using_settings_default");let c={query:r.query,modeSource:i.modeSource,matchMode:r.matchMode,options:r.options,includeLinked:r.includeLinked,titleExact:r.titleExact,phraseExact:r.phraseExact,scoreThreshold:i.scoreThreshold,hybridSemanticWeight:i.hybridSemanticWeight,queryExpansion:i.queryExpansion,rerank:i.rerank,projection:r.projection,warnings:s,runtimeFieldFilters:i.runtimeFieldFilters};if(i.effectiveMode==="keyword"&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return Vs({query:r.query,mode:i.effectiveMode,searchOptions:r.options,pmRoot:i.pmRoot}),qe(Sr({...c,effectiveMode:i.effectiveMode},r.countOnly),d);let l=await Hm(r,i,o.filteredDocuments),u=await Km({prepared:r,runtime:i,filteredDocuments:o.filteredDocuments,keywordHits:l,warnings:s,modeWasExplicit:r.modeWasExplicit});if(u.effectiveMode!=="keyword"&&u.hits.length===0&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return Vs({query:r.query,mode:u.effectiveMode,searchOptions:r.options,pmRoot:i.pmRoot}),qe(Sr({...c,effectiveMode:u.effectiveMode},r.countOnly),d);let m=u.hits.filter(k=>k.exact_id_match===!0||k.score>=i.scoreThreshold),p=Zn(m,i.statusRegistry),g=p.length,_=_s({pmRoot:i.pmRoot,sorted:p,query:r.query,mode:u.effectiveMode,searchOptions:r.options,limit:r.limit??i.maxResults}),y={...c,effectiveMode:u.effectiveMode};if(r.countOnly)return qe(qs(y,g),d);let{hits:w,projection:S}=Ws(r,o.filteredDocuments,_.limited),b=kr(w,S);return qe(zs(y,b,g,_.limited.length,S,_.pageExtras),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]="f303192a-cac2-588b-b988-e3a8132f4199")}catch{}})();var Ks=["ndcg","mrr","precision","recall"];function Ym(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Eval minimum must be an object of metric floors");let t={};for(let[n,r]of Object.entries(e)){if(!Ks.some(i=>i===n))throw new TypeError(`Unknown eval minimum metric: ${n}`);if(typeof r!="number"||!Number.isFinite(r)||r<0||r>1)throw new TypeError(`Eval minimum.${n} must be a finite number in [0, 1]`);t[n]=r}return t}function Xy(e,t){let n=Ym(t),r=[];for(let i of Ks){let o=n[i];if(o===void 0)continue;let s=e[i];!Number.isFinite(s)||s<0||s>1?r.push(`${i}:invalid`):s<o&&r.push(`${i}:${s}<${o}`)}return r}export{Qs as a,Jm as b,Zi as c,Zs as d,ea as e,tn as f,tf as g,aa as h,ca as i,nf as j,af as k,oh as l,to as m,ff as n,pf as o,hf as p,gf as q,no as r,Sf as s,Ef as t,Cf as u,po as v,_t as w,nc as x,wt as y,vt as z,Uf as A,wo as B,pn as C,St as D,Mc as E,So as F,Pc as G,Et as H,jc as I,Uc as J,qc as K,Wc as L,Kf as M,zc as N,Eo as O,hn as P,gn as Q,nd as R,cd as S,op as T,yn as U,_n as V,Ct as W,fd as X,yd as Y,It as Z,Ed as _,$o as $,Cd as aa,Oo as ba,Id as ca,Md as da,Me as ea,Np as fa,kn as ga,Ld as ha,Nd as ia,En as ja,ie as ka,In as la,xn as ma,Tn as na,he as oa,Le as pa,Tt as qa,Pp as ra,Nl as sa,jp as ta,Gl as ua,Zp as va,eh as wa,th as xa,nh as ya,rh as za,uh as Aa,mh as Ba,ls as Ca,us as Da,ms as Ea,jh as Fa,Uh as Ga,Qh as Ha,Nn as Ia,Pn as Ja,jn as Ka,Un as La,Bn as Ma,Gn as Na,_s as Oa,ye as Pa,_e as Qa,Pt as Ra,jt as Sa,Os as Ta,Ls as Ua,Vy as Va,Ky as Wa,Ks as Xa,Ym as Ya,Xy as Za};
|
|
12
|
-
//# sourceMappingURL=chunk-
|
|
12
|
+
//# sourceMappingURL=chunk-EIOQNLBQ.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{r as D,s as q}from"./chunk-
|
|
1
|
+
import{r as D,s as q}from"./chunk-52UJEHEV.js";import{Yb as N,cc as z,ec as _}from"./chunk-SIEGIPNT.js";import{fd as C,fe as x,id as L,ka as k,ld as j,pa as m,tb as O,ua as b,ya as S}from"./chunk-B3YW6H2I.js";import{constants as p}from"node:fs";import{lstat as M,mkdir as $,open as F}from"node:fs/promises";import h from"node:path";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="5434ff6f-95af-5983-88cb-fd360d95cb9e")}catch{}})();function E(r,e){if(typeof r!="string"||r.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return r.trim()}function I(r,e){let t=e.require(r.kind),i=t.direction==="undirected"?[r.source,r.target].sort().join("\0"):`${r.source}\0${r.target}`;return`${t.kind}\0${i}`}function H(r){return Object.freeze({...r,...r.payload===void 0?{}:{payload:Object.freeze(structuredClone(r.payload))}})}function J(r,e,t,i){let n=t.require(r.kind),o=i.outgoingOne.get(`${n.kind}\0${r.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${n.kind}`);let s=i.incomingOne.get(`${n.kind}\0${r.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${n.kind}`);let c=I(r,t),a=i.identities.get(c);if(a!==void 0&&a!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function K(r){let e=new Map;for(let t of r)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function G(r,e,t){if(r.expectedVersion!==void 0&&r.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${r.expectedVersion}, current ${e}`);let i=E(r.eventId,"eventId");if(t.has(i))throw new TypeError(`Relationship event already exists: ${i}`);if(r.action!=="add"&&r.action!=="remove"&&r.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${r.action}`);if(!Number.isFinite(Date.parse(r.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:i,relationshipId:E(r.relationshipId,"relationshipId"),author:E(r.author,"author"),timestamp:new Date(r.timestamp).toISOString()}}function Q(r,e,t,i,n,o){let s=t.has(e);if(r.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(r.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(r.action==="remove")return;if(!r.edge)throw new TypeError(`Relationship ${r.action} event requires an edge`);let c=typeof r.edge.source=="string"?r.edge.source.trim():"",a=typeof r.edge.target=="string"?r.edge.target.trim():"";if(!i.has(c)||!i.has(a))throw new TypeError(`Relationship endpoint not found: ${c} -> ${a}`);let d=new m([c,a],[r.edge],n).edges()[0];return J(d,e,n,o),H(d)}var T=class{#t;#i;#r=[];#o=new Set;#e=new Map;#n={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(i=>typeof i=="string").map(i=>i.trim()).filter(Boolean)),this.#i=t.registry??k()}get version(){return this.#r.length}events(){return Object.freeze([...this.#r])}*stream(e={}){let t=e.fromVersion??1,i=e.toVersion??this.version,n=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(i)||i<0||i>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${i}`);if(!Number.isInteger(n)||n<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>i+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<i;o+=n)yield Object.freeze(this.#r.slice(o,Math.min(o+n,i)))}project(e,t,i={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let n=e,o=0,s;for(let c of this.stream({...i,batchSize:256}))for(let a of c)n=t(n,a),o+=1,s=a;return Object.freeze({state:n,version:s?.sequence??Math.max(0,(i.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let i=this.#i.require(t.kind);this.#n.identities.set(I(t,this.#i),e),i.outgoing==="one"&&this.#n.outgoingOne.set(`${i.kind}\0${t.source}`,e),i.incoming==="one"&&this.#n.incomingOne.set(`${i.kind}\0${t.target}`,e)}#a(e){let t=this.#i.require(e.kind);this.#n.identities.delete(I(e,this.#i)),t.outgoing==="one"&&this.#n.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#n.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=G(e,this.version,this.#o),i=this.#e.get(t.relationshipId),n=Q(e,t.relationshipId,this.#e,this.#t,this.#i,this.#n),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...n===void 0?{}:{edge:n},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#r.push(o),this.#o.add(t.eventId),i&&this.#a(i),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,n),this.#s(t.relationshipId,n)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#r.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#r.slice(0,o)}let i=K(t),n=new m(this.#t,i.values(),this.#i);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:n.edges(),graph:n})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=C("relationship-events",{order:"append-sequence"}),i=e.cursor===void 0?this.version:Number(L(e.cursor,t).snapshot);if(!Number.isSafeInteger(i)||i<0||i>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let n=j(this.#r.slice(0,i),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(i)});return{version:i,events:n.rows,hasMore:n.has_more,...n.next_cursor?{nextCursor:n.next_cursor}:{}}}},Y="relationship-event-store",A=p.O_NOFOLLOW;function g(r){return x(r,Y,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function f(r,e="relationships/events.jsonl"){let t=h.resolve(r),i=h.resolve(t,e),n=h.relative(t,i);if(n.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(n===".."||n.startsWith(`..${h.sep}`)||h.isAbsolute(n))throw new TypeError("Relationship event path must stay within the tracker root");if(await $(t,{recursive:!0}),(await M(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let o=t;for(let s of n.split(h.sep)){o=h.join(o,s);try{if((await M(o)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(c){if(b(c))break;throw c}}return i}async function w(r,e,t){let i=new T(e,{registry:t}),n,o;try{o=await F(r,p.O_RDONLY|A),n=await o.readFile("utf8")}catch(c){if(b(c))return{log:i,raw:""};throw c}finally{await o?.close()}let s=n.split(`
|
|
2
2
|
`);for(let c=0;c<s.length;c+=1){let a=s[c].trim();if(!a)continue;let d;try{d=JSON.parse(a)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${c+1}`)}if(d.sequence!==i.version+1)throw new TypeError(`Invalid relationship event sequence at line ${c+1}`);i.append({eventId:d.eventId,relationshipId:d.relationshipId,action:d.action,...d.edge===void 0?{}:{edge:d.edge},author:d.author,timestamp:d.timestamp,...d.reason===void 0?{}:{reason:d.reason},expectedVersion:i.version})}return{log:i,raw:n}}function U(r,e,t,i){let n=Date.parse(e.timestamp),o;return e.action!=="remove"&&e.edge!==void 0&&(o=new m(t,[e.edge],i).edges()[0]),r.eventId===e.eventId.trim()&&r.relationshipId===e.relationshipId.trim()&&r.action===e.action&&r.author===e.author.trim()&&Number.isFinite(n)&&r.timestamp===new Date(n).toISOString()&&r.reason===(e.reason?.trim()||void 0)&&O(r.edge)===O(o)}var V=class r{#t;#i;#r;#o;#e;constructor(e,t,i,n){this.#t=e.pmRoot,this.#i=t,this.#r=e.registry,this.#o=i,this.#e=n}static async open(e){let t=Object.freeze([...e.nodes]),i=await f(e.pmRoot,e.relativePath),n=await g(e.pmRoot);try{await f(e.pmRoot,i);let{log:o}=await w(i,t,e.registry);return new r(e,t,i,o)}finally{await n()}}get path(){return this.#o}async currentVersion(){return this.#e=await this.#n(),this.#e.version}async append(e){let t=await g(this.#t);try{let i=await f(this.#t,this.#o),{log:n}=await w(i,this.#i,this.#r),o=n.append(e);await $(h.dirname(i),{recursive:!0}),await f(this.#t,i);let s=await F(i,p.O_APPEND|p.O_CREAT|p.O_WRONLY|A);try{await s.appendFile(`${JSON.stringify(o)}
|
|
3
3
|
`,"utf8")}finally{await s.close()}return this.#e=n,o}finally{await t()}}async appendBatch(e,t={}){let i=await g(this.#t);try{let n=await f(this.#t,this.#o),{log:o,raw:s}=await w(n,this.#i,this.#r),c=o.version,a=new Map(o.events().map(l=>[l.eventId,l])),d=[],R=[];for(let l of e){let u=l.eventId.trim(),v=a.get(u);if(v!==void 0){if(t.existingEventPolicy==="skip_identical"&&U(v,l,this.#i,this.#r)){R.push(v.eventId);continue}if(t.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${u}`)}let y=o.append(l);a.set(y.eventId,y),d.push(y)}if(d.length>0){let l=s.length===0||s.endsWith(`
|
|
4
4
|
`)?s:`${s}
|
|
5
5
|
`;await $(h.dirname(n),{recursive:!0}),await f(this.#t,n),await S(n,`${l}${d.map(u=>JSON.stringify(u)).join(`
|
|
6
6
|
`)}
|
|
7
7
|
`)}return this.#e=o,Object.freeze({version_before:c,version_after:o.version,appended:Object.freeze(d),skipped_event_ids:Object.freeze(R)})}finally{await i()}}async snapshot(e={}){return this.#e=await this.#n(),this.#e.snapshot(e)}async page(e){return this.#e=await this.#n(),this.#e.page(e)}async*stream(e={}){this.#e=await this.#n(),yield*this.#e.stream(e)}async project(e,t,i={}){return this.#e=await this.#n(),this.#e.project(e,t,i)}async#n(){let e=await g(this.#t);try{let t=await f(this.#t,this.#o);return(await w(t,this.#i,this.#r)).log}finally{await e()}}};(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new r.Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="73852fdf-f072-51ab-9449-d7922712eeb4")}catch{}})();function P(r){return[...r].sort().join("\0")}function X(r,e,t){let i=r.successors.get(e);i?i.push(t):r.successors.set(e,[t]);let n=r.predecessors.get(t);n?n.push(e):r.predecessors.set(t,[e])}function W(r,e,t,i,n){let o=e.resolve(n);if(o?.ordering!==!0)return;let s=z(i),c=s===void 0?void 0:r.canonicalIds.get(s.toLowerCase());if(c===void 0)return;let a=(o.precedence??"source_before_target")==="source_before_target";X(r,a?t:c,a?c:t)}function Z(r,e){let t={successors:new Map,predecessors:new Map,canonicalIds:new Map},i=r.filter(n=>typeof n?.id=="string"&&n.id.trim().length>0);for(let n of i){let o=n.id.trim();t.canonicalIds.set(o.toLowerCase(),o)}for(let n of i){let o=n.id.trim();W(t,e,o,n.blocked_by,"blocked_by");for(let s of n.dependencies??[])typeof s!="object"||s===null||W(t,e,o,s.id,typeof s.kind=="string"?s.kind:"related")}for(let n of[t.successors,t.predecessors])for(let o of n.values())o.sort();return t}function ee(r,e){let t=new Set([e]),i=[e];for(;i.length>0;){let n=i.pop();for(let o of[r.successors,r.predecessors])for(let s of o.get(n)??[])t.has(s)||(t.add(s),i.push(s))}return t}function te(r,e){let t=new Map;for(let i of e){let n=(r.successors.get(i)??[]).filter(o=>e.has(o));n.length>0&&t.set(i,n)}return t}function B(r,e,t){let i=Z(r,e),n=i.canonicalIds.get(t.trim().toLowerCase());if(n===void 0)return{cycles:[],successors:new Map,canonical:t};let o=te(i,ee(i,n));return{cycles:D(o).filter(s=>s.includes(n)),successors:o,canonical:n}}function ie(r,e,t){let i=new Set(e),n=i.has(t)?t:e[0];if(r.get(n)?.includes(n))return[n,n];for(let o of r.get(n)??[]){if(!i.has(o))continue;let s=re(r,i,n,o);if(s)return s}return[...e,e[0]]}function re(r,e,t,i){let n=[[i]],o=new Set([t,i]);for(;n.length>0;){let s=n.shift(),c=s.at(-1);for(let a of r.get(c)??[]){if(a===t)return[t,...s,t];!e.has(a)||o.has(a)||(o.add(a),n.push([...s,a]))}}}function me(r,e,t){let i=N(),n=B(r,i,t),o=B(e,i,t),s=new Set(n.cycles.map(P)),c=new Set(_(r,void 0,i).map(a=>`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`));return[..._(e,void 0,i).filter(a=>a.holder_id.toLowerCase()===t.trim().toLowerCase()&&!c.has(`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`)).map(a=>`ordering_storage_contradiction_created:${q(a)}:remove_contradicting_dependency_row:run_pm_graph_audit`),...o.cycles.filter(a=>!s.has(P(a))).map(a=>`ordering_cycle_created:${ie(o.successors,a,o.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)]}export{T as a,V as b,me as c};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-GVGFUD52.js.map
|