@unbrained/pm-cli 2026.11.27 → 2026.11.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/commander-usage.js +4 -4
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/linked-resource-value-list.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3AZOATC2.js +2 -0
- package/dist/cli-bundle/chunks/chunk-3E53F7QY.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-5CMR4R5V.js → chunk-3TK2YOVB.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-O23KTJL6.js → chunk-3US5T6B2.js} +63 -63
- package/dist/cli-bundle/chunks/chunk-4EBHZBM2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-MGJMQSN4.js → chunk-4QA5O64H.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-5EFS7K7Y.js +1 -0
- package/dist/cli-bundle/chunks/chunk-CNZOC6JD.js +2 -0
- package/dist/cli-bundle/chunks/chunk-CV2B4JUB.js +3 -0
- package/dist/cli-bundle/chunks/chunk-DBASKWBO.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZGV4ZXDS.js → chunk-EYEQC3L2.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-FRYNDVLN.js +8 -0
- package/dist/cli-bundle/chunks/chunk-GSLOAEY2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-KS47NGMQ.js → chunk-JFPCL45G.js} +14 -14
- package/dist/cli-bundle/chunks/chunk-JQHLOSSS.js +4 -0
- package/dist/cli-bundle/chunks/chunk-JV7LREUF.js +3 -0
- package/dist/cli-bundle/chunks/chunk-K3MVVDLN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-6OIHST4I.js → chunk-K672XXGQ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-KP75JTTO.js → chunk-KCR4NF2A.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-L7HON3BE.js +23 -0
- package/dist/cli-bundle/chunks/chunk-LQEB6GSY.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-W7SPEGSP.js → chunk-NLHNB2L3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-63AVXDZS.js → chunk-NRCGGNOE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KHFUHGL3.js → chunk-OGVSGXQX.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-PY6A7ULK.js +125 -0
- package/dist/cli-bundle/chunks/{chunk-6NJ3BONB.js → chunk-Q6GIFUCW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-X6TE47CS.js → chunk-R6M5OGJH.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-RWHS77ME.js +113 -0
- package/dist/cli-bundle/chunks/chunk-SV27NNXQ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-TE6FBDHP.js +4 -0
- package/dist/cli-bundle/chunks/chunk-VI3A7UZ2.js +2 -0
- package/dist/cli-bundle/chunks/chunk-WLZ5KVM2.js +2 -0
- package/dist/cli-bundle/chunks/chunk-WNB62BGK.js +10 -0
- package/dist/cli-bundle/chunks/chunk-X5D5YUHR.js +2 -0
- package/dist/cli-bundle/chunks/chunk-ZK4CY24V.js +2 -0
- package/dist/cli-bundle/chunks/chunk-ZSBPE36C.js +2 -0
- package/dist/cli-bundle/chunks/field-definition-losses-XKE4DRUA.js +2 -0
- package/dist/cli-bundle/chunks/field-option-collisions-OZE43TOH.js +2 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-H3MMNXXG.js → indexed-receipt-blobs-DR3FDHND.js} +2 -2
- package/dist/cli-bundle/{focused-chunks/item-revision-NOHVIOQQ.js → chunks/item-revision-3WXNNFLP.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-DJ5GAITL.js +2 -0
- package/dist/cli-bundle/chunks/linked-resource-value-list-2655COY2.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-QOKPDYM4.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-JNJHB3E6.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-Q7UW2EPV.js → register-list-query-YGVUE4YZ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-YNW7E3T4.js → register-mutation-3JVZQDHH.js} +2 -2
- package/dist/cli-bundle/chunks/register-operations-LCHUHKRA.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-IJ7M3VUK.js +2 -0
- package/dist/cli-bundle/chunks/runtime-schema-OAIUNQRL.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-ESAAEBRM.js → settlement-hook-BIVNGBZF.js} +2 -2
- package/dist/cli-bundle/chunks/stage-7BD7U2BX.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-26P6C6OO.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-2CQFGJQ6.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-42SU4LK3.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-5NSWNLFE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4HLZOOZI.js → chunk-ACTBMSCH.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-BPBKHY6H.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UGQ2EXTU.js → chunk-BPOU2S44.js} +57 -57
- package/dist/cli-bundle/focused-chunks/chunk-BZ3PUUPG.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-CWQLW4ZO.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-N7ZAMULP.js → chunk-EUDAUT6T.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-GTUPHXKR.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NGFDPEP7.js → chunk-IRYNVGKH.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-JFICNN4T.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-AL47ODFZ.js → chunk-KLOHZNJ4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KPASZGBL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-24W63UPP.js → chunk-KWKPX36T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-HSWL6L2O.js → chunk-LKTRICZR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7FKGIJEB.js → chunk-LSVRZ4KQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MYWUMVCZ.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-NNLENKU7.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-NO5MUY4I.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-52PHSTGP.js → chunk-NZA2LP4Y.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GUAT4OAC.js → chunk-PPCBCPIZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QTV6UE2Q.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-REORRDPH.js → chunk-S4AC7OMI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7GZMOLQY.js → chunk-S5VG7RFY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-TSZVCALS.js +91 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YPOATPTX.js → chunk-TX24L7RQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WJAUHPXD.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4SX2BN4V.js → chunk-XR6MLUVW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/field-definition-losses-GGA6FUHD.js +2 -0
- package/dist/cli-bundle/focused-chunks/field-option-collisions-HABQYZMQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-PG2VJ3MB.js → indexed-receipt-blobs-EUYZJR5R.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-YH5R7YPW.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-YZ2PUPGM.js +2 -0
- package/dist/cli-bundle/{chunks/mutation-actor-SFYTD2ZB.js → focused-chunks/mutation-actor-DJ2VRLKG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-3SECKVKY.js +2 -0
- package/dist/cli-bundle/focused-chunks/runtime-schema-IDRXWCC4.js +2 -0
- package/dist/cli-bundle/focused-chunks/{settlement-hook-4MGRERCT.js → settlement-hook-Q6MJQKIE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/stage-FEJT2UCG.js +2 -0
- package/dist/cli-bundle/main.js +26 -26
- 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 +2 -2
- package/dist/core/extensions/item-fields.d.ts +33 -2
- package/dist/core/extensions/item-fields.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/fs/fs-utils.d.ts +8 -0
- package/dist/core/fs/fs-utils.js +2 -2
- package/dist/core/item/item-type-inspection.js +2 -0
- package/dist/core/item/type-registry.js +1 -1
- package/dist/core/profile/profile-lint.js +1 -1
- package/dist/core/schema/runtime-schema.d.ts +39 -1
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/store/settings.d.ts +7 -0
- package/dist/core/store/settings.js +5 -5
- package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
- package/dist/sdk/extension/command-options.d.ts +8 -0
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/update.js +2 -2
- package/dist/sdk/profile.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/schema/field-definition-losses.js +2 -0
- package/dist/sdk/schema/field-option-collisions.js +1 -1
- package/dist/sdk/schema/schema-file-entry-losses.js +2 -0
- package/dist/sdk/schema.js +2 -2
- package/dist/sdk/test/execution.d.ts +9 -1
- package/dist/sdk/test/execution.js +4 -4
- package/docs/COMMANDS.md +3 -1
- package/docs/CONFIGURATION.md +2 -0
- package/docs/EXTENSIONS.md +1 -1
- package/docs/SDK_AUDITED_MUTATIONS.md +21 -3
- package/marketplace.json +1 -1
- package/node_modules/fast-json-patch/README.md +2 -2
- package/node_modules/fast-json-patch/dist/fast-json-patch.js +604 -818
- package/node_modules/fast-json-patch/dist/fast-json-patch.min.js +4 -8
- package/node_modules/fast-json-patch/package.json +14 -17
- package/package.json +2 -2
- 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-5M7UTO2G.js +0 -2
- package/dist/cli-bundle/chunks/chunk-66TNCHHG.js +0 -2
- package/dist/cli-bundle/chunks/chunk-AVHRMUXJ.js +0 -3
- package/dist/cli-bundle/chunks/chunk-HTT52JL3.js +0 -125
- package/dist/cli-bundle/chunks/chunk-J25DZRYJ.js +0 -31
- package/dist/cli-bundle/chunks/chunk-J6TFG34A.js +0 -4
- package/dist/cli-bundle/chunks/chunk-JX475QVU.js +0 -3
- package/dist/cli-bundle/chunks/chunk-OFX2VA5Z.js +0 -2
- package/dist/cli-bundle/chunks/chunk-QVDEZBSV.js +0 -8
- package/dist/cli-bundle/chunks/chunk-SIRZ4VMT.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SX76UGEY.js +0 -3
- package/dist/cli-bundle/chunks/chunk-VC4BJIA7.js +0 -9
- package/dist/cli-bundle/chunks/chunk-WY7467RY.js +0 -3
- package/dist/cli-bundle/chunks/chunk-XB6QEVUK.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XYX4CXFR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-Y5U7QCNX.js +0 -2
- package/dist/cli-bundle/chunks/chunk-YGK6SA7P.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZILIHDDY.js +0 -113
- package/dist/cli-bundle/chunks/field-option-collisions-UL6BIPAK.js +0 -2
- package/dist/cli-bundle/chunks/item-revision-WNUDY5DM.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-ER3OWOPV.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-AVOOT3KH.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-DAUTQCIO.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-VSURGF7V.js +0 -2
- package/dist/cli-bundle/chunks/runtime-schema-Y4SHTEXL.js +0 -2
- package/dist/cli-bundle/chunks/stage-N5GDBS5A.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2XGHBYDA.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-3QRMY6KF.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-AN4NFFLL.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-B2HJI6KA.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-C2HW7BSE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-GISZWMBS.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-H4JBS477.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HGJ4MILN.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-I4GY7HAP.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-KMG4O2IU.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-OCKKIECS.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-SXWUKNTY.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-ZZYJS74B.js +0 -91
- package/dist/cli-bundle/focused-chunks/field-option-collisions-BP7ILGQK.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-O26COBOJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-actor-HVJV5S76.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-JRICEVYN.js +0 -2
- package/dist/cli-bundle/focused-chunks/runtime-schema-YXPYDD2C.js +0 -2
- package/dist/cli-bundle/focused-chunks/stage-NSX6ASBZ.js +0 -2
- package/node_modules/fast-json-patch/webpack.config.js +0 -63
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{normalizeItemFieldType as _}from"./item-field-types.js";import{EXIT_CODE as
|
|
1
|
+
import{normalizeItemFieldType as _}from"./item-field-types.js";import{EXIT_CODE as l,ITEM_METADATA_KEY_ORDER as A}from"../shared/constants.js";import{PmCliError as f}from"../shared/errors.js";const c=new Set(A),p=Object.freeze({get size(){return c.size},has(e){return c.has(e)},entries(){return c.entries()},keys(){return c.keys()},values(){return c.values()},forEach(e,t){c.forEach(r=>e.call(t,r,r,p))},[Symbol.iterator](){return c.values()}});function u(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function m(e){return typeof e!="string"?null:_(e)}function w(e){try{return structuredClone(e)}catch{return e}}function $(e){const t=e.trim(),r=t.indexOf("=");if(r<=0)throw new f(`--field entries must use name=value syntax, received: ${e}`,l.USAGE);const n=t.slice(0,r).trim(),i=t.slice(r+1);return{key:n,value:i}}function x(e,t,r){try{const n=JSON.parse(e);if(r==="array"&&Array.isArray(n)||r==="object"&&typeof n=="object"&&n!==null&&!Array.isArray(n))return n}catch{}throw new f(`--field ${t}=... must be valid JSON ${r}`,l.USAGE)}function E(e,t,r){if(t==="string")return r;if(t==="number"){const n=r.trim();if(n.length===0)throw new f(`--field ${e}=... must be a number`,l.USAGE);const i=Number(n);if(!Number.isFinite(i))throw new f(`--field ${e}=... must be a number`,l.USAGE);return i}if(t==="boolean"){const n=r.trim().toLowerCase();if(n==="true"||n==="1"||n==="yes")return!0;if(n==="false"||n==="0"||n==="no")return!1;throw new f(`--field ${e}=... must be one of true|false|1|0|yes|no`,l.USAGE)}return t==="string_array"?r.split(/[\n,|]/u).map(n=>n.trim()).filter(n=>n.length>0):x(r,e,t)}function h(e){const t=new Map;if(!e)return t;for(const r of e.item_fields)for(const n of r.fields){const i=u(n.name),o=m(n.type);if(!i||!o)continue;const s=t.get(i);if(s&&s.type!==o)throw new f(`Extension item field "${i}" is declared with conflicting types: ${s.type}, ${o}`,l.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(i,{name:i,type:o})}return t}function g(e){if(p.has(e))throw new f(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...p].sort((t,r)=>t.localeCompare(r)).join(", ")}.`,l.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function G(e,t,r){const n=t.replace(/^@[^/]+\//u,"").replaceAll(/[^A-Za-z0-9]+/gu,"_").toLowerCase();return`extension_item_field_reserved:${e}:${t}:${r}:rename=${n}_${r}`}function j(e,t){const r=u(t.name),n=m(t.type);if(!(!r||!n))for(const i of e)for(const o of i.fields){const s=m(o.type);if(!(u(o.name)!==r||!s))return s===n?void 0:{layer:i.layer,name:i.name,type:s}}}function C(e,t,r,n){return`extension_item_field_type_conflict:${e}:${t}:${u(r.name)}:${m(r.type)}:kept=${n.layer}:${n.name}:${n.type}`}function D(e){return[...h(e).keys()].sort((t,r)=>t.localeCompare(r))}function z(e,t,r,n){if(!e||e.length===0)return{};const i=h(t),o={};for(const s of e){const{key:a,value:y}=$(s),d=i.get(a);if(!d)throw b(a,i,r,n);g(d.name),o[d.name]=E(d.name,d.type,y)}return o}function b(e,t,r,n){if(p.has(e)){const s=r?.(e)??{recovery:{provided_fields:[e]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};return new f(`--field ${e} is a core item field, not an extension field`,l.USAGE,{code:"core_item_field_requires_dedicated_flag",field:e,...s})}const i=n?.(e);if(i!==void 0){const s=i.recovery?.suggested_flags?.[0];return new f(s===void 0?`--field ${e} is a project-schema field, not an extension field`:`--field ${e} is a project-schema field; set it with its declared flag ${s}`,l.USAGE,{code:"project_schema_field_requires_declared_flag",field:e,changed:!1,...i})}const o=[...t.keys()].sort((s,a)=>s.localeCompare(a));return new f(`--field ${e} is not declared by an active extension item-field registration`,l.USAGE,{code:"extension_item_field_unknown",field:e,recovery:{provided_fields:[e]},nextSteps:o.length>0?[`Use one of the declared fields: ${o.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}function F(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(r=>typeof r=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function S(e,t){return!t||t.length===0?!0:t.some(r=>Object.is(r,e))}function I(e,t,r={}){if(t){h(t);for(const n of t.item_fields)for(const i of n.fields){const o=u(i.name);if(!o)continue;g(o),!(o in e)&&!r.skipDefaultFields?.has(o)&&Object.prototype.hasOwnProperty.call(i,"default")&&(e[o]=w(i.default));const s=e[o];if(s===void 0)continue;const a=m(i.type);if(a&&!F(s,a))throw new TypeError(`Item field "${o}" must be of type ${a}`);const y=Array.isArray(i.values)?i.values:void 0;if(!S(s,y))throw new TypeError(`Item field "${o}" must match one of the configured allowed values`)}}}function N(e,t,r={}){try{I(e,t,r)}catch(n){throw n instanceof f?n:new f(n.message,l.USAGE)}}export{p as RESERVED_ITEM_FIELD_NAMES,I as applyRegisteredItemFieldDefaultsAndValidation,N as applyRegisteredItemFieldDefaultsForWrite,D as collectRegisteredItemFieldNames,j as findConflictingItemFieldDeclaration,C as formatItemFieldTypeConflictWarning,G as formatReservedItemFieldWarning,z as parseRegisteredItemFieldAssignments};
|
|
2
2
|
//# sourceMappingURL=item-fields.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import w from"node:fs/promises";import x from"node:path";import{pathToFileURL as xe}from"node:url";import{createRelationshipKindRegistry as Ee}from"../../sdk/relationships.js";import{pathExists as H}from"../fs/fs-utils.js";import{isPathWithinDirectory as L}from"../fs/path-utils.js";import{isHostOutputSuppressed as be,suppressHostOutput as Ce}from"../output/output-control.js";import{resolvePmPackageRootFromModule as Re}from"../packages/root.js";import{asRecordLoose as B,resolveActivatablePropertyRecord as ke}from"../shared/primitives.js";import{resolveGlobalPmRoot as $e}from"../store/paths.js";import{captureExtensionActivationRollback as Pe}from"./activation-transaction.js";import{assertCommandDefinitionMetadataStrings as Se}from"./command-visibility-tier.js";import{normalizeExtensionReadOutput as Ie}from"./read-output-contract.js";import{normalizeExtensionContributionInventory as Me}from"./contribution-inventory.js";import{buildImportExportContext as U,resolveImportExportArtifactOutput as Ae}from"./exporter-output-contract.js";import{buildReadyExtensionCandidate as Te}from"./extension-candidate.js";import{collectUnknownExtensionCapabilities as De,formatLegacyExtensionCapabilityAliasWarning as Fe,formatUnknownExtensionCapabilityWarning as Oe,isKnownExtensionCapability as ze,normalizeNames as K}from"./extension-capability-aliases.js";import{evaluateExtensionPolicyForCapability as We,evaluateExtensionPolicyForExtension as je,evaluateExtensionPolicyForRegistration as Ne,hydrateExtensionPolicy as Ve,normalizeExtensionPolicy as qe,serializeExtensionPolicy as He}from"./extension-policy.js";import{createEmptyExtensionCommandRegistry as Le,createEmptyExtensionHookRegistry as Be,createEmptyExtensionParserRegistry as Ue,createEmptyExtensionPreflightRegistry as Ke,createEmptyExtensionRegistrationRegistry as Xe,createEmptyExtensionRendererRegistry as Ge,createEmptyExtensionServiceRegistry as Je}from"./extension-registries.js";import{normalizeCommandName as b}from"./extension-runtime-helpers.js";import{KNOWN_EXTENSION_CAPABILITIES as Ye,KNOWN_EXTENSION_SERVICE_NAMES as Qe,createDefaultExtensionGovernancePolicy as Ze}from"./extension-types.js";import{parseExtensionManifestDocument as X}from"./manifest-parser.js";import{formatExtensionManifestSchemaWarnings as er}from"./manifest-schema.js";import{snapshotExtensionModuleGraph as rr}from"./module-graph-snapshot.js";import{collectPreflightCollisionWarnings as tr,normalizePreflightOverride as nr}from"./preflight-ownership.js";import{applyProjectProfileDefaults as ir,assertFlagValueTypeAndDefault as sr,normalizeCommandDefinitionArguments as T,normalizeFlagDefinitions as D,resolveCommandDefinitionAction as F,validateFlagDefinitions as O,validateItemFieldDefinitions as G,validateItemTypeDefinitions as or,validateMigrationDefinition as ar,validateProjectProfileDefinition as mr}from"./registration-contracts.js";import{assertOptionalStringField as $,normalizeOptionalStringArrayField as C}from"./registration-validation.js";import{assertHookHandler as E,assertNonEmptyRegistrationString as P,assertRegistrationFunction as S,attachRuntimeDefinition as I,cloneRuntimeRegistrationValue as cr,createRegistrationValidationError as y,extractRegistrationValidationTrace as J,isExtensionServiceName as lr,isOutputRendererFormat as dr,normalizeRegistrationName as Y,normalizeRegistrationRecord as R,normalizeRegistrationRecordList as z,normalizeRuntimeRegistrationRecord as k,sanitizeRegistrationValue as Q,toRegistrationCommandPath as Z,validateAssuranceMeasurementProviderDefinition as ur}from"./registration-values.js";import{normalizeServiceOverrideOwnership as hr}from"./service-ownership.js";import{compareComparableVersions as pr,evaluatePmMaxVersionBound as fr,evaluatePmMinVersionBound as gr,parseComparableVersion as yr}from"./version-compat.js";import{parseLegacyExtensionCapabilityAliasWarning as wt,parseUnknownExtensionCapabilityWarning as xt}from"./extension-capability-aliases.js";import{createEmptyExtensionCommandRegistry as bt,createEmptyExtensionHookRegistry as Ct,createEmptyExtensionParserRegistry as Rt,createEmptyExtensionPreflightRegistry as kt,createEmptyExtensionRegistrationRegistry as $t,createEmptyExtensionRendererRegistry as Pt,createEmptyExtensionServiceRegistry as St}from"./extension-registries.js";import{runAfterCommandHooks as Mt,runBeforeCommandHooks as At,runBeforeMutationHooks as Tt,runCommandHandler as Dt,runCommandOverride as Ft,runOnIndexHooks as Ot,runOnReadHooks as zt,runOnWriteHooks as Wt,runParserOverride as jt,runPreflightOverride as Nt,runRendererOverride as Vt,runServiceOverride as qt,runServiceOverrideSync as Ht}from"./extension-hook-runtime.js";export*from"./extension-types.js";import{DEFAULT_EXTENSION_PRIORITY as Ut,parseExtensionManifestDocument as Kt}from"./manifest-parser.js";let W=null;const _r=Object.freeze(Ze());let ee=0;function vr(r=Date.now()){return ee+=1,`${ee}-${r}`}function wr(r,e,t){return t.has(r)?!1:e.size===0?!0:e.has(r)}async function xr(r,e){const[t,n]=await Promise.all([w.realpath(r),w.realpath(e)]);return L(t,n)}function Er(r,e=process.cwd()){return{global:x.join($e(e),"extensions"),project:x.join(r,"extensions")}}async function br(r){try{return(await w.readdir(r,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n))}catch{return[]}}function Cr(r){const e={layer:r.layer,directory:r.directory,manifest_path:r.manifest_path,name:r.manifest.name,version:r.manifest.version,entry:r.manifest.entry,priority:r.manifest.priority,entry_path:r.entry_path,manifest_version:r.manifest.manifest_version,pm_min_version:r.manifest.pm_min_version,pm_max_version:r.manifest.pm_max_version,engines:r.manifest.engines,trusted:r.manifest.trusted,provenance:r.manifest.provenance,sandbox_profile:r.manifest.sandbox_profile,permissions:r.manifest.permissions,capabilities:[...r.manifest.capabilities],activation:r.manifest.activation?{commands:[...r.manifest.activation.commands]}:void 0,contributions:r.manifest.contributions??r.contributions};return r.source_package&&(e.source_package=r.source_package),r.source_aliases&&(e.source_aliases=[...r.source_aliases]),e}function re(r){return typeof r=="string"&&r.trim().length>0?r.trim():void 0}async function te(r){const e=new Map;try{const t=JSON.parse(await w.readFile(x.join(r,".managed-extensions.json"),"utf8")),i=B(t)?.entries;if(!Array.isArray(i))return e;for(const o of i){if(typeof o!="object"||o===null)continue;const s=o,a=re(s.source?.package),m=[s.source?.input,s.source?.name,a].map(d=>re(d)).filter(d=>d!==void 0),c=Me(s.contributions),l={aliases:[...new Set(m)],...a?{package_name:a}:{},...c?{contributions:c}:{}};typeof s.directory=="string"&&s.directory.trim().length>0&&e.set(`directory:${s.directory.trim()}`,l),typeof s.name=="string"&&s.name.trim().length>0&&e.set(`name:${s.name.trim()}`,l)}}catch{return e}return e}function ne(r){return[...r].sort((e,t)=>{if(e.manifest.priority!==t.manifest.priority)return e.manifest.priority-t.manifest.priority;const n=e.manifest.name.localeCompare(t.manifest.name);return n!==0?n:e.directory.localeCompare(t.directory)})}function Rr(r,e){const t=[...ne(r),...ne(e)],n=[];for(const i of t){const o=n.findIndex(s=>s.manifest.name===i.manifest.name);o>=0&&n.splice(o,1),n.push(i)}return n}async function ie(r,e,t,n,i){const o=[],s=[],a=[],m=await br(e),c=await te(e);for(const l of m){const d=await Pr(r,e,l,t,n,c,i);o.push(d.diagnostic),s.push(...d.warnings),d.candidate&&a.push(d.candidate)}return{diagnostics:o,warnings:s,candidates:a}}function kr(){return{diagnostics:[],warnings:[],candidates:[]}}function se(r,e,t,n){return{diagnostic:{layer:r,directory:e,manifest_path:t,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[n],candidate:null}}function $r(r,e,t,n,i,o,s,a){const m=er(r,e,t);Array.isArray(e.legacy_capability_aliases)&&e.legacy_capability_aliases.length>0&&m.push(Fe(r,e.name,e.legacy_capability_aliases));for(const c of De(e.capabilities))m.push(Oe(r,e.name,c));return n?i||m.push(`extension_entry_missing:${r}:${e.name}`):m.push(`extension_entry_outside_extension:${r}:${e.name}`),o.warning&&m.push(a?o.warning:o.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&m.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),m}async function Pr(r,e,t,n,i,o,s){const a=x.join(e,t),m=x.join(a,"manifest.json");if(!await H(m))return se(r,t,m,`extension_manifest_missing:${r}:${t}`);let c,l;try{const q=JSON.parse(await w.readFile(m,"utf8"));l=B(q),c=X(q)}catch{l=null,c=null}if(!c||!l)return se(r,t,m,`extension_manifest_invalid:${r}:${t}`);const d=x.resolve(a,c.entry),h=L(a,d),u=h?await H(d):!1,f=h&&u?await xr(a,d):h,g=wr(c.name,n,i),v=await me(r,c),_=await ce(r,c,s),A=$r(r,c,l,f,u,v,_,g),V=f&&u&&v.allowed&&_.allowed,we=o.get(`directory:${t}`)??o.get(`name:${c.name}`);return{diagnostic:{layer:r,directory:t,manifest_path:m,name:c.name,version:c.version,entry:c.entry,priority:c.priority,entry_path:d,enabled:g,status:V?"ok":"warn"},warnings:A,candidate:Te({layer:r,directory:t,manifestPath:m,entryPath:d,manifest:c,sourceIdentity:we,extensionReady:V,enabledForLoad:g})}}async function Sr(r){const e=Er(r.pmRoot,r.cwd??process.cwd()),t=K(r.settings.extensions.enabled),n=K(r.settings.extensions.disabled),i=qe(r.settings),o=He(i);if(r.noExtensions)return{disabled_by_flag:!0,roots:e,configured_enabled:t,configured_disabled:n,discovered:[],effective:[],warnings:[...i.warnings],policy:o};const s=new Set(t),a=new Set(n),m=r.ignoreGlobalExtensions===!0?kr():await ie("global",e.global,s,a,i.pmMaxVersionExceededMode.global),c=await ie("project",e.project,s,a,i.pmMaxVersionExceededMode.project),l=[...i.warnings],d=Rr(m.candidates,c.candidates),h=[];for(const u of d){const f={layer:u.layer,name:u.manifest.name,trusted:u.manifest.trusted===!0,provenanceVerified:u.manifest.provenance?.verified===!0,sandboxProfile:u.manifest.sandbox_profile,permissions:u.manifest.permissions&&typeof u.manifest.permissions=="object"?{fs_read:u.manifest.permissions.fs_read,fs_write:u.manifest.permissions.fs_write,network:u.manifest.permissions.network,env_read:u.manifest.permissions.env_read,env_write:u.manifest.permissions.env_write,process_spawn:u.manifest.permissions.process_spawn}:void 0},g=je(i,f);if(g.warning&&l.push(g.warning),!!g.allowed){for(const v of u.manifest.capabilities){const _=We(i,f,v);_.warning&&l.push(_.warning)}h.push(Cr(u))}}return{disabled_by_flag:!1,roots:e,configured_enabled:t,configured_disabled:n,discovered:[...m.diagnostics,...c.diagnostics],effective:h,warnings:[...new Set([...m.warnings,...c.warnings,...l])],policy:o}}function M(r){return r instanceof Error&&r.message.trim().length>0?r.message:String(r)}async function oe(){try{const r=Re(import.meta.url,["../../.."]),e=await w.readFile(x.join(r,"package.json"),"utf8"),t=JSON.parse(e);return typeof t.version=="string"&&t.version.trim().length>0?t.version.trim():null}catch{return null}}function j(){return W??=oe(),W}function ae(r,e,t){const n=t.current??"unknown";if(t.kind==="pm_min_version")switch(t.status){case"invalid":return`extension_pm_min_version_invalid:${r}:${e.name}:required=${t.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${r}:${e.name}:required=${t.required}:current=${n}`;case"unmet":return`extension_pm_min_version_unmet:${r}:${e.name}:required=${t.required}:current=${n}`;default:return}switch(t.status){case"invalid":return`extension_pm_max_version_invalid:${r}:${e.name}:allowed=${t.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${r}:${e.name}:allowed=${t.required}:current=${n}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${r}:${e.name}:allowed=${t.required}:current=${n}`;case"exceeded":return`extension_pm_max_version_exceeded:${r}:${e.name}:allowed=${t.required}:current=${n}`;default:return}}async function me(r,e){if(e.pm_min_version===void 0)return{allowed:!0};const t=gr(e.pm_min_version,await j()),n=ae(r,e,t);return n?{allowed:t.allowed,warning:n}:{allowed:t.allowed}}async function ce(r,e,t){if(e.pm_max_version===void 0)return{allowed:!0};const n=fr(e.pm_max_version,await j(),t),i=ae(r,e,n);return i?{allowed:n.allowed,warning:i}:{allowed:n.allowed}}async function N(r){try{const e=await w.stat(r);return`${Math.trunc(e.mtimeMs)}-${e.size}`}catch{return"missing"}}async function le(r,e){let t=r.entry_path;e.module_graph_snapshot_root&&(t=await rr(e.module_graph_snapshot_root,r));const n=new URL(xe(t).href);if(!(e.cache_bust===!0||typeof e.reload_token=="string"))return n.href;const[o,s]=await Promise.all([N(r.entry_path),N(r.manifest_path)]),a=e.reload_token??vr();return n.searchParams.set("pm_ext_reload",a),n.searchParams.set("pm_ext_entry",o),n.searchParams.set("pm_ext_manifest",s),n.href}async function pt(r){const e=await Sr(r),t=[],n=[],i=[...e.warnings];if(e.disabled_by_flag)return{...e,warnings:i,loaded:t,failed:n};const o=typeof r.extensionFilter=="function"?e.effective.filter(r.extensionFilter):e.effective;for(const s of o)try{const m=await import(await le(s,r));t.push({...s,module:m})}catch(a){i.push(`extension_load_failed:${s.layer}:${s.name}`),n.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:M(a)})}return{...e,warnings:i,loaded:t,failed:n}}const de=5e3,Ir=2147483647;function Mr(r){const t={activate:r.activate.bind(r)};if(typeof r.deactivate=="function"){const n=r.deactivate;t.deactivate=n.bind(r)}return t}function ue(r){const e=ke(r);return e?Mr(e):null}async function ft(r,e,t={}){const n=he(t?.deactivate_timeout_ms),i=new Set((e?.failed??[]).map(l=>`${l.layer}:${l.name}`)),o=[];for(const l of r.loaded){if(i.has(`${l.layer}:${l.name}`))continue;const d=ue(l.module);!d||typeof d.deactivate!="function"||o.push({extension:l,deactivate:d.deactivate})}const s=await Promise.all(o.map(async({extension:l,deactivate:d})=>{try{return await Ar(d,n),{ok:!0}}catch(h){return{ok:!1,layer:l.layer,name:l.name,error:M(h)}}})),a=[],m=[];let c=0;for(const l of s){if(l.ok){c+=1;continue}a.push(`extension_deactivate_failed:${l.layer}:${l.name}`),m.push({layer:l.layer,name:l.name,error:l.error})}return{deactivated:c,warnings:a,failed:m}}function he(r){return typeof r!="number"||r<0?de:r===0||r===1/0?0:Number.isFinite(r)?Math.min(Ir,Math.max(1,Math.floor(r))):de}async function Ar(r,e){if(e===0){await r();return}let t;try{const n=Promise.resolve().then(()=>r());n.catch(()=>{}),await Promise.race([n,new Promise((i,o)=>{t=setTimeout(()=>{o(new Error(`extension deactivate timed out after ${e}ms`))},e),t.unref?.()})])}finally{clearTimeout(t)}}function Tr(r){if(!Array.isArray(r.capabilities))return null;const e=new Set;for(const t of r.capabilities){const n=t.trim().toLowerCase();ze(n)&&e.add(n)}return e}function p(r,e,t){const n=Tr(r);if(n!==null&&!n.has(e))throw y(`${t} requires capability '${e}' in extension manifest capabilities`,{method:t,registration_index:-1,capability:e,missing_capability:e,expected_schema:`"capabilities": [..., "${e}"]`,received:r.capabilities,hint:`Add "${e}" to ${r.name} manifest capabilities, or remove the ${t} registration call.`})}function Dr(r){return Object.freeze({name:r.name,layer:r.layer,version:r.version,capabilities:Object.freeze((r.capabilities??[]).filter(e=>Ye.includes(e))),pm_min_version:r.pm_min_version,pm_max_version:r.pm_max_version,source_package:r.source_package})}function Fr(r){return{layer:r.layer,name:r.name,trusted:r.trusted===!0,provenanceVerified:r.provenance?.verified===!0,sandboxProfile:r.sandbox_profile,permissions:r.permissions&&typeof r.permissions=="object"?{fs_read:r.permissions.fs_read,fs_write:r.permissions.fs_write,network:r.permissions.network,env_read:r.permissions.env_read,env_write:r.permissions.env_write,process_spawn:r.permissions.process_spawn}:void 0}}class Or{extension;hooks;#e;#s;#t;#n;#o;#a;#m;#c;#r;#i;#l;#d;constructor(e,t,n,i,o,s,a,m,c,l,d){this.#e=e,this.extension=Dr(e),this.#s=Fr(e),this.#t=t,this.#n=n,this.#o=i,this.#a=o,this.#m=s,this.#c=a,this.#r=m,this.#i=c,this.#l=l,this.#d=d,this.registerCommand=this.registerCommand.bind(this),this.registerParser=this.registerParser.bind(this),this.registerPreflight=this.registerPreflight.bind(this),this.registerService=this.registerService.bind(this),this.registerFlags=this.registerFlags.bind(this),this.registerItemFields=this.registerItemFields.bind(this),this.registerItemTypes=this.registerItemTypes.bind(this),this.registerRelationshipKinds=this.registerRelationshipKinds.bind(this),this.registerMigration=this.registerMigration.bind(this),this.registerProfile=this.registerProfile.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerImporter=this.registerImporter.bind(this),this.registerExporter=this.registerExporter.bind(this),this.registerSearchProvider=this.registerSearchProvider.bind(this),this.registerVectorStoreAdapter=this.registerVectorStoreAdapter.bind(this),this.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:h=>this.registerBeforeCommand(h),beforeMutation:h=>this.registerBeforeMutation(h),afterCommand:h=>this.registerAfterCommand(h),onWrite:h=>this.registerOnWrite(h),onRead:h=>this.registerOnRead(h),onIndex:h=>this.registerOnIndex(h)}}allowRegistration(e,t,n,i){const o=Ne(this.#d,this.#s,e,t,n,i);return o.warning&&this.#i.push(o.warning),o.allowed}registerCommandTrace(e,t,n,i,o){return{method:"registerCommand",registration_index:e==="override"?this.#n.overrides.length:this.#n.handlers.length,command:t,expected_schema:n,received:Q(i),hint:o}}registerCommandOverride(e,t){const n=b(e);if(n.length===0)throw y("registerCommand requires a non-empty command name",this.registerCommandTrace("override",e,'registerCommand("<command>", (context) => unknown)',e,"Provide a non-empty command path as the first argument."));if(typeof t!="function"){const i=this.registerCommandTrace("override",n,'registerCommand("<command>", (context) => unknown)',t,"Provide a function as the second registerCommand argument.");throw y(`registerCommand requires an override function when command name is provided (command="${n}", registration_index=${i.registration_index})`,i)}this.allowRegistration("commands.override","registerCommand","commands",{command:n})&&this.#n.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:t})}resolveCommandDefinitionRunHandler(e,t){const n=typeof e.run=="function"?e.run:void 0,i=typeof e.handler=="function"?e.handler:void 0;return!n&&i&&this.#i.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${t}`),n??i}registerCommandDefinition(e){if(typeof e!="object"||e===null)throw y("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",e,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof e.name!="string")throw y("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",e,"Set command definition.name to a non-empty string command path."));const t=b(e.name);if(t.length===0)throw y("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",e.name,"{ name: string; run: (context) => unknown; }",e,"Ensure command definition.name contains a non-empty command path."));const n=this.resolveCommandDefinitionRunHandler(e,t);if(typeof n!="function"){const i=this.registerCommandTrace("definition",t,"{ name: string; run: (context) => unknown; }",n,"Define command definition.run as a function.");throw y(`registerCommand requires a command definition run handler (command="${t}", registration_index=${i.registration_index})`,i)}try{Se(e);const i=F(t,e.action),o=Ie(e.read_output,t,i);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:t,action:i}))return;const s=e.description?.trim(),a=e.intent?.trim(),m=C("registerCommand definition.examples",e.examples),c=C("registerCommand definition.failure_hints",e.failure_hints),l=T(e.arguments);e.flags!==void 0&&(p(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(O(e.flags),this.#r.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:t,flags:D("registerCommand definition.flags",e.flags)})));const d={source_version:this.#e.version,read_output:o,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:t,action:i,examples:m,failure_hints:c,arguments:l,tier:e.tier??"standard",family:e.family??"extensions"};s&&(d.description=s),a&&(d.intent=a),this.#r.commands.push(d)}catch(i){const o=M(i),s=this.registerCommandTrace("definition",t,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",e,o),a=y(`registerCommand definition metadata invalid (command="${t}", registration_index=${s.registration_index}): ${o}`,s);this.#i.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${t}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:t,run:n})}registerCommand(e,t){if(p(this.#e,"commands","registerCommand"),typeof e=="string"){this.registerCommandOverride(e,t);return}this.registerCommandDefinition(e)}registerParser(e,t){if(p(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;const n=b(P("registerParser command",e));S("registerParser override",t),this.#o.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:t})}registerPreflight(e){if(p(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;const t=nr(e);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...t})}registerService(e,t,n={}){p(this.#e,"services","registerService");const i=String(e).trim().toLowerCase();if(!lr(i))throw new TypeError(`registerService service must be one of: ${Qe.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:i})&&(S("registerService override",t),this.#m.overrides.push({layer:this.#e.layer,name:this.#e.name,service:i,run:t,...hr(n)?{passThrough:!0}:{}}))}registerRenderer(e,t,n={}){if(p(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof t!="function")throw new TypeError("registerRenderer requires a renderer function");const i=String(e).trim().toLowerCase();if(!dr(i))throw new Error(`registerRenderer format must be toon|json, received: ${String(e)}`);if(n.resultDiscriminator!==void 0&&typeof n.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");const o=[...new Set((n.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return b(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:i,run:t,commands:o,...n.resultDiscriminator?{resultDiscriminator:n.resultDiscriminator}:{}})}registerFlags(e,t){if(p(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;const n=b(P("registerFlags targetCommand",e));O(t);const i=D("registerFlags flags",t);if(i.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#r.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:i})}registerItemFields(e){if(p(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;G(e);const t=z("registerItemFields fields",e);if(t.length===0)throw new TypeError("registerItemFields requires at least one field definition");this.#r.item_fields.push({layer:this.#e.layer,name:this.#e.name,fields:t})}registerItemTypes(e){if(p(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;or(e);const t=z("registerItemTypes types",e);if(t.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#r.item_types.push({layer:this.#e.layer,name:this.#e.name,types:t})}registerRelationshipKinds(e){if(p(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(e))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(e.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");const t=Ee();for(const i of this.#r.relationship_kinds)for(const o of i.definitions)t.register(o);const n=e.map(i=>(t.register(i),t.require(i.kind)));this.#r.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:n})}registerMigration(e){if(p(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;ar(e);const t=k("registerMigration definition",e);this.#r.migrations.push(I({layer:this.#e.layer,name:this.#e.name,definition:R("registerMigration definition",e)},t))}registerProfile(e){if(p(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;const t=cr(e);mr(t),this.#r.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:ir(t)})}registerImportExportCommandFlags(e,t,n){n.flags!==void 0&&(p(this.#e,"schema",`${e} options.flags`),this.allowRegistration("schema.flags",`${e} options.flags`,"schema")&&(O(n.flags),this.#r.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:t,flags:D(`${e} options.flags`,n.flags)})))}applyImportExportCommandMetadata(e,t,n){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw new TypeError(`${e} options must be an object when provided`);const i=`${e==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,o=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...n,description:n?.description??i,arguments:n?.arguments??o},a=Ae(e,s,n?.description!==void 0);$(`${e} options.action`,s.action),$(`${e} options.description`,s.description),$(`${e} options.intent`,s.intent);const m=F(t,s.action),c=C(`${e} options.examples`,s.examples),l=C(`${e} options.failure_hints`,s.failure_hints),d=T(s.arguments);this.registerImportExportCommandFlags(e,t,s);const h={source_version:this.#e.version,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:t,action:m,examples:c,failure_hints:l,arguments:d},u=s.description?.trim();u&&(h.description=u);const f=s.intent?.trim();return f&&(h.intent=f),this.#r.commands.push(h),a}registerImporter(e,t,n){if(p(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;const i=Y(P("registerImporter name",e));S("registerImporter importer",t);const o=Z(i,"import");this.applyImportExportCommandMetadata("registerImporter",o,n),this.#r.importers.push({layer:this.#e.layer,name:this.#e.name,importer:i}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:o,run:async s=>t(U(s,i,"import"))})}registerExporter(e,t,n){if(p(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;const i=Y(P("registerExporter name",e));S("registerExporter exporter",t);const o=Z(i,"export"),s=this.applyImportExportCommandMetadata("registerExporter",o,n);this.#r.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:i,...s===void 0?{}:{output:s}}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:o,run:async a=>{const m=await t(U(a,i,"export"));return s?.receipt==="suppress"&&!be(m)?Ce(m):m}})}registerSearchProvider(e){if(p(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;const t=k("registerSearchProvider provider",e);this.#r.search_providers.push(I({layer:this.#e.layer,name:this.#e.name,definition:R("registerSearchProvider provider",e)},t))}registerVectorStoreAdapter(e){if(p(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;const t=k("registerVectorStoreAdapter adapter",e);this.#r.vector_store_adapters.push(I({layer:this.#e.layer,name:this.#e.name,definition:R("registerVectorStoreAdapter adapter",e)},t))}registerAssuranceMeasurementProvider(e){if(p(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(ur(e),e.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");const t=k("registerAssuranceMeasurementProvider provider",e);this.#r.assurance_providers.push(I({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:R("registerAssuranceMeasurementProvider provider",e)},t))}registerBeforeCommand(e){p(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(E("beforeCommand",e),this.#t.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerBeforeMutation(e){p(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(E("beforeMutation",e),this.#t.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerAfterCommand(e){p(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(E("afterCommand",e),this.#t.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerOnWrite(e){p(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(E("onWrite",e),this.#t.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerOnRead(e){p(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(E("onRead",e),this.#t.onRead.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerOnIndex(e){p(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(E("onIndex",e),this.#t.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:e}))}}function pe(r,e,t,n,i,o,s,a,m,c,l){return new Or(r,e,t,n,i,o,s,a,m,c,l)}function fe(r){const e=r.commands.length,t=r.flags.reduce((s,a)=>s+a.flags.length,0),n=r.item_fields.reduce((s,a)=>s+a.fields.length,0),i=r.item_types.reduce((s,a)=>s+a.types.length,0),o=(r.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:e,flags:t,item_fields:n,item_types:i,...o>0?{relationship_kinds:o}:{},migrations:r.migrations.length,profiles:r.profiles.length,importers:r.importers.length,exporters:r.exporters.length,search_providers:r.search_providers.length,vector_store_adapters:r.vector_store_adapters.length,...(r.assurance_providers?.length??0)>0?{assurance_providers:r.assurance_providers.length}:{}}}function ge(r){const e=[],t=(o,s)=>{const a=new Map;for(const m of o){const c=a.get(m.command)??[];c.push(m),a.set(m.command,c)}for(const m of[...a.keys()].sort((c,l)=>c.localeCompare(l))){const c=a.get(m);if(c.length<=1)continue;const l=c[c.length-1];for(const d of c.slice(0,-1))e.push(`${s}:${m}:${l.layer}:${l.name}:${d.layer}:${d.name}`)}};t(r.handlers,"extension_command_handler_collision"),t(r.overrides,"extension_command_override_collision");const n=new Set(r.handlers.map(o=>o.command)),i=[...new Set(r.overrides.map(o=>o.command))].filter(o=>n.has(o));i.sort((o,s)=>o.localeCompare(s));for(const o of i){const s=r.handlers.filter(m=>m.command===o),a=r.overrides.filter(m=>m.command===o);for(const m of a)for(const c of s)e.push(`extension_command_override_handler_overlap:${o}:${m.layer}:${m.name}:${c.layer}:${c.name}`)}return e}function ye(r){const e=new Map;for(const n of r.overrides){const i=e.get(n.format)??[];i.push(n),e.set(n.format,i)}const t=[];for(const n of[...e.keys()].sort((i,o)=>i.localeCompare(o))){const i=e.get(n);if(i.length<=1)continue;const o=i[i.length-1];for(const s of i.slice(0,-1))o.commands?.length&&s.commands?.length&&!s.commands.some(a=>o.commands?.includes(a))||t.push(`extension_renderer_collision:${n}:${o.layer}:${o.name}:${s.layer}:${s.name}`)}return t}function _e(r){const e=[],t=new Map;for(const n of r.overrides){const i=t.get(n.command)??[];i.push(n),t.set(n.command,i)}for(const n of[...t.keys()].sort((i,o)=>i.localeCompare(o))){const i=t.get(n);if(i.length<=1)continue;const o=i[i.length-1];for(const s of i.slice(0,-1))e.push(`extension_parser_override_collision:${n}:${o.layer}:${o.name}:${s.layer}:${s.name}`)}return e}const zr=new Set(["output_format"]);function ve(r){const e=[],t=new Map;for(const n of r.overrides){const i=t.get(n.service)??[];i.push(n),t.set(n.service,i)}for(const n of[...t.keys()].sort((i,o)=>i.localeCompare(o))){const i=t.get(n);if(i.length<=1||zr.has(n))continue;const o=i[i.length-1];for(const s of i.slice(0,-1))e.push(`extension_service_override_collision:${n}:${o.layer}:${o.name}:${s.layer}:${s.name}`)}return e}async function gt(r){const e=Ve(r.policy??_r),t=Be(),n=Le(),i=Ue(),o=Ke(),s=Je(),a=Ge(),m=Xe(),c=[],l=[];for(const u of r.loaded){const f=ue(u.module);if(!f)continue;const g=c.length,v=Pe({hooks:t,commands:n,parsers:i,preflight:o,services:s,renderers:a,registrations:m});try{await f.activate(pe(u,t,n,i,o,s,a,m,l,c,e)),c.length>g&&(v(),l.push(`extension_activation_rolled_back:${u.layer}:${u.name}`))}catch(_){v(),l.push(`extension_activate_failed:${u.layer}:${u.name}`);const A=J(_);c.push({layer:u.layer,name:u.name,entry_path:u.entry_path,error:M(_),trace:A})}}const d=[...ge(n),..._e(i),...tr(o),...ve(s),...ye(a)],h=[...new Set([...l,...d])];return{hooks:t,commands:n,parsers:i,preflight:o,services:s,renderers:a,registrations:m,failed:c,warnings:h,hook_counts:{before_command:t.beforeCommand.length,before_mutation:t.beforeMutation.length,after_command:t.afterCommand.length,on_write:t.onWrite.length,on_read:t.onRead.length,on_index:t.onIndex.length},command_override_count:n.overrides.length,command_handler_count:n.handlers.length,parser_override_count:i.overrides.length,preflight_override_count:o.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:fe(m)}}const yt={assertFlagValueTypeAndDefault:sr,assertOptionalStringField:$,compareComparableVersions:pr,collectCommandCollisionWarnings:ge,collectParserCollisionWarnings:_e,collectRendererCollisionWarnings:ye,collectServiceCollisionWarnings:ve,createExtensionApi:pe,createRegistrationValidationError:y,evaluatePmMaxVersionCompatibility:ce,evaluatePmMinVersionCompatibility:me,extractRegistrationValidationTrace:J,fingerprintPath:N,getRegistrationCounts:fe,normalizeCommandDefinitionArguments:T,normalizeExtensionDeactivateTimeout:he,normalizeOptionalStringArrayField:C,normalizeRegistrationRecord:R,normalizeRegistrationRecordList:z,normalizeRuntimeRegistrationRecord:k,parseComparableVersion:yr,parseManifest:X,readCurrentPmCliVersion:oe,readManagedExtensionSourcePackages:async r=>new Map([...await te(r)].filter(e=>typeof e[1].package_name=="string").map(([e,t])=>[e,t.package_name])),resolveExtensionImportHref:le,resolveCurrentPmCliVersion:j,resolveCommandDefinitionAction:F,sanitizeRegistrationValue:Q,validateItemFieldDefinitions:G,resetCurrentPmCliVersionCacheForTest:()=>{W=null}};export{Ut as DEFAULT_EXTENSION_PRIORITY,yt as _testOnlyLoader,gt as activateExtensions,bt as createEmptyExtensionCommandRegistry,Ct as createEmptyExtensionHookRegistry,Rt as createEmptyExtensionParserRegistry,kt as createEmptyExtensionPreflightRegistry,$t as createEmptyExtensionRegistrationRegistry,Pt as createEmptyExtensionRendererRegistry,St as createEmptyExtensionServiceRegistry,ft as deactivateExtensions,Sr as discoverExtensions,xr as isCanonicalPathWithinDirectory,pt as loadExtensions,vr as nextExtensionReloadToken,Kt as parseExtensionManifestDocument,wt as parseLegacyExtensionCapabilityAliasWarning,xt as parseUnknownExtensionCapabilityWarning,Er as resolveExtensionRoots,Mt as runAfterCommandHooks,At as runBeforeCommandHooks,Tt as runBeforeMutationHooks,Dt as runCommandHandler,Ft as runCommandOverride,Ot as runOnIndexHooks,zt as runOnReadHooks,Wt as runOnWriteHooks,jt as runParserOverride,Nt as runPreflightOverride,Vt as runRendererOverride,qt as runServiceOverride,Ht as runServiceOverrideSync};
|
|
1
|
+
import w from"node:fs/promises";import x from"node:path";import{pathToFileURL as xe}from"node:url";import{createRelationshipKindRegistry as Ee}from"../../sdk/relationships.js";import{pathExists as H}from"../fs/fs-utils.js";import{isPathWithinDirectory as L}from"../fs/path-utils.js";import{isHostOutputSuppressed as be,suppressHostOutput as Ce}from"../output/output-control.js";import{resolvePmPackageRootFromModule as Re}from"../packages/root.js";import{asRecordLoose as B,resolveActivatablePropertyRecord as ke}from"../shared/primitives.js";import{resolveGlobalPmRoot as $e}from"../store/paths.js";import{captureExtensionActivationRollback as Pe}from"./activation-transaction.js";import{assertCommandDefinitionMetadataStrings as Se}from"./command-visibility-tier.js";import{normalizeExtensionReadOutput as Ie}from"./read-output-contract.js";import{normalizeExtensionContributionInventory as Me}from"./contribution-inventory.js";import{buildImportExportContext as U,resolveImportExportArtifactOutput as Ae}from"./exporter-output-contract.js";import{buildReadyExtensionCandidate as Te}from"./extension-candidate.js";import{collectUnknownExtensionCapabilities as De,formatLegacyExtensionCapabilityAliasWarning as Fe,formatUnknownExtensionCapabilityWarning as Oe,isKnownExtensionCapability as ze,normalizeNames as K}from"./extension-capability-aliases.js";import{evaluateExtensionPolicyForCapability as We,evaluateExtensionPolicyForExtension as Ne,evaluateExtensionPolicyForRegistration as je,hydrateExtensionPolicy as Ve,normalizeExtensionPolicy as qe,serializeExtensionPolicy as He}from"./extension-policy.js";import{createEmptyExtensionCommandRegistry as Le,createEmptyExtensionHookRegistry as Be,createEmptyExtensionParserRegistry as Ue,createEmptyExtensionPreflightRegistry as Ke,createEmptyExtensionRegistrationRegistry as Xe,createEmptyExtensionRendererRegistry as Ge,createEmptyExtensionServiceRegistry as Je}from"./extension-registries.js";import{normalizeCommandName as b}from"./extension-runtime-helpers.js";import{KNOWN_EXTENSION_CAPABILITIES as Ye,KNOWN_EXTENSION_SERVICE_NAMES as Qe,createDefaultExtensionGovernancePolicy as Ze}from"./extension-types.js";import{findConflictingItemFieldDeclaration as er,formatItemFieldTypeConflictWarning as rr,formatReservedItemFieldWarning as tr,RESERVED_ITEM_FIELD_NAMES as nr}from"./item-fields.js";import{parseExtensionManifestDocument as X}from"./manifest-parser.js";import{formatExtensionManifestSchemaWarnings as ir}from"./manifest-schema.js";import{snapshotExtensionModuleGraph as sr}from"./module-graph-snapshot.js";import{collectPreflightCollisionWarnings as or,normalizePreflightOverride as ar}from"./preflight-ownership.js";import{applyProjectProfileDefaults as mr,assertFlagValueTypeAndDefault as cr,normalizeCommandDefinitionArguments as T,normalizeFlagDefinitions as D,resolveCommandDefinitionAction as F,validateFlagDefinitions as O,validateItemFieldDefinitions as G,validateItemTypeDefinitions as lr,validateMigrationDefinition as dr,validateProjectProfileDefinition as ur}from"./registration-contracts.js";import{assertOptionalStringField as $,normalizeOptionalStringArrayField as C}from"./registration-validation.js";import{assertHookHandler as E,assertNonEmptyRegistrationString as P,assertRegistrationFunction as S,attachRuntimeDefinition as I,cloneRuntimeRegistrationValue as hr,createRegistrationValidationError as y,extractRegistrationValidationTrace as J,isExtensionServiceName as pr,isOutputRendererFormat as fr,normalizeRegistrationName as Y,normalizeRegistrationRecord as R,normalizeRegistrationRecordList as z,normalizeRuntimeRegistrationRecord as k,sanitizeRegistrationValue as Q,toRegistrationCommandPath as Z,validateAssuranceMeasurementProviderDefinition as gr}from"./registration-values.js";import{normalizeServiceOverrideOwnership as yr}from"./service-ownership.js";import{compareComparableVersions as _r,evaluatePmMaxVersionBound as vr,evaluatePmMinVersionBound as wr,parseComparableVersion as xr}from"./version-compat.js";import{parseLegacyExtensionCapabilityAliasWarning as Rt,parseUnknownExtensionCapabilityWarning as kt}from"./extension-capability-aliases.js";import{createEmptyExtensionCommandRegistry as Pt,createEmptyExtensionHookRegistry as St,createEmptyExtensionParserRegistry as It,createEmptyExtensionPreflightRegistry as Mt,createEmptyExtensionRegistrationRegistry as At,createEmptyExtensionRendererRegistry as Tt,createEmptyExtensionServiceRegistry as Dt}from"./extension-registries.js";import{runAfterCommandHooks as Ot,runBeforeCommandHooks as zt,runBeforeMutationHooks as Wt,runCommandHandler as Nt,runCommandOverride as jt,runOnIndexHooks as Vt,runOnReadHooks as qt,runOnWriteHooks as Ht,runParserOverride as Lt,runPreflightOverride as Bt,runRendererOverride as Ut,runServiceOverride as Kt,runServiceOverrideSync as Xt}from"./extension-hook-runtime.js";export*from"./extension-types.js";import{DEFAULT_EXTENSION_PRIORITY as Yt,parseExtensionManifestDocument as Qt}from"./manifest-parser.js";let W=null;const Er=Object.freeze(Ze());let ee=0;function br(r=Date.now()){return ee+=1,`${ee}-${r}`}function Cr(r,e,t){return t.has(r)?!1:e.size===0?!0:e.has(r)}async function Rr(r,e){const[t,n]=await Promise.all([w.realpath(r),w.realpath(e)]);return L(t,n)}function kr(r,e=process.cwd()){return{global:x.join($e(e),"extensions"),project:x.join(r,"extensions")}}async function $r(r){try{return(await w.readdir(r,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n))}catch{return[]}}function Pr(r){const e={layer:r.layer,directory:r.directory,manifest_path:r.manifest_path,name:r.manifest.name,version:r.manifest.version,entry:r.manifest.entry,priority:r.manifest.priority,entry_path:r.entry_path,manifest_version:r.manifest.manifest_version,pm_min_version:r.manifest.pm_min_version,pm_max_version:r.manifest.pm_max_version,engines:r.manifest.engines,trusted:r.manifest.trusted,provenance:r.manifest.provenance,sandbox_profile:r.manifest.sandbox_profile,permissions:r.manifest.permissions,capabilities:[...r.manifest.capabilities],activation:r.manifest.activation?{commands:[...r.manifest.activation.commands]}:void 0,contributions:r.manifest.contributions??r.contributions};return r.source_package&&(e.source_package=r.source_package),r.source_aliases&&(e.source_aliases=[...r.source_aliases]),e}function re(r){return typeof r=="string"&&r.trim().length>0?r.trim():void 0}async function te(r){const e=new Map;try{const t=JSON.parse(await w.readFile(x.join(r,".managed-extensions.json"),"utf8")),i=B(t)?.entries;if(!Array.isArray(i))return e;for(const o of i){if(typeof o!="object"||o===null)continue;const s=o,a=re(s.source?.package),m=[s.source?.input,s.source?.name,a].map(d=>re(d)).filter(d=>d!==void 0),c=Me(s.contributions),l={aliases:[...new Set(m)],...a?{package_name:a}:{},...c?{contributions:c}:{}};typeof s.directory=="string"&&s.directory.trim().length>0&&e.set(`directory:${s.directory.trim()}`,l),typeof s.name=="string"&&s.name.trim().length>0&&e.set(`name:${s.name.trim()}`,l)}}catch{return e}return e}function ne(r){return[...r].sort((e,t)=>{if(e.manifest.priority!==t.manifest.priority)return e.manifest.priority-t.manifest.priority;const n=e.manifest.name.localeCompare(t.manifest.name);return n!==0?n:e.directory.localeCompare(t.directory)})}function Sr(r,e){const t=[...ne(r),...ne(e)],n=[];for(const i of t){const o=n.findIndex(s=>s.manifest.name===i.manifest.name);o>=0&&n.splice(o,1),n.push(i)}return n}async function ie(r,e,t,n,i){const o=[],s=[],a=[],m=await $r(e),c=await te(e);for(const l of m){const d=await Ar(r,e,l,t,n,c,i);o.push(d.diagnostic),s.push(...d.warnings),d.candidate&&a.push(d.candidate)}return{diagnostics:o,warnings:s,candidates:a}}function Ir(){return{diagnostics:[],warnings:[],candidates:[]}}function se(r,e,t,n){return{diagnostic:{layer:r,directory:e,manifest_path:t,name:null,version:null,entry:null,priority:null,entry_path:null,enabled:null,status:"warn"},warnings:[n],candidate:null}}function Mr(r,e,t,n,i,o,s,a){const m=ir(r,e,t);Array.isArray(e.legacy_capability_aliases)&&e.legacy_capability_aliases.length>0&&m.push(Fe(r,e.name,e.legacy_capability_aliases));for(const c of De(e.capabilities))m.push(Oe(r,e.name,c));return n?i||m.push(`extension_entry_missing:${r}:${e.name}`):m.push(`extension_entry_outside_extension:${r}:${e.name}`),o.warning&&m.push(a?o.warning:o.warning.replace("extension_pm_","extension_disabled_pm_")),s.warning&&m.push(a?s.warning:s.warning.replace("extension_pm_","extension_disabled_pm_")),m}async function Ar(r,e,t,n,i,o,s){const a=x.join(e,t),m=x.join(a,"manifest.json");if(!await H(m))return se(r,t,m,`extension_manifest_missing:${r}:${t}`);let c,l;try{const q=JSON.parse(await w.readFile(m,"utf8"));l=B(q),c=X(q)}catch{l=null,c=null}if(!c||!l)return se(r,t,m,`extension_manifest_invalid:${r}:${t}`);const d=x.resolve(a,c.entry),h=L(a,d),u=h?await H(d):!1,f=h&&u?await Rr(a,d):h,g=Cr(c.name,n,i),v=await me(r,c),_=await ce(r,c,s),A=Mr(r,c,l,f,u,v,_,g),V=f&&u&&v.allowed&&_.allowed,we=o.get(`directory:${t}`)??o.get(`name:${c.name}`);return{diagnostic:{layer:r,directory:t,manifest_path:m,name:c.name,version:c.version,entry:c.entry,priority:c.priority,entry_path:d,enabled:g,status:V?"ok":"warn"},warnings:A,candidate:Te({layer:r,directory:t,manifestPath:m,entryPath:d,manifest:c,sourceIdentity:we,extensionReady:V,enabledForLoad:g})}}async function Tr(r){const e=kr(r.pmRoot,r.cwd??process.cwd()),t=K(r.settings.extensions.enabled),n=K(r.settings.extensions.disabled),i=qe(r.settings),o=He(i);if(r.noExtensions)return{disabled_by_flag:!0,roots:e,configured_enabled:t,configured_disabled:n,discovered:[],effective:[],warnings:[...i.warnings],policy:o};const s=new Set(t),a=new Set(n),m=r.ignoreGlobalExtensions===!0?Ir():await ie("global",e.global,s,a,i.pmMaxVersionExceededMode.global),c=await ie("project",e.project,s,a,i.pmMaxVersionExceededMode.project),l=[...i.warnings],d=Sr(m.candidates,c.candidates),h=[];for(const u of d){const f={layer:u.layer,name:u.manifest.name,trusted:u.manifest.trusted===!0,provenanceVerified:u.manifest.provenance?.verified===!0,sandboxProfile:u.manifest.sandbox_profile,permissions:u.manifest.permissions&&typeof u.manifest.permissions=="object"?{fs_read:u.manifest.permissions.fs_read,fs_write:u.manifest.permissions.fs_write,network:u.manifest.permissions.network,env_read:u.manifest.permissions.env_read,env_write:u.manifest.permissions.env_write,process_spawn:u.manifest.permissions.process_spawn}:void 0},g=Ne(i,f);if(g.warning&&l.push(g.warning),!!g.allowed){for(const v of u.manifest.capabilities){const _=We(i,f,v);_.warning&&l.push(_.warning)}h.push(Pr(u))}}return{disabled_by_flag:!1,roots:e,configured_enabled:t,configured_disabled:n,discovered:[...m.diagnostics,...c.diagnostics],effective:h,warnings:[...new Set([...m.warnings,...c.warnings,...l])],policy:o}}function M(r){return r instanceof Error&&r.message.trim().length>0?r.message:String(r)}async function oe(){try{const r=Re(import.meta.url,["../../.."]),e=await w.readFile(x.join(r,"package.json"),"utf8"),t=JSON.parse(e);return typeof t.version=="string"&&t.version.trim().length>0?t.version.trim():null}catch{return null}}function N(){return W??=oe(),W}function ae(r,e,t){const n=t.current??"unknown";if(t.kind==="pm_min_version")switch(t.status){case"invalid":return`extension_pm_min_version_invalid:${r}:${e.name}:required=${t.required}`;case"unchecked":return`extension_pm_min_version_unchecked:${r}:${e.name}:required=${t.required}:current=${n}`;case"unmet":return`extension_pm_min_version_unmet:${r}:${e.name}:required=${t.required}:current=${n}`;default:return}switch(t.status){case"invalid":return`extension_pm_max_version_invalid:${r}:${e.name}:allowed=${t.required}`;case"unchecked":return`extension_pm_max_version_unchecked:${r}:${e.name}:allowed=${t.required}:current=${n}`;case"exceeded_warn":return`extension_pm_max_version_exceeded_warn:${r}:${e.name}:allowed=${t.required}:current=${n}`;case"exceeded":return`extension_pm_max_version_exceeded:${r}:${e.name}:allowed=${t.required}:current=${n}`;default:return}}async function me(r,e){if(e.pm_min_version===void 0)return{allowed:!0};const t=wr(e.pm_min_version,await N()),n=ae(r,e,t);return n?{allowed:t.allowed,warning:n}:{allowed:t.allowed}}async function ce(r,e,t){if(e.pm_max_version===void 0)return{allowed:!0};const n=vr(e.pm_max_version,await N(),t),i=ae(r,e,n);return i?{allowed:n.allowed,warning:i}:{allowed:n.allowed}}async function j(r){try{const e=await w.stat(r);return`${Math.trunc(e.mtimeMs)}-${e.size}`}catch{return"missing"}}async function le(r,e){let t=r.entry_path;e.module_graph_snapshot_root&&(t=await sr(e.module_graph_snapshot_root,r));const n=new URL(xe(t).href);if(!(e.cache_bust===!0||typeof e.reload_token=="string"))return n.href;const[o,s]=await Promise.all([j(r.entry_path),j(r.manifest_path)]),a=e.reload_token??br();return n.searchParams.set("pm_ext_reload",a),n.searchParams.set("pm_ext_entry",o),n.searchParams.set("pm_ext_manifest",s),n.href}async function vt(r){const e=await Tr(r),t=[],n=[],i=[...e.warnings];if(e.disabled_by_flag)return{...e,warnings:i,loaded:t,failed:n};const o=typeof r.extensionFilter=="function"?e.effective.filter(r.extensionFilter):e.effective;for(const s of o)try{const m=await import(await le(s,r));t.push({...s,module:m})}catch(a){i.push(`extension_load_failed:${s.layer}:${s.name}`),n.push({layer:s.layer,name:s.name,entry_path:s.entry_path,error:M(a)})}return{...e,warnings:i,loaded:t,failed:n}}const de=5e3,Dr=2147483647;function Fr(r){const t={activate:r.activate.bind(r)};if(typeof r.deactivate=="function"){const n=r.deactivate;t.deactivate=n.bind(r)}return t}function ue(r){const e=ke(r);return e?Fr(e):null}async function wt(r,e,t={}){const n=he(t?.deactivate_timeout_ms),i=new Set((e?.failed??[]).map(l=>`${l.layer}:${l.name}`)),o=[];for(const l of r.loaded){if(i.has(`${l.layer}:${l.name}`))continue;const d=ue(l.module);!d||typeof d.deactivate!="function"||o.push({extension:l,deactivate:d.deactivate})}const s=await Promise.all(o.map(async({extension:l,deactivate:d})=>{try{return await Or(d,n),{ok:!0}}catch(h){return{ok:!1,layer:l.layer,name:l.name,error:M(h)}}})),a=[],m=[];let c=0;for(const l of s){if(l.ok){c+=1;continue}a.push(`extension_deactivate_failed:${l.layer}:${l.name}`),m.push({layer:l.layer,name:l.name,error:l.error})}return{deactivated:c,warnings:a,failed:m}}function he(r){return typeof r!="number"||r<0?de:r===0||r===1/0?0:Number.isFinite(r)?Math.min(Dr,Math.max(1,Math.floor(r))):de}async function Or(r,e){if(e===0){await r();return}let t;try{const n=Promise.resolve().then(()=>r());n.catch(()=>{}),await Promise.race([n,new Promise((i,o)=>{t=setTimeout(()=>{o(new Error(`extension deactivate timed out after ${e}ms`))},e),t.unref?.()})])}finally{clearTimeout(t)}}function zr(r){if(!Array.isArray(r.capabilities))return null;const e=new Set;for(const t of r.capabilities){const n=t.trim().toLowerCase();ze(n)&&e.add(n)}return e}function p(r,e,t){const n=zr(r);if(n!==null&&!n.has(e))throw y(`${t} requires capability '${e}' in extension manifest capabilities`,{method:t,registration_index:-1,capability:e,missing_capability:e,expected_schema:`"capabilities": [..., "${e}"]`,received:r.capabilities,hint:`Add "${e}" to ${r.name} manifest capabilities, or remove the ${t} registration call.`})}function Wr(r){return Object.freeze({name:r.name,layer:r.layer,version:r.version,capabilities:Object.freeze((r.capabilities??[]).filter(e=>Ye.includes(e))),pm_min_version:r.pm_min_version,pm_max_version:r.pm_max_version,source_package:r.source_package})}function Nr(r){return{layer:r.layer,name:r.name,trusted:r.trusted===!0,provenanceVerified:r.provenance?.verified===!0,sandboxProfile:r.sandbox_profile,permissions:r.permissions&&typeof r.permissions=="object"?{fs_read:r.permissions.fs_read,fs_write:r.permissions.fs_write,network:r.permissions.network,env_read:r.permissions.env_read,env_write:r.permissions.env_write,process_spawn:r.permissions.process_spawn}:void 0}}class jr{extension;hooks;#e;#s;#t;#n;#o;#a;#m;#c;#r;#i;#l;#d;constructor(e,t,n,i,o,s,a,m,c,l,d){this.#e=e,this.extension=Wr(e),this.#s=Nr(e),this.#t=t,this.#n=n,this.#o=i,this.#a=o,this.#m=s,this.#c=a,this.#r=m,this.#i=c,this.#l=l,this.#d=d,this.registerCommand=this.registerCommand.bind(this),this.registerParser=this.registerParser.bind(this),this.registerPreflight=this.registerPreflight.bind(this),this.registerService=this.registerService.bind(this),this.registerFlags=this.registerFlags.bind(this),this.registerItemFields=this.registerItemFields.bind(this),this.registerItemTypes=this.registerItemTypes.bind(this),this.registerRelationshipKinds=this.registerRelationshipKinds.bind(this),this.registerMigration=this.registerMigration.bind(this),this.registerProfile=this.registerProfile.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerImporter=this.registerImporter.bind(this),this.registerExporter=this.registerExporter.bind(this),this.registerSearchProvider=this.registerSearchProvider.bind(this),this.registerVectorStoreAdapter=this.registerVectorStoreAdapter.bind(this),this.registerAssuranceMeasurementProvider=this.registerAssuranceMeasurementProvider.bind(this),this.hooks={beforeCommand:h=>this.registerBeforeCommand(h),beforeMutation:h=>this.registerBeforeMutation(h),afterCommand:h=>this.registerAfterCommand(h),onWrite:h=>this.registerOnWrite(h),onRead:h=>this.registerOnRead(h),onIndex:h=>this.registerOnIndex(h)}}allowRegistration(e,t,n,i){const o=je(this.#d,this.#s,e,t,n,i);return o.warning&&this.#i.push(o.warning),o.allowed}registerCommandTrace(e,t,n,i,o){return{method:"registerCommand",registration_index:e==="override"?this.#n.overrides.length:this.#n.handlers.length,command:t,expected_schema:n,received:Q(i),hint:o}}registerCommandOverride(e,t){const n=b(e);if(n.length===0)throw y("registerCommand requires a non-empty command name",this.registerCommandTrace("override",e,'registerCommand("<command>", (context) => unknown)',e,"Provide a non-empty command path as the first argument."));if(typeof t!="function"){const i=this.registerCommandTrace("override",n,'registerCommand("<command>", (context) => unknown)',t,"Provide a function as the second registerCommand argument.");throw y(`registerCommand requires an override function when command name is provided (command="${n}", registration_index=${i.registration_index})`,i)}this.allowRegistration("commands.override","registerCommand","commands",{command:n})&&this.#n.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:t})}resolveCommandDefinitionRunHandler(e,t){const n=typeof e.run=="function"?e.run:void 0,i=typeof e.handler=="function"?e.handler:void 0;return!n&&i&&this.#i.push(`extension_command_definition_legacy_handler_alias:${this.#e.layer}:${this.#e.name}:${t}`),n??i}registerCommandDefinition(e){if(typeof e!="object"||e===null)throw y("registerCommand requires a command definition object",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",e,'Use registerCommand({ name: "command path", run: (context) => ... }).'));if(typeof e.name!="string")throw y("registerCommand requires a command definition name",this.registerCommandTrace("definition",void 0,"{ name: string; run: (context) => unknown; }",e,"Set command definition.name to a non-empty string command path."));const t=b(e.name);if(t.length===0)throw y("registerCommand requires a non-empty command definition name",this.registerCommandTrace("definition",e.name,"{ name: string; run: (context) => unknown; }",e,"Ensure command definition.name contains a non-empty command path."));const n=this.resolveCommandDefinitionRunHandler(e,t);if(typeof n!="function"){const i=this.registerCommandTrace("definition",t,"{ name: string; run: (context) => unknown; }",n,"Define command definition.run as a function.");throw y(`registerCommand requires a command definition run handler (command="${t}", registration_index=${i.registration_index})`,i)}try{Se(e);const i=F(t,e.action),o=Ie(e.read_output,t,i);if(!this.allowRegistration("commands.handler","registerCommand","commands",{command:t,action:i}))return;const s=e.description?.trim(),a=e.intent?.trim(),m=C("registerCommand definition.examples",e.examples),c=C("registerCommand definition.failure_hints",e.failure_hints),l=T(e.arguments);e.flags!==void 0&&(p(this.#e,"schema","registerCommand flags"),this.allowRegistration("schema.flags","registerCommand flags","schema")&&(O(e.flags),this.#r.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:t,flags:D("registerCommand definition.flags",e.flags)})));const d={source_version:this.#e.version,read_output:o,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:t,action:i,examples:m,failure_hints:c,arguments:l,tier:e.tier??"standard",family:e.family??"extensions"};s&&(d.description=s),a&&(d.intent=a),this.#r.commands.push(d)}catch(i){const o=M(i),s=this.registerCommandTrace("definition",t,"{ name: string; run: (context) => unknown; action?: string; arguments?: object[]; flags?: object[]; }",e,o),a=y(`registerCommand definition metadata invalid (command="${t}", registration_index=${s.registration_index}): ${o}`,s);this.#i.push(`extension_command_quarantined:${this.#e.layer}:${this.#e.name}:${t}`),this.#l.push({layer:this.#e.layer,name:this.#e.name,entry_path:this.#e.entry_path,error:a.message,trace:s});return}this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:t,run:n})}registerCommand(e,t){if(p(this.#e,"commands","registerCommand"),typeof e=="string"){this.registerCommandOverride(e,t);return}this.registerCommandDefinition(e)}registerParser(e,t){if(p(this.#e,"parser","registerParser"),!this.allowRegistration("parser.override","registerParser","parser"))return;const n=b(P("registerParser command",e));S("registerParser override",t),this.#o.overrides.push({layer:this.#e.layer,name:this.#e.name,command:n,run:t})}registerPreflight(e){if(p(this.#e,"preflight","registerPreflight"),!this.allowRegistration("preflight.override","registerPreflight","preflight"))return;const t=ar(e);this.#a.overrides.push({layer:this.#e.layer,name:this.#e.name,...t})}registerService(e,t,n={}){p(this.#e,"services","registerService");const i=String(e).trim().toLowerCase();if(!pr(i))throw new TypeError(`registerService service must be one of: ${Qe.join(", ")}`);this.allowRegistration("services.override","registerService","services",{service:i})&&(S("registerService override",t),this.#m.overrides.push({layer:this.#e.layer,name:this.#e.name,service:i,run:t,...yr(n)?{passThrough:!0}:{}}))}registerRenderer(e,t,n={}){if(p(this.#e,"renderers","registerRenderer"),!this.allowRegistration("renderers.override","registerRenderer","renderers"))return;if(typeof t!="function")throw new TypeError("registerRenderer requires a renderer function");const i=String(e).trim().toLowerCase();if(!fr(i))throw new Error(`registerRenderer format must be toon|json, received: ${String(e)}`);if(n.resultDiscriminator!==void 0&&typeof n.resultDiscriminator!="function")throw new TypeError("registerRenderer ownership.resultDiscriminator must be a function when provided");const o=[...new Set((n.commands??[]).map(s=>{if(typeof s!="string"||s.trim().length===0)throw new TypeError("registerRenderer ownership.commands must contain non-empty command paths");return b(s)}))];this.#c.overrides.push({layer:this.#e.layer,name:this.#e.name,format:i,run:t,commands:o,...n.resultDiscriminator?{resultDiscriminator:n.resultDiscriminator}:{}})}registerFlags(e,t){if(p(this.#e,"schema","registerFlags"),!this.allowRegistration("schema.flags","registerFlags","schema"))return;const n=b(P("registerFlags targetCommand",e));O(t);const i=D("registerFlags flags",t);if(i.length===0)throw new TypeError("registerFlags requires at least one flag definition");this.#r.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:n,flags:i})}registerItemFields(e){if(p(this.#e,"schema","registerItemFields"),!this.allowRegistration("schema.itemfields","registerItemFields","schema"))return;G(e);const t=z("registerItemFields fields",e);if(t.length===0)throw new TypeError("registerItemFields requires at least one field definition");const{layer:n,name:i}=this.#e,o={layer:n,name:i,fields:[]};for(const s of t){const a=typeof s.name=="string"?s.name.trim():"";if(nr.has(a)){this.#i.push(tr(n,i,a));continue}const m=er([...this.#r.item_fields,o],s);if(m){this.#i.push(rr(n,i,s,m));continue}o.fields.push(s)}this.#r.item_fields.push(o)}registerItemTypes(e){if(p(this.#e,"schema","registerItemTypes"),!this.allowRegistration("schema.itemtypes","registerItemTypes","schema"))return;lr(e);const t=z("registerItemTypes types",e);if(t.length===0)throw new TypeError("registerItemTypes requires at least one type definition");this.#r.item_types.push({layer:this.#e.layer,name:this.#e.name,types:t})}registerRelationshipKinds(e){if(p(this.#e,"schema","registerRelationshipKinds"),!this.allowRegistration("schema.relationshipkinds","registerRelationshipKinds","schema"))return;if(!Array.isArray(e))throw new TypeError("registerRelationshipKinds definitions requires an array of object definitions");if(e.length===0)throw new TypeError("registerRelationshipKinds requires at least one definition");const t=Ee();for(const i of this.#r.relationship_kinds)for(const o of i.definitions)t.register(o);const n=e.map(i=>(t.register(i),t.require(i.kind)));this.#r.relationship_kinds.push({layer:this.#e.layer,name:this.#e.name,definitions:n})}registerMigration(e){if(p(this.#e,"schema","registerMigration"),!this.allowRegistration("schema.migrations","registerMigration","schema"))return;dr(e);const t=k("registerMigration definition",e);this.#r.migrations.push(I({layer:this.#e.layer,name:this.#e.name,definition:R("registerMigration definition",e)},t))}registerProfile(e){if(p(this.#e,"schema","registerProfile"),!this.allowRegistration("schema.profiles","registerProfile","schema"))return;const t=hr(e);ur(t),this.#r.profiles.push({layer:this.#e.layer,name:this.#e.name,profile:mr(t)})}registerImportExportCommandFlags(e,t,n){n.flags!==void 0&&(p(this.#e,"schema",`${e} options.flags`),this.allowRegistration("schema.flags",`${e} options.flags`,"schema")&&(O(n.flags),this.#r.flags.push({layer:this.#e.layer,name:this.#e.name,target_command:t,flags:D(`${e} options.flags`,n.flags)})))}applyImportExportCommandMetadata(e,t,n){if(n!==void 0&&(typeof n!="object"||n===null||Array.isArray(n)))throw new TypeError(`${e} options must be an object when provided`);const i=`${e==="registerImporter"?"Import":"Export"} items with the registered extension adapter.`,o=[{name:"file",required:!1,description:"Optional input or output file path."}],s={...n,description:n?.description??i,arguments:n?.arguments??o},a=Ae(e,s,n?.description!==void 0);$(`${e} options.action`,s.action),$(`${e} options.description`,s.description),$(`${e} options.intent`,s.intent);const m=F(t,s.action),c=C(`${e} options.examples`,s.examples),l=C(`${e} options.failure_hints`,s.failure_hints),d=T(s.arguments);this.registerImportExportCommandFlags(e,t,s);const h={source_version:this.#e.version,layer:this.#e.layer,name:this.#e.name,source_package:this.#e.source_package,command:t,action:m,examples:c,failure_hints:l,arguments:d},u=s.description?.trim();u&&(h.description=u);const f=s.intent?.trim();return f&&(h.intent=f),this.#r.commands.push(h),a}registerImporter(e,t,n){if(p(this.#e,"importers","registerImporter"),!this.allowRegistration("importers.importer","registerImporter","importers"))return;const i=Y(P("registerImporter name",e));S("registerImporter importer",t);const o=Z(i,"import");this.applyImportExportCommandMetadata("registerImporter",o,n),this.#r.importers.push({layer:this.#e.layer,name:this.#e.name,importer:i}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:o,run:async s=>t(U(s,i,"import"))})}registerExporter(e,t,n){if(p(this.#e,"importers","registerExporter"),!this.allowRegistration("importers.exporter","registerExporter","importers"))return;const i=Y(P("registerExporter name",e));S("registerExporter exporter",t);const o=Z(i,"export"),s=this.applyImportExportCommandMetadata("registerExporter",o,n);this.#r.exporters.push({layer:this.#e.layer,name:this.#e.name,exporter:i,...s===void 0?{}:{output:s}}),this.#n.handlers.push({layer:this.#e.layer,name:this.#e.name,command:o,run:async a=>{const m=await t(U(a,i,"export"));return s?.receipt==="suppress"&&!be(m)?Ce(m):m}})}registerSearchProvider(e){if(p(this.#e,"search","registerSearchProvider"),!this.allowRegistration("search.provider","registerSearchProvider","search"))return;const t=k("registerSearchProvider provider",e);this.#r.search_providers.push(I({layer:this.#e.layer,name:this.#e.name,definition:R("registerSearchProvider provider",e)},t))}registerVectorStoreAdapter(e){if(p(this.#e,"search","registerVectorStoreAdapter"),!this.allowRegistration("search.vectorstore","registerVectorStoreAdapter","search"))return;const t=k("registerVectorStoreAdapter adapter",e);this.#r.vector_store_adapters.push(I({layer:this.#e.layer,name:this.#e.name,definition:R("registerVectorStoreAdapter adapter",e)},t))}registerAssuranceMeasurementProvider(e){if(p(this.#e,"services","registerAssuranceMeasurementProvider"),!this.allowRegistration("services.assuranceprovider","registerAssuranceMeasurementProvider","services"))return;if(gr(e),e.network&&this.#e.permissions?.network!==!0)throw new TypeError("registerAssuranceMeasurementProvider network provider requires permissions.network=true");const t=k("registerAssuranceMeasurementProvider provider",e);this.#r.assurance_providers.push(I({layer:this.#e.layer,name:this.#e.name,network_permission:this.#e.permissions?.network===!0,definition:R("registerAssuranceMeasurementProvider provider",e)},t))}registerBeforeCommand(e){p(this.#e,"hooks","api.hooks.beforeCommand"),this.allowRegistration("hooks.beforecommand","api.hooks.beforeCommand","hooks")&&(E("beforeCommand",e),this.#t.beforeCommand.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerBeforeMutation(e){p(this.#e,"hooks","api.hooks.beforeMutation"),this.allowRegistration("hooks.beforemutation","api.hooks.beforeMutation","hooks")&&(E("beforeMutation",e),this.#t.beforeMutation.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerAfterCommand(e){p(this.#e,"hooks","api.hooks.afterCommand"),this.allowRegistration("hooks.aftercommand","api.hooks.afterCommand","hooks")&&(E("afterCommand",e),this.#t.afterCommand.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerOnWrite(e){p(this.#e,"hooks","api.hooks.onWrite"),this.allowRegistration("hooks.onwrite","api.hooks.onWrite","hooks")&&(E("onWrite",e),this.#t.onWrite.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerOnRead(e){p(this.#e,"hooks","api.hooks.onRead"),this.allowRegistration("hooks.onread","api.hooks.onRead","hooks")&&(E("onRead",e),this.#t.onRead.push({layer:this.#e.layer,name:this.#e.name,run:e}))}registerOnIndex(e){p(this.#e,"hooks","api.hooks.onIndex"),this.allowRegistration("hooks.onindex","api.hooks.onIndex","hooks")&&(E("onIndex",e),this.#t.onIndex.push({layer:this.#e.layer,name:this.#e.name,run:e}))}}function pe(r,e,t,n,i,o,s,a,m,c,l){return new jr(r,e,t,n,i,o,s,a,m,c,l)}function fe(r){const e=r.commands.length,t=r.flags.reduce((s,a)=>s+a.flags.length,0),n=r.item_fields.reduce((s,a)=>s+a.fields.length,0),i=r.item_types.reduce((s,a)=>s+a.types.length,0),o=(r.relationship_kinds??[]).reduce((s,a)=>s+a.definitions.length,0);return{commands:e,flags:t,item_fields:n,item_types:i,...o>0?{relationship_kinds:o}:{},migrations:r.migrations.length,profiles:r.profiles.length,importers:r.importers.length,exporters:r.exporters.length,search_providers:r.search_providers.length,vector_store_adapters:r.vector_store_adapters.length,...(r.assurance_providers?.length??0)>0?{assurance_providers:r.assurance_providers.length}:{}}}function ge(r){const e=[],t=(o,s)=>{const a=new Map;for(const m of o){const c=a.get(m.command)??[];c.push(m),a.set(m.command,c)}for(const m of[...a.keys()].sort((c,l)=>c.localeCompare(l))){const c=a.get(m);if(c.length<=1)continue;const l=c[c.length-1];for(const d of c.slice(0,-1))e.push(`${s}:${m}:${l.layer}:${l.name}:${d.layer}:${d.name}`)}};t(r.handlers,"extension_command_handler_collision"),t(r.overrides,"extension_command_override_collision");const n=new Set(r.handlers.map(o=>o.command)),i=[...new Set(r.overrides.map(o=>o.command))].filter(o=>n.has(o));i.sort((o,s)=>o.localeCompare(s));for(const o of i){const s=r.handlers.filter(m=>m.command===o),a=r.overrides.filter(m=>m.command===o);for(const m of a)for(const c of s)e.push(`extension_command_override_handler_overlap:${o}:${m.layer}:${m.name}:${c.layer}:${c.name}`)}return e}function ye(r){const e=new Map;for(const n of r.overrides){const i=e.get(n.format)??[];i.push(n),e.set(n.format,i)}const t=[];for(const n of[...e.keys()].sort((i,o)=>i.localeCompare(o))){const i=e.get(n);if(i.length<=1)continue;const o=i[i.length-1];for(const s of i.slice(0,-1))o.commands?.length&&s.commands?.length&&!s.commands.some(a=>o.commands?.includes(a))||t.push(`extension_renderer_collision:${n}:${o.layer}:${o.name}:${s.layer}:${s.name}`)}return t}function _e(r){const e=[],t=new Map;for(const n of r.overrides){const i=t.get(n.command)??[];i.push(n),t.set(n.command,i)}for(const n of[...t.keys()].sort((i,o)=>i.localeCompare(o))){const i=t.get(n);if(i.length<=1)continue;const o=i[i.length-1];for(const s of i.slice(0,-1))e.push(`extension_parser_override_collision:${n}:${o.layer}:${o.name}:${s.layer}:${s.name}`)}return e}const Vr=new Set(["output_format"]);function ve(r){const e=[],t=new Map;for(const n of r.overrides){const i=t.get(n.service)??[];i.push(n),t.set(n.service,i)}for(const n of[...t.keys()].sort((i,o)=>i.localeCompare(o))){const i=t.get(n);if(i.length<=1||Vr.has(n))continue;const o=i[i.length-1];for(const s of i.slice(0,-1))e.push(`extension_service_override_collision:${n}:${o.layer}:${o.name}:${s.layer}:${s.name}`)}return e}async function xt(r){const e=Ve(r.policy??Er),t=Be(),n=Le(),i=Ue(),o=Ke(),s=Je(),a=Ge(),m=Xe(),c=[],l=[];for(const u of r.loaded){const f=ue(u.module);if(!f)continue;const g=c.length,v=Pe({hooks:t,commands:n,parsers:i,preflight:o,services:s,renderers:a,registrations:m});try{await f.activate(pe(u,t,n,i,o,s,a,m,l,c,e)),c.length>g&&(v(),l.push(`extension_activation_rolled_back:${u.layer}:${u.name}`))}catch(_){v(),l.push(`extension_activate_failed:${u.layer}:${u.name}`);const A=J(_);c.push({layer:u.layer,name:u.name,entry_path:u.entry_path,error:M(_),trace:A})}}const d=[...ge(n),..._e(i),...or(o),...ve(s),...ye(a)],h=[...new Set([...l,...d])];return{hooks:t,commands:n,parsers:i,preflight:o,services:s,renderers:a,registrations:m,failed:c,warnings:h,hook_counts:{before_command:t.beforeCommand.length,before_mutation:t.beforeMutation.length,after_command:t.afterCommand.length,on_write:t.onWrite.length,on_read:t.onRead.length,on_index:t.onIndex.length},command_override_count:n.overrides.length,command_handler_count:n.handlers.length,parser_override_count:i.overrides.length,preflight_override_count:o.overrides.length,service_override_count:s.overrides.length,renderer_override_count:a.overrides.length,registration_counts:fe(m)}}const Et={assertFlagValueTypeAndDefault:cr,assertOptionalStringField:$,compareComparableVersions:_r,collectCommandCollisionWarnings:ge,collectParserCollisionWarnings:_e,collectRendererCollisionWarnings:ye,collectServiceCollisionWarnings:ve,createExtensionApi:pe,createRegistrationValidationError:y,evaluatePmMaxVersionCompatibility:ce,evaluatePmMinVersionCompatibility:me,extractRegistrationValidationTrace:J,fingerprintPath:j,getRegistrationCounts:fe,normalizeCommandDefinitionArguments:T,normalizeExtensionDeactivateTimeout:he,normalizeOptionalStringArrayField:C,normalizeRegistrationRecord:R,normalizeRegistrationRecordList:z,normalizeRuntimeRegistrationRecord:k,parseComparableVersion:xr,parseManifest:X,readCurrentPmCliVersion:oe,readManagedExtensionSourcePackages:async r=>new Map([...await te(r)].filter(e=>typeof e[1].package_name=="string").map(([e,t])=>[e,t.package_name])),resolveExtensionImportHref:le,resolveCurrentPmCliVersion:N,resolveCommandDefinitionAction:F,sanitizeRegistrationValue:Q,validateItemFieldDefinitions:G,resetCurrentPmCliVersionCacheForTest:()=>{W=null}};export{Yt as DEFAULT_EXTENSION_PRIORITY,Et as _testOnlyLoader,xt as activateExtensions,Pt as createEmptyExtensionCommandRegistry,St as createEmptyExtensionHookRegistry,It as createEmptyExtensionParserRegistry,Mt as createEmptyExtensionPreflightRegistry,At as createEmptyExtensionRegistrationRegistry,Tt as createEmptyExtensionRendererRegistry,Dt as createEmptyExtensionServiceRegistry,wt as deactivateExtensions,Tr as discoverExtensions,Rr as isCanonicalPathWithinDirectory,vt as loadExtensions,br as nextExtensionReloadToken,Qt as parseExtensionManifestDocument,Rt as parseLegacyExtensionCapabilityAliasWarning,kt as parseUnknownExtensionCapabilityWarning,kr as resolveExtensionRoots,Ot as runAfterCommandHooks,zt as runBeforeCommandHooks,Wt as runBeforeMutationHooks,Nt as runCommandHandler,jt as runCommandOverride,Vt as runOnIndexHooks,qt as runOnReadHooks,Ht as runOnWriteHooks,Lt as runParserOverride,Bt as runPreflightOverride,Ut as runRendererOverride,Kt as runServiceOverride,Xt as runServiceOverrideSync};
|
|
2
2
|
//# sourceMappingURL=loader.js.map
|
|
@@ -17,6 +17,14 @@ export declare function isFileAbsentError(error:unknown):boolean;
|
|
|
17
17
|
export declare function isFileMissingError(error:unknown):boolean;
|
|
18
18
|
/** Implements read file if exists for the public runtime surface of this module. */
|
|
19
19
|
export declare function readFileIfExists(targetPath:string):Promise<string|null>;
|
|
20
|
+
/**
|
|
21
|
+
* Read an optional file without blocking on a special one: null when it is
|
|
22
|
+
* absent, its UTF-8 text when it is a regular file, and a thrown error for
|
|
23
|
+
* anything else. The open is non-blocking where Node exposes O_NONBLOCK, so a
|
|
24
|
+
* named pipe with no writer fails like a directory instead of stalling the
|
|
25
|
+
* read. Links are followed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readOptionalRegularFile(targetPath:string):Promise<string|null>;
|
|
20
28
|
/**
|
|
21
29
|
* Read UTF-8 bytes after checking that the opened descriptor is a regular file.
|
|
22
30
|
* Callers validate entries, ancestors and optional-file absence before opening.
|
package/dist/core/fs/fs-utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
`,"utf8")}finally{await o.close()}}async function b(e){try{await
|
|
1
|
+
import*as i from"node:fs/promises";import{constants as f}from"node:fs";import c from"node:path";import m from"node:crypto";import{EXIT_CODE as h}from"../shared/constants.js";import{PmCliError as E}from"../shared/errors.js";const O=[10,25,50,100];async function y(e){await i.mkdir(e,{recursive:!0})}async function R(e){try{return await i.access(e),!0}catch{return!1}}function p(e){return _(e)||l(e,"ENOTDIR")}function _(e){return l(e,"ENOENT")}async function v(e){try{return await i.readFile(e,"utf8")}catch(t){if(p(t))return null;throw t}}async function A(e){let t;try{t=await i.open(e,f.O_RDONLY|f.O_NONBLOCK)}catch(r){if(p(r))return null;throw r}try{if(!(await t.stat()).isFile())throw new Error(`Not a regular file: ${e}`);return await t.readFile("utf8")}finally{await t.close()}}async function D(e,t){const r=await i.open(e,f.O_RDONLY|f.O_NOFOLLOW|f.O_NONBLOCK);try{if(!(await r.stat()).isFile())throw t;return await r.readFile("utf8")}finally{await r.close()}}function $(e){const t=e?.replaceAll(c.sep,"/"),r=t!==void 0&&!c.posix.isAbsolute(t)&&!c.win32.isAbsolute(t)&&!t.split("/").includes(".."),o=r?t.split("/")[0]:void 0,n={"settings.json":"settings",runtime:"runtime",schema:"schema",history:"history",transactions:"transactions"},a=o===void 0?"tracker_storage":Object.hasOwn(n,o)?n[o]:"tracker_storage",u=r&&t.length>0&&t.length<=160&&t.split("/").every(s=>s!=="."&&/^[a-zA-Z0-9_.-]+$/u.test(s)),d=u?t:`${a} (entry name redacted)`;return new E(`Transaction preview requires regular files and directories. Inspect ${d} relative to the selected tracker root.`,h.USAGE,{code:"transaction_preview_non_regular_file",preview_storage:{storage_area:a,...u?{relative_entry:t}:{},entry_redacted:!u},required:"regular files and directories within the configured tracker storage",why:"Preview does not follow linked entries or read special files.",nextSteps:[`Inspect ${d} within the selected tracker for links, directories used as files, or special files; do not follow link targets.`,"Restore the intended regular files and directories, then retry the original dry-run command."]})}async function w(e){try{await i.unlink(e)}catch{}}async function L(e,t,r={}){const o=c.dirname(e);r.createParentDirectories!==!1&&await y(o);const n=c.join(o,`.${c.basename(e)}.${process.pid}.${Date.now()}.${m.randomBytes(4).toString("hex")}.tmp`);try{await i.writeFile(n,t,r.mode===void 0?"utf8":{encoding:"utf8",mode:r.mode})}catch(a){throw await w(n),a}try{await i.rename(n,e)}catch(a){if(process.platform==="win32"&&(l(a,"EPERM")||l(a,"EBUSY"))){let u=a;for(const d of O){await new Promise(s=>setTimeout(s,d));try{await i.rename(n,e);return}catch(s){if(u=s,!l(s,"EPERM")&&!l(s,"EBUSY"))break}}throw await w(n),u}if(l(a,"EXDEV")){try{await i.copyFile(n,e)}finally{await w(n)}return}throw await w(n),a}}async function S(e,t){const r=c.dirname(e);await y(r);const o=await i.open(e,"a");try{await o.writeFile(`${t}
|
|
2
|
+
`,"utf8")}finally{await o.close()}}async function b(e){try{await i.unlink(e)}catch(t){if(!p(t))throw t}}function l(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}export{S as appendLineAtomic,y as ensureDir,p as isFileAbsentError,_ as isFileMissingError,R as pathExists,v as readFileIfExists,A as readOptionalRegularFile,D as readRegularFile,b as removeFileIfExists,$ as transactionPreviewNonRegularFileError,L as writeFileAtomic};
|
|
3
3
|
//# sourceMappingURL=fs-utils.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{parseItemExecutionRole as $}from"./item-type-definition.js";function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function r(e){try{return JSON.stringify(e)??String(e)}catch{return"a value that cannot be shown"}}function d(e,t,n,i){const o=e[t];if(o===void 0)return;if(!Array.isArray(o)){i.push(`${n}${t}: is not a list`);return}for(const u of o)typeof u!="string"?i.push(`${n}${t}: ${r(u)} is not a string`):u.trim().length===0&&i.push(`${n}${t}: ${r(u)} is blank`);const s=o.filter(u=>typeof u=="string"&&u.trim().length>0);return s.length===0&&o.length>0?void 0:s}function f(e,t,n,i){const o=e[t];if(o===void 0||typeof o=="string")return o;i.push(`${n}${t}: is not a string`)}function a(e,t,n,i,o){const s=e[t];if(s===void 0||typeof s=="boolean")return s;const u=o==="extension"?!!s:void 0;return i.push(`${n}${t}: ${r(s)} is not a boolean, so ${u===void 0?"it is ignored":`it reads as ${String(u)}`}`),u}function p(e){return typeof e=="string"&&e.trim().length>0}function _(e,t,n,i){if(!l(e)||!p(e.key))return n.push(`${t}: ${r(e)} is not an option with a key`),null;const o=`${t}.`,s=d(e,"values",o,n);return e.values!==void 0&&s===void 0?(n.push(`${t}: values has no usable value, so the option is dropped`),null):{key:e.key,values:s??[],required:a(e,"required",o,n,i),aliases:d(e,"aliases",o,n),description:f(e,"description",o,n)}}function g(e,t,n,i){const o=l(e)&&typeof e.command=="string"?e.command.trim().toLowerCase():void 0;if(!l(e)||o!=="create"&&o!=="update"||!p(e.option))return n.push(`${t}: ${r(e)} is not a create or update policy with an option`),null;const s=`${t}.`,u=n.length,c={command:o,option:e.option,required:a(e,"required",s,n,i),visible:a(e,"visible",s,n,i),enabled:a(e,"enabled",s,n,i)};return i==="schema_file"&&n.length>u?(n.push(`${t}: has a switch that is not a boolean, so the policy is dropped`),null):c}function h(e,t,n,i,o){const s=e[t];if(s===void 0)return;if(!Array.isArray(s)){n.push(`${t}: is not a list`);return}const u=s.flatMap((c,y)=>o(c,`${t}[${y}]`,n,i)??[]);return u.length===0&&s.length>0?void 0:u}function m(e,t,n){const i=e.execution_role;return t==="extension"||i===void 0||i==="agent"||i==="human"||i==="gate"?$(i):(n.push(`execution_role: ${r(i)} is not agent, human or gate, so the type reads as human and is never offered for agent dispatch`),"human")}function b(e,t){if(!l(e))return{definition:null,loss:{dropped:"not_an_object",ignored:[]}};if(typeof e.name!="string"||e.name.trim().length===0)return{definition:null,loss:{dropped:"name_empty",ignored:[]}};const n=[];return{definition:{name:e.name,description:f(e,"description","",n),default_status:f(e,"default_status","",n),execution_role:m(e,t,n),folder:f(e,"folder","",n),aliases:d(e,"aliases","",n),required_create_fields:d(e,"required_create_fields","",n),required_create_repeatables:d(e,"required_create_repeatables","",n),options:h(e,"options",n,t,_),command_option_policies:h(e,"command_option_policies",n,t,g)},loss:{ignored:n}}}export{b as inspectItemTypeDefinition};
|
|
2
|
+
//# sourceMappingURL=item-type-inspection.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import w from"node:path";import{TYPE_TO_FOLDER as R}from"../shared/constants.js";import{ITEM_TYPE_VALUES as k}from"../../types/index.js";import{normalizeItemTypeDefinition as L,normalizeItemTypeStringList as f,strictPolicyCommand as M,parseItemExecutionRole as N}from"./item-type-definition.js";const I=Object.freeze({decision:"human",milestone:"gate"}),q=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],S=["dep","comment","note","learning","file","test","doc"],b=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],D=["title","description","type","status","priority","tags","body",...b,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],x=["title","description","body","status","closeReason","priority","type","tags",...b,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],O={"close-reason":"closeReason",close_reason:"closeReason","estimated-minutes":"estimatedMinutes",estimated_minutes:"estimatedMinutes",estimate:"estimatedMinutes","acceptance-criteria":"acceptanceCriteria",acceptance_criteria:"acceptanceCriteria",ac:"acceptanceCriteria","definition-of-ready":"definitionOfReady",definition_of_ready:"definitionOfReady",rank:"order","why-now":"whyNow",why_now:"whyNow","blocked-by":"blockedBy",blocked_by:"blockedBy","blocked-reason":"blockedReason",blocked_reason:"blockedReason","unblock-note":"unblockNote",unblock_note:"unblockNote","repro-steps":"reproSteps",repro_steps:"reproSteps","expected-result":"expectedResult",expected_result:"expectedResult","actual-result":"actualResult",actual_result:"actualResult","affected-version":"affectedVersion",affected_version:"affectedVersion","fixed-version":"fixedVersion",fixed_version:"fixedVersion","customer-impact":"customerImpact",customer_impact:"customerImpact","type-option":"typeOption",type_option:"typeOption",type_options:"typeOption"},P={...O},$={...O},A=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],C=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function E(t){return Object.fromEntries(t)}const B=E([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...A,["author","--author"],["message","--message"],["dep","--dep"],...C]),U=E([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...A,...C,["author","--author"],["message","--message"],["force","--force"]]);function F(t){return t.trim().replace(/^--+/,"").toLowerCase()}function j(t){return t==="create"?D:x}function V(t){return t==="create"?P:$}function T(t,e){const n=F(e);if(n.length===0)return;const o=V(t)[n];return o||j(t).find(r=>r.toLowerCase()===n)}function be(t,e){return(t==="create"?B:U)[e]??`--${e.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function K(t){const e=Y(t);return e.length===0?"items":e.endsWith("s")?e:`${e}s`}function z(t){const e=t.trim(),o=e.replaceAll("\\","/").replace(/^\/+/,""),r=w.posix.normalize(o);if(e.includes("\0")||/^[A-Za-z]:/.test(r)||r==="."||r===".."||r.startsWith("../"))throw new Error(`Item type folder "${t}" must stay inside the pm tracker root.`);return r}function Y(t){const e=t.trim().toLowerCase();let n="",o=!1;for(const r of e){const s=r.charCodeAt(0),a=s>=97&&s<=122,d=s>=48&&s<=57;if(a||d){o&&n.length>0&&(n+="-"),n+=r,o=!1;continue}n.length>0&&(o=!0)}return n}function G(t){return L(t,{resolvePolicyCommand:M})}function l(t,e){const n=t[e];return Array.isArray(n)?n.filter(o=>typeof o=="string"):void 0}function Q(t){if(typeof t!="object"||t===null||Array.isArray(t))return null;const e=t;return typeof e.key!="string"?null:{key:e.key,values:l(e,"values")??[],required:e.required===void 0?void 0:!!e.required,aliases:l(e,"aliases"),description:typeof e.description=="string"?e.description:void 0}}function W(t){if(typeof t!="object"||t===null||Array.isArray(t))return null;const e=t;if(typeof e.command!="string"||typeof e.option!="string")return null;const n=e.command.trim().toLowerCase();return n!=="create"&&n!=="update"?null:{command:n,option:e.option,required:e.required===void 0?void 0:!!e.required,visible:e.visible===void 0?void 0:!!e.visible,enabled:e.enabled===void 0?void 0:!!e.enabled}}function Z(t){if(Array.isArray(t.options))return t.options.map(e=>Q(e)).filter(e=>e!==null)}function H(t){if(Array.isArray(t.command_option_policies))return t.command_option_policies.map(e=>W(e)).filter(e=>e!==null)}function X(t){if(typeof t!="object"||t===null||Array.isArray(t))return null;const e=t,n=typeof e.name=="string"?e.name:"";if(n.trim().length===0)return null;const o=typeof e.folder=="string"?e.folder:void 0,r=typeof e.description=="string"?e.description:void 0,s=typeof e.default_status=="string"?e.default_status:void 0;return{name:n,description:r,default_status:s,execution_role:N(e.execution_role),folder:o,aliases:l(e,"aliases"),required_create_fields:l(e,"required_create_fields"),required_create_repeatables:l(e,"required_create_repeatables"),options:Z(e),command_option_policies:H(e)}}function J(t,e){return t.required_create_fields?f(t.required_create_fields):e?.required_create_fields??[]}function ee(t,e){return t.required_create_repeatables?f(t.required_create_repeatables):e?.required_create_repeatables??[]}function te(t,e){return t.options?t.options:e?.options?[...e.options]:[]}function oe(t,e){return t.command_option_policies?t.command_option_policies:e?.command_option_policies?[...e.command_option_policies]:[]}function ne(t,e){const n=e?.name??t.name,o=t.description??e?.description,r=t.default_status??e?.default_status,s=z(t.folder??e?.folder??K(n)),a={name:n,execution_role:t.execution_role,folder:s,aliases:f([...e?.aliases??[],...t.aliases??[]]),required_create_fields:J(t,e),required_create_repeatables:ee(t,e),options:te(t,e),command_option_policies:oe(t,e)};return o&&(a.description=o),r&&(a.default_status=r),a}function v(t,e){for(const n of t){const o=G(n);if(!o)continue;const r=o.name.toLowerCase(),s=e.get(r);e.set(r,ne({...o,execution_role:o.execution_role??s?.execution_role},s))}}function re(t){if(!t)return[];const e=[];for(const n of t.item_types??[]){const o=n.types;if(Array.isArray(o))for(const r of o){const s=X(r);s&&e.push(s)}}return e}function Oe(t,e=null){const n=new Map;for(const i of k)n.set(i.toLowerCase(),{name:i,execution_role:I[i.toLowerCase()]??"agent",folder:R[i],aliases:[],required_create_fields:[...q],required_create_repeatables:[...S],options:[],command_option_policies:[]});v(t.item_types?.definitions??[],n),v(re(e),n);const o=[...n.values()].sort((i,c)=>i.name.localeCompare(c.name)),r={},s={},a={};for(const i of o){r[i.name]=i,a[i.name]=i.folder,s[i.name.toLowerCase()]=i.name;for(const c of i.aliases)s[c.toLowerCase()]=i.name}const d=[...new Set(o.map(i=>i.folder))].sort((i,c)=>i.localeCompare(c));return{types:o.map(i=>i.name),folders:d,type_to_folder:a,by_type:r,alias_to_type:s}}function ie(t,e){if(t!==void 0)return e.alias_to_type[t.trim().toLowerCase()]}function se(t,e){const n=ie(t,e);if(n)return e.by_type[n]}function ae(t,e,n,o){for(const r of o){const s=T(n,r);if(s){t.required.add(s);continue}t.errors.push(`Unsupported base required option "${r}" for command "${n}" on type "${e.name}"`)}}function m(t,e,n){if(n){t.add(e);return}t.delete(e)}function ce(t,e,n,o){const r=T(n,o.option);if(!r){t.errors.push(`Unsupported command_option_policies option "${o.option}" for command "${n}" on type "${e.name}"`);return}o.required!==void 0&&m(t.required,r,o.required),o.visible!==void 0&&m(t.hidden,r,!o.visible),o.enabled!==void 0&&m(t.disabled,r,!o.enabled)}function de(t,e,n){for(const o of e.command_option_policies)o.command===n&&ce(t,e,n,o)}function le(t,e,n){for(const o of t.required)t.disabled.has(o)&&t.errors.push(`Option "${o}" cannot be both required and disabled for command "${n}" on type "${e.name}"`)}function Ae(t,e,n){const o=[],r=new Set,s=new Set,a=new Set,d={required:r,hidden:s,disabled:a,errors:o};return ae(d,t,e,n),de(d,t,e),le(d,t,e),{required:[...r],hidden:[...s].sort((i,c)=>i.localeCompare(c)),disabled:[...a].sort((i,c)=>i.localeCompare(c)),errors:o}}function pe(t){const e=new Map;for(const n of t.options){e.set(n.key.toLowerCase(),n);for(const o of n.aliases??[])e.set(o.toLowerCase(),n)}return e}function ue(t,e,n){const o=t.values;if(o.length===0)return e;const s=new Map(o.map(a=>[a.toLowerCase(),a])).get(e.toLowerCase());if(!s){n.push(`Invalid value "${e}" for type option "${t.key}". Allowed: ${o.join(", ")}`);return}return s}function Ce(t,e,n){const o=se(t,n);if(!o)return{normalized:void 0,errors:[`Unknown type "${t}"`]};const r=[],s=pe(o),a={};for(const[i,c]of Object.entries(e??{})){const p=i.trim(),y=c.trim();if(p.length===0){r.push("type option keys must not be empty");continue}if(y.length===0){r.push(`type option "${p}" must not be empty`);continue}const u=s.get(p.toLowerCase());if(!u){const g=o.options.map(h=>h.key).join(", ");r.push(o.options.length>0?`Unknown type option "${p}" for type "${o.name}". Allowed: ${g}`:`Type "${o.name}" does not define any configurable type options`);continue}const _=ue(u,y,r);_!==void 0&&(a[u.key]=_)}for(const i of o.options)i.required&&!(i.key in a)&&r.push(`Missing required type option "${i.key}" for type "${o.name}"`);const d=Object.keys(a).sort((i,c)=>i.localeCompare(c));return d.length===0?{normalized:void 0,errors:r}:{normalized:Object.fromEntries(d.map(i=>[i,a[i]])),errors:r}}export{I as BUILTIN_ITEM_EXECUTION_ROLES,b as COMMON_MUTATION_COMMAND_OPTION_KEYS,q as DEFAULT_REQUIRED_CREATE_FIELDS,S as DEFAULT_REQUIRED_CREATE_REPEATABLES,T as canonicalizeCommandOptionKey,be as commandOptionFlagLabel,z as normalizeItemTypeFolder,Ae as resolveCommandOptionPolicyState,Oe as resolveItemTypeRegistry,se as resolveTypeDefinition,ie as resolveTypeName,K as toDefaultFolder,Ce as validateTypeOptions};
|
|
1
|
+
import v from"node:path";import{TYPE_TO_FOLDER as R}from"../shared/constants.js";import{ITEM_TYPE_VALUES as L}from"../../types/index.js";import{normalizeItemTypeDefinition as k,normalizeItemTypeStringList as u,strictPolicyCommand as g}from"./item-type-definition.js";import{inspectItemTypeDefinition as M}from"./item-type-inspection.js";const N=Object.freeze({decision:"human",milestone:"gate"}),I=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],S=["dep","comment","note","learning","file","test","doc"],y=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],D=["title","description","type","status","priority","tags","body",...y,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],x=["title","description","body","status","closeReason","priority","type","tags",...y,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],b={"close-reason":"closeReason",close_reason:"closeReason","estimated-minutes":"estimatedMinutes",estimated_minutes:"estimatedMinutes",estimate:"estimatedMinutes","acceptance-criteria":"acceptanceCriteria",acceptance_criteria:"acceptanceCriteria",ac:"acceptanceCriteria","definition-of-ready":"definitionOfReady",definition_of_ready:"definitionOfReady",rank:"order","why-now":"whyNow",why_now:"whyNow","blocked-by":"blockedBy",blocked_by:"blockedBy","blocked-reason":"blockedReason",blocked_reason:"blockedReason","unblock-note":"unblockNote",unblock_note:"unblockNote","repro-steps":"reproSteps",repro_steps:"reproSteps","expected-result":"expectedResult",expected_result:"expectedResult","actual-result":"actualResult",actual_result:"actualResult","affected-version":"affectedVersion",affected_version:"affectedVersion","fixed-version":"fixedVersion",fixed_version:"fixedVersion","customer-impact":"customerImpact",customer_impact:"customerImpact","type-option":"typeOption",type_option:"typeOption",type_options:"typeOption"},q={...b},P={...b},O=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],C=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function w(e){return Object.fromEntries(e)}const $=w([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...O,["author","--author"],["message","--message"],["dep","--dep"],...C]),B=w([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...O,...C,["author","--author"],["message","--message"],["force","--force"]]);function U(e){return e.trim().replace(/^--+/,"").toLowerCase()}function F(e){return e==="create"?D:x}function V(e){return e==="create"?q:P}function T(e,t){const n=U(t);if(n.length===0)return;const o=V(e)[n];return o||F(e).find(r=>r.toLowerCase()===n)}function ue(e,t){return(e==="create"?$:B)[t]??`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function j(e){const t=z(e);return t.length===0?"items":t.endsWith("s")?t:`${t}s`}function K(e){const t=e.trim(),o=t.replaceAll("\\","/").replace(/^\/+/,""),r=v.posix.normalize(o);if(t.includes("\0")||/^[A-Za-z]:/.test(r)||r==="."||r===".."||r.startsWith("../"))throw new Error(`Item type folder "${e}" must stay inside the pm tracker root.`);return r}function z(e){const t=e.trim().toLowerCase();let n="",o=!1;for(const r of t){const s=r.charCodeAt(0),a=s>=97&&s<=122,p=s>=48&&s<=57;if(a||p){o&&n.length>0&&(n+="-"),n+=r,o=!1;continue}n.length>0&&(o=!0)}return n}function Y(e){return k(e,{resolvePolicyCommand:g})}function G(e,t){return e.required_create_fields?u(e.required_create_fields):t?.required_create_fields??[]}function Q(e,t){return e.required_create_repeatables?u(e.required_create_repeatables):t?.required_create_repeatables??[]}function W(e,t){return e.options?e.options:t?.options?[...t.options]:[]}function Z(e,t){return e.command_option_policies?e.command_option_policies:t?.command_option_policies?[...t.command_option_policies]:[]}function H(e,t){const n=t?.name??e.name,o=e.description??t?.description,r=e.default_status??t?.default_status,s=K(e.folder??t?.folder??j(n)),a={name:n,execution_role:e.execution_role,folder:s,aliases:u([...t?.aliases??[],...e.aliases??[]]),required_create_fields:G(e,t),required_create_repeatables:Q(e,t),options:W(e,t),command_option_policies:Z(e,t)};return o&&(a.description=o),r&&(a.default_status=r),a}function E(e,t){for(const n of e){const o=Y(n);if(!o)continue;const r=o.name.toLowerCase(),s=t.get(r);t.set(r,H({...o,execution_role:o.execution_role??s?.execution_role},s))}}function X(e){if(!e)return[];const t=[];for(const n of e.item_types??[]){const o=n.types;if(Array.isArray(o))for(const r of o){const s=M(r,"extension").definition;s&&t.push(s)}}return t}function fe(e,t=null){const n=new Map;for(const i of L)n.set(i.toLowerCase(),{name:i,execution_role:N[i.toLowerCase()]??"agent",folder:R[i],aliases:[],required_create_fields:[...I],required_create_repeatables:[...S],options:[],command_option_policies:[]});E(e.item_types?.definitions??[],n),E(X(t),n);const o=[...n.values()].sort((i,c)=>i.name.localeCompare(c.name)),r={},s={},a={};for(const i of o){r[i.name]=i,a[i.name]=i.folder,s[i.name.toLowerCase()]=i.name;for(const c of i.aliases)s[c.toLowerCase()]=i.name}const p=[...new Set(o.map(i=>i.folder))].sort((i,c)=>i.localeCompare(c));return{types:o.map(i=>i.name),folders:p,type_to_folder:a,by_type:r,alias_to_type:s}}function J(e,t){if(e!==void 0)return t.alias_to_type[e.trim().toLowerCase()]}function ee(e,t){const n=J(e,t);if(n)return t.by_type[n]}function te(e,t,n,o){for(const r of o){const s=T(n,r);if(s){e.required.add(s);continue}e.errors.push(`Unsupported base required option "${r}" for command "${n}" on type "${t.name}"`)}}function f(e,t,n){if(n){e.add(t);return}e.delete(t)}function oe(e,t,n,o){const r=T(n,o.option);if(!r){e.errors.push(`Unsupported command_option_policies option "${o.option}" for command "${n}" on type "${t.name}"`);return}o.required!==void 0&&f(e.required,r,o.required),o.visible!==void 0&&f(e.hidden,r,!o.visible),o.enabled!==void 0&&f(e.disabled,r,!o.enabled)}function ne(e,t,n){for(const o of t.command_option_policies)o.command===n&&oe(e,t,n,o)}function re(e,t,n){for(const o of e.required)e.disabled.has(o)&&e.errors.push(`Option "${o}" cannot be both required and disabled for command "${n}" on type "${t.name}"`)}function me(e,t,n){const o=[],r=new Set,s=new Set,a=new Set,p={required:r,hidden:s,disabled:a,errors:o};return te(p,e,t,n),ne(p,e,t),re(p,e,t),{required:[...r],hidden:[...s].sort((i,c)=>i.localeCompare(c)),disabled:[...a].sort((i,c)=>i.localeCompare(c)),errors:o}}function ie(e){const t=new Map;for(const n of e.options){t.set(n.key.toLowerCase(),n);for(const o of n.aliases??[])t.set(o.toLowerCase(),n)}return t}function se(e,t,n){const o=e.values;if(o.length===0)return t;const s=new Map(o.map(a=>[a.toLowerCase(),a])).get(t.toLowerCase());if(!s){n.push(`Invalid value "${t}" for type option "${e.key}". Allowed: ${o.join(", ")}`);return}return s}function _e(e,t,n){const o=ee(e,n);if(!o)return{normalized:void 0,errors:[`Unknown type "${e}"`]};const r=[],s=ie(o),a={};for(const[i,c]of Object.entries(t??{})){const l=i.trim(),m=c.trim();if(l.length===0){r.push("type option keys must not be empty");continue}if(m.length===0){r.push(`type option "${l}" must not be empty`);continue}const d=s.get(l.toLowerCase());if(!d){const A=o.options.map(h=>h.key).join(", ");r.push(o.options.length>0?`Unknown type option "${l}" for type "${o.name}". Allowed: ${A}`:`Type "${o.name}" does not define any configurable type options`);continue}const _=se(d,m,r);_!==void 0&&(a[d.key]=_)}for(const i of o.options)i.required&&!(i.key in a)&&r.push(`Missing required type option "${i.key}" for type "${o.name}"`);const p=Object.keys(a).sort((i,c)=>i.localeCompare(c));return p.length===0?{normalized:void 0,errors:r}:{normalized:Object.fromEntries(p.map(i=>[i,a[i]])),errors:r}}export{N as BUILTIN_ITEM_EXECUTION_ROLES,y as COMMON_MUTATION_COMMAND_OPTION_KEYS,I as DEFAULT_REQUIRED_CREATE_FIELDS,S as DEFAULT_REQUIRED_CREATE_REPEATABLES,T as canonicalizeCommandOptionKey,ue as commandOptionFlagLabel,K as normalizeItemTypeFolder,me as resolveCommandOptionPolicyState,fe as resolveItemTypeRegistry,ee as resolveTypeDefinition,J as resolveTypeName,j as toDefaultFolder,_e as validateTypeOptions};
|
|
2
2
|
//# sourceMappingURL=type-registry.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{BUILTIN_ITEM_TYPE_VALUES as _}from"../../types/index.js";import{parseNestedSettingValue as g,resolveNestedSettingDescriptor as k}from"../config/nested-settings.js";import{normalizeAddFieldInput as v}from"../schema/fields-file.js";import{normalizeAddStatusInput as S}from"../schema/status-defs-file.js";import{normalizeAddTypeInput as $}from"../schema/item-types-file.js";import{normalizeStatusToken as p}from"../schema/type-workflows.js";import{DEFAULT_RUNTIME_STATUS_DEFINITIONS as T}from"../schema/runtime-schema.js";import{toErrorMessage as f}from"../shared/primitives.js";import{resolvePmToolCustomFieldCollision as I}from"../../sdk/cli-contracts/tool-schema.js";import{describeFieldFlagSpellingDefectLine as b,describeFieldOptionCollision as F,resolveAddFieldFlagSpellingDefects as P,resolveAddFieldOptionCollisions as C}from"../../sdk/schema/field-option-collisions.js";import{normalizeProfileLookupKey as h}from"./profile-presets.js";const J=["profile","types","statuses","fields","workflows","config","templates","packages"],Q=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","field_option_collision","field_flag_invalid","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],L=new Set(T.flatMap(t=>[p(t.id),...(t.aliases??[]).map(e=>p(e))]).filter(t=>t.length>0)),w=new Set(_.map(t=>t.toLowerCase()));function E(t,e){t.name.trim().length===0?e.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):t.name!==h(t.name)&&e.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:t.name,message:`Profile name "${t.name}" is not in canonical form; resolution folds it to "${h(t.name)}" (lowercase, hyphens as underscores).`}),t.title.trim().length===0&&e.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),t.summary.trim().length===0&&e.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function N(t,e){const r=new Set,i=new Set;for(const[s,o]of t.types.entries()){let n;try{n=$(o).name}catch(d){e.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof o.name=="string"?o.name:`#${s}`,message:f(d)});continue}const a=n.toLowerCase();if(i.has(a)){e.push({severity:"error",code:"type_duplicate",dimension:"types",target:n,message:`Item type "${n}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}i.add(a),r.add(a)}return r}function z(t,e){const r=new Set,i=new Set;for(const[s,o]of t.statuses.entries()){let n;try{n=S(o)}catch(a){e.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof o.id=="string"?o.id:`#${s}`,message:f(a)});continue}if(i.has(n.id)){e.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:n.id,message:`Status "${n.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}i.add(n.id),r.add(n.id);for(const a of n.aliases??[])r.add(p(a))}return r}function x(t,e){const r=new Set;for(const[i,s]of t.fields.entries()){let o,n;try{n=v(s),o=n.key}catch(m){e.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof s.key=="string"?s.key:`#${i}`,message:f(m)});continue}if(r.has(o)){e.push({severity:"error",code:"field_duplicate",dimension:"fields",target:o,message:`Field "${o}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}r.add(o);const a=P(n);a.length>0&&e.push({severity:"error",code:"field_flag_invalid",dimension:"fields",target:o,message:`Field "${o}" declares a flag that is not one option spelling: ${a.map(b).join("; ")}. Pass one spelling per alias.`});const d=C(n);d.length>0&&e.push({severity:"error",code:"field_option_collision",dimension:"fields",target:o,message:`Field "${o}" would disable a built-in option: ${d.map(F).join("; ")}. Rename the field or narrow its commands.`});const l=I(o);l&&e.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:o,message:`Field "${o}" collides with canonical MCP property "${l.property}" owned by ${l.owner}; callers must pass the custom value through ${l.nested_path}.`})}}function A(t,e,r,i){const s=new Set;for(const[o,n]of t.workflows.entries()){const a=n.type.trim().toLowerCase();if(a.length===0){i.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${o}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}const d=s.has(a);s.add(a),d?i.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:n.type,message:`Workflow type "${n.type}" is declared more than once; the later transition set wins.`}):!w.has(a)&&!e.has(a)&&i.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:n.type,message:`Workflow governs type "${n.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});const l=new Set;for(const m of n.allowed_transitions){const u=p(m[0]),y=p(m[1]);if(u.length===0||y.length===0){i.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:n.type,message:`Workflow "${n.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(const c of[u,y])L.has(c)||r.has(c)||l.has(c)||(l.add(c),i.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:c,message:`Workflow "${n.type}" references status "${c}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function O(t,e){const r=new Set;for(const i of t.config){const s=k(i.key);if(s===void 0){e.push({severity:"error",code:"config_key_unknown",dimension:"config",target:i.key,message:`Config knob "${i.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}r.has(s.key)?e.push({severity:"error",code:"config_duplicate",dimension:"config",target:s.key,message:`Config knob "${s.key}" is set more than once; the later value silently overwrites the earlier one.`}):r.add(s.key);const o=g(s,i.value);o.ok||e.push({severity:"error",code:"config_value_invalid",dimension:"config",target:i.key,message:o.error.message})}}function U(t,e,r){for(const i of t.templates){const s=i.options.type;if(typeof s!="string"||s.trim().length===0)continue;const o=s.trim().toLowerCase();!w.has(o)&&!e.has(o)&&r.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:i.name,message:`Template "${i.name}" creates type "${s}" which is neither a built-in type nor declared by this profile.`})}}function D(t,e){for(const[r,i]of t.packages.entries())i.spec.trim().length===0&&e.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${r}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function X(t){const e=[];E(t,e);const r=N(t,e),i=z(t,e);x(t,e),A(t,r,i,e),O(t,e),U(t,r,e),D(t,e);const s=e.filter(n=>n.severity==="error").length,o=e.length-s;return{profile:t.name,ok:s===0,findings:e,errorCount:s,warningCount:o}}export{Q as PROFILE_LINT_CODES,J as PROFILE_LINT_DIMENSIONS,X as lintProjectProfile};
|
|
1
|
+
import{BUILTIN_ITEM_TYPE_VALUES as _}from"../../types/index.js";import{parseNestedSettingValue as g,resolveNestedSettingDescriptor as k}from"../config/nested-settings.js";import{normalizeAddFieldInput as v}from"../schema/fields-file.js";import{normalizeAddStatusInput as S}from"../schema/status-defs-file.js";import{normalizeAddTypeInput as $}from"../schema/item-types-file.js";import{normalizeStatusToken as p}from"../schema/type-workflows.js";import{DEFAULT_RUNTIME_STATUS_DEFINITIONS as T}from"../schema/runtime-schema.js";import{toErrorMessage as f}from"../shared/primitives.js";import{resolvePmToolCustomFieldCollision as I}from"../../sdk/cli-contracts/tool-schema.js";import{describeFieldFlagSpellingDefectLine as b,describeFieldOptionCollision as F,resolveAddFieldFlagSpellingDefects as P,resolveAddFieldOptionCollisions as C}from"../../sdk/schema/field-option-collisions.js";import{normalizeProfileLookupKey as h}from"./profile-presets.js";const J=["profile","types","statuses","fields","workflows","config","templates","packages"],Q=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","field_option_collision","field_flag_invalid","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],L=new Set(T.flatMap(t=>[p(t.id),...(t.aliases??[]).map(e=>p(e))]).filter(t=>t.length>0)),w=new Set(_.map(t=>t.toLowerCase()));function E(t,e){t.name.trim().length===0?e.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):t.name!==h(t.name)&&e.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:t.name,message:`Profile name "${t.name}" is not in canonical form; resolution folds it to "${h(t.name)}" (lowercase, hyphens as underscores).`}),t.title.trim().length===0&&e.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),t.summary.trim().length===0&&e.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function N(t,e){const r=new Set,i=new Set;for(const[s,o]of t.types.entries()){let n;try{n=$(o).name}catch(d){e.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof o.name=="string"?o.name:`#${s}`,message:f(d)});continue}const a=n.toLowerCase();if(i.has(a)){e.push({severity:"error",code:"type_duplicate",dimension:"types",target:n,message:`Item type "${n}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}i.add(a),r.add(a)}return r}function z(t,e){const r=new Set,i=new Set;for(const[s,o]of t.statuses.entries()){let n;try{n=S(o)}catch(a){e.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof o.id=="string"?o.id:`#${s}`,message:f(a)});continue}if(i.has(n.id)){e.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:n.id,message:`Status "${n.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}i.add(n.id),r.add(n.id);for(const a of n.aliases??[])r.add(p(a))}return r}function x(t,e){const r=new Set;for(const[i,s]of t.fields.entries()){let o,n;try{n=v(s),o=n.key}catch(m){e.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof s.key=="string"?s.key:`#${i}`,message:f(m)});continue}if(r.has(o)){e.push({severity:"error",code:"field_duplicate",dimension:"fields",target:o,message:`Field "${o}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}r.add(o);const a=P(n,s);a.length>0&&e.push({severity:"error",code:"field_flag_invalid",dimension:"fields",target:o,message:`Field "${o}" declares a flag that is not one option spelling: ${a.map(b).join("; ")}. Pass one spelling per alias.`});const d=C(n);d.length>0&&e.push({severity:"error",code:"field_option_collision",dimension:"fields",target:o,message:`Field "${o}" would disable a built-in option: ${d.map(F).join("; ")}. Rename the field or narrow its commands.`});const l=I(o);l&&e.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:o,message:`Field "${o}" collides with canonical MCP property "${l.property}" owned by ${l.owner}; callers must pass the custom value through ${l.nested_path}.`})}}function A(t,e,r,i){const s=new Set;for(const[o,n]of t.workflows.entries()){const a=n.type.trim().toLowerCase();if(a.length===0){i.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${o}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}const d=s.has(a);s.add(a),d?i.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:n.type,message:`Workflow type "${n.type}" is declared more than once; the later transition set wins.`}):!w.has(a)&&!e.has(a)&&i.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:n.type,message:`Workflow governs type "${n.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});const l=new Set;for(const m of n.allowed_transitions){const u=p(m[0]),y=p(m[1]);if(u.length===0||y.length===0){i.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:n.type,message:`Workflow "${n.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(const c of[u,y])L.has(c)||r.has(c)||l.has(c)||(l.add(c),i.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:c,message:`Workflow "${n.type}" references status "${c}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function O(t,e){const r=new Set;for(const i of t.config){const s=k(i.key);if(s===void 0){e.push({severity:"error",code:"config_key_unknown",dimension:"config",target:i.key,message:`Config knob "${i.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}r.has(s.key)?e.push({severity:"error",code:"config_duplicate",dimension:"config",target:s.key,message:`Config knob "${s.key}" is set more than once; the later value silently overwrites the earlier one.`}):r.add(s.key);const o=g(s,i.value);o.ok||e.push({severity:"error",code:"config_value_invalid",dimension:"config",target:i.key,message:o.error.message})}}function U(t,e,r){for(const i of t.templates){const s=i.options.type;if(typeof s!="string"||s.trim().length===0)continue;const o=s.trim().toLowerCase();!w.has(o)&&!e.has(o)&&r.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:i.name,message:`Template "${i.name}" creates type "${s}" which is neither a built-in type nor declared by this profile.`})}}function D(t,e){for(const[r,i]of t.packages.entries())i.spec.trim().length===0&&e.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${r}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function X(t){const e=[];E(t,e);const r=N(t,e),i=z(t,e);x(t,e),A(t,r,i,e),O(t,e),U(t,r,e),D(t,e);const s=e.filter(n=>n.severity==="error").length,o=e.length-s;return{profile:t.name,ok:s===0,findings:e,errorCount:s,warningCount:o}}export{Q as PROFILE_LINT_CODES,J as PROFILE_LINT_DIMENSIONS,X as lintProjectProfile};
|
|
2
2
|
//# sourceMappingURL=profile-lint.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type{ItemTypeDefinition,RuntimeFieldCommand,RuntimeFieldValueSchema,RuntimeFieldType,RuntimeSchemaSettings,RuntimeStatusDefinition,RuntimeStatusRole,RuntimeWorkflowDefinition}from "../../types/index.js";export type{RuntimeFieldCommand}from "../../types/index.js";
|
|
1
|
+
import type{ItemTypeDefinition,RuntimeFieldCommand,RuntimeFieldDefinition,RuntimeFieldValueSchema,RuntimeFieldType,RuntimeSchemaSettings,RuntimeStatusDefinition,RuntimeStatusRole,RuntimeWorkflowDefinition}from "../../types/index.js";export type{RuntimeFieldCommand}from "../../types/index.js";
|
|
2
2
|
/** Fallback runtime schema file paths used when callers do not provide an override. */
|
|
3
3
|
export declare const DEFAULT_RUNTIME_SCHEMA_FILE_PATHS:Readonly<{types:"schema/types.json";statuses:"schema/statuses.json";fields:"schema/fields.json";workflows:"schema/workflows.json";}>;
|
|
4
4
|
/** Fallback runtime workflow used when callers do not provide an override. */
|
|
@@ -101,8 +101,46 @@ warnings:string[];
|
|
|
101
101
|
created_paths:string[];}
|
|
102
102
|
/** Normalize a stored field flag token as the registry reads it: trimmed, lower-cased, separators as hyphens, leading dashes removed. */
|
|
103
103
|
export declare function normalizeCliToken(value:unknown):string;
|
|
104
|
+
/** Why the status registry drops a whole stored definition. */
|
|
105
|
+
export type RuntimeStatusDefinitionDropReason="not_an_object"|"id_empty";
|
|
106
|
+
/** What the status registry discards from one stored definition: the whole entry, or the members it ignores. */
|
|
107
|
+
export interface RuntimeStatusDefinitionLoss{
|
|
108
|
+
/** Set when the registry drops the whole definition. */
|
|
109
|
+
dropped?:RuntimeStatusDefinitionDropReason;
|
|
110
|
+
/** One line per member the registry ignores while it keeps the definition. */
|
|
111
|
+
ignored:string[];}
|
|
112
|
+
/**
|
|
113
|
+
* Resolve one stored status definition and record what the registry discards
|
|
114
|
+
* from it (pm-x17o8l). A wrong-typed member, such as a numeric description, is
|
|
115
|
+
* ignored instead of failing the settings read, and the registry and
|
|
116
|
+
* `pm validate` read this one function.
|
|
117
|
+
*/
|
|
118
|
+
export declare function inspectRuntimeStatusDefinition(definition:unknown,fallbackOrder:number):{resolved:RuntimeStatusDefinitionResolved|null;loss:RuntimeStatusDefinitionLoss;};
|
|
119
|
+
/** Why the field registry drops a whole stored definition (pm-x9r2h3). */
|
|
120
|
+
export type RuntimeFieldDefinitionDropReason="not_an_object"|"key_empty"|"metadata_key_empty"|"cli_flag_empty"|"value_schema_invalid";
|
|
121
|
+
/**
|
|
122
|
+
* What the field registry discards from one stored definition (pm-x9r2h3):
|
|
123
|
+
* the whole definition, or members it ignores or replaces while keeping it.
|
|
124
|
+
*/
|
|
125
|
+
export interface RuntimeFieldDefinitionLoss{
|
|
126
|
+
/** Set when the registry drops the whole definition. */
|
|
127
|
+
dropped?:RuntimeFieldDefinitionDropReason;
|
|
128
|
+
/** One line per member the registry ignores or replaces, such as a blank alias. */
|
|
129
|
+
ignored:string[];}
|
|
130
|
+
/**
|
|
131
|
+
* Resolve one stored definition and record what the registry discards from
|
|
132
|
+
* it. The registry and `pm validate` both read this one function, so a
|
|
133
|
+
* diagnostic can never disagree with what the registry keeps.
|
|
134
|
+
*/
|
|
135
|
+
export declare function inspectRuntimeFieldDefinition(definition:unknown):{resolved:RuntimeFieldDefinitionResolved|null;loss:RuntimeFieldDefinitionLoss;};
|
|
104
136
|
/** Implements normalize runtime schema settings for the public runtime surface of this module. */
|
|
105
137
|
export declare function normalizeRuntimeSchemaSettings(schema:Partial<RuntimeSchemaSettings>|undefined):RuntimeSchemaSettings;
|
|
138
|
+
/** The definitions list of a parsed types file, in any of its accepted shapes; undefined for any other shape. */
|
|
139
|
+
export declare function readTypeDefinitionsFromSchemaFile(parsed:unknown):unknown[]|undefined;
|
|
140
|
+
/** The definitions list of a parsed statuses file, in any of its accepted shapes; undefined for any other shape. */
|
|
141
|
+
export declare function readStatusesFromSchemaFile(parsed:unknown):RuntimeStatusDefinition[]|undefined;
|
|
142
|
+
/** The definitions list of a parsed fields file, in any of its accepted shapes; undefined for any other shape. */
|
|
143
|
+
export declare function readFieldsFromSchemaFile(parsed:unknown):RuntimeFieldDefinition[]|undefined;
|
|
106
144
|
/** Implements file path for schema section for the public runtime surface of this module. */
|
|
107
145
|
export declare function filePathForSchemaSection(pmRoot:string,configuredPath:string|undefined,fallbackPath:string):string;
|
|
108
146
|
/** Resolves the active tracker's `schema/types.json` path so user-facing hints (e.g. the invalid-type error) point at the real `--pm-path` location instead of the hardcoded `.agents/pm` default. Mirrors how `pm schema add/remove-type` report their target path. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import U from"node:path";import{pathExists as W,readFileIfExists as v}from"../fs/fs-utils.js";import{createFileAtomic as K}from"../fs/atomic-create.js";import{DEFAULT_STATUS_DEFINITIONS as V,DEFAULT_WORKFLOW_DEFINITION as H}from"../shared/constants.js";import{RUNTIME_FIELD_COMMAND_VALUES as Y,RUNTIME_FIELD_TYPE_VALUES as $,RUNTIME_STATUS_ROLE_VALUES as J,RUNTIME_UNKNOWN_FIELD_POLICY_VALUES as B,STATUS_VALUES as X}from"../../types/index.js";import{normalizeStatusToken as k}from"./status-token.js";const m=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),O=H,D=V,Z=["create","update"],G=new Set(J),Q=new Set($),ee=new Set(Y),te=new Set(B),ne=new Set(["string","number","boolean","array","object"]),re=16;function R(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const se=[e=>e.type===void 0||typeof e.type=="string"&&ne.has(e.type),e=>!Object.hasOwn(e,"const")||E(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>E(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||R(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function E(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);const n=Array.isArray(e)?e.every(r=>E(r,t)):Object.values(e).every(r=>E(r,t));return t.delete(e),n}function I(e,t=0,n=new Set){if(!R(e)||t>re||n.has(e))return;n.add(e);const r=e,s=r.type,o=r.enum,u=r.one_of,a=r.properties,i=r.items,d=r.required,c=r.min_length,l=r.min_items,p=r.format,w=r.additional_properties;if(!se.every(_=>_(r))){n.delete(e);return}const h=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([_,z])=>[_,I(z,t+1,n)])),A=i===void 0?void 0:I(i,t+1,n),g=u===void 0?void 0:u.map(_=>I(_,t+1,n));if([...Object.values(h??{}),...i===void 0?[]:[A],...g??[]].some(_=>_===void 0)){n.delete(e);return}return n.delete(e),Object.fromEntries(Object.entries({type:s,const:Object.hasOwn(r,"const")?r.const:void 0,enum:o,min_length:c,min_items:l,format:p,properties:h,required:d===void 0?void 0:[...new Set(d)],additional_properties:w,items:A,one_of:g}).filter(([,_])=>_!==void 0))}function T(e){const t=Array.isArray(e)?e:[];return[...new Set(t.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function f(e){if(typeof e!="string"||e.length===0)return;const t=k(e);return t.length>0?t:void 0}function ie(e){return e.startsWith("--")?e.slice(2):e}function M(e){return typeof e=="string"?ie(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function j(e){return e.replaceAll("_","-")}function oe(e){const t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(s=>s.length>0).map(s=>s.toLowerCase());if(t.length===0)return e;const[n,...r]=t;return`${n}${r.map(s=>`${s.slice(0,1).toUpperCase()}${s.slice(1)}`).join("")}`}function L(e,t){const n=f(e.id);if(!n)return null;const r=[...new Set(T(e.aliases).map(k).filter(a=>a.length>0))].sort((a,i)=>a.localeCompare(i)),s=T(e.roles).filter(a=>G.has(a)),o=e.description?.trim(),u=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:n,aliases:r,roles:s,description:o&&o.length>0?o:void 0,order:u}}function ae(e){return{draft_status:f(e?.draft_status),open_status:f(e?.open_status),in_progress_status:f(e?.in_progress_status),blocked_status:f(e?.blocked_status),close_status:f(e?.close_status),canceled_status:f(e?.canceled_status)}}function C(e,t){if(!Array.isArray(t)||t.length!==2)return;const n=k(t[0]),r=k(t[1]);n.length===0||r.length===0||e.pairs.some(s=>s[0]===n&&s[1]===r)||e.pairs.push([n,r])}function le(e){const t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;const n={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(const r of e.allowed_transitions)C(n,r);return{typeKey:t.toLowerCase(),record:n}}function ue(e){if(!Array.isArray(e)||e.length===0)return;const t=new Map;for(const r of e){const s=le(r);if(s===null)continue;const o=t.get(s.typeKey)??s.record;o.denyAll||=s.record.denyAll;for(const u of s.record.pairs)C(o,u);t.set(s.typeKey,o)}const n=[];for(const r of t.values())(r.pairs.length>0||r.denyAll)&&n.push({type:r.type,allowed_transitions:r.pairs});return n.sort((r,s)=>r.type.localeCompare(s.type)),n.length>0?n:void 0}function P(e){const t=k(e.key??"");if(!t)return null;const n=k(e.metadata_key??e.front_matter_key??t),r=M(e.cli_flag??j(t));if(!r)return null;const s=T(e.cli_aliases).map(l=>M(l)).filter(l=>l.length>0&&l!==r),o=typeof e.type=="string"?e.type.trim().toLowerCase():"string",u=Q.has(o)?o:"string",a=(()=>{const l=T(e.commands).filter(p=>ee.has(p));return l.length>0?l:[...Z]})(),i=e.description?.trim(),d=T(e.required_types),c=e.value_schema===void 0?void 0:I(e.value_schema);return e.value_schema!==void 0&&c===void 0?null:{key:t,metadata_key:n,cli_flag:r,cli_aliases:s,description:i&&i.length>0?i:void 0,type:u,commands:a,repeatable:[e.repeatable===!0,u==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:d,allow_unset:e.allow_unset!==!1,value_schema:c}}function de(e){const t=new Map;for(const[r,s]of e.entries()){const o=L(s,r);o&&t.set(o.id,o)}const n=q([...t.values()]);return n.length>0?n:q(D.map((r,s)=>L(r,s)).filter(r=>r!==null))}function q(e){return e.sort((t,n)=>t.order===n.order?t.id.localeCompare(n.id):t.order-n.order)}function ce(e){const t=new Map;for(const n of e??[]){const r=P(n);r&&t.set(r.key,r)}return[...t.values()].sort((n,r)=>n.key.localeCompare(r.key))}function fe(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function _e(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==j(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function me(e){const t=typeof e=="string"?e.trim().toLowerCase():"allow";return te.has(t)?t:"allow"}function F(e){const t={...m,...e?.files},n=e?.statuses&&e.statuses.length>0?e.statuses:D,r=de(n),s=ce(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:r.map(fe),fields:s.map(_e),workflow:{...O,...ae(e?.workflow)},type_workflows:ue(e?.type_workflows),unknown_field_policy:me(e?.unknown_field_policy)}}function pe(e,t,n){try{return JSON.parse(e)}catch{n.push(t);return}}function ye(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){const n=t.item_types;if(Array.isArray(n.definitions))return n.definitions}}function we(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function Se(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function he(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;return typeof t.workflow=="object"&&t.workflow!==null&&!Array.isArray(t.workflow)?t.workflow:typeof t.workflows=="object"&&t.workflows!==null&&!Array.isArray(t.workflows)?t.workflows:t}function Ae(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(Array.isArray(t.type_workflows))return t.type_workflows}function y(e,t,n){const r=t?.trim()||n;return U.isAbsolute(r)?r:U.join(e,r)}function Le(e,t){return y(e,t.files.types,m.types)}async function Ne(e,t){const n=F(t),r=[{path:y(e,n.files.types,m.types),seed:{definitions:[]}},{path:y(e,n.files.statuses,m.statuses),seed:{statuses:D}},{path:y(e,n.files.fields,m.fields),seed:{fields:[]}},{path:y(e,n.files.workflows,m.workflows),seed:{workflow:O}}],s=[];for(const o of r)await W(o.path)||await K(o.path,`${JSON.stringify(o.seed,null,2)}
|
|
2
|
-
`)&&s.push(o.path);return{created_paths:s}}async function
|
|
1
|
+
import P from"node:path";import{pathExists as J,readOptionalRegularFile as X}from"../fs/fs-utils.js";import{createFileAtomic as Z}from"../fs/atomic-create.js";import{DEFAULT_STATUS_DEFINITIONS as G,DEFAULT_WORKFLOW_DEFINITION as Q,ITEM_METADATA_KEY_ORDER as ee}from"../shared/constants.js";import{RUNTIME_FIELD_COMMAND_VALUES as te,RUNTIME_FIELD_TYPE_VALUES as ne,RUNTIME_STATUS_ROLE_VALUES as re,RUNTIME_UNKNOWN_FIELD_POLICY_VALUES as se,STATUS_VALUES as ie}from"../../types/index.js";import{BUILTIN_FIELD_KEYS as oe}from"./fields-file.js";import{normalizeStatusToken as _}from"./status-token.js";import{inspectItemTypeDefinition as ae}from"../item/item-type-inspection.js";const m=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),x=Q,N=G,le=["create","update"],K=new Set(re),ue=new Set(ne),$=new Set(te),de=new Set(se),ce=new Set(["string","number","boolean","array","object"]),fe=16;function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const pe=[e=>e.type===void 0||typeof e.type=="string"&&ce.has(e.type),e=>!Object.hasOwn(e,"const")||M(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>M(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||D(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function M(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);const n=Array.isArray(e)?e.every(r=>M(r,t)):Object.values(e).every(r=>M(r,t));return t.delete(e),n}function R(e,t=0,n=new Set){if(!D(e)||t>fe||n.has(e))return;n.add(e);const r=e,s=r.type,o=r.enum,l=r.one_of,a=r.properties,i=r.items,d=r.required,u=r.min_length,c=r.min_items,w=r.format,h=r.additional_properties;if(!pe.every(p=>p(r))){n.delete(e);return}const g=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([p,z])=>[p,R(z,t+1,n)])),A=i===void 0?void 0:R(i,t+1,n),k=l===void 0?void 0:l.map(p=>R(p,t+1,n));if([...Object.values(g??{}),...i===void 0?[]:[A],...k??[]].some(p=>p===void 0)){n.delete(e);return}return n.delete(e),Object.fromEntries(Object.entries({type:s,const:Object.hasOwn(r,"const")?r.const:void 0,enum:o,min_length:u,min_items:c,format:w,properties:g,required:d===void 0?void 0:[...new Set(d)],additional_properties:h,items:A,one_of:k}).filter(([,p])=>p!==void 0))}function b(e){const t=Array.isArray(e)?e:[];return[...new Set(t.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function f(e){if(typeof e!="string"||e.length===0)return;const t=_(e);return t.length>0?t:void 0}function _e(e){return e.replace(/^(?:--)+/u,"")}function U(e){return typeof e=="string"?_e(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function q(e){return e.replaceAll("_","-")}function me(e){const t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(s=>s.length>0).map(s=>s.toLowerCase());if(t.length===0)return e;const[n,...r]=t;return`${n}${r.map(s=>`${s.slice(0,1).toUpperCase()}${s.slice(1)}`).join("")}`}function ye(e,t){if(!O(e))return{resolved:null,loss:{dropped:"not_an_object",ignored:[]}};const n=e,r=f(n.id);if(!r)return{resolved:null,loss:{dropped:"id_empty",ignored:[]}};const s=[...new Set(b(n.aliases).map(_).filter(u=>u.length>0))].sort((u,c)=>u.localeCompare(c)),o=b(n.roles).filter(u=>K.has(u)),l=typeof n.description=="string"?n.description.trim():void 0,a=typeof n.order=="number"&&Number.isFinite(n.order),i={id:r,aliases:s,roles:o,description:l&&l.length>0?l:void 0,order:a?n.order:t},d=[...F("aliases",n.aliases,u=>_(u).length>0,"a status name"),...F("roles",n.roles,u=>K.has(u),"a status role"),...n.description===void 0||typeof n.description=="string"?[]:["description: is not a string"],...n.order===void 0||a?[]:[`order: ${E(n.order)} is not a number, so the status keeps its position`]];return{resolved:i,loss:{ignored:d}}}function j(e,t){return ye(e,t).resolved}function he(e){return{draft_status:f(e?.draft_status),open_status:f(e?.open_status),in_progress_status:f(e?.in_progress_status),blocked_status:f(e?.blocked_status),close_status:f(e?.close_status),canceled_status:f(e?.canceled_status)}}function W(e,t){if(!Array.isArray(t)||t.length!==2)return;const n=_(t[0]),r=_(t[1]);n.length===0||r.length===0||e.pairs.some(s=>s[0]===n&&s[1]===r)||e.pairs.push([n,r])}function Se(e){const t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;const n={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(const r of e.allowed_transitions)W(n,r);return{typeKey:t.toLowerCase(),record:n}}function we(e){if(!Array.isArray(e)||e.length===0)return;const t=new Map;for(const r of e){const s=Se(r);if(s===null)continue;const o=t.get(s.typeKey)??s.record;o.denyAll||=s.record.denyAll;for(const l of s.record.pairs)W(o,l);t.set(s.typeKey,o)}const n=[];for(const r of t.values())(r.pairs.length>0||r.denyAll)&&n.push({type:r.type,allowed_transitions:r.pairs});return n.sort((r,s)=>r.type.localeCompare(s.type)),n.length>0?n:void 0}function E(e){try{return JSON.stringify(e)??String(e)}catch{try{return String(e)}catch{return"a value that cannot be shown"}}}function F(e,t,n,r){return t===void 0?[]:Array.isArray(t)?t.filter(s=>typeof s!="string"||!n(s.trim())).map(s=>`${e}: ${E(s)} is not ${r}`):[`${e}: is not a list`]}const ge=["repeatable","required","required_on_create","allow_unset"];function Ae(e,t){return ge.flatMap(n=>{const r=e[n];return r===void 0||typeof r=="boolean"?[]:[`${n}: ${E(r)} is not a boolean, so it reads as ${String(t[n])}`]})}const ke=new Set(["type","const","enum","min_length","min_items","format","properties","required","additional_properties","items","one_of"]);function L(e,t){if(!D(e))return[];const n=e;return[...Object.keys(n).filter(r=>!ke.has(r)).map(r=>`${t}.${r}: is not a value schema keyword, so it is not enforced`),...D(n.properties)?Object.entries(n.properties).flatMap(([r,s])=>L(s,`${t}.properties.${r}`)):[],...L(n.items,`${t}.items`),...Array.isArray(n.one_of)?n.one_of.flatMap((r,s)=>L(r,`${t}.one_of[${s}]`)):[]]}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function V(e,t,n){if(e===void 0)return;const r=e.filter(s=>!t(s)).length;return r===0?e:(n.warnings.push(`${n.warningKey}:${r}`),n.keepPositions?e.map(s=>t(s)?s:{}):e.filter(s=>t(s)))}function be(e,t){if(e===void 0)return;const n=e.flatMap(r=>ae(r,"schema_file").definition??[]);return n.length<e.length&&t.push(`runtime_schema_types_entry_invalid:${e.length-n.length}`),n}function Ee(e){const t=typeof e.type=="string"?e.type.trim().toLowerCase():"string";return ue.has(t)?t:"string"}function Fe(e){const t=b(e.commands).filter(n=>$.has(n));return t.length>0?t:[...le]}function v(e){return e.metadata_key!=null?{member:"metadata_key",value:e.metadata_key}:e.front_matter_key==null?void 0:{member:"front_matter_key",value:e.front_matter_key}}const Te=new Set([...oe,...ee]);function Ie(e,t){const n=v(e);return n!==void 0&&_(n.value).length===0&&Te.has(t)}function De(e,t){const n=_(v(e)?.value);return n.length>0?n:t}function Me(e,t){const n=typeof e.type=="string"&&e.type.trim().toLowerCase()===t.type,r=v(e);return[...r===void 0||_(r.value).length>0?[]:[`${r.member}: ${E(r.value)} names no item key, so values are stored under the field key`],...F("cli_aliases",e.cli_aliases,s=>U(s).length>0,"a flag spelling"),...e.type===void 0||n?[]:[`type: ${E(e.type)} is not a field type, so the field reads as string`],...F("commands",e.commands,s=>$.has(s),"a field command"),...F("required_types",e.required_types,s=>s.length>0,"a type name"),...e.description===void 0||typeof e.description=="string"?[]:["description: is not a string"],...Ae(e,t),...L(e.value_schema,"value_schema")]}function Re(e){const t=i=>({resolved:null,loss:{dropped:i,ignored:[]}});if(!O(e))return t("not_an_object");const n=_(e.key??"");if(!n)return t("key_empty");if(Ie(e,n))return t("metadata_key_empty");const r=U(e.cli_flag??q(n));if(!r)return t("cli_flag_empty");const s=e.value_schema===void 0?void 0:R(e.value_schema);if(e.value_schema!==void 0&&s===void 0)return t("value_schema_invalid");const o=Ee(e),l=typeof e.description=="string"?e.description.trim():void 0,a={key:n,metadata_key:De(e,n),cli_flag:r,cli_aliases:b(e.cli_aliases).map(i=>U(i)).filter(i=>i.length>0&&i!==r),description:l&&l.length>0?l:void 0,type:o,commands:Fe(e),repeatable:[e.repeatable===!0,o==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:b(e.required_types),allow_unset:e.allow_unset!==!1,value_schema:s};return{resolved:a,loss:{ignored:Me(e,a)}}}function B(e){return Re(e).resolved}function Le(e){const t=new Map;for(const[r,s]of e.entries()){const o=j(s,r);o&&t.set(o.id,o)}const n=Y([...t.values()]);return n.length>0?n:Y(N.map((r,s)=>j(r,s)).filter(r=>r!==null))}function Y(e){return e.sort((t,n)=>t.order===n.order?t.id.localeCompare(n.id):t.order-n.order)}function Oe(e){const t=new Map;for(const n of e??[]){const r=B(n);r&&t.set(r.key,r)}return[...t.values()].sort((n,r)=>n.key.localeCompare(r.key))}function ze(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function Ne(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==q(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function Ue(e){const t=typeof e=="string"?e.trim().toLowerCase():"allow";return de.has(t)?t:"allow"}function T(e){const t={...m,...e?.files},n=e?.statuses&&e.statuses.length>0?e.statuses:N,r=Le(n),s=Oe(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:r.map(ze),fields:s.map(Ne),workflow:{...x,...he(e?.workflow)},type_workflows:we(e?.type_workflows),unknown_field_policy:Ue(e?.unknown_field_policy)}}function je(e,t,n){try{return JSON.parse(e)}catch{n.push(t);return}}function ve(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){const n=t.item_types;if(Array.isArray(n.definitions))return n.definitions}}function Ce(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function Pe(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function xe(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;return typeof t.workflow=="object"&&t.workflow!==null&&!Array.isArray(t.workflow)?t.workflow:typeof t.workflows=="object"&&t.workflows!==null&&!Array.isArray(t.workflows)?t.workflows:t}function Ke(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(Array.isArray(t.type_workflows))return t.type_workflows}function y(e,t,n){const r=t?.trim()||n;return P.isAbsolute(r)?r:P.join(e,r)}function Qe(e,t){return y(e,t.files.types,m.types)}async function et(e,t){const n=T(t),r=[{path:y(e,n.files.types,m.types),seed:{definitions:[]}},{path:y(e,n.files.statuses,m.statuses),seed:{statuses:N}},{path:y(e,n.files.fields,m.fields),seed:{fields:[]}},{path:y(e,n.files.workflows,m.workflows),seed:{workflow:x}}],s=[];for(const o of r)await J(o.path)||await Z(o.path,`${JSON.stringify(o.seed,null,2)}
|
|
2
|
+
`)&&s.push(o.path);return{created_paths:s}}async function tt(e,t){const n=T(t),r=[],s=y(e,n.files.types,m.types),o=y(e,n.files.statuses,m.statuses),l=y(e,n.files.fields,m.fields),a=y(e,n.files.workflows,m.workflows);let i,d,u,c,w;const h=async(z,H)=>{const C=await X(z);if(C!==null)return je(C,H,r)},g=await h(s,"runtime_schema_types_invalid_json");g!==void 0&&(i=be(ve(g),r),i===void 0&&r.push("runtime_schema_types_invalid_shape"));const A=await h(o,"runtime_schema_statuses_invalid_json");A!==void 0&&(d=V(Ce(A),O,{warningKey:"runtime_schema_statuses_entry_invalid",warnings:r,keepPositions:!0}),d===void 0&&r.push("runtime_schema_statuses_invalid_shape"));const k=await h(l,"runtime_schema_fields_invalid_json");k!==void 0&&(u=V(Pe(k),O,{warningKey:"runtime_schema_fields_entry_invalid",warnings:r,keepPositions:!1}),u===void 0&&r.push("runtime_schema_fields_invalid_shape"));const S=await h(a,"runtime_schema_workflows_invalid_json");return S!==void 0&&(c=xe(S),c===void 0&&r.push("runtime_schema_workflows_invalid_shape"),w=Ke(S)),{schema:T({...n,statuses:[...n.statuses,...d??[]],fields:[...n.fields,...u??[]],workflow:{...n.workflow,...c},type_workflows:[...n.type_workflows??[],...w??[]]}),type_definitions_from_file:i,warnings:r,created_paths:[]}}function I(e,t,n,r=!1){const o=n.map(a=>f(a)).filter(a=>typeof a=="string").find(a=>e.some(i=>i.id===a));if(r&&o!==void 0)return o;const l=e.find(a=>a.roles.includes(t));return l!==void 0?l.id:o??e[0]?.id}function $e(e){const t=new Map,n=new Map;for(const r of e){n.set(r.id,r),t.set(r.id,r.id),t.set(r.id.replaceAll("_","-"),r.id),t.set(r.id.replaceAll("_"," "),r.id);for(const s of r.aliases)t.set(s,r.id),t.set(s.replaceAll("_","-"),r.id),t.set(s.replaceAll("_"," "),r.id)}return{aliasToId:t,byId:n}}function qe(e){const t={activeStatuses:new Set,blockedStatuses:new Set,draftStatuses:new Set,terminalCanceledStatuses:new Set,terminalDoneStatuses:new Set,terminalStatuses:new Set};for(const n of e){const r=new Set(n.roles);(r.has("terminal")||r.has("terminal_done")||r.has("terminal_canceled"))&&t.terminalStatuses.add(n.id),r.has("terminal_done")&&t.terminalDoneStatuses.add(n.id),r.has("terminal_canceled")&&t.terminalCanceledStatuses.add(n.id),r.has("active")&&t.activeStatuses.add(n.id),r.has("blocked")&&t.blockedStatuses.add(n.id),r.has("draft")&&t.draftStatuses.add(n.id)}return t}function nt(e){const t=T(e),n=t.statuses.map((S,p)=>j(S,p)).filter(S=>S!==null),{aliasToId:r,byId:s}=$e(n),{activeStatuses:o,blockedStatuses:l,draftStatuses:a,terminalCanceledStatuses:i,terminalDoneStatuses:d,terminalStatuses:u}=qe(n),c=t.workflow,w=f(c.open_status)??I(n,"default_open",["open","in_progress",ie[0]]),h=f(c.in_progress_status)??I(n,"active",["in_progress","in-progress",w],!0),g=f(c.blocked_status)??I(n,"blocked",["blocked"]),A=f(c.close_status)??I(n,"default_close",["closed","done","complete"]),k=f(c.canceled_status)??I(n,"default_cancel",["canceled","cancelled"]);return{definitions:n,by_id:s,alias_to_id:r,terminal_statuses:u,terminal_done_statuses:d,terminal_canceled_statuses:i,active_statuses:o,blocked_statuses:l,draft_statuses:a,open_status:w,in_progress_status:h,blocked_status:g,close_status:A,canceled_status:k}}function We(e,t){const n=_(e);if(n)return t.alias_to_id.get(n)}function rt(e){const t=T(e),n=new Map,r=t.fields.map(i=>B(i)).filter(i=>i!==null);for(const i of r)n.set(i.key,i);const s=[...n.values()].sort((i,d)=>i.key.localeCompare(d.key)),o=new Map,l=new Map,a=new Map;for(const i of s){o.set(i.key,i),l.set(i.cli_flag,i);for(const d of i.cli_aliases)l.set(d,i);for(const d of i.commands){const u=a.get(d)??[];u.push(i),a.set(d,u)}}for(const[i,d]of a.entries())d.sort((u,c)=>u.key.localeCompare(c.key)),a.set(i,d);return{definitions:s,by_key:o,by_cli_token:l,command_to_fields:a}}function st(e){return me(e.key)}function it(e,t){const n=We(e,t);return n?t.terminal_statuses.has(n):!1}export{m as DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,N as DEFAULT_RUNTIME_STATUS_DEFINITIONS,x as DEFAULT_RUNTIME_WORKFLOW,et as ensureRuntimeSchemaFileScaffold,y as filePathForSchemaSection,Re as inspectRuntimeFieldDefinition,ye as inspectRuntimeStatusDefinition,tt as loadRuntimeSchemaFromOptionalFiles,U as normalizeCliToken,T as normalizeRuntimeSchemaSettings,We as normalizeStatusInputWithRegistry,Pe as readFieldsFromSchemaFile,Ce as readStatusesFromSchemaFile,ve as readTypeDefinitionsFromSchemaFile,Qe as resolveItemTypesFilePath,rt as resolveRuntimeFieldRegistry,nt as resolveRuntimeStatusRegistry,st as runtimeFieldOptionTarget,it as statusIsTerminal};
|
|
3
3
|
//# sourceMappingURL=runtime-schema.js.map
|
|
@@ -54,6 +54,13 @@ export declare function persistSelectedItemFormat(settings:PmSettings):void;decl
|
|
|
54
54
|
export declare function isSettingsReadFallback(settings:PmSettings):boolean;declare function hasExplicitItemFormat(raw:unknown):boolean;declare function normalizeStringList(values:string[]|undefined):string[];declare function normalizeLowerStringList(values:string[]|undefined):string[];declare function normalizeExtensionPolicyMode(value:ExtensionPolicyMode|undefined):ExtensionPolicyMode;declare function normalizeExtensionTrustMode(value:ExtensionTrustMode|undefined):ExtensionTrustMode;declare function normalizeExtensionSandboxProfile(value:ExtensionSandboxProfile|undefined):ExtensionSandboxProfile;declare function normalizeExtensionPolicyOverride(override:ExtensionPolicyOverrideSettings):ExtensionPolicyOverrideSettings|null;declare function normalizeExtensionPolicyOverrides(overrides:ExtensionPolicyOverrideSettings[]|undefined):ExtensionPolicyOverrideSettings[];
|
|
55
55
|
/** Preserve a configured `pm_max_version_exceeded_mode` (string mode or per-layer override object) through settings normalization. Unset/invalid values are omitted so existing settings.json files round-trip byte-identically and the loader applies its safe default ("block"). */
|
|
56
56
|
declare function normalizePmMaxVersionExceededModeSetting(value:PmMaxVersionExceededModeSetting|undefined):PmMaxVersionExceededModeSetting|undefined;declare function normalizeExtensionPolicySettings(policy:Partial<ExtensionGovernancePolicy>|undefined):ExtensionGovernancePolicy;declare function normalizeValidationMetadataRequiredFields(values:string[]|undefined):ValidateMetadataRequiredField[];declare function normalizeValidationPatternList(values:string[]|undefined):string[];declare function valueOrDefault<T>(value:T|undefined,fallback:T):T;declare function arrayOrEmpty<T>(value:unknown):T[];
|
|
57
|
+
/**
|
|
58
|
+
* Hydrate merged settings with the schema files, as the settings read does.
|
|
59
|
+
* It throws where the read falls back to defaults (`settings_read_merge_failed`),
|
|
60
|
+
* so a settings writer can tell whether the stored schema definitions are
|
|
61
|
+
* active before and after its proposal (pm-8dbagz).
|
|
62
|
+
*/
|
|
63
|
+
export declare function hydrateMergedSettings(pmRoot:string,mergedSettings:PmSettings):Promise<{settings:PmSettings;warnings:string[];}>;
|
|
57
64
|
/** Implements normalize item type definitions for the public runtime surface of this module. */
|
|
58
65
|
export declare function normalizeItemTypeDefinitions(definitions:ItemTypeDefinition[]|undefined):ItemTypeDefinition[];
|
|
59
66
|
/** Resolve validated inline settings using the shared defaults and preset rules, without filesystem reads or schema hydration. */
|