@unbrained/pm-cli 2026.11.10 → 2026.11.11
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 +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/cli/commander-usage.js +2 -2
- package/dist/cli/error-guidance.js +3 -3
- package/dist/cli/help-json-payload.js +1 -1
- package/dist/cli/main.js +4 -4
- package/dist/cli/runtime/refusal-credential-redaction.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-NNE63MSM.js → chunk-4RHXGQMK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YSWD2NXB.js → chunk-5N3JMGXU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TBBWPEF5.js → chunk-DIWTFDU7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OJ2KEDUX.js → chunk-DV7WBAKQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-F6FBGLR7.js → chunk-EBAHNZJT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BSJSGDA3.js → chunk-FM375BHH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-F7P2NZEG.js → chunk-GOLQYO6M.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-GZ52WAY2.js +124 -0
- package/dist/cli-bundle/chunks/{chunk-EHDGHFMJ.js → chunk-JESMEJTD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CZETQYKO.js → chunk-JLQ7O6UV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FYD6LSJA.js → chunk-L3SA3354.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-U7LILCUN.js → chunk-NIOOJ3AG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WNEUWDUE.js → chunk-PZI6CR24.js} +46 -46
- package/dist/cli-bundle/chunks/{chunk-NZAFLDSH.js → chunk-QCTA2UFR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4FLAKTZW.js → chunk-SPERPX27.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-T2MNRM3S.js → chunk-SVVFJPNW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5CAMQHEW.js → chunk-WEAF3OY4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UL64P6MR.js → chunk-WWW5WHHJ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-X7NM5HVQ.js → chunk-XJUYJXHZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-L4WWG2H6.js → chunk-XN2BRWDD.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-Z4YEH7VQ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-7NAAW5EX.js → chunk-ZJDYBXMC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4AASUCHO.js → chunk-ZSL6U53K.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-M7KXLQXF.js → item-revision-LNIHK36Q.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-TMUYPSMR.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-admission-374UR7NI.js → mutation-admission-WZY22LVH.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-GSB7PP5P.js → register-list-query-DYGPLVRL.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-ZBF6ITYK.js → register-mutation-MP5JCBAJ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-PWF6GOHE.js → register-operations-QEASK3EF.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-QDZ2Y3CI.js → register-setup-G66U2WFV.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-67WGPKPH.js → stage-VIDXGF3T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WK773UVA.js → chunk-2ZS3I5ZP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-33EK522E.js +26 -0
- package/dist/cli-bundle/focused-chunks/{chunk-BE2GK2G7.js → chunk-3A6XMQZJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PAGW6A2X.js → chunk-3FN4ON2Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3DWNH72D.js → chunk-3SH3L3DB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ALLOWZSH.js → chunk-6ICHSVEY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-QK7FX4O5.js → chunk-6TJXTKZD.js} +4 -4
- package/dist/cli-bundle/focused-chunks/{chunk-QHGGO7SY.js → chunk-AXPRCCYM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UIZVD36C.js → chunk-DW5S67LO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-HTMQDNVC.js → chunk-GBW2EAAG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZBOCYFBE.js → chunk-HIKZYZ26.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-QCHCEFTO.js → chunk-JYWVRXLD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-M5FZTPFA.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2SQUWQP3.js → chunk-MK7UQEE5.js} +18 -18
- package/dist/cli-bundle/focused-chunks/{chunk-2Y4H4LIX.js → chunk-NMU3QFAU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LY3JXL25.js → chunk-NP5C2TQM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RFMKS7VD.js → chunk-NSOXVVQX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WJHDUON5.js → chunk-NY65XTX7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-67M7E2Z3.js → chunk-P6KYUJD4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LWMPQRJT.js → chunk-UCUESVFW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NZQYHPUN.js → chunk-V27M5UQH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3K2MYE7R.js → chunk-VVGXPF4W.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-XC4ZJ7MY.js → item-revision-B3BIG66B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-CVGK4RJP.js → item-transaction-4JDWOXNB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-N27D5H64.js → mutation-admission-577MXOGD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-KPK2UHVO.js → stage-EKYWEU2Y.js} +2 -2
- package/dist/cli-bundle/main.js +32 -32
- 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 +1 -1
- 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 +57 -57
- 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 +11 -11
- package/dist/core/sentry/instrument.js +1 -1
- package/dist/core/shared/secret-rules.d.ts +18 -2
- package/dist/core/shared/secret-rules.js +4 -2
- package/dist/core/shared/url-credentials.d.ts +37 -0
- package/dist/core/shared/url-credentials.js +2 -0
- package/dist/core/telemetry/runtime.js +2 -2
- package/dist/sdk/command-line.d.ts +1 -1
- package/dist/sdk/command-line.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/lifecycle/item-revision.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/docs/CODEX_PLUGIN.md +2 -1
- package/docs/CONFIGURATION.md +16 -0
- package/docs/MUTATION_INTEGRITY.md +65 -0
- package/docs/README.md +2 -2
- package/docs/SDK.md +16 -0
- package/marketplace.json +1 -1
- package/package.json +2 -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 +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-D727C4RO.js +0 -122
- package/dist/cli-bundle/chunks/chunk-UFPLZ6LZ.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-4N5P34GO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-56MIAFEN.js +0 -24
- package/dist/cli-bundle/focused-chunks/chunk-U7HWWEJ2.js +0 -2
- package/docs/CHATGPT_CODEX_PLUGIN_IMPLEMENTATION.md +0 -776
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as E,i as f,j as ie,k as ae,l as le,o as y,p as de,q as ue,r as me}from"./chunk-
|
|
1
|
+
import{f as E,i as f,j as ie,k as ae,l as le,o as y,p as de,q as ue,r as me}from"./chunk-3SH3L3DB.js";import{U as pe,a as J,b as Z}from"./chunk-V27M5UQH.js";import{c as p,f as oe,g as re,i as se}from"./chunk-33EK522E.js";import{A as ee,E as te,eb as ne}from"./chunk-UCUESVFW.js";import{a as g,d as ce}from"./chunk-HIKZYZ26.js";import{$a as N,F as Y,J as T,Ob as H,Pb as Q,Qb as $,Rb as O,ea as S,g as G}from"./chunk-MK7UQEE5.js";import{A as w,a as W,e as B,f as U,g as V,i as X,z as b}from"./chunk-G6ERMFJ5.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]="d449d43b-5192-58dc-bdc0-0ec5e8922353")}catch{}})();var Ot=W,Et=B,It=X,xt=U,At=V;function fe(e,t,n,o){let r=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),s=n.has(r);return{long:t,...o?{short:o}:{},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:s?"string":"boolean",...s?{value_name:e.value_name??"value"}:{}}}function ye(e,t=[]){let n=new Set(t.flatMap(r=>r.keys)),o=[];for(let r of ee(e.map(s=>({...s})))){o.push(fe(r,r.flag,n,r.short));for(let s of r.aliases??[])o.push(fe(r,s,n))}return o}var Tt=ye(te,J),Nt=ye(ne,Z);(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"],C={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:E.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 E,i as f,j as ie,k as ae,l as le,o as y,p as de,q as ue,r as me}from
|
|
|
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 Ae(e){if(e===void 0)return;let t=m(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 Lt(e){let t=Ae(e);if(t===void 0)throw new Error(`Profile name is required. Allowed: ${_.join(", ")}.`);return C[t]}function Dt(){return _.map(e=>C[e])}function m(e){return e.trim().toLowerCase().replaceAll("-","_")}function he(e){return e.map(t=>t.definition.name).join(", ")}function Te(e=[]){let t=_.map(s=>({definition:C[s],source:"builtin"})),n=new Set(_.map(s=>m(s))),o=new Set(n),r=[];for(let s of e){let i=m(s.profile.name);if(n.has(i)){r.push(`Extension "${s.name}" profile "${s.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(o.has(i)){r.push(`Profile "${s.profile.name}" from extension "${s.name}" duplicates an already-registered profile and was ignored.`);continue}o.add(i),t.push({definition:s.profile,source:"extension",package:s.name})}return{profiles:t,warnings:r}}function Pt(e,t=[]){let{profiles:n,warnings:o}=Te(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${he(n)}.`);let r=m(e),s=n.find(i=>m(i.definition.name)===r);if(s===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${he(n)}.`);return{resolved:s,warnings: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]="ab26bcb3-fb2a-5f2f-96e7-7965787b924e")}catch{}})();function Ne(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 jt(e){return{name:e.name,title:e.title,summary:e.summary,composition:Ne(e),types:e.types.map(t=>L(()=>p(t).name,()=>String(t.name??""))),statuses:e.statuses.map(t=>L(()=>y(t).id,()=>String(t.id??""))),fields:e.fields.map(t=>L(()=>f(t).key,()=>String(t.key??""))),workflows:e.workflows.map(t=>t.type),config:e.config.map(t=>`${t.key}=${t.value}`),templates:e.templates.map(t=>t.name),packages:e.packages.map(t=>({spec:t.spec,reason:t.reason}))}}function L(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]="42c9df66-4303-5d06-b931-0a276894e5e5")}catch{}})();var $e=[{key:"context_default_depth",path:"context.default_depth",kind:"string",choices:Y,summary:"Default context depth."},{key:"context_activity_limit",path:"context.activity_limit",kind:"integer",min:1,max:Number.MAX_SAFE_INTEGER,decimal_only:!0,summary:"Default context activity row limit; positive decimal integer."},{key:"context_stale_threshold_days",path:"context.stale_threshold_days",kind:"integer",min:1,max:Number.MAX_SAFE_INTEGER,decimal_only:!0,summary:"Days before context marks an item stale; positive decimal integer."},...["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"].map(e=>({key:`context_sections_${e}`,path:`context.sections.${e}`,kind:"boolean",summary:`Include ${e} in default context output.`})),{key:"context_next_ranking_policy",path:"context.next_ranking_policy",kind:"string",choices:["priority_floor","weighted"],summary:"Ready-queue order for pm next with the built-in scorer: priority_floor (resume in-progress work, then priority tiers, relevance within a tier) or weighted (blended relevance order). An extension context_relevance scorer keeps its own order."},{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:"Wait budget in milliseconds before a contended lock fails with lock_conflict; item-store mutations, restore and the hierarchy lock treat it as a no-progress window that each observed owner handoff restarts (120 s total cap), other locks as a fixed total; 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)."}],Ce=new Map($e.flatMap(e=>[[e.key,e],[e.path.toLowerCase().replaceAll("-","_"),e]]));function I(e){if(typeof e!="string")return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length!==0)return Ce.get(t)}function Le(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 De(e,t,n){return e.key==="context_default_depth"&&(n=n.toLowerCase()),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 ge(e,t){let n=[e.min===void 0?"":`minimum ${e.min}`,e.max===void 0?"":`maximum ${e.max}`].filter(Boolean).join(", ");return{message:`Config set ${e.key} requires non-empty decimal integer digits${n?` (${n})`:""}, got "${t}"`}}function Pe(e,t,n){if(e.decimal_only&&!/^\d+$/u.test(n))return{ok:!1,error:ge(e,t)};if(n.length===0)return{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}};let o=Number(n);return Number.isFinite(o)?{ok:!0,value:o}:{ok:!1,error:e.decimal_only?ge(e,t):{message:`Config set ${e.key} requires a finite number, got "${t}"`}}}function Fe(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 Re(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 Me(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 x(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 Le(e,t);if(e.kind==="string")return De(e,t,n);let o=Pe(e,t,n);return o.ok?e.kind==="integer"?Fe(e,t,o.value):e.kind==="ratio"?Re(e,t,o.value):Me(e,t,o.value):{ok:!1,error:o.error}}function _e(e,t){let n=t.path.split("."),o=e;for(let r of n){if(typeof o!="object"||o===null)return null;let s=Object.getOwnPropertyDescriptor(o,r);if(!s||!Object.hasOwn(s,"value"))return null;o=s.value}return typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:null}function Wt(e,t,n){let o=t.path.split(".");if(o.some(i=>i.length===0||["__proto__","constructor","prototype"].includes(i)))throw new Error("Unsafe settings path");let r=e;for(let i=0;i<o.length-1;i+=1){let a=o[i],l=Object.getOwnPropertyDescriptor(r,a)?.value;if(typeof l!="object"||l===null||Array.isArray(l)){let c={};Object.defineProperty(r,a,{value:c,writable:!0,enumerable:!0,configurable:!0}),r=c}else r=l}let s=o[o.length-1];return Object.getOwnPropertyDescriptor(r,s)?.value===n?!1:(Object.defineProperty(r,s,{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 tn=["profile","types","statuses","fields","workflows","config","templates","packages"],nn=["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"],ze=new Set(ce.flatMap(e=>[g(e.id),...(e.aliases??[]).map(t=>g(t))]).filter(e=>e.length>0)),ke=new Set(G.map(e=>e.toLowerCase()));function je(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!==m(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 "${m(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 qe(e,t){let n=new Set,o=new Set;for(let[r,s]of e.types.entries()){let i;try{i=p(s).name}catch(l){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof s.name=="string"?s.name:`#${r}`,message:S(l)});continue}let a=i.toLowerCase();if(o.has(a)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:i,message:`Item type "${i}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}o.add(a),n.add(a)}return n}function Ke(e,t){let n=new Set,o=new Set;for(let[r,s]of e.statuses.entries()){let i;try{i=y(s)}catch(a){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof s.id=="string"?s.id:`#${r}`,message:S(a)});continue}if(o.has(i.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:i.id,message:`Status "${i.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}o.add(i.id),n.add(i.id);for(let a of i.aliases??[])n.add(g(a))}return n}function We(e,t){let n=new Set;for(let[o,r]of e.fields.entries()){let s;try{s=f(r).key}catch(a){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof r.key=="string"?r.key:`#${o}`,message:S(a)});continue}if(n.has(s)){t.push({severity:"error",code:"field_duplicate",dimension:"fields",target:s,message:`Field "${s}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}n.add(s);let i=pe(s);i&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:s,message:`Field "${s}" collides with canonical MCP property "${i.property}" owned by ${i.owner}; callers must pass the custom value through ${i.nested_path}.`})}}function Be(e,t,n,o){let r=new Set;for(let[s,i]of e.workflows.entries()){let a=i.type.trim().toLowerCase();if(a.length===0){o.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${s}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}let l=r.has(a);r.add(a),l?o.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:i.type,message:`Workflow type "${i.type}" is declared more than once; the later transition set wins.`}):!ke.has(a)&&!t.has(a)&&o.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:i.type,message:`Workflow governs type "${i.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});let c=new Set;for(let d of i.allowed_transitions){let u=g(d[0]),K=g(d[1]);if(u.length===0||K.length===0){o.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:i.type,message:`Workflow "${i.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(let h of[u,K])ze.has(h)||n.has(h)||c.has(h)||(c.add(h),o.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:h,message:`Workflow "${i.type}" references status "${h}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function Ue(e,t){let n=new Set;for(let o of e.config){let r=I(o.key);if(r===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:o.key,message:`Config knob "${o.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}n.has(r.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:r.key,message:`Config knob "${r.key}" is set more than once; the later value silently overwrites the earlier one.`}):n.add(r.key);let s=x(r,o.value);s.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:o.key,message:s.error.message})}}function Ve(e,t,n){for(let o of e.templates){let r=o.options.type;if(typeof r!="string"||r.trim().length===0)continue;let s=r.trim().toLowerCase();!ke.has(s)&&!t.has(s)&&n.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:o.name,message:`Template "${o.name}" creates type "${r}" which is neither a built-in type nor declared by this profile.`})}}function Xe(e,t){for(let[n,o]of e.packages.entries())o.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 on(e){let t=[];je(e,t);let n=qe(e,t),o=Ke(e,t);We(e,t),Be(e,n,o,t),Ue(e,t),Ve(e,n,t),Xe(e,t);let r=t.filter(i=>i.severity==="error").length,s=t.length-r;return{profile:e.name,ok:r===0,findings:t,errorCount:r,warningCount:s}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be2b507d-2797-570c-b211-46d950edcbde")}catch{}})();function D(e,t,n,o,r){let s=e,i=[];for(let a of t){let l=o(s),c=r(s,a),d=o(c.file);s=c.file;let u=l===d?"unchanged":c.replaced?"update":"add";i.push({key:n(a),status:u})}return{file:s,changes:i,changed:i.some(a=>a.status!=="unchanged")}}function be(e){return JSON.stringify(e.map(t=>t.join("\0")).sort())}function Ge(e,t){let n=e.map(r=>({...r})),o=[];for(let r of t){let s=n.findIndex(a=>a.type===r.type),i={type:r.type,allowed_transitions:r.allowed_transitions};s<0?(n.push(i),o.push({type:r.type,status:"add"})):be(n[s].allowed_transitions)===be(r.allowed_transitions)?o.push({type:r.type,status:"unchanged"}):(n[s]=i,o.push({type:r.type,status:"update"}))}return{changes:o,result:n,changed:o.some(r=>r.status!=="unchanged")}}function Ye(e,t){let n=[];for(let o of e.config){let r=I(o.key);if(r===void 0)throw new Error(`Profile "${e.name}" references unknown config key "${o.key}".`);let s=x(r,o.value);if(!s.ok)throw new Error(`Profile "${e.name}" config ${o.key}: ${s.error.message}`);let i=_e(t,r),a=i===null?"add":i===s.parsed.value?"unchanged":"update";n.push({key:r.key,path:r.path,value:s.parsed.value,status:a})}return{changes:n,changed:n.some(o=>o.status!=="unchanged")}}function we(e){let t=Object.entries(e).sort(([n],[o])=>n.localeCompare(o));return JSON.stringify(t)}function He(e,t){let n=[];for(let o of e.templates){let r=t.get(o.name),s;r===void 0?s="add":we(r)===we(o.options)?s="unchanged":s="update",n.push({name:o.name,options:o.options,status:s})}return{changes:n,changed:n.some(o=>o.status!=="unchanged")}}function dn(e,t){let n=D(oe(t.typesRaw),e.types,d=>p(d).name,se,(d,u)=>re(d,p(u))),o=D(de(t.statusesRaw),e.statuses,d=>y(d).id,ue,(d,u)=>me(d,y(u))),r=D(ie(t.fieldsRaw),e.fields,d=>f(d).key,ae,(d,u)=>le(d,f(u))),s=Ge(t.workflows,e.workflows),i=Ye(e,t.settings),a=He(e,t.templates),l=e.packages.map(d=>({spec:d.spec,reason:d.reason,status:t.installedPackages.has(d.spec)?"installed":"recommended"})),c=n.changed||o.changed||r.changed||s.changed||i.changed||a.changed;return{profile:{name:e.name,title:e.title,summary:e.summary},types:n,statuses:o,fields:r,workflows:s,config:i,templates:a,packages:l,changed:c}}import{isDeepStrictEqual as Qe}from"node:util";(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]="90fdc6f3-29d4-5266-a142-d9d14fbb12e7")}catch{}})();var Je=new Set(["__proto__","prototype","constructor"]),R=Symbol("looseOptionOccurrences");function A(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,n)=>n.toUpperCase())}function P(e){return Je.has(e)}function Se(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return H(t)}function Oe(e){let t=[],n=T(e.long)??"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let r=A(n.slice(2));r.length>0&&!P(r)&&t.push(r)}if(o.startsWith("-")&&!o.startsWith("--")){let r=A(o.slice(1));r.length>0&&!P(r)&&t.push(r)}return[...new Set(t)]}function v(e){let t=T(e.long)??"";if(t.startsWith("--")){let n=A(t.slice(2));if(n.length>0&&!P(n))return n}return Oe(e)[0]??null}function M(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function Ze(e){return typeof e=="string"||e==null?e:String(e)}function et(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function Ee(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var tt={string:Ze,number:et,boolean:Ee};function k(e,t){return Array.isArray(e)?e.map(n=>k(n,t)):tt[t](e)}function Ie(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(r=>r!=null&&r!==""):$(e);return t?o.map(r=>k(r,t)):o}function nt(e,t,n,o){return n?Ie(e,t,o):t?k(e,t):e}function ot(e,t,n){let o=e[R];if(!o||o.length===0)return n;let r=new Set(t);return o.filter(s=>r.has(s.key)).map(s=>s.value)}function xe(e){return Q(e).value_arity==="none"}function z(e,t,n,o,r){let s=M(e),i=r?` for extension command '${r}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new w(`Option '${s}'${i} expects ${o}; received ${a}.`,b.USAGE,{code:"extension_flag_value_invalid",required:`Pass ${s} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${s}.`,`Run pm ${r??"<command>"} --help to review the declared flag contract.`]})}function j(e,t){return e.value_validation==="strict"&&t!=="string"}function rt(e,t){let n=e[R];if(!n)return[];let o=new Set(t);return n.filter(r=>o.has(r.key))}function st(e,t,n,o){if(xe(e))for(let r of rt(n,t)){if(r.attached!==!0)continue;let s=e.list===!0&&e.repeatable!==!0?$(r.value):[r.value];for(let i of s){let a=O(k(i,"boolean"),"boolean");a!==null&&z(e,"boolean",i,a.expected,o)}}}function it(e,t,n,o,r){let s=Array.isArray(n)?n.flat(1/0):[n],i=o?s:s.flatMap(a=>typeof a=="string"?a.split(","):[a]);for(let a of i)if(typeof a=="string"&&a.trim().length===0){let l=O(a,t);z(e,t,a,l.expected,r)}}function q(e,t,n,o){if(!j(e,n))return t;let r=n==="boolean"&&xe(e),s=i=>{let a=O(i,n);return a===null?i:r&&typeof i=="string"?!0:z(e,n,i,a.expected,o)};return Array.isArray(t)?t.map(s):s(t)}function at(e,t,n,o){for(let r of n)if(!(r===t||!Object.hasOwn(e,r))){if(Object.hasOwn(e,t)){if(o){let s=e[t],i=e[r];e[t]=[...Array.isArray(s)?s:[s],...Array.isArray(i)?i:[i]].filter(a=>a!=null)}delete e[r];continue}e[t]=e[r],delete e[r]}}function lt(e,t,n=e,o){if(t.length===0)return e;let r=Object.create(null);for(let[i,a]of Object.entries(e))r[i]=a;let s=new Set(t.map(i=>v(i)).filter(i=>i!==null));for(let i of t){let a=v(i);if(a){let l=Oe(i).filter(c=>c===a||!s.has(c));ct(r,i,a,l,n,o)}}return r}function ct(e,t,n,o,r,s){let i=t.list===!0,a=Se(t);a&&!i&&dt(e,t,n,o,a,s),at(e,n,o,i);let l=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=nt(t.default,a,i,l));return}if(a==="boolean"&&j(t,a)&&st(t,o,r,s),i){e[n]=ut(t,o,r,e[n],a,l,s);return}a&&(e[n]=q(t,k(e[n],a),a,s))}function dt(e,t,n,o,r,s){for(let i of o)i!==n&&Object.hasOwn(e,i)&&q(t,k(e[i],r),r,s)}function ut(e,t,n,o,r,s,i){let a=ot(n,t,o);r&&j(e,r)&&it(e,r,a,s,i);let l=Ie(a,r,s);return r?q(e,l,r,i):l}function yn(e){return v(e)}function ve(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function hn(e,t){let n=ve(t);if(n.length===0)return[];let o=N(n);return e.flags.filter(r=>N(ve(r.target_command))===o).flatMap(r=>[...r.flags])}function mt(e,t,n,o){let r=M(e),[s,i]=n;throw new w(`Options '${s}' and '${i}' both set ${r} for extension command '${o}' with different values.`,b.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${r} once, under the handler key '${t}'.`,why:`'${s}' and '${i}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${i}' and pass one value as '${t}'.`,`Run pm contracts --command ${o} --flags-only --json to read each flag's sdk_option key.`]})}function gn(e,t,n){if(t.length===0)return e;let o=yt(t),r=gt(e,o,n),s=new Set([...o.long.values()].map(({handlerKey:l})=>l)),i=Object.create(null),a=Object.create(null);for(let[l,c]of Object.entries(r))(s.has(l)?i:a)[l]=c;return ft(i,t,n),Object.assign(a,lt(i,t,pt(i,o),n))}function pt(e,t){let n=new Set([...t.long.values()].map(({handlerKey:s})=>s)),o=Object.entries(e).filter(([s])=>n.has(s)).flatMap(([s,i])=>(Array.isArray(i)?i.flat(1/0):[i]).map(a=>({consumed:1,key:s,value:a,attached:!0}))),r=Object.create(null);return Object.defineProperty(r,R,{value:o}),r}function ft(e,t,n){for(let o of t){let r=v(o);if(r===null)continue;let s=M(o),i=Object.hasOwn(e,r);if(o.enabled===!1&&i)throw new w(`Option '${s}' is disabled for extension command '${n}'.`,b.USAGE);if(o.required===!0&&o.enabled!==!1&&!i)throw new w(`Missing required option '${s}' for extension command '${n}'.`,b.USAGE)}}function yt(e){let t={long:new Map,short:new Map},n=(o,r,s)=>{r.length>0&&!o.has(r)&&o.set(r,s)};for(let o of e){let r=v(o);if(r===null)continue;let s={handlerKey:r,definition:o};n(t.long,r,s);let i=typeof o.short=="string"?o.short.trim():"";i.startsWith("-")&&!i.startsWith("--")&&n(t.short,i.slice(1),s)}return t}function F(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(A(t.replace(/^-{1,2}/u,"")))}function ht(e,t,n){let o=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(o===void 0||F(e,t)!==void 0)return{spelling:t,value:n};let r=F(e,o),s=Ee(n);return r!==void 0&&Se(r.definition)==="boolean"&&typeof s=="boolean"?{spelling:o,value:!s}:{spelling:t,value:n}}function gt(e,t,n){let o=Object.create(null),r=new Map;for(let[s,i]of Object.entries(e)){let{spelling:a,value:l}=ht(t,s,i),c=F(t,a);if(c===void 0)o[a]=l;else if(l!==void 0){let d=r.get(c.handlerKey);d===void 0?(r.set(c.handlerKey,a),o[c.handlerKey]=l):Qe(o[c.handlerKey],l)||mt(c.definition,c.handlerKey,[d,a],n)}}return o}export{Ot as a,Et as b,It as c,xt as d,At as e,ye as f,Tt as g,Nt as h,_ as i,C as j,Ae as k,Lt as l,Dt as m,Te as n,Pt as o,Ne as p,jt as q,$e as r,I as s,x as t,_e as u,Wt as v,tn as w,nn as x,on as y,dn as z,yn as A,hn as B,gn as C};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-VVGXPF4W.js.map
|
package/dist/cli-bundle/focused-chunks/{item-revision-XC4ZJ7MY.js → item-revision-B3BIG66B.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=item-revision-
|
|
1
|
+
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-M5FZTPFA.js";import"./chunk-NP5C2TQM.js";import"./chunk-33EK522E.js";import"./chunk-3FN4ON2Z.js";import"./chunk-GHQVM6K6.js";import{A as c,B as d,y as a,z as b}from"./chunk-NY65XTX7.js";import"./chunk-HIKZYZ26.js";import"./chunk-C3O6JJPO.js";import"./chunk-MK7UQEE5.js";import"./chunk-G6ERMFJ5.js";export{f as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,e as ITEM_REVISION_CONFLICT_CODE,w as assertExpectHashAdmissible,t as bindExpectedItemRevisions,c as bindItemRevisionScope,a as createItemRevisionScope,k as describeItemRevisionChanges,y as dispatchWithExpectedItemRevisions,q as enrichItemRevisionConflict,o as expectHashInvocationRewrittenError,x as expectHashRequiresMutationError,m as isItemRevisionConflict,u as isTrackerRevisionGuarded,l as itemRevisionConflictRowFields,d as itemRevisionScopeReceipt,v as itemRevisionUncheckedWarning,g as normalizeExpectedItemHash,h as parseExpectHashSpecs,i as readItemRevision,j as resolveExpectedItemRevisions,r as runWithBoundItemRevisionScope,b as runWithItemRevisionScope,p as scopeItemRevisionConflict,n as throwFirstItemRevisionConflict,s as withExpectedItemRevisions};
|
|
2
|
+
//# sourceMappingURL=item-revision-B3BIG66B.js.map
|
package/dist/cli-bundle/focused-chunks/{item-transaction-CVGK4RJP.js → item-transaction-4JDWOXNB.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as ke,C as Me,E as W,H as Re,J as Ie,K as Ce,M as Ne,a as Oe,p as J}from"./chunk-QK7FX4O5.js";import"./chunk-3K2MYE7R.js";import"./chunk-UIZVD36C.js";import{A as Ae,B as L,C as Te,y as k,z as K}from"./chunk-BE2GK2G7.js";import"./chunk-U7HWWEJ2.js";import"./chunk-HTMQDNVC.js";import"./chunk-IDAYTYNN.js";import"./chunk-WK773UVA.js";import"./chunk-3DWNH72D.js";import"./chunk-SVOOGGAK.js";import"./chunk-ALLOWZSH.js";import{N as we,Q as ge}from"./chunk-NZQYHPUN.js";import"./chunk-67M7E2Z3.js";import"./chunk-QHGGO7SY.js";import{Ea as $e}from"./chunk-QCHCEFTO.js";import"./chunk-2Y4H4LIX.js";import"./chunk-LY3JXL25.js";import{G as x}from"./chunk-56MIAFEN.js";import{qa as pe,wa as le}from"./chunk-LWMPQRJT.js";import"./chunk-RFMKS7VD.js";import"./chunk-PAGW6A2X.js";import"./chunk-GHQVM6K6.js";import{aa as Ee,l as q,x as $}from"./chunk-WJHDUON5.js";import{Ia as T,Ma as G,Y as ve,c as me,e as F,f as fe,i as he,lb as _e,pb as Se,vb as be,xa as S}from"./chunk-ZBOCYFBE.js";import"./chunk-I5LGPUWH.js";import"./chunk-C3O6JJPO.js";import{Ga as ue,pc as ye,qc as P,ra as D,ya as de}from"./chunk-2SQUWQP3.js";import"./chunk-EGN2HFRU.js";import"./chunk-FOA7XKWP.js";import{A as l,E as j,G as ce,H as O,l as oe,q as E,s as ae,x as se,z as m}from"./chunk-G6ERMFJ5.js";import X from"node:crypto";import{constants as V}from"node:fs";import{cp as nt,lstat as Fe,mkdir as rt,mkdtemp as Pe,open as it,readdir as ot,realpath as xe,rm as Ge,stat as Z,writeFile as qe}from"node:fs/promises";import{tmpdir as Ke}from"node:os";import d 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]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var He=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...oe,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);(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]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function z(e,t,r){let n=e?.estimatedMinutes;if(!(n===void 0||typeof n=="string"))throw new l(`Mutation ${r+1} ${t} option "estimatedMinutes" must be a string.`,m.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(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]="a17df3f5-aee8-5734-b1ce-b643482be3a7")}catch{}})();var Xe=["op","id","reason","options","unique","match"],Ze=[...Xe,"ref"],en=[...Ze,"item"];var je="[a-z][a-z0-9._-]{0,63}",tn=new RegExp(`^${je}$`,"u"),nn=new RegExp(`(^|,)id=@(${je})(?=,|$)`,"gu"),Ue=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,r)=>r.toUpperCase());var Qe=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count"]),rn=new Set([...Qe,"completed_at","id"]),on={create:we.map(e=>e.target),update:ge.map(e=>e.target),close:pe.map(e=>Ue(e.flag)).filter(e=>e!=="reason"),release:le.map(e=>Ue(e.flag))};function et(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function tt(e,t){return e<t?-1:+(e!==t)}function B(e){return Array.isArray(e)?e.map(B):et(e)?Object.fromEntries(Object.entries(e).sort(([t],[r])=>tt(t,r)).map(([t,r])=>[t,B(r)])):e}function v(e){return typeof e=="string"?e.trim():JSON.stringify(B(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]="49806fc6-ff49-5b67-9b3f-c182ace00c20")}catch{}})();async function at(e,t){if(!Se(e))return{schema:F(t.schema),typeDefinitionsFromFile:[]};let r=await gt(e,t.schema);return{schema:r.schema,typeDefinitionsFromFile:r.type_definitions_from_file??[]}}async function st(e,t,r,n){let i=D({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...r.typeDefinitionsFromFile]}},P());return(await Ee(e,t.item_format,i.type_to_folder,void 0,r.schema)).flatMap(a=>{let o=a[n];return o==null?[]:[{id:a.id,value:o}]})}function Q(e){let t=new Map,r=async n=>{let i=await be(e),a=await at(e,i),o=new Map;for(let s of await st(e,i,a,n)){let c=v(s.value);o.set(c,[...o.get(c)??[],s.id])}return o};return{lookup(n){let i=t.get(n)??r(n);return t.set(n,i),i},async recordCreate(n){for(let[i,a]of t){let o=n[i];if(o==null)continue;let s=await a,c=v(o);s.set(c,[...s.get(c)??[],String(n.id)])}},invalidate(){t.clear()}}}async function ct(e,t){let r=v(t.value),n=(await e.lookup(t.key)).get(r)??[];if(n.length!==0)throw new l(`Upsert key "${t.key}" value ${JSON.stringify(r)} now matches existing item ${n.join(", ")}; the plan was resolved before it existed.`,m.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function dt(e,t,r){let n=e.metadata[r.key],i=v(r.value);if(v(n)!==i)throw new l(`Item ${t} no longer carries upsert key "${r.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,m.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function De(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function C(e,t){let r={...e,...t};return e===void 0?r:x(e,r)}async function g(e,t){try{let r=(await J(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(r){if(r instanceof l&&r.exitCode===m.NOT_FOUND)return;throw r}}function ee(e,t){let r=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),n=X.createHash("sha256").update(ue(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${r}-${n}`}function ut(e,t){let r=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${r}`}function h(e,t,r){return`bulk-item-transaction ${e} ${t} ${r}`}async function A(e,t,r,n){let i=await S(d.join(e,"history",`${t}.jsonl`),t),a=h(r,n,"apply"),o=h(r,n,"compensate");for(let s=i.length-1;s>=0;s-=1){let c=i[s].message;if(c===a)return!0;if(c===o)return!1}return!1}async function te(e,t){let r=await g(e,t.id);if(r?.updatedAt===void 0)throw new l(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,m.NOT_FOUND);let n=await S(d.join(e,"history",`${r.id}.jsonl`),r.id);if(n.length===0)throw new l(`Bulk ${t.op} target ${t.id} has no restorable history`,m.NOT_FOUND);return{target_updated_at:r.updatedAt,target_version:String(q(n)+n.length),target_history_hash:T(n),target_history_length:n.length}}function b(e,t,r){return new l(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${r}; review item ${t} history before recovery.`,m.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function Le(e,t){let r=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(n=>typeof n=="string"&&n.startsWith(r))}function pt(e,t,r){let{expectedHistory:n,length:i,version:a}=t;if(T(e)===n)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||T(e.slice(0,i))!==n||a!==String(q(e)+i))throw b(r,r.itemId,r.stepId);let o=h(r.transactionId,r.stepId,"apply"),s=e.slice(i),c=p=>p.message===o||p.context?.item_transaction_step===o,u=h(r.transactionId,r.stepId,"compensate");if(s.filter(p=>c(p)||p.message===u).at(-1)?.message===u)return!1;let f=s.filter(c);if(f.length===0)return!1;let _=e.at(-1).after_hash===f.at(-1).after_hash&&s.every(p=>Le(p,r.transactionId));if(f.length!==s.length&&!_)throw b(r,r.itemId,r.stepId);return!0}async function N(e,t,r,n){let i=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let a=i.target_updated_at,o=await g(e.pmRoot,t);if(o===void 0)return;let s=await S(d.join(e.pmRoot,"history",`${o.id}.jsonl`),o.id),c=i.target_history_hash;if(typeof c=="string"){if(!pt(s,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:o.id,stepId:r}))return}else{if(o.updatedAt===a)return;if(!await A(e.pmRoot,o.id,e.transactionId,r))throw b(e,o.id,r)}let u=()=>Ce(t,typeof i.target_version=="string"?i.target_version:a,{force:!0,author:e.author,message:h(e.transactionId,r,"compensate")},{pmRoot:e.pmRoot});await $({pmRoot:e.pmRoot,id:o.id,validate:f=>{if(G(f)!==s.at(-1).after_hash)throw b(e,o.id,r)}},u)}function Je(e,t,r){return{id:r,async inspect(){let n=await g(e.pmRoot,t.id);if(n===void 0)return{state:"pending"};if(n.closedAt!==void 0){let i=await S(d.join(e.pmRoot,"history",`${n.id}.jsonl`),n.id),a=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(o=>o.op==="close").at(-1)?.patch.some(o=>o.op==="add"||o.op==="replace"?o.path==="/metadata/close_reason"&&o.value===a:!1)??!1)throw new l(`Created item ${n.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,m.CONFLICT,{code:"transaction_create_compensated",item_id:n.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${n.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:n.id,op:"create"}}},async apply(){t.unique!==void 0&&await ct(e.uniqueIndex,t.unique);let n=await ke(C(t.options,{author:e.author,id:t.id,message:h(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot}),i=n.item;return e.onCreateWarnings?.(String(i.id),n.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await lt(e,t.id,r)}}}async function lt(e,t,r){let n=await g(e.pmRoot,t);if(n===void 0||e.createCompensation==="close"&&n.closedAt!==void 0)return;let i=await S(d.join(e.pmRoot,"history",`${n.id}.jsonl`),n.id),a=h(e.transactionId,r,"apply"),o=h(e.transactionId,r,"compensate"),s=i.filter(c=>c.message===a||c.message===o).at(-1);if(s?.message!==o){if(s===void 0||!i.every(c=>Le(c,e.transactionId)))throw b(e,n.id,r);await $({pmRoot:e.pmRoot,id:n.id,validate:c=>{if(G(c)!==i.at(-1).after_hash)throw b(e,n.id,r)}},async()=>{let c={force:!0,author:e.author,message:o};e.createCompensation==="delete"?await Ie(t,c,{pmRoot:e.pmRoot}):await W(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,c,{pmRoot:e.pmRoot})})}}function mt(e,t,r){return{id:r,compensatePending:!0,async inspect(){let n=await g(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await A(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return te(e.pmRoot,t)},async apply(){let n=()=>Me(t.id,C(t.options,{author:e.author,message:h(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot}),i=t.match,a=i,o=(await $({pmRoot:e.pmRoot,id:String((await J(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:s=>{a!==void 0&&dt(s,t.id,a)},committed:s=>{i!==void 0&&(a={key:i.key,value:structuredClone(s.metadata[i.key])})},historyContext:{item_transaction_step:h(e.transactionId,r,"apply")}},n)).item;return e.uniqueIndex.invalidate(),{id:String(o.id),op:"update"}},async compensate(n){await N(e,t.id,r,n)}}}function ft(e,t,r){return{id:r,async inspect(){let n=await g(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await A(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"close"}}:n.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:n.id,op:"close"}}},async prepareCompensation(){return te(e.pmRoot,t)},async apply(){let n=(await W(t.id,t.reason,C(t.options,{author:e.author,message:h(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(n.id),op:"close"}},async compensate(n){await N(e,t.id,r,n)}}}function ht(e,t,r){return{id:r,async inspect(){let n=await g(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await A(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"release"}}:n.assignee!==void 0||n.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:n.id,op:"release"}}},async prepareCompensation(){return te(e.pmRoot,t)},async apply(){let n=(await Re(t.id,C(t.options,{author:e.author,message:h(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(n.id),op:"release"}},async compensate(n){await N(e,t.id,r,n)}}}function ne(e,t,r){let n=ee(t,r);switch(t.op){case"create":return Je(e,t,n);case"update":return mt(e,t,n);case"close":return ft(e,t,n);case"release":return ht(e,t,n)}}function yt(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`);if(e.op==="create"&&e.unique!==void 0&&!De(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!De(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);z(e.options,e.op,t)}function We(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[r,n]of e.entries()){if(yt(n,r),n.op!=="create"||n.unique===void 0)continue;let{key:i,value:a}=n.unique,o=t.get(i)??new Map,s=v(a),c=o.get(s);if(c!==void 0)throw new l(`Bulk create mutations ${c+1} and ${r+1} share the upsert key value ${JSON.stringify(s)} for "${i}".`,m.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});o.set(s,r),t.set(i,o)}}function ze(e){let t=[...e];return We(t),t.map(r=>{let n=structuredClone(r);return r.options!==void 0&&n.options!==void 0&&x(r.options,n.options),n})}function Be(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([r,n])=>{let i=`${t}/${r.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(r)?[i]:Be(n,i)})}async function Y(e,t,r){try{return await r()}catch(n){throw n instanceof l?new l(n.message,n.exitCode,{...n.context,transaction_operation:{index:t,op:e.op,id:e.id}}):n}}function Ve(e,t,r,n){let i=d.relative(e,t),a=i.split(d.sep);return a[0]==="extensions"&&a[2]==="node_modules"&&!n.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`))?!1:["locks","runtime","search"].includes(i.split(d.sep)[0])?n.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`)):i===""||r===void 0||r.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`))}async function R(e,t){let r=await Fe(t);if(r.isSymbolicLink())await Z(t);else if(r.isDirectory()||r.isFile())return r;throw O(d.relative(e,t))}async function wt(e,t){let r=await it(t,V.O_RDONLY|V.O_NOFOLLOW|V.O_NONBLOCK);try{let n=await r.stat();if(!n.isFile())throw O(d.relative(e,t));let i=X.createHash("sha256");if(n.size>0)for await(let a of r.createReadStream({highWaterMark:64*1024,end:n.size-1,autoClose:!1}))i.update(a);return i.digest()}finally{await r.close()}}async function H(e,t,r){let n=X.createHash("sha256");async function i(a){for(let o of(await ot(a)).sort()){let s=d.join(a,o);Ve(e,s,t,r)&&((await R(e,s)).isDirectory()?await i(s):(n.update(JSON.stringify(d.relative(e,s))),n.update(await wt(e,s))))}}return await i(e),n.digest("hex")}function M(){return new l("Tracker changed while preparing the transaction preview; retry against stable state.",m.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function re(e){if(!j(e))return!1;let t=e.path;if(typeof t!="string")return!1;let r=d.resolve(t),n=r;for(;;)try{let i=await Fe(n);return n!==r&&i.isDirectory()}catch(i){if(!j(i))return!1;let a=d.dirname(n);if(a===n)return!1;n=a}}async function I(e,t){let r=d.join(e,t);try{let n=e;for(let i of t.split(d.sep).slice(0,-1))n=d.join(n,i),await R(e,n);if(!(await R(e,r)).isFile())throw O(t);return await ce(r,O(t))}catch(n){if(await re(n))return;throw n}}async function Ye(e,t,r,n){let i=F(r);for(let[a,o]of Object.entries(i.files)){let s=d.relative(e,fe(e,o,me[a]));if(s===""||!d.resolve(e,s).startsWith(d.join(e,d.sep)))throw new l("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",m.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${a}`});i.files[a]=s;let c=await I(e,s);if(n?.set(s,c),c!==void 0){let u=d.join(t,s);await rt(d.dirname(u),{recursive:!0}),await qe(u,c)}}return he(t,i)}async function gt(e,t){await Z(e);let r=await Pe(d.join(Ke(),"pm-schema-plan-"));try{let n=await xe(e);return await Ye(n,d.join(r,"configuration"),t)}catch(n){throw await re(n)?M():n}finally{await Ge(r,{recursive:!0,force:!0})}}async function vt(e,t,r){let n=new Map,i=await I(e,E);n.set(E,i);let a;try{a=JSON.parse(i??"null")}catch{a=null}let o=_e(a),s=o.success?o.data:void 0,c=await Ye(e,t,s?.schema,n),u=c.schema,f=d.relative(e,ve(e));n.set(f,await I(e,f));let _=D({...se,item_types:{definitions:[...s?.item_types?.definitions??[],...c.type_definitions_from_file??[]]}},r),p=de(e)===e?[...ae.filter(Boolean),E,Oe,"transactions",..._.folders,...n.keys()].map(w=>d.normalize(w)):void 0,y=s===void 0?void 0:JSON.stringify({...a,schema:{...s.schema,files:u.files}});return{configuration:n,ownedPaths:p,stagedSettings:y,registryFolders:_.folders}}async function _t(e,t,r){await Z(e);try{let n=await xe(e),i=await vt(n,d.join(d.dirname(t),"configuration"),r),a=[...i.configuration.keys(),...i.registryFolders].map(u=>d.normalize(u)),o=await H(n,i.ownedPaths,a);await nt(n,t,{recursive:!0,dereference:!1,filter:async u=>Ve(n,u,i.ownedPaths,a)?(await R(n,u),!0):!1});let[s,c]=await Promise.all([H(n,i.ownedPaths,a),H(t,i.ownedPaths,a)]);if(o!==s||o!==c)throw M();for(let[u,f]of i.configuration)if(await I(t,u)!==f)throw M();i.stagedSettings!==void 0&&await qe(d.join(t,E),i.stagedSettings)}catch(n){throw await re(n)?M():n}}async function jn(e){let t=k(e),r=ze(e.mutations),n=P(),i=await Pe(d.join(Ke(),"pm-transaction-preview-")),a=d.join(i,"tracker");try{await _t(t.pmRoot,a,n);let o=!1,s=[],c=[],u=new Set;return await Ne({path:a,noExtensions:!0},async()=>{ye(n);let f={...t,pmRoot:a,createCompensation:"close",uniqueIndex:Q(a)},_=r.map((p,y)=>{let w=ne({...f,onCreateWarnings:(U,ie)=>{ie.length>0&&s.push({index:y,id:U,op:"create",warnings:ie})}},p,y);return{...w,inspect:()=>Y(p,y,()=>w.inspect()),prepareCompensation:()=>Y(p,y,async()=>w.prepareCompensation?.()),apply:()=>Y(p,y,async()=>{let U=await w.apply();return u.add(y),U})}});if(await K({...t,pmRoot:a,steps:_,onTransition:({transition:p})=>{p==="committed"&&(o=!0)}}),o)for(let[p,y]of r.entries()){let w=(await $e(y.id,{path:a},{full:!0})).item;c.push({index:p,id:String(w.id),op:y.op,execution:u.has(p)?"applied":"adopted",item:w,commit_time_fields:Be(w)})}}),{records:c,validated:o,state:o?"staged_snapshot":"replayed_committed_plan",warnings:s,unresolved_commit_constraints:["concurrent_tracker_changes","extension_mutation_guards_and_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await Ge(i,{recursive:!0,force:!0})}}async function St(e){let t=k(e),r=ze(e.mutations),n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:n,uniqueIndex:Q(t.pmRoot)},a=await K({...t,steps:r.map((s,c)=>ne(i,s,c)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:r,createCompensation:n})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),o={};for(let[s,c]of r.entries()){let u=ee(c,s),f=a.results[u];o[ut(c,s)]=f}return{transactionId:a.transactionId,status:"committed",recovered:a.recovered,results:o}}function bt(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function Dn(e){return St({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:bt(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Fn={buildCreateStep:Je,bulkHistoryMarker:h,compensateByRestore:N,deriveStepId:ee,isUpdateMarkerApplied:A,readItemSnapshot:g};async function Pn(e,t){let r=await Ae(e,t);return r===void 0?void 0:{journal:r,planDigest:L(r)}}function Et(e,t){let r=t.recoveryData;if(r===null||typeof r!="object"||Array.isArray(r)||r.kind!=="item-mutations-v1"||!Array.isArray(r.mutations)||!["close","delete"].includes(String(r.createCompensation)))throw new l("Transaction has no supported item recovery plan",m.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let n=r.mutations;We(n);let i={...e,createCompensation:r.createCompensation,uniqueIndex:Q(e.pmRoot)};return n.map((a,o)=>ne(i,a,o))}async function xn(e){let t=k(e),r=await Te({...e,...t,resolveSteps:n=>Et({...e,...t},n)});return{journal:r,planDigest:L(r)}}export{Fn as _testOnlyItemTransaction,xn as abandonItemTransaction,bt as buildItemCompletionMutations,Dn as commitItemCompletion,St as commitItemMutations,st as listUpsertKeyCandidates,gt as loadGuardedRuntimeSchema,jn as previewItemMutations,Pn as readItemTransaction,at as resolveTransactionSchema};
|
|
2
|
-
//# sourceMappingURL=item-transaction-
|
|
1
|
+
import{B as ke,C as Me,E as W,H as Re,J as Ie,K as Ce,M as Ne,a as Oe,p as J}from"./chunk-6TJXTKZD.js";import"./chunk-VVGXPF4W.js";import"./chunk-DW5S67LO.js";import{A as Ae,B as L,C as Te,y as k,z as K}from"./chunk-3A6XMQZJ.js";import"./chunk-M5FZTPFA.js";import"./chunk-GBW2EAAG.js";import"./chunk-IDAYTYNN.js";import"./chunk-2ZS3I5ZP.js";import"./chunk-3SH3L3DB.js";import"./chunk-SVOOGGAK.js";import"./chunk-6ICHSVEY.js";import{N as we,Q as ge}from"./chunk-V27M5UQH.js";import"./chunk-P6KYUJD4.js";import"./chunk-AXPRCCYM.js";import{Ea as $e}from"./chunk-JYWVRXLD.js";import"./chunk-NMU3QFAU.js";import"./chunk-NP5C2TQM.js";import{G as x}from"./chunk-33EK522E.js";import{qa as pe,wa as le}from"./chunk-UCUESVFW.js";import"./chunk-NSOXVVQX.js";import"./chunk-3FN4ON2Z.js";import"./chunk-GHQVM6K6.js";import{aa as Ee,l as q,x as $}from"./chunk-NY65XTX7.js";import{Ia as T,Ma as G,Y as ve,c as me,e as F,f as fe,i as he,lb as _e,pb as Se,vb as be,xa as S}from"./chunk-HIKZYZ26.js";import"./chunk-I5LGPUWH.js";import"./chunk-C3O6JJPO.js";import{Ga as ue,pc as ye,qc as P,ra as D,ya as de}from"./chunk-MK7UQEE5.js";import"./chunk-EGN2HFRU.js";import"./chunk-FOA7XKWP.js";import{A as l,E as j,G as ce,H as O,l as oe,q as E,s as ae,x as se,z as m}from"./chunk-G6ERMFJ5.js";import X from"node:crypto";import{constants as V}from"node:fs";import{cp as nt,lstat as Fe,mkdir as rt,mkdtemp as Pe,open as it,readdir as ot,realpath as xe,rm as Ge,stat as Z,writeFile as qe}from"node:fs/promises";import{tmpdir as Ke}from"node:os";import d 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]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var He=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...oe,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);(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]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function z(e,t,r){let n=e?.estimatedMinutes;if(!(n===void 0||typeof n=="string"))throw new l(`Mutation ${r+1} ${t} option "estimatedMinutes" must be a string.`,m.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(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]="a17df3f5-aee8-5734-b1ce-b643482be3a7")}catch{}})();var Xe=["op","id","reason","options","unique","match"],Ze=[...Xe,"ref"],en=[...Ze,"item"];var je="[a-z][a-z0-9._-]{0,63}",tn=new RegExp(`^${je}$`,"u"),nn=new RegExp(`(^|,)id=@(${je})(?=,|$)`,"gu"),Ue=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,r)=>r.toUpperCase());var Qe=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count"]),rn=new Set([...Qe,"completed_at","id"]),on={create:we.map(e=>e.target),update:ge.map(e=>e.target),close:pe.map(e=>Ue(e.flag)).filter(e=>e!=="reason"),release:le.map(e=>Ue(e.flag))};function et(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function tt(e,t){return e<t?-1:+(e!==t)}function B(e){return Array.isArray(e)?e.map(B):et(e)?Object.fromEntries(Object.entries(e).sort(([t],[r])=>tt(t,r)).map(([t,r])=>[t,B(r)])):e}function v(e){return typeof e=="string"?e.trim():JSON.stringify(B(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]="49806fc6-ff49-5b67-9b3f-c182ace00c20")}catch{}})();async function at(e,t){if(!Se(e))return{schema:F(t.schema),typeDefinitionsFromFile:[]};let r=await gt(e,t.schema);return{schema:r.schema,typeDefinitionsFromFile:r.type_definitions_from_file??[]}}async function st(e,t,r,n){let i=D({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...r.typeDefinitionsFromFile]}},P());return(await Ee(e,t.item_format,i.type_to_folder,void 0,r.schema)).flatMap(a=>{let o=a[n];return o==null?[]:[{id:a.id,value:o}]})}function Q(e){let t=new Map,r=async n=>{let i=await be(e),a=await at(e,i),o=new Map;for(let s of await st(e,i,a,n)){let c=v(s.value);o.set(c,[...o.get(c)??[],s.id])}return o};return{lookup(n){let i=t.get(n)??r(n);return t.set(n,i),i},async recordCreate(n){for(let[i,a]of t){let o=n[i];if(o==null)continue;let s=await a,c=v(o);s.set(c,[...s.get(c)??[],String(n.id)])}},invalidate(){t.clear()}}}async function ct(e,t){let r=v(t.value),n=(await e.lookup(t.key)).get(r)??[];if(n.length!==0)throw new l(`Upsert key "${t.key}" value ${JSON.stringify(r)} now matches existing item ${n.join(", ")}; the plan was resolved before it existed.`,m.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function dt(e,t,r){let n=e.metadata[r.key],i=v(r.value);if(v(n)!==i)throw new l(`Item ${t} no longer carries upsert key "${r.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,m.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function De(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function C(e,t){let r={...e,...t};return e===void 0?r:x(e,r)}async function g(e,t){try{let r=(await J(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(r){if(r instanceof l&&r.exitCode===m.NOT_FOUND)return;throw r}}function ee(e,t){let r=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),n=X.createHash("sha256").update(ue(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${r}-${n}`}function ut(e,t){let r=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${r}`}function h(e,t,r){return`bulk-item-transaction ${e} ${t} ${r}`}async function A(e,t,r,n){let i=await S(d.join(e,"history",`${t}.jsonl`),t),a=h(r,n,"apply"),o=h(r,n,"compensate");for(let s=i.length-1;s>=0;s-=1){let c=i[s].message;if(c===a)return!0;if(c===o)return!1}return!1}async function te(e,t){let r=await g(e,t.id);if(r?.updatedAt===void 0)throw new l(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,m.NOT_FOUND);let n=await S(d.join(e,"history",`${r.id}.jsonl`),r.id);if(n.length===0)throw new l(`Bulk ${t.op} target ${t.id} has no restorable history`,m.NOT_FOUND);return{target_updated_at:r.updatedAt,target_version:String(q(n)+n.length),target_history_hash:T(n),target_history_length:n.length}}function b(e,t,r){return new l(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${r}; review item ${t} history before recovery.`,m.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function Le(e,t){let r=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(n=>typeof n=="string"&&n.startsWith(r))}function pt(e,t,r){let{expectedHistory:n,length:i,version:a}=t;if(T(e)===n)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||T(e.slice(0,i))!==n||a!==String(q(e)+i))throw b(r,r.itemId,r.stepId);let o=h(r.transactionId,r.stepId,"apply"),s=e.slice(i),c=p=>p.message===o||p.context?.item_transaction_step===o,u=h(r.transactionId,r.stepId,"compensate");if(s.filter(p=>c(p)||p.message===u).at(-1)?.message===u)return!1;let f=s.filter(c);if(f.length===0)return!1;let _=e.at(-1).after_hash===f.at(-1).after_hash&&s.every(p=>Le(p,r.transactionId));if(f.length!==s.length&&!_)throw b(r,r.itemId,r.stepId);return!0}async function N(e,t,r,n){let i=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let a=i.target_updated_at,o=await g(e.pmRoot,t);if(o===void 0)return;let s=await S(d.join(e.pmRoot,"history",`${o.id}.jsonl`),o.id),c=i.target_history_hash;if(typeof c=="string"){if(!pt(s,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:o.id,stepId:r}))return}else{if(o.updatedAt===a)return;if(!await A(e.pmRoot,o.id,e.transactionId,r))throw b(e,o.id,r)}let u=()=>Ce(t,typeof i.target_version=="string"?i.target_version:a,{force:!0,author:e.author,message:h(e.transactionId,r,"compensate")},{pmRoot:e.pmRoot});await $({pmRoot:e.pmRoot,id:o.id,validate:f=>{if(G(f)!==s.at(-1).after_hash)throw b(e,o.id,r)}},u)}function Je(e,t,r){return{id:r,async inspect(){let n=await g(e.pmRoot,t.id);if(n===void 0)return{state:"pending"};if(n.closedAt!==void 0){let i=await S(d.join(e.pmRoot,"history",`${n.id}.jsonl`),n.id),a=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(o=>o.op==="close").at(-1)?.patch.some(o=>o.op==="add"||o.op==="replace"?o.path==="/metadata/close_reason"&&o.value===a:!1)??!1)throw new l(`Created item ${n.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,m.CONFLICT,{code:"transaction_create_compensated",item_id:n.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${n.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:n.id,op:"create"}}},async apply(){t.unique!==void 0&&await ct(e.uniqueIndex,t.unique);let n=await ke(C(t.options,{author:e.author,id:t.id,message:h(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot}),i=n.item;return e.onCreateWarnings?.(String(i.id),n.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await lt(e,t.id,r)}}}async function lt(e,t,r){let n=await g(e.pmRoot,t);if(n===void 0||e.createCompensation==="close"&&n.closedAt!==void 0)return;let i=await S(d.join(e.pmRoot,"history",`${n.id}.jsonl`),n.id),a=h(e.transactionId,r,"apply"),o=h(e.transactionId,r,"compensate"),s=i.filter(c=>c.message===a||c.message===o).at(-1);if(s?.message!==o){if(s===void 0||!i.every(c=>Le(c,e.transactionId)))throw b(e,n.id,r);await $({pmRoot:e.pmRoot,id:n.id,validate:c=>{if(G(c)!==i.at(-1).after_hash)throw b(e,n.id,r)}},async()=>{let c={force:!0,author:e.author,message:o};e.createCompensation==="delete"?await Ie(t,c,{pmRoot:e.pmRoot}):await W(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,c,{pmRoot:e.pmRoot})})}}function mt(e,t,r){return{id:r,compensatePending:!0,async inspect(){let n=await g(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await A(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return te(e.pmRoot,t)},async apply(){let n=()=>Me(t.id,C(t.options,{author:e.author,message:h(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot}),i=t.match,a=i,o=(await $({pmRoot:e.pmRoot,id:String((await J(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:s=>{a!==void 0&&dt(s,t.id,a)},committed:s=>{i!==void 0&&(a={key:i.key,value:structuredClone(s.metadata[i.key])})},historyContext:{item_transaction_step:h(e.transactionId,r,"apply")}},n)).item;return e.uniqueIndex.invalidate(),{id:String(o.id),op:"update"}},async compensate(n){await N(e,t.id,r,n)}}}function ft(e,t,r){return{id:r,async inspect(){let n=await g(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await A(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"close"}}:n.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:n.id,op:"close"}}},async prepareCompensation(){return te(e.pmRoot,t)},async apply(){let n=(await W(t.id,t.reason,C(t.options,{author:e.author,message:h(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(n.id),op:"close"}},async compensate(n){await N(e,t.id,r,n)}}}function ht(e,t,r){return{id:r,async inspect(){let n=await g(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await A(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"release"}}:n.assignee!==void 0||n.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:n.id,op:"release"}}},async prepareCompensation(){return te(e.pmRoot,t)},async apply(){let n=(await Re(t.id,C(t.options,{author:e.author,message:h(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(n.id),op:"release"}},async compensate(n){await N(e,t.id,r,n)}}}function ne(e,t,r){let n=ee(t,r);switch(t.op){case"create":return Je(e,t,n);case"update":return mt(e,t,n);case"close":return ft(e,t,n);case"release":return ht(e,t,n)}}function yt(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`);if(e.op==="create"&&e.unique!==void 0&&!De(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!De(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);z(e.options,e.op,t)}function We(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[r,n]of e.entries()){if(yt(n,r),n.op!=="create"||n.unique===void 0)continue;let{key:i,value:a}=n.unique,o=t.get(i)??new Map,s=v(a),c=o.get(s);if(c!==void 0)throw new l(`Bulk create mutations ${c+1} and ${r+1} share the upsert key value ${JSON.stringify(s)} for "${i}".`,m.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});o.set(s,r),t.set(i,o)}}function ze(e){let t=[...e];return We(t),t.map(r=>{let n=structuredClone(r);return r.options!==void 0&&n.options!==void 0&&x(r.options,n.options),n})}function Be(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([r,n])=>{let i=`${t}/${r.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(r)?[i]:Be(n,i)})}async function Y(e,t,r){try{return await r()}catch(n){throw n instanceof l?new l(n.message,n.exitCode,{...n.context,transaction_operation:{index:t,op:e.op,id:e.id}}):n}}function Ve(e,t,r,n){let i=d.relative(e,t),a=i.split(d.sep);return a[0]==="extensions"&&a[2]==="node_modules"&&!n.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`))?!1:["locks","runtime","search"].includes(i.split(d.sep)[0])?n.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`)):i===""||r===void 0||r.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`))}async function R(e,t){let r=await Fe(t);if(r.isSymbolicLink())await Z(t);else if(r.isDirectory()||r.isFile())return r;throw O(d.relative(e,t))}async function wt(e,t){let r=await it(t,V.O_RDONLY|V.O_NOFOLLOW|V.O_NONBLOCK);try{let n=await r.stat();if(!n.isFile())throw O(d.relative(e,t));let i=X.createHash("sha256");if(n.size>0)for await(let a of r.createReadStream({highWaterMark:64*1024,end:n.size-1,autoClose:!1}))i.update(a);return i.digest()}finally{await r.close()}}async function H(e,t,r){let n=X.createHash("sha256");async function i(a){for(let o of(await ot(a)).sort()){let s=d.join(a,o);Ve(e,s,t,r)&&((await R(e,s)).isDirectory()?await i(s):(n.update(JSON.stringify(d.relative(e,s))),n.update(await wt(e,s))))}}return await i(e),n.digest("hex")}function M(){return new l("Tracker changed while preparing the transaction preview; retry against stable state.",m.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function re(e){if(!j(e))return!1;let t=e.path;if(typeof t!="string")return!1;let r=d.resolve(t),n=r;for(;;)try{let i=await Fe(n);return n!==r&&i.isDirectory()}catch(i){if(!j(i))return!1;let a=d.dirname(n);if(a===n)return!1;n=a}}async function I(e,t){let r=d.join(e,t);try{let n=e;for(let i of t.split(d.sep).slice(0,-1))n=d.join(n,i),await R(e,n);if(!(await R(e,r)).isFile())throw O(t);return await ce(r,O(t))}catch(n){if(await re(n))return;throw n}}async function Ye(e,t,r,n){let i=F(r);for(let[a,o]of Object.entries(i.files)){let s=d.relative(e,fe(e,o,me[a]));if(s===""||!d.resolve(e,s).startsWith(d.join(e,d.sep)))throw new l("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",m.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${a}`});i.files[a]=s;let c=await I(e,s);if(n?.set(s,c),c!==void 0){let u=d.join(t,s);await rt(d.dirname(u),{recursive:!0}),await qe(u,c)}}return he(t,i)}async function gt(e,t){await Z(e);let r=await Pe(d.join(Ke(),"pm-schema-plan-"));try{let n=await xe(e);return await Ye(n,d.join(r,"configuration"),t)}catch(n){throw await re(n)?M():n}finally{await Ge(r,{recursive:!0,force:!0})}}async function vt(e,t,r){let n=new Map,i=await I(e,E);n.set(E,i);let a;try{a=JSON.parse(i??"null")}catch{a=null}let o=_e(a),s=o.success?o.data:void 0,c=await Ye(e,t,s?.schema,n),u=c.schema,f=d.relative(e,ve(e));n.set(f,await I(e,f));let _=D({...se,item_types:{definitions:[...s?.item_types?.definitions??[],...c.type_definitions_from_file??[]]}},r),p=de(e)===e?[...ae.filter(Boolean),E,Oe,"transactions",..._.folders,...n.keys()].map(w=>d.normalize(w)):void 0,y=s===void 0?void 0:JSON.stringify({...a,schema:{...s.schema,files:u.files}});return{configuration:n,ownedPaths:p,stagedSettings:y,registryFolders:_.folders}}async function _t(e,t,r){await Z(e);try{let n=await xe(e),i=await vt(n,d.join(d.dirname(t),"configuration"),r),a=[...i.configuration.keys(),...i.registryFolders].map(u=>d.normalize(u)),o=await H(n,i.ownedPaths,a);await nt(n,t,{recursive:!0,dereference:!1,filter:async u=>Ve(n,u,i.ownedPaths,a)?(await R(n,u),!0):!1});let[s,c]=await Promise.all([H(n,i.ownedPaths,a),H(t,i.ownedPaths,a)]);if(o!==s||o!==c)throw M();for(let[u,f]of i.configuration)if(await I(t,u)!==f)throw M();i.stagedSettings!==void 0&&await qe(d.join(t,E),i.stagedSettings)}catch(n){throw await re(n)?M():n}}async function jn(e){let t=k(e),r=ze(e.mutations),n=P(),i=await Pe(d.join(Ke(),"pm-transaction-preview-")),a=d.join(i,"tracker");try{await _t(t.pmRoot,a,n);let o=!1,s=[],c=[],u=new Set;return await Ne({path:a,noExtensions:!0},async()=>{ye(n);let f={...t,pmRoot:a,createCompensation:"close",uniqueIndex:Q(a)},_=r.map((p,y)=>{let w=ne({...f,onCreateWarnings:(U,ie)=>{ie.length>0&&s.push({index:y,id:U,op:"create",warnings:ie})}},p,y);return{...w,inspect:()=>Y(p,y,()=>w.inspect()),prepareCompensation:()=>Y(p,y,async()=>w.prepareCompensation?.()),apply:()=>Y(p,y,async()=>{let U=await w.apply();return u.add(y),U})}});if(await K({...t,pmRoot:a,steps:_,onTransition:({transition:p})=>{p==="committed"&&(o=!0)}}),o)for(let[p,y]of r.entries()){let w=(await $e(y.id,{path:a},{full:!0})).item;c.push({index:p,id:String(w.id),op:y.op,execution:u.has(p)?"applied":"adopted",item:w,commit_time_fields:Be(w)})}}),{records:c,validated:o,state:o?"staged_snapshot":"replayed_committed_plan",warnings:s,unresolved_commit_constraints:["concurrent_tracker_changes","extension_mutation_guards_and_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await Ge(i,{recursive:!0,force:!0})}}async function St(e){let t=k(e),r=ze(e.mutations),n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:n,uniqueIndex:Q(t.pmRoot)},a=await K({...t,steps:r.map((s,c)=>ne(i,s,c)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:r,createCompensation:n})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),o={};for(let[s,c]of r.entries()){let u=ee(c,s),f=a.results[u];o[ut(c,s)]=f}return{transactionId:a.transactionId,status:"committed",recovered:a.recovered,results:o}}function bt(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function Dn(e){return St({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:bt(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Fn={buildCreateStep:Je,bulkHistoryMarker:h,compensateByRestore:N,deriveStepId:ee,isUpdateMarkerApplied:A,readItemSnapshot:g};async function Pn(e,t){let r=await Ae(e,t);return r===void 0?void 0:{journal:r,planDigest:L(r)}}function Et(e,t){let r=t.recoveryData;if(r===null||typeof r!="object"||Array.isArray(r)||r.kind!=="item-mutations-v1"||!Array.isArray(r.mutations)||!["close","delete"].includes(String(r.createCompensation)))throw new l("Transaction has no supported item recovery plan",m.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let n=r.mutations;We(n);let i={...e,createCompensation:r.createCompensation,uniqueIndex:Q(e.pmRoot)};return n.map((a,o)=>ne(i,a,o))}async function xn(e){let t=k(e),r=await Te({...e,...t,resolveSteps:n=>Et({...e,...t},n)});return{journal:r,planDigest:L(r)}}export{Fn as _testOnlyItemTransaction,xn as abandonItemTransaction,bt as buildItemCompletionMutations,Dn as commitItemCompletion,St as commitItemMutations,st as listUpsertKeyCandidates,gt as loadGuardedRuntimeSchema,jn as previewItemMutations,Pn as readItemTransaction,at as resolveTransactionSchema};
|
|
2
|
+
//# sourceMappingURL=item-transaction-4JDWOXNB.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s as E,x as N}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=mutation-admission-
|
|
1
|
+
import{s as E,x as N}from"./chunk-2ZS3I5ZP.js";import"./chunk-6ICHSVEY.js";import{N as y,Q as C}from"./chunk-V27M5UQH.js";import"./chunk-33EK522E.js";import{Na as h,Ta as w}from"./chunk-UCUESVFW.js";import"./chunk-NY65XTX7.js";import{l as T,m as O,vb as A,y as R}from"./chunk-HIKZYZ26.js";import"./chunk-I5LGPUWH.js";import"./chunk-C3O6JJPO.js";import{a as g,xa as _}from"./chunk-MK7UQEE5.js";import{A as f}from"./chunk-G6ERMFJ5.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new t.Error().stack;o&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[o]="d19ff816-7570-5e8a-a4de-ad2ca48f0df0")}catch{}})();function b(t,o,r,a=!1){let d=[...r].map(n=>({candidate:n,distance:g(o,n,3)})).filter(n=>n.distance!==null).sort((n,i)=>n.distance-i.distance||n.candidate.localeCompare(i.candidate))[0]?.candidate,s=a?`Put mutation fields under options (options.${o}).`:d?`Did you mean "${d}"?`:"Use the declared command options or the field option for registered item fields.";throw new f(`Unknown ${t} ${a?"argument":"option"} "${o}". ${s} No changes were made.`,2,{code:"invalid_argument_value",reason:"unknown_mutation_option",changed:!1,field:o,required:s,nextSteps:[s]})}async function j(t,o,r,a,d){if(E(o))return;let s=t==="create"?y:C,n=(t==="create"?h:w).map(({flag:e})=>e.slice(2).replace(/-([a-z])/gu,(m,v)=>v.toUpperCase())),i=new Set([...s.flatMap(e=>[e.target,...e.keys]),...n]),l=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];for(let e of["author","message","force","fullChangedFields","idOnly",...l])i.add(e);let S=new Set(["action","options","path","cwd","author","force","noExtensions","no_extensions","fullChangedFields","idOnly",...l,...d,...t==="update"?["id"]:[]]);for(let e of Object.keys(o))S.has(e)||b(t,e,i,i.has(e));let u=o.options;if(u!==void 0&&!N(u))throw new f("Mutation options must be an object. No changes were made.",2,{code:"invalid_argument_value",changed:!1});let c=[...new Set([...Object.keys(u??{}),...Object.keys(r)])].filter(e=>!i.has(e));if(c.length===0)return;let p=T((await A(_(process.cwd(),a))).schema).command_to_fields.get(t)??[];for(let e of p)i.add(O(e));for(let e of c)p.some(m=>R({[e]:!0},m)===!0)||b(t,e,i)}export{j as assertNativeMutationOptions};
|
|
2
|
+
//# sourceMappingURL=mutation-admission-577MXOGD.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as w,j as y}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=stage-
|
|
1
|
+
import{c as w,j as y}from"./chunk-GBW2EAAG.js";import{b as g}from"./chunk-IDAYTYNN.js";import"./chunk-GHQVM6K6.js";import"./chunk-HIKZYZ26.js";import{xa as h}from"./chunk-MK7UQEE5.js";import{b as u}from"./chunk-FOA7XKWP.js";import{A as f,z as d}from"./chunk-G6ERMFJ5.js";import{execFile as _}from"node:child_process";import{realpath as b}from"node:fs/promises";import l from"node:path";import{promisify as x}from"node:util";(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]="7f4b2fc8-c9c6-51ff-a345-b76b8abdacf4")}catch{}})();var R=x(_);function c(e){return new f(`Automatic merge settlement refused: ${e}`,d.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"},nextSteps:["Inspect receipts, repair streams and Git changes. Resolve competing values or unrelated drift explicitly, then run pm merge reconcile and stage the reviewed artifacts manually."]})}async function $(e){let t=process.env.GIT_INDEX_FILE;if(t===void 0)return;let a=(await e(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(l.resolve(t)!==l.resolve(a))throw c("an alternate Git index requires explicit manual settlement")}async function I(e,t){if(t.length===0)return[];let a=t.map(s=>`:(literal)${s}`),o=new Set((await e(["ls-files","--cached","-z","--",...a])).stdout.split("\0")),i=t.filter(s=>!o.has(s)).map(s=>`:(literal)${s}`);if(i.length>0&&(await e(["diff","--cached","--name-only","--diff-filter=D","-z","--",...i])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return i}async function G(e){let{git:t,preview:a,paths:o,newReceiptPathspecs:i}=e,s=!1;try{i.length>0&&(s=!0,await t(["add","--",...i]));let n=await e.apply();if(!n.ok||JSON.stringify(n.receipts.summaries)!==JSON.stringify(a.receipts.summaries)||n.repair.streams.some(p=>!a.repair.streams.some(m=>m.id===p.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return o.length>0&&await t(["add","--",...o.map(p=>`:(literal)${p}`)]),{...n,staged_paths:o,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(n){throw s&&await t(["reset","--quiet","--",...i]),n}}function k(e){if(e.repair.totals.failed>0||e.receipts.missing_history_references_after>0||e.receipts.summaries.some(t=>t.conflict_fields.length>0)||e.repair.streams.some(t=>t.merge_receipt_proof?.trusted!==!0)||e.validation.checks.some(t=>t.name!=="history_drift"&&t.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function S(e){try{return{...e,path:await b(h(process.cwd(),e.path))}}catch{throw c("the tracker root cannot be resolved")}}async function F(e){let{preview:t}=e;k(t);let{path:a}=await S(e.global),o=await w(a);if(o===null)throw c("a Git workspace is required");let i=r=>R("git",r,{cwd:o,env:u(),timeout:1e4});if(await $(i),(await i(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let s=[...new Set([...[...new Set([...t.repair.streams.map(r=>r.id),...t.receipts.summaries.map(r=>r.item_id)])].map(r=>l.join(a,"history",`${r}.jsonl`)),...t.receipts.summaries.map(r=>l.join(a,"merge-receipts",`${r.receipt_id}.json`))])].map(r=>l.relative(o,r).replaceAll("\\","/"));if(s.some(g))throw c("reconciliation artifacts must belong to this Git workspace");let n=await y(o,s);if(n.length>0)throw new f(`Automatic merge settlement refused: required artifacts are ignored by Git: ${n.map(r=>`${r.path} (${r.source}:${r.line}: ${r.pattern})`).join(", ")}. Remove or narrow the owning ignore rules because merge receipts must travel with the commit.`,d.CONFLICT,{code:"merge_settlement_review_required",reason:"ignored_merge_artifacts",paths:n.map(r=>r.path),nextSteps:["Remove or narrow the named ignore rules, preserve receipt and history files, then retry pm merge reconcile --stage --dry-run before applying pm merge reconcile --stage. Do not force-add ignored proof as a substitute for fixing the shared policy."]});let p=s.map(r=>`:(literal)${r}`),m=t.receipts.summaries.map(r=>l.relative(o,l.join(a,"merge-receipts",`${r.receipt_id}.json`)).replaceAll("\\","/"));if(p.length>0)try{await i(["diff","--quiet","--",...p])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let v=await I(i,m);return e.dryRun?{...t,staged_paths:[]}:G({...e,git:i,paths:s,newReceiptPathspecs:v})}export{S as resolveMergeSettlementGlobal,F as stageLosslessMergeReconciliation};
|
|
2
|
+
//# sourceMappingURL=stage-EKYWEU2Y.js.map
|