@unbrained/pm-cli 2026.12.2 → 2026.12.3
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/dist/cli/commander-usage.js +4 -4
- package/dist/cli/expected-revisions.js +1 -1
- package/dist/cli/extension-command-help.js +4 -4
- package/dist/cli/main.js +5 -5
- package/dist/cli/runtime/invocation-rewrites.js +1 -1
- package/dist/cli/runtime-field-commands.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3ESBFEQC.js +2 -0
- package/dist/cli-bundle/chunks/chunk-46AZP5QW.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-OBPO6V7H.js → chunk-5WTBF4M4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3KEMIPKG.js → chunk-6TOZQ5BQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YYFY33T.js → chunk-AHVOEE7F.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-CQHB3ZZH.js +2 -0
- package/dist/cli-bundle/chunks/chunk-DZPOS3YT.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ROTEELDL.js → chunk-E5ADC3HT.js} +65 -65
- package/dist/cli-bundle/chunks/{chunk-SY5C3U32.js → chunk-E5HO7HWP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3HKPVOAN.js → chunk-EDJ3KR2H.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TKUG2X24.js → chunk-FWQNWPIV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7NAO7I75.js → chunk-H4U3LEOD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MZZ4ZJ5Z.js → chunk-HNMED75Y.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SDXCJZKB.js → chunk-HPCMM74Q.js} +22 -22
- package/dist/cli-bundle/chunks/{chunk-WSEIEDEK.js → chunk-ITM4AMVM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q6K7HWZ7.js → chunk-IW4A3I4N.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7V65VACG.js → chunk-JJ73G5UT.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-L4HMFRHB.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-GOEQXVOI.js → chunk-LTQWPQ7H.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UNBW2LF3.js → chunk-MRT3ADO4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZL6J6JYT.js → chunk-PBMLIV74.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-G6TARHFK.js → chunk-PJMGWJKU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-Q2HMDV56.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-OXC5KBIQ.js → chunk-RRBNCL63.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CBUC4X7Q.js → chunk-TDOF7BKO.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-UXEZXGAD.js +113 -0
- package/dist/cli-bundle/chunks/{chunk-PCDTWL6V.js → chunk-W7HA65EO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-I4SPJQQI.js → chunk-XGNUDSCG.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-AHV3CSQG.js → chunk-XKJ5NWQ7.js} +2 -2
- package/dist/cli-bundle/chunks/{field-option-collisions-BBGTV7AD.js → field-option-collisions-DXKTKW6J.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-DXEF4XBU.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-EANA7V4W.js +2 -0
- package/dist/cli-bundle/chunks/{linked-resource-value-list-ZBIY4H23.js → linked-resource-value-list-5JRGUDUB.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-actor-NHN33ITJ.js → mutation-actor-S5G7FMNG.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-PGKJTCG6.js → mutation-admission-HQVNPOXV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-7S5QWDTI.js → register-list-query-SQF5PSJ4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-EK6DVIQK.js → register-mutation-4AQ4CEBL.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-6MURXE4V.js → register-operations-76P7OM4P.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-RW26X3GJ.js → register-setup-T6OEOZK3.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-4ZCF74G4.js → stage-KUICZHSF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-4SCFAWAW.js → chunk-3LHBKFPD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-4DDXERKN.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-JPZGC3W4.js → chunk-4YU75CWI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TXTPAFHJ.js → chunk-5JQVPQMN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KNBGHCIP.js → chunk-5Z4DXYBZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7DOP5HEZ.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TR22GU7M.js → chunk-AX4RBJ7B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7A6SEZEY.js → chunk-BEHQCHQV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-BUIF6CMZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-E2IWEJL5.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-GBU7GKNJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-EQCQTYKO.js → chunk-K35KTBDZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VQIC3UZB.js → chunk-KNST4PGF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-P2H3GTJK.js → chunk-L2XJB5PK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-L6NOGC4N.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-VK3IE3TS.js → chunk-LWIIDPAV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6IY5CVGJ.js → chunk-M54BMYG4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6BKT6XQN.js → chunk-NEK7RX3N.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BHNBPCHP.js → chunk-OKGWIW6C.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2DGKVXFT.js → chunk-RFDSSOTZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SSX5YBDC.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OG57ESZK.js → chunk-TIEQVIFN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3COWDIPX.js → chunk-VEUBDQDP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2UWKU2BQ.js → chunk-WDHNPNHX.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-2C6DLUC4.js → field-option-collisions-32X7FP3H.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-GUYSVVQD.js +2 -0
- package/dist/cli-bundle/focused-chunks/{item-transaction-LQLQLZE7.js → item-transaction-MLKHZPL7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-DJMZUIZI.js → mutation-actor-RDZJTRW2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-SDWQVVHN.js → mutation-admission-IQB6XL75.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-QBZIK3T5.js → stage-AA7LORZ2.js} +2 -2
- package/dist/cli-bundle/main.js +27 -27
- 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 +63 -63
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +9 -9
- package/dist/core/extensions/loader.d.ts +8 -0
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/item/actionability.js +1 -1
- package/dist/core/output/output.js +16 -16
- package/dist/mcp/server.js +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +25 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/lifecycle/expect-hash-admission.d.ts +27 -8
- package/dist/sdk/lifecycle/expect-hash-admission.js +1 -1
- package/dist/sdk/lifecycle/item-revision.d.ts +12 -4
- package/dist/sdk/lifecycle/item-revision.js +1 -1
- package/dist/sdk/output-projection.d.ts +1 -1
- package/dist/sdk/output-projection.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output/surfaces.js +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/runtime-input.d.ts +6 -0
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.js +1 -1
- package/docs/COMMANDS.md +23 -5
- package/docs/EXTENSIONS.md +1 -1
- package/docs/SDK.md +15 -2
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +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-A5ZEMOVR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-C6WM6ZN4.js +0 -9
- package/dist/cli-bundle/chunks/chunk-HZZLSBIJ.js +0 -2
- package/dist/cli-bundle/chunks/chunk-L2ZSSMYY.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NRQCBUYD.js +0 -113
- package/dist/cli-bundle/chunks/chunk-QDV7S2QS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-V2S4XAX3.js +0 -2
- package/dist/cli-bundle/chunks/item-revision-3LENTXYF.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-56J5OCHA.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HTDYNY4L.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-J72TRWR5.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-N64AC5G6.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-QZRYGYTI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-SQMOF65W.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-T3ILWAEV.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-W4JMV7GF.js +0 -3
- package/dist/cli-bundle/focused-chunks/item-revision-723XCQPS.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{S as E,T as j,U as G,V as k,W as w,X as $,Y as I,a as le,ba as F,g as P,i as J,o as N,q as U,s as B}from"./chunk-W4JMV7GF.js";import{E as ce,F as ue,H as _,I as de,W as V,fa as Z,o as K,oa as fe,p as X}from"./chunk-VK3IE3TS.js";import{L as S}from"./chunk-N64AC5G6.js";import{A as p,z as f}from"./chunk-IRYNVGKH.js";var Fe=new Set(["none","null"]);function bt(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function v(e){return e===void 0?!1:Fe.has(e.trim().toLowerCase())}function Mt(e,t,r){if(!v(e))return;let n=r?` ${r}`:"";throw new p(`${t} no longer accepts "none" or "null".${n}`.trim(),f.USAGE)}function kt(e,t,r){if(!e||e.length===0||X(e)||!e.some(i=>v(i)))return;let o=r?` ${r}`:"";throw new p(`${t} no longer accepts "none" or "null".${o}`.trim(),f.USAGE)}function wt(e,t){for(let r of t){let n=e[r.optionKey];if(!Array.isArray(n)||n.length===0)continue;if(!n.every(s=>typeof s=="string"))throw new p(`${r.valueFlag} entries must be strings.`,f.USAGE);if(X(n))continue;let o=n;if(!o.some(s=>v(s)))continue;if(o.filter(s=>!v(s)).length>0)throw new p(`Cannot mix legacy clear token "none"/"null" with concrete ${r.valueFlag} entries. Use ${r.clearFlag} to clear or provide explicit entries.`,f.USAGE);e[r.optionKey]=void 0,e[r.clearFlagKey]=!0,r.disableFlagKey&&(e[r.disableFlagKey]=!1)}return e}var Ke=["close_reason","close-reason"],pe=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],me=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],De=[...pe,...me],ye=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],ee=[...De,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...ye],Le=[...pe,{canonical:"close-reason",aliases:Ke,optionKey:"closeReason",metadataKey:"close_reason"},...me,...ye],Pe=new Set(["none","null","-"]);function ge(e){return e==="create"?ee:Le}function H(e,t){let r=t.unset;if(r!==void 0&&typeof r!="string"&&!Array.isArray(r))return;let n=[];for(let o of ge(e))o.optionKey==="author"||!Object.hasOwn(t,o.optionKey)||t[o.optionKey]!==null||(Reflect.deleteProperty(t,o.optionKey),n.push(o.canonical));n.length!==0&&(t.unset=[...r===void 0?[]:typeof r=="string"?[r]:r,...n])}function Q(e){return typeof e=="string"&&Pe.has(e.trim().toLowerCase())}function Dt(e,t,r,n){return r?ge(e).flatMap(o=>{let i=t[o.optionKey],a=n[o.metadataKey];return Q(i)&&(Q(a)||Array.isArray(a)&&a.some(Q))?[`literal_sentinel_stored:${o.canonical}:${i.trim()}`]:[]}):[]}function Ue(e,t){return e.flatMap(r=>r.includes(",")&&t(r)?[r]:r.split(","))}function Be(e){let t=new Set,r=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:r};let n=Ue(e.raw,o=>e.resolveDefinition(o.trim().toLowerCase())!==void 0);for(let o of n){let i=o.trim().toLowerCase();if(!i)throw new p("--unset values must not be empty; name each field once, for example --unset parent,release",f.USAGE);if(v(i))throw new p('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',f.USAGE);let a=e.resolveDefinition(i);if(!a)throw new p(`Unsupported --unset field "${o}". Supported fields: ${e.supportedFields}`,f.USAGE);t.add(a.metadataKey),r.add(a.optionKey)}return{metadataKeys:t,optionKeys:r}}function je(e,t,r){let n=e.trim().toLowerCase();if(!r)return;let o=r.command_to_fields?.get(t)??[];for(let i of o){if(i.allow_unset===!1)continue;let a=new Set;if(typeof i.key=="string"&&i.key.length>0&&a.add(i.key.toLowerCase()),typeof i.metadata_key=="string"&&i.metadata_key.length>0&&a.add(i.metadata_key.toLowerCase()),typeof i.cli_flag=="string"&&i.cli_flag.length>0&&(a.add(i.cli_flag.replaceAll("-","_").toLowerCase()),a.add(i.cli_flag.toLowerCase())),Array.isArray(i.cli_aliases))for(let s of i.cli_aliases)typeof s!="string"||s.length===0||(a.add(s.replaceAll("-","_").toLowerCase()),a.add(s.toLowerCase()));if(a.has(n))return{optionKey:i.key,metadataKey:i.metadata_key}}}var Ge=(()=>{let e=new Map;for(let t of ee)for(let r of t.aliases)e.set(r,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),$e=ee.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function Lt(e,t){return Be({raw:e,supportedFields:$e,resolveDefinition:r=>Ge.get(r)??je(r,"create",t)})}var Ve={create:'client.create({ type: "Task", title: "Example", createMode: "progressive" })',update:'client.update(id, { estimatedMinutes: "45", force: false })',append:'client.append(id, "Body text")',reopen:'client.reopen(id, "The work recurred", { expectedResult: "Verified recovery" })'};function x(e,t,r){let n=`${e} ${t} must be ${r}.`;throw new p(n,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",field:t,changed:!1,required:n,examples:[Ve[e]]})}function D(e,t,r){typeof e!="string"&&x(t,r,"a string")}function te(e,t){(e===null||typeof e!="object"||Array.isArray(e))&&x(t,"options","an object")}function Ae(e,t){(e==="append"||e==="update")&&t.id!==void 0&&D(t.id,e,"id"),e==="item-reopen"&&(t.id!==void 0&&D(t.id,"reopen","id"),t.reason!==void 0&&D(t.reason,"reopen","reason"),t.options!==void 0&&He(t.options))}function Wt(e){te(e,"append");for(let t of["body","author","message"])e[t]!==void 0&&D(e[t],"append",t);e.force!==void 0&&typeof e.force!="boolean"&&x("append","force","a boolean")}function He(e){te(e,"reopen");for(let t of F["item-reopen"].optional){let r=e[t];r!==void 0&&(S(Reflect.get(E,t)).type==="boolean"?typeof r!="boolean"&&x("reopen",t,"a boolean"):D(r,"reopen",t))}}function ze(e,t){return e?t?"a string or string array":"a string array":"a string"}function qe(e,t,r,n,o,i){r===void 0||typeof r=="string"&&(!o||i)||n==="priority"&&typeof r=="number"&&Number.isFinite(r)||o&&Array.isArray(r)&&Array.from(r).every(a=>typeof a=="string")||x(e,t,ze(o,i))}function Ye(e,t,r){let n=e==="create"?U:B;for(let{param:o}of[...n,...N,{param:"force"}]){if(S(Reflect.get(E,o)).type!=="boolean")continue;let i=r.find(a=>a.keys.includes(o))?.keys??[o];for(let a of i)t[a]!==void 0&&typeof t[a]!="boolean"&&x(e,a,"a boolean")}}function re(e,t,r=!0,n=!1){let o=e==="create"?j:w;for(let{target:i,keys:a,repeatable:s}of o)if(S(Reflect.get(E,i)).type!=="boolean")for(let u of a){let h=n&&u!==i,A=s===!0&&(i!=="acceptanceCriteria"||h);qe(e,u,t[u],i,A,r||h)}Ye(e,t,o)}function Jt(e,t){te(t,e);let r=ce(t),n=K(r);return n||H(e,r),re(e,r,!1,n),r}import{Option as hr}from"commander";function O(e,t,r){if(typeof r!="string")return;let n=r.trim();n.length!==0&&e.push(t,n)}function y(e,t,r){r===!0&&e.push(t)}function C(e,t,r){if(Array.isArray(r))for(let n of r){if(typeof n!="string")continue;let o=n.trim();o.length!==0&&e.push(t,o)}}function We(e,t){let r=["test",e,"--run","--json","--progress"];return C(r,"--add",t.add),C(r,"--add-json",t.addJson),C(r,"--remove",t.remove),C(r,"--remove-index",Array.isArray(t.removeIndex)?t.removeIndex.map(n=>typeof n=="number"?String(n):n):t.removeIndex),O(r,"--match",t.match),O(r,"--only-index",typeof t.onlyIndex=="number"?String(t.onlyIndex):t.onlyIndex),y(r,"--only-last",t.onlyLast),y(r,"--full-history",t.fullHistory),C(r,"--measure",t.measure),O(r,"--metric-below",t.metricBelow),O(r,"--metric-diff",t.metricDiff),Je(r,t),O(r,"--author",t.author),O(r,"--message",t.message),y(r,"--force",t.force),r}function Je(e,t){O(e,"--timeout",t.timeout),C(e,"--env-set",t.envSet),C(e,"--env-clear",t.envClear),y(e,"--shared-host-safe",t.sharedHostSafe),O(e,"--pm-context",t.pmContext),y(e,"--override-linked-pm-context",t.overrideLinkedPmContext),O(e,"--workspace-context",t.workspaceContext),y(e,"--override-linked-workspace-context",t.overrideLinkedWorkspaceContext),y(e,"--allow-untrusted-linked-tests",t.allowUntrustedLinkedTests),y(e,"--fail-on-context-mismatch",t.failOnContextMismatch),y(e,"--fail-on-skipped",t.failOnSkipped),y(e,"--fail-on-empty-test-run",t.failOnEmptyTestRun),y(e,"--require-assertions-for-pm",t.requireAssertionsForPm),y(e,"--check-context",t.checkContext),y(e,"--full-output",t.fullOutput),y(e,"--auto-pm-context",t.autoPmContext)}function he(e,t){let r=[],n=new Set;for(let o of t.keys){if(!Object.hasOwn(e,o))continue;let i=e[o];if(i!=null){if(typeof i=="string"){r.push(i);continue}if(!Array.isArray(i)||!i.every(a=>typeof a=="string"))return;n.has(i)||(n.add(i),r.push(...i))}}return r.length>0?r.join("; "):void 0}function R(e,t){return e.find(n=>n.target===t)??{target:t,keys:[t]}}function l(e,t){return e[t]===!0?!0:void 0}function T(e,t){return e[t]===!1?!0:void 0}function z(e,t){return t.some(r=>e[r]===!0)?!0:void 0}function ne(e,t){for(let[r,n]of Object.entries(t))r==="__proto__"||r==="constructor"||r==="prototype"||Object.hasOwn(e,r)||(e[r]=n)}function _e(e,t={}){let r=a=>P(e,R(G,a)),n=a=>J(e,R(k,a)),o=r("type");if(t.requireType!==!1&&o===void 0)throw new p("Missing required option --type <value>. Why required: create resolves runtime schema fields/workflow from item type. Retry: add --type <built-in or configured custom type> (example: --type Task).",f.USAGE);let i={title:r("title"),description:r("description"),type:o,template:r("template"),createMode:r("createMode"),defer:n("defer"),deferReason:r("deferReason"),schedulePreset:r("schedulePreset"),status:r("status"),closeReason:r("closeReason"),completedAt:r("completedAt"),priority:r("priority"),tags:r("tags"),addTags:n("addTags"),body:r("body"),deadline:r("deadline"),estimatedMinutes:r("estimatedMinutes"),acceptanceCriteria:he(e,R(k,"acceptanceCriteria")),definitionOfReady:r("definitionOfReady"),order:r("order"),rank:r("rank"),goal:r("goal"),objective:r("objective"),value:r("value"),impact:r("impact"),outcome:r("outcome"),whyNow:r("whyNow"),author:r("author"),message:r("message"),assignee:r("assignee"),parent:r("parent"),inheritFocus:e.inheritFocus,allowMissingParent:z(e,["allowMissingParent","allow_missing_parent"])===!0,allowUnresolvedDeps:z(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,allowDuplicate:l(e,"allowDuplicate")===!0,reviewer:r("reviewer"),risk:r("risk"),confidence:r("confidence"),sprint:r("sprint"),release:r("release"),blockedBy:r("blockedBy"),blockedReason:r("blockedReason"),unblockNote:r("unblockNote"),reporter:r("reporter"),severity:r("severity"),environment:r("environment"),reproSteps:r("reproSteps"),resolution:r("resolution"),expectedResult:r("expectedResult"),actualResult:r("actualResult"),affectedVersion:r("affectedVersion"),fixedVersion:r("fixedVersion"),component:r("component"),regression:e.regression===!0?"true":r("regression"),customerImpact:r("customerImpact"),dep:n("dep"),comment:n("comment"),note:n("note"),learning:n("learning"),file:n("file"),test:n("test"),doc:n("doc"),reminder:n("reminder"),event:n("event"),typeOption:n("typeOption"),field:n("field"),unset:n("unset"),clearDeps:l(e,"clearDeps"),clearComments:l(e,"clearComments"),clearNotes:l(e,"clearNotes"),clearLearnings:l(e,"clearLearnings"),clearFiles:l(e,"clearFiles"),clearTests:l(e,"clearTests"),clearDocs:l(e,"clearDocs"),clearReminders:l(e,"clearReminders"),clearEvents:l(e,"clearEvents"),clearTypeOptions:l(e,"clearTypeOptions")};return ne(i,e),_(e,i)}function Oe(e){let t=o=>P(e,R($,o)),r=o=>J(e,R(I,o)),n={title:t("title"),description:t("description"),body:t("body"),status:t("status"),closeReason:t("closeReason"),priority:t("priority"),type:t("type"),tags:t("tags"),addTags:r("addTags"),removeTags:r("removeTags"),deadline:t("deadline"),estimatedMinutes:t("estimatedMinutes"),acceptanceCriteria:he(e,R(I,"acceptanceCriteria")),addAc:r("addAc"),removeAc:r("removeAc"),definitionOfReady:t("definitionOfReady"),order:t("order"),rank:t("rank"),goal:t("goal"),objective:t("objective"),value:t("value"),impact:t("impact"),outcome:t("outcome"),whyNow:t("whyNow"),author:t("author"),message:t("message"),force:!!e.force,ownershipMetadataBypass:e.ownershipMetadataBypass===!0?!0:void 0,ownershipDependencyBypass:e.ownershipDependencyBypass===!0?!0:void 0,assignee:t("assignee"),parent:t("parent"),allowUnresolvedDeps:z(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,reviewer:t("reviewer"),risk:t("risk"),confidence:t("confidence"),sprint:t("sprint"),release:t("release"),blockedBy:t("blockedBy"),blockedReason:t("blockedReason"),unblockNote:t("unblockNote"),reporter:t("reporter"),severity:t("severity"),environment:t("environment"),reproSteps:t("reproSteps"),resolution:t("resolution"),expectedResult:t("expectedResult"),actualResult:t("actualResult"),affectedVersion:t("affectedVersion"),fixedVersion:t("fixedVersion"),component:t("component"),regression:e.regression===!0?"true":t("regression"),customerImpact:t("customerImpact"),dep:r("dep"),depRemove:r("depRemove"),replaceDeps:l(e,"replaceDeps"),replaceTests:l(e,"replaceTests"),replaceFiles:l(e,"replaceFiles"),replaceDocs:l(e,"replaceDocs"),comment:r("comment"),note:r("note"),learning:r("learning"),file:r("file"),test:r("test"),doc:r("doc"),reminder:r("reminder"),event:r("event"),typeOption:r("typeOption"),field:r("field"),unset:r("unset"),clearDeps:l(e,"clearDeps"),clearComments:l(e,"clearComments"),clearNotes:l(e,"clearNotes"),clearLearnings:l(e,"clearLearnings"),clearFiles:l(e,"clearFiles"),clearTests:l(e,"clearTests"),clearDocs:l(e,"clearDocs"),clearReminders:l(e,"clearReminders"),clearEvents:l(e,"clearEvents"),clearTypeOptions:l(e,"clearTypeOptions")};return ne(n,e),_(e,n)}function d(e,t){let r=R(le,t),n=P(e,r);if(n!==void 0)return n;for(let o of r.keys){let i=e[o];if(Array.isArray(i)){let a=i.filter(s=>typeof s=="string");if(a.length>0)return a.join(",")}if(t==="ids"&&typeof i=="string")return i;if(typeof i=="number"&&Number.isFinite(i))return String(i)}}function Xe(e){let t=l(e,"filterFilesMissing"),r=l(e,"filterDocsMissing");return{filterReviewerMissing:l(e,"filterReviewerMissing"),filterRiskMissing:l(e,"filterRiskMissing"),filterConfidenceMissing:l(e,"filterConfidenceMissing"),filterSprintMissing:l(e,"filterSprintMissing"),filterReleaseMissing:l(e,"filterReleaseMissing"),hasNotes:l(e,"hasNotes"),hasLearnings:l(e,"hasLearnings"),hasFiles:l(e,"hasFiles"),hasDocs:l(e,"hasDocs"),hasTests:l(e,"hasTests"),hasComments:l(e,"hasComments"),hasDeps:l(e,"hasDeps"),hasBody:l(e,"hasBody"),hasLinkedCommand:l(e,"hasLinkedCommand"),noNotes:T(e,"notes"),noLearnings:T(e,"learnings"),noFiles:T(e,"files")??t,filterFilesMissing:t,noDocs:T(e,"docs")??r,filterDocsMissing:r,noTests:T(e,"tests"),noComments:T(e,"comments"),noDeps:T(e,"deps"),emptyBody:l(e,"emptyBody"),noLinkedCommand:T(e,"linkedCommand")}}function Te(e){let t={status:d(e,"status"),type:d(e,"type"),tag:d(e,"tag"),priority:d(e,"priority"),deadlineBefore:d(e,"deadlineBefore"),deadlineAfter:d(e,"deadlineAfter"),updatedAfter:d(e,"updatedAfter"),updatedBefore:d(e,"updatedBefore"),createdAfter:d(e,"createdAfter"),createdBefore:d(e,"createdBefore"),today:l(e,"today"),recent:l(e,"recent"),ids:d(e,"ids"),assignee:d(e,"assignee"),assigneeFilter:d(e,"assigneeFilter"),parent:d(e,"parent"),sprint:d(e,"sprint"),release:d(e,"release"),limit:d(e,"limit"),offset:d(e,"offset"),noTruncate:T(e,"truncate"),includeBody:l(e,"includeBody"),strictRead:l(e,"strictRead"),compact:l(e,"compact"),brief:l(e,"brief"),full:l(e,"full"),fields:d(e,"fields"),sort:d(e,"sort"),order:d(e,"order"),tree:l(e,"tree"),treeDepth:d(e,"treeDepth"),filterAcMissing:l(e,"filterAcMissing"),filterEstimatesMissing:z(e,["filterEstimatesMissing","filterEstimateMissing"]),filterResolutionMissing:l(e,"filterResolutionMissing"),filterMetadataMissing:l(e,"filterMetadataMissing"),...Xe(e)};return ne(t,e),t}var Ze=Symbol("pm.mcp-mutation-transport"),Qe=new Set(["create","update","append"]),W={create:{parameters:U,aliases:j,strings:G,repeatables:k},update:{parameters:B,aliases:w,strings:$,repeatables:I}},et=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function L(e){return Ze in e}function Y(e,t){return L(e)?ue(t):_(e,t)}function Ur(e,t,r=[]){let n=_(e,{...e,...t});for(let o of r)Reflect.deleteProperty(n,o);return n}function c(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r:void 0}function m(e,t){let r=e[t];return typeof r=="string"?r.trim().length>0?r:void 0:typeof r=="number"&&Number.isFinite(r)?String(r):void 0}function Br(e,t){let r=e[t];return typeof r=="string"?r:typeof r=="number"&&Number.isFinite(r)?String(r):void 0}function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jr(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new p(`${t} must be a finite integer.`,f.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let r=Number(e);if(!Number.isInteger(r))throw new p(`${t} must be a finite integer.`,f.USAGE);return r}}function Gr(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:c(e,"limit")??c(t,"limit")}function $r(e){let t=c(e,"outputFormat");return{json:!0,quiet:!0,author:c(e,"author"),path:c(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:c(e,"outputInclude"),outputLimit:m(e,"outputLimit"),outputBudget:m(e,"outputBudget"),outputSession:c(e,"outputSession"),outputCursor:c(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var Ee=new Set(["tags","blockedBy","blocked_by","skills","fields"]),ve=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),tt=new Set([...ve].filter(e=>e!=="file")),rt=new Set(["files","files-discover","docs","test","test-all"]),oe=new Set(["comments","notes","learnings"]);function nt(e,t){if(!(!oe.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new p(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,f.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var it=new Set(["claim","release","start-task","pause-task","close-task"]),xe={history:["order"],"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate","inheritFocus"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable","takeoverStale"],"start-task":["takeoverStale"],release:["pause","handoff"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun","offline","fields","scope"],package:["dryRun","offline","fields","scope"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},at=new Set(["context","get","list","next","search","comments","notes","learnings","files","docs","test"]),ot=new Set(["query","keywords","id","text"]);function st(e){return at.has(e)?F[e].optional.filter(t=>!ot.has(t)):[]}var lt=new Set(["claim","start-task","comments","notes","learnings","files","docs","test"]);function ct(e,t){if(!lt.has(e??""))return t;let r={...t};for(let n of F[e].optional){let o=n.replace(/[A-Z]/gu,i=>`_${i.toLowerCase()}`);o===n||r[o]===void 0||(r[n]??=r[o],delete r[o])}return r}function ut(e,t,r){if(!oe.has(e??""))return r;let n=r,o=n.text??t.text;if(o===void 0)return n;if(n.add!==void 0&&n.add!==o){let a=e.replace(/s$/u,"");throw new p(`Specify ${a} text either as text or with add, not both.`,f.USAGE,{code:"annotation_text_source_conflict",field:"text",required:`Pass the ${a} text once: text and add are the same source.`})}let i={...n,add:o};return delete i.text,i}function dt(e,t){let r=t.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return e[t]!==void 0||e[r]!==void 0}function ft(e){return[...xe[e]??[],...st(e),...be]}var be=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function Me(e,t=""){let r={},n=rt.has(t),o=t==="files"||t==="files-discover"||t==="docs",i=oe.has(t)?tt:ve;for(let[a,s]of Object.entries(e)){if(Array.isArray(s)&&Ee.has(a)){r[a]=s.join(",");continue}if(a==="note"&&o){r[a]=s;continue}if(typeof s=="string"&&i.has(a)){r[a]=[s];continue}if(typeof s=="string"&&n&&(a==="add"||a==="remove")){r[a]=[s];continue}r[a]=s}return Object.assign(r,Object.fromEntries(Object.getOwnPropertySymbols(e).map(a=>[a,Reflect.get(e,a)]))),r}function pt(e,t,r){let n=c(e,"author");return n!==void 0?n:r!==void 0&&it.has(r)?c(e,"assignee")??c(t,"assignee"):void 0}function mt(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function yt(e,t,r){let n={},o=W[e],i=new Set([...o.parameters.map(({param:a})=>a),...N.map(({param:a})=>a),...xe[e],...be,"force"]);for(let a of i){let s=o.aliases.find(u=>u.keys.includes(a))?.keys??[a];t[a]===void 0||s.some(u=>r[u]!==void 0)||(n[a]=t[a])}return n}function b(e,t){throw new p(`Invalid MCP ${e} value for "${t}". No changes were made.`,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:t,required:`Provide valid ${e} field values and an options object; inspect the pm_${e} input schema for supported types.`})}function gt(e,t,r){let n=W[e],o=[...n.parameters,...N,{param:"force"}];for(let{param:i}of o){if(S(E[i]).type!=="boolean")continue;let s=(n.aliases.find(u=>u.keys.includes(i))?.keys??[i]).find(u=>r[u]!==void 0&&typeof r[u]!="boolean");s!==void 0&&b(e,s)}for(let i of["idOnly","fullChangedFields"])t[i]!==void 0&&typeof t[i]!="boolean"&&b(e,i)}function At(e,t,r){t.options!==void 0&&!g(t.options)&&b(e,"options"),gt(e,t,r);for(let a of Ee){let s=r[a];Array.isArray(s)&&s.some(u=>typeof u!="string")&&b(e,a)}let n=Ie(r,e),o=W[e];for(let{keys:a,target:s}of o.strings)a.some(u=>r[u]!==void 0)&&n[s]===void 0&&b(e,s);let i=o.repeatables.flatMap(({keys:a})=>a).find(a=>{let s=r[a];return s!==void 0&&typeof s!="string"&&(!Array.isArray(s)||s.some(u=>typeof u!="string"))});return i!==void 0&&b(e,i),n}function ht(e,t,r,n,o){let i=(t==="create"||t==="update")&&L(e),a={...i?yt(t,e,n):r,...n};if((t==="create"||t==="update")&&!i){let s=g(e.options)&&K(e.options);s||H(t,a),re(t,a,!0,s)}return i?At(t,e,a):o?Me(a,t):a}function _t(e,t){return!Qe.has(e??"")||K(t)?t:fe(t)}function Vr(e,t,{nativeAction:r=!0}={}){Ae(t,e);let n=g(e.options)?e.options:void 0,o=S(e.options),i={},a=A=>{dt(o,A)||e[A]===void 0||(i[A]=e[A])};for(let A of ft(t??""))a(A);t!==void 0&&L(e)&&nt(t,o);let s=ut(t,e,ct(t,ht(e,t,i,o,r)));if(t==="history-attest"&&L(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new p("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",f.USAGE);let u=L(e)?e:n??e,h=Y(u,mt(s,pt(e,s,t)));return _t(t,h)}function Hr(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function zr(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function Ot(e){let t=[],r=!0;for(let n of e.trim().toLowerCase()){if(n>="a"&&n<="z"||n>="0"&&n<="9"){t.push(n),r=!1;continue}r||(t.push("-"),r=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function qr(e){return!et.has(Ot(e))}function Yr(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function Tt(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function Wr(e,t){let r=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),n={};for(let[i,a]of Object.entries(e))r.has(i)||(n[i]=a);let o={...n,...t};return delete o.args,delete o.author,o}function Jr(e,t){let r=Y(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:r}}function ae(e){return{type:m(e,"filterType"),tag:m(e,"filterTag"),priority:m(e,"filterPriority"),deadlineBefore:m(e,"filterDeadlineBefore"),deadlineAfter:m(e,"filterDeadlineAfter"),updatedAfter:m(e,"filterUpdatedAfter"),updatedBefore:m(e,"filterUpdatedBefore"),createdAfter:m(e,"filterCreatedAfter"),createdBefore:m(e,"filterCreatedBefore"),ids:Z(e.ids),assignee:m(e,"filterAssignee"),assigneeFilter:m(e,"filterAssigneeFilter")??m(e,"filterAssignee_filter"),parent:m(e,"filterParent"),sprint:m(e,"filterSprint"),release:m(e,"filterRelease"),limit:m(e,"limit"),offset:m(e,"offset")}}function ie(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return Tt(e)}function q(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function Xr(e){let t=ie(e.kind),r=ie(e.exemptIsolate),n=ie(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:q(e.maxDepth),limit:q(e.limit),after:c(e,"after"),direction:c(e,"direction"),maxPaths:q(e.maxPaths),sample:q(e.sample),...r===void 0?{}:{exemptIsolate:r},...n===void 0?{}:{exemptIsolateType:n},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function ke(e){let t=Te(e);return e.ids!==void 0&&(t.ids=Z(e.ids)),t}function Zr(e){return{status:c(e,"filterStatus"),list:g(e.list)?ke(e.list):ae(e),reason:c(e,"reason"),completedAt:c(e,"completedAt")??c(e,"completed_at"),resolution:c(e,"resolution"),expectedResult:c(e,"expectedResult")??c(e,"expected_result")??c(e,"expected"),actualResult:c(e,"actualResult")??c(e,"actual_result")??c(e,"actual"),validateClose:c(e,"validateClose")??c(e,"validate_close"),author:c(e,"author"),message:c(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var se=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function Se(e){let t={};for(let[r,n]of Object.entries(e))se.has(r)||(t[r]=n);return we(t)}function we(e){return Ie(e,"update")}function Ie(e,t){let r=Me(e,t),n=W[t],o=new Set([...n.parameters,...N].filter(({booleanish:i})=>i===!0).map(({param:i})=>i));for(let{keys:i}of n.repeatables)for(let a of i)typeof r[a]=="string"&&(r[a]=[r[a]]);for(let i of n.strings)for(let a of i.keys){let s=r[a];(typeof s=="number"&&Number.isFinite(s)||s===!1&&o.has(a))&&(r[a]=String(s))}return t==="create"?{..._e(r,{requireType:!1})}:Oe(r)}var St=new Map(w.flatMap(({target:e,keys:t})=>t.map(r=>[r,e])));function Ct(e){return e.startsWith("filter")||e==="ids"||e==="limit"||e==="offset"}function Ce(e,t){throw new p(`update-many "${e}" cannot be null. No changes were made.`,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:e,required:t})}function Rt(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!se.has(t)))}function Re(e,t,r){if(!e)return;let n=g(t.list)?t.list:{},o=g(t.update)?t.update:void 0,i=Object.keys(t).find(s=>t[s]===null&&(o!==void 0||se.has(s)||Ct(s)))??Object.keys(n).filter(s=>n[s]===null).map(s=>`list.${s}`)[0];i!==void 0&&Ce(i,`"${i}" selects rows or controls the run: omit it or pass a value. To clear an item field, pass null on the field itself${o===void 0?"":" inside update"}.`);let a=o??Rt(t);for(let[s,u]of Object.entries(a)){if(u!==null)continue;let h=St.get(s);h===void 0&&Ce(s,`Pass unset: ["${s}"] to clear a field, or omit "${s}".`),r[h]=null}}var Nt=["author","message"];function Et(e,t){let r=Object.fromEntries(Nt.filter(n=>typeof e[n]=="string"&&t[n]===void 0).map(n=>[n,e[n]]));return e.force===!0&&t.force===void 0&&(r.force=!0),Object.keys(r).length===0?t:_(t,{...t,...r})}function Qr(e,t=!1){if(g(e.list)||g(e.update)){let n=g(e.update)?Et(e,e.update):Se(e),o=Y(e,we(n));return Re(t,e,o),{status:m(e,"filterStatus"),list:g(e.list)?ke(e.list):ae(e),update:de(n,o),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}let r=Y(e,Se(e));return Re(t,e,r),{status:m(e,"filterStatus"),list:ae(e),update:r,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}function Ne(e){return"expectHash"in e||"expect_hash"in e}function en(e){if(!Ne(e)&&!(g(e.options)&&Ne(e.options)))return{expectHash:void 0,dispatchArgs:e};let{expectHash:t,expect_hash:r,...n}=e,o=g(n.options)?n.options:{},{expectHash:i,expect_hash:a,...s}=o,u=[t,r,i,a].filter(M=>M!==void 0),h=u.length>1?u.flatMap(M=>Array.isArray(M)?M:[M]):u[0],A=_(e,"options"in n?{...n,options:g(n.options)?_(n.options,s):n.options}:n);return{expectHash:h,dispatchArgs:A}}export{bt as a,v as b,Mt as c,kt as d,wt as e,Ke as f,ee as g,Le as h,Dt as i,Ue as j,Be as k,je as l,Lt as m,D as n,te as o,Wt as p,He as q,Jt as r,We as s,L as t,Ur as u,c as v,m as w,Br as x,g as y,jr as z,Gr as A,$r as B,xe as C,Me as D,Vr as E,Hr as F,zr as G,Ot as H,qr as I,Yr as J,Tt as K,Wr as L,Jr as M,ae as N,Xr as O,Zr as P,se as Q,we as R,Qr as S,en as T};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{S as E,T as j,U as G,V as k,W as w,X as $,Y as I,a as le,ba as F,g as P,i as J,o as N,q as U,s as B}from"./chunk-E2IWEJL5.js";import{E as ce,F as ue,H as _,I as de,W as V,fa as Z,o as K,oa as fe,p as X}from"./chunk-LWIIDPAV.js";import{L as S}from"./chunk-L6NOGC4N.js";import{A as p,z as f}from"./chunk-IRYNVGKH.js";var Fe=new Set(["none","null"]);function bt(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function v(e){return e===void 0?!1:Fe.has(e.trim().toLowerCase())}function Mt(e,t,r){if(!v(e))return;let n=r?` ${r}`:"";throw new p(`${t} no longer accepts "none" or "null".${n}`.trim(),f.USAGE)}function kt(e,t,r){if(!e||e.length===0||X(e)||!e.some(i=>v(i)))return;let o=r?` ${r}`:"";throw new p(`${t} no longer accepts "none" or "null".${o}`.trim(),f.USAGE)}function wt(e,t){for(let r of t){let n=e[r.optionKey];if(!Array.isArray(n)||n.length===0)continue;if(!n.every(s=>typeof s=="string"))throw new p(`${r.valueFlag} entries must be strings.`,f.USAGE);if(X(n))continue;let o=n;if(!o.some(s=>v(s)))continue;if(o.filter(s=>!v(s)).length>0)throw new p(`Cannot mix legacy clear token "none"/"null" with concrete ${r.valueFlag} entries. Use ${r.clearFlag} to clear or provide explicit entries.`,f.USAGE);e[r.optionKey]=void 0,e[r.clearFlagKey]=!0,r.disableFlagKey&&(e[r.disableFlagKey]=!1)}return e}var Ke=["close_reason","close-reason"],pe=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],me=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],De=[...pe,...me],ye=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],ee=[...De,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...ye],Le=[...pe,{canonical:"close-reason",aliases:Ke,optionKey:"closeReason",metadataKey:"close_reason"},...me,...ye],Pe=new Set(["none","null","-"]);function ge(e){return e==="create"?ee:Le}function H(e,t){let r=t.unset;if(r!==void 0&&typeof r!="string"&&!Array.isArray(r))return;let n=[];for(let o of ge(e))o.optionKey==="author"||!Object.hasOwn(t,o.optionKey)||t[o.optionKey]!==null||(Reflect.deleteProperty(t,o.optionKey),n.push(o.canonical));n.length!==0&&(t.unset=[...r===void 0?[]:typeof r=="string"?[r]:r,...n])}function Q(e){return typeof e=="string"&&Pe.has(e.trim().toLowerCase())}function Dt(e,t,r,n){return r?ge(e).flatMap(o=>{let i=t[o.optionKey],a=n[o.metadataKey];return Q(i)&&(Q(a)||Array.isArray(a)&&a.some(Q))?[`literal_sentinel_stored:${o.canonical}:${i.trim()}`]:[]}):[]}function Ue(e,t){return e.flatMap(r=>r.includes(",")&&t(r)?[r]:r.split(","))}function Be(e){let t=new Set,r=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:r};let n=Ue(e.raw,o=>e.resolveDefinition(o.trim().toLowerCase())!==void 0);for(let o of n){let i=o.trim().toLowerCase();if(!i)throw new p("--unset values must not be empty; name each field once, for example --unset parent,release",f.USAGE);if(v(i))throw new p('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',f.USAGE);let a=e.resolveDefinition(i);if(!a)throw new p(`Unsupported --unset field "${o}". Supported fields: ${e.supportedFields}`,f.USAGE);t.add(a.metadataKey),r.add(a.optionKey)}return{metadataKeys:t,optionKeys:r}}function je(e,t,r){let n=e.trim().toLowerCase();if(!r)return;let o=r.command_to_fields?.get(t)??[];for(let i of o){if(i.allow_unset===!1)continue;let a=new Set;if(typeof i.key=="string"&&i.key.length>0&&a.add(i.key.toLowerCase()),typeof i.metadata_key=="string"&&i.metadata_key.length>0&&a.add(i.metadata_key.toLowerCase()),typeof i.cli_flag=="string"&&i.cli_flag.length>0&&(a.add(i.cli_flag.replaceAll("-","_").toLowerCase()),a.add(i.cli_flag.toLowerCase())),Array.isArray(i.cli_aliases))for(let s of i.cli_aliases)typeof s!="string"||s.length===0||(a.add(s.replaceAll("-","_").toLowerCase()),a.add(s.toLowerCase()));if(a.has(n))return{optionKey:i.key,metadataKey:i.metadata_key}}}var Ge=(()=>{let e=new Map;for(let t of ee)for(let r of t.aliases)e.set(r,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),$e=ee.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function Lt(e,t){return Be({raw:e,supportedFields:$e,resolveDefinition:r=>Ge.get(r)??je(r,"create",t)})}var Ve={create:'client.create({ type: "Task", title: "Example", createMode: "progressive" })',update:'client.update(id, { estimatedMinutes: "45", force: false })',append:'client.append(id, "Body text")',reopen:'client.reopen(id, "The work recurred", { expectedResult: "Verified recovery" })'};function x(e,t,r){let n=`${e} ${t} must be ${r}.`;throw new p(n,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",field:t,changed:!1,required:n,examples:[Ve[e]]})}function D(e,t,r){typeof e!="string"&&x(t,r,"a string")}function te(e,t){(e===null||typeof e!="object"||Array.isArray(e))&&x(t,"options","an object")}function he(e,t){(e==="append"||e==="update")&&t.id!==void 0&&D(t.id,e,"id"),e==="item-reopen"&&(t.id!==void 0&&D(t.id,"reopen","id"),t.reason!==void 0&&D(t.reason,"reopen","reason"),t.options!==void 0&&He(t.options))}function Wt(e){te(e,"append");for(let t of["body","author","message"])e[t]!==void 0&&D(e[t],"append",t);e.force!==void 0&&typeof e.force!="boolean"&&x("append","force","a boolean")}function He(e){te(e,"reopen");for(let t of F["item-reopen"].optional){let r=e[t];r!==void 0&&(S(Reflect.get(E,t)).type==="boolean"?typeof r!="boolean"&&x("reopen",t,"a boolean"):D(r,"reopen",t))}}function ze(e,t){return e?t?"a string or string array":"a string array":"a string"}function qe(e,t,r,n,o,i){r===void 0||typeof r=="string"&&(!o||i)||n==="priority"&&typeof r=="number"&&Number.isFinite(r)||o&&Array.isArray(r)&&Array.from(r).every(a=>typeof a=="string")||x(e,t,ze(o,i))}function Ye(e,t,r){let n=e==="create"?U:B;for(let{param:o}of[...n,...N,{param:"force"}]){if(S(Reflect.get(E,o)).type!=="boolean")continue;let i=r.find(a=>a.keys.includes(o))?.keys??[o];for(let a of i)t[a]!==void 0&&typeof t[a]!="boolean"&&x(e,a,"a boolean")}}function re(e,t,r=!0,n=!1){let o=e==="create"?j:w;for(let{target:i,keys:a,repeatable:s}of o)if(S(Reflect.get(E,i)).type!=="boolean")for(let u of a){let A=n&&u!==i,h=s===!0&&(i!=="acceptanceCriteria"||A);qe(e,u,t[u],i,h,r||A)}Ye(e,t,o)}function Jt(e,t){te(t,e);let r=ce(t),n=K(r);return n||H(e,r),re(e,r,!1,n),r}import{Option as Ar}from"commander";function O(e,t,r){if(typeof r!="string")return;let n=r.trim();n.length!==0&&e.push(t,n)}function y(e,t,r){r===!0&&e.push(t)}function C(e,t,r){if(Array.isArray(r))for(let n of r){if(typeof n!="string")continue;let o=n.trim();o.length!==0&&e.push(t,o)}}function We(e,t){let r=["test",e,"--run","--json","--progress"];return C(r,"--add",t.add),C(r,"--add-json",t.addJson),C(r,"--remove",t.remove),C(r,"--remove-index",Array.isArray(t.removeIndex)?t.removeIndex.map(n=>typeof n=="number"?String(n):n):t.removeIndex),O(r,"--match",t.match),O(r,"--only-index",typeof t.onlyIndex=="number"?String(t.onlyIndex):t.onlyIndex),y(r,"--only-last",t.onlyLast),y(r,"--full-history",t.fullHistory),C(r,"--measure",t.measure),O(r,"--metric-below",t.metricBelow),O(r,"--metric-diff",t.metricDiff),Je(r,t),O(r,"--author",t.author),O(r,"--message",t.message),y(r,"--force",t.force),r}function Je(e,t){O(e,"--timeout",t.timeout),C(e,"--env-set",t.envSet),C(e,"--env-clear",t.envClear),y(e,"--shared-host-safe",t.sharedHostSafe),O(e,"--pm-context",t.pmContext),y(e,"--override-linked-pm-context",t.overrideLinkedPmContext),O(e,"--workspace-context",t.workspaceContext),y(e,"--override-linked-workspace-context",t.overrideLinkedWorkspaceContext),y(e,"--allow-untrusted-linked-tests",t.allowUntrustedLinkedTests),y(e,"--fail-on-context-mismatch",t.failOnContextMismatch),y(e,"--fail-on-skipped",t.failOnSkipped),y(e,"--fail-on-empty-test-run",t.failOnEmptyTestRun),y(e,"--require-assertions-for-pm",t.requireAssertionsForPm),y(e,"--check-context",t.checkContext),y(e,"--full-output",t.fullOutput),y(e,"--auto-pm-context",t.autoPmContext)}function Ae(e,t){let r=[],n=new Set;for(let o of t.keys){if(!Object.hasOwn(e,o))continue;let i=e[o];if(i!=null){if(typeof i=="string"){r.push(i);continue}if(!Array.isArray(i)||!i.every(a=>typeof a=="string"))return;n.has(i)||(n.add(i),r.push(...i))}}return r.length>0?r.join("; "):void 0}function R(e,t){return e.find(n=>n.target===t)??{target:t,keys:[t]}}function l(e,t){return e[t]===!0?!0:void 0}function T(e,t){return e[t]===!1?!0:void 0}function z(e,t){return t.some(r=>e[r]===!0)?!0:void 0}function ne(e,t){for(let[r,n]of Object.entries(t))r==="__proto__"||r==="constructor"||r==="prototype"||Object.hasOwn(e,r)||(e[r]=n)}function _e(e,t={}){let r=a=>P(e,R(G,a)),n=a=>J(e,R(k,a)),o=r("type");if(t.requireType!==!1&&o===void 0)throw new p("Missing required option --type <value>. Why required: create resolves runtime schema fields/workflow from item type. Retry: add --type <built-in or configured custom type> (example: --type Task).",f.USAGE);let i={title:r("title"),description:r("description"),type:o,template:r("template"),createMode:r("createMode"),defer:n("defer"),deferReason:r("deferReason"),schedulePreset:r("schedulePreset"),status:r("status"),closeReason:r("closeReason"),completedAt:r("completedAt"),priority:r("priority"),tags:r("tags"),addTags:n("addTags"),body:r("body"),deadline:r("deadline"),estimatedMinutes:r("estimatedMinutes"),acceptanceCriteria:Ae(e,R(k,"acceptanceCriteria")),definitionOfReady:r("definitionOfReady"),order:r("order"),rank:r("rank"),goal:r("goal"),objective:r("objective"),value:r("value"),impact:r("impact"),outcome:r("outcome"),whyNow:r("whyNow"),author:r("author"),message:r("message"),assignee:r("assignee"),parent:r("parent"),inheritFocus:e.inheritFocus,allowMissingParent:z(e,["allowMissingParent","allow_missing_parent"])===!0,allowUnresolvedDeps:z(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,allowDuplicate:l(e,"allowDuplicate")===!0,reviewer:r("reviewer"),risk:r("risk"),confidence:r("confidence"),sprint:r("sprint"),release:r("release"),blockedBy:r("blockedBy"),blockedReason:r("blockedReason"),unblockNote:r("unblockNote"),reporter:r("reporter"),severity:r("severity"),environment:r("environment"),reproSteps:r("reproSteps"),resolution:r("resolution"),expectedResult:r("expectedResult"),actualResult:r("actualResult"),affectedVersion:r("affectedVersion"),fixedVersion:r("fixedVersion"),component:r("component"),regression:e.regression===!0?"true":r("regression"),customerImpact:r("customerImpact"),dep:n("dep"),comment:n("comment"),note:n("note"),learning:n("learning"),file:n("file"),test:n("test"),doc:n("doc"),reminder:n("reminder"),event:n("event"),typeOption:n("typeOption"),field:n("field"),unset:n("unset"),clearDeps:l(e,"clearDeps"),clearComments:l(e,"clearComments"),clearNotes:l(e,"clearNotes"),clearLearnings:l(e,"clearLearnings"),clearFiles:l(e,"clearFiles"),clearTests:l(e,"clearTests"),clearDocs:l(e,"clearDocs"),clearReminders:l(e,"clearReminders"),clearEvents:l(e,"clearEvents"),clearTypeOptions:l(e,"clearTypeOptions")};return ne(i,e),_(e,i)}function Oe(e){let t=o=>P(e,R($,o)),r=o=>J(e,R(I,o)),n={title:t("title"),description:t("description"),body:t("body"),status:t("status"),closeReason:t("closeReason"),priority:t("priority"),type:t("type"),tags:t("tags"),addTags:r("addTags"),removeTags:r("removeTags"),deadline:t("deadline"),estimatedMinutes:t("estimatedMinutes"),acceptanceCriteria:Ae(e,R(I,"acceptanceCriteria")),addAc:r("addAc"),removeAc:r("removeAc"),definitionOfReady:t("definitionOfReady"),order:t("order"),rank:t("rank"),goal:t("goal"),objective:t("objective"),value:t("value"),impact:t("impact"),outcome:t("outcome"),whyNow:t("whyNow"),author:t("author"),message:t("message"),force:!!e.force,ownershipMetadataBypass:e.ownershipMetadataBypass===!0?!0:void 0,ownershipDependencyBypass:e.ownershipDependencyBypass===!0?!0:void 0,assignee:t("assignee"),parent:t("parent"),allowUnresolvedDeps:z(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,reviewer:t("reviewer"),risk:t("risk"),confidence:t("confidence"),sprint:t("sprint"),release:t("release"),blockedBy:t("blockedBy"),blockedReason:t("blockedReason"),unblockNote:t("unblockNote"),reporter:t("reporter"),severity:t("severity"),environment:t("environment"),reproSteps:t("reproSteps"),resolution:t("resolution"),expectedResult:t("expectedResult"),actualResult:t("actualResult"),affectedVersion:t("affectedVersion"),fixedVersion:t("fixedVersion"),component:t("component"),regression:e.regression===!0?"true":t("regression"),customerImpact:t("customerImpact"),dep:r("dep"),depRemove:r("depRemove"),replaceDeps:l(e,"replaceDeps"),replaceTests:l(e,"replaceTests"),replaceFiles:l(e,"replaceFiles"),replaceDocs:l(e,"replaceDocs"),comment:r("comment"),note:r("note"),learning:r("learning"),file:r("file"),test:r("test"),doc:r("doc"),reminder:r("reminder"),event:r("event"),typeOption:r("typeOption"),field:r("field"),unset:r("unset"),clearDeps:l(e,"clearDeps"),clearComments:l(e,"clearComments"),clearNotes:l(e,"clearNotes"),clearLearnings:l(e,"clearLearnings"),clearFiles:l(e,"clearFiles"),clearTests:l(e,"clearTests"),clearDocs:l(e,"clearDocs"),clearReminders:l(e,"clearReminders"),clearEvents:l(e,"clearEvents"),clearTypeOptions:l(e,"clearTypeOptions")};return ne(n,e),_(e,n)}function d(e,t){let r=R(le,t),n=P(e,r);if(n!==void 0)return n;for(let o of r.keys){let i=e[o];if(Array.isArray(i)){let a=i.filter(s=>typeof s=="string");if(a.length>0)return a.join(",")}if(t==="ids"&&typeof i=="string")return i;if(typeof i=="number"&&Number.isFinite(i))return String(i)}}function Xe(e){let t=l(e,"filterFilesMissing"),r=l(e,"filterDocsMissing");return{filterReviewerMissing:l(e,"filterReviewerMissing"),filterRiskMissing:l(e,"filterRiskMissing"),filterConfidenceMissing:l(e,"filterConfidenceMissing"),filterSprintMissing:l(e,"filterSprintMissing"),filterReleaseMissing:l(e,"filterReleaseMissing"),hasNotes:l(e,"hasNotes"),hasLearnings:l(e,"hasLearnings"),hasFiles:l(e,"hasFiles"),hasDocs:l(e,"hasDocs"),hasTests:l(e,"hasTests"),hasComments:l(e,"hasComments"),hasDeps:l(e,"hasDeps"),hasBody:l(e,"hasBody"),hasLinkedCommand:l(e,"hasLinkedCommand"),noNotes:T(e,"notes"),noLearnings:T(e,"learnings"),noFiles:T(e,"files")??t,filterFilesMissing:t,noDocs:T(e,"docs")??r,filterDocsMissing:r,noTests:T(e,"tests"),noComments:T(e,"comments"),noDeps:T(e,"deps"),emptyBody:l(e,"emptyBody"),noLinkedCommand:T(e,"linkedCommand")}}function Te(e){let t={status:d(e,"status"),type:d(e,"type"),tag:d(e,"tag"),priority:d(e,"priority"),deadlineBefore:d(e,"deadlineBefore"),deadlineAfter:d(e,"deadlineAfter"),updatedAfter:d(e,"updatedAfter"),updatedBefore:d(e,"updatedBefore"),createdAfter:d(e,"createdAfter"),createdBefore:d(e,"createdBefore"),today:l(e,"today"),recent:l(e,"recent"),ids:d(e,"ids"),assignee:d(e,"assignee"),assigneeFilter:d(e,"assigneeFilter"),parent:d(e,"parent"),sprint:d(e,"sprint"),release:d(e,"release"),limit:d(e,"limit"),offset:d(e,"offset"),noTruncate:T(e,"truncate"),includeBody:l(e,"includeBody"),strictRead:l(e,"strictRead"),compact:l(e,"compact"),brief:l(e,"brief"),full:l(e,"full"),fields:d(e,"fields"),sort:d(e,"sort"),order:d(e,"order"),tree:l(e,"tree"),treeDepth:d(e,"treeDepth"),filterAcMissing:l(e,"filterAcMissing"),filterEstimatesMissing:z(e,["filterEstimatesMissing","filterEstimateMissing"]),filterResolutionMissing:l(e,"filterResolutionMissing"),filterMetadataMissing:l(e,"filterMetadataMissing"),...Xe(e)};return ne(t,e),t}var Ze=Symbol("pm.mcp-mutation-transport"),Qe=new Set(["create","update","append"]),W={create:{parameters:U,aliases:j,strings:G,repeatables:k},update:{parameters:B,aliases:w,strings:$,repeatables:I}},et=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function L(e){return Ze in e}function Y(e,t){return L(e)?ue(t):_(e,t)}function Ur(e,t,r=[]){let n=_(e,{...e,...t});for(let o of r)Reflect.deleteProperty(n,o);return n}function c(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r:void 0}function m(e,t){let r=e[t];return typeof r=="string"?r.trim().length>0?r:void 0:typeof r=="number"&&Number.isFinite(r)?String(r):void 0}function Br(e,t){let r=e[t];return typeof r=="string"?r:typeof r=="number"&&Number.isFinite(r)?String(r):void 0}function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jr(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new p(`${t} must be a finite integer.`,f.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let r=Number(e);if(!Number.isInteger(r))throw new p(`${t} must be a finite integer.`,f.USAGE);return r}}function Gr(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:c(e,"limit")??c(t,"limit")}function $r(e){let t=c(e,"outputFormat");return{json:!0,quiet:!0,author:c(e,"author"),path:c(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:c(e,"outputInclude"),outputLimit:m(e,"outputLimit"),outputBudget:m(e,"outputBudget"),outputSession:c(e,"outputSession"),outputCursor:c(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var Ee=new Set(["tags","blockedBy","blocked_by","skills","fields"]),ve=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),tt=new Set([...ve].filter(e=>e!=="file")),rt=new Set(["files","files-discover","docs","test","test-all"]),oe=new Set(["comments","notes","learnings"]);function nt(e,t){if(!(!oe.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new p(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,f.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var it=new Set(["claim","release","start-task","pause-task","close-task"]),xe={history:["order"],"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate","inheritFocus"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable","takeoverStale"],"start-task":["takeoverStale"],release:["pause","handoff"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun","offline","fields","scope"],package:["dryRun","offline","fields","scope"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},at=new Set(["context","get","list","next","search","comments","notes","learnings","files","docs","test"]),ot=new Set(["query","keywords","id","text"]);function st(e){return at.has(e)?F[e].optional.filter(t=>!ot.has(t)):[]}var lt=new Set(["claim","start-task","comments","notes","learnings","files","docs","test"]);function ct(e,t){if(!lt.has(e??""))return t;let r={...t};for(let n of F[e].optional){let o=n.replace(/[A-Z]/gu,i=>`_${i.toLowerCase()}`);o===n||r[o]===void 0||(r[n]??=r[o],delete r[o])}return r}function ut(e,t,r){if(!oe.has(e??""))return r;let n=r,o=n.text??t.text;if(o===void 0)return n;if(n.add!==void 0&&n.add!==o){let a=e.replace(/s$/u,"");throw new p(`Specify ${a} text either as text or with add, not both.`,f.USAGE,{code:"annotation_text_source_conflict",field:"text",required:`Pass the ${a} text once: text and add are the same source.`})}let i={...n,add:o};return delete i.text,i}function dt(e,t){let r=t.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return e[t]!==void 0||e[r]!==void 0}function ft(e){return[...xe[e]??[],...st(e),...be]}var be=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor","outputRowContract"];function Me(e,t=""){let r={},n=rt.has(t),o=t==="files"||t==="files-discover"||t==="docs",i=oe.has(t)?tt:ve;for(let[a,s]of Object.entries(e)){if(Array.isArray(s)&&Ee.has(a)){r[a]=s.join(",");continue}if(a==="note"&&o){r[a]=s;continue}if(typeof s=="string"&&i.has(a)){r[a]=[s];continue}if(typeof s=="string"&&n&&(a==="add"||a==="remove")){r[a]=[s];continue}r[a]=s}return Object.assign(r,Object.fromEntries(Object.getOwnPropertySymbols(e).map(a=>[a,Reflect.get(e,a)]))),r}function pt(e,t,r){let n=c(e,"author");return n!==void 0?n:r!==void 0&&it.has(r)?c(e,"assignee")??c(t,"assignee"):void 0}function mt(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function yt(e,t,r){let n={},o=W[e],i=new Set([...o.parameters.map(({param:a})=>a),...N.map(({param:a})=>a),...xe[e],...be,"force"]);for(let a of i){let s=o.aliases.find(u=>u.keys.includes(a))?.keys??[a];t[a]===void 0||s.some(u=>r[u]!==void 0)||(n[a]=t[a])}return n}function b(e,t){throw new p(`Invalid MCP ${e} value for "${t}". No changes were made.`,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:t,required:`Provide valid ${e} field values and an options object; inspect the pm_${e} input schema for supported types.`})}function gt(e,t,r){let n=W[e],o=[...n.parameters,...N,{param:"force"}];for(let{param:i}of o){if(S(E[i]).type!=="boolean")continue;let s=(n.aliases.find(u=>u.keys.includes(i))?.keys??[i]).find(u=>r[u]!==void 0&&typeof r[u]!="boolean");s!==void 0&&b(e,s)}for(let i of["idOnly","fullChangedFields"])t[i]!==void 0&&typeof t[i]!="boolean"&&b(e,i)}function ht(e,t,r){t.options!==void 0&&!g(t.options)&&b(e,"options"),gt(e,t,r);for(let a of Ee){let s=r[a];Array.isArray(s)&&s.some(u=>typeof u!="string")&&b(e,a)}let n=Ie(r,e),o=W[e];for(let{keys:a,target:s}of o.strings)a.some(u=>r[u]!==void 0)&&n[s]===void 0&&b(e,s);let i=o.repeatables.flatMap(({keys:a})=>a).find(a=>{let s=r[a];return s!==void 0&&typeof s!="string"&&(!Array.isArray(s)||s.some(u=>typeof u!="string"))});return i!==void 0&&b(e,i),n}function At(e,t,r,n,o){let i=(t==="create"||t==="update")&&L(e),a={...i?yt(t,e,n):r,...n};if((t==="create"||t==="update")&&!i){let s=g(e.options)&&K(e.options);s||H(t,a),re(t,a,!0,s)}return i?ht(t,e,a):o?Me(a,t):a}function _t(e,t){return!Qe.has(e??"")||K(t)?t:fe(t)}function Vr(e,t,{nativeAction:r=!0}={}){he(t,e);let n=g(e.options)?e.options:void 0,o=S(e.options),i={},a=h=>{dt(o,h)||e[h]===void 0||(i[h]=e[h])};for(let h of ft(t??""))a(h);t!==void 0&&L(e)&&nt(t,o);let s=ut(t,e,ct(t,At(e,t,i,o,r)));if(t==="history-attest"&&L(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new p("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",f.USAGE);let u=L(e)?e:n??e,A=Y(u,mt(s,pt(e,s,t)));return _t(t,A)}function Hr(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function zr(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function Ot(e){let t=[],r=!0;for(let n of e.trim().toLowerCase()){if(n>="a"&&n<="z"||n>="0"&&n<="9"){t.push(n),r=!1;continue}r||(t.push("-"),r=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function qr(e){return!et.has(Ot(e))}function Yr(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function Wr(e,t){return c(e,"subcommand")??c(t,"subcommand")}function Tt(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function Jr(e,t){let r=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),n={};for(let[i,a]of Object.entries(e))r.has(i)||(n[i]=a);let o={...n,...t};return delete o.args,delete o.author,o}function Xr(e,t){let r=Y(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:r}}function ae(e){return{type:m(e,"filterType"),tag:m(e,"filterTag"),priority:m(e,"filterPriority"),deadlineBefore:m(e,"filterDeadlineBefore"),deadlineAfter:m(e,"filterDeadlineAfter"),updatedAfter:m(e,"filterUpdatedAfter"),updatedBefore:m(e,"filterUpdatedBefore"),createdAfter:m(e,"filterCreatedAfter"),createdBefore:m(e,"filterCreatedBefore"),ids:Z(e.ids),assignee:m(e,"filterAssignee"),assigneeFilter:m(e,"filterAssigneeFilter")??m(e,"filterAssignee_filter"),parent:m(e,"filterParent"),sprint:m(e,"filterSprint"),release:m(e,"filterRelease"),limit:m(e,"limit"),offset:m(e,"offset")}}function ie(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return Tt(e)}function q(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function Zr(e){let t=ie(e.kind),r=ie(e.exemptIsolate),n=ie(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:q(e.maxDepth),limit:q(e.limit),after:c(e,"after"),direction:c(e,"direction"),maxPaths:q(e.maxPaths),sample:q(e.sample),...r===void 0?{}:{exemptIsolate:r},...n===void 0?{}:{exemptIsolateType:n},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function ke(e){let t=Te(e);return e.ids!==void 0&&(t.ids=Z(e.ids)),t}function Qr(e){return{status:c(e,"filterStatus"),list:g(e.list)?ke(e.list):ae(e),reason:c(e,"reason"),completedAt:c(e,"completedAt")??c(e,"completed_at"),resolution:c(e,"resolution"),expectedResult:c(e,"expectedResult")??c(e,"expected_result")??c(e,"expected"),actualResult:c(e,"actualResult")??c(e,"actual_result")??c(e,"actual"),validateClose:c(e,"validateClose")??c(e,"validate_close"),author:c(e,"author"),message:c(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var se=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function Se(e){let t={};for(let[r,n]of Object.entries(e))se.has(r)||(t[r]=n);return we(t)}function we(e){return Ie(e,"update")}function Ie(e,t){let r=Me(e,t),n=W[t],o=new Set([...n.parameters,...N].filter(({booleanish:i})=>i===!0).map(({param:i})=>i));for(let{keys:i}of n.repeatables)for(let a of i)typeof r[a]=="string"&&(r[a]=[r[a]]);for(let i of n.strings)for(let a of i.keys){let s=r[a];(typeof s=="number"&&Number.isFinite(s)||s===!1&&o.has(a))&&(r[a]=String(s))}return t==="create"?{..._e(r,{requireType:!1})}:Oe(r)}var St=new Map(w.flatMap(({target:e,keys:t})=>t.map(r=>[r,e])));function Ct(e){return e.startsWith("filter")||e==="ids"||e==="limit"||e==="offset"}function Ce(e,t){throw new p(`update-many "${e}" cannot be null. No changes were made.`,f.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:e,required:t})}function Rt(e){return Object.fromEntries(Object.entries(e).filter(([t])=>!se.has(t)))}function Re(e,t,r){if(!e)return;let n=g(t.list)?t.list:{},o=g(t.update)?t.update:void 0,i=Object.keys(t).find(s=>t[s]===null&&(o!==void 0||se.has(s)||Ct(s)))??Object.keys(n).filter(s=>n[s]===null).map(s=>`list.${s}`)[0];i!==void 0&&Ce(i,`"${i}" selects rows or controls the run: omit it or pass a value. To clear an item field, pass null on the field itself${o===void 0?"":" inside update"}.`);let a=o??Rt(t);for(let[s,u]of Object.entries(a)){if(u!==null)continue;let A=St.get(s);A===void 0&&Ce(s,`Pass unset: ["${s}"] to clear a field, or omit "${s}".`),r[A]=null}}var Nt=["author","message"];function Et(e,t){let r=Object.fromEntries(Nt.filter(n=>typeof e[n]=="string"&&t[n]===void 0).map(n=>[n,e[n]]));return e.force===!0&&t.force===void 0&&(r.force=!0),Object.keys(r).length===0?t:_(t,{...t,...r})}function en(e,t=!1){if(g(e.list)||g(e.update)){let n=g(e.update)?Et(e,e.update):Se(e),o=Y(e,we(n));return Re(t,e,o),{status:m(e,"filterStatus"),list:g(e.list)?ke(e.list):ae(e),update:de(n,o),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}let r=Y(e,Se(e));return Re(t,e,r),{status:m(e,"filterStatus"),list:ae(e),update:r,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:V(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}function Ne(e){return"expectHash"in e||"expect_hash"in e}function tn(e){if(!Ne(e)&&!(g(e.options)&&Ne(e.options)))return{expectHash:void 0,dispatchArgs:e};let{expectHash:t,expect_hash:r,...n}=e,o=g(n.options)?n.options:{},{expectHash:i,expect_hash:a,...s}=o,u=[t,r,i,a].filter(M=>M!==void 0),A=u.length>1?u.flatMap(M=>Array.isArray(M)?M:[M]):u[0],h=_(e,"options"in n?{...n,options:g(n.options)?_(n.options,s):n.options}:n);return{expectHash:A,dispatchArgs:h}}export{bt as a,v as b,Mt as c,kt as d,wt as e,Ke as f,ee as g,Le as h,Dt as i,Ue as j,Be as k,je as l,Lt as m,D as n,te as o,Wt as p,He as q,Jt as r,We as s,L as t,Ur as u,c as v,m as w,Br as x,g as y,jr as z,Gr as A,$r as B,xe as C,Me as D,Vr as E,Hr as F,zr as G,Ot as H,qr as I,Yr as J,Wr as K,Tt as L,Jr as M,Xr as N,ae as O,Zr as P,Qr as Q,se as R,we as S,en as T,tn as U};
|
|
2
|
+
//# sourceMappingURL=chunk-NEK7RX3N.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{r as D,s as V}from"./chunk-
|
|
1
|
+
import{r as D,s as V}from"./chunk-KNST4PGF.js";import{d as g,j as q,l as k}from"./chunk-3LHBKFPD.js";import{Ob as N,lf as j,of as z,rf as M,t as C,y as m}from"./chunk-L6NOGC4N.js";import{c as O}from"./chunk-WDHNPNHX.js";import{A as x,E as _,J as L,z as S}from"./chunk-IRYNVGKH.js";import{constants as p}from"node:fs";import{lstat as A,mkdir as $,open as P}from"node:fs/promises";import h from"node:path";function E(r,e){if(typeof r!="string"||r.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return r.trim()}function R(r,e){let t=e.require(r.kind),n=t.direction==="undirected"?[r.source,r.target].sort().join("\0"):`${r.source}\0${r.target}`;return`${t.kind}\0${n}`}function Q(r){return Object.freeze({...r,...r.payload===void 0?{}:{payload:Object.freeze(structuredClone(r.payload))}})}function U(r,e,t,n){let i=t.require(r.kind),o=n.outgoingOne.get(`${i.kind}\0${r.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${i.kind}`);let s=n.incomingOne.get(`${i.kind}\0${r.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${i.kind}`);let c=R(r,t),d=n.identities.get(c);if(d!==void 0&&d!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function Y(r){let e=new Map;for(let t of r)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function X(r,e,t){if(r.expectedVersion!==void 0&&r.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${r.expectedVersion}, current ${e}`);let n=E(r.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(r.action!=="add"&&r.action!=="remove"&&r.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${r.action}`);if(!Number.isFinite(Date.parse(r.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(r.relationshipId,"relationshipId"),author:E(r.author,"author"),timestamp:new Date(r.timestamp).toISOString()}}function Z(r,e,t,n,i,o){let s=t.has(e);if(r.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(r.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(r.action==="remove")return;if(!r.edge)throw new TypeError(`Relationship ${r.action} event requires an edge`);let c=typeof r.edge.source=="string"?r.edge.source.trim():"",d=typeof r.edge.target=="string"?r.edge.target.trim():"";if(!n.has(c)||!n.has(d))throw new TypeError(`Relationship endpoint not found: ${c} -> ${d}`);let a=new m([c,d],[r.edge],i).edges()[0];return U(a,e,i,o),Q(a)}var I=class{#t;#n;#i=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#n=t.registry??C()}get version(){return this.#i.length}events(){return Object.freeze([...this.#i])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,i=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(i)||i<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=i)yield Object.freeze(this.#i.slice(o,Math.min(o+i,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let i=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let d of c)i=t(i,d),o+=1,s=d;return Object.freeze({state:i,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#n.require(t.kind);this.#r.identities.set(R(t,this.#n),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#n.require(e.kind);this.#r.identities.delete(R(e,this.#n)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=X(e,this.version,this.#o),n=this.#e.get(t.relationshipId),i=Z(e,t.relationshipId,this.#e,this.#t,this.#n,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...i===void 0?{}:{edge:i},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#i.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,i),this.#s(t.relationshipId,i)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#i.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#i.slice(0,o)}let n=Y(t),i=new m(this.#t,n.values(),this.#n);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:i.edges(),graph:i})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=j("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(z(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let i=M(this.#i.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:i.rows,hasMore:i.has_more,...i.next_cursor?{nextCursor:i.next_cursor}:{}}}},ee="relationship-event-store",W=p.O_NOFOLLOW;function w(r){return N(r,ee,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function l(r,e="relationships/events.jsonl"){let t=h.resolve(r),n=h.resolve(t,e),i=h.relative(t,n);if(i.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(i===".."||i.startsWith(`..${h.sep}`)||h.isAbsolute(i))throw new TypeError("Relationship event path must stay within the tracker root");if(await $(t,{recursive:!0}),(await A(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let s=t;for(let c of i.split(h.sep)){s=h.join(s,c);try{if((await A(s)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(d){if(_(d))break;throw d}}return n}async function y(r,e,t){let n=new I(e,{registry:t}),i,o;try{o=await P(r,p.O_RDONLY|W),i=await o.readFile("utf8")}catch(c){if(_(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=i.split(`
|
|
2
2
|
`);for(let c=0;c<s.length;c+=1){let d=s[c].trim();if(!d)continue;let a;try{a=JSON.parse(d)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${c+1}`)}if(a.sequence!==n.version+1)throw new TypeError(`Invalid relationship event sequence at line ${c+1}`);n.append({eventId:a.eventId,relationshipId:a.relationshipId,action:a.action,...a.edge===void 0?{}:{edge:a.edge},author:a.author,timestamp:a.timestamp,...a.reason===void 0?{}:{reason:a.reason},expectedVersion:n.version})}return{log:n,raw:i}}function te(r,e,t,n){let i=Date.parse(e.timestamp),o;return e.action!=="remove"&&e.edge!==void 0&&(o=new m(t,[e.edge],n).edges()[0]),r.eventId===e.eventId.trim()&&r.relationshipId===e.relationshipId.trim()&&r.action===e.action&&r.author===e.author.trim()&&Number.isFinite(i)&&r.timestamp===new Date(i).toISOString()&&r.reason===(e.reason?.trim()||void 0)&&O(r.edge)===O(o)}var F=class r{#t;#n;#i;#o;#e;constructor(e,t,n,i){this.#t=e.pmRoot,this.#n=t,this.#i=e.registry,this.#o=n,this.#e=i}static async open(e){let t=Object.freeze([...e.nodes]),n=await l(e.pmRoot,e.relativePath),i=await w(e.pmRoot);try{await l(e.pmRoot,n);let{log:o}=await y(n,t,e.registry);return new r(e,t,n,o)}finally{await i()}}get path(){return this.#o}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(e){let t=await w(this.#t);try{let n=await l(this.#t,this.#o),{log:i}=await y(n,this.#n,this.#i),o=i.append(e);await $(h.dirname(n),{recursive:!0}),await l(this.#t,n);let s=await P(n,p.O_APPEND|p.O_CREAT|p.O_WRONLY|W);try{await s.appendFile(`${JSON.stringify(o)}
|
|
3
3
|
`,"utf8")}finally{await s.close()}return this.#e=i,o}finally{await t()}}async appendBatch(e,t={}){let n=await w(this.#t);try{let i=await l(this.#t,this.#o),{log:o,raw:s}=await y(i,this.#n,this.#i),c=o.version,d=new Map(o.events().map(f=>[f.eventId,f])),a=[],T=[];for(let f of e){let u=f.eventId.trim(),v=d.get(u);if(v!==void 0){if(t.existingEventPolicy==="skip_identical"&&te(v,f,this.#n,this.#i)){T.push(v.eventId);continue}if(t.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${u}`)}let b=o.append(f);d.set(b.eventId,b),a.push(b)}if(a.length>0){let f=s.length===0||s.endsWith(`
|
|
4
4
|
`)?s:`${s}
|
|
5
5
|
`;await $(h.dirname(i),{recursive:!0}),await l(this.#t,i),await L(i,`${f}${a.map(u=>JSON.stringify(u)).join(`
|
|
6
6
|
`)}
|
|
7
7
|
`)}return this.#e=o,Object.freeze({version_before:c,version_after:o.version,appended:Object.freeze(a),skipped_event_ids:Object.freeze(T)})}finally{await n()}}async snapshot(e={}){return this.#e=await this.#r(),this.#e.snapshot(e)}async page(e){return this.#e=await this.#r(),this.#e.page(e)}async*stream(e={}){this.#e=await this.#r(),yield*this.#e.stream(e)}async project(e,t,n={}){return this.#e=await this.#r(),this.#e.project(e,t,n)}async#r(){let e=await w(this.#t);try{let t=await l(this.#t,this.#o);return(await y(t,this.#n,this.#i)).log}finally{await e()}}};function K(r){return[...r].sort().join("\0")}function ne(r,e,t){let n=r.successors.get(e);n?n.push(t):r.successors.set(e,[t]);let i=r.predecessors.get(t);i?i.push(e):r.predecessors.set(t,[e])}function G(r,e,t,n,i){let o=e.resolve(i);if(o?.ordering!==!0)return;let s=q(n),c=s===void 0?void 0:r.canonicalIds.get(s.toLowerCase());if(c===void 0)return;let d=(o.precedence??"source_before_target")==="source_before_target";ne(r,d?t:c,d?c:t)}function ie(r,e){let t={successors:new Map,predecessors:new Map,canonicalIds:new Map},n=r.filter(i=>typeof i?.id=="string"&&i.id.trim().length>0);for(let i of n){let o=i.id.trim();t.canonicalIds.set(o.toLowerCase(),o)}for(let i of n){let o=i.id.trim();G(t,e,o,i.blocked_by,"blocked_by");for(let s of i.dependencies??[])typeof s!="object"||s===null||G(t,e,o,s.id,typeof s.kind=="string"?s.kind:"related")}for(let i of[t.successors,t.predecessors])for(let o of i.values())o.sort();return t}function re(r,e){let t=new Set([e]),n=[e];for(;n.length>0;){let i=n.pop();for(let o of[r.successors,r.predecessors])for(let s of o.get(i)??[])t.has(s)||(t.add(s),n.push(s))}return t}function oe(r,e){let t=new Map;for(let n of e){let i=(r.successors.get(n)??[]).filter(o=>e.has(o));i.length>0&&t.set(n,i)}return t}function H(r,e,t){let n=ie(r,e),i=n.canonicalIds.get(t.trim().toLowerCase());if(i===void 0)return{cycles:[],successors:new Map,canonical:t};let o=oe(n,re(n,i));return{cycles:D(o).filter(s=>s.includes(i)),successors:o,canonical:i}}function se(r,e,t){let n=new Set(e),i=n.has(t)?t:e[0];if(r.get(i)?.includes(i))return[i,i];for(let o of r.get(i)??[]){if(!n.has(o))continue;let s=ae(r,n,i,o);if(s)return s}return[...e,e[0]]}function ae(r,e,t,n){let i=[[n]],o=new Set([t,n]);for(;i.length>0;){let s=i.shift(),c=s.at(-1);for(let d of r.get(c)??[]){if(d===t)return[t,...s,t];!e.has(d)||o.has(d)||(o.add(d),i.push([...s,d]))}}}function ve(r,e,t){let n=g(),i=H(r,n,t),o=H(e,n,t),s=new Set(i.cycles.map(K)),c=new Set(k(r,void 0,n).map(a=>`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`));return[...k(e,void 0,n).filter(a=>a.holder_id.toLowerCase()===t.trim().toLowerCase()&&!c.has(`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`)).map(a=>`ordering_storage_contradiction_created:${V(a)}:remove_contradicting_dependency_row:run_pm_graph_audit`),...o.cycles.filter(a=>!s.has(K(a))).map(a=>`ordering_cycle_created:${se(o.successors,a,o.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)]}function Ee(r,e){let t=e.resolve(r);return t?.hierarchy===!0||t?.outgoing==="one"||t?.incoming==="one"}function J(r,e,t,n,i){let o=JSON.stringify([e,t,n]),s=r.get(o);s===void 0&&(s={kind:e,direction:t,node_id:n,endpoints:new Set},r.set(o,s)),s.endpoints.add(i)}function B(r,e){let t=new Map;for(let n of r)for(let i of n.dependencies??[]){let o=e.resolve(i.kind);o===void 0||o.hierarchy||(o.outgoing==="one"&&J(t,o.kind,"outgoing",n.id,i.id),o.incoming==="one"&&J(t,o.kind,"incoming",i.id,n.id))}return t}function $e(r,e,t=g()){let n=B(r,t),i=B(e,t);for(let o of[...i.keys()].sort()){let s=i.get(o);if(s.endpoints.size<=1)continue;let c=n.get(o);if(![...s.endpoints].every(d=>c?.endpoints.has(d)))throw new x(`Relationship ${s.kind} permits only one ${s.direction} endpoint for ${s.node_id}.`,S.USAGE,{code:"dependency_cardinality_created",field:"dependencies",value:s.kind,relationship_cardinality:{kind:s.kind,direction:s.direction,node_id:s.node_id,endpoint_ids:[...s.endpoints].sort()},required:"The final dependency set must satisfy the active relationship kind's one-edge cardinality.",nextSteps:["Drop extra --dep seeds, or remove conflicting rows with update --dep-remove before adding another edge.","Choose another kind only when its declared semantics match the intended relationship."]})}}export{I as a,F as b,ve as c,Ee as d,$e as e};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-OKGWIW6C.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as N,f as P}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as N,f as P}from"./chunk-BUIF6CMZ.js";import{D as m,E as R,T as L,e as p,f as x}from"./chunk-5JQVPQMN.js";import{r as v,x as E}from"./chunk-L2XJB5PK.js";import{a as g,b as C}from"./chunk-X6CXWWNB.js";import{Ud as k,v as f}from"./chunk-L6NOGC4N.js";import{g as w,n as _,t as l}from"./chunk-26P6C6OO.js";import{ba as b}from"./chunk-JFICNN4T.js";import{A as s,C as I,z as c}from"./chunk-IRYNVGKH.js";async function X(t){let i=_(process.cwd(),t);await E(i);let r=await v(i),a=w(r,k());return{pmRoot:i,settings:r,typeRegistry:a}}async function j(t,i,r,a){l(t,p(i));let e=await m(t,i,r.id_prefix,r.item_format,a);if(e)return{id:e.id,historyPath:l(t,e.id),located:e};let o=x(i,r.id_prefix),n=p(i),d=o===n?[o]:[o,n];for(let u of d){let h=l(t,u);if(await I(h))return{id:u,historyPath:h,located:null}}throw new s(`Item ${i} not found`,c.NOT_FOUND)}import{readdir as T}from"node:fs/promises";import y from"node:path";function B(t,i){let r=new Map;for(let a of t){let e=a.external?a.id:i.get(a.id.toLowerCase())?.id??a.id;r.set(a.external?`external:${e}`:`local:${e.toLowerCase()}`,{...a,id:e})}return[...r.values()]}async function D(t,i){let r=y.basename(t),e=(await T(y.dirname(t)).catch(o=>{throw L("Cannot verify the blocker's physical file identity",{exitCode:c.GENERIC_FAILURE,context:{code:"blocker_identity_read_failed",required:"Restore access to the blocker item directory, then retry the item read."},cause:o})})).filter(o=>o.toLowerCase()===r.toLowerCase()).sort((o,n)=>+(n===r)-+(o===r)||o.localeCompare(n)).map(o=>y.parse(o).name)[0];if(e===void 0)throw new s(`Blocker canonical file disappeared during identity verification: ${i}`,c.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker file and validate storage integrity before retrying the item read."});return e}async function te(t){let i=N(t.metadata);if(i.length===0)return[];let r=new Map([t.metadata.blocked_by,...(t.metadata.dependencies??[]).filter(e=>f(e.kind)==="blocked_by").map(e=>e.id)].filter(e=>typeof e=="string").map(e=>[e.trim().toLowerCase(),e.trim()])),a=new Map;for(let e of i){if(g(e)||!/^(?!\.{1,2}$)[^/\\:\0]+$/u.test(e)||t.metadata.dependencies?.some(d=>d.id.trim()===e&&f(d.kind)==="blocked_by"&&C(d.source_kind)))continue;let o=await m(t.pmRoot,r.get(e),t.settings.id_prefix,t.settings.item_format,t.typeToFolder);if(o===null)continue;let n=await R(o,{schema:t.settings.schema});if(o.id=await D(o.itemPath,o.id),n.document.metadata.id!==o.id)throw new s(`Blocker identity differs from its canonical file: ${o.id}`,c.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker identity and validate storage integrity before retrying the item read."});a.set(e.toLowerCase(),n.document.metadata)}return B(P({blocked_by:t.metadata.blocked_by,dependencies:t.metadata.dependencies,updated_at:t.metadata.updated_at},a,b(t.settings.schema)),a)}export{X as a,j as b,D as c,te as d};
|
|
2
|
+
//# sourceMappingURL=chunk-RFDSSOTZ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{J as u,ub as h}from"./chunk-4DDXERKN.js";import{X as r,Y as A,aa as F,ba as w}from"./chunk-WDHNPNHX.js";import{H as y,S as k,da as d}from"./chunk-JFICNN4T.js";import{A as f,m as _,z as c}from"./chunk-IRYNVGKH.js";function S(e){return e.trim().toLowerCase().replace(/^-+/u,"")}function v(e){let n=S(e),i=w({key:n,cli_flag:n,cli_aliases:[]});return[...new Set([...i,F(n)])]}var $=new Set(_.filter(e=>!y.has(e))),E={flag:"--help",short:"-h"},C=new Map;function b(e){let n=C.get(e);if(n===void 0){let i=new Map,o=new Map;for(let l of[...h(e),...u,E]){for(let t of[l.flag,...l.aliases??[]].flatMap(v))i.has(t)||i.set(t,l.flag);l.short!==void 0&&!o.has(l.short)&&o.set(l.short,l.flag)}n={long:i,short:o},C.set(e,n)}return n}function D(e,n){return r(e)?n.short.get(e.trim()):v(e).map(i=>n.long.get(i)).find(i=>i!==void 0)}function p(e){let n=[];for(let i of e){let o=a=>r(a)?a.trim():S(a),l=[...new Set([i.cli_flag,...i.cli_aliases].map(o))],t=o(i.key);for(let a of i.commands)n.push(...T(i.key,l,l.includes(t)?void 0:t,a.replaceAll("_","-")))}return n.sort((i,o)=>i.field.localeCompare(o.field)||i.command.localeCompare(o.command)||i.option.localeCompare(o.option))}function T(e,n,i,o){let l=b(o),t=new Map;for(let a of i===void 0?n:[...n,i]){if($.has(e)&&a.replaceAll("-","_")===e)continue;let s=D(a,l);s===void 0||t.has(s)||a===i&&s===E.flag||t.set(s,{field:e,command:o,field_flag:r(a)?a:`--${a.replaceAll("_","-")}`,option:s})}return[...t.values()]}function I(e){return p([{key:e.key,cli_flag:e.cliFlag??e.key.replaceAll("_","-"),cli_aliases:e.cliAliases,commands:e.commands}])}function g(e){return e.flatMap(n=>[...new Set([n.cli_flag,...n.cli_aliases])].flatMap(i=>{let o=A(i);return o===void 0?[]:[{field:n.key,spelling:i,reason:o}]}))}function M(e,n){return[...O(e.key,n?.cliFlag,n?.aliases),...g([{key:e.key,cli_flag:e.cliFlag??e.key.replaceAll("_","-"),cli_aliases:e.cliAliases}])]}function L(e){return`${JSON.stringify(e.spelling)} ${e.reason}`}function R(e){return`${e.field_flag} shadows built-in ${e.option} on pm ${e.command}`}function q(e,n){let i=d(e).definitions,o=p(i),l=g(i),t=l.length===0?{details:{},warnings:[]}:{details:{schema_field_flag_invalid_count:l.length,schema_field_flag_invalid:l.slice(0,n),schema_field_flag_invalid_truncated:l.length>n,schema_field_flag_invalid_fix_hint:"Re-register the field with one flag and one spelling per alias: pm schema add-field <key> --cli-flag <flag> --alias <alias>. A short alias is one dash and one character. Edit a field defined inline in settings.json there."},warnings:[`validate_schema_field_flag_invalid:${l.length}`]};return o.length===0?t:{details:{...t.details,schema_field_option_collision_count:o.length,schema_field_option_collisions:o.slice(0,n),schema_field_option_collisions_truncated:o.length>n,schema_field_option_collision_fix_hint:"Rename a file-backed field without losing item values: pm schema rename-field <key> --to <new-key>. For a colliding flag, alias or command list, re-register the same key: pm schema add-field <key> --cli-flag <flag> --commands <commands>. Edit a field defined inline in settings.json there."},warnings:[...t.warnings,`validate_schema_field_option_collision:${o.length}`]}}function z(e,n){m(e.key,M(e,n)),x(e.key,e.commands,I(e))}function O(e,n,i){return[n,...Array.isArray(i)?i:[]].filter(o=>typeof o=="string"&&k(o).length===0).map(o=>({field:e,spelling:o,reason:"is empty"}))}function H(e){m(e.key,O(e.key,e.cli_flag,e.cli_aliases));let n=d({fields:[e]}).definitions;m(e.key,g(n)),x(e.key,n.flatMap(i=>i.commands),p(n))}function m(e,n){if(n.length!==0)throw new f(`Cannot define custom field "${e}": flag ${n.map(L).join("; ")}. The command it is registered for could not register it as one option.`,c.USAGE,{code:"schema_field_flag_invalid",field:e,flag:n[0].spelling,required:"Each custom field flag and alias must be one option spelling: a long name without spaces, pipes, commas, '=' or brackets, or a short flag of one dash and one character.",nextSteps:[`Pass one spelling per --alias, for example pm schema add-field ${e} --alias <first> --alias <second>.`]})}function x(e,n,i){if(i.length===0)return;let o={key:e,commands:n},l=new Set(i.map(a=>a.command)),t=o.commands.filter(a=>!l.has(a.replaceAll("_","-")));throw new f(`Cannot define custom field "${o.key}": ${i.map(R).join("; ")}. The built-in option would stop working for that command.`,c.USAGE,{code:"schema_field_option_collision",field:o.key,flag:i[0].option,required:"A custom field's key, flag and aliases must differ from every built-in option of each command it is registered for.",nextSteps:[`Rename the field with a project-specific prefix, for example pm schema add-field project_${o.key}.`,...t.length>0?[`Or register "${o.key}" only where its option is free: --commands ${t.join(",")}.`]:[]]})}export{p as a,I as b,g as c,M as d,L as e,R as f,q as g,z as h,H as i};
|
|
2
|
+
//# sourceMappingURL=chunk-SSX5YBDC.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{b as K}from"./chunk-XR6MLUVW.js";import{a as X,b as R,c as h,d as z}from"./chunk-AIDL2ZNT.js";import{l as H,r as $,t as V,x as q}from"./chunk-
|
|
1
|
+
import{b as K}from"./chunk-XR6MLUVW.js";import{a as X,b as R,c as h,d as z}from"./chunk-AIDL2ZNT.js";import{l as H,r as $,t as V,x as q}from"./chunk-L2XJB5PK.js";import{B,Ob as P,pc as U}from"./chunk-L6NOGC4N.js";import{F as W}from"./chunk-WDHNPNHX.js";import{g as L,n as E}from"./chunk-26P6C6OO.js";import{A as v,C as S,E as F,F as G,J as N,z as _}from"./chunk-IRYNVGKH.js";import{access as ue,lstat as ee,readFile as T,realpath as w}from"node:fs/promises";import{constants as me}from"node:fs";import{execFile as pe}from"node:child_process";import c from"node:path";import{promisify as de}from"node:util";var ce="PM_SOURCE_CONTEXT_ACCESS",le="PM_ALLOW_SOURCE_CONTEXT_WRITES";function J(e){let n=e[ce],r=n===void 0||n.trim().toLowerCase()==="write"?"write":"read_only",t=r==="read_only"&&e[le]?.trim()==="1";return{access:r,write_override_applied:t,source_writes_allowed:r==="write"||t}}var k=de(pe),C="# pm-cli:merge-drivers:start",fe="# pm-cli:merge-drivers:end",x="# pm-cli:merge-drivers:v2:start",te="# pm-cli:merge-drivers:v2:end",ge="merge-fence",he="merge-attributes";function A(e){return`'${e.replaceAll("'",`'"'"'`)}'`}async function we(e,n){let r=await w(e);if(/(?:^|[\\/])bun-node-[^\\/]+[\\/]bun(?:\.exe)?$/iu.test(r))return;let{stdout:t}=await k(e,["--version"],{encoding:"utf8",windowsHide:!0,timeout:1e4});return t.trim()===n?r:void 0}async function ye(){let e=B(import.meta.url,["../../.."]),n=process.execPath,r=!1,t=await w(process.execPath),o=process.versions.bun,i=(process.env.PATH??"").split(c.delimiter).filter(s=>c.isAbsolute(s)).map(s=>c.join(s,o===void 0?c.basename(process.execPath):process.platform==="win32"?"bun.exe":"bun")),a=o===void 0?i:[process.env.npm_execpath??"",...i,t].filter(s=>c.isAbsolute(s)&&/^(?:bun|bun\.exe)$/iu.test(c.basename(s)));for(let s of a)try{if(await ue(s,me.X_OK),o!==void 0){let u=await we(s,o);if(u!==void 0){n=u,r=!0;break}continue}if(s!==t&&await w(s)===t){n=s;break}}catch{}if(o!==void 0&&!r)throw new v("Cannot install Bun merge drivers without a durable executable matching the current Bun version.",_.DEPENDENCY_FAILED,{code:"merge_bun_launcher_unavailable",why:"The current Bun process may be a temporary bunx launcher that Git cannot reuse after this command exits.",nextSteps:["Run with a durable version-matched Bun executable, expose one on an absolute PATH entry, or invoke pm through a Bun runner that publishes an absolute npm_execpath.","Retry pm merge install, then check pm health --strict-exit before merging branches."]});return`${A(n)} ${A(c.join(e,"dist","cli.js"))}`}var re=[{key:"pm-item-toon",name:"pm field-aware TOON item document merge",artifact:"item",itemPath:"%P"},{key:"pm-item-markdown",name:"pm field-aware JSON-markdown item document merge",artifact:"item",itemPath:"%P"},{key:"pm-history",name:"pm append-only history stream merge",artifact:"history",itemPath:void 0},{key:"pm-relationship",name:"pm append-only relationship event store merge",artifact:"relationship",itemPath:void 0},{key:"pm-json",name:"pm key-level JSON config merge",artifact:"json",itemPath:void 0}];function _e(e){let n=e.explicitPath?.trim(),r=e.environment.PM_SOURCE_WORKSPACE_ROOT?.trim(),t=e.environment.PM_SOURCE_PM_PATH?.trim(),o=J(e.environment),i=!!(r&&t),a=n===void 0&&i&&(e.dryRun||o.source_writes_allowed);if(n!==void 0){let s=E(e.cwd,n);return{pm_root:s,workspace_start:s,source_coordinates_available:i,source_context_selected:!1,source_policy:o}}return a?{pm_root:c.resolve(t),workspace_start:c.resolve(r),source_coordinates_available:!0,source_context_selected:!0,source_policy:o}:{pm_root:i?E(e.cwd,".agents/pm"):E(e.cwd),workspace_start:e.cwd,source_coordinates_available:i,source_context_selected:!1,source_policy:o}}async function O(e){try{let{stdout:n}=await k("git",["rev-parse","--show-toplevel"],{cwd:e,env:h(),encoding:"utf8",windowsHide:!0,timeout:1e4});return await w(R(n))}catch{return null}}async function ne(e){let n=await O(e);if(n===null)throw new v("pm merge install requires a git repository (merge drivers are git configuration).",_.USAGE);return n}function M(e,n){return c.relative(e,n).split(c.sep).join("/")}function Y(e){return e.replace(/[\\*?[\]!]/gu,"\\$&")}function g(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}function Q(e,n){if(e[n]!=="'")return null;let r="";for(let t=n+1;t<e.length;t+=1){if(e.startsWith(`'"'"'`,t)){r+="'",t+=4;continue}if(e[t]==="'")return{value:r,nextOffset:t+1};r+=e[t]}return null}async function ve(e,n,r){if(V(n).filter(i=>i.constraint==="exact").some(i=>i.version!==r))return!1;let o=await O(e);if(o!==null&&o!==await w(n)){let i=await Promise.all([o,n].map(async a=>{let s=await k("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:a,env:h(),timeout:1e4});return w(s.stdout.trim())}));if(i[0]===i[1])return!1}return!0}async function be(e,n,r){let t=Q(e,0);if(t===null||e[t.nextOffset]!==" ")return!1;let o=Q(e,t.nextOffset+1);if(o===null||e.slice(o.nextOffset)!==n||!/^(?:node|bun)(?:\.exe)?$/iu.test(c.basename(t.value))||c.basename(o.value)!=="cli.js"||c.basename(c.dirname(o.value))!=="dist"||!await S(t.value)||!await S(o.value))return!1;try{let i=c.dirname(c.dirname(o.value)),a=JSON.parse(await T(c.join(i,"package.json"),"utf8")),s=typeof a.bin=="string"?a.bin:a.bin?.pm;return await ve(i,r,a.version)?a.name==="@unbrained/pm-cli"&&s==="dist/cli.js":!1}catch{return!1}}function I(e,n){let r=e.length>0?`${Y(e)}/`:"",t=[`${g(`${r}**/*.toon`)} merge=pm-item-toon`,`${g(`${r}**/*.md`)} merge=pm-item-markdown`];for(let o of n){let i=Y(o);t.push(`${g(`${r}${i}/*.toon`)} merge=pm-item-toon`),t.push(`${g(`${r}${i}/*.md`)} merge=pm-item-markdown`)}return t.push(`${g(`${r}**/*.jsonl`)} merge=pm-relationship`),t.push(`${g(`${r}history/*.jsonl`)} merge=pm-history`),t.push(`${g(`${r}settings.json`)} merge=pm-json`),t.push(`${g(`${r}**/*.json`)} merge=pm-json`),t.push(`${g(`${r}extensions/**`)} merge=text`),t.push(`${g(`${r}extensions/.managed-extensions.json`)} merge=pm-json`),t}function oe(e){let n=[],r=0;for(;r<e.length;){let t=e.indexOf(C,r),o=e.indexOf(x,r),i=t===-1?o:o===-1?t:Math.min(t,o);if(i===-1)break;let a=i===o,s=a?x:C,u=a?te:fe,p=e.indexOf(u,i+s.length),m=p===-1?e.length:p+u.length;n.push({start:i,end:m,closed:p!==-1,lines:e.slice(i+s.length,p===-1?m:p).split(`
|
|
2
2
|
`).map(l=>l.trim()).filter(Boolean)}),r=m}return n}function ie(e,n,r){let t=new Set(n),o=g(r.length>0?`${r}/`:"").slice(0,-1);return e.some(i=>t.has(i)||i.startsWith(o)&&/^[^/]+\/\*\.(?:toon|md)" merge=pm-item-(?:toon|markdown)$/u.test(i.slice(o.length)))}async function se(e,n,r,t){let o=c.join(e,".gitattributes"),i=t?null:R((await k("git",["rev-parse","--absolute-git-dir"],{cwd:e,env:h(),encoding:"utf8",windowsHide:!0,timeout:1e4})).stdout),a=i===null?null:await P(i,he,120,"merge-fence",!1,!0,5e3);try{let s=await G(o)??"",u=[x,...r,te].join(`
|
|
3
3
|
`),p=oe(s),m=p.filter(d=>ie(d.lines,r,n));m.length===0&&n===".agents/pm"&&p.length===1&&p[0].lines.every(d=>!d.includes("/"))&&m.push(p[0]);let l;if(m.length>0){let d=m[0];l=s;for(let b of m.slice(1).reverse())l=`${l.slice(0,b.start)}${l.slice(b.end)}`;l=`${l.slice(0,d.start)}${u}${l.slice(d.end)}`}else{let d=s.trimEnd();l=`${d.length>0?`${d}
|
|
4
4
|
|
|
5
5
|
`:""}${u}
|
|
6
6
|
`}return l===s&&!(await ee(o)).isSymbolicLink()?{path:o,changed:!1}:(t||await N(o,l),{path:o,changed:!0})}finally{await a?.()}}function ae(e){let n=L(e,null);return[...new Set(Object.values(n.type_to_folder))].sort((r,t)=>r.localeCompare(t))}async function Z(e){try{return await w(e)}catch{return null}}function ke(e,n){let r=c.relative(e,n);return r===""||!c.isAbsolute(r)&&r.split(c.sep)[0]!==".."}async function xe(e){try{return(await ee(e)).isFile()?await T(e,"utf8"):null}catch{return null}}async function Ee(e){try{return await T(e,"utf8")}catch{return null}}async function Pe(e,n){let r=n===void 0?await O(e):n;if(r===null)return{trackerRoot:e,topLevel:null};let[t,o]=await Promise.all([Z(e),Z(r)]);return t===null||o===null||!ke(o,t)?null:{trackerRoot:t,topLevel:o}}async function $e(e){let n=e.topLevel===null?Ee:xe,r=e.trackerRoot;for(let t=0;e.topLevel!==null||t<8;t+=1){let o=await n(c.join(r,".gitattributes"));if(o!==null&&(o.includes(x)||o.includes(C)))return{directory:r,content:o};let i=c.dirname(r);if(i===r||e.topLevel!==null&&c.relative(e.topLevel,r)==="")return null;r=i}return null}async function et(e,n,r={}){let t=await Pe(c.resolve(e),r.gitWorkspaceRoot),o=t===null?null:await $e(t);if(t===null||o===null)return{status:"not_installed",missing_patterns:[],stale_patterns:[],schema_scope:"project"};let i=o.directory,a=o.content,s=c.join(i,".gitattributes"),u=M(i,t.trackerRoot),p=oe(a),m=I(u,n),l=p.filter(y=>ie(y.lines,m,u)),d=l.flatMap(y=>y.closed?y.lines:[]),b=new Set(d),f=new Set(m),j=m.filter(y=>!b.has(y)),D=d.filter(y=>!f.has(y));return{status:l.length!==1||!l[0].closed||j.length>0||D.length>0?"drift":"ok",path:s,missing_patterns:j,stale_patterns:D,schema_scope:"project"}}async function tt(e){let n=[],r=[];for(let t of re){let o=`merge.${t.key}.driver`,i=` merge driver ${t.artifact} "%O" "%A" "%B"${t.itemPath===void 0?"":` --item-path ${t.itemPath}`}`;try{let{stdout:a}=await k("git",["config","--get",o],{cwd:e,env:h(),encoding:"utf8",windowsHide:!0,timeout:1e4}),s=a.trim();await be(s,i,e)||r.push(o)}catch{n.push(o)}}return{status:n.length>0?"missing":r.length>0?"drift":"ok",missing_keys:n,drifted_keys:r}}async function rt(e){let n;try{n=await ne(c.resolve(e))}catch{return{status:"no_git"}}let r=M(n,c.resolve(e)),t=await $(e),o=U(void 0,t.author_default),i=await P(e,ge,t.locks.ttl_seconds,o,!1,H(t).force_required_for_stale_lock,t.locks.wait_ms);try{let a=c.join(n,".gitattributes"),s;try{s=await T(a,"utf8")}catch(l){if(l instanceof Error&&"code"in l&&F(l))return{status:"not_installed",path:a};throw l}if(!s.includes(x)&&!s.includes(C))return{status:"not_installed",path:a};let u=await $(e),p=ae(u),m=await se(n,r,I(r,p),!1);return{status:m.changed?"refreshed":"unchanged",path:m.path}}finally{await i()}}async function nt(e,n){let r=_e({cwd:process.cwd(),explicitPath:n.path,dryRun:e.dryRun===!0,environment:process.env}),t=r.pm_root;await q(t);let o=await ne(r.workspace_start);return Te({pmRoot:t,workspaceRoot:o,dryRun:e.dryRun===!0,preCommitHook:e.preCommitHook===!0})}async function Ce(e,n){let r=(await k("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:e,env:h(),timeout:1e4})).stdout.trim(),t=await P(r,"merge-driver-config",120,"merge-install",!1,!0,5e3);try{let o=await z(e),i;try{i=(await k("git",["config",o,"--null","--get-regexp","."],{cwd:e,env:h(),timeout:1e4})).stdout}catch(s){if(typeof s!="object"||s===null||!("code"in s)||s.code!==1)throw s;i=""}let a=new Map(i.split("\0").filter(Boolean).map(s=>{let u=s.indexOf(`
|
|
7
7
|
`);return[s.slice(0,u),s.slice(u+1)]}));for(let s of n)a.get(s.key)!==s.value&&await X(e,[o,s.key,s.value])}finally{await t()}}async function Te(e){let n=c.resolve(e.pmRoot),r=c.resolve(e.workspaceRoot),t=e.dryRun===!0,o,i;try{[o,i]=await Promise.all([w(n),w(r)])}catch(f){throw new v(`Cannot resolve tracker root ${n} or workspace root ${r}: ${String(f)}`,_.NOT_FOUND,{code:"merge_root_not_found",nextSteps:["Initialize the tracker and ensure both paths are accessible.",'Retry "pm merge install" from the repository workspace.']})}let a=M(i,o);if(K(a))throw new v(`Tracker root ${n} is outside the git repository ${r}; there is nothing to configure for this repository.`,_.USAGE);let s=await $(o),u=ae(s),p=I(a,u),m=[],l=await ye(),d=e.preCommitHook===!0?await import("./settlement-hook-Q6MJQKIE.js").then(async f=>({plan:await f.prepareMergeSettlementHook(i,`${l} --pm-path ${A(a||".")}`),write:f.writeMergeSettlementHook})):void 0;for(let f of re)m.push({key:`merge.${f.key}.name`,value:f.name}),m.push({key:`merge.${f.key}.driver`,value:`${l} merge driver ${f.artifact} "%O" "%A" "%B"${f.itemPath===void 0?"":` --item-path ${f.itemPath}`}`});if(!t)try{await Ce(i,m)}catch{throw new v(`Cannot install repository-local merge drivers in ${i}. Ensure the repository Git config is writable and no other Git process holds its lock, then retry.`,_.DEPENDENCY_FAILED,{code:"merge_git_config_unwritable",why:"pm merge install must persist clone-local driver commands before publishing their shared .gitattributes mappings.",nextSteps:["Make the repository Git config writable or wait for the process holding its lock to finish.",'Retry "pm merge install"; the operation is idempotent.','Use "pm merge install --dry-run --json" when the workspace is intentionally read-only.']})}let b=await se(i,a,p,t);return d!==void 0&&!t&&await d.write(d.plan),{ok:!0,dry_run:t,workspace_root:i,pm_root:o,gitattributes:{path:b.path,changed:b.changed,patterns:p,schema_scope:"project"},git_config:m,...d===void 0?{}:{settlement_hook:{path:d.plan.path,changed:d.plan.changed}},guidance:["Commit .gitattributes so every branch and collaborator shares the merge mapping.",'git config is per-clone: each collaborator (and each fresh worktree/clone) runs "pm merge install" once.','After merging branches, run "pm merge reconcile --dry-run" to inspect the complete receipt and history repair, then apply "pm merge reconcile"; use --force only after explicitly accepting any discarded values.',"Custom item types registered later refresh this fence automatically (pm schema add-type/remove-type); rerun pm merge install only after out-of-band type-folder edits."],generated_at:W()}}import{execFile as Se}from"node:child_process";import{promisify as Re}from"node:util";var Ae=Re(Se);async function ut(e,n){if(n.length===0)return[];let r;try{let i=Ae("git",["check-ignore","--verbose","-z","--stdin"],{cwd:e,env:h(),timeout:1e4}),a=i.child.stdin;a!==null&&(a.on("error",()=>{i.child.kill()}),a.end(`${n.join("\0")}\0`)),{stdout:r}=await i}catch(i){if(typeof i=="object"&&i!==null&&"code"in i&&i.code===1)return[];throw new v("Git could not verify ignore rules for merge artifacts; no automatic settlement is safe until that check succeeds.",_.CONFLICT,{code:"merge_settlement_review_required",reason:"ignore_check_unavailable",nextSteps:["Check Git configuration and ignore-file readability, then retry pm merge reconcile --stage --dry-run."]})}let t=r.split("\0"),o=[];for(let i=0;i+3<t.length;i+=4){let[a,s,u,p]=t.slice(i,i+4);u.startsWith("!")||o.push({path:p,source:a,line:Number(s),pattern:u})}return o}export{ce as a,le as b,O as c,ae as d,et as e,tt as f,rt as g,nt as h,Te as i,ut as j};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-TIEQVIFN.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{K as Qu,v as te,z as Ms}from"./chunk-6BKT6XQN.js";import{a as js,d as Hs,e as om,f as Us,g as sm}from"./chunk-KPASZGBL.js";import{a as ji,b as hr}from"./chunk-IIP6LZ5E.js";import{i as gm,k as ym}from"./chunk-T3ILWAEV.js";import{c as Dt,d as Cn,e as $n,f as Tn,g as cm,j as _m}from"./chunk-OG57ESZK.js";import{a as am}from"./chunk-XR6MLUVW.js";import{a as hs,c as di,d as li,e as cl,g as dl,h as gs,i as ys,j as vl,k as hn,l as _n,m as kl,n as bl,o as ws}from"./chunk-EQCQTYKO.js";import{g as lu,h as uu,i as As}from"./chunk-SQMOF65W.js";import{a as Ds}from"./chunk-K53OIT5J.js";import{H as iu,I as Ai,J as ou,K as Rs,M as su,N as au,P as cu,Q as du,R as Ii,_ as Ci}from"./chunk-W4JMV7GF.js";import{K as hm}from"./chunk-VQIC3UZB.js";import{A as Je,B as I,C as Hi,D as dm,E as On,F as zs,G as lm,H as um,I as xe,J as _r,K as Ui,L as mm,M as Pn,N as pm,Q as fm,Z as Ws,w as nm,y as im}from"./chunk-7A6SEZEY.js";import{a as Fs,b as rm}from"./chunk-2DGKVXFT.js";import{$a as Ps,A as ur,Aa as pr,B as pu,C as fu,Ca as $s,D as mr,Ga as Mu,Ha as Fu,Hb as Yu,Ia as ju,Ja as Hu,Ka as Mi,M as hu,Ma as Uu,Na as zu,Oa as Wu,Pa as Kt,Pb as Xu,Qa as qu,Qb as Zu,R as _u,Ra as Rn,Sa as Gu,Ta as Ts,Ua as An,Va as Bu,Wa as Vu,Xa as Ju,Ya as Os,Za as Ku,_a as In,a as il,ab as Ls,b as mn,ba as gu,c as _s,ca as yu,d as ol,da as wu,e as sl,f as ft,g as ui,ga as Oi,h as al,i as Tt,rb as Ns,v as $i,xa as Li,ya as Eu,z as mu,za as Cs}from"./chunk-VK3IE3TS.js";import{d as fr,f as Fi,m as em,p as tm}from"./chunk-4SCFAWAW.js";import{A as Ni,C as Lu,D as ge,E as ye,F as Nu,G as Di,H as _t,I as gt,M as Du,N as yt,a as Ti,c as vu,j as Ru,k as Au,m as Iu,n as Cu,o as Nt,p as $u,q as Tu,u as Ou,v as Pu}from"./chunk-TXTPAFHJ.js";import{a as re,b as bn,c as ku,d as Is,e as xn,f as Sn,g as En,h as bu,i as xu,l as Ve,q as Su,r as T,s as Pi,x as ie}from"./chunk-P2H3GTJK.js";import{$c as kn,$d as nu,A as Ae,Ab as Tl,Ac as qe,B as tt,Bb as Ol,Bc as xs,C as qd,Ca as Bt,Dc as wn,Dd as Zl,E as X,Ec as gi,Fc as ht,Fd as Si,Gb as Pl,Gc as be,Gd as Ql,H as Gd,Hb as Ll,Hc as cr,Hd as eu,Ic as Wl,Jb as Nl,Jc as ql,Jd as tu,Kb as Dl,Kc as Gl,La as fs,Lb as se,Lc as Bl,M as ci,Mc as Vl,N as Xd,Na as un,Nc as yi,O as us,Oc as Jt,P as ms,Pa as rt,Pc as wi,Q as ps,Ra as it,Rd as U,S as Zd,T as Qd,Vc as Jl,Vd as Y,W as el,Wc as dr,Xc as vn,Yc as Ge,Zd as Be,_a as xl,a as Ld,ad as vi,ae as Ei,ba as nl,bb as ke,bd as Kl,cb as vs,cd as ki,d as Nd,db as pi,e as Dd,eb as ar,ed as Yl,fb as Rl,fe as ru,gb as fi,gd as bi,h as dn,hb as Al,jb as hi,kb as _i,le as Ri,mb as Il,mc as q,nc as Ml,nd as Ss,od as Es,pc as Fl,pd as Xl,q as zd,qb as Cl,qc as jl,rb as $l,rc as We,sc as Hl,t as Wd,ta as rl,tc as Ul,ub as Ne,uc as ks,v as ds,vc as zl,wc as bs,xd as lr,yc as Lt,yd as xi,zb as Pt}from"./chunk-N64AC5G6.js";import{E as $,F as Sl,G as gn,H as Ot,I as Vt,L as yn,M as K,U as El,c as A,d as ls,e as $e,p as tl}from"./chunk-2UWKU2BQ.js";import{e as Vd,f as Jd,g as W,l as sr,n as M,o as nt,p as ai,q as ln,s as Kd,t as pt,v as Yd}from"./chunk-26P6C6OO.js";import{E as Bd,G as ce,I as ll,J as pn,K as fn,L as ul,M as ml,N as pl,O as fl,P as ve,T as hl,V as Te,W as _l,X as gl,Z as Oe,ba as _e,ca as yl,da as mi,fa as wl,i as cs}from"./chunk-JFICNN4T.js";import{A as g,B as or,C as P,D as et,E as H,F as B,J as ee,a as ii,d as oi,p as Md,r as Fd,t as jd,v as Hd,w as si,x as Ud,y as $t,z as y}from"./chunk-IRYNVGKH.js";var L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},Ie=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},ot=class extends TypeError{measurement_id;source_kind;field;check;constructor(t,n){super(t),this.name="AssuranceSourceResolutionError",this.measurement_id=n.measurement_id,this.source_kind=n.source_kind,this.field=n.field,this.check=n.check}};async function Ln(e){try{return await e()}catch(t){throw t instanceof L?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function qs(e){try{return await e()}catch(t){throw t instanceof Ie?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as fv}from"node:crypto";import hv from"node:path";var vm=1,Yt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],Gs=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],_v=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],gv=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,zi=30,Wi=5e3,km=4,yv=50;function wt(e,t){if(!gv.test(e))throw new L(`${t} must be a stable lowercase id`)}function wv(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function yr(e){let t=_v.filter(i=>e[i]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function Vs(e,t){return A(e)===A(t)}function bm(e,t){if(t.polarity==="equals")return Vs(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let r=t.value;return e.every(i=>r.includes(i))}if(typeof e!="number")return!1;let n=t.value;return t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?e<=n:t.polarity==="floor"||t.polarity==="monotone_nondecreasing"?e>=n:e===0}function xm(e){let t=yr(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>bm(r.observed,t)===(r.expected==="pass"))}function vv(e,t){if(e.polarity!==t.polarity)return!0;if(typeof e.value=="number"&&typeof t.value=="number")return e.polarity==="ceiling"||e.polarity==="monotone_nonincreasing"?t.value>e.value:e.polarity==="floor"||e.polarity==="monotone_nondecreasing"?t.value<e.value:t.value!==e.value;if(e.polarity==="subset_of"){let n=e.value,r=t.value;return!Array.isArray(n)||!Array.isArray(r)||r.some(i=>!n.includes(i))}return!Vs(e.value,t.value)}function kv(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||A(e.scope)!==A(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return vv(yr(e),yr(t))||n[t.enforcement]<n[e.enforcement]||r}function bv(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new L("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,r=Number(t)+Number(n);if(e.field!==void 0&&r!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new L("items source equals/state requires field")}function xv(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new L("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(n=>n!==void 0).length>1)throw new L("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new L("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new L("dependency_kind source source_kind_state must be present or missing")}function Sv(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new L("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new L("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new L("prose_edge_gap exemption selectors must not be empty")}}function Js(e){wt(e.id,"measurement.id"),e.max_cost!==void 0&&wv(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new L(`measurement.source.kind must be one of ${Gs.join(", ")}`);let n=Reflect.get(t,"kind");if(!Gs.includes(n))throw new L(`measurement.source.kind must be one of ${Gs.join(", ")}`);let r=t;if(r.kind==="items"&&bv(r),r.kind==="dependency_kind"&&xv(r),r.kind==="prose_edge_gap"&&Sv(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new L(`${r.kind} source requires field`);return r.kind==="provider"&&(wt(r.provider,"provider source provider"),wt(r.key,"provider source key")),e}function Ks(e){if(wt(e.id,"assertion.id"),wt(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new L("assertion.owner_item_id is required");let t=yr(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new L(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new L("retired assertion requires retire_reason");e.scope.kind==="filter"&&wt(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(r=>r.expected==="pass")||!n.some(r=>r.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!xm(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function Ev(e){if(!Array.isArray(e.allowed_providers))throw new L("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)wt(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new L("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!Yt.includes(t))throw new L(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new L(`gate provider policy trigger ${t} is invalid`)}}function Sm(e){if(wt(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new L("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new L("gate requires at least one assertion");for(let t of e.assertion_ids)wt(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${Yt.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!Yt.includes(t))throw new L(`gate trigger must be one of ${Yt.join(", ")}`);return e.provider_policy&&Ev(e.provider_policy),e}function Nn(e){if(e.version!==vm)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(Js(r),t.has(`measurement:${r.id}`))throw new L(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(Ks(r),t.has(`assertion:${r.id}`))throw new L(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){Sm(r);let i=r.assertion_ids.filter(o=>!e.assertions.some(s=>s.id===o));if(i.length>0)throw new L(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new L(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of Em(e))if(!n.has(r))throw new L(`${i.join(", ")} references missing measurement ${r}`);return e}function Ys(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)Ys(n,t)}function Em(e){let t=new Map,n=(r,i)=>{let o=t.get(r)??[];o.push(i),t.set(r,o)};for(let r of e.assertions)n(r.measurement_id,`assertion ${r.id}`),r.scope.kind==="filter"&&n(r.scope.measurement_id,`assertion ${r.id} scope`);for(let r of e.measurements){if(r.source.kind!=="derived")continue;let i=[];Ys(r.source.expression,i);for(let o of i)n(o,`derived measurement ${r.id}`)}return t}function Rv(e,t){let n=e.assertion_ids.flatMap(o=>{let s=t.assertions.find(a=>a.id===o);return[s.measurement_id,...s.scope.kind==="filter"?[s.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let o=n.pop();if(r.has(o))continue;r.add(o);let s=t.measurements.find(a=>a.id===o);s.source.kind==="provider"?i.add(s.source.provider):s.source.kind==="derived"&&Ys(s.source.expression,n)}return i}function wr(){return{version:vm,measurements:[],assertions:[],gates:[]}}function Av(e,t){let n=t.items.filter(r=>(e.statuses===void 0||e.statuses.includes(r.status))&&(e.types===void 0||e.types.includes(r.type))&&(e.tags===void 0||e.tags.every(i=>r.tags?.includes(i)))&&(e.field===void 0||(()=>{let i=r[e.field];if(e.state!==void 0){let o=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?o:!o}return Vs(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function Iv(e,t){return e.source_kind!==void 0?t?.toLowerCase()===e.source_kind.trim().toLowerCase():e.source_kind_prefix!==void 0?t?.toLowerCase().startsWith(e.source_kind_prefix.trim().toLowerCase())===!0:e.source_kind_state==="present"?t!==void 0&&t.length>0:e.source_kind_state==="missing"?t===void 0||t.length===0:!0}function Cv(e,t){let n=[],r=ds(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let o of i.dependencies??[]){let s=ds(o.kind)??o.kind.trim().toLowerCase(),a=o.source_kind?.trim();s===r&&Iv(e,a)&&n.push(`${i.id}->${o.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function $v(e){let t=[e.description,e.body].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);for(let n of["comments","notes","learnings"]){let r=e[n];if(Array.isArray(r)){for(let i of r)if(typeof i=="string")t.push(i);else if(typeof i=="object"&&i!==null){let o=Reflect.get(i,"text");typeof o=="string"&&t.push(o)}}}return t}function Tv(e,t,n,r){return e.some(i=>i.holder_id.trim().toLowerCase()===t.toLowerCase()&&(i.target_id===void 0||i.target_id.trim().toLowerCase()===n.toLowerCase())&&(i.text_contains===void 0||r.toLowerCase().includes(i.text_contains.trim().toLowerCase())))}function Bs(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function Ov(e){let t=new Map,n=new Set,r=[],i=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,o=0;for(let s of e){t.set(s.id.toLowerCase(),s.id);for(let a of s.dependencies??[])n.add(Bs(s.id,a.id));for(let a of[s.parent,s.blocked_by])typeof a=="string"&&n.add(Bs(s.id,a));for(let a of $v(s)){let c=[...a.matchAll(i)].map(d=>d[0]);o+=c.length,r.push({holder_id:s.id,segment:a,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:o}}function Pv(e,t){let n=Ov(t.items),r=new Map;for(let s of n.prose_mentions){let a=s.mentioned_ids.map(d=>n.canonical_ids.get(d.toLowerCase())).filter(d=>d!==void 0&&d!==s.holder_id),c=[...new Set(a)];for(let d of c){let l=Bs(s.holder_id,d);if(n.linked_pairs.has(l)||Tv(e.exemptions??[],s.holder_id,d,s.segment))continue;let u=c.some(m=>m!==d);r.get(l)?.explicit===!0&&!u||r.set(l,{contributor:`${s.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],o=i.map(s=>s.contributor).sort();return{value:o.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:o.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(s=>s.explicit).length,implicit_subject:i.filter(s=>!s.explicit).length}}}function Lv(e,t){return{value:t.history.filter(r=>(e.op===void 0||r.op===e.op)&&(e.author===void 0||r.author===e.author)&&(e.harness===void 0||r.agent_harness===e.harness)&&(e.model===void 0||r.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function Nv(e,t){let n=t.items.filter(r=>{let i=r[e.link],o=Array.isArray(i)&&i.length>0;return e.state==="present"?o:!o});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function Dv(e,t){let n=e.source;return n.kind==="items"?Av(n,t):n.kind==="dependency_kind"?Cv(n,t):n.kind==="prose_edge_gap"?Pv(n,t):n.kind==="history"?Lv(n,t):n.kind==="links"?Nv(n,t):null}function Rm(e,t){return e.reduce((n,r)=>({units:n.units+r.units,items_scanned:n.items_scanned+r.items_scanned,history_entries:n.history_entries+r.history_entries,provider_calls:n.provider_calls+r.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function Mv(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,r)=>n+r,0);if(e==="subtract")return t.slice(1).reduce((n,r)=>n-r,t[0]);if(e==="multiply")return t.reduce((n,r)=>n*r,1);if(e==="divide"){if(t.slice(1).includes(0))throw new TypeError("derived divide cannot divide by zero");return t.slice(1).reduce((n,r)=>n/r,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function Am(e,t,n){let r=new Array(e.length),i=0,o=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let s=i;i+=1,r[s]=await n(e[s],s)}});return await Promise.all(o),r}async function Im(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let s=n.find(d=>d.id===e.measurement);if(!s)throw new TypeError(`derived measurement references missing ${e.measurement}`);let a=await Cm(s,t,n,r,i);if(typeof a.value!="number")throw new TypeError(`derived measurement ${s.id} is not numeric`);let c=i.charged.has(s.id)?[]:[a.cost];return i.charged.add(s.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let o=await Am(e.operands,km,s=>Im(s,t,n,r,i));return{value:Mv(e.operator,o.map(s=>s.value)),costs:o.flatMap(s=>s.costs),population_size:Math.max(0,...o.map(s=>s.population_size)),contributors:[...new Set(o.flatMap(s=>s.contributors))]}}async function Fv(e,t,n,r,i){Js(e);let o=Date.now(),s,a=[],c=0;if(e.source.kind==="derived"){let u=await Im(e.source.expression,t,n,[...r,e.id],i);s={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=Dv(e,t);u!==null?s=u:(s=await t.external(e.source),c=1)}let d={units:s.cost,items_scanned:e.source.kind==="items"||e.source.kind==="dependency_kind"||e.source.kind==="prose_edge_gap"||e.source.kind==="links"?t.items.length:0,history_entries:e.source.kind==="history"?t.history.length:0,provider_calls:c,duration_ms:Date.now()-o},l=Rm([...a,d],Date.now()-o);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new Ie(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${fv("sha256").update(A(e)).digest("hex")}`,value:s.value,population_size:s.population_size,cost:l,contributors:s.contributors??[],...s.partitions?{partitions:s.partitions}:{}}}function Cm(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let o=i.cache.get(e.id);if(o)return o;let s=Fv(e,t,n,r,i).catch(a=>{if(a instanceof ot&&a.measurement_id===void 0){let c={measurement_id:e.id,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}},d=new ot(a.message,c);throw d.cause=a,d}throw a});return i.cache.set(e.id,s),s}async function Xs(e,t,n=[e]){return Cm(e,t,n,[],{cache:new Map,charged:new Set})}function jv(e,t){return typeof e!="number"||typeof t.value!="number"?null:t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?t.value-e:(t.polarity==="floor"||t.polarity==="monotone_nondecreasing",e-t.value)}function Hv(e,t,n={}){Ks(e);let r=yr(e),i=e.lifetime==="retire"&&n.owner_terminal===!0;return{assertion_id:e.id,measurement_id:e.measurement_id,measurement_definition_fingerprint:t.definition_fingerprint,scope:e.scope,population_size:t.population_size,observed:t.value,bound:r,distance:jv(t.value,r),verdict:i?"retired":bm(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:xm(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function Uv(e,t,n,r){let i=Rv(e,t);if(i.size===0)return;let o=e.provider_policy,s=o?.triggers[r];if(!o||!s)throw new Ie(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(o.allowed_providers),c={low:0,medium:1,high:2};for(let d of i){if(!a.has(d))throw new Ie(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new Ie(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[s.max_cost_class])throw new Ie(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!s.allow_network)throw new Ie(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function wm(e,t,n,r,i){try{return await Xs(n,r,i)}catch(o){if(o instanceof ot){let s=o.check?` check ${o.check}`:"",a=o.measurement_id??n.id,c=new Ie(`assurance gate ${e} assertion ${t} measurement ${a} source ${o.source_kind}${s} field ${o.field} could not resolve: ${o.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:o.source_kind,field:o.field,...o.check?{check:o.check}:{}});throw c.cause=o,c}throw o}}async function $m(e,t,n,r){Nn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new Ie(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new Ie(`assurance gate ${e} does not declare trigger ${r.trigger}`);Uv(i,t,n,r.trigger);let o=await Am(i.assertion_ids,km,async c=>{let d=t.assertions.find(f=>f.id===c),l=t.measurements.find(f=>f.id===d.measurement_id),u=n;if(d.scope.kind==="active"){let f=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(h=>!f.has(h.status))}}else if(d.scope.kind==="filter"){let f=d.scope.measurement_id,h=t.measurements.find(v=>v.id===f),_=await wm(i.id,d.id,h,n,t.measurements),w=new Set(_.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(f=>f.id===d.owner_item_id),p=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return Hv(d,await wm(i.id,d.id,l,u,t.measurements),{owner_terminal:p})}),s=o.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=o.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:i.id,tree_id:n.tree_id,trigger:r.trigger,dry_run:r.dry_run===!0,evaluated_at:new Date().toISOString(),verdict:s?"block":a?"warn":"pass",exit_code:s?1:0,assertions:o,assertions_total:o.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:Rm(o.map(c=>c.cost),Math.max(0,...o.map(c=>c.cost.duration_ms)))}}function qi(e){return hv.join(e,"assurance.json")}async function Tm(e){let t=await B(qi(e));return t===null?wr():Gi(t)}function Gi(e){try{return Nn(JSON.parse(e))}catch(t){throw new g("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",y.GENERIC_FAILURE,{code:"assurance_registry_invalid",reason:String(t),nextSteps:["Restore a valid assurance.json from version control or repair its declaration references.","Run pm assurance list measurement after the repair."]})}}function Bi(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function zv(e,t){e==="measurement"?Js(t):e==="assertion"?Ks(t):Sm(t)}async function vr(e,t){let n=structuredClone(Bi(await Tm(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function Om(e,t,n){let r=Bi(await Tm(e),t).find(i=>i.id===n);if(!r)throw new Ie(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Vi(e,t,n,r={}){zv(t,n);let i=await T(e),o=q(r.author,i.author_default),s=await Sn({pmRoot:e,filePath:qi(e),op:`assurance:${t}:put`,author:o,message:r.message,lockTtlSeconds:zi,lockWaitMs:Wi,mutate:a=>{let c=a===null?wr():Gi(a),d=Bi(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&kv(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),Nn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
1
|
+
import{L as Qu,v as te,z as Ms}from"./chunk-NEK7RX3N.js";import{a as js,d as Hs,e as om,f as Us,g as sm}from"./chunk-KPASZGBL.js";import{a as ji,b as hr}from"./chunk-IIP6LZ5E.js";import{j as gm,l as ym}from"./chunk-GBU7GKNJ.js";import{c as Dt,d as Cn,e as $n,f as Tn,g as cm,j as _m}from"./chunk-TIEQVIFN.js";import{a as am}from"./chunk-XR6MLUVW.js";import{a as hs,c as di,d as li,e as cl,g as dl,h as gs,i as ys,j as vl,k as hn,l as _n,m as kl,n as bl,o as ws}from"./chunk-K35KTBDZ.js";import{g as lu,h as uu,i as As}from"./chunk-SSX5YBDC.js";import{a as Ds}from"./chunk-K53OIT5J.js";import{H as iu,I as Ai,J as ou,K as Rs,M as su,N as au,P as cu,Q as du,R as Ii,_ as Ci}from"./chunk-E2IWEJL5.js";import{K as hm}from"./chunk-KNST4PGF.js";import{A as Je,B as I,C as Hi,D as dm,E as On,F as zs,G as lm,H as um,I as xe,J as _r,K as Ui,L as mm,M as Pn,N as pm,Q as fm,Z as Ws,w as nm,y as im}from"./chunk-BEHQCHQV.js";import{a as Fs,b as rm}from"./chunk-RFDSSOTZ.js";import{$a as Ps,A as ur,Aa as pr,B as pu,C as fu,Ca as $s,D as mr,Ga as Mu,Ha as Fu,Hb as Yu,Ia as ju,Ja as Hu,Ka as Mi,M as hu,Ma as Uu,Na as zu,Oa as Wu,Pa as Kt,Pb as Xu,Qa as qu,Qb as Zu,R as _u,Ra as Rn,Sa as Gu,Ta as Ts,Ua as An,Va as Bu,Wa as Vu,Xa as Ju,Ya as Os,Za as Ku,_a as In,a as il,ab as Ls,b as mn,ba as gu,c as _s,ca as yu,d as ol,da as wu,e as sl,f as ft,g as ui,ga as Oi,h as al,i as Tt,rb as Ns,v as $i,xa as Li,ya as Eu,z as mu,za as Cs}from"./chunk-LWIIDPAV.js";import{d as fr,f as Fi,m as em,p as tm}from"./chunk-3LHBKFPD.js";import{A as Ni,C as Lu,D as ge,E as ye,F as Nu,G as Di,H as _t,I as gt,M as Du,N as yt,a as Ti,c as vu,j as Ru,k as Au,m as Iu,n as Cu,o as Nt,p as $u,q as Tu,u as Ou,v as Pu}from"./chunk-5JQVPQMN.js";import{a as re,b as bn,c as ku,d as Is,e as xn,f as Sn,g as En,h as bu,i as xu,l as Ve,q as Su,r as T,s as Pi,x as ie}from"./chunk-L2XJB5PK.js";import{$c as Ge,A as Ae,Ad as lr,B as tt,Bc as Lt,Bd as xi,C as qd,Cb as Pt,Db as Tl,Dc as qe,E as X,Eb as Ol,Ec as xs,Fa as Bt,Gc as wn,Gd as Zl,H as Gd,Hc as gi,Ic as ht,Id as Si,Jb as Pl,Jc as be,Jd as Ql,Kb as Ll,Kc as cr,Kd as eu,Lc as Wl,M as ci,Mb as Nl,Mc as ql,Md as tu,N as Xd,Nb as Dl,Nc as Gl,O as us,Oa as fs,Ob as se,Oc as Bl,P as ms,Pc as Vl,Q as ps,Qa as un,Qc as yi,Rc as Jt,S as Zd,Sa as rt,Sc as wi,T as Qd,Ua as it,Ud as U,W as el,Yc as Jl,Yd as Y,Zc as dr,_c as vn,a as Ld,ae as Be,ba as nl,bb as xl,cd as kn,ce as nu,d as Nd,dd as vi,de as Ei,e as Dd,eb as ke,ed as Kl,fb as vs,fd as ki,gb as pi,h as dn,hb as ar,hd as Yl,ib as Rl,ie as ru,jb as fi,jd as bi,kb as Al,mb as hi,nb as _i,oe as Ri,pb as Il,pc as q,q as zd,qc as Ml,qd as Ss,rd as Es,sc as Fl,sd as Xl,t as Wd,tb as Cl,tc as jl,ub as $l,uc as We,v as ds,vc as Hl,wa as rl,wc as Ul,xb as Ne,xc as ks,yc as zl,zc as bs}from"./chunk-L6NOGC4N.js";import{F as $,G as Sl,H as gn,I as Ot,J as Vt,M as yn,N as K,V as El,c as A,d as ls,e as $e,p as tl}from"./chunk-WDHNPNHX.js";import{e as Vd,f as Jd,g as W,l as sr,n as M,o as nt,p as ai,q as ln,s as Kd,t as pt,v as Yd}from"./chunk-26P6C6OO.js";import{E as Bd,G as ce,I as ll,J as pn,K as fn,L as ul,M as ml,N as pl,O as fl,P as ve,T as hl,V as Te,W as _l,X as gl,Z as Oe,ba as _e,ca as yl,da as mi,fa as wl,i as cs}from"./chunk-JFICNN4T.js";import{A as g,B as or,C as P,D as et,E as H,F as B,J as ee,a as ii,d as oi,p as Md,r as Fd,t as jd,v as Hd,w as si,x as Ud,y as $t,z as y}from"./chunk-IRYNVGKH.js";var L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},Ie=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},ot=class extends TypeError{measurement_id;source_kind;field;check;constructor(t,n){super(t),this.name="AssuranceSourceResolutionError",this.measurement_id=n.measurement_id,this.source_kind=n.source_kind,this.field=n.field,this.check=n.check}};async function Ln(e){try{return await e()}catch(t){throw t instanceof L?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function qs(e){try{return await e()}catch(t){throw t instanceof Ie?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as fv}from"node:crypto";import hv from"node:path";var vm=1,Yt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],Gs=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],_v=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],gv=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,zi=30,Wi=5e3,km=4,yv=50;function wt(e,t){if(!gv.test(e))throw new L(`${t} must be a stable lowercase id`)}function wv(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function yr(e){let t=_v.filter(i=>e[i]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function Vs(e,t){return A(e)===A(t)}function bm(e,t){if(t.polarity==="equals")return Vs(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let r=t.value;return e.every(i=>r.includes(i))}if(typeof e!="number")return!1;let n=t.value;return t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?e<=n:t.polarity==="floor"||t.polarity==="monotone_nondecreasing"?e>=n:e===0}function xm(e){let t=yr(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>bm(r.observed,t)===(r.expected==="pass"))}function vv(e,t){if(e.polarity!==t.polarity)return!0;if(typeof e.value=="number"&&typeof t.value=="number")return e.polarity==="ceiling"||e.polarity==="monotone_nonincreasing"?t.value>e.value:e.polarity==="floor"||e.polarity==="monotone_nondecreasing"?t.value<e.value:t.value!==e.value;if(e.polarity==="subset_of"){let n=e.value,r=t.value;return!Array.isArray(n)||!Array.isArray(r)||r.some(i=>!n.includes(i))}return!Vs(e.value,t.value)}function kv(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||A(e.scope)!==A(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return vv(yr(e),yr(t))||n[t.enforcement]<n[e.enforcement]||r}function bv(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new L("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,r=Number(t)+Number(n);if(e.field!==void 0&&r!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new L("items source equals/state requires field")}function xv(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new L("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(n=>n!==void 0).length>1)throw new L("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new L("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new L("dependency_kind source source_kind_state must be present or missing")}function Sv(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new L("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new L("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new L("prose_edge_gap exemption selectors must not be empty")}}function Js(e){wt(e.id,"measurement.id"),e.max_cost!==void 0&&wv(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new L(`measurement.source.kind must be one of ${Gs.join(", ")}`);let n=Reflect.get(t,"kind");if(!Gs.includes(n))throw new L(`measurement.source.kind must be one of ${Gs.join(", ")}`);let r=t;if(r.kind==="items"&&bv(r),r.kind==="dependency_kind"&&xv(r),r.kind==="prose_edge_gap"&&Sv(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new L(`${r.kind} source requires field`);return r.kind==="provider"&&(wt(r.provider,"provider source provider"),wt(r.key,"provider source key")),e}function Ks(e){if(wt(e.id,"assertion.id"),wt(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new L("assertion.owner_item_id is required");let t=yr(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new L(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new L("retired assertion requires retire_reason");e.scope.kind==="filter"&&wt(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(r=>r.expected==="pass")||!n.some(r=>r.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!xm(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function Ev(e){if(!Array.isArray(e.allowed_providers))throw new L("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)wt(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new L("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!Yt.includes(t))throw new L(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new L(`gate provider policy trigger ${t} is invalid`)}}function Sm(e){if(wt(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new L("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new L("gate requires at least one assertion");for(let t of e.assertion_ids)wt(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${Yt.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!Yt.includes(t))throw new L(`gate trigger must be one of ${Yt.join(", ")}`);return e.provider_policy&&Ev(e.provider_policy),e}function Nn(e){if(e.version!==vm)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(Js(r),t.has(`measurement:${r.id}`))throw new L(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(Ks(r),t.has(`assertion:${r.id}`))throw new L(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){Sm(r);let i=r.assertion_ids.filter(o=>!e.assertions.some(s=>s.id===o));if(i.length>0)throw new L(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new L(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of Em(e))if(!n.has(r))throw new L(`${i.join(", ")} references missing measurement ${r}`);return e}function Ys(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)Ys(n,t)}function Em(e){let t=new Map,n=(r,i)=>{let o=t.get(r)??[];o.push(i),t.set(r,o)};for(let r of e.assertions)n(r.measurement_id,`assertion ${r.id}`),r.scope.kind==="filter"&&n(r.scope.measurement_id,`assertion ${r.id} scope`);for(let r of e.measurements){if(r.source.kind!=="derived")continue;let i=[];Ys(r.source.expression,i);for(let o of i)n(o,`derived measurement ${r.id}`)}return t}function Rv(e,t){let n=e.assertion_ids.flatMap(o=>{let s=t.assertions.find(a=>a.id===o);return[s.measurement_id,...s.scope.kind==="filter"?[s.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let o=n.pop();if(r.has(o))continue;r.add(o);let s=t.measurements.find(a=>a.id===o);s.source.kind==="provider"?i.add(s.source.provider):s.source.kind==="derived"&&Ys(s.source.expression,n)}return i}function wr(){return{version:vm,measurements:[],assertions:[],gates:[]}}function Av(e,t){let n=t.items.filter(r=>(e.statuses===void 0||e.statuses.includes(r.status))&&(e.types===void 0||e.types.includes(r.type))&&(e.tags===void 0||e.tags.every(i=>r.tags?.includes(i)))&&(e.field===void 0||(()=>{let i=r[e.field];if(e.state!==void 0){let o=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?o:!o}return Vs(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function Iv(e,t){return e.source_kind!==void 0?t?.toLowerCase()===e.source_kind.trim().toLowerCase():e.source_kind_prefix!==void 0?t?.toLowerCase().startsWith(e.source_kind_prefix.trim().toLowerCase())===!0:e.source_kind_state==="present"?t!==void 0&&t.length>0:e.source_kind_state==="missing"?t===void 0||t.length===0:!0}function Cv(e,t){let n=[],r=ds(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let o of i.dependencies??[]){let s=ds(o.kind)??o.kind.trim().toLowerCase(),a=o.source_kind?.trim();s===r&&Iv(e,a)&&n.push(`${i.id}->${o.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function $v(e){let t=[e.description,e.body].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);for(let n of["comments","notes","learnings"]){let r=e[n];if(Array.isArray(r)){for(let i of r)if(typeof i=="string")t.push(i);else if(typeof i=="object"&&i!==null){let o=Reflect.get(i,"text");typeof o=="string"&&t.push(o)}}}return t}function Tv(e,t,n,r){return e.some(i=>i.holder_id.trim().toLowerCase()===t.toLowerCase()&&(i.target_id===void 0||i.target_id.trim().toLowerCase()===n.toLowerCase())&&(i.text_contains===void 0||r.toLowerCase().includes(i.text_contains.trim().toLowerCase())))}function Bs(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function Ov(e){let t=new Map,n=new Set,r=[],i=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,o=0;for(let s of e){t.set(s.id.toLowerCase(),s.id);for(let a of s.dependencies??[])n.add(Bs(s.id,a.id));for(let a of[s.parent,s.blocked_by])typeof a=="string"&&n.add(Bs(s.id,a));for(let a of $v(s)){let c=[...a.matchAll(i)].map(d=>d[0]);o+=c.length,r.push({holder_id:s.id,segment:a,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:o}}function Pv(e,t){let n=Ov(t.items),r=new Map;for(let s of n.prose_mentions){let a=s.mentioned_ids.map(d=>n.canonical_ids.get(d.toLowerCase())).filter(d=>d!==void 0&&d!==s.holder_id),c=[...new Set(a)];for(let d of c){let l=Bs(s.holder_id,d);if(n.linked_pairs.has(l)||Tv(e.exemptions??[],s.holder_id,d,s.segment))continue;let u=c.some(m=>m!==d);r.get(l)?.explicit===!0&&!u||r.set(l,{contributor:`${s.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],o=i.map(s=>s.contributor).sort();return{value:o.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:o.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(s=>s.explicit).length,implicit_subject:i.filter(s=>!s.explicit).length}}}function Lv(e,t){return{value:t.history.filter(r=>(e.op===void 0||r.op===e.op)&&(e.author===void 0||r.author===e.author)&&(e.harness===void 0||r.agent_harness===e.harness)&&(e.model===void 0||r.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function Nv(e,t){let n=t.items.filter(r=>{let i=r[e.link],o=Array.isArray(i)&&i.length>0;return e.state==="present"?o:!o});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function Dv(e,t){let n=e.source;return n.kind==="items"?Av(n,t):n.kind==="dependency_kind"?Cv(n,t):n.kind==="prose_edge_gap"?Pv(n,t):n.kind==="history"?Lv(n,t):n.kind==="links"?Nv(n,t):null}function Rm(e,t){return e.reduce((n,r)=>({units:n.units+r.units,items_scanned:n.items_scanned+r.items_scanned,history_entries:n.history_entries+r.history_entries,provider_calls:n.provider_calls+r.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function Mv(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,r)=>n+r,0);if(e==="subtract")return t.slice(1).reduce((n,r)=>n-r,t[0]);if(e==="multiply")return t.reduce((n,r)=>n*r,1);if(e==="divide"){if(t.slice(1).includes(0))throw new TypeError("derived divide cannot divide by zero");return t.slice(1).reduce((n,r)=>n/r,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function Am(e,t,n){let r=new Array(e.length),i=0,o=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let s=i;i+=1,r[s]=await n(e[s],s)}});return await Promise.all(o),r}async function Im(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let s=n.find(d=>d.id===e.measurement);if(!s)throw new TypeError(`derived measurement references missing ${e.measurement}`);let a=await Cm(s,t,n,r,i);if(typeof a.value!="number")throw new TypeError(`derived measurement ${s.id} is not numeric`);let c=i.charged.has(s.id)?[]:[a.cost];return i.charged.add(s.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let o=await Am(e.operands,km,s=>Im(s,t,n,r,i));return{value:Mv(e.operator,o.map(s=>s.value)),costs:o.flatMap(s=>s.costs),population_size:Math.max(0,...o.map(s=>s.population_size)),contributors:[...new Set(o.flatMap(s=>s.contributors))]}}async function Fv(e,t,n,r,i){Js(e);let o=Date.now(),s,a=[],c=0;if(e.source.kind==="derived"){let u=await Im(e.source.expression,t,n,[...r,e.id],i);s={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=Dv(e,t);u!==null?s=u:(s=await t.external(e.source),c=1)}let d={units:s.cost,items_scanned:e.source.kind==="items"||e.source.kind==="dependency_kind"||e.source.kind==="prose_edge_gap"||e.source.kind==="links"?t.items.length:0,history_entries:e.source.kind==="history"?t.history.length:0,provider_calls:c,duration_ms:Date.now()-o},l=Rm([...a,d],Date.now()-o);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new Ie(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${fv("sha256").update(A(e)).digest("hex")}`,value:s.value,population_size:s.population_size,cost:l,contributors:s.contributors??[],...s.partitions?{partitions:s.partitions}:{}}}function Cm(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let o=i.cache.get(e.id);if(o)return o;let s=Fv(e,t,n,r,i).catch(a=>{if(a instanceof ot&&a.measurement_id===void 0){let c={measurement_id:e.id,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}},d=new ot(a.message,c);throw d.cause=a,d}throw a});return i.cache.set(e.id,s),s}async function Xs(e,t,n=[e]){return Cm(e,t,n,[],{cache:new Map,charged:new Set})}function jv(e,t){return typeof e!="number"||typeof t.value!="number"?null:t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?t.value-e:(t.polarity==="floor"||t.polarity==="monotone_nondecreasing",e-t.value)}function Hv(e,t,n={}){Ks(e);let r=yr(e),i=e.lifetime==="retire"&&n.owner_terminal===!0;return{assertion_id:e.id,measurement_id:e.measurement_id,measurement_definition_fingerprint:t.definition_fingerprint,scope:e.scope,population_size:t.population_size,observed:t.value,bound:r,distance:jv(t.value,r),verdict:i?"retired":bm(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:xm(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function Uv(e,t,n,r){let i=Rv(e,t);if(i.size===0)return;let o=e.provider_policy,s=o?.triggers[r];if(!o||!s)throw new Ie(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(o.allowed_providers),c={low:0,medium:1,high:2};for(let d of i){if(!a.has(d))throw new Ie(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new Ie(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[s.max_cost_class])throw new Ie(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!s.allow_network)throw new Ie(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function wm(e,t,n,r,i){try{return await Xs(n,r,i)}catch(o){if(o instanceof ot){let s=o.check?` check ${o.check}`:"",a=o.measurement_id??n.id,c=new Ie(`assurance gate ${e} assertion ${t} measurement ${a} source ${o.source_kind}${s} field ${o.field} could not resolve: ${o.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:o.source_kind,field:o.field,...o.check?{check:o.check}:{}});throw c.cause=o,c}throw o}}async function $m(e,t,n,r){Nn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new Ie(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new Ie(`assurance gate ${e} does not declare trigger ${r.trigger}`);Uv(i,t,n,r.trigger);let o=await Am(i.assertion_ids,km,async c=>{let d=t.assertions.find(f=>f.id===c),l=t.measurements.find(f=>f.id===d.measurement_id),u=n;if(d.scope.kind==="active"){let f=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(h=>!f.has(h.status))}}else if(d.scope.kind==="filter"){let f=d.scope.measurement_id,h=t.measurements.find(v=>v.id===f),_=await wm(i.id,d.id,h,n,t.measurements),w=new Set(_.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(f=>f.id===d.owner_item_id),p=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return Hv(d,await wm(i.id,d.id,l,u,t.measurements),{owner_terminal:p})}),s=o.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=o.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:i.id,tree_id:n.tree_id,trigger:r.trigger,dry_run:r.dry_run===!0,evaluated_at:new Date().toISOString(),verdict:s?"block":a?"warn":"pass",exit_code:s?1:0,assertions:o,assertions_total:o.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:Rm(o.map(c=>c.cost),Math.max(0,...o.map(c=>c.cost.duration_ms)))}}function qi(e){return hv.join(e,"assurance.json")}async function Tm(e){let t=await B(qi(e));return t===null?wr():Gi(t)}function Gi(e){try{return Nn(JSON.parse(e))}catch(t){throw new g("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",y.GENERIC_FAILURE,{code:"assurance_registry_invalid",reason:String(t),nextSteps:["Restore a valid assurance.json from version control or repair its declaration references.","Run pm assurance list measurement after the repair."]})}}function Bi(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function zv(e,t){e==="measurement"?Js(t):e==="assertion"?Ks(t):Sm(t)}async function vr(e,t){let n=structuredClone(Bi(await Tm(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function Om(e,t,n){let r=Bi(await Tm(e),t).find(i=>i.id===n);if(!r)throw new Ie(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Vi(e,t,n,r={}){zv(t,n);let i=await T(e),o=q(r.author,i.author_default),s=await Sn({pmRoot:e,filePath:qi(e),op:`assurance:${t}:put`,author:o,message:r.message,lockTtlSeconds:zi,lockWaitMs:Wi,mutate:a=>{let c=a===null?wr():Gi(a),d=Bi(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&kv(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),Nn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
2
2
|
`,result:{changed:!0,action:u,kind:t,id:n.id}}}});return{...s.result,changed:s.changed}}async function Zs(e,t,n={}){let r=wr();r.measurements=structuredClone(t.measurements),r.assertions=structuredClone(t.assertions),r.gates=structuredClone(t.gates),Nn(r);let i=await T(e),o=q(n.author,i.author_default),s=await Sn({pmRoot:e,filePath:qi(e),op:"assurance:bundle:apply",author:o,message:n.message,lockTtlSeconds:zi,lockWaitMs:Wi,mutate:a=>{let c=a===null?wr():Gi(a),d=[],l=[],u=(m,p,f)=>{for(let h of p){let _=m.find(w=>w.id===h.id);if(!_){m.push(structuredClone(h)),d.push(`${f}:${h.id}`);continue}if(A(_)!==A(h))throw new L(`assurance bundle refuses to replace divergent ${f} ${h.id}`);l.push(`${f}:${h.id}`)}};return u(c.measurements,r.measurements,"measurement"),u(c.assertions,r.assertions,"assertion"),u(c.gates,r.gates,"gate"),Nn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
3
3
|
`,result:{changed:d.length>0,created_ids:d,unchanged_ids:l}}}});return{...s.result,changed:s.changed}}async function Pm(e,t,n,r={}){let i=await T(e),o=q(r.author,i.author_default),s=await Sn({pmRoot:e,filePath:qi(e),op:`assurance:${t}:remove`,author:o,message:r.message,lockTtlSeconds:zi,lockWaitMs:Wi,mutate:a=>{let c=a===null?wr():Gi(a);if(t==="measurement"){let u=Em(c).get(n);if(u&&u.length>0)throw new L(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new L(`assurance assertion ${n} is referenced by gate`);let d=Bi(c,t),l=d.findIndex(u=>u.id===n);if(l<0)throw new L(`assurance ${t} ${n} not found`);return d.splice(l,1),Nn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
4
4
|
`,result:{changed:!0,action:"removed",kind:t,id:n}}}});return{...s.result,changed:s.changed}}async function Lm(e,t,n={}){if(t.dry_run)throw new TypeError("dry-run assurance verdicts are not persisted");let r=await T(e);await xn({pmRoot:e,op:"assurance:gate:verdict",author:q(n.author,r.author_default),context:{assurance_verdict:t},message:n.message??`Assurance gate ${t.gate_id} returned ${t.verdict}`,lockTtlSeconds:zi,lockWaitMs:Wi})}async function Nm(e,t={}){let n=t.limit??yv;if(!Number.isInteger(n)||n<1||n>1e3)throw new TypeError(`assurance verdict limit must be an integer from 1 through ${1e3}`);return(await We(bn(e),re)).reverse().filter(i=>i.op==="assurance:gate:verdict").map(i=>i.context?.assurance_verdict).filter(i=>typeof i=="object"&&i!==null&&"gate_id"in i).filter(i=>t.gate_id===void 0||i.gate_id===t.gate_id).slice(0,n)}import{AsyncLocalStorage as Wv}from"node:async_hooks";import Dm from"node:path";var Mm=new Wv;function Fm(e,t){return Mm.run({...e,pmRoot:Dm.resolve(e.pmRoot)},t)}function zL(e,t){let n=Mm.getStore();return n!==void 0&&n.pmRoot===Dm.resolve(e)&&n.transactionId===t?n.step:void 0}import{mkdir as qv,readFile as Gv}from"node:fs/promises";import Hm from"node:path";import{createHash as Bv}from"node:crypto";var Qs=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},Um="sdk-workspace-transaction",zm=/^[a-zA-Z0-9._-]+$/,Wm=30,qm=3e3;function ia(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!zm.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function ea(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function oa(e){return{pmRoot:ea(e.pmRoot,"Transaction pmRoot"),transactionId:ia(e.transactionId,"Transaction id"),author:ea(e.author,"Transaction author")}}function Ki(e,t,n){let r=e??t;if(!Number.isInteger(r)||r<=0)throw new TypeError(`${n} must be a positive integer`);return r}function Gm(e,t){return Hm.join(e,"transactions","sdk",`${t}.json`)}async function st(e,t){t.updatedAt=$();let n=Gm(e,t.transactionId);await qv(Hm.dirname(n),{recursive:!0}),await ee(n,`${JSON.stringify(t,null,2)}
|
|
@@ -74,4 +74,4 @@ ${o}`,y.GENERIC_FAILURE)}}function is(e){return typeof e.tag=="string"&&e.tag.tr
|
|
|
74
74
|
`);de(e.progressEnabled,"writing keyword artifacts"),await ee(t,`${JSON.stringify(e.manifest,null,2)}
|
|
75
75
|
`),await ee(n,`${i}
|
|
76
76
|
`);let o=[];if(e.mode!=="keyword")try{de(e.progressEnabled,"writing vectorization status ledger"),await Bu(e.pmRoot,e.vectorizationLedgerEntries,e.vectorizationEmbeddingMetadata)}catch(s){o.push(`search_vectorization_status_ledger_write_failed:${s instanceof Error?s.message:String(s)}`)}return o}async function nK(e,t){let n=sL(e.mode),r=oL(e),i=e.full===!0;de(r,`start mode=${n}`);let o=M(process.cwd(),t.path);await ie(o);let s=Li(await T(o)).settings,a=null;try{a=await se(o,Eu,s.locks.ttl_seconds,q(void 0,"pm-reindex"),!1,s.governance.force_required_for_stale_lock,s.locks.wait_ms)}catch(c){throw c instanceof g&&c.exitCode===y.CONFLICT?new g("Another pm reindex run is already active for this project. Wait for it to finish before starting a new keyword, semantic, or hybrid reindex.",y.CONFLICT,{code:"reindex_already_running",type:"urn:pm-cli:error:reindex_already_running",why:"Semantic reindex can be expensive and duplicate runs compete for the same local embedding model and vector store.",nextSteps:["Check active pm reindex processes before starting another reindex.","Rerun with --progress when you need non-interactive visibility."]}):c}try{let c=dL(s),d=lL(s),l=_L({requestedMode:n,pmRoot:o,settings:s,extensionEmbedding:c,extensionVectorAdapter:d}),u=n;de(r,"loading item corpus");let m=await gL({pmRoot:o,settings:s}),p=m.warnings,{documentCandidates:f,metadataDocuments:h}=m;de(r,`loaded_items=${h.length}`);let _=$(),w=hL(u,_,h),v=ni.join(o,Cd),k=ni.join(o,$d),x=u==="keyword"?await Od(o,f,s.schema,p):h,E=[],R={},S=null,b=fL(u);if(u==="keyword"&&await yL({pmRoot:o,settings:s,forceFullSemantic:i,extensionEmbedding:c,reindexWarnings:p}),u!=="keyword"){let C=await EL({pmRoot:o,settings:s,requestedMode:n,activeEmbeddingProvider:l.activeEmbeddingProvider,activeVectorStore:l.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:d,documentCandidates:f,metadataDocuments:h,documentsForKeywordArtifacts:x,forceFullSemantic:i,reindexWarnings:p,semanticWarnings:E,semanticSummary:b,progressEnabled:r});x=C.documentsForKeywordArtifacts,R=C.vectorizationLedgerEntries,S=C.vectorizationEmbeddingMetadata}let D=await RL({pmRoot:o,mode:u,manifest:w,documentsForKeywordArtifacts:x,settings:s,vectorizationLedgerEntries:R,vectorizationEmbeddingMetadata:S,progressEnabled:r}),F=[...await Y({path:v,scope:"project",op:"reindex:manifest"}),...await Y({path:k,scope:"project",op:"reindex:embeddings"}),...await Ei({mode:u,total_items:h.length})];return de(r,"done"),{ok:!0,mode:u,total_items:h.length,semantic:b,artifacts:{manifest:Cd,embeddings:$d},warnings:[...p,...E,...D,...F],generated_at:_}}finally{await a?.()}}export{L as a,Ie as b,ot as c,Ln as d,qs as e,vm as f,Yt as g,Gs as h,kv as i,Js as j,Ks as k,Sm as l,Nn as m,wr as n,Xs as o,Hv as p,$m as q,vr as r,Om as s,Vi as t,Zs as u,Pm as v,Lm as w,Nm as x,zL as y,oa as z,Jm as A,tN as B,tk as C,nN as D,rk as E,oN as F,Zm as G,sk as H,xN as I,lx as J,iF as K,oF as L,sF as M,Or as N,aF as O,cF as P,dF as Q,lF as R,uF as S,mF as T,pF as U,fF as V,hF as W,_F as X,gF as Y,Th as Z,ec as _,ND as $,zp as aa,lk as ba,ip as ca,MN as da,Sr as ea,FN as fa,gk as ga,yk as ha,jN as ia,wk as ja,U0 as ka,Oy as la,aT as ma,Dy as na,qN as oa,up as pa,Fy as qa,cB as ra,dB as sa,Er as ta,Qi as ua,pp as va,fp as wa,hp as xa,_p as ya,vp as za,ua as Aa,bp as Ba,Ep as Ca,Rp as Da,Fk as Ea,Ip as Fa,Ht as Ga,g1 as Ha,y1 as Ia,w1 as Ja,v1 as Ka,I1 as La,U_ as Ma,Oo as Na,X1 as Oa,Et as Pa,Y_ as Qa,Z1 as Ra,Q1 as Sa,jI as Ta,WI as Ua,tg as Va,Hk as Wa,pa as Xa,Vr as Ya,EW as Za,RW as _a,to as $a,no as ab,Bg as bb,Mq as cb,Vg as db,Kg as eb,Yg as fb,Qg as gb,ty as hb,RT as ib,AT as jb,hB as kb,_B as lb,gB as mb,yB as nb,Uy as ob,CT as pb,Wy as qb,Bo as rb,Gy as sb,By as tb,Vy as ub,TT as vb,PT as wb,NT as xb,wB as yb,DT as zb,id as Ab,od as Bb,$B as Cb,TB as Db,OB as Eb,mO as Fb,YV as Gb,Lw as Hb,Zr as Ib,Mw as Jb,Fw as Kb,jw as Lb,kd as Mb,kP as Nb,PJ as Ob,n2 as Pb,u2 as Qb,ev as Rb,tv as Sb,nv as Tb,N2 as Ub,J2 as Vb,K2 as Wb,Y2 as Xb,nK as Yb};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-VEUBDQDP.js.map
|