From 3b3842d3219f1eb0061091993972c0feb790ee59 Mon Sep 17 00:00:00 2001 From: William Thorsen Date: Tue, 26 May 2026 19:21:17 -0700 Subject: [PATCH] agents|fix: Tolerate unknown keys in `.agents/preferences.yaml` Tolerates unknown keys in `.agents/preferences.yaml` and the global `~/.agents/preferences.yaml`. This file is a multi-tool surface (analogous to `.editorconfig`), not a codeassembly-owned namespace; keys belonging to other tooling, or deprecated keys held for backward compatibility, no longer break skills that read session context (artifact saving, frontmatter resolution, `/design-and-plan`, `/refine-plan`, and orchestrated runs). The YAML's `$schema` reference is now the single authoring-time validation surface; editor LSPs continue to flag schema issues in context. Wrong types or out-of-enum values on the fields actually read still hard-fail at read time with a message naming the offending key. --- .../skills/_data/artifact-conventions.md | 8 + .../derive-session-context.mjs | 5552 +++-------------- .../__tests__/read-preferences.test.ts | 60 +- .../read-preferences.ts | 229 +- .../src/derive-session-context/types.ts | 9 +- 5 files changed, 1094 insertions(+), 4764 deletions(-) diff --git a/packages/agents/content/skills/_data/artifact-conventions.md b/packages/agents/content/skills/_data/artifact-conventions.md index 7dbc0290..8ce1500f 100644 --- a/packages/agents/content/skills/_data/artifact-conventions.md +++ b/packages/agents/content/skills/_data/artifact-conventions.md @@ -69,6 +69,14 @@ For contexts where neither the deriver nor a cached manifest is available (e.g., 4. If `base_dir` is relative, resolve from project root. If absolute, use as-is. 5. Read `project.slug` from `.agents/preferences.yaml`, falling back to `~/.agents/preferences.yaml`, then the bare directory name of the working directory. +### Reader tolerance and authoring-time validation + +The session-context deriver reads only the fields it consumes (`artifacts.base_dir`, `artifacts.paths`, `project.slug`, `project.ticket_ref_prefix`, `platform`, `repository.slug`, `repository.default_remote.{name,default_branch}`). Unknown top-level keys, unknown nested keys, and keys for other tooling that shares `.agents/preferences.yaml` are silently tolerated — this file is a multi-tool surface (analogous to `.editorconfig` or `package.json`), not a codeassembly-owned namespace. + +Schema validation against `schemas/preferences.json` is an authoring-time concern, surfaced by the `$schema` reference at the top of the YAML (for editor LSPs) and by `preferences-schema.test.ts` against the project-checked-in `.agents/preferences.yaml`. The reader does not validate against the schema at runtime; doing so would fail on legitimate keys owned by other tools. + +The reader does still hard-fail on malformed YAML, missing git state, and shape problems on fields it consumes (e.g., `artifacts.base_dir` set to a non-string, `platform` set to a value outside the `github | bitbucket` enum). Per-field errors name the offending key path so the user can locate the issue without reading the whole file. + ### Ticket-scoped paths ``` diff --git a/packages/agents/content/skills/derive-session-context/derive-session-context.mjs b/packages/agents/content/skills/derive-session-context/derive-session-context.mjs index d60448e2..0cd9ef98 100644 --- a/packages/agents/content/skills/derive-session-context/derive-session-context.mjs +++ b/packages/agents/content/skills/derive-session-context/derive-session-context.mjs @@ -32,213 +32,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge mod )); -// ../../node_modules/.pnpm/content-type@1.0.5/node_modules/content-type/index.js -var require_content_type = __commonJS({ - "../../node_modules/.pnpm/content-type@1.0.5/node_modules/content-type/index.js"(exports) { - "use strict"; - var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g; - var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/; - var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; - var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g; - var QUOTE_REGEXP = /([\\"])/g; - var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; - exports.format = format; - exports.parse = parse2; - function format(obj) { - if (!obj || typeof obj !== "object") { - throw new TypeError("argument obj is required"); - } - var parameters = obj.parameters; - var type = obj.type; - if (!type || !TYPE_REGEXP.test(type)) { - throw new TypeError("invalid type"); - } - var string = type; - if (parameters && typeof parameters === "object") { - var param; - var params = Object.keys(parameters).sort(); - for (var i = 0; i < params.length; i++) { - param = params[i]; - if (!TOKEN_REGEXP.test(param)) { - throw new TypeError("invalid parameter name"); - } - string += "; " + param + "=" + qstring(parameters[param]); - } - } - return string; - } - function parse2(string) { - if (!string) { - throw new TypeError("argument string is required"); - } - var header = typeof string === "object" ? getcontenttype(string) : string; - if (typeof header !== "string") { - throw new TypeError("argument string is required to be a string"); - } - var index = header.indexOf(";"); - var type = index !== -1 ? header.slice(0, index).trim() : header.trim(); - if (!TYPE_REGEXP.test(type)) { - throw new TypeError("invalid media type"); - } - var obj = new ContentType(type.toLowerCase()); - if (index !== -1) { - var key; - var match; - var value3; - PARAM_REGEXP.lastIndex = index; - while (match = PARAM_REGEXP.exec(header)) { - if (match.index !== index) { - throw new TypeError("invalid parameter format"); - } - index += match[0].length; - key = match[1].toLowerCase(); - value3 = match[2]; - if (value3.charCodeAt(0) === 34) { - value3 = value3.slice(1, -1); - if (value3.indexOf("\\") !== -1) { - value3 = value3.replace(QESC_REGEXP, "$1"); - } - } - obj.parameters[key] = value3; - } - if (index !== header.length) { - throw new TypeError("invalid parameter format"); - } - } - return obj; - } - function getcontenttype(obj) { - var header; - if (typeof obj.getHeader === "function") { - header = obj.getHeader("content-type"); - } else if (typeof obj.headers === "object") { - header = obj.headers && obj.headers["content-type"]; - } - if (typeof header !== "string") { - throw new TypeError("content-type header is missing from object"); - } - return header; - } - function qstring(val) { - var str = String(val); - if (TOKEN_REGEXP.test(str)) { - return str; - } - if (str.length > 0 && !TEXT_REGEXP.test(str)) { - throw new TypeError("invalid parameter value"); - } - return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"'; - } - function ContentType(type) { - this.parameters = /* @__PURE__ */ Object.create(null); - this.type = type; - } - } -}); - -// ../../node_modules/.pnpm/json-stringify-deterministic@1.0.13/node_modules/json-stringify-deterministic/lib/defaults.js -var require_defaults = __commonJS({ - "../../node_modules/.pnpm/json-stringify-deterministic@1.0.13/node_modules/json-stringify-deterministic/lib/defaults.js"(exports, module) { - module.exports = { - space: "", - cycles: false, - replacer: (k, v) => v, - stringify: JSON.stringify - }; - } -}); - -// ../../node_modules/.pnpm/json-stringify-deterministic@1.0.13/node_modules/json-stringify-deterministic/lib/util.js -var require_util = __commonJS({ - "../../node_modules/.pnpm/json-stringify-deterministic@1.0.13/node_modules/json-stringify-deterministic/lib/util.js"(exports, module) { - "use strict"; - module.exports = { - isArray: Array.isArray, - assign: Object.assign, - isObject: (v) => typeof v === "object", - isFunction: (v) => typeof v === "function", - isBoolean: (v) => typeof v === "boolean", - isRegex: (v) => v instanceof RegExp, - keys: Object.keys - }; - } -}); - -// ../../node_modules/.pnpm/json-stringify-deterministic@1.0.13/node_modules/json-stringify-deterministic/lib/index.js -var require_lib = __commonJS({ - "../../node_modules/.pnpm/json-stringify-deterministic@1.0.13/node_modules/json-stringify-deterministic/lib/index.js"(exports, module) { - "use strict"; - var DEFAULTS = require_defaults(); - var isFunction = require_util().isFunction; - var isBoolean = require_util().isBoolean; - var isObject = require_util().isObject; - var isArray = require_util().isArray; - var isRegex = require_util().isRegex; - var assign = require_util().assign; - var keys3 = require_util().keys; - function serialize(obj) { - if (obj === null || obj === void 0) return obj; - if (isRegex(obj)) return obj.toString(); - return obj.toJSON ? obj.toJSON() : obj; - } - function stringifyDeterministic(obj, opts) { - opts = opts || assign({}, DEFAULTS); - if (isFunction(opts)) opts = { compare: opts }; - const space = opts.space || DEFAULTS.space; - const cycles = isBoolean(opts.cycles) ? opts.cycles : DEFAULTS.cycles; - const replacer = opts.replacer || DEFAULTS.replacer; - const stringify = opts.stringify || DEFAULTS.stringify; - const compare = opts.compare && /* @__PURE__ */ (function(f) { - return function(node) { - return function(a, b) { - const aobj = { key: a, value: node[a] }; - const bobj = { key: b, value: node[b] }; - return f(aobj, bobj); - }; - }; - })(opts.compare); - if (!cycles) stringify(obj); - const seen = []; - return (function _deterministic(parent, key, node, level) { - const indent = space ? "\n" + new Array(level + 1).join(space) : ""; - const colonSeparator = space ? ": " : ":"; - node = serialize(node); - node = replacer.call(parent, key, node); - if (node === void 0) return; - if (!isObject(node) || node === null) return stringify(node); - if (isArray(node)) { - const out = []; - for (let i = 0; i < node.length; i++) { - const item = _deterministic(node, i, node[i], level + 1) || stringify(null); - out.push(indent + space + item); - } - return "[" + out.join(",") + indent + "]"; - } else { - if (cycles) { - if (seen.indexOf(node) !== -1) { - return stringify("[Circular]"); - } else { - seen.push(node); - } - } - const nodeKeys = keys3(node).sort(compare && compare(node)); - const out = []; - for (let i = 0; i < nodeKeys.length; i++) { - const key2 = nodeKeys[i]; - const value3 = _deterministic(node, key2, node[key2], level + 1); - if (!value3) continue; - const keyValue = stringify(key2) + colonSeparator + value3; - out.push(indent + space + keyValue); - } - seen.splice(seen.indexOf(node), 1); - return "{" + out.join(",") + indent + "}"; - } - })({ "": obj }, "", obj, 0); - } - module.exports = stringifyDeterministic; - } -}); - // ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js var require_identity = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js"(exports) { @@ -254,7 +47,7 @@ var require_identity = __commonJS({ var isDocument = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === DOC; var isMap = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === MAP; var isPair = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === PAIR; - var isScalar2 = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SCALAR; + var isScalar = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SCALAR; var isSeq = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SEQ; function isCollection(node) { if (node && typeof node === "object") @@ -276,7 +69,7 @@ var require_identity = __commonJS({ } return false; } - var hasAnchor = (node) => (isScalar2(node) || isCollection(node)) && !!node.anchor; + var hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor; exports.ALIAS = ALIAS; exports.DOC = DOC; exports.MAP = MAP; @@ -291,7 +84,7 @@ var require_identity = __commonJS({ exports.isMap = isMap; exports.isNode = isNode; exports.isPair = isPair; - exports.isScalar = isScalar2; + exports.isScalar = isScalar; exports.isSeq = isSeq; } }); @@ -316,17 +109,17 @@ var require_visit = __commonJS({ visit.BREAK = BREAK; visit.SKIP = SKIP; visit.REMOVE = REMOVE; - function visit_(key, node, visitor, path6) { - const ctrl = callVisitor(key, node, visitor, path6); + function visit_(key, node, visitor, path4) { + const ctrl = callVisitor(key, node, visitor, path4); if (identity.isNode(ctrl) || identity.isPair(ctrl)) { - replaceNode(key, path6, ctrl); - return visit_(key, ctrl, visitor, path6); + replaceNode(key, path4, ctrl); + return visit_(key, ctrl, visitor, path4); } if (typeof ctrl !== "symbol") { if (identity.isCollection(node)) { - path6 = Object.freeze(path6.concat(node)); + path4 = Object.freeze(path4.concat(node)); for (let i = 0; i < node.items.length; ++i) { - const ci = visit_(i, node.items[i], visitor, path6); + const ci = visit_(i, node.items[i], visitor, path4); if (typeof ci === "number") i = ci - 1; else if (ci === BREAK) @@ -337,13 +130,13 @@ var require_visit = __commonJS({ } } } else if (identity.isPair(node)) { - path6 = Object.freeze(path6.concat(node)); - const ck = visit_("key", node.key, visitor, path6); + path4 = Object.freeze(path4.concat(node)); + const ck = visit_("key", node.key, visitor, path4); if (ck === BREAK) return BREAK; else if (ck === REMOVE) node.key = null; - const cv = visit_("value", node.value, visitor, path6); + const cv = visit_("value", node.value, visitor, path4); if (cv === BREAK) return BREAK; else if (cv === REMOVE) @@ -364,17 +157,17 @@ var require_visit = __commonJS({ visitAsync.BREAK = BREAK; visitAsync.SKIP = SKIP; visitAsync.REMOVE = REMOVE; - async function visitAsync_(key, node, visitor, path6) { - const ctrl = await callVisitor(key, node, visitor, path6); + async function visitAsync_(key, node, visitor, path4) { + const ctrl = await callVisitor(key, node, visitor, path4); if (identity.isNode(ctrl) || identity.isPair(ctrl)) { - replaceNode(key, path6, ctrl); - return visitAsync_(key, ctrl, visitor, path6); + replaceNode(key, path4, ctrl); + return visitAsync_(key, ctrl, visitor, path4); } if (typeof ctrl !== "symbol") { if (identity.isCollection(node)) { - path6 = Object.freeze(path6.concat(node)); + path4 = Object.freeze(path4.concat(node)); for (let i = 0; i < node.items.length; ++i) { - const ci = await visitAsync_(i, node.items[i], visitor, path6); + const ci = await visitAsync_(i, node.items[i], visitor, path4); if (typeof ci === "number") i = ci - 1; else if (ci === BREAK) @@ -385,13 +178,13 @@ var require_visit = __commonJS({ } } } else if (identity.isPair(node)) { - path6 = Object.freeze(path6.concat(node)); - const ck = await visitAsync_("key", node.key, visitor, path6); + path4 = Object.freeze(path4.concat(node)); + const ck = await visitAsync_("key", node.key, visitor, path4); if (ck === BREAK) return BREAK; else if (ck === REMOVE) node.key = null; - const cv = await visitAsync_("value", node.value, visitor, path6); + const cv = await visitAsync_("value", node.value, visitor, path4); if (cv === BREAK) return BREAK; else if (cv === REMOVE) @@ -418,23 +211,23 @@ var require_visit = __commonJS({ } return visitor; } - function callVisitor(key, node, visitor, path6) { + function callVisitor(key, node, visitor, path4) { if (typeof visitor === "function") - return visitor(key, node, path6); + return visitor(key, node, path4); if (identity.isMap(node)) - return visitor.Map?.(key, node, path6); + return visitor.Map?.(key, node, path4); if (identity.isSeq(node)) - return visitor.Seq?.(key, node, path6); + return visitor.Seq?.(key, node, path4); if (identity.isPair(node)) - return visitor.Pair?.(key, node, path6); + return visitor.Pair?.(key, node, path4); if (identity.isScalar(node)) - return visitor.Scalar?.(key, node, path6); + return visitor.Scalar?.(key, node, path4); if (identity.isAlias(node)) - return visitor.Alias?.(key, node, path6); + return visitor.Alias?.(key, node, path4); return void 0; } - function replaceNode(key, path6, node) { - const parent = path6[path6.length - 1]; + function replaceNode(key, path4, node) { + const parent = path4[path4.length - 1]; if (identity.isCollection(parent)) { parent.items[key] = node; } else if (identity.isPair(parent)) { @@ -750,26 +543,26 @@ var require_toJS = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/toJS.js"(exports) { "use strict"; var identity = require_identity(); - function toJS(value3, arg, ctx) { - if (Array.isArray(value3)) - return value3.map((v, i) => toJS(v, String(i), ctx)); - if (value3 && typeof value3.toJSON === "function") { - if (!ctx || !identity.hasAnchor(value3)) - return value3.toJSON(arg, ctx); + function toJS(value, arg, ctx) { + if (Array.isArray(value)) + return value.map((v, i) => toJS(v, String(i), ctx)); + if (value && typeof value.toJSON === "function") { + if (!ctx || !identity.hasAnchor(value)) + return value.toJSON(arg, ctx); const data = { aliasCount: 0, count: 1, res: void 0 }; - ctx.anchors.set(value3, data); + ctx.anchors.set(value, data); ctx.onCreate = (res2) => { data.res = res2; delete ctx.onCreate; }; - const res = value3.toJSON(arg, ctx); + const res = value.toJSON(arg, ctx); if (ctx.onCreate) ctx.onCreate(res); return res; } - if (typeof value3 === "bigint" && !ctx?.keep) - return Number(value3); - return value3; + if (typeof value === "bigint" && !ctx?.keep) + return Number(value); + return value; } exports.toJS = toJS; } @@ -939,11 +732,11 @@ var require_Scalar = __commonJS({ var identity = require_identity(); var Node = require_Node(); var toJS = require_toJS(); - var isScalarValue = (value3) => !value3 || typeof value3 !== "function" && typeof value3 !== "object"; + var isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object"; var Scalar = class extends Node.NodeBase { - constructor(value3) { + constructor(value) { super(identity.SCALAR); - this.value = value3; + this.value = value; } toJSON(arg, ctx) { return ctx?.keep ? this.value : toJS.toJS(this.value, arg, ctx); @@ -970,7 +763,7 @@ var require_createNode = __commonJS({ var identity = require_identity(); var Scalar = require_Scalar(); var defaultTagPrefix = "tag:yaml.org,2002:"; - function findTagObject(value3, tagName, tags) { + function findTagObject(value, tagName, tags) { if (tagName) { const match = tags.filter((t) => t.tag === tagName); const tagObj = match.find((t) => !t.format) ?? match[0]; @@ -978,53 +771,53 @@ var require_createNode = __commonJS({ throw new Error(`Tag ${tagName} not found`); return tagObj; } - return tags.find((t) => t.identify?.(value3) && !t.format); + return tags.find((t) => t.identify?.(value) && !t.format); } - function createNode(value3, tagName, ctx) { - if (identity.isDocument(value3)) - value3 = value3.contents; - if (identity.isNode(value3)) - return value3; - if (identity.isPair(value3)) { - const map2 = ctx.schema[identity.MAP].createNode?.(ctx.schema, null, ctx); - map2.items.push(value3); - return map2; + function createNode(value, tagName, ctx) { + if (identity.isDocument(value)) + value = value.contents; + if (identity.isNode(value)) + return value; + if (identity.isPair(value)) { + const map = ctx.schema[identity.MAP].createNode?.(ctx.schema, null, ctx); + map.items.push(value); + return map; } - if (value3 instanceof String || value3 instanceof Number || value3 instanceof Boolean || typeof BigInt !== "undefined" && value3 instanceof BigInt) { - value3 = value3.valueOf(); + if (value instanceof String || value instanceof Number || value instanceof Boolean || typeof BigInt !== "undefined" && value instanceof BigInt) { + value = value.valueOf(); } const { aliasDuplicateObjects, onAnchor, onTagObj, schema, sourceObjects } = ctx; let ref = void 0; - if (aliasDuplicateObjects && value3 && typeof value3 === "object") { - ref = sourceObjects.get(value3); + if (aliasDuplicateObjects && value && typeof value === "object") { + ref = sourceObjects.get(value); if (ref) { - ref.anchor ?? (ref.anchor = onAnchor(value3)); + ref.anchor ?? (ref.anchor = onAnchor(value)); return new Alias.Alias(ref.anchor); } else { ref = { anchor: null, node: null }; - sourceObjects.set(value3, ref); + sourceObjects.set(value, ref); } } if (tagName?.startsWith("!!")) tagName = defaultTagPrefix + tagName.slice(2); - let tagObj = findTagObject(value3, tagName, schema.tags); + let tagObj = findTagObject(value, tagName, schema.tags); if (!tagObj) { - if (value3 && typeof value3.toJSON === "function") { - value3 = value3.toJSON(); + if (value && typeof value.toJSON === "function") { + value = value.toJSON(); } - if (!value3 || typeof value3 !== "object") { - const node2 = new Scalar.Scalar(value3); + if (!value || typeof value !== "object") { + const node2 = new Scalar.Scalar(value); if (ref) ref.node = node2; return node2; } - tagObj = value3 instanceof Map ? schema[identity.MAP] : Symbol.iterator in Object(value3) ? schema[identity.SEQ] : schema[identity.MAP]; + tagObj = value instanceof Map ? schema[identity.MAP] : Symbol.iterator in Object(value) ? schema[identity.SEQ] : schema[identity.MAP]; } if (onTagObj) { onTagObj(tagObj); delete ctx.onTagObj; } - const node = tagObj?.createNode ? tagObj.createNode(ctx.schema, value3, ctx) : typeof tagObj?.nodeClass?.from === "function" ? tagObj.nodeClass.from(ctx.schema, value3, ctx) : new Scalar.Scalar(value3); + const node = tagObj?.createNode ? tagObj.createNode(ctx.schema, value, ctx) : typeof tagObj?.nodeClass?.from === "function" ? tagObj.nodeClass.from(ctx.schema, value, ctx) : new Scalar.Scalar(value); if (tagName) node.tag = tagName; else if (!tagObj.default) @@ -1044,10 +837,10 @@ var require_Collection = __commonJS({ var createNode = require_createNode(); var identity = require_identity(); var Node = require_Node(); - function collectionFromPath(schema, path6, value3) { - let v = value3; - for (let i = path6.length - 1; i >= 0; --i) { - const k = path6[i]; + function collectionFromPath(schema, path4, value) { + let v = value; + for (let i = path4.length - 1; i >= 0; --i) { + const k = path4[i]; if (typeof k === "number" && Number.isInteger(k) && k >= 0) { const a = []; a[k] = v; @@ -1066,7 +859,7 @@ var require_Collection = __commonJS({ sourceObjects: /* @__PURE__ */ new Map() }); } - var isEmptyPath = (path6) => path6 == null || typeof path6 === "object" && !!path6[Symbol.iterator]().next().done; + var isEmptyPath = (path4) => path4 == null || typeof path4 === "object" && !!path4[Symbol.iterator]().next().done; var Collection = class extends Node.NodeBase { constructor(type, schema) { super(type); @@ -1096,16 +889,16 @@ var require_Collection = __commonJS({ * be a Pair instance or a `{ key, value }` object, which may not have a key * that already exists in the map. */ - addIn(path6, value3) { - if (isEmptyPath(path6)) - this.add(value3); + addIn(path4, value) { + if (isEmptyPath(path4)) + this.add(value); else { - const [key, ...rest] = path6; + const [key, ...rest] = path4; const node = this.get(key, true); if (identity.isCollection(node)) - node.addIn(rest, value3); + node.addIn(rest, value); else if (node === void 0 && this.schema) - this.set(key, collectionFromPath(this.schema, rest, value3)); + this.set(key, collectionFromPath(this.schema, rest, value)); else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } @@ -1114,8 +907,8 @@ var require_Collection = __commonJS({ * Removes a value from the collection. * @returns `true` if the item was found and removed. */ - deleteIn(path6) { - const [key, ...rest] = path6; + deleteIn(path4) { + const [key, ...rest] = path4; if (rest.length === 0) return this.delete(key); const node = this.get(key, true); @@ -1129,8 +922,8 @@ var require_Collection = __commonJS({ * scalar values from their surrounding node; to disable set `keepScalar` to * `true` (collections are always returned intact). */ - getIn(path6, keepScalar) { - const [key, ...rest] = path6; + getIn(path4, keepScalar) { + const [key, ...rest] = path4; const node = this.get(key, true); if (rest.length === 0) return !keepScalar && identity.isScalar(node) ? node.value : node; @@ -1148,8 +941,8 @@ var require_Collection = __commonJS({ /** * Checks if the collection includes a value with the key `key`. */ - hasIn(path6) { - const [key, ...rest] = path6; + hasIn(path4) { + const [key, ...rest] = path4; if (rest.length === 0) return this.has(key); const node = this.get(key, true); @@ -1159,16 +952,16 @@ var require_Collection = __commonJS({ * Sets a value in this collection. For `!!set`, `value` needs to be a * boolean to add/remove the item from the set. */ - setIn(path6, value3) { - const [key, ...rest] = path6; + setIn(path4, value) { + const [key, ...rest] = path4; if (rest.length === 0) { - this.set(key, value3); + this.set(key, value); } else { const node = this.get(key, true); if (identity.isCollection(node)) - node.setIn(rest, value3); + node.setIn(rest, value); else if (node === void 0 && this.schema) - this.set(key, collectionFromPath(this.schema, rest, value3)); + this.set(key, collectionFromPath(this.schema, rest, value)); else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } @@ -1363,13 +1156,13 @@ var require_stringifyString = __commonJS({ } return true; } - function doubleQuotedString(value3, ctx) { - const json = JSON.stringify(value3); + function doubleQuotedString(value, ctx) { + const json = JSON.stringify(value); if (ctx.options.doubleQuotedAsJSON) return json; const { implicitKey } = ctx; const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength; - const indent = ctx.indent || (containsDocumentMarker(value3) ? " " : ""); + const indent = ctx.indent || (containsDocumentMarker(value) ? " " : ""); let str = ""; let start = 0; for (let i = 0, ch = json[i]; ch; ch = json[++i]) { @@ -1443,22 +1236,22 @@ var require_stringifyString = __commonJS({ str = start ? str + json.slice(start) : json; return implicitKey ? str : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false)); } - function singleQuotedString(value3, ctx) { - if (ctx.options.singleQuote === false || ctx.implicitKey && value3.includes("\n") || /[ \t]\n|\n[ \t]/.test(value3)) - return doubleQuotedString(value3, ctx); - const indent = ctx.indent || (containsDocumentMarker(value3) ? " " : ""); - const res = "'" + value3.replace(/'/g, "''").replace(/\n+/g, `$& + function singleQuotedString(value, ctx) { + if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value)) + return doubleQuotedString(value, ctx); + const indent = ctx.indent || (containsDocumentMarker(value) ? " " : ""); + const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$& ${indent}`) + "'"; return ctx.implicitKey ? res : foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false)); } - function quotedString(value3, ctx) { + function quotedString(value, ctx) { const { singleQuote } = ctx.options; let qs; if (singleQuote === false) qs = doubleQuotedString; else { - const hasDouble = value3.includes('"'); - const hasSingle = value3.includes("'"); + const hasDouble = value.includes('"'); + const hasSingle = value.includes("'"); if (hasDouble && !hasSingle) qs = singleQuotedString; else if (hasSingle && !hasDouble) @@ -1466,7 +1259,7 @@ ${indent}`) + "'"; else qs = singleQuote ? singleQuotedString : doubleQuotedString; } - return qs(value3, ctx); + return qs(value, ctx); } var blockEndNewlines; try { @@ -1474,27 +1267,27 @@ ${indent}`) + "'"; } catch { blockEndNewlines = /\n+(?!\n|$)/g; } - function blockString({ comment, type, value: value3 }, ctx, onComment, onChompKeep) { + function blockString({ comment, type, value }, ctx, onComment, onChompKeep) { const { blockQuote, commentString, lineWidth } = ctx.options; - if (!blockQuote || /\n[\t ]+$/.test(value3)) { - return quotedString(value3, ctx); + if (!blockQuote || /\n[\t ]+$/.test(value)) { + return quotedString(value, ctx); } - const indent = ctx.indent || (ctx.forceBlockIndent || containsDocumentMarker(value3) ? " " : ""); - const literal = blockQuote === "literal" ? true : blockQuote === "folded" || type === Scalar.Scalar.BLOCK_FOLDED ? false : type === Scalar.Scalar.BLOCK_LITERAL ? true : !lineLengthOverLimit(value3, lineWidth, indent.length); - if (!value3) + const indent = ctx.indent || (ctx.forceBlockIndent || containsDocumentMarker(value) ? " " : ""); + const literal = blockQuote === "literal" ? true : blockQuote === "folded" || type === Scalar.Scalar.BLOCK_FOLDED ? false : type === Scalar.Scalar.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, lineWidth, indent.length); + if (!value) return literal ? "|\n" : ">\n"; let chomp; let endStart; - for (endStart = value3.length; endStart > 0; --endStart) { - const ch = value3[endStart - 1]; + for (endStart = value.length; endStart > 0; --endStart) { + const ch = value[endStart - 1]; if (ch !== "\n" && ch !== " " && ch !== " ") break; } - let end = value3.substring(endStart); + let end = value.substring(endStart); const endNlPos = end.indexOf("\n"); if (endNlPos === -1) { chomp = "-"; - } else if (value3 === end || endNlPos !== end.length - 1) { + } else if (value === end || endNlPos !== end.length - 1) { chomp = "+"; if (onChompKeep) onChompKeep(); @@ -1502,7 +1295,7 @@ ${indent}`) + "'"; chomp = ""; } if (end) { - value3 = value3.slice(0, -end.length); + value = value.slice(0, -end.length); if (end[end.length - 1] === "\n") end = end.slice(0, -1); end = end.replace(blockEndNewlines, `$&${indent}`); @@ -1510,8 +1303,8 @@ ${indent}`) + "'"; let startWithSpace = false; let startEnd; let startNlPos = -1; - for (startEnd = 0; startEnd < value3.length; ++startEnd) { - const ch = value3[startEnd]; + for (startEnd = 0; startEnd < value.length; ++startEnd) { + const ch = value[startEnd]; if (ch === " ") startWithSpace = true; else if (ch === "\n") @@ -1519,9 +1312,9 @@ ${indent}`) + "'"; else break; } - let start = value3.substring(0, startNlPos < startEnd ? startNlPos + 1 : startEnd); + let start = value.substring(0, startNlPos < startEnd ? startNlPos + 1 : startEnd); if (start) { - value3 = value3.substring(start.length); + value = value.substring(start.length); start = start.replace(/\n+/g, `$&${indent}`); } const indentSize = indent ? "2" : "1"; @@ -1532,7 +1325,7 @@ ${indent}`) + "'"; onComment(); } if (!literal) { - const foldedValue = value3.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`); + const foldedValue = value.replace(/\n+/g, "\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${indent}`); let literalFallback = false; const foldOptions = getFoldOptions(ctx, true); if (blockQuote !== "folded" && type !== Scalar.Scalar.BLOCK_FOLDED) { @@ -1545,37 +1338,37 @@ ${indent}`) + "'"; return `>${header} ${indent}${body}`; } - value3 = value3.replace(/\n+/g, `$&${indent}`); + value = value.replace(/\n+/g, `$&${indent}`); return `|${header} -${indent}${start}${value3}${end}`; +${indent}${start}${value}${end}`; } function plainString(item, ctx, onComment, onChompKeep) { - const { type, value: value3 } = item; + const { type, value } = item; const { actualString, implicitKey, indent, indentStep, inFlow } = ctx; - if (implicitKey && value3.includes("\n") || inFlow && /[[\]{},]/.test(value3)) { - return quotedString(value3, ctx); + if (implicitKey && value.includes("\n") || inFlow && /[[\]{},]/.test(value)) { + return quotedString(value, ctx); } - if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value3)) { - return implicitKey || inFlow || !value3.includes("\n") ? quotedString(value3, ctx) : blockString(item, ctx, onComment, onChompKeep); + if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) { + return implicitKey || inFlow || !value.includes("\n") ? quotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep); } - if (!implicitKey && !inFlow && type !== Scalar.Scalar.PLAIN && value3.includes("\n")) { + if (!implicitKey && !inFlow && type !== Scalar.Scalar.PLAIN && value.includes("\n")) { return blockString(item, ctx, onComment, onChompKeep); } - if (containsDocumentMarker(value3)) { + if (containsDocumentMarker(value)) { if (indent === "") { ctx.forceBlockIndent = true; return blockString(item, ctx, onComment, onChompKeep); } else if (implicitKey && indent === indentStep) { - return quotedString(value3, ctx); + return quotedString(value, ctx); } } - const str = value3.replace(/\n+/g, `$& + const str = value.replace(/\n+/g, `$& ${indent}`); if (actualString) { const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str); const { compat, tags } = ctx.doc.schema; if (tags.some(test) || compat?.some(test)) - return quotedString(value3, ctx); + return quotedString(value, ctx); } return implicitKey ? str : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false)); } @@ -1748,7 +1541,7 @@ var require_stringifyPair = __commonJS({ var Scalar = require_Scalar(); var stringify = require_stringify(); var stringifyComment = require_stringifyComment(); - function stringifyPair({ key, value: value3 }, ctx, onComment, onChompKeep) { + function stringifyPair({ key, value }, ctx, onComment, onChompKeep) { const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx; let keyComment = identity.isNode(key) && key.comment || null; if (simpleKeys) { @@ -1760,7 +1553,7 @@ var require_stringifyPair = __commonJS({ throw new Error(msg); } } - let explicitKey = !simpleKeys && (!key || keyComment && value3 == null && !ctx.inFlow || identity.isCollection(key) || (identity.isScalar(key) ? key.type === Scalar.Scalar.BLOCK_FOLDED || key.type === Scalar.Scalar.BLOCK_LITERAL : typeof key === "object")); + let explicitKey = !simpleKeys && (!key || keyComment && value == null && !ctx.inFlow || identity.isCollection(key) || (identity.isScalar(key) ? key.type === Scalar.Scalar.BLOCK_FOLDED || key.type === Scalar.Scalar.BLOCK_LITERAL : typeof key === "object")); ctx = Object.assign({}, ctx, { allNullValues: false, implicitKey: !explicitKey && (simpleKeys || !allNullValues), @@ -1775,12 +1568,12 @@ var require_stringifyPair = __commonJS({ explicitKey = true; } if (ctx.inFlow) { - if (allNullValues || value3 == null) { + if (allNullValues || value == null) { if (keyCommentDone && onComment) onComment(); return str === "" ? "?" : explicitKey ? `? ${str}` : str; } - } else if (allNullValues && !simpleKeys || value3 == null && explicitKey) { + } else if (allNullValues && !simpleKeys || value == null && explicitKey) { str = `? ${str}`; if (keyComment && !keyCommentDone) { str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment)); @@ -1801,26 +1594,26 @@ ${indent}:`; str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment)); } let vsb, vcb, valueComment; - if (identity.isNode(value3)) { - vsb = !!value3.spaceBefore; - vcb = value3.commentBefore; - valueComment = value3.comment; + if (identity.isNode(value)) { + vsb = !!value.spaceBefore; + vcb = value.commentBefore; + valueComment = value.comment; } else { vsb = false; vcb = null; valueComment = null; - if (value3 && typeof value3 === "object") - value3 = doc.createNode(value3); + if (value && typeof value === "object") + value = doc.createNode(value); } ctx.implicitKey = false; - if (!explicitKey && !keyComment && identity.isScalar(value3)) + if (!explicitKey && !keyComment && identity.isScalar(value)) ctx.indentAtStart = str.length + 1; chompKeep = false; - if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity.isSeq(value3) && !value3.flow && !value3.tag && !value3.anchor) { + if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && identity.isSeq(value) && !value.flow && !value.tag && !value.anchor) { ctx.indent = ctx.indent.substring(2); } let valueCommentDone = false; - const valueStr = stringify.stringify(value3, ctx, () => valueCommentDone = true, () => chompKeep = true); + const valueStr = stringify.stringify(value, ctx, () => valueCommentDone = true, () => chompKeep = true); let ws = " "; if (keyComment || vsb || vcb) { ws = vsb ? "\n" : ""; @@ -1836,11 +1629,11 @@ ${stringifyComment.indentComment(cs, ctx.indent)}`; ws += ` ${ctx.indent}`; } - } else if (!explicitKey && identity.isCollection(value3)) { + } else if (!explicitKey && identity.isCollection(value)) { const vs0 = valueStr[0]; const nl0 = valueStr.indexOf("\n"); const hasNewline = nl0 !== -1; - const flow = ctx.inFlow ?? value3.flow ?? value3.items.length === 0; + const flow = ctx.inFlow ?? value.flow ?? value.items.length === 0; if (hasNewline || !flow) { let hasPropsLine = false; if (hasNewline && (vs0 === "&" || vs0 === "!")) { @@ -1903,7 +1696,7 @@ var require_merge = __commonJS({ var Scalar = require_Scalar(); var MERGE_KEY = "<<"; var merge = { - identify: (value3) => value3 === MERGE_KEY || typeof value3 === "symbol" && value3.description === MERGE_KEY, + identify: (value) => value === MERGE_KEY || typeof value === "symbol" && value.description === MERGE_KEY, default: "key", tag: "tag:yaml.org,2002:merge", test: /^<<$/, @@ -1913,41 +1706,41 @@ var require_merge = __commonJS({ stringify: () => MERGE_KEY }; var isMergeKey = (ctx, key) => (merge.identify(key) || identity.isScalar(key) && (!key.type || key.type === Scalar.Scalar.PLAIN) && merge.identify(key.value)) && ctx?.doc.schema.tags.some((tag) => tag.tag === merge.tag && tag.default); - function addMergeToJSMap(ctx, map2, value3) { - const source = resolveAliasValue(ctx, value3); + function addMergeToJSMap(ctx, map, value) { + const source = resolveAliasValue(ctx, value); if (identity.isSeq(source)) for (const it of source.items) - mergeValue(ctx, map2, it); + mergeValue(ctx, map, it); else if (Array.isArray(source)) for (const it of source) - mergeValue(ctx, map2, it); + mergeValue(ctx, map, it); else - mergeValue(ctx, map2, source); + mergeValue(ctx, map, source); } - function mergeValue(ctx, map2, value3) { - const source = resolveAliasValue(ctx, value3); + function mergeValue(ctx, map, value) { + const source = resolveAliasValue(ctx, value); if (!identity.isMap(source)) throw new Error("Merge sources must be maps or map aliases"); const srcMap = source.toJSON(null, ctx, Map); - for (const [key, value4] of srcMap) { - if (map2 instanceof Map) { - if (!map2.has(key)) - map2.set(key, value4); - } else if (map2 instanceof Set) { - map2.add(key); - } else if (!Object.prototype.hasOwnProperty.call(map2, key)) { - Object.defineProperty(map2, key, { - value: value4, + for (const [key, value2] of srcMap) { + if (map instanceof Map) { + if (!map.has(key)) + map.set(key, value2); + } else if (map instanceof Set) { + map.add(key); + } else if (!Object.prototype.hasOwnProperty.call(map, key)) { + Object.defineProperty(map, key, { + value: value2, writable: true, enumerable: true, configurable: true }); } } - return map2; + return map; } - function resolveAliasValue(ctx, value3) { - return ctx && identity.isAlias(value3) ? value3.resolve(ctx.doc, ctx) : value3; + function resolveAliasValue(ctx, value) { + return ctx && identity.isAlias(value) ? value.resolve(ctx.doc, ctx) : value; } exports.addMergeToJSMap = addMergeToJSMap; exports.isMergeKey = isMergeKey; @@ -1964,32 +1757,32 @@ var require_addPairToJSMap = __commonJS({ var stringify = require_stringify(); var identity = require_identity(); var toJS = require_toJS(); - function addPairToJSMap(ctx, map2, { key, value: value3 }) { + function addPairToJSMap(ctx, map, { key, value }) { if (identity.isNode(key) && key.addToJSMap) - key.addToJSMap(ctx, map2, value3); + key.addToJSMap(ctx, map, value); else if (merge.isMergeKey(ctx, key)) - merge.addMergeToJSMap(ctx, map2, value3); + merge.addMergeToJSMap(ctx, map, value); else { const jsKey = toJS.toJS(key, "", ctx); - if (map2 instanceof Map) { - map2.set(jsKey, toJS.toJS(value3, jsKey, ctx)); - } else if (map2 instanceof Set) { - map2.add(jsKey); + if (map instanceof Map) { + map.set(jsKey, toJS.toJS(value, jsKey, ctx)); + } else if (map instanceof Set) { + map.add(jsKey); } else { const stringKey = stringifyKey(key, jsKey, ctx); - const jsValue = toJS.toJS(value3, stringKey, ctx); - if (stringKey in map2) - Object.defineProperty(map2, stringKey, { + const jsValue = toJS.toJS(value, stringKey, ctx); + if (stringKey in map) + Object.defineProperty(map, stringKey, { value: jsValue, writable: true, enumerable: true, configurable: true }); else - map2[stringKey] = jsValue; + map[stringKey] = jsValue; } } - return map2; + return map; } function stringifyKey(key, jsKey, ctx) { if (jsKey === null) @@ -2027,24 +1820,24 @@ var require_Pair = __commonJS({ var stringifyPair = require_stringifyPair(); var addPairToJSMap = require_addPairToJSMap(); var identity = require_identity(); - function createPair(key, value3, ctx) { + function createPair(key, value, ctx) { const k = createNode.createNode(key, void 0, ctx); - const v = createNode.createNode(value3, void 0, ctx); + const v = createNode.createNode(value, void 0, ctx); return new Pair(k, v); } var Pair = class _Pair { - constructor(key, value3 = null) { + constructor(key, value = null) { Object.defineProperty(this, identity.NODE_TYPE, { value: identity.PAIR }); this.key = key; - this.value = value3; + this.value = value; } clone(schema) { - let { key, value: value3 } = this; + let { key, value } = this; if (identity.isNode(key)) key = key.clone(schema); - if (identity.isNode(value3)) - value3 = value3.clone(schema); - return new _Pair(key, value3); + if (identity.isNode(value)) + value = value.clone(schema); + return new _Pair(key, value); } toJSON(_, ctx) { const pair = ctx?.mapAsMap ? /* @__PURE__ */ new Map() : {}; @@ -2246,26 +2039,26 @@ var require_YAMLMap = __commonJS({ */ static from(schema, obj, ctx) { const { keepUndefined, replacer } = ctx; - const map2 = new this(schema); - const add = (key, value3) => { + const map = new this(schema); + const add = (key, value) => { if (typeof replacer === "function") - value3 = replacer.call(obj, key, value3); + value = replacer.call(obj, key, value); else if (Array.isArray(replacer) && !replacer.includes(key)) return; - if (value3 !== void 0 || keepUndefined) - map2.items.push(Pair.createPair(key, value3, ctx)); + if (value !== void 0 || keepUndefined) + map.items.push(Pair.createPair(key, value, ctx)); }; if (obj instanceof Map) { - for (const [key, value3] of obj) - add(key, value3); + for (const [key, value] of obj) + add(key, value); } else if (obj && typeof obj === "object") { for (const key of Object.keys(obj)) add(key, obj[key]); } if (typeof schema.sortMapEntries === "function") { - map2.items.sort(schema.sortMapEntries); + map.items.sort(schema.sortMapEntries); } - return map2; + return map; } /** * Adds a value to the collection. @@ -2315,8 +2108,8 @@ var require_YAMLMap = __commonJS({ has(key) { return !!findPair(this.items, key); } - set(key, value3) { - this.add(new Pair.Pair(key, value3), true); + set(key, value) { + this.add(new Pair.Pair(key, value), true); } /** * @param ctx - Conversion context, originally set in Document#toJS() @@ -2324,12 +2117,12 @@ var require_YAMLMap = __commonJS({ * @returns Instance of Type, Map, or Object */ toJSON(_, ctx, Type) { - const map2 = Type ? new Type() : ctx?.mapAsMap ? /* @__PURE__ */ new Map() : {}; + const map = Type ? new Type() : ctx?.mapAsMap ? /* @__PURE__ */ new Map() : {}; if (ctx?.onCreate) - ctx.onCreate(map2); + ctx.onCreate(map); for (const item of this.items) - addPairToJSMap.addPairToJSMap(ctx, map2, item); - return map2; + addPairToJSMap.addPairToJSMap(ctx, map, item); + return map; } toString(ctx, onComment, onChompKeep) { if (!ctx) @@ -2360,19 +2153,19 @@ var require_map = __commonJS({ "use strict"; var identity = require_identity(); var YAMLMap = require_YAMLMap(); - var map2 = { + var map = { collection: "map", default: true, nodeClass: YAMLMap.YAMLMap, tag: "tag:yaml.org,2002:map", - resolve(map3, onError) { - if (!identity.isMap(map3)) + resolve(map2, onError) { + if (!identity.isMap(map2)) onError("Expected a mapping for this tag"); - return map3; + return map2; }, createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx) }; - exports.map = map2; + exports.map = map; } }); @@ -2394,8 +2187,8 @@ var require_YAMLSeq = __commonJS({ super(identity.SEQ, schema); this.items = []; } - add(value3) { - this.items.push(value3); + add(value) { + this.items.push(value); } /** * Removes a value from the collection. @@ -2436,15 +2229,15 @@ var require_YAMLSeq = __commonJS({ * If `key` does not contain a representation of an integer, this will throw. * It may be wrapped in a `Scalar`. */ - set(key, value3) { + set(key, value) { const idx = asItemIndex(key); if (typeof idx !== "number") throw new Error(`Expected a valid index, not ${key}.`); const prev = this.items[idx]; - if (identity.isScalar(prev) && Scalar.isScalarValue(value3)) - prev.value = value3; + if (identity.isScalar(prev) && Scalar.isScalarValue(value)) + prev.value = value; else - this.items[idx] = value3; + this.items[idx] = value; } toJSON(_, ctx) { const seq = []; @@ -2520,7 +2313,7 @@ var require_string = __commonJS({ "use strict"; var stringifyString = require_stringifyString(); var string = { - identify: (value3) => typeof value3 === "string", + identify: (value) => typeof value === "string", default: true, tag: "tag:yaml.org,2002:str", resolve: (str) => str, @@ -2539,7 +2332,7 @@ var require_null = __commonJS({ "use strict"; var Scalar = require_Scalar(); var nullTag = { - identify: (value3) => value3 == null, + identify: (value) => value == null, createNode: () => new Scalar.Scalar(null), default: true, tag: "tag:yaml.org,2002:null", @@ -2557,18 +2350,18 @@ var require_bool = __commonJS({ "use strict"; var Scalar = require_Scalar(); var boolTag = { - identify: (value3) => typeof value3 === "boolean", + identify: (value) => typeof value === "boolean", default: true, tag: "tag:yaml.org,2002:bool", test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/, resolve: (str) => new Scalar.Scalar(str[0] === "t" || str[0] === "T"), - stringify({ source, value: value3 }, ctx) { + stringify({ source, value }, ctx) { if (source && boolTag.test.test(source)) { const sv = source[0] === "t" || source[0] === "T"; - if (value3 === sv) + if (value === sv) return source; } - return value3 ? ctx.options.trueStr : ctx.options.falseStr; + return value ? ctx.options.trueStr : ctx.options.falseStr; } }; exports.boolTag = boolTag; @@ -2579,13 +2372,13 @@ var require_bool = __commonJS({ var require_stringifyNumber = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/stringify/stringifyNumber.js"(exports) { "use strict"; - function stringifyNumber({ format, minFractionDigits, tag, value: value3 }) { - if (typeof value3 === "bigint") - return String(value3); - const num = typeof value3 === "number" ? value3 : Number(value3); + function stringifyNumber({ format, minFractionDigits, tag, value }) { + if (typeof value === "bigint") + return String(value); + const num = typeof value === "number" ? value : Number(value); if (!isFinite(num)) return isNaN(num) ? ".nan" : num < 0 ? "-.inf" : ".inf"; - let n = Object.is(value3, -0) ? "-0" : JSON.stringify(value3); + let n = Object.is(value, -0) ? "-0" : JSON.stringify(value); if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^-?\d/.test(n) && !n.includes("e")) { let i = n.indexOf("."); if (i < 0) { @@ -2609,7 +2402,7 @@ var require_float = __commonJS({ var Scalar = require_Scalar(); var stringifyNumber = require_stringifyNumber(); var floatNaN = { - identify: (value3) => typeof value3 === "number", + identify: (value) => typeof value === "number", default: true, tag: "tag:yaml.org,2002:float", test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/, @@ -2617,7 +2410,7 @@ var require_float = __commonJS({ stringify: stringifyNumber.stringifyNumber }; var floatExp = { - identify: (value3) => typeof value3 === "number", + identify: (value) => typeof value === "number", default: true, tag: "tag:yaml.org,2002:float", format: "EXP", @@ -2629,7 +2422,7 @@ var require_float = __commonJS({ } }; var float = { - identify: (value3) => typeof value3 === "number", + identify: (value) => typeof value === "number", default: true, tag: "tag:yaml.org,2002:float", test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/, @@ -2653,16 +2446,16 @@ var require_int = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/core/int.js"(exports) { "use strict"; var stringifyNumber = require_stringifyNumber(); - var intIdentify = (value3) => typeof value3 === "bigint" || Number.isInteger(value3); + var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value); var intResolve = (str, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str) : parseInt(str.substring(offset), radix); function intStringify(node, radix, prefix) { - const { value: value3 } = node; - if (intIdentify(value3) && value3 >= 0) - return prefix + value3.toString(radix); + const { value } = node; + if (intIdentify(value) && value >= 0) + return prefix + value.toString(radix); return stringifyNumber.stringifyNumber(node); } var intOct = { - identify: (value3) => intIdentify(value3) && value3 >= 0, + identify: (value) => intIdentify(value) && value >= 0, default: true, tag: "tag:yaml.org,2002:int", format: "OCT", @@ -2679,7 +2472,7 @@ var require_int = __commonJS({ stringify: stringifyNumber.stringifyNumber }; var intHex = { - identify: (value3) => intIdentify(value3) && value3 >= 0, + identify: (value) => intIdentify(value) && value >= 0, default: true, tag: "tag:yaml.org,2002:int", format: "HEX", @@ -2697,7 +2490,7 @@ var require_int = __commonJS({ var require_schema = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/core/schema.js"(exports) { "use strict"; - var map2 = require_map(); + var map = require_map(); var _null = require_null(); var seq = require_seq(); var string = require_string(); @@ -2705,7 +2498,7 @@ var require_schema = __commonJS({ var float = require_float(); var int = require_int(); var schema = [ - map2.map, + map.map, seq.seq, string.string, _null.nullTag, @@ -2726,22 +2519,22 @@ var require_schema2 = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/json/schema.js"(exports) { "use strict"; var Scalar = require_Scalar(); - var map2 = require_map(); + var map = require_map(); var seq = require_seq(); - function intIdentify(value3) { - return typeof value3 === "bigint" || Number.isInteger(value3); + function intIdentify(value) { + return typeof value === "bigint" || Number.isInteger(value); } - var stringifyJSON = ({ value: value3 }) => JSON.stringify(value3); + var stringifyJSON = ({ value }) => JSON.stringify(value); var jsonScalars = [ { - identify: (value3) => typeof value3 === "string", + identify: (value) => typeof value === "string", default: true, tag: "tag:yaml.org,2002:str", resolve: (str) => str, stringify: stringifyJSON }, { - identify: (value3) => value3 == null, + identify: (value) => value == null, createNode: () => new Scalar.Scalar(null), default: true, tag: "tag:yaml.org,2002:null", @@ -2750,7 +2543,7 @@ var require_schema2 = __commonJS({ stringify: stringifyJSON }, { - identify: (value3) => typeof value3 === "boolean", + identify: (value) => typeof value === "boolean", default: true, tag: "tag:yaml.org,2002:bool", test: /^true$|^false$/, @@ -2763,10 +2556,10 @@ var require_schema2 = __commonJS({ tag: "tag:yaml.org,2002:int", test: /^-?(?:0|[1-9][0-9]*)$/, resolve: (str, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str) : parseInt(str, 10), - stringify: ({ value: value3 }) => intIdentify(value3) ? value3.toString() : JSON.stringify(value3) + stringify: ({ value }) => intIdentify(value) ? value.toString() : JSON.stringify(value) }, { - identify: (value3) => typeof value3 === "number", + identify: (value) => typeof value === "number", default: true, tag: "tag:yaml.org,2002:float", test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/, @@ -2783,7 +2576,7 @@ var require_schema2 = __commonJS({ return str; } }; - var schema = [map2.map, seq.seq].concat(jsonScalars, jsonError); + var schema = [map.map, seq.seq].concat(jsonScalars, jsonError); exports.schema = schema; } }); @@ -2796,7 +2589,7 @@ var require_binary = __commonJS({ var Scalar = require_Scalar(); var stringifyString = require_stringifyString(); var binary = { - identify: (value3) => value3 instanceof Uint8Array, + identify: (value) => value instanceof Uint8Array, // Buffer inherits from Uint8Array default: false, tag: "tag:yaml.org,2002:binary", @@ -2822,10 +2615,10 @@ var require_binary = __commonJS({ return src; } }, - stringify({ comment, type, value: value3 }, ctx, onComment, onChompKeep) { - if (!value3) + stringify({ comment, type, value }, ctx, onComment, onChompKeep) { + if (!value) return ""; - const buf = value3; + const buf = value; let str; if (typeof node_buffer.Buffer === "function") { str = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64"); @@ -2897,25 +2690,25 @@ ${cn.comment}` : item.comment; for (let it of iterable) { if (typeof replacer === "function") it = replacer.call(iterable, String(i++), it); - let key, value3; + let key, value; if (Array.isArray(it)) { if (it.length === 2) { key = it[0]; - value3 = it[1]; + value = it[1]; } else throw new TypeError(`Expected [key, value] tuple: ${it}`); } else if (it && it instanceof Object) { - const keys3 = Object.keys(it); - if (keys3.length === 1) { - key = keys3[0]; - value3 = it[key]; + const keys = Object.keys(it); + if (keys.length === 1) { + key = keys[0]; + value = it[key]; } else { - throw new TypeError(`Expected tuple with one key, not ${keys3.length} keys`); + throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`); } } else { key = it; } - pairs2.items.push(Pair.createPair(key, value3, ctx)); + pairs2.items.push(Pair.createPair(key, value, ctx)); } return pairs2; } @@ -2958,22 +2751,22 @@ var require_omap = __commonJS({ toJSON(_, ctx) { if (!ctx) return super.toJSON(_); - const map2 = /* @__PURE__ */ new Map(); + const map = /* @__PURE__ */ new Map(); if (ctx?.onCreate) - ctx.onCreate(map2); + ctx.onCreate(map); for (const pair of this.items) { - let key, value3; + let key, value; if (identity.isPair(pair)) { key = toJS.toJS(pair.key, "", ctx); - value3 = toJS.toJS(pair.value, key, ctx); + value = toJS.toJS(pair.value, key, ctx); } else { key = toJS.toJS(pair, "", ctx); } - if (map2.has(key)) + if (map.has(key)) throw new Error("Ordered maps must not include duplicate keys"); - map2.set(key, value3); + map.set(key, value); } - return map2; + return map; } static from(schema, iterable, ctx) { const pairs$1 = pairs.createPairs(schema, iterable, ctx); @@ -2985,7 +2778,7 @@ var require_omap = __commonJS({ YAMLOMap.tag = "tag:yaml.org,2002:omap"; var omap = { collection: "seq", - identify: (value3) => value3 instanceof Map, + identify: (value) => value instanceof Map, nodeClass: YAMLOMap, default: false, tag: "tag:yaml.org,2002:omap", @@ -3015,14 +2808,14 @@ var require_bool2 = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/yaml-1.1/bool.js"(exports) { "use strict"; var Scalar = require_Scalar(); - function boolStringify({ value: value3, source }, ctx) { - const boolObj = value3 ? trueTag : falseTag; + function boolStringify({ value, source }, ctx) { + const boolObj = value ? trueTag : falseTag; if (source && boolObj.test.test(source)) return source; - return value3 ? ctx.options.trueStr : ctx.options.falseStr; + return value ? ctx.options.trueStr : ctx.options.falseStr; } var trueTag = { - identify: (value3) => value3 === true, + identify: (value) => value === true, default: true, tag: "tag:yaml.org,2002:bool", test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/, @@ -3030,7 +2823,7 @@ var require_bool2 = __commonJS({ stringify: boolStringify }; var falseTag = { - identify: (value3) => value3 === false, + identify: (value) => value === false, default: true, tag: "tag:yaml.org,2002:bool", test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/, @@ -3049,7 +2842,7 @@ var require_float2 = __commonJS({ var Scalar = require_Scalar(); var stringifyNumber = require_stringifyNumber(); var floatNaN = { - identify: (value3) => typeof value3 === "number", + identify: (value) => typeof value === "number", default: true, tag: "tag:yaml.org,2002:float", test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/, @@ -3057,7 +2850,7 @@ var require_float2 = __commonJS({ stringify: stringifyNumber.stringifyNumber }; var floatExp = { - identify: (value3) => typeof value3 === "number", + identify: (value) => typeof value === "number", default: true, tag: "tag:yaml.org,2002:float", format: "EXP", @@ -3069,7 +2862,7 @@ var require_float2 = __commonJS({ } }; var float = { - identify: (value3) => typeof value3 === "number", + identify: (value) => typeof value === "number", default: true, tag: "tag:yaml.org,2002:float", test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/, @@ -3096,7 +2889,7 @@ var require_int2 = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/yaml-1.1/int.js"(exports) { "use strict"; var stringifyNumber = require_stringifyNumber(); - var intIdentify = (value3) => typeof value3 === "bigint" || Number.isInteger(value3); + var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value); function intResolve(str, offset, radix, { intAsBigInt }) { const sign = str[0]; if (sign === "-" || sign === "+") @@ -3121,10 +2914,10 @@ var require_int2 = __commonJS({ return sign === "-" ? -1 * n : n; } function intStringify(node, radix, prefix) { - const { value: value3 } = node; - if (intIdentify(value3)) { - const str = value3.toString(radix); - return value3 < 0 ? "-" + prefix + str.substr(1) : prefix + str; + const { value } = node; + if (intIdentify(value)) { + const str = value.toString(radix); + return value < 0 ? "-" + prefix + str.substr(1) : prefix + str; } return stringifyNumber.stringifyNumber(node); } @@ -3202,13 +2995,13 @@ var require_set = __commonJS({ const pair = YAMLMap.findPair(this.items, key); return !keepPair && identity.isPair(pair) ? identity.isScalar(pair.key) ? pair.key.value : pair.key : pair; } - set(key, value3) { - if (typeof value3 !== "boolean") - throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value3}`); + set(key, value) { + if (typeof value !== "boolean") + throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`); const prev = YAMLMap.findPair(this.items, key); - if (prev && !value3) { + if (prev && !value) { this.items.splice(this.items.indexOf(prev), 1); - } else if (!prev && value3) { + } else if (!prev && value) { this.items.push(new Pair.Pair(key)); } } @@ -3227,10 +3020,10 @@ var require_set = __commonJS({ const { replacer } = ctx; const set2 = new this(schema); if (iterable && Symbol.iterator in Object(iterable)) - for (let value3 of iterable) { + for (let value of iterable) { if (typeof replacer === "function") - value3 = replacer.call(iterable, value3, value3); - set2.items.push(Pair.createPair(value3, null, ctx)); + value = replacer.call(iterable, value, value); + set2.items.push(Pair.createPair(value, null, ctx)); } return set2; } @@ -3238,20 +3031,20 @@ var require_set = __commonJS({ YAMLSet.tag = "tag:yaml.org,2002:set"; var set = { collection: "map", - identify: (value3) => value3 instanceof Set, + identify: (value) => value instanceof Set, nodeClass: YAMLSet, default: false, tag: "tag:yaml.org,2002:set", createNode: (schema, iterable, ctx) => YAMLSet.from(schema, iterable, ctx), - resolve(map2, onError) { - if (identity.isMap(map2)) { - if (map2.hasAllNullValues(true)) - return Object.assign(new YAMLSet(), map2); + resolve(map, onError) { + if (identity.isMap(map)) { + if (map.hasAllNullValues(true)) + return Object.assign(new YAMLSet(), map); else onError("Set items must all have null values"); } else onError("Expected a mapping for this tag"); - return map2; + return map; } }; exports.YAMLSet = YAMLSet; @@ -3272,33 +3065,33 @@ var require_timestamp = __commonJS({ return sign === "-" ? num(-1) * res : res; } function stringifySexagesimal(node) { - let { value: value3 } = node; + let { value } = node; let num = (n) => n; - if (typeof value3 === "bigint") + if (typeof value === "bigint") num = (n) => BigInt(n); - else if (isNaN(value3) || !isFinite(value3)) + else if (isNaN(value) || !isFinite(value)) return stringifyNumber.stringifyNumber(node); let sign = ""; - if (value3 < 0) { + if (value < 0) { sign = "-"; - value3 *= num(-1); + value *= num(-1); } const _60 = num(60); - const parts = [value3 % _60]; - if (value3 < 60) { + const parts = [value % _60]; + if (value < 60) { parts.unshift(0); } else { - value3 = (value3 - parts[0]) / _60; - parts.unshift(value3 % _60); - if (value3 >= 60) { - value3 = (value3 - parts[0]) / _60; - parts.unshift(value3); + value = (value - parts[0]) / _60; + parts.unshift(value % _60); + if (value >= 60) { + value = (value - parts[0]) / _60; + parts.unshift(value); } } return sign + parts.map((n) => String(n).padStart(2, "0")).join(":").replace(/000000\d*$/, ""); } var intTime = { - identify: (value3) => typeof value3 === "bigint" || Number.isInteger(value3), + identify: (value) => typeof value === "bigint" || Number.isInteger(value), default: true, tag: "tag:yaml.org,2002:int", format: "TIME", @@ -3307,7 +3100,7 @@ var require_timestamp = __commonJS({ stringify: stringifySexagesimal }; var floatTime = { - identify: (value3) => typeof value3 === "number", + identify: (value) => typeof value === "number", default: true, tag: "tag:yaml.org,2002:float", format: "TIME", @@ -3316,7 +3109,7 @@ var require_timestamp = __commonJS({ stringify: stringifySexagesimal }; var timestamp = { - identify: (value3) => value3 instanceof Date, + identify: (value) => value instanceof Date, default: true, tag: "tag:yaml.org,2002:timestamp", // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part @@ -3339,7 +3132,7 @@ var require_timestamp = __commonJS({ } return new Date(date); }, - stringify: ({ value: value3 }) => value3?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? "" + stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? "" }; exports.floatTime = floatTime; exports.intTime = intTime; @@ -3351,7 +3144,7 @@ var require_timestamp = __commonJS({ var require_schema3 = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/yaml-1.1/schema.js"(exports) { "use strict"; - var map2 = require_map(); + var map = require_map(); var _null = require_null(); var seq = require_seq(); var string = require_string(); @@ -3365,7 +3158,7 @@ var require_schema3 = __commonJS({ var set = require_set(); var timestamp = require_timestamp(); var schema = [ - map2.map, + map.map, seq.seq, string.string, _null.nullTag, @@ -3395,7 +3188,7 @@ var require_schema3 = __commonJS({ var require_tags = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/tags.js"(exports) { "use strict"; - var map2 = require_map(); + var map = require_map(); var _null = require_null(); var seq = require_seq(); var string = require_string(); @@ -3413,7 +3206,7 @@ var require_tags = __commonJS({ var timestamp = require_timestamp(); var schemas = /* @__PURE__ */ new Map([ ["core", schema.schema], - ["failsafe", [map2.map, seq.seq, string.string]], + ["failsafe", [map.map, seq.seq, string.string]], ["json", schema$1.schema], ["yaml11", schema$2.schema], ["yaml-1.1", schema$2.schema] @@ -3429,7 +3222,7 @@ var require_tags = __commonJS({ intHex: int.intHex, intOct: int.intOct, intTime: timestamp.intTime, - map: map2.map, + map: map.map, merge: merge.merge, null: _null.nullTag, omap: omap.omap, @@ -3456,8 +3249,8 @@ var require_tags = __commonJS({ if (Array.isArray(customTags)) tags = []; else { - const keys3 = Array.from(schemas.keys()).filter((key) => key !== "yaml11").map((key) => JSON.stringify(key)).join(", "); - throw new Error(`Unknown schema "${schemaName}"; use one of ${keys3} or define customTags array`); + const keys = Array.from(schemas.keys()).filter((key) => key !== "yaml11").map((key) => JSON.stringify(key)).join(", "); + throw new Error(`Unknown schema "${schemaName}"; use one of ${keys} or define customTags array`); } } if (Array.isArray(customTags)) { @@ -3472,8 +3265,8 @@ var require_tags = __commonJS({ const tagObj = typeof tag === "string" ? tagsByName[tag] : tag; if (!tagObj) { const tagName = JSON.stringify(tag); - const keys3 = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", "); - throw new Error(`Unknown custom tag ${tagName}; use one of ${keys3}`); + const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", "); + throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`); } if (!tags2.includes(tagObj)) tags2.push(tagObj); @@ -3490,7 +3283,7 @@ var require_Schema = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/schema/Schema.js"(exports) { "use strict"; var identity = require_identity(); - var map2 = require_map(); + var map = require_map(); var seq = require_seq(); var string = require_string(); var tags = require_tags(); @@ -3502,7 +3295,7 @@ var require_Schema = __commonJS({ this.knownTags = resolveKnownTags ? tags.coreKnownTags : {}; this.tags = tags.getTags(customTags, this.name, merge); this.toStringOptions = toStringDefaults ?? null; - Object.defineProperty(this, identity.MAP, { value: map2.map }); + Object.defineProperty(this, identity.MAP, { value: map.map }); Object.defineProperty(this, identity.SCALAR, { value: string.string }); Object.defineProperty(this, identity.SEQ, { value: seq.seq }); this.sortMapEntries = typeof sortMapEntries === "function" ? sortMapEntries : sortMapEntries === true ? sortMapEntriesByKey : null; @@ -3613,7 +3406,7 @@ var require_Document = __commonJS({ var createNode = require_createNode(); var directives = require_directives(); var Document = class _Document { - constructor(value3, replacer, options) { + constructor(value, replacer, options) { this.commentBefore = null; this.comment = null; this.errors = []; @@ -3645,7 +3438,7 @@ var require_Document = __commonJS({ } else this.directives = new directives.Directives({ version }); this.setSchema(version, options); - this.contents = value3 === void 0 ? null : this.createNode(value3, _replacer, options); + this.contents = value === void 0 ? null : this.createNode(value, _replacer, options); } /** * Create a deep copy of this Document and its contents. @@ -3670,14 +3463,14 @@ var require_Document = __commonJS({ return copy; } /** Adds a value to the document. */ - add(value3) { + add(value) { if (assertCollection(this.contents)) - this.contents.add(value3); + this.contents.add(value); } /** Adds a value to the document. */ - addIn(path6, value3) { + addIn(path4, value) { if (assertCollection(this.contents)) - this.contents.addIn(path6, value3); + this.contents.addIn(path4, value); } /** * Create a new `Alias` node, ensuring that the target `node` has the required anchor. @@ -3696,10 +3489,10 @@ var require_Document = __commonJS({ } return new Alias.Alias(node.anchor); } - createNode(value3, replacer, options) { + createNode(value, replacer, options) { let _replacer = void 0; if (typeof replacer === "function") { - value3 = replacer.call({ "": value3 }, "", value3); + value = replacer.call({ "": value }, "", value); _replacer = replacer; } else if (Array.isArray(replacer)) { const keyToStr = (v) => typeof v === "number" || v instanceof String || v instanceof Number; @@ -3726,7 +3519,7 @@ var require_Document = __commonJS({ schema: this.schema, sourceObjects }; - const node = createNode.createNode(value3, tag, ctx); + const node = createNode.createNode(value, tag, ctx); if (flow && identity.isCollection(node)) node.flow = true; setAnchors(); @@ -3736,9 +3529,9 @@ var require_Document = __commonJS({ * Convert a key and a value into a `Pair` using the current schema, * recursively wrapping all values as `Scalar` or `Collection` nodes. */ - createPair(key, value3, options = {}) { + createPair(key, value, options = {}) { const k = this.createNode(key, null, options); - const v = this.createNode(value3, null, options); + const v = this.createNode(value, null, options); return new Pair.Pair(k, v); } /** @@ -3752,14 +3545,14 @@ var require_Document = __commonJS({ * Removes a value from the document. * @returns `true` if the item was found and removed. */ - deleteIn(path6) { - if (Collection.isEmptyPath(path6)) { + deleteIn(path4) { + if (Collection.isEmptyPath(path4)) { if (this.contents == null) return false; this.contents = null; return true; } - return assertCollection(this.contents) ? this.contents.deleteIn(path6) : false; + return assertCollection(this.contents) ? this.contents.deleteIn(path4) : false; } /** * Returns item at `key`, or `undefined` if not found. By default unwraps @@ -3774,10 +3567,10 @@ var require_Document = __commonJS({ * scalar values from their surrounding node; to disable set `keepScalar` to * `true` (collections are always returned intact). */ - getIn(path6, keepScalar) { - if (Collection.isEmptyPath(path6)) + getIn(path4, keepScalar) { + if (Collection.isEmptyPath(path4)) return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents; - return identity.isCollection(this.contents) ? this.contents.getIn(path6, keepScalar) : void 0; + return identity.isCollection(this.contents) ? this.contents.getIn(path4, keepScalar) : void 0; } /** * Checks if the document includes a value with the key `key`. @@ -3788,33 +3581,33 @@ var require_Document = __commonJS({ /** * Checks if the document includes a value at `path`. */ - hasIn(path6) { - if (Collection.isEmptyPath(path6)) + hasIn(path4) { + if (Collection.isEmptyPath(path4)) return this.contents !== void 0; - return identity.isCollection(this.contents) ? this.contents.hasIn(path6) : false; + return identity.isCollection(this.contents) ? this.contents.hasIn(path4) : false; } /** * Sets a value in this document. For `!!set`, `value` needs to be a * boolean to add/remove the item from the set. */ - set(key, value3) { + set(key, value) { if (this.contents == null) { - this.contents = Collection.collectionFromPath(this.schema, [key], value3); + this.contents = Collection.collectionFromPath(this.schema, [key], value); } else if (assertCollection(this.contents)) { - this.contents.set(key, value3); + this.contents.set(key, value); } } /** * Sets a value in this document. For `!!set`, `value` needs to be a * boolean to add/remove the item from the set. */ - setIn(path6, value3) { - if (Collection.isEmptyPath(path6)) { - this.contents = value3; + setIn(path4, value) { + if (Collection.isEmptyPath(path4)) { + this.contents = value; } else if (this.contents == null) { - this.contents = Collection.collectionFromPath(this.schema, Array.from(path6), value3); + this.contents = Collection.collectionFromPath(this.schema, Array.from(path4), value); } else if (assertCollection(this.contents)) { - this.contents.setIn(path6, value3); + this.contents.setIn(path4, value); } } /** @@ -3990,29 +3783,29 @@ var require_resolve_props = __commonJS({ let comma = null; let found = null; let start = null; - for (const token2 of tokens) { + for (const token of tokens) { if (reqSpace) { - if (token2.type !== "space" && token2.type !== "newline" && token2.type !== "comma") - onError(token2.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"); + if (token.type !== "space" && token.type !== "newline" && token.type !== "comma") + onError(token.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"); reqSpace = false; } if (tab) { - if (atNewline && token2.type !== "comment" && token2.type !== "newline") { + if (atNewline && token.type !== "comment" && token.type !== "newline") { onError(tab, "TAB_AS_INDENT", "Tabs are not allowed as indentation"); } tab = null; } - switch (token2.type) { + switch (token.type) { case "space": - if (!flow && (indicator !== "doc-start" || next?.type !== "flow-collection") && token2.source.includes(" ")) { - tab = token2; + if (!flow && (indicator !== "doc-start" || next?.type !== "flow-collection") && token.source.includes(" ")) { + tab = token; } hasSpace = true; break; case "comment": { if (!hasSpace) - onError(token2, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"); - const cb = token2.source.substring(1) || " "; + onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"); + const cb = token.source.substring(1) || " "; if (!comment) comment = cb; else @@ -4024,33 +3817,33 @@ var require_resolve_props = __commonJS({ case "newline": if (atNewline) { if (comment) - comment += token2.source; + comment += token.source; else if (!found || indicator !== "seq-item-ind") spaceBefore = true; } else - commentSep += token2.source; + commentSep += token.source; atNewline = true; hasNewline = true; if (anchor || tag) - newlineAfterProp = token2; + newlineAfterProp = token; hasSpace = true; break; case "anchor": if (anchor) - onError(token2, "MULTIPLE_ANCHORS", "A node can have at most one anchor"); - if (token2.source.endsWith(":")) - onError(token2.offset + token2.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", true); - anchor = token2; - start ?? (start = token2.offset); + onError(token, "MULTIPLE_ANCHORS", "A node can have at most one anchor"); + if (token.source.endsWith(":")) + onError(token.offset + token.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", true); + anchor = token; + start ?? (start = token.offset); atNewline = false; hasSpace = false; reqSpace = true; break; case "tag": { if (tag) - onError(token2, "MULTIPLE_TAGS", "A node can have at most one tag"); - tag = token2; - start ?? (start = token2.offset); + onError(token, "MULTIPLE_TAGS", "A node can have at most one tag"); + tag = token; + start ?? (start = token.offset); atNewline = false; hasSpace = false; reqSpace = true; @@ -4058,25 +3851,25 @@ var require_resolve_props = __commonJS({ } case indicator: if (anchor || tag) - onError(token2, "BAD_PROP_ORDER", `Anchors and tags must be after the ${token2.source} indicator`); + onError(token, "BAD_PROP_ORDER", `Anchors and tags must be after the ${token.source} indicator`); if (found) - onError(token2, "UNEXPECTED_TOKEN", `Unexpected ${token2.source} in ${flow ?? "collection"}`); - found = token2; + onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.source} in ${flow ?? "collection"}`); + found = token; atNewline = indicator === "seq-item-ind" || indicator === "explicit-key-ind"; hasSpace = false; break; case "comma": if (flow) { if (comma) - onError(token2, "UNEXPECTED_TOKEN", `Unexpected , in ${flow}`); - comma = token2; + onError(token, "UNEXPECTED_TOKEN", `Unexpected , in ${flow}`); + comma = token; atNewline = false; hasSpace = false; break; } // else fallthrough default: - onError(token2, "UNEXPECTED_TOKEN", `Unexpected ${token2.type} token`); + onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.type} token`); atNewline = false; hasSpace = false; } @@ -4194,13 +3987,13 @@ var require_resolve_block_map = __commonJS({ var startColMsg = "All mapping items must start at the same column"; function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, tag) { const NodeClass = tag?.nodeClass ?? YAMLMap.YAMLMap; - const map2 = new NodeClass(ctx.schema); + const map = new NodeClass(ctx.schema); if (ctx.atRoot) ctx.atRoot = false; let offset = bm.offset; let commentEnd = null; for (const collItem of bm.items) { - const { start, key, sep, value: value3 } = collItem; + const { start, key, sep, value } = collItem; const keyProps = resolveProps.resolveProps(start, { indicator: "explicit-key-ind", next: key ?? sep?.[0], @@ -4220,10 +4013,10 @@ var require_resolve_block_map = __commonJS({ if (!keyProps.anchor && !keyProps.tag && !sep) { commentEnd = keyProps.end; if (keyProps.comment) { - if (map2.comment) - map2.comment += "\n" + keyProps.comment; + if (map.comment) + map.comment += "\n" + keyProps.comment; else - map2.comment = keyProps.comment; + map.comment = keyProps.comment; } continue; } @@ -4239,11 +4032,11 @@ var require_resolve_block_map = __commonJS({ if (ctx.schema.compat) utilFlowIndentCheck.flowIndentCheck(bm.indent, key, onError); ctx.atKey = false; - if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode)) + if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode)) onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique"); const valueProps = resolveProps.resolveProps(sep ?? [], { indicator: "map-value-ind", - next: value3, + next: value, offset: keyNode.range[2], onError, parentIndent: bm.indent, @@ -4252,19 +4045,19 @@ var require_resolve_block_map = __commonJS({ offset = valueProps.end; if (valueProps.found) { if (implicitKey) { - if (value3?.type === "block-map" && !valueProps.hasNewline) + if (value?.type === "block-map" && !valueProps.hasNewline) onError(offset, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings"); if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024) onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key"); } - const valueNode = value3 ? composeNode(ctx, value3, valueProps, onError) : composeEmptyNode(ctx, offset, sep, null, valueProps, onError); + const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep, null, valueProps, onError); if (ctx.schema.compat) - utilFlowIndentCheck.flowIndentCheck(bm.indent, value3, onError); + utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError); offset = valueNode.range[2]; const pair = new Pair.Pair(keyNode, valueNode); if (ctx.options.keepSourceTokens) pair.srcToken = collItem; - map2.items.push(pair); + map.items.push(pair); } else { if (implicitKey) onError(keyNode.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"); @@ -4277,13 +4070,13 @@ var require_resolve_block_map = __commonJS({ const pair = new Pair.Pair(keyNode); if (ctx.options.keepSourceTokens) pair.srcToken = collItem; - map2.items.push(pair); + map.items.push(pair); } } if (commentEnd && commentEnd < offset) onError(commentEnd, "IMPOSSIBLE", "Map comment with trailing content"); - map2.range = [bm.offset, offset, commentEnd ?? offset]; - return map2; + map.range = [bm.offset, offset, commentEnd ?? offset]; + return map; } exports.resolveBlockMap = resolveBlockMap; } @@ -4305,18 +4098,18 @@ var require_resolve_block_seq = __commonJS({ ctx.atKey = false; let offset = bs.offset; let commentEnd = null; - for (const { start, value: value3 } of bs.items) { + for (const { start, value } of bs.items) { const props = resolveProps.resolveProps(start, { indicator: "seq-item-ind", - next: value3, + next: value, offset, onError, parentIndent: bs.indent, startOnNewline: true }); if (!props.found) { - if (props.anchor || props.tag || value3) { - if (value3?.type === "block-seq") + if (props.anchor || props.tag || value) { + if (value?.type === "block-seq") onError(props.end, "BAD_INDENT", "All sequence items must start at the same column"); else onError(offset, "MISSING_CHAR", "Sequence item without - indicator"); @@ -4327,9 +4120,9 @@ var require_resolve_block_seq = __commonJS({ continue; } } - const node = value3 ? composeNode(ctx, value3, props, onError) : composeEmptyNode(ctx, props.end, start, null, props, onError); + const node = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, start, null, props, onError); if (ctx.schema.compat) - utilFlowIndentCheck.flowIndentCheck(bs.indent, value3, onError); + utilFlowIndentCheck.flowIndentCheck(bs.indent, value, onError); offset = node.range[2]; seq.items.push(node); } @@ -4349,15 +4142,15 @@ var require_resolve_end = __commonJS({ if (end) { let hasSpace = false; let sep = ""; - for (const token2 of end) { - const { source, type } = token2; + for (const token of end) { + const { source, type } = token; switch (type) { case "space": hasSpace = true; break; case "comment": { if (reqSpace && !hasSpace) - onError(token2, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"); + onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"); const cb = source.substring(1) || " "; if (!comment) comment = cb; @@ -4372,7 +4165,7 @@ var require_resolve_end = __commonJS({ hasSpace = true; break; default: - onError(token2, "UNEXPECTED_TOKEN", `Unexpected ${type} at node end`); + onError(token, "UNEXPECTED_TOKEN", `Unexpected ${type} at node end`); } offset += source.length; } @@ -4396,7 +4189,7 @@ var require_resolve_flow_collection = __commonJS({ var utilContainsNewline = require_util_contains_newline(); var utilMapIncludes = require_util_map_includes(); var blockMsg = "Block collections are not allowed within flow collections"; - var isBlock = (token2) => token2 && (token2.type === "block-map" || token2.type === "block-seq"); + var isBlock = (token) => token && (token.type === "block-map" || token.type === "block-seq"); function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError, tag) { const isMap = fc.start.source === "{"; const fcName = isMap ? "flow map" : "flow sequence"; @@ -4411,7 +4204,7 @@ var require_resolve_flow_collection = __commonJS({ let offset = fc.offset + fc.start.source.length; for (let i = 0; i < fc.items.length; ++i) { const collItem = fc.items[i]; - const { start, key, sep, value: value3 } = collItem; + const { start, key, sep, value } = collItem; const props = resolveProps.resolveProps(start, { flow: fcName, indicator: "explicit-key-ind", @@ -4422,7 +4215,7 @@ var require_resolve_flow_collection = __commonJS({ startOnNewline: false }); if (!props.found) { - if (!props.anchor && !props.tag && !sep && !value3) { + if (!props.anchor && !props.tag && !sep && !value) { if (i === 0 && props.comma) onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`); else if (i < fc.items.length - 1) @@ -4477,10 +4270,10 @@ var require_resolve_flow_collection = __commonJS({ } } if (!isMap && !sep && !props.found) { - const valueNode = value3 ? composeNode(ctx, value3, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError); + const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError); coll.items.push(valueNode); offset = valueNode.range[2]; - if (isBlock(value3)) + if (isBlock(value)) onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg); } else { ctx.atKey = true; @@ -4492,7 +4285,7 @@ var require_resolve_flow_collection = __commonJS({ const valueProps = resolveProps.resolveProps(sep ?? [], { flow: fcName, indicator: "map-value-ind", - next: value3, + next: value, offset: keyNode.range[2], onError, parentIndent: fc.indent, @@ -4512,15 +4305,15 @@ var require_resolve_flow_collection = __commonJS({ if (props.start < valueProps.found.offset - 1024) onError(valueProps.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key"); } - } else if (value3) { - if ("source" in value3 && value3.source?.[0] === ":") - onError(value3, "MISSING_CHAR", `Missing space after : in ${fcName}`); + } else if (value) { + if ("source" in value && value.source?.[0] === ":") + onError(value, "MISSING_CHAR", `Missing space after : in ${fcName}`); else onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`); } - const valueNode = value3 ? composeNode(ctx, value3, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError) : null; + const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError) : null; if (valueNode) { - if (isBlock(value3)) + if (isBlock(value)) onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg); } else if (valueProps.comment) { if (keyNode.comment) @@ -4532,17 +4325,17 @@ var require_resolve_flow_collection = __commonJS({ if (ctx.options.keepSourceTokens) pair.srcToken = collItem; if (isMap) { - const map2 = coll; - if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode)) + const map = coll; + if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode)) onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique"); - map2.items.push(pair); + map.items.push(pair); } else { - const map2 = new YAMLMap.YAMLMap(ctx.schema); - map2.flow = true; - map2.items.push(pair); + const map = new YAMLMap.YAMLMap(ctx.schema); + map.flow = true; + map.items.push(pair); const endRange = (valueNode ?? keyNode).range; - map2.range = [keyNode.range[0], endRange[1], endRange[2]]; - coll.items.push(map2); + map.range = [keyNode.range[0], endRange[1], endRange[2]]; + coll.items.push(map); } offset = valueNode ? valueNode.range[2] : valueProps.end; } @@ -4588,8 +4381,8 @@ var require_compose_collection = __commonJS({ var resolveBlockMap = require_resolve_block_map(); var resolveBlockSeq = require_resolve_block_seq(); var resolveFlowCollection = require_resolve_flow_collection(); - function resolveCollection(CN, ctx, token2, onError, tagName, tag) { - const coll = token2.type === "block-map" ? resolveBlockMap.resolveBlockMap(CN, ctx, token2, onError, tag) : token2.type === "block-seq" ? resolveBlockSeq.resolveBlockSeq(CN, ctx, token2, onError, tag) : resolveFlowCollection.resolveFlowCollection(CN, ctx, token2, onError, tag); + function resolveCollection(CN, ctx, token, onError, tagName, tag) { + const coll = token.type === "block-map" ? resolveBlockMap.resolveBlockMap(CN, ctx, token, onError, tag) : token.type === "block-seq" ? resolveBlockSeq.resolveBlockSeq(CN, ctx, token, onError, tag) : resolveFlowCollection.resolveFlowCollection(CN, ctx, token, onError, tag); const Coll = coll.constructor; if (tagName === "!" || tagName === Coll.tagName) { coll.tag = Coll.tagName; @@ -4599,10 +4392,10 @@ var require_compose_collection = __commonJS({ coll.tag = tagName; return coll; } - function composeCollection(CN, ctx, token2, props, onError) { + function composeCollection(CN, ctx, token, props, onError) { const tagToken = props.tag; const tagName = !tagToken ? null : ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)); - if (token2.type === "block-seq") { + if (token.type === "block-seq") { const { anchor, newlineAfterProp: nl } = props; const lastProp = anchor && tagToken ? anchor.offset > tagToken.offset ? anchor : tagToken : anchor ?? tagToken; if (lastProp && (!nl || nl.offset < lastProp.offset)) { @@ -4610,9 +4403,9 @@ var require_compose_collection = __commonJS({ onError(lastProp, "MISSING_CHAR", message); } } - const expType = token2.type === "block-map" ? "map" : token2.type === "block-seq" ? "seq" : token2.start.source === "{" ? "map" : "seq"; + const expType = token.type === "block-map" ? "map" : token.type === "block-seq" ? "seq" : token.start.source === "{" ? "map" : "seq"; if (!tagToken || !tagName || tagName === "!" || tagName === YAMLMap.YAMLMap.tagName && expType === "map" || tagName === YAMLSeq.YAMLSeq.tagName && expType === "seq") { - return resolveCollection(CN, ctx, token2, onError, tagName); + return resolveCollection(CN, ctx, token, onError, tagName); } let tag = ctx.schema.tags.find((t) => t.tag === tagName && t.collection === expType); if (!tag) { @@ -4626,10 +4419,10 @@ var require_compose_collection = __commonJS({ } else { onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, true); } - return resolveCollection(CN, ctx, token2, onError, tagName); + return resolveCollection(CN, ctx, token, onError, tagName); } } - const coll = resolveCollection(CN, ctx, token2, onError, tagName, tag); + const coll = resolveCollection(CN, ctx, token, onError, tagName, tag); const res = tag.resolve?.(coll, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg), ctx.options) ?? coll; const node = identity.isNode(res) ? res : new Scalar.Scalar(res); node.range = coll.range; @@ -4663,11 +4456,11 @@ var require_resolve_block_scalar = __commonJS({ break; } if (chompStart === 0) { - const value4 = header.chomp === "+" && lines.length > 0 ? "\n".repeat(Math.max(1, lines.length - 1)) : ""; + const value2 = header.chomp === "+" && lines.length > 0 ? "\n".repeat(Math.max(1, lines.length - 1)) : ""; let end2 = start + header.length; if (scalar.source) end2 += scalar.source.length; - return { value: value4, type, comment: header.comment, range: [start, end2, end2] }; + return { value: value2, type, comment: header.comment, range: [start, end2, end2] }; } let trimIndent = scalar.indent + header.indent; let offset = scalar.offset + header.length; @@ -4697,11 +4490,11 @@ var require_resolve_block_scalar = __commonJS({ if (lines[i][0].length > trimIndent) chompStart = i + 1; } - let value3 = ""; + let value = ""; let sep = ""; let prevMoreIndented = false; for (let i = 0; i < contentStart; ++i) - value3 += lines[i][0].slice(trimIndent) + "\n"; + value += lines[i][0].slice(trimIndent) + "\n"; for (let i = contentStart; i < chompStart; ++i) { let [indent, content] = lines[i]; offset += indent.length + content.length + 1; @@ -4715,23 +4508,23 @@ var require_resolve_block_scalar = __commonJS({ indent = ""; } if (type === Scalar.Scalar.BLOCK_LITERAL) { - value3 += sep + indent.slice(trimIndent) + content; + value += sep + indent.slice(trimIndent) + content; sep = "\n"; } else if (indent.length > trimIndent || content[0] === " ") { if (sep === " ") sep = "\n"; else if (!prevMoreIndented && sep === "\n") sep = "\n\n"; - value3 += sep + indent.slice(trimIndent) + content; + value += sep + indent.slice(trimIndent) + content; sep = "\n"; prevMoreIndented = true; } else if (content === "") { if (sep === "\n") - value3 += "\n"; + value += "\n"; else sep = "\n"; } else { - value3 += sep + content; + value += sep + content; sep = " "; prevMoreIndented = false; } @@ -4741,15 +4534,15 @@ var require_resolve_block_scalar = __commonJS({ break; case "+": for (let i = chompStart; i < lines.length; ++i) - value3 += "\n" + lines[i][0].slice(trimIndent); - if (value3[value3.length - 1] !== "\n") - value3 += "\n"; + value += "\n" + lines[i][0].slice(trimIndent); + if (value[value.length - 1] !== "\n") + value += "\n"; break; default: - value3 += "\n"; + value += "\n"; } const end = start + header.length + scalar.source.length; - return { value: value3, type, comment: header.comment, range: [start, end, end] }; + return { value, type, comment: header.comment, range: [start, end, end] }; } function parseBlockScalarHeader({ offset, props }, strict, onError) { if (props[0].type !== "block-scalar-header") { @@ -4777,39 +4570,39 @@ var require_resolve_block_scalar = __commonJS({ onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source}`); let hasSpace = false; let comment = ""; - let length3 = source.length; + let length = source.length; for (let i = 1; i < props.length; ++i) { - const token2 = props[i]; - switch (token2.type) { + const token = props[i]; + switch (token.type) { case "space": hasSpace = true; // fallthrough case "newline": - length3 += token2.source.length; + length += token.source.length; break; case "comment": if (strict && !hasSpace) { const message = "Comments must be separated from other tokens by white space characters"; - onError(token2, "MISSING_CHAR", message); + onError(token, "MISSING_CHAR", message); } - length3 += token2.source.length; - comment = token2.source.substring(1); + length += token.source.length; + comment = token.source.substring(1); break; case "error": - onError(token2, "UNEXPECTED_TOKEN", token2.message); - length3 += token2.source.length; + onError(token, "UNEXPECTED_TOKEN", token.message); + length += token.source.length; break; /* istanbul ignore next should not happen */ default: { - const message = `Unexpected token in block scalar header: ${token2.type}`; - onError(token2, "UNEXPECTED_TOKEN", message); - const ts = token2.source; + const message = `Unexpected token in block scalar header: ${token.type}`; + onError(token, "UNEXPECTED_TOKEN", message); + const ts = token.source; if (ts && typeof ts === "string") - length3 += ts.length; + length += ts.length; } } } - return { mode, indent, chomp, comment, length: length3 }; + return { mode, indent, chomp, comment, length }; } function splitLines(source) { const split = source.split(/\n( *)/); @@ -4834,20 +4627,20 @@ var require_resolve_flow_scalar = __commonJS({ function resolveFlowScalar(scalar, strict, onError) { const { offset, type, source, end } = scalar; let _type; - let value3; + let value; const _onError = (rel, code, msg) => onError(offset + rel, code, msg); switch (type) { case "scalar": _type = Scalar.Scalar.PLAIN; - value3 = plainValue(source, _onError); + value = plainValue(source, _onError); break; case "single-quoted-scalar": _type = Scalar.Scalar.QUOTE_SINGLE; - value3 = singleQuotedValue(source, _onError); + value = singleQuotedValue(source, _onError); break; case "double-quoted-scalar": _type = Scalar.Scalar.QUOTE_DOUBLE; - value3 = doubleQuotedValue(source, _onError); + value = doubleQuotedValue(source, _onError); break; /* istanbul ignore next should not happen */ default: @@ -4862,7 +4655,7 @@ var require_resolve_flow_scalar = __commonJS({ const valueEnd = offset + source.length; const re = resolveEnd.resolveEnd(end, valueEnd, strict, onError); return { - value: value3, + value, type: _type, comment: re.comment, range: [offset, valueEnd, re.offset] @@ -4958,9 +4751,9 @@ var require_resolve_flow_scalar = __commonJS({ while (next === " " || next === " ") next = source[++i + 1]; } else if (next === "x" || next === "u" || next === "U") { - const length3 = next === "x" ? 2 : next === "u" ? 4 : 8; - res += parseCharCode(source, i + 1, length3, onError); - i += length3; + const length = next === "x" ? 2 : next === "u" ? 4 : 8; + res += parseCharCode(source, i + 1, length, onError); + i += length; } else { const raw = source.substr(i - 1, 2); onError(i - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`); @@ -5029,14 +4822,14 @@ var require_resolve_flow_scalar = __commonJS({ "\\": "\\", " ": " " }; - function parseCharCode(source, offset, length3, onError) { - const cc = source.substr(offset, length3); - const ok = cc.length === length3 && /^[0-9a-fA-F]+$/.test(cc); + function parseCharCode(source, offset, length, onError) { + const cc = source.substr(offset, length); + const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc); const code = ok ? parseInt(cc, 16) : NaN; try { return String.fromCodePoint(code); } catch { - const raw = source.substr(offset - 2, length3 + 2); + const raw = source.substr(offset - 2, length + 2); onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`); return raw; } @@ -5053,29 +4846,29 @@ var require_compose_scalar = __commonJS({ var Scalar = require_Scalar(); var resolveBlockScalar = require_resolve_block_scalar(); var resolveFlowScalar = require_resolve_flow_scalar(); - function composeScalar(ctx, token2, tagToken, onError) { - const { value: value3, type, comment, range } = token2.type === "block-scalar" ? resolveBlockScalar.resolveBlockScalar(ctx, token2, onError) : resolveFlowScalar.resolveFlowScalar(token2, ctx.options.strict, onError); + function composeScalar(ctx, token, tagToken, onError) { + const { value, type, comment, range } = token.type === "block-scalar" ? resolveBlockScalar.resolveBlockScalar(ctx, token, onError) : resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError); const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null; let tag; if (ctx.options.stringKeys && ctx.atKey) { tag = ctx.schema[identity.SCALAR]; } else if (tagName) - tag = findScalarTagByName(ctx.schema, value3, tagName, tagToken, onError); - else if (token2.type === "scalar") - tag = findScalarTagByTest(ctx, value3, token2, onError); + tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError); + else if (token.type === "scalar") + tag = findScalarTagByTest(ctx, value, token, onError); else tag = ctx.schema[identity.SCALAR]; let scalar; try { - const res = tag.resolve(value3, (msg) => onError(tagToken ?? token2, "TAG_RESOLVE_FAILED", msg), ctx.options); + const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options); scalar = identity.isScalar(res) ? res : new Scalar.Scalar(res); } catch (error) { const msg = error instanceof Error ? error.message : String(error); - onError(tagToken ?? token2, "TAG_RESOLVE_FAILED", msg); - scalar = new Scalar.Scalar(value3); + onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg); + scalar = new Scalar.Scalar(value); } scalar.range = range; - scalar.source = value3; + scalar.source = value; if (type) scalar.type = type; if (tagName) @@ -5086,7 +4879,7 @@ var require_compose_scalar = __commonJS({ scalar.comment = comment; return scalar; } - function findScalarTagByName(schema, value3, tagName, tagToken, onError) { + function findScalarTagByName(schema, value, tagName, tagToken, onError) { if (tagName === "!") return schema[identity.SCALAR]; const matchWithTest = []; @@ -5099,7 +4892,7 @@ var require_compose_scalar = __commonJS({ } } for (const tag of matchWithTest) - if (tag.test?.test(value3)) + if (tag.test?.test(value)) return tag; const kt = schema.knownTags[tagName]; if (kt && !kt.collection) { @@ -5109,15 +4902,15 @@ var require_compose_scalar = __commonJS({ onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str"); return schema[identity.SCALAR]; } - function findScalarTagByTest({ atKey, directives, schema }, value3, token2, onError) { - const tag = schema.tags.find((tag2) => (tag2.default === true || atKey && tag2.default === "key") && tag2.test?.test(value3)) || schema[identity.SCALAR]; + function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) { + const tag = schema.tags.find((tag2) => (tag2.default === true || atKey && tag2.default === "key") && tag2.test?.test(value)) || schema[identity.SCALAR]; if (schema.compat) { - const compat = schema.compat.find((tag2) => tag2.default && tag2.test?.test(value3)) ?? schema[identity.SCALAR]; + const compat = schema.compat.find((tag2) => tag2.default && tag2.test?.test(value)) ?? schema[identity.SCALAR]; if (tag.tag !== compat.tag) { const ts = directives.tagString(tag.tag); const cs = directives.tagString(compat.tag); const msg = `Value may be parsed as either ${ts} or ${cs}`; - onError(token2, "TAG_RESOLVE_FAILED", msg, true); + onError(token, "TAG_RESOLVE_FAILED", msg, true); } } return tag; @@ -5167,22 +4960,22 @@ var require_compose_node = __commonJS({ var resolveEnd = require_resolve_end(); var utilEmptyScalarPosition = require_util_empty_scalar_position(); var CN = { composeNode, composeEmptyNode }; - function composeNode(ctx, token2, props, onError) { + function composeNode(ctx, token, props, onError) { const atKey = ctx.atKey; const { spaceBefore, comment, anchor, tag } = props; let node; let isSrcToken = true; - switch (token2.type) { + switch (token.type) { case "alias": - node = composeAlias(ctx, token2, onError); + node = composeAlias(ctx, token, onError); if (anchor || tag) - onError(token2, "ALIAS_PROPS", "An alias node must not specify any properties"); + onError(token, "ALIAS_PROPS", "An alias node must not specify any properties"); break; case "scalar": case "single-quoted-scalar": case "double-quoted-scalar": case "block-scalar": - node = composeScalar.composeScalar(ctx, token2, tag, onError); + node = composeScalar.composeScalar(ctx, token, tag, onError); if (anchor) node.anchor = anchor.source.substring(1); break; @@ -5190,47 +4983,47 @@ var require_compose_node = __commonJS({ case "block-seq": case "flow-collection": try { - node = composeCollection.composeCollection(CN, ctx, token2, props, onError); + node = composeCollection.composeCollection(CN, ctx, token, props, onError); if (anchor) node.anchor = anchor.source.substring(1); } catch (error) { const message = error instanceof Error ? error.message : String(error); - onError(token2, "RESOURCE_EXHAUSTION", message); + onError(token, "RESOURCE_EXHAUSTION", message); } break; default: { - const message = token2.type === "error" ? token2.message : `Unsupported token (type: ${token2.type})`; - onError(token2, "UNEXPECTED_TOKEN", message); + const message = token.type === "error" ? token.message : `Unsupported token (type: ${token.type})`; + onError(token, "UNEXPECTED_TOKEN", message); isSrcToken = false; } } - node ?? (node = composeEmptyNode(ctx, token2.offset, void 0, null, props, onError)); + node ?? (node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError)); if (anchor && node.anchor === "") onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string"); if (atKey && ctx.options.stringKeys && (!identity.isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) { const msg = "With stringKeys, all keys must be strings"; - onError(tag ?? token2, "NON_STRING_KEY", msg); + onError(tag ?? token, "NON_STRING_KEY", msg); } if (spaceBefore) node.spaceBefore = true; if (comment) { - if (token2.type === "scalar" && token2.source === "") + if (token.type === "scalar" && token.source === "") node.comment = comment; else node.commentBefore = comment; } if (ctx.options.keepSourceTokens && isSrcToken) - node.srcToken = token2; + node.srcToken = token; return node; } function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) { - const token2 = { + const token = { type: "scalar", offset: utilEmptyScalarPosition.emptyScalarPosition(offset, before, pos), indent: -1, source: "" }; - const node = composeScalar.composeScalar(ctx, token2, tag, onError); + const node = composeScalar.composeScalar(ctx, token, tag, onError); if (anchor) { node.anchor = anchor.source.substring(1); if (node.anchor === "") @@ -5270,7 +5063,7 @@ var require_compose_doc = __commonJS({ var composeNode = require_compose_node(); var resolveEnd = require_resolve_end(); var resolveProps = require_resolve_props(); - function composeDoc(options, directives, { offset, start, value: value3, end }, onError) { + function composeDoc(options, directives, { offset, start, value, end }, onError) { const opts = Object.assign({ _directives: directives }, options); const doc = new Document.Document(void 0, opts); const ctx = { @@ -5282,7 +5075,7 @@ var require_compose_doc = __commonJS({ }; const props = resolveProps.resolveProps(start, { indicator: "doc-start", - next: value3 ?? end?.[0], + next: value ?? end?.[0], offset, onError, parentIndent: 0, @@ -5290,10 +5083,10 @@ var require_compose_doc = __commonJS({ }); if (props.found) { doc.directives.docStart = true; - if (value3 && (value3.type === "block-map" || value3.type === "block-seq") && !props.hasNewline) + if (value && (value.type === "block-map" || value.type === "block-seq") && !props.hasNewline) onError(props.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker"); } - doc.contents = value3 ? composeNode.composeNode(ctx, value3, props, onError) : composeNode.composeEmptyNode(ctx, props.end, start, null, props, onError); + doc.contents = value ? composeNode.composeNode(ctx, value, props, onError) : composeNode.composeEmptyNode(ctx, props.end, start, null, props, onError); const contentEnd = doc.contents.range[2]; const re = resolveEnd.resolveEnd(end, contentEnd, false, onError); if (re.comment) @@ -5421,28 +5214,28 @@ ${cb}` : comment; * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. */ *compose(tokens, forceDoc = false, endOffset = -1) { - for (const token2 of tokens) - yield* this.next(token2); + for (const token of tokens) + yield* this.next(token); yield* this.end(forceDoc, endOffset); } /** Advance the composer by one CST token. */ - *next(token2) { + *next(token) { if (node_process.env.LOG_STREAM) - console.dir(token2, { depth: null }); - switch (token2.type) { + console.dir(token, { depth: null }); + switch (token.type) { case "directive": - this.directives.add(token2.source, (offset, message, warning) => { - const pos = getErrorPos(token2); + this.directives.add(token.source, (offset, message, warning) => { + const pos = getErrorPos(token); pos[0] += offset; this.onError(pos, "BAD_DIRECTIVE", message, warning); }); - this.prelude.push(token2.source); + this.prelude.push(token.source); this.atDirectives = true; break; case "document": { - const doc = composeDoc.composeDoc(this.options, this.directives, token2, this.onError); + const doc = composeDoc.composeDoc(this.options, this.directives, token, this.onError); if (this.atDirectives && !doc.directives.docStart) - this.onError(token2, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"); + this.onError(token, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"); this.decorate(doc, false); if (this.doc) yield this.doc; @@ -5455,11 +5248,11 @@ ${cb}` : comment; break; case "comment": case "newline": - this.prelude.push(token2.source); + this.prelude.push(token.source); break; case "error": { - const msg = token2.source ? `${token2.message}: ${JSON.stringify(token2.source)}` : token2.message; - const error = new errors.YAMLParseError(getErrorPos(token2), "UNEXPECTED_TOKEN", msg); + const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message; + const error = new errors.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg); if (this.atDirectives || !this.doc) this.errors.push(error); else @@ -5469,11 +5262,11 @@ ${cb}` : comment; case "doc-end": { if (!this.doc) { const msg = "Unexpected doc-end without preceding document"; - this.errors.push(new errors.YAMLParseError(getErrorPos(token2), "UNEXPECTED_TOKEN", msg)); + this.errors.push(new errors.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg)); break; } this.doc.directives.docEnd = true; - const end = resolveEnd.resolveEnd(token2.end, token2.offset + token2.source.length, this.doc.options.strict, this.onError); + const end = resolveEnd.resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError); this.decorate(this.doc, true); if (end.comment) { const dc = this.doc.comment; @@ -5484,7 +5277,7 @@ ${end.comment}` : end.comment; break; } default: - this.errors.push(new errors.YAMLParseError(getErrorPos(token2), "UNEXPECTED_TOKEN", `Unsupported token ${token2.type}`)); + this.errors.push(new errors.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`)); } } /** @@ -5521,8 +5314,8 @@ var require_cst_scalar = __commonJS({ var resolveFlowScalar = require_resolve_flow_scalar(); var errors = require_errors(); var stringifyString = require_stringifyString(); - function resolveAsScalar(token2, strict = true, onError) { - if (token2) { + function resolveAsScalar(token, strict = true, onError) { + if (token) { const _onError = (pos, code, message) => { const offset = typeof pos === "number" ? pos : Array.isArray(pos) ? pos[0] : pos.offset; if (onError) @@ -5530,20 +5323,20 @@ var require_cst_scalar = __commonJS({ else throw new errors.YAMLParseError([offset, offset + 1], code, message); }; - switch (token2.type) { + switch (token.type) { case "scalar": case "single-quoted-scalar": case "double-quoted-scalar": - return resolveFlowScalar.resolveFlowScalar(token2, strict, _onError); + return resolveFlowScalar.resolveFlowScalar(token, strict, _onError); case "block-scalar": - return resolveBlockScalar.resolveBlockScalar({ options: { strict } }, token2, _onError); + return resolveBlockScalar.resolveBlockScalar({ options: { strict } }, token, _onError); } } return null; } - function createScalarToken(value3, context) { + function createScalarToken(value, context) { const { implicitKey = false, indent, inFlow = false, offset = -1, type = "PLAIN" } = context; - const source = stringifyString.stringifyString({ type, value: value3 }, { + const source = stringifyString.stringifyString({ type, value }, { implicitKey, indent: indent > 0 ? " ".repeat(indent) : "", inFlow, @@ -5556,10 +5349,10 @@ var require_cst_scalar = __commonJS({ case "|": case ">": { const he = source.indexOf("\n"); - const head2 = source.substring(0, he); + const head = source.substring(0, he); const body = source.substring(he + 1) + "\n"; const props = [ - { type: "block-scalar-header", offset, indent, source: head2 } + { type: "block-scalar-header", offset, indent, source: head } ]; if (!addEndtoBlockProps(props, end)) props.push({ type: "newline", offset: -1, indent, source: "\n" }); @@ -5573,13 +5366,13 @@ var require_cst_scalar = __commonJS({ return { type: "scalar", offset, indent, source, end }; } } - function setScalarValue(token2, value3, context = {}) { + function setScalarValue(token, value, context = {}) { let { afterKey = false, implicitKey = false, inFlow = false, type } = context; - let indent = "indent" in token2 ? token2.indent : null; + let indent = "indent" in token ? token.indent : null; if (afterKey && typeof indent === "number") indent += 2; if (!type) - switch (token2.type) { + switch (token.type) { case "single-quoted-scalar": type = "QUOTE_SINGLE"; break; @@ -5587,7 +5380,7 @@ var require_cst_scalar = __commonJS({ type = "QUOTE_DOUBLE"; break; case "block-scalar": { - const header = token2.props[0]; + const header = token.props[0]; if (header.type !== "block-scalar-header") throw new Error("Invalid block scalar header"); type = header.source[0] === ">" ? "BLOCK_FOLDED" : "BLOCK_LITERAL"; @@ -5596,7 +5389,7 @@ var require_cst_scalar = __commonJS({ default: type = "PLAIN"; } - const source = stringifyString.stringifyString({ type, value: value3 }, { + const source = stringifyString.stringifyString({ type, value }, { implicitKey: implicitKey || indent === null, indent: indent !== null && indent > 0 ? " ".repeat(indent) : "", inFlow, @@ -5605,40 +5398,40 @@ var require_cst_scalar = __commonJS({ switch (source[0]) { case "|": case ">": - setBlockScalarValue(token2, source); + setBlockScalarValue(token, source); break; case '"': - setFlowScalarValue(token2, source, "double-quoted-scalar"); + setFlowScalarValue(token, source, "double-quoted-scalar"); break; case "'": - setFlowScalarValue(token2, source, "single-quoted-scalar"); + setFlowScalarValue(token, source, "single-quoted-scalar"); break; default: - setFlowScalarValue(token2, source, "scalar"); + setFlowScalarValue(token, source, "scalar"); } } - function setBlockScalarValue(token2, source) { + function setBlockScalarValue(token, source) { const he = source.indexOf("\n"); - const head2 = source.substring(0, he); + const head = source.substring(0, he); const body = source.substring(he + 1) + "\n"; - if (token2.type === "block-scalar") { - const header = token2.props[0]; + if (token.type === "block-scalar") { + const header = token.props[0]; if (header.type !== "block-scalar-header") throw new Error("Invalid block scalar header"); - header.source = head2; - token2.source = body; + header.source = head; + token.source = body; } else { - const { offset } = token2; - const indent = "indent" in token2 ? token2.indent : -1; + const { offset } = token; + const indent = "indent" in token ? token.indent : -1; const props = [ - { type: "block-scalar-header", offset, indent, source: head2 } + { type: "block-scalar-header", offset, indent, source: head } ]; - if (!addEndtoBlockProps(props, "end" in token2 ? token2.end : void 0)) + if (!addEndtoBlockProps(props, "end" in token ? token.end : void 0)) props.push({ type: "newline", offset: -1, indent, source: "\n" }); - for (const key of Object.keys(token2)) + for (const key of Object.keys(token)) if (key !== "type" && key !== "offset") - delete token2[key]; - Object.assign(token2, { type: "block-scalar", indent, props, source: body }); + delete token[key]; + Object.assign(token, { type: "block-scalar", indent, props, source: body }); } } function addEndtoBlockProps(props, end) { @@ -5655,40 +5448,40 @@ var require_cst_scalar = __commonJS({ } return false; } - function setFlowScalarValue(token2, source, type) { - switch (token2.type) { + function setFlowScalarValue(token, source, type) { + switch (token.type) { case "scalar": case "double-quoted-scalar": case "single-quoted-scalar": - token2.type = type; - token2.source = source; + token.type = type; + token.source = source; break; case "block-scalar": { - const end = token2.props.slice(1); + const end = token.props.slice(1); let oa = source.length; - if (token2.props[0].type === "block-scalar-header") - oa -= token2.props[0].source.length; + if (token.props[0].type === "block-scalar-header") + oa -= token.props[0].source.length; for (const tok of end) tok.offset += oa; - delete token2.props; - Object.assign(token2, { type, source, end }); + delete token.props; + Object.assign(token, { type, source, end }); break; } case "block-map": case "block-seq": { - const offset = token2.offset + source.length; - const nl = { type: "newline", offset, indent: token2.indent, source: "\n" }; - delete token2.items; - Object.assign(token2, { type, source, end: [nl] }); + const offset = token.offset + source.length; + const nl = { type: "newline", offset, indent: token.indent, source: "\n" }; + delete token.items; + Object.assign(token, { type, source, end: [nl] }); break; } default: { - const indent = "indent" in token2 ? token2.indent : -1; - const end = "end" in token2 && Array.isArray(token2.end) ? token2.end.filter((st) => st.type === "space" || st.type === "comment" || st.type === "newline") : []; - for (const key of Object.keys(token2)) + const indent = "indent" in token ? token.indent : -1; + const end = "end" in token && Array.isArray(token.end) ? token.end.filter((st) => st.type === "space" || st.type === "comment" || st.type === "newline") : []; + for (const key of Object.keys(token)) if (key !== "type" && key !== "offset") - delete token2[key]; - Object.assign(token2, { type, indent, source, end }); + delete token[key]; + Object.assign(token, { type, indent, source, end }); } } } @@ -5703,46 +5496,46 @@ var require_cst_stringify = __commonJS({ "../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/parse/cst-stringify.js"(exports) { "use strict"; var stringify = (cst) => "type" in cst ? stringifyToken(cst) : stringifyItem(cst); - function stringifyToken(token2) { - switch (token2.type) { + function stringifyToken(token) { + switch (token.type) { case "block-scalar": { let res = ""; - for (const tok of token2.props) + for (const tok of token.props) res += stringifyToken(tok); - return res + token2.source; + return res + token.source; } case "block-map": case "block-seq": { let res = ""; - for (const item of token2.items) + for (const item of token.items) res += stringifyItem(item); return res; } case "flow-collection": { - let res = token2.start.source; - for (const item of token2.items) + let res = token.start.source; + for (const item of token.items) res += stringifyItem(item); - for (const st of token2.end) + for (const st of token.end) res += st.source; return res; } case "document": { - let res = stringifyItem(token2); - if (token2.end) - for (const st of token2.end) + let res = stringifyItem(token); + if (token.end) + for (const st of token.end) res += st.source; return res; } default: { - let res = token2.source; - if ("end" in token2 && token2.end) - for (const st of token2.end) + let res = token.source; + if ("end" in token && token.end) + for (const st of token.end) res += st.source; return res; } } } - function stringifyItem({ start, key, sep, value: value3 }) { + function stringifyItem({ start, key, sep, value }) { let res = ""; for (const st of start) res += st.source; @@ -5751,8 +5544,8 @@ var require_cst_stringify = __commonJS({ if (sep) for (const st of sep) res += st.source; - if (value3) - res += stringifyToken(value3); + if (value) + res += stringifyToken(value); return res; } exports.stringify = stringify; @@ -5774,9 +5567,9 @@ var require_cst_visit = __commonJS({ visit.BREAK = BREAK; visit.SKIP = SKIP; visit.REMOVE = REMOVE; - visit.itemAtPath = (cst, path6) => { + visit.itemAtPath = (cst, path4) => { let item = cst; - for (const [field, index] of path6) { + for (const [field, index] of path4) { const tok = item?.[field]; if (tok && "items" in tok) { item = tok.items[index]; @@ -5785,37 +5578,37 @@ var require_cst_visit = __commonJS({ } return item; }; - visit.parentCollection = (cst, path6) => { - const parent = visit.itemAtPath(cst, path6.slice(0, -1)); - const field = path6[path6.length - 1][0]; + visit.parentCollection = (cst, path4) => { + const parent = visit.itemAtPath(cst, path4.slice(0, -1)); + const field = path4[path4.length - 1][0]; const coll = parent?.[field]; if (coll && "items" in coll) return coll; throw new Error("Parent collection not found"); }; - function _visit(path6, item, visitor) { - let ctrl = visitor(item, path6); + function _visit(path4, item, visitor) { + let ctrl = visitor(item, path4); if (typeof ctrl === "symbol") return ctrl; for (const field of ["key", "value"]) { - const token2 = item[field]; - if (token2 && "items" in token2) { - for (let i = 0; i < token2.items.length; ++i) { - const ci = _visit(Object.freeze(path6.concat([[field, i]])), token2.items[i], visitor); + const token = item[field]; + if (token && "items" in token) { + for (let i = 0; i < token.items.length; ++i) { + const ci = _visit(Object.freeze(path4.concat([[field, i]])), token.items[i], visitor); if (typeof ci === "number") i = ci - 1; else if (ci === BREAK) return BREAK; else if (ci === REMOVE) { - token2.items.splice(i, 1); + token.items.splice(i, 1); i -= 1; } } if (typeof ctrl === "function" && field === "key") - ctrl = ctrl(item, path6); + ctrl = ctrl(item, path4); } } - return typeof ctrl === "function" ? ctrl(item, path6) : ctrl; + return typeof ctrl === "function" ? ctrl(item, path4) : ctrl; } exports.visit = visit; } @@ -5832,10 +5625,10 @@ var require_cst = __commonJS({ var DOCUMENT = ""; var FLOW_END = ""; var SCALAR = ""; - var isCollection = (token2) => !!token2 && "items" in token2; - var isScalar2 = (token2) => !!token2 && (token2.type === "scalar" || token2.type === "single-quoted-scalar" || token2.type === "double-quoted-scalar" || token2.type === "block-scalar"); - function prettyToken(token2) { - switch (token2) { + var isCollection = (token) => !!token && "items" in token; + var isScalar = (token) => !!token && (token.type === "scalar" || token.type === "single-quoted-scalar" || token.type === "double-quoted-scalar" || token.type === "block-scalar"); + function prettyToken(token) { + switch (token) { case BOM: return ""; case DOCUMENT: @@ -5845,7 +5638,7 @@ var require_cst = __commonJS({ case SCALAR: return ""; default: - return JSON.stringify(token2); + return JSON.stringify(token); } } function tokenType(source) { @@ -5917,7 +5710,7 @@ var require_cst = __commonJS({ exports.FLOW_END = FLOW_END; exports.SCALAR = SCALAR; exports.isCollection = isCollection; - exports.isScalar = isScalar2; + exports.isScalar = isScalar; exports.prettyToken = prettyToken; exports.tokenType = tokenType; } @@ -6569,8 +6362,8 @@ var require_parser = __commonJS({ } return -1; } - function isFlowToken(token2) { - switch (token2?.type) { + function isFlowToken(token) { + switch (token?.type) { case "alias": case "scalar": case "single-quoted-scalar": @@ -6777,38 +6570,38 @@ var require_parser = __commonJS({ return this.stack[this.stack.length - n]; } *pop(error) { - const token2 = error ?? this.stack.pop(); - if (!token2) { + const token = error ?? this.stack.pop(); + if (!token) { const message = "Tried to pop an empty stack"; yield { type: "error", offset: this.offset, source: "", message }; } else if (this.stack.length === 0) { - yield token2; + yield token; } else { const top = this.peek(1); - if (token2.type === "block-scalar") { - token2.indent = "indent" in top ? top.indent : 0; - } else if (token2.type === "flow-collection" && top.type === "document") { - token2.indent = 0; + if (token.type === "block-scalar") { + token.indent = "indent" in top ? top.indent : 0; + } else if (token.type === "flow-collection" && top.type === "document") { + token.indent = 0; } - if (token2.type === "flow-collection") - fixFlowSeqItems(token2); + if (token.type === "flow-collection") + fixFlowSeqItems(token); switch (top.type) { case "document": - top.value = token2; + top.value = token; break; case "block-scalar": - top.props.push(token2); + top.props.push(token); break; case "block-map": { const it = top.items[top.items.length - 1]; if (it.value) { - top.items.push({ start: [], key: token2, sep: [] }); + top.items.push({ start: [], key: token, sep: [] }); this.onKeyLine = true; return; } else if (it.sep) { - it.value = token2; + it.value = token; } else { - Object.assign(it, { key: token2, sep: [] }); + Object.assign(it, { key: token, sep: [] }); this.onKeyLine = !it.explicitKey; return; } @@ -6817,34 +6610,34 @@ var require_parser = __commonJS({ case "block-seq": { const it = top.items[top.items.length - 1]; if (it.value) - top.items.push({ start: [], value: token2 }); + top.items.push({ start: [], value: token }); else - it.value = token2; + it.value = token; break; } case "flow-collection": { const it = top.items[top.items.length - 1]; if (!it || it.value) - top.items.push({ start: [], key: token2, sep: [] }); + top.items.push({ start: [], key: token, sep: [] }); else if (it.sep) - it.value = token2; + it.value = token; else - Object.assign(it, { key: token2, sep: [] }); + Object.assign(it, { key: token, sep: [] }); return; } /* istanbul ignore next should not happen */ default: yield* this.pop(); - yield* this.pop(token2); + yield* this.pop(token); } - if ((top.type === "document" || top.type === "block-map" || top.type === "block-seq") && (token2.type === "block-map" || token2.type === "block-seq")) { - const last = token2.items[token2.items.length - 1]; - if (last && !last.sep && !last.value && last.start.length > 0 && findNonEmptyIndex(last.start) === -1 && (token2.indent === 0 || last.start.every((st) => st.type !== "comment" || st.indent < token2.indent))) { + if ((top.type === "document" || top.type === "block-map" || top.type === "block-seq") && (token.type === "block-map" || token.type === "block-seq")) { + const last = token.items[token.items.length - 1]; + if (last && !last.sep && !last.value && last.start.length > 0 && findNonEmptyIndex(last.start) === -1 && (token.indent === 0 || last.start.every((st) => st.type !== "comment" || st.indent < token.indent))) { if (top.type === "document") top.end = last.start; else top.items.push({ start: last.start }); - token2.items.splice(-1, 1); + token.items.splice(-1, 1); } } } @@ -6923,14 +6716,14 @@ var require_parser = __commonJS({ delete scalar.end; } else sep = [this.sourceToken]; - const map2 = { + const map = { type: "block-map", offset: scalar.offset, indent: scalar.indent, items: [{ start, key: scalar, sep }] }; this.onKeyLine = true; - this.stack[this.stack.length - 1] = map2; + this.stack[this.stack.length - 1] = map; } else yield* this.lineEnd(scalar); } @@ -6960,8 +6753,8 @@ var require_parser = __commonJS({ yield* this.step(); } } - *blockMap(map2) { - const it = map2.items[map2.items.length - 1]; + *blockMap(map) { + const it = map.items[map.items.length - 1]; switch (this.type) { case "newline": this.onKeyLine = false; @@ -6971,7 +6764,7 @@ var require_parser = __commonJS({ if (last?.type === "comment") end?.push(this.sourceToken); else - map2.items.push({ start: [this.sourceToken] }); + map.items.push({ start: [this.sourceToken] }); } else if (it.sep) { it.sep.push(this.sourceToken); } else { @@ -6981,17 +6774,17 @@ var require_parser = __commonJS({ case "space": case "comment": if (it.value) { - map2.items.push({ start: [this.sourceToken] }); + map.items.push({ start: [this.sourceToken] }); } else if (it.sep) { it.sep.push(this.sourceToken); } else { - if (this.atIndentedComment(it.start, map2.indent)) { - const prev = map2.items[map2.items.length - 2]; + if (this.atIndentedComment(it.start, map.indent)) { + const prev = map.items[map.items.length - 2]; const end = prev?.value?.end; if (Array.isArray(end)) { arrayPushArray(end, it.start); end.push(this.sourceToken); - map2.items.pop(); + map.items.pop(); return; } } @@ -6999,8 +6792,8 @@ var require_parser = __commonJS({ } return; } - if (this.indent >= map2.indent) { - const atMapIndent = !this.onKeyLine && this.indent === map2.indent; + if (this.indent >= map.indent) { + const atMapIndent = !this.onKeyLine && this.indent === map.indent; const atNextItem = atMapIndent && (it.sep || it.explicitKey) && this.type !== "seq-item-ind"; let start = []; if (atNextItem && it.sep && !it.value) { @@ -7014,7 +6807,7 @@ var require_parser = __commonJS({ case "space": break; case "comment": - if (st.indent > map2.indent) + if (st.indent > map.indent) nl.length = 0; break; default: @@ -7029,7 +6822,7 @@ var require_parser = __commonJS({ case "tag": if (atNextItem || it.value) { start.push(this.sourceToken); - map2.items.push({ start }); + map.items.push({ start }); this.onKeyLine = true; } else if (it.sep) { it.sep.push(this.sourceToken); @@ -7043,7 +6836,7 @@ var require_parser = __commonJS({ it.explicitKey = true; } else if (atNextItem || it.value) { start.push(this.sourceToken); - map2.items.push({ start, explicitKey: true }); + map.items.push({ start, explicitKey: true }); } else { this.stack.push({ type: "block-map", @@ -7069,7 +6862,7 @@ var require_parser = __commonJS({ }); } } else if (it.value) { - map2.items.push({ start: [], key: null, sep: [this.sourceToken] }); + map.items.push({ start: [], key: null, sep: [this.sourceToken] }); } else if (includesToken(it.sep, "map-value-ind")) { this.stack.push({ type: "block-map", @@ -7099,7 +6892,7 @@ var require_parser = __commonJS({ if (!it.sep) { Object.assign(it, { key: null, sep: [this.sourceToken] }); } else if (it.value || atNextItem) { - map2.items.push({ start, key: null, sep: [this.sourceToken] }); + map.items.push({ start, key: null, sep: [this.sourceToken] }); } else if (includesToken(it.sep, "map-value-ind")) { this.stack.push({ type: "block-map", @@ -7119,7 +6912,7 @@ var require_parser = __commonJS({ case "double-quoted-scalar": { const fs = this.flowScalar(this.type); if (atNextItem || it.value) { - map2.items.push({ start, key: fs, sep: [] }); + map.items.push({ start, key: fs, sep: [] }); this.onKeyLine = true; } else if (it.sep) { this.stack.push(fs); @@ -7130,7 +6923,7 @@ var require_parser = __commonJS({ return; } default: { - const bv = this.startBlockValue(map2); + const bv = this.startBlockValue(map); if (bv) { if (bv.type === "block-seq") { if (!it.explicitKey && it.sep && !includesToken(it.sep, "newline")) { @@ -7143,7 +6936,7 @@ var require_parser = __commonJS({ return; } } else if (atMapIndent) { - map2.items.push({ start }); + map.items.push({ start }); } this.stack.push(bv); return; @@ -7284,14 +7077,14 @@ var require_parser = __commonJS({ fixFlowSeqItems(fc); const sep = fc.end.splice(1, fc.end.length); sep.push(this.sourceToken); - const map2 = { + const map = { type: "block-map", offset: fc.offset, indent: fc.indent, items: [{ start, key: fc, sep }] }; this.onKeyLine = true; - this.stack[this.stack.length - 1] = map2; + this.stack[this.stack.length - 1] = map; } else { yield* this.lineEnd(fc); } @@ -7387,7 +7180,7 @@ var require_parser = __commonJS({ yield* this.pop(); } } - *lineEnd(token2) { + *lineEnd(token) { switch (this.type) { case "comma": case "doc-start": @@ -7404,10 +7197,10 @@ var require_parser = __commonJS({ case "space": case "comment": default: - if (token2.end) - token2.end.push(this.sourceToken); + if (token.end) + token.end.push(this.sourceToken); else - token2.end = [this.sourceToken]; + token.end = [this.sourceToken]; if (this.type === "newline") yield* this.pop(); } @@ -7466,7 +7259,7 @@ var require_public_api = __commonJS({ } return doc; } - function parse2(src, reviver, options) { + function parse(src, reviver, options) { let _reviver = void 0; if (typeof reviver === "function") { _reviver = reviver; @@ -7485,7 +7278,7 @@ var require_public_api = __commonJS({ } return doc.toJS(Object.assign({ reviver: _reviver }, options)); } - function stringify(value3, replacer, options) { + function stringify(value, replacer, options) { let _replacer = null; if (typeof replacer === "function" || Array.isArray(replacer)) { _replacer = replacer; @@ -7498,16 +7291,16 @@ var require_public_api = __commonJS({ const indent = Math.round(options); options = indent < 1 ? void 0 : indent > 8 ? { indent: 8 } : { indent }; } - if (value3 === void 0) { + if (value === void 0) { const { keepUndefined } = options ?? replacer ?? {}; if (!keepUndefined) return void 0; } - if (identity.isDocument(value3) && !_replacer) - return value3.toString(options); - return new Document.Document(value3, _replacer, options).toString(options); + if (identity.isDocument(value) && !_replacer) + return value.toString(options); + return new Document.Document(value, _replacer, options).toString(options); } - exports.parse = parse2; + exports.parse = parse; exports.parseAllDocuments = parseAllDocuments; exports.parseDocument = parseDocument; exports.stringify = stringify; @@ -7571,9 +7364,9 @@ import { execFile } from "node:child_process"; import { realpathSync } from "node:fs"; import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises"; import { homedir as homedir2 } from "node:os"; -import path5 from "node:path"; +import path3 from "node:path"; import process from "node:process"; -import { fileURLToPath as fileURLToPath2 } from "node:url"; +import { fileURLToPath } from "node:url"; import { promisify } from "node:util"; // src/derive-session-context/compose-manifest.ts @@ -7585,8 +7378,8 @@ var BARE_NUMERIC_PATTERN = /^[0-9]+/; function extractTicketId(input) { const jiraMatch = input.branchName.match(JIRA_STYLE_PATTERN); if (jiraMatch !== null) { - const id62 = jiraMatch[0].toUpperCase(); - return { ticket_id: id62, ticket_ref: id62 }; + const id = jiraMatch[0].toUpperCase(); + return { ticket_id: id, ticket_ref: id }; } const bareMatch = input.branchName.match(BARE_NUMERIC_PATTERN); if (bareMatch === null) { @@ -7598,8 +7391,8 @@ function extractTicketId(input) { return { ticket_id: bareNumber, ticket_ref: `#${bareNumber}` }; } if (prefix !== void 0 && prefix !== "") { - const id62 = `${prefix}${bareNumber}`; - return { ticket_id: id62, ticket_ref: id62 }; + const id = `${prefix}${bareNumber}`; + return { ticket_id: id, ticket_ref: id }; } return { ticket_id: bareNumber, ticket_ref: bareNumber }; } @@ -7615,21 +7408,21 @@ var DEFAULT_ARTIFACT_PATHS = Object.freeze({ plans: "plans" }); function composeManifest(input) { - const { preferences, branchName, cwd: cwd2, home, now } = input; + const { preferences, branchName, cwd, home, now } = input; const ticketRefPrefix = preferences.project?.ticket_ref_prefix; const ticketResult = ticketRefPrefix === void 0 ? extractTicketId({ branchName }) : extractTicketId({ branchName, ticketRefPrefix }); - const projectSlug = preferences.project?.slug ?? preferences.repository?.slug ?? path.basename(cwd2); + const projectSlug = preferences.project?.slug ?? preferences.repository?.slug ?? path.basename(cwd); const platform = preferences.platform ?? DEFAULT_PLATFORM; const remoteName = preferences.repository?.default_remote?.name ?? DEFAULT_REMOTE_NAME; const remoteBranch = preferences.repository?.default_remote?.default_branch ?? DEFAULT_REMOTE_BRANCH; const defaultBranch = `${remoteName}/${remoteBranch}`; const rawBaseDir = preferences.artifacts?.base_dir ?? DEFAULT_BASE_DIR; - const artifactBaseDir = resolveBaseDir(rawBaseDir, cwd2, home); + const artifactBaseDir = resolveBaseDir(rawBaseDir, cwd, home); const artifactPaths = { ...DEFAULT_ARTIFACT_PATHS }; const configuredPaths = preferences.artifacts?.paths; if (configuredPaths !== void 0) { - for (const [key, value3] of Object.entries(configuredPaths)) { - artifactPaths[key] = value3; + for (const [key, value] of Object.entries(configuredPaths)) { + artifactPaths[key] = value; } } return { @@ -7644,7 +7437,7 @@ function composeManifest(input) { created_at: formatIsoUtc(now) }; } -function resolveBaseDir(rawBaseDir, cwd2, home) { +function resolveBaseDir(rawBaseDir, cwd, home) { let expanded = rawBaseDir; if (rawBaseDir === "~") { expanded = home; @@ -7654,3792 +7447,278 @@ function resolveBaseDir(rawBaseDir, cwd2, home) { if (path.isAbsolute(expanded)) { return expanded; } - return path.resolve(cwd2, expanded); + return path.resolve(cwd, expanded); } function formatIsoUtc(date) { return date.toISOString().replace(/\.\d{3}Z$/, "Z"); } // src/derive-session-context/read-preferences.ts +var import_yaml = __toESM(require_dist(), 1); import { readFile } from "node:fs/promises"; import { homedir } from "node:os"; -import path4 from "node:path"; - -// ../../node_modules/.pnpm/@hyperjump+uri@1.3.3/node_modules/@hyperjump/uri/lib/index.js -var hexdig = `[a-fA-F0-9]`; -var unreserved = `[a-zA-Z0-9-._~]`; -var subDelims = `[!$&'()*+,;=]`; -var pctEncoded = `%${hexdig}${hexdig}`; -var decOctet = `(?:\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])`; -var ipV4Address = `${decOctet}\\.${decOctet}\\.${decOctet}\\.${decOctet}`; -var h16 = `${hexdig}{1,4}`; -var ls32 = `(?:${h16}:${h16}|${ipV4Address})`; -var ipV6Address = `(?:(?:${h16}:){6}${ls32}|::(?:${h16}:){5}${ls32}|(?:${h16})?::(?:${h16}:){4}${ls32}|(?:(?:${h16}:){0,1}${h16})?::(?:${h16}:){3}${ls32}|(?:(?:${h16}:){0,2}${h16})?::(?:${h16}:){2}${ls32}|(?:(?:${h16}:){0,3}${h16})?::(?:${h16}:){1}${ls32}|(?:(?:${h16}:){0,4}${h16})?::${ls32}|(?:(?:${h16}:){0,5}${h16})?::${h16}|(?:(?:${h16}:){0,6}${h16})?::)`; -var ipVFuture = `v${hexdig}+\\.(?:${unreserved}|${subDelims}|:)+`; -var ipLiteral = `\\[(?:${ipV6Address}|${ipVFuture})\\]`; -var scheme = `(?[a-zA-Z][a-zA-Z0-9-+.]*)`; -var port = `:(?\\d*)`; -var regName = `(?:${unreserved}|${pctEncoded}|${subDelims})*?`; -var host = `(?${ipLiteral}|${ipV4Address}|${regName})`; -var userinfo = `(?(?:${unreserved}|${pctEncoded}|${subDelims}|:)*)`; -var pchar = `(?:${unreserved}|${pctEncoded}|${subDelims}|:|@)`; -var segment = `${pchar}*?`; -var pathAbEmpty = `(?:/${segment})*`; -var authority = `(?(?:${userinfo}@)?${host}(?:${port})?)`; -var path2 = `(?${pathAbEmpty})`; -var pathWithoutAuthority = `(?(?!//)${segment}${pathAbEmpty})`; -var query = `(?:\\?(?(?:${pchar}|/|\\?)*))?`; -var fragment = `(?:#(?(?:${pchar}|/|\\?)*))?`; -var uri = `^${scheme}:(?://${authority}${path2}|${pathWithoutAuthority})${query}${fragment}$`; -var uriReference = `^(?:${scheme}:|)(?://${authority}${path2}|${pathWithoutAuthority})${query}${fragment}$`; -var absoluteUri = `^${scheme}:(?://${authority}${path2}|${pathWithoutAuthority})${query}$`; -var iunreserved = `[a-zA-Z0-9\\-._~\\u{A0}-\\u{D7FF}\\u{F900}-\\u{FDCF}\\u{FDF0}-\\u{FFEF}\\u{10000}-\\u{1FFFD}\\u{20000}-\\u{2FFFD}\\u{30000}-\\u{3FFFD}\\u{40000}-\\u{4FFFD}\\u{50000}-\\u{5FFFD}\\u{60000}-\\u{6FFFD}\\u{70000}-\\u{7FFFD}\\u{80000}-\\u{8FFFD}\\u{90000}-\\u{9FFFD}\\u{A0000}-\\u{AFFFD}\\u{B0000}-\\u{BFFFD}\\u{C0000}-\\u{CFFFD}\\u{D0000}-\\u{DFFFD}\\u{E1000}-\\u{EFFFD}]`; -var iprivate = `[\\u{E000}-\\u{F8FF}\\u{F0000}-\\u{FFFFD}\\u{100000}-\\u{10FFFD}]`; -var iregName = `(?:${iunreserved}|${pctEncoded}|${subDelims})*?`; -var ihost = `(?${ipLiteral}|${ipV4Address}|${iregName})`; -var iuserinfo = `(?(?:${iunreserved}|${pctEncoded}|${subDelims}|:)*)`; -var ipchar = `(?:${iunreserved}|${pctEncoded}|${subDelims}|:|@)`; -var isegment = `${ipchar}*?`; -var ipathAbEmpty = `(?:/${isegment})*`; -var iauthority = `(?(?:${iuserinfo}@)?${ihost}(?:${port})?)`; -var ipath = `(?${ipathAbEmpty})`; -var ipathWithoutAuthority = `(?(?!//)${isegment}${ipathAbEmpty})`; -var iquery = `(?:\\?(?(?:${ipchar}|${iprivate}|/|\\?)*))?`; -var ifragment = `(?:#(?(?:${ipchar}|/|\\?)*))?`; -var iri = `^${scheme}:(?://${iauthority}${ipath}|${ipathWithoutAuthority})${iquery}${ifragment}$`; -var iriReference = `^(?:${scheme}:|)(?://${iauthority}${ipath}|${ipathWithoutAuthority})${iquery}${ifragment}$`; -var absoluteIri = `^${scheme}:(?://${iauthority}${ipath}|${ipathWithoutAuthority})${iquery}$`; -var resolveReference = (strategy) => (reference, base) => { - const resolvedComponents = ( - /** @type API.IdentifierComponents */ - strategy.parseReference(reference) - ); - if (resolvedComponents.scheme === void 0) { - const baseComponents = strategy.parseAbsolute(base); - resolvedComponents.scheme = baseComponents.scheme; - if (resolvedComponents.authority === void 0) { - resolvedComponents.authority = baseComponents.authority; - resolvedComponents.userinfo = baseComponents.userinfo; - resolvedComponents.host = baseComponents.host; - resolvedComponents.port = baseComponents.port; - if (resolvedComponents.path === "") { - resolvedComponents.path = baseComponents.path; - resolvedComponents.query ??= baseComponents.query; - } else if (!resolvedComponents.path.startsWith("/")) { - resolvedComponents.path = mergePaths(resolvedComponents.path, baseComponents); - } +import path2 from "node:path"; +async function readPreferences(input) { + const home = input.home ?? homedir(); + const projectPath = path2.join(input.cwd, ".agents", "preferences.yaml"); + const globalPath = path2.join(home, ".agents", "preferences.yaml"); + const project = await readOptionalYaml(projectPath); + const global = await readOptionalYaml(globalPath); + const merged = mergeTopLevel(global?.value, project?.value); + const preferences = projectPreferences(merged); + const sources = { + ...project !== null && { project: projectPath }, + ...global !== null && { global: globalPath } + }; + return { + preferences, + sources + }; +} +async function readOptionalYaml(filePath) { + let text; + try { + text = await readFile(filePath, "utf8"); + } catch (error) { + if (isEnoentError(error)) { + return null; } + throw error; } - return composeIdentifier(strategy, resolvedComponents); -}; -var mergePaths = (path6, base) => { - if (base.authority && base.path === "") { - return "/" + path6; - } else { - const position = base.path.lastIndexOf("/"); - return position === -1 ? path6 : base.path.slice(0, position + 1) + path6; + let parsed; + try { + parsed = (0, import_yaml.parse)(text); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + throw new Error(`${filePath}: malformed YAML \u2014 ${message}`); } -}; -var isNoOpSegment = /^\.?\.\/|^\.\.?$/; -var isSlashDotSegment = /^\/\.(?:\/|$)/; -var isUpSegment = /^\/\.\.(?:\/|$)/; -var removeDotSegments = (path6) => { - let output = ""; - while (path6.length > 0) { - if (isNoOpSegment.test(path6)) { - path6 = removeSegment(path6); - } else if (isSlashDotSegment.test(path6)) { - path6 = replaceSegmentWithSlash(path6); - } else if (isUpSegment.test(path6)) { - path6 = replaceSegmentWithSlash(path6); - output = removeLastSegment(output); - } else { - const segment3 = getSegment(path6); - path6 = removeSegment(path6); - output += segment3; + return { value: parsed ?? {} }; +} +function mergeTopLevel(global, project) { + const result = {}; + if (isRecord(global)) { + for (const [key, value] of Object.entries(global)) { + result[key] = value; } } - return output; -}; -var removeSegment = (path6) => { - const position = path6.indexOf("/", 1); - return position === -1 ? "" : "/" + path6.slice(position + 1); -}; -var replaceSegmentWithSlash = (path6) => { - const position = path6.indexOf("/", 1); - return position === -1 ? "/" : "/" + path6.slice(position + 1); -}; -var removeLastSegment = (path6) => { - const position = path6.lastIndexOf("/"); - return position === -1 ? path6 : path6.slice(0, position); -}; -var getSegment = (path6) => { - const position = path6.indexOf("/", 1); - return position === -1 ? path6 : path6.slice(0, position); -}; -var composeIdentifier = (strategy, components) => { - let resolved = components.scheme.toLowerCase() + ":"; - resolved += components.authority === void 0 ? "" : "//" + (components.userinfo === void 0 ? "" : components.userinfo + "@") + components.host.toLowerCase() + (components.port === void 0 ? "" : ":" + components.port); - resolved += strategy.normalizePath(components.path); - resolved += components.query === void 0 ? "" : "?" + strategy.normalizeQuery(components.query); - resolved += components.fragment === void 0 ? "" : "#" + strategy.normalizeFragment(components.fragment); - return resolved; -}; -var percentEncoded = new RegExp(pctEncoded, "g"); -var percentEncodedToChar = (isAllowed) => (match) => { - const charCode = parseInt(match.slice(1), 16); - const char = String.fromCharCode(charCode); - return isAllowed(char) ? char : match.toUpperCase(); -}; -var isAllowedUnescapedInPath = RegExp.prototype.test.bind(new RegExp(`${unreserved}|${subDelims}|[:@]`)); -var isAllowedUnescapedInIPath = RegExp.prototype.test.bind(new RegExp(`${iunreserved}|${subDelims}|[:@]`, "u")); -var normalizePath = (isAllowed) => (segment3) => removeDotSegments(segment3).replaceAll(percentEncoded, percentEncodedToChar(isAllowed)); -var isAllowedUnescapedInQuery = RegExp.prototype.test.bind(new RegExp(`${unreserved}|${subDelims}|[:@/?]`)); -var isAllowedUnescapedInIQuery = RegExp.prototype.test.bind(new RegExp(`${iunreserved}|${subDelims}|[:@/?]`, "u")); -var normalizeQuery = (isAllowed) => (query3) => query3.replaceAll(percentEncoded, percentEncodedToChar(isAllowed)); -var isUri = RegExp.prototype.test.bind(new RegExp(uri)); -var isUriReference = RegExp.prototype.test.bind(new RegExp(uriReference)); -var isAbsoluteUri = RegExp.prototype.test.bind(new RegExp(absoluteUri)); -var isIri = RegExp.prototype.test.bind(new RegExp(iri, "u")); -var isIriReference = RegExp.prototype.test.bind(new RegExp(iriReference, "u")); -var isAbsoluteIri = RegExp.prototype.test.bind(new RegExp(absoluteIri, "u")); -var createParser = (pattern, type) => (value3) => { - const match = pattern.exec(value3); - if (match === null) { - throw Error(`Invalid ${type}: ${value3}`); - } - const groups = ( - /** @type Record */ - match.groups - ); - if (groups.authority === void 0) { - groups.path = groups.path2; - } - delete groups.path2; - return groups; -}; -var parseUri = createParser(new RegExp(uri), "URI"); -var parseUriReference = createParser(new RegExp(uriReference), "URI-reference"); -var parseAbsoluteUri = createParser(new RegExp(absoluteUri), "absolute-URI"); -var parseIri = createParser(new RegExp(iri, "u"), "IRI"); -var parseIriReference = createParser(new RegExp(iriReference, "u"), "IRI-reference"); -var parseAbsoluteIri = createParser(new RegExp(absoluteIri, "u"), "absolute-IRI"); -var strategies = { - uri: { - parseAbsolute: parseAbsoluteUri, - parseReference: parseUriReference, - parse: parseUri, - normalizePath: normalizePath(isAllowedUnescapedInPath), - normalizeQuery: normalizeQuery(isAllowedUnescapedInQuery), - normalizeFragment: normalizeQuery(isAllowedUnescapedInQuery) - }, - iri: { - parseAbsolute: parseAbsoluteIri, - parseReference: parseIriReference, - parse: parseIri, - normalizePath: normalizePath(isAllowedUnescapedInIPath), - normalizeQuery: normalizeQuery(isAllowedUnescapedInIQuery), - normalizeFragment: normalizeQuery(isAllowedUnescapedInIQuery) - } -}; -var toAbsolute = (strategy) => (identifier) => { - const components = strategy.parse(identifier); - delete components.fragment; - return composeIdentifier(strategy, components); -}; -var toAbsoluteUri = toAbsolute(strategies.uri); -var toAbsoluteIri = toAbsolute(strategies.iri); -var normalize = (strategy) => (identifier) => { - const components = strategy.parse(identifier); - return composeIdentifier(strategy, components); -}; -var normalizeUri = normalize(strategies.uri); -var normalizeIri = normalize(strategies.iri); -var resolveUri = resolveReference(strategies.uri); -var resolveIri = resolveReference(strategies.iri); -var toRelative = (strategy) => (uri4, relativeTo) => { - const fromUri = strategy.parseAbsolute(uri4); - const toUri = strategy.parse(relativeTo); - if (toUri.scheme !== fromUri.scheme) { - return relativeTo; - } - if (toUri.authority !== fromUri.authority) { - return relativeTo; - } - let result; - if (fromUri.path === toUri.path) { - result = ""; - } else { - const fromSegments = fromUri.path.split("/"); - const toSegments = toUri.path.split("/"); - let position = 0; - while (fromSegments[position] === toSegments[position] && position < fromSegments.length - 1 && position < toSegments.length - 1) { - position++; - } - const segments = []; - for (let index = position + 1; index < fromSegments.length; index++) { - segments.push(".."); - } - for (let index = position; index < toSegments.length; index++) { - segments.push(toSegments[index]); - } - result = segments.join("/"); + if (isRecord(project)) { + for (const [key, value] of Object.entries(project)) { + result[key] = value; + } } - if (toUri.query !== void 0) { - result += `?${toUri.query}`; + return result; +} +function projectPreferences(merged) { + const result = {}; + if (merged.platform !== void 0) { + result.platform = expectPlatform(merged.platform); + } + if (merged.project !== void 0) { + const section = expectRecord(merged.project, "project"); + const project = {}; + if (section.slug !== void 0) { + project.slug = expectString(section.slug, "project.slug"); + } + if (section.ticket_ref_prefix !== void 0) { + project.ticket_ref_prefix = expectString(section.ticket_ref_prefix, "project.ticket_ref_prefix"); + } + result.project = project; + } + if (merged.repository !== void 0) { + const section = expectRecord(merged.repository, "repository"); + const repository = {}; + if (section.slug !== void 0) { + repository.slug = expectString(section.slug, "repository.slug"); + } + if (section.default_remote !== void 0) { + const remoteSection = expectRecord(section.default_remote, "repository.default_remote"); + const defaultRemote = {}; + if (remoteSection.name !== void 0) { + defaultRemote.name = expectString(remoteSection.name, "repository.default_remote.name"); + } + if (remoteSection.default_branch !== void 0) { + defaultRemote.default_branch = expectString( + remoteSection.default_branch, + "repository.default_remote.default_branch" + ); + } + repository.default_remote = defaultRemote; + } + result.repository = repository; } - if (toUri.fragment !== void 0) { - result += `#${toUri.fragment}`; + if (merged.artifacts !== void 0) { + const section = expectRecord(merged.artifacts, "artifacts"); + const artifacts = {}; + if (section.base_dir !== void 0) { + artifacts.base_dir = expectString(section.base_dir, "artifacts.base_dir"); + } + if (section.paths !== void 0) { + const pathsSection = expectRecord(section.paths, "artifacts.paths"); + const paths = {}; + for (const [key, value] of Object.entries(pathsSection)) { + paths[key] = expectString(value, `artifacts.paths.${key}`); + } + artifacts.paths = paths; + } + result.artifacts = artifacts; } return result; -}; -var toRelativeUri = toRelative(strategies.uri); -var toRelativeIri = toRelative(strategies.iri); - -// ../../node_modules/.pnpm/@hyperjump+json-pointer@1.1.2/node_modules/@hyperjump/json-pointer/lib/index.js -var nil = ""; -var pointerSegments = function* (pointer) { - if (pointer.length > 0 && !pointer.startsWith("/")) { - throw Error("Invalid JSON Pointer"); - } - if (/~(?![01])/.test(pointer)) { - throw Error("Invalid JSON Pointer"); +} +function expectPlatform(value) { + if (value === "github" || value === "bitbucket") { + return value; } - let segmentStart = 1; - let segmentEnd = 0; - while (segmentEnd < pointer.length) { - const position = pointer.indexOf("/", segmentStart); - segmentEnd = position === -1 ? pointer.length : position; - const segment3 = pointer.slice(segmentStart, segmentEnd); - segmentStart = segmentEnd + 1; - yield unescape(segment3); + throw new Error(`preferences: 'platform' must be "github" or "bitbucket" (got ${formatValue(value)})`); +} +function expectString(value, keyPath) { + if (typeof value === "string") { + return value; } -}; -var get = (pointer, subject = void 0) => { - if (subject === void 0) { - const segments = [...pointerSegments(pointer)]; - return (subject2) => _get(segments, subject2); - } else { - return _get(pointerSegments(pointer), subject); + throw new Error(`preferences: '${keyPath}' must be a string (got ${formatValue(value)})`); +} +function expectRecord(value, keyPath) { + if (isRecord(value)) { + return value; } -}; -var _get = (segments, subject) => { - let cursor = nil; - for (const segment3 of segments) { - subject = applySegment(subject, segment3, cursor); - cursor = append(segment3, cursor); + throw new Error(`preferences: '${keyPath}' must be an object (got ${formatValue(value)})`); +} +function formatValue(value) { + if (typeof value === "string") { + return JSON.stringify(value); } - return subject; -}; -var append = (segment3, pointer) => pointer + "/" + escape(segment3); -var escape = (segment3) => segment3.toString().replace(/~/g, "~0").replace(/\//g, "~1"); -var unescape = (segment3) => segment3.toString().replace(/~1/g, "/").replace(/~0/g, "~"); -var computeSegment = (value3, segment3) => { - if (Array.isArray(value3)) { - return segment3 === "-" ? value3.length : parseInt(segment3, 10); - } else { - return segment3; + try { + return JSON.stringify(value); + } catch { + return String(value); } -}; -var applySegment = (value3, segment3, cursor = "") => { - if (value3 === void 0) { - throw TypeError(`Value at '${cursor}' is undefined and does not have property '${segment3}'`); - } else if (value3 === null) { - throw TypeError(`Value at '${cursor}' is null and does not have property '${segment3}'`); - } else if (isScalar(value3)) { - throw TypeError(`Value at '${cursor}' is a ${typeof value3} and does not have property '${segment3}'`); - } else { - const computedSegment = computeSegment(value3, segment3); - if (Object.hasOwn(value3, computedSegment)) { - return ( - /** @type API.JsonObject */ - value3[computedSegment] - ); - } +} +function isRecord(value) { + return typeof value === "object" && value !== null && !Array.isArray(value); +} +function isEnoentError(error) { + if (!isRecord(error)) { + return false; } -}; -var isScalar = (value3) => value3 === null || typeof value3 !== "object"; + return error.code === "ENOENT"; +} -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/common.js -var jsonTypeOf = (value3) => { - const jsType = typeof value3; - switch (jsType) { - case "number": - case "string": - case "boolean": - case "undefined": - return jsType; - case "object": - if (Array.isArray(value3)) { - return "array"; - } else if (value3 === null) { - return "null"; - } else if (Object.getPrototypeOf(value3) === Object.prototype) { - return "object"; - } - default: { - const type = jsType === "object" ? Object.getPrototypeOf(value3).constructor.name || "anonymous" : jsType; - throw Error(`Not a JSON compatible type: ${type}`); - } +// src/derive-session-context/cli.ts +var execFileAsync = promisify(execFile); +var REQUIRED_MANIFEST_FIELDS = [ + "ticket_id", + "ticket_ref", + "project_slug", + "platform", + "default_branch", + "branch_name", + "artifact_base_dir", + "artifact_paths", + "created_at" +]; +async function main() { + try { + const parsed = parseArgs(process.argv.slice(2)); + const cwd = parsed.cwd ?? process.cwd(); + const branch = parsed.branch ?? await resolveCurrentBranch(cwd); + const manifest = await deriveSessionContext({ + cwd, + branch, + now: /* @__PURE__ */ new Date(), + ...parsed.home !== null && { home: parsed.home } + }); + process.stdout.write(`${JSON.stringify(manifest, null, 2)} +`); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + process.stderr.write(`derive-session-context: ${message} +`); + process.exit(1); } -}; -var toAbsoluteUri2 = (uri4) => { - const position = uri4.indexOf("#"); - const end = position === -1 ? uri4.length : position; - return uri4.slice(0, end); -}; -var uriFragment = (uri4) => decodeURIComponent(parseIriReference(uri4).fragment || ""); - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords.js -var _keywords = {}; -var getKeyword = (id62) => { - if (id62.indexOf("#") !== -1) { - const absoluteId = toAbsoluteUri2(id62); - return { ..._keywords[absoluteId], id: id62 }; +} +async function deriveSessionContext(input) { + if (input.branch === "" || input.branch === "HEAD") { + throw new Error("Detached HEAD: this script requires an active branch. Create or check out a branch first."); } - return _keywords[id62]; -}; -var getKeywordByName = (keyword, dialectId) => { - const keywordId = getKeywordId(keyword, dialectId); - if (!keywordId) { - throw Error(`Encountered unknown keyword '${keyword}'`); + const home = input.home ?? homedir2(); + const sanitizedBranch = sanitizeBranch(input.branch); + const newPath = path3.join(input.cwd, ".agents", `${sanitizedBranch}.branch-manifest.json`); + const oldPath = path3.join(input.cwd, ".agents", `${sanitizedBranch}.manifest.json`); + const cached = await tryReadManifest(newPath); + if (cached !== null) { + return cached; } - const keywordHandler = getKeyword(keywordId); - if (!keywordHandler) { - throw Error(`Encountered unsupported keyword ${keyword}. You can provide an implementation for the '${keywordId}' keyword using the 'addKeyword' function.`); + const cachedOld = await tryReadManifest(oldPath); + if (cachedOld !== null) { + await mkdir(path3.dirname(newPath), { recursive: true }); + await writeFile(newPath, `${JSON.stringify(cachedOld, null, 2)} +`, "utf8"); + return cachedOld; } - return keywordHandler; -}; -var addKeyword = (keywordHandler) => { - _keywords[keywordHandler.id] = keywordHandler; -}; -var _vocabularies = {}; -var defineVocabulary = (id62, keywords) => { - _vocabularies[id62] = keywords; -}; -var _formats = {}; -var getFormatHandler = (formatUri) => { - return _formats[formatUri]; -}; -var _dialects = {}; -var getKeywordId = (keyword, dialectId) => { - const dialect = getDialect(dialectId); - return dialect.keywords[keyword] ?? (dialect.allowUnknownKeywords || keyword.startsWith("x-") ? `https://json-schema.org/keyword/unknown#${keyword}` : void 0); -}; -var getKeywordName = (dialectId, keywordId) => { - const dialect = getDialect(dialectId); - for (const keyword in dialect.keywords) { - if (dialect.keywords[keyword] === keywordId) { - return keyword; + const readResult = await readPreferences({ cwd: input.cwd, home }); + const manifest = composeManifest({ + preferences: readResult.preferences, + branchName: input.branch, + cwd: input.cwd, + home, + now: input.now + }); + await mkdir(path3.dirname(newPath), { recursive: true }); + await writeFile(newPath, `${JSON.stringify(manifest, null, 2)} +`, "utf8"); + return manifest; +} +function sanitizeBranch(branch) { + let sanitized = branch.trim().replaceAll("/", "-"); + while (sanitized.endsWith("-")) { + sanitized = sanitized.slice(0, -1); + } + return sanitized; +} +async function tryReadManifest(filePath) { + let text; + try { + text = await readFile2(filePath, "utf8"); + } catch (error) { + if (isEnoentError2(error)) { + return null; } + throw error; } -}; -var getDialect = (dialectId) => { - if (!(dialectId in _dialects)) { - throw Error(`Encountered unknown dialect '${dialectId}'`); + let parsed; + try { + parsed = JSON.parse(text); + } catch { + process.stderr.write(`derive-session-context: warning: manifest at ${filePath} is corrupt; recomposing +`); + return null; } - return _dialects[dialectId]; -}; -var loadDialect = (dialectId, dialect, allowUnknownKeywords = false, isPersistent = true) => { - _dialects[dialectId] = { - keywords: {}, - allowUnknownKeywords, - persistentDialects: _dialects[dialectId]?.persistentDialects || isPersistent - }; - for (const vocabularyId in dialect) { - if (vocabularyId in _vocabularies) { - for (const keyword in _vocabularies[vocabularyId]) { - let keywordId = _vocabularies[vocabularyId][keyword]; - if (!dialect[vocabularyId]) { - if (vocabularyId === "https://json-schema.org/draft/2019-09/vocab/format") { - keywordId = "https://json-schema.org/keyword/draft-2019-09/format"; - } else if (!(keywordId in _keywords)) { - keywordId = `https://json-schema.org/keyword/unknown#${keyword}`; - } - } - _dialects[dialectId].keywords[keyword] = keywordId; - } - } else if (!allowUnknownKeywords || dialect[vocabularyId]) { - delete _dialects[dialectId]; - throw Error(`Unrecognized vocabulary: ${vocabularyId}. You can define this vocabulary with the 'defineVocabulary' function.`); - } + if (!isCurrentSchema(parsed)) { + return null; } -}; - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/media-types/media-types.js -var import_content_type = __toESM(require_content_type(), 1); -var mediaTypePlugins = {}; -var addMediaTypePlugin = (contentType, plugin5) => { - mediaTypePlugins[contentType] = plugin5; -}; -var parseResponse = (response) => { - const contentTypeText = response.headers.get("content-type"); - if (contentTypeText === null) { - throw new UnknownMediaTypeError("The media type of the response could not be determined. Make sure the response includes a 'Content-Type' header.", { cause: response }); + return parsed; +} +function isCurrentSchema(value) { + if (!isRecord2(value)) { + return false; } - const contentType = (0, import_content_type.parse)(contentTypeText); - for (const pattern in mediaTypePlugins) { - if (mimeMatch(pattern, contentType.type)) { - return mediaTypePlugins[pattern].parse(response); + for (const field of REQUIRED_MANIFEST_FIELDS) { + if (!(field in value)) { + return false; } } - throw new UnsupportedMediaTypeError(contentType.type, `'${contentType.type}' is not supported. Use the 'addMediaTypePlugin' function to add support for this media type.`, { - cause: response - }); -}; -var alpha = `A-Za-z`; -var token = `[!#$%&'*\\-_.^\`|~\\d${alpha}]+`; -var mediaRange = `(?${token})/(?${token}(?:\\+(?${token}))?)`; -var mediaRangePattern = new RegExp(mediaRange); -var mimeMatch = (expected, actual) => { - if (expected === actual) { - return true; + if (!isStringOrNull(value.ticket_id) || !isStringOrNull(value.ticket_ref)) { + return false; } - const expectedMatches = mediaRangePattern.exec(expected)?.groups; - if (!expectedMatches) { - throw Error(`Unable to parse media-range: ${expected}`); + if (!isRecord2(value.artifact_paths)) { + return false; } - const actualMatches = mediaRangePattern.exec(actual)?.groups; - if (!actualMatches) { - throw Error(`Unable to parse media-type: ${actual}`); - } - if (expectedMatches.type === actualMatches.type || expectedMatches.type === "*") { - if (expectedMatches.subType === actualMatches.subType || expectedMatches.subType === "*") { - return true; - } - if (expectedMatches.subType === actualMatches.suffix) { - return true; - } - } - return false; -}; -var getFileMediaType = async (path6) => { - for (const contentType in mediaTypePlugins) { - if (await mediaTypePlugins[contentType].fileMatcher(path6)) { - return contentType; - } - } - throw new UnknownMediaTypeError(`The media type of the file at '${path6}' could not be determined. Use the 'addMediaTypePlugin' function to add support for this media type.`); -}; -var acceptableMediaTypes = () => { - let accept = ""; - for (const contentType in mediaTypePlugins) { - accept = addAcceptableMediaType(accept, contentType, mediaTypePlugins[contentType].quality); - } - return addAcceptableMediaType(accept, "*/*", "0.001"); -}; -var addAcceptableMediaType = (accept, contentType, quality) => { - if (accept.length > 0) { - accept += ", "; - } - accept += contentType; - if (quality) { - accept += `; q=${quality}`; - } - return accept; -}; -var UnsupportedMediaTypeError = class extends Error { - constructor(mediaType, message = void 0) { - super(message); - this.name = this.constructor.name; - this.mediaType = mediaType; - } -}; -var UnknownMediaTypeError = class extends Error { - constructor(message = void 0) { - super(message); - this.name = this.constructor.name; - } -}; - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/jref/index.js -var parse = (jref, reviver = void 0) => { - return JSON.parse(jref, (key, value3) => { - const newValue = value3 !== null && typeof value3.$ref === "string" ? new Reference(value3.$ref) : value3; - return reviver ? reviver(key, newValue) : newValue; - }); -}; -var Reference = class { - #href; - #value; - constructor(href, value3 = void 0) { - this.#href = href; - this.#value = value3 ?? { $ref: href }; - } - get href() { - return this.#href; - } - toJSON() { - return this.#value; - } -}; -var jrefTypeOf = (value3) => { - const jsType = typeof value3; - switch (jsType) { - case "bigint": - return "number"; - case "number": - case "string": - case "boolean": - case "undefined": - return jsType; - case "object": - if (value3 instanceof Reference) { - return "reference"; - } else if (Array.isArray(value3)) { - return "array"; - } else if (value3 === null) { - return "null"; - } else if (Object.getPrototypeOf(value3) === Object.prototype || Object.getPrototypeOf(value3) === null) { - return "object"; - } - default: { - const type = jsType === "object" ? Object.getPrototypeOf(value3).constructor.name || "anonymous" : jsType; - throw Error(`Not a JRef compatible type: ${type}`); - } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/media-types/jref-media-type-plugin.js -var jrefMediaTypePlugin = { - parse: async (response) => { - return { - baseUri: response.url, - root: parse(await response.text()), - anchorLocation - }; - }, - fileMatcher: (path6) => /[^/]\.jref$/.test(path6) -}; -var anchorLocation = (fragment3) => decodeURI(fragment3 || ""); - -// ../../node_modules/.pnpm/@hyperjump+uri@1.3.4/node_modules/@hyperjump/uri/lib/index.js -var hexdig2 = `[a-fA-F0-9]`; -var unreserved2 = `[a-zA-Z0-9-._~]`; -var subDelims2 = `[!$&'()*+,;=]`; -var pctEncoded2 = `%${hexdig2}${hexdig2}`; -var decOctet2 = `(?:\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])`; -var ipV4Address2 = `${decOctet2}\\.${decOctet2}\\.${decOctet2}\\.${decOctet2}`; -var h162 = `${hexdig2}{1,4}`; -var ls322 = `(?:${h162}:${h162}|${ipV4Address2})`; -var ipV6Address2 = `(?:(?:${h162}:){6}${ls322}|::(?:${h162}:){5}${ls322}|(?:${h162})?::(?:${h162}:){4}${ls322}|(?:(?:${h162}:){0,1}${h162})?::(?:${h162}:){3}${ls322}|(?:(?:${h162}:){0,2}${h162})?::(?:${h162}:){2}${ls322}|(?:(?:${h162}:){0,3}${h162})?::(?:${h162}:){1}${ls322}|(?:(?:${h162}:){0,4}${h162})?::${ls322}|(?:(?:${h162}:){0,5}${h162})?::${h162}|(?:(?:${h162}:){0,6}${h162})?::)`; -var ipVFuture2 = `[vV]${hexdig2}+\\.(?:${unreserved2}|${subDelims2}|:)+`; -var ipLiteral2 = `\\[(?:${ipV6Address2}|${ipVFuture2})\\]`; -var scheme2 = `(?[a-zA-Z][a-zA-Z0-9-+.]*)`; -var port2 = `:(?\\d*)`; -var regName2 = `(?:${unreserved2}|${pctEncoded2}|${subDelims2})*?`; -var host2 = `(?${ipLiteral2}|${ipV4Address2}|${regName2})`; -var userinfo2 = `(?(?:${unreserved2}|${pctEncoded2}|${subDelims2}|:)*)`; -var pchar2 = `(?:${unreserved2}|${pctEncoded2}|${subDelims2}|:|@)`; -var segment2 = `${pchar2}*?`; -var pathAbEmpty2 = `(?:/${segment2})*`; -var authority2 = `(?(?:${userinfo2}@)?${host2}(?:${port2})?)`; -var path3 = `(?${pathAbEmpty2})`; -var pathWithoutAuthority2 = `(?(?!//)${segment2}${pathAbEmpty2})`; -var query2 = `(?:\\?(?(?:${pchar2}|/|\\?)*))?`; -var fragment2 = `(?:#(?(?:${pchar2}|/|\\?)*))?`; -var uri2 = `^${scheme2}:(?://${authority2}${path3}|${pathWithoutAuthority2})${query2}${fragment2}$`; -var uriReference2 = `^(?:${scheme2}:|)(?://${authority2}${path3}|${pathWithoutAuthority2})${query2}${fragment2}$`; -var absoluteUri2 = `^${scheme2}:(?://${authority2}${path3}|${pathWithoutAuthority2})${query2}$`; -var iunreserved2 = `[a-zA-Z0-9\\-._~\\u{A0}-\\u{D7FF}\\u{F900}-\\u{FDCF}\\u{FDF0}-\\u{FFEF}\\u{10000}-\\u{1FFFD}\\u{20000}-\\u{2FFFD}\\u{30000}-\\u{3FFFD}\\u{40000}-\\u{4FFFD}\\u{50000}-\\u{5FFFD}\\u{60000}-\\u{6FFFD}\\u{70000}-\\u{7FFFD}\\u{80000}-\\u{8FFFD}\\u{90000}-\\u{9FFFD}\\u{A0000}-\\u{AFFFD}\\u{B0000}-\\u{BFFFD}\\u{C0000}-\\u{CFFFD}\\u{D0000}-\\u{DFFFD}\\u{E1000}-\\u{EFFFD}]`; -var iprivate2 = `[\\u{E000}-\\u{F8FF}\\u{F0000}-\\u{FFFFD}\\u{100000}-\\u{10FFFD}]`; -var iregName2 = `(?:${iunreserved2}|${pctEncoded2}|${subDelims2})*?`; -var ihost2 = `(?${ipLiteral2}|${ipV4Address2}|${iregName2})`; -var iuserinfo2 = `(?(?:${iunreserved2}|${pctEncoded2}|${subDelims2}|:)*)`; -var ipchar2 = `(?:${iunreserved2}|${pctEncoded2}|${subDelims2}|:|@)`; -var isegment2 = `${ipchar2}*?`; -var ipathAbEmpty2 = `(?:/${isegment2})*`; -var iauthority2 = `(?(?:${iuserinfo2}@)?${ihost2}(?:${port2})?)`; -var ipath2 = `(?${ipathAbEmpty2})`; -var ipathWithoutAuthority2 = `(?(?!//)${isegment2}${ipathAbEmpty2})`; -var iquery2 = `(?:\\?(?(?:${ipchar2}|${iprivate2}|/|\\?)*))?`; -var ifragment2 = `(?:#(?(?:${ipchar2}|/|\\?)*))?`; -var iri2 = `^${scheme2}:(?://${iauthority2}${ipath2}|${ipathWithoutAuthority2})${iquery2}${ifragment2}$`; -var iriReference2 = `^(?:${scheme2}:|)(?://${iauthority2}${ipath2}|${ipathWithoutAuthority2})${iquery2}${ifragment2}$`; -var absoluteIri2 = `^${scheme2}:(?://${iauthority2}${ipath2}|${ipathWithoutAuthority2})${iquery2}$`; -var resolveReference2 = (strategy) => (reference, base) => { - const resolvedComponents = ( - /** @type API.IdentifierComponents */ - strategy.parseReference(reference) - ); - if (resolvedComponents.scheme === void 0) { - const baseComponents = strategy.parseAbsolute(base); - resolvedComponents.scheme = baseComponents.scheme; - if (resolvedComponents.authority === void 0) { - resolvedComponents.authority = baseComponents.authority; - resolvedComponents.userinfo = baseComponents.userinfo; - resolvedComponents.host = baseComponents.host; - resolvedComponents.port = baseComponents.port; - if (resolvedComponents.path === "") { - resolvedComponents.path = baseComponents.path; - resolvedComponents.query ??= baseComponents.query; - } else if (!resolvedComponents.path.startsWith("/")) { - resolvedComponents.path = mergePaths2(resolvedComponents.path, baseComponents); - } - } - } - return composeIdentifier2(strategy, resolvedComponents); -}; -var mergePaths2 = (path6, base) => { - if (base.authority && base.path === "") { - return "/" + path6; - } else { - const position = base.path.lastIndexOf("/"); - return position === -1 ? path6 : base.path.slice(0, position + 1) + path6; - } -}; -var isNoOpSegment2 = /^\.?\.\/|^\.\.?$/; -var isSlashDotSegment2 = /^\/\.(?:\/|$)/; -var isUpSegment2 = /^\/\.\.(?:\/|$)/; -var removeDotSegments2 = (path6) => { - let output = ""; - while (path6.length > 0) { - if (isNoOpSegment2.test(path6)) { - path6 = removeSegment2(path6); - } else if (isSlashDotSegment2.test(path6)) { - path6 = replaceSegmentWithSlash2(path6); - } else if (isUpSegment2.test(path6)) { - path6 = replaceSegmentWithSlash2(path6); - output = removeLastSegment2(output); - } else { - const segment3 = getSegment2(path6); - path6 = removeSegment2(path6); - output += segment3; - } - } - return output; -}; -var removeSegment2 = (path6) => { - const position = path6.indexOf("/", 1); - return position === -1 ? "" : "/" + path6.slice(position + 1); -}; -var replaceSegmentWithSlash2 = (path6) => { - const position = path6.indexOf("/", 1); - return position === -1 ? "/" : "/" + path6.slice(position + 1); -}; -var removeLastSegment2 = (path6) => { - const position = path6.lastIndexOf("/"); - return position === -1 ? path6 : path6.slice(0, position); -}; -var getSegment2 = (path6) => { - const position = path6.indexOf("/", 1); - return position === -1 ? path6 : path6.slice(0, position); -}; -var composeIdentifier2 = (strategy, components) => { - let resolved = components.scheme.toLowerCase() + ":"; - resolved += components.authority === void 0 ? "" : "//" + (components.userinfo === void 0 ? "" : components.userinfo + "@") + components.host.toLowerCase() + (components.port === void 0 ? "" : ":" + components.port); - resolved += strategy.normalizePath(components.path); - resolved += components.query === void 0 ? "" : "?" + strategy.normalizeQuery(components.query); - resolved += components.fragment === void 0 ? "" : "#" + strategy.normalizeFragment(components.fragment); - return resolved; -}; -var percentEncoded2 = new RegExp(pctEncoded2, "g"); -var percentEncodedToChar2 = (isAllowed) => (match) => { - const charCode = parseInt(match.slice(1), 16); - const char = String.fromCharCode(charCode); - return isAllowed(char) ? char : match.toUpperCase(); -}; -var isAllowedUnescapedInPath2 = RegExp.prototype.test.bind(new RegExp(`${unreserved2}|${subDelims2}|[:@]`)); -var isAllowedUnescapedInIPath2 = RegExp.prototype.test.bind(new RegExp(`${iunreserved2}|${subDelims2}|[:@]`, "u")); -var normalizePath2 = (isAllowed) => (segment3) => removeDotSegments2(segment3).replaceAll(percentEncoded2, percentEncodedToChar2(isAllowed)); -var isAllowedUnescapedInQuery2 = RegExp.prototype.test.bind(new RegExp(`${unreserved2}|${subDelims2}|[:@/?]`)); -var isAllowedUnescapedInIQuery2 = RegExp.prototype.test.bind(new RegExp(`${iunreserved2}|${subDelims2}|[:@/?]`, "u")); -var normalizeQuery2 = (isAllowed) => (query3) => query3.replaceAll(percentEncoded2, percentEncodedToChar2(isAllowed)); -var isUri2 = RegExp.prototype.test.bind(new RegExp(uri2)); -var isUriReference2 = RegExp.prototype.test.bind(new RegExp(uriReference2)); -var isAbsoluteUri2 = RegExp.prototype.test.bind(new RegExp(absoluteUri2)); -var isIri2 = RegExp.prototype.test.bind(new RegExp(iri2, "u")); -var isIriReference2 = RegExp.prototype.test.bind(new RegExp(iriReference2, "u")); -var isAbsoluteIri2 = RegExp.prototype.test.bind(new RegExp(absoluteIri2, "u")); -var createParser2 = (pattern, type) => (value3) => { - const match = pattern.exec(value3); - if (match === null) { - throw Error(`Invalid ${type}: ${value3}`); - } - const groups = ( - /** @type Record */ - match.groups - ); - if (groups.authority === void 0) { - groups.path = groups.path2; - } - delete groups.path2; - return groups; -}; -var parseUri2 = createParser2(new RegExp(uri2), "URI"); -var parseUriReference2 = createParser2(new RegExp(uriReference2), "URI-reference"); -var parseAbsoluteUri2 = createParser2(new RegExp(absoluteUri2), "absolute-URI"); -var parseIri2 = createParser2(new RegExp(iri2, "u"), "IRI"); -var parseIriReference2 = createParser2(new RegExp(iriReference2, "u"), "IRI-reference"); -var parseAbsoluteIri2 = createParser2(new RegExp(absoluteIri2, "u"), "absolute-IRI"); -var strategies2 = { - uri: { - parseAbsolute: parseAbsoluteUri2, - parseReference: parseUriReference2, - parse: parseUri2, - normalizePath: normalizePath2(isAllowedUnescapedInPath2), - normalizeQuery: normalizeQuery2(isAllowedUnescapedInQuery2), - normalizeFragment: normalizeQuery2(isAllowedUnescapedInQuery2) - }, - iri: { - parseAbsolute: parseAbsoluteIri2, - parseReference: parseIriReference2, - parse: parseIri2, - normalizePath: normalizePath2(isAllowedUnescapedInIPath2), - normalizeQuery: normalizeQuery2(isAllowedUnescapedInIQuery2), - normalizeFragment: normalizeQuery2(isAllowedUnescapedInIQuery2) - } -}; -var toAbsolute2 = (strategy) => (identifier) => { - const components = strategy.parse(identifier); - delete components.fragment; - return composeIdentifier2(strategy, components); -}; -var toAbsoluteUri3 = toAbsolute2(strategies2.uri); -var toAbsoluteIri2 = toAbsolute2(strategies2.iri); -var normalize2 = (strategy) => (identifier) => { - const components = strategy.parse(identifier); - return composeIdentifier2(strategy, components); -}; -var normalizeUri2 = normalize2(strategies2.uri); -var normalizeIri2 = normalize2(strategies2.iri); -var resolveUri2 = resolveReference2(strategies2.uri); -var resolveIri2 = resolveReference2(strategies2.iri); -var toRelative2 = (strategy) => (uri4, relativeTo) => { - const fromUri = strategy.parseAbsolute(uri4); - const toUri = strategy.parse(relativeTo); - if (toUri.scheme !== fromUri.scheme) { - return relativeTo; - } - if (toUri.authority !== fromUri.authority) { - return relativeTo; - } - let result; - if (fromUri.path === toUri.path) { - result = ""; - } else { - const fromSegments = fromUri.path.split("/"); - const toSegments = toUri.path.split("/"); - let position = 0; - while (fromSegments[position] === toSegments[position] && position < fromSegments.length - 1 && position < toSegments.length - 1) { - position++; - } - const segments = []; - for (let index = position + 1; index < fromSegments.length; index++) { - segments.push(".."); - } - for (let index = position; index < toSegments.length; index++) { - segments.push(toSegments[index]); - } - result = segments.join("/"); - } - if (toUri.query !== void 0) { - result += `?${toUri.query}`; - } - if (toUri.fragment !== void 0) { - result += `#${toUri.fragment}`; - } - return result; -}; -var toRelativeUri2 = toRelative2(strategies2.uri); -var toRelativeIri2 = toRelative2(strategies2.iri); - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/uri-schemes/uri-schemes.js -var uriSchemePlugins = {}; -var addUriSchemePlugin = (scheme3, plugin5) => { - uriSchemePlugins[scheme3] = plugin5; -}; -var retrieve = (uri4, baseUri) => { - uri4 = resolveIri2(uri4, baseUri); - const { scheme: scheme3 } = parseIri2(uri4); - if (!(scheme3 in uriSchemePlugins)) { - throw new UnsupportedUriSchemeError(scheme3, `The '${scheme3}:' URI scheme is not supported. Use the 'addUriSchemePlugin' function to add support for '${scheme3}:' URIs.`); - } - return uriSchemePlugins[scheme3].retrieve(uri4, baseUri); -}; -var UnsupportedUriSchemeError = class extends Error { - constructor(scheme3, message = void 0) { - super(message); - this.name = this.constructor.name; - this.scheme = scheme3; - } -}; - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/uri-schemes/http-scheme-plugin.js -var successStatus = /* @__PURE__ */ new Set([200, 203]); -var retrieve2 = async (uri4) => { - const response = await fetch(uri4, { headers: { Accept: acceptableMediaTypes() } }); - if (response.status >= 400) { - throw new HttpError(response, `Failed to retrieve '${uri4}'`); - } - if (!successStatus.has(response.status)) { - throw new HttpError(response, "Unsupported HTTP response status code"); - } - return response; -}; -var httpSchemePlugin = { retrieve: retrieve2 }; -var HttpError = class extends Error { - constructor(response, message = void 0) { - super(`${response.status} ${response.statusText}${message ? ` -- ${message}` : ""}`); - this.name = this.constructor.name; - this.response = response; - } -}; - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/uri-schemes/file-scheme-plugin.js -import { createReadStream } from "node:fs"; -import { readlink, lstat } from "node:fs/promises"; -import { fileURLToPath, pathToFileURL } from "node:url"; -var retrieve3 = async (uri4, baseUri) => { - const { scheme: scheme3 } = parseIri2(baseUri); - if (baseUri) { - if (scheme3 !== "file") { - throw Error(`Accessing a file (${uri4}) from a non-filesystem document (${baseUri}) is not allowed`); - } - } - let responseUri = toAbsoluteIri2(uri4); - const filePath = fileURLToPath(uri4); - const stats = await lstat(filePath); - if (stats.isSymbolicLink()) { - responseUri = pathToFileURL(await readlink(filePath)).toString(); - } - const contentType = await getFileMediaType(responseUri); - const stream = createReadStream(filePath); - const response = new Response(stream, { - headers: { "Content-Type": contentType } - }); - Object.defineProperty(response, "url", { value: responseUri }); - return response; -}; -var fileSchemePlugin = { retrieve: retrieve3 }; - -// ../../node_modules/.pnpm/just-curry-it@5.3.0/node_modules/just-curry-it/index.mjs -var functionCurry = curry; -function curry(fn, arity) { - return function curried() { - if (arity == null) { - arity = fn.length; - } - var args = [].slice.call(arguments); - if (args.length >= arity) { - return fn.apply(this, args); - } else { - return function() { - return curried.apply(this, args.concat([].slice.call(arguments))); - }; - } - }; -} - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/browser/context-uri.js -import { cwd } from "node:process"; -import { pathToFileURL as pathToFileURL2 } from "node:url"; -var contextUri = () => pathToFileURL2(cwd()) + "/"; - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/browser/browser.js -var get2 = async (uri4, browser = { _cache: {} }) => { - const baseUri = browser.document?.baseUri ?? contextUri(); - uri4 = resolveIri2(uri4, baseUri); - const id62 = toAbsoluteIri2(uri4); - const { fragment: fragment3 } = parseIri2(uri4); - const cachedDocument = browser._cache[id62] ?? browser.document?.embedded?.[id62]; - if (cachedDocument) { - browser.document = cachedDocument; - browser.uri = uri4; - browser.cursor = browser.document.anchorLocation(fragment3); - } else { - try { - const response = await retrieve(uri4, baseUri); - browser.document = await parseResponse(response); - browser.uri = response.url + (fragment3 === void 0 ? "" : `#${fragment3}`); - browser.cursor = browser.document.anchorLocation(fragment3); - } catch (error) { - const referencedMessage = browser.uri ? ` Referenced from '${browser.uri}'.` : ""; - throw new RetrievalError(`Unable to load resource '${uri4}'.${referencedMessage}`, error); - } - browser._cache[id62] = browser.document; - } - browser._value = get(browser.cursor, browser.document.root); - return followReferences(browser); -}; -var followReferences = (browser) => jrefTypeOf(value(browser)) === "reference" ? get2(value(browser).href, browser) : browser; -var value = (browser) => browser._value; -var typeOf = (browser) => jrefTypeOf(browser._value); -var has = (key, browser) => key in browser._value; -var length = (browser) => browser._value.length; -var step = functionCurry((key, browser) => { - return followReferences({ - ...browser, - cursor: append(`${key}`, browser.cursor), - _value: browser._value[key] - }); -}); -var iter = async function* (browser) { - for (let index = 0; index < value(browser).length; index++) { - yield step(index, browser); - } -}; -var keys = function* (browser) { - for (const key in value(browser)) { - yield key; - } -}; -var values = async function* (browser) { - for (const key in value(browser)) { - yield step(key, browser); - } -}; -var entries = async function* (browser) { - for (const key in value(browser)) { - yield [key, await step(key, browser)]; - } -}; -var RetrievalError = class extends Error { - constructor(message, cause) { - super(message, { cause }); - this.name = this.constructor.name; - } -}; - -// ../../node_modules/.pnpm/@hyperjump+browser@1.3.1/node_modules/@hyperjump/browser/lib/index.js -addMediaTypePlugin("application/reference+json", jrefMediaTypePlugin); -addUriSchemePlugin("http", httpSchemePlugin); -addUriSchemePlugin("https", httpSchemePlugin); -addUriSchemePlugin("file", fileSchemePlugin); - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/schema.js -var import_content_type2 = __toESM(require_content_type(), 1); -var schemaPlugin = { - parse: async (response) => { - const contentType = import_content_type2.default.parse(response.headers.get("content-type") ?? ""); - const contextDialectId = contentType.parameters.schema ?? contentType.parameters.profile; - return buildSchemaDocument(await response.json(), response.url, contextDialectId); - }, - fileMatcher: async (path6) => /(\.|\/)schema\.json$/.test(path6) -}; -var schemaRegistry = {}; -var getSchema = async (uri4, browser = void 0) => { - if (!browser) { - browser = { _cache: {} }; - } - for (const uri5 in schemaRegistry) { - if (!(uri5 in browser._cache)) { - browser._cache[uri5] = schemaRegistry[uri5]; - } - } - const schema = await get2(uri4, { ...browser }); - if (typeof schema.document.dialectId !== "string") { - throw Error(`The document at ${schema.document.baseUri} is not a schema.`); - } - return schema; -}; -var registerSchema = (schema, retrievalUri, contextDialectId) => { - schema = structuredClone(schema); - const document = buildSchemaDocument(schema, retrievalUri, contextDialectId); - if (document.baseUri in schemaRegistry) { - throw Error(`A schema has already been registered for '${document.baseUri}. You can use 'unregisterSchema' to remove the old schema before registering the new one.`); - } - if (document.baseUri.startsWith("file:")) { - throw Error(`Registering a schema with a 'file:' URI scheme is not allowed: ${document.baseUri}`); - } - schemaRegistry[retrievalUri ? toAbsoluteIri(retrievalUri) : document.baseUri] = document; -}; -var hasSchema = (uri4) => uri4 in schemaRegistry; -var buildSchemaDocument = (schema, id62, dialectId, embedded = {}) => { - if (typeof schema.$schema === "string") { - dialectId = schema.$schema; - delete schema.$schema; - } - if (!dialectId) { - throw Error("Unable to determine a dialect for the schema. The dialect can be declared in a number of ways, but the recommended way is to use the '$schema' keyword in your schema."); - } - dialectId = toAbsoluteIri(dialectId); - const legacyIdToken = getKeywordName(dialectId, "https://json-schema.org/keyword/draft-04/id"); - const idToken = getKeywordName(dialectId, "https://json-schema.org/keyword/id") || legacyIdToken; - if (!schema[idToken] && !id62) { - throw Error(`Unable to determine an identifier for the schema. Use the '${idToken}' keyword or pass a retrievalUri when loading the schema.`); - } - const resolvedId = resolveIri(schema[idToken] ?? "", id62 ?? ""); - id62 = toAbsoluteIri(resolvedId); - if (legacyIdToken && resolvedId.length > id62.length) { - schema[idToken] = "#" + uriFragment(resolvedId); - } else { - delete schema[idToken]; - } - const vocabularyToken = getKeywordName(dialectId, "https://json-schema.org/keyword/vocabulary"); - if (jsonTypeOf(schema[vocabularyToken]) === "object") { - const allowUnknownKeywords = schema[vocabularyToken]["https://json-schema.org/draft/2019-09/vocab/core"] || schema[vocabularyToken]["https://json-schema.org/draft/2020-12/vocab/core"]; - loadDialect(id62, schema[vocabularyToken], allowUnknownKeywords, false); - delete schema[vocabularyToken]; - } - const anchors = { "": "" }; - const dynamicAnchors = {}; - const recursiveAnchorToken = getKeywordName(dialectId, "https://json-schema.org/keyword/draft-2019-09/recursiveAnchor"); - if (schema[recursiveAnchorToken] === true) { - dynamicAnchors[""] = `${id62}#`; - } - delete schema[recursiveAnchorToken]; - embedded[id62] = { - baseUri: id62, - dialectId, - root: processSchema(schema, id62, dialectId, "", embedded, anchors, dynamicAnchors), - anchorLocation: (fragment3) => { - if (fragment3 === void 0) { - return ""; - } - fragment3 = decodeURI(fragment3); - if (fragment3[0] === "/") { - return fragment3; - } else if (!(fragment3 in anchors)) { - throw Error(`No such anchor '${id62}#${encodeURI(fragment3)}'`); - } else { - return anchors[fragment3]; - } - }, - anchors, - dynamicAnchors, - embedded - }; - return embedded[id62]; -}; -var processSchema = (json, id62, dialectId, cursor, embedded, anchors, dynamicAnchors) => { - if (jsonTypeOf(json) === "object") { - const embeddedDialectId = typeof json.$schema === "string" ? toAbsoluteIri(json.$schema) : dialectId; - const idToken = getKeywordName(embeddedDialectId, "https://json-schema.org/keyword/id"); - if (typeof json[idToken] === "string") { - const embeddedId = toAbsoluteIri(resolveIri(json[idToken], id62)); - json[idToken] = embeddedId; - embedded[embeddedId] = buildSchemaDocument(json, embeddedId, embeddedDialectId, embedded); - return new Reference(embeddedId, {}); - } - const legacyIdToken = getKeywordName(embeddedDialectId, "https://json-schema.org/keyword/draft-04/id"); - if (typeof json[legacyIdToken] === "string") { - if (json[legacyIdToken][0] === "#") { - const anchor = decodeURIComponent(json[legacyIdToken].slice(1)); - anchors[anchor] = cursor; - delete json[legacyIdToken]; - } else { - const embeddedId = toAbsoluteIri(resolveIri(json[legacyIdToken], id62)); - json[legacyIdToken] = embeddedId; - embedded[embeddedId] = buildSchemaDocument(json, embeddedId, embeddedDialectId, embedded); - return new Reference(embeddedId, {}); - } - } - const jrefToken = getKeywordName(dialectId, "https://json-schema.org/keyword/draft-04/ref"); - if (typeof json[jrefToken] === "string") { - return new Reference(json[jrefToken], json); - } - const anchorToken = getKeywordName(dialectId, "https://json-schema.org/keyword/anchor"); - if (typeof json[anchorToken] === "string") { - anchors[json[anchorToken]] = cursor; - delete json[anchorToken]; - } - const dynamicAnchorToken = getKeywordName(dialectId, "https://json-schema.org/keyword/dynamicAnchor"); - if (typeof json[dynamicAnchorToken] === "string") { - dynamicAnchors[json[dynamicAnchorToken]] = `${id62}#${encodeURI(cursor)}`; - delete json[dynamicAnchorToken]; - } - const legacyDynamicAnchorToken = getKeywordName(dialectId, "https://json-schema.org/keyword/draft-2020-12/dynamicAnchor"); - if (typeof json[legacyDynamicAnchorToken] === "string") { - dynamicAnchors[json[legacyDynamicAnchorToken]] = `${id62}#${encodeURI(cursor)}`; - anchors[json[legacyDynamicAnchorToken]] = cursor; - delete json[legacyDynamicAnchorToken]; - } - for (const key in json) { - const referenceToken = getKeywordName(dialectId, "https://json-schema.org/keyword/ref"); - if (key === referenceToken && typeof json[key] === "string") { - json[key] = new Reference(json[key], json[key]); - } else { - json[key] = processSchema(json[key], id62, dialectId, append(key, cursor), embedded, anchors, dynamicAnchors); - } - } - } else if (Array.isArray(json)) { - for (let index = 0; index < json.length; index++) { - json[index] = processSchema(json[index], id62, dialectId, append(index, cursor), embedded, anchors, dynamicAnchors); - } - } - return json; -}; -var canonicalUri = (browser) => `${browser.document.baseUri}#${encodeURI(browser.cursor)}`; - -// ../../node_modules/.pnpm/@hyperjump+pact@1.4.0/node_modules/@hyperjump/pact/src/curry.js -var curry2 = ( - /** @type API.curry */ - ((fn) => (...args) => { - const firstApplication = fn.length === 1 ? ( - /** @type Extract any> */ - fn(args[0]) - ) : fn(args[0], args[1]); - const iterable = ( - /** @type I */ - args[fn.length] - ); - return iterable === void 0 ? firstApplication : firstApplication(iterable); - }) -); - -// ../../node_modules/.pnpm/@hyperjump+pact@1.4.0/node_modules/@hyperjump/pact/src/index.js -var map = curry2((fn) => function* (iter3) { - for (const n of iter3) { - yield fn(n); - } -}); -var asyncMap = curry2((fn) => async function* (iter3) { - for await (const n of iter3) { - yield fn(n); - } -}); -var tap = curry2((fn) => function* (iter3) { - for (const n of iter3) { - fn(n); - yield n; - } -}); -var asyncTap = curry2((fn) => async function* (iter3) { - for await (const n of iter3) { - await fn(n); - yield n; - } -}); -var filter = curry2((fn) => function* (iter3) { - for (const n of iter3) { - if (fn(n)) { - yield n; - } - } -}); -var asyncFilter = curry2((fn) => async function* (iter3) { - for await (const n of iter3) { - if (await fn(n)) { - yield n; - } - } -}); -var scan = ( - /** @type API.scan */ - curry2( - // eslint-disable-next-line @stylistic/no-extra-parens - /** @type API.scan */ - ((fn, acc) => function* (iter3) { - for (const item of iter3) { - acc = fn( - acc, - /** @type any */ - item - ); - yield acc; - } - }) - ) -); -var asyncScan = ( - /** @type API.asyncScan */ - curry2( - // eslint-disable-next-line @stylistic/no-extra-parens - /** @type API.asyncScan */ - ((fn, acc) => async function* (iter3) { - for await (const item of iter3) { - acc = await fn( - acc, - /** @type any */ - item - ); - yield acc; - } - }) - ) -); -var drop = curry2((count) => function* (iter3) { - let index = 0; - for (const item of iter3) { - if (index++ >= count) { - yield item; - } - } -}); -var asyncDrop = curry2((count) => async function* (iter3) { - let index = 0; - for await (const item of iter3) { - if (index++ >= count) { - yield item; - } - } -}); -var dropWhile = curry2((fn) => function* (iter3) { - let dropping = true; - for (const n of iter3) { - if (dropping) { - if (fn(n)) { - continue; - } else { - dropping = false; - } - } - yield n; - } -}); -var asyncDropWhile = curry2((fn) => async function* (iter3) { - let dropping = true; - for await (const n of iter3) { - if (dropping) { - if (await fn(n)) { - continue; - } else { - dropping = false; - } - } - yield n; - } -}); -var take = curry2((count) => function* (iter3) { - const iterator = getIterator(iter3); - let current; - while (count-- > 0 && !(current = iterator.next())?.done) { - yield current.value; - } -}); -var asyncTake = curry2((count) => async function* (iter3) { - const iterator = getAsyncIterator(iter3); - let current; - while (count-- > 0 && !(current = await iterator.next())?.done) { - yield current.value; - } -}); -var takeWhile = curry2((fn) => function* (iter3) { - for (const n of iter3) { - if (fn(n)) { - yield n; - } else { - break; - } - } -}); -var asyncTakeWhile = curry2((fn) => async function* (iter3) { - for await (const n of iter3) { - if (await fn(n)) { - yield n; - } else { - break; - } - } -}); -var head = (iter3) => { - const iterator = getIterator(iter3); - const result = iterator.next(); - return result.done ? void 0 : result.value; -}; -var asyncHead = async (iter3) => { - const iterator = getAsyncIterator(iter3); - const result = await iterator.next(); - return result.done ? void 0 : result.value; -}; -var empty = function* () { -}; -var zip = function* (a, b) { - const bIter = getIterator(b); - for (const item1 of a) { - yield [item1, bIter.next().value]; - } -}; -var concat = function* (...iters) { - for (const iter3 of iters) { - yield* iter3; - } -}; -var reduce = ( - /** @type API.reduce */ - curry2( - // eslint-disable-next-line @stylistic/no-extra-parens - /** @type API.reduce */ - ((fn, acc) => (iter3) => { - for (const item of iter3) { - acc = fn( - acc, - /** @type any */ - item - ); - } - return acc; - }) - ) -); -var asyncReduce = ( - /** @type API.asyncReduce */ - curry2( - // eslint-disable-next-line @stylistic/no-extra-parens - /** @type API.asyncReduce */ - ((fn, acc) => async (iter3) => { - for await (const item of iter3) { - acc = await fn( - acc, - /** @type any */ - item - ); - } - return acc; - }) - ) -); -var every = curry2((fn) => (iter3) => { - for (const item of iter3) { - if (!fn(item)) { - return false; - } - } - return true; -}); -var asyncEvery = curry2((fn) => async (iter3) => { - for await (const item of iter3) { - if (!await fn(item)) { - return false; - } - } - return true; -}); -var some = curry2((fn) => (iter3) => { - for (const item of iter3) { - if (fn(item)) { - return true; - } - } - return false; -}); -var asyncSome = curry2((fn) => async (iter3) => { - for await (const item of iter3) { - if (await fn(item)) { - return true; - } - } - return false; -}); -var find = curry2((fn) => (iter3) => { - for (const item of iter3) { - if (fn(item)) { - return item; - } - } -}); -var asyncFind = curry2((fn) => async (iter3) => { - for await (const item of iter3) { - if (await fn(item)) { - return item; - } - } -}); -var asyncCollectArray = async (iter3) => { - const result = []; - for await (const item of iter3) { - result.push(item); - } - return result; -}; -var asyncCollectObject = async (iter3) => { - const result = /* @__PURE__ */ Object.create(null); - for await (const [key, value3] of iter3) { - result[key] = value3; - } - return result; -}; -var join = curry2((separator) => (iter3) => { - let result = head(iter3) ?? ""; - for (const n of iter3) { - result += separator + n; - } - return result; -}); -var asyncJoin = curry2((separator) => async (iter3) => { - let result = await asyncHead(iter3) ?? ""; - for await (const n of iter3) { - result += separator + n; - } - return result; -}); -var getIterator = (iter3) => { - if (typeof iter3?.[Symbol.iterator] === "function") { - return iter3[Symbol.iterator](); - } else { - throw TypeError("`iter` is not iterable"); - } -}; -var getAsyncIterator = (iter3) => { - if (Symbol.asyncIterator in iter3 && typeof iter3[Symbol.asyncIterator] === "function") { - return iter3[Symbol.asyncIterator](); - } else if (Symbol.iterator in iter3 && typeof iter3[Symbol.iterator] === "function") { - return asyncMap((a) => a, iter3); - } else { - throw TypeError("`iter` is not iterable"); - } -}; -var pipe = ( - /** @type (acc: any, ...fns: ((a: any) => any)[]) => any */ - ((acc, ...fns) => { - return reduce((acc2, fn) => fn(acc2), acc, fns); - }) -); - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/instance.js -var fromJs = (value3, uri4 = "", pointer = "", parent = void 0) => { - const jsType = typeof value3; - switch (jsType) { - case "number": - case "string": - case "boolean": - return cons(uri4, pointer, value3, jsType, [], parent); - case "object": - if (value3 === null) { - return cons(uri4, pointer, value3, "null", [], parent); - } else if (Array.isArray(value3)) { - const arrayNode = cons(uri4, pointer, value3, "array", [], parent); - arrayNode.children = value3.map((item, index) => { - return fromJs(item, uri4, append(index, pointer), arrayNode); - }); - return arrayNode; - } else if (Object.getPrototypeOf(value3) === Object.prototype) { - const objectNode = cons(uri4, pointer, value3, "object", [], parent); - objectNode.children = Object.entries(value3).map((entry) => { - const propertyPointer = append(entry[0], pointer); - const propertyNode = cons(uri4, propertyPointer, void 0, "property", [], objectNode); - propertyNode.children[0] = fromJs(entry[0], uri4, "*" + propertyPointer, propertyNode); - propertyNode.children[1] = fromJs(entry[1], uri4, propertyPointer, propertyNode); - return propertyNode; - }); - return objectNode; - } else if (value3 instanceof Reference) { - return fromJs(value3.toJSON(), uri4, pointer, parent); - } - default: { - const type = jsType === "object" ? Object.getPrototypeOf(value3).constructor.name || "anonymous" : jsType; - throw Error(`Not a JSON compatible type: ${type}`); - } - } -}; -var cons = (baseUri, pointer, value3, type, children, parent) => { - const node = { - baseUri: baseUri ? toAbsoluteIri(baseUri) : "", - pointer, - value: value3, - type, - children, - parent, - annotations: {} - }; - node.root = parent?.root ?? node; - return node; -}; -var uri3 = (node) => `${node.baseUri}#${encodeURI(node.pointer)}`; -var value2 = (node) => node.value; -var typeOf2 = (node) => node.type; -var has2 = (key, node) => key in node.value; -var iter2 = function* (node) { - if (node.type !== "array") { - return; - } - yield* node.children; -}; -var keys2 = function* (node) { - if (node.type !== "object") { - return; - } - for (const property of node.children) { - yield property.children[0]; - } -}; -var entries2 = function* (node) { - if (node.type !== "object") { - return; - } - for (const property of node.children) { - if (property.children.length === 2) { - yield property.children; - } - } -}; -var length2 = (node) => { - if (node.type !== "array") { - return; - } - return node.children.length; -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/pubsub.js -var subscriptions = {}; -var uid = 0; -var subscribe = (message, fn) => { - if (!(message in subscriptions)) { - subscriptions[message] = {}; - } - const subscriptionId = `pubsub_subscription_${uid++}`; - subscriptions[message][subscriptionId] = fn; - return subscriptionId; -}; -var publishAsync = async (message, data) => { - const promises = []; - if (message in subscriptions) { - for (const subscriptionId in subscriptions[message]) { - promises.push(subscriptions[message][subscriptionId](message, data)); - } - } - await Promise.all(promises); -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/configuration.js -var metaSchemaOutputFormat; -var getMetaSchemaOutputFormat = () => metaSchemaOutputFormat; -var setMetaSchemaOutputFormat = (format) => { - metaSchemaOutputFormat = format; -}; -var shouldValidateSchema = true; -var getShouldValidateSchema = () => shouldValidateSchema; -var shouldValidateFormat; -var getShouldValidateFormat = () => shouldValidateFormat; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/invalid-schema-error.js -var InvalidSchemaError = class extends Error { - constructor(output) { - super("Invalid Schema"); - this.name = this.constructor.name; - this.output = output; - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/validation.js -var id = "https://json-schema.org/evaluation/validate"; -var compile = async (schema, ast) => { - await publishAsync("validate.metaValidate", schema); - if (!(schema.document.baseUri in ast.metaData)) { - ast.metaData[schema.document.baseUri] = { - dynamicAnchors: schema.document.dynamicAnchors - }; - } - const url = canonicalUri(schema); - if (!(url in ast)) { - ast[url] = false; - const schemaValue = value(schema); - if (!["object", "boolean"].includes(typeof schemaValue)) { - throw Error(`No schema found at '${url}'`); - } - if (typeof schemaValue === "boolean") { - ast[url] = schemaValue; - } else { - ast[url] = await pipe( - entries(schema), - asyncMap(async ([keyword, keywordSchema]) => { - const keywordHandler = getKeywordByName(keyword, schema.document.dialectId); - if (keywordHandler.plugin) { - ast.plugins.add(keywordHandler.plugin); - } - const keywordAst = await keywordHandler.compile(keywordSchema, ast, schema); - return [keywordHandler.id, append(keyword, canonicalUri(schema)), keywordAst]; - }), - asyncCollectArray - ); - ast[url].sort(keywordComparator); - } - } - return url; -}; -var lastKeywords = /* @__PURE__ */ new Set([ - "https://json-schema.org/keyword/unevaluatedProperties", - "https://json-schema.org/keyword/unevaluatedItems" -]); -var keywordComparator = (_a, b) => lastKeywords.has(b[0]) ? -1 : 1; -var interpret = (url, instance, context) => { - let valid = true; - for (const plugin5 of context.plugins) { - plugin5.beforeSchema?.(url, instance, context); - } - if (typeof context.ast[url] === "boolean") { - valid = context.ast[url]; - } else { - for (const node of context.ast[url]) { - const [keywordId, , keywordValue] = node; - const keyword = getKeyword(keywordId); - const keywordContext = { - ast: context.ast, - plugins: context.plugins - }; - for (const plugin5 of context.plugins) { - plugin5.beforeKeyword?.(node, instance, keywordContext, context, keyword); - } - const isKeywordValid = keyword.interpret(keywordValue, instance, keywordContext); - if (!isKeywordValid) { - valid = false; - } - for (const plugin5 of context.plugins) { - plugin5.afterKeyword?.(node, instance, keywordContext, isKeywordValid, context, keyword); - } - } - } - for (const plugin5 of context.plugins) { - plugin5.afterSchema?.(url, instance, context, valid); - } - return valid; -}; -var validation_default = { id, compile, interpret }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/evaluation-plugins/basic-output.js -var BasicOutputPlugin = class { - beforeSchema(_url, _intance, context) { - context.errors ??= []; - } - beforeKeyword(_node, _instance, context) { - context.errors = []; - } - afterKeyword(node, instance, context, valid, schemaContext, keyword) { - if (!valid) { - if (!keyword.simpleApplicator) { - const [keywordId, schemaUri] = node; - schemaContext.errors.push({ - keyword: keywordId, - absoluteKeywordLocation: schemaUri, - instanceLocation: uri3(instance) - }); - } - schemaContext.errors.push(...context.errors); - } - } - afterSchema(url, instance, context, valid) { - if (typeof context.ast[url] === "boolean" && !valid) { - context.errors.push({ - keyword: validation_default.id, - absoluteKeywordLocation: url, - instanceLocation: uri3(instance) - }); - } - this.errors = context.errors; - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/evaluation-plugins/detailed-output.js -var DetailedOutputPlugin = class { - beforeSchema(_url, _instance, context) { - context.errors ??= []; - } - beforeKeyword(_node, _instance, context) { - context.errors = []; - } - afterKeyword(node, instance, context, valid, schemaContext) { - if (!valid) { - const [keywordId, schemaUri] = node; - const outputUnit = { - keyword: keywordId, - absoluteKeywordLocation: schemaUri, - instanceLocation: uri3(instance) - }; - schemaContext.errors.push(outputUnit); - if (context.errors.length > 0) { - outputUnit.errors = context.errors; - } - } - } - afterSchema(url, instance, context, valid) { - if (typeof context.ast[url] === "boolean" && !valid) { - context.errors.push({ - keyword: validation_default.id, - absoluteKeywordLocation: url, - instanceLocation: uri3(instance) - }); - } - this.errors = context.errors; - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/core.js -var FLAG = "FLAG"; -var BASIC = "BASIC"; -var DETAILED = "DETAILED"; -setMetaSchemaOutputFormat(FLAG); -var validate = async (url, value3 = void 0, options = void 0) => { - const schema = await getSchema(url); - const compiled = await compile2(schema); - const interpretAst = (value4, options2) => interpret2(compiled, fromJs(value4), options2); - return value3 === void 0 ? interpretAst : interpretAst(value3, options); -}; -var compile2 = async (schema) => { - const ast = { metaData: {}, plugins: /* @__PURE__ */ new Set() }; - const schemaUri = await validation_default.compile(schema, ast); - return { ast, schemaUri }; -}; -var interpret2 = functionCurry(({ ast, schemaUri }, instance, options = FLAG) => { - const outputFormat = typeof options === "string" ? options : options.outputFormat ?? FLAG; - const plugins = options.plugins ?? []; - const context = { ast, plugins: [...ast.plugins, ...plugins] }; - let outputPlugin; - switch (outputFormat) { - case FLAG: - break; - case BASIC: - outputPlugin = new BasicOutputPlugin(); - context.plugins.push(outputPlugin); - break; - case DETAILED: - outputPlugin = new DetailedOutputPlugin(); - context.plugins.push(outputPlugin); - break; - default: - throw Error(`Unsupported output format '${outputFormat}'`); - } - const valid = validation_default.interpret(schemaUri, instance, context); - return !valid && outputPlugin ? { valid, errors: outputPlugin.errors } : { valid }; -}); -var metaValidators = {}; -subscribe("validate.metaValidate", async (_message, schema) => { - if (getShouldValidateSchema() && !schema.document.validated) { - schema.document.validated = true; - if (!(schema.document.dialectId in metaValidators)) { - const metaSchema = await getSchema(schema.document.dialectId, schema); - const compiledSchema = await compile2(metaSchema); - metaValidators[schema.document.dialectId] = interpret2(compiledSchema); - } - const schemaInstance = fromJs(schema.document.root, schema.document.baseUri); - const metaResults = metaValidators[schema.document.dialectId](schemaInstance, getMetaSchemaOutputFormat()); - if (!metaResults.valid) { - throw new InvalidSchemaError(metaResults); - } - } -}); - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/additionalProperties.js -var id2 = "https://json-schema.org/keyword/additionalProperties"; -var compile3 = async (schema, ast, parentSchema) => { - const propertiesKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/properties"); - const propertiesSchema = await step(propertiesKeyword, parentSchema); - const propertyPatterns = typeOf(propertiesSchema) === "object" ? map((propertyName) => "^" + regexEscape(propertyName) + "$", keys(propertiesSchema)) : empty(); - const patternPropertiesKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/patternProperties"); - const patternProperties = await step(patternPropertiesKeyword, parentSchema); - const patternPropertyPatterns = typeOf(patternProperties) === "object" ? keys(patternProperties) : empty(); - const pattern = pipe( - concat(propertyPatterns, patternPropertyPatterns), - join("|") - ) || "(?!)"; - return [new RegExp(pattern, "u"), await validation_default.compile(schema, ast)]; -}; -var regexEscape = (string) => string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d"); -var interpret3 = ([isDefinedProperty, additionalProperties], instance, context) => { - if (typeOf2(instance) !== "object") { - return true; - } - let isValid = true; - for (const [propertyNameNode, property] of entries2(instance)) { - const propertyName = value2(propertyNameNode); - if (isDefinedProperty.test(propertyName)) { - continue; - } - if (!validation_default.interpret(additionalProperties, property, context)) { - isValid = false; - } - context.evaluatedProperties?.add(propertyName); - } - return isValid; -}; -var simpleApplicator = true; -var additionalProperties_default = { id: id2, compile: compile3, interpret: interpret3, simpleApplicator }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/allOf.js -var id3 = "https://json-schema.org/keyword/allOf"; -var compile4 = (schema, ast) => pipe( - iter(schema), - asyncMap((itemSchema) => validation_default.compile(itemSchema, ast)), - asyncCollectArray -); -var interpret4 = (allOf, instance, ast, dynamicAnchors, quiet) => { - let isValid = true; - for (const schemaUri of allOf) { - if (!validation_default.interpret(schemaUri, instance, ast, dynamicAnchors, quiet)) { - isValid = false; - } - } - return isValid; -}; -var simpleApplicator2 = true; -var allOf_default = { id: id3, compile: compile4, interpret: interpret4, simpleApplicator: simpleApplicator2 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/anchor.js -var anchor_default = { id: "https://json-schema.org/keyword/anchor" }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/anyOf.js -var id4 = "https://json-schema.org/keyword/anyOf"; -var compile5 = (schema, ast) => pipe( - iter(schema), - asyncMap((itemSchema) => validation_default.compile(itemSchema, ast)), - asyncCollectArray -); -var interpret5 = (anyOf, instance, ast, dynamicAnchors, quiet) => { - const matches = anyOf.filter((schemaUrl) => validation_default.interpret(schemaUrl, instance, ast, dynamicAnchors, quiet)); - return matches.length > 0; -}; -var anyOf_default = { id: id4, compile: compile5, interpret: interpret5 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/conditional.js -var id5 = "https://json-schema.org/keyword/conditional"; -var compile6 = (schema, ast) => pipe( - iter(schema), - schemaFlatten, - asyncMap((subSchema) => validation_default.compile(subSchema, ast)), - asyncCollectArray -); -var interpret6 = (conditional, instance, context) => { - for (let index = 0; index < conditional.length; index += 2) { - const isValid = validation_default.interpret(conditional[index], instance, context); - if (index + 1 === conditional.length) { - return isValid; - } else if (isValid) { - return validation_default.interpret(conditional[index + 1], instance, context); - } - } - return true; -}; -var schemaFlatten = async function* (iter3, depth = 1) { - for await (const n of iter3) { - if (depth > 0 && typeOf(n) === "array") { - yield* schemaFlatten(iter(n), depth - 1); - } else { - yield n; - } - } -}; -var conditional_default = { id: id5, compile: compile6, interpret: interpret6 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/const.js -var import_json_stringify_deterministic = __toESM(require_lib(), 1); -var id6 = "https://json-schema.org/keyword/const"; -var compile7 = (schema) => (0, import_json_stringify_deterministic.default)(value(schema)); -var interpret7 = (const_, instance) => (0, import_json_stringify_deterministic.default)(value2(instance)) === const_; -var const_default = { id: id6, compile: compile7, interpret: interpret7 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/contains.js -var id7 = "https://json-schema.org/keyword/contains"; -var compile8 = async (schema, ast, parentSchema) => { - const contains = await validation_default.compile(schema, ast); - const minContainsKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/minContains"); - const minContainsSchema = await step(minContainsKeyword, parentSchema); - const minContains = typeOf(minContainsSchema) === "number" ? value(minContainsSchema) : 1; - const maxContainsKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/maxContains"); - const maxContainsSchema = await step(maxContainsKeyword, parentSchema); - const maxContains = typeOf(maxContainsSchema) === "number" ? value(maxContainsSchema) : Number.MAX_SAFE_INTEGER; - return { contains, minContains, maxContains }; -}; -var interpret8 = ({ contains, minContains, maxContains }, instance, context) => { - if (typeOf2(instance) !== "array") { - return true; - } - let matches = 0; - let index = 0; - for (const item of iter2(instance)) { - if (validation_default.interpret(contains, item, context)) { - matches++; - context.evaluatedItems?.add(index); - } - index++; - } - return matches >= minContains && matches <= maxContains; -}; -var contains_default = { id: id7, compile: compile8, interpret: interpret8 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/comment.js -var id8 = "https://json-schema.org/keyword/comment"; -var compile9 = () => void 0; -var interpret9 = () => true; -var comment_default = { id: id8, compile: compile9, interpret: interpret9 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/contentEncoding.js -var id9 = "https://json-schema.org/keyword/contentEncoding"; -var compile10 = (schema) => value(schema); -var interpret10 = () => true; -var annotation = (contentEncoding, instance) => { - if (typeOf2(instance) !== "string") { - return; - } - return contentEncoding; -}; -var contentEncoding_default = { id: id9, compile: compile10, interpret: interpret10, annotation }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/contentMediaType.js -var id10 = "https://json-schema.org/keyword/contentMediaType"; -var compile11 = (schema) => value(schema); -var interpret11 = () => true; -var annotation2 = (contentMediaType, instance) => { - if (typeOf2(instance) !== "string") { - return; - } - return contentMediaType; -}; -var contentMediaType_default = { id: id10, compile: compile11, interpret: interpret11, annotation: annotation2 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/contentSchema.js -var id11 = "https://json-schema.org/keyword/contentSchema"; -var compile12 = async (contentSchema, _ast, parentSchema) => { - const contentMediaTypeKeyword = getKeywordName(contentSchema.document.dialectId, "https://json-schema.org/keyword/contentMediaType"); - const contentMediaType = await step(contentMediaTypeKeyword, parentSchema); - if (value(contentMediaType) === void 0) { - return; - } - return value(contentSchema); -}; -var interpret12 = () => true; -var annotation3 = (contentSchema, instance) => { - if (!contentSchema || typeOf2(instance) !== "string") { - return; - } - return contentSchema; -}; -var contentSchema_default = { id: id11, compile: compile12, interpret: interpret12, annotation: annotation3 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/default.js -var id12 = "https://json-schema.org/keyword/default"; -var compile13 = (schema) => value(schema); -var interpret13 = () => true; -var annotation4 = (value3) => value3; -var default_default = { id: id12, compile: compile13, interpret: interpret13, annotation: annotation4 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/definitions.js -var id13 = "https://json-schema.org/keyword/definitions"; -var compile14 = (schema, ast) => pipe( - values(schema), - asyncMap((definitionSchema) => validation_default.compile(definitionSchema, ast)), - asyncCollectArray -); -var interpret14 = () => true; -var definitions_default = { id: id13, compile: compile14, interpret: interpret14 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/dependentRequired.js -var id14 = "https://json-schema.org/keyword/dependentRequired"; -var compile15 = (schema) => pipe( - entries(schema), - asyncMap(([key, dependentRequired]) => [key, value(dependentRequired)]), - asyncCollectArray -); -var interpret15 = (dependentRequired, instance) => { - if (typeOf2(instance) !== "object") { - return true; - } - let isValid = true; - for (const [propertyName, required] of dependentRequired) { - if (has2(propertyName, instance) && !required.every((key) => has2(key, instance))) { - isValid = false; - } - } - return isValid; -}; -var dependentRequired_default = { id: id14, compile: compile15, interpret: interpret15 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/dependentSchemas.js -var id15 = "https://json-schema.org/keyword/dependentSchemas"; -var compile16 = (schema, ast) => pipe( - entries(schema), - asyncMap(async ([key, dependentSchema]) => [key, await validation_default.compile(dependentSchema, ast)]), - asyncCollectArray -); -var interpret16 = (dependentSchemas, instance, context) => { - if (typeOf2(instance) !== "object") { - return true; - } - let isValid = true; - for (const [propertyName, dependentSchema] of dependentSchemas) { - if (has2(propertyName, instance) && !validation_default.interpret(dependentSchema, instance, context)) { - isValid = false; - } - } - return isValid; -}; -var simpleApplicator3 = true; -var dependentSchemas_default = { id: id15, compile: compile16, interpret: interpret16, simpleApplicator: simpleApplicator3 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/deprecated.js -var id16 = "https://json-schema.org/keyword/deprecated"; -var compile17 = (schema) => value(schema); -var interpret17 = () => true; -var annotation5 = (deprecated) => deprecated; -var deprecated_default = { id: id16, compile: compile17, interpret: interpret17, annotation: annotation5 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/description.js -var id17 = "https://json-schema.org/keyword/description"; -var compile18 = (schema) => value(schema); -var interpret18 = () => true; -var annotation6 = (description) => description; -var description_default = { id: id17, compile: compile18, interpret: interpret18, annotation: annotation6 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/dynamicAnchor.js -var dynamicAnchor_default = { id: "https://json-schema.org/keyword/dynamicAnchor" }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/dynamicRef.js -var id18 = "https://json-schema.org/keyword/dynamicRef"; -var compile19 = async (schema, ast) => { - const reference = value(schema); - const self = await get2(schema.document.baseUri, schema); - await validation_default.compile(self, ast); - return reference.startsWith("#") ? reference.slice(1) : reference; -}; -var interpret19 = (fragment3, instance, context) => { - if (!(fragment3 in context.dynamicAnchors)) { - throw Error(`No dynamic anchor found for "${fragment3}"`); - } - return validation_default.interpret(context.dynamicAnchors[fragment3], instance, context); -}; -var simpleApplicator4 = true; -var plugin = { - beforeSchema(url, _instance, context) { - context.dynamicAnchors = { - ...context.ast.metaData[toAbsoluteUri2(url)].dynamicAnchors, - ...context.dynamicAnchors - }; - }, - beforeKeyword(_url, _instance, context, schemaContext) { - context.dynamicAnchors = schemaContext.dynamicAnchors; - } -}; -var dynamicRef_default = { id: id18, compile: compile19, interpret: interpret19, simpleApplicator: simpleApplicator4, plugin }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/else.js -var id19 = "https://json-schema.org/keyword/else"; -var compile20 = async (schema, ast, parentSchema) => { - const ifKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/if"); - if (has(ifKeyword, parentSchema)) { - const ifSchema = await step(ifKeyword, parentSchema); - return [await validation_default.compile(ifSchema, ast), await validation_default.compile(schema, ast)]; - } else { - return []; - } -}; -var interpret20 = ([ifSchema, elseSchema], instance, context) => { - return ifSchema === void 0 || validation_default.interpret(ifSchema, instance, { ...context, plugins: context.ast.plugins }) || validation_default.interpret(elseSchema, instance, context); -}; -var simpleApplicator5 = true; -var else_default = { id: id19, compile: compile20, interpret: interpret20, simpleApplicator: simpleApplicator5 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/enum.js -var import_json_stringify_deterministic2 = __toESM(require_lib(), 1); -var id20 = "https://json-schema.org/keyword/enum"; -var compile21 = (schema) => pipe( - iter(schema), - asyncMap(value), - asyncMap(import_json_stringify_deterministic2.default), - asyncCollectArray -); -var interpret21 = (enum_, instance) => { - const instanceValue = (0, import_json_stringify_deterministic2.default)(value2(instance)); - return enum_.some((enumValue) => instanceValue === enumValue); -}; -var enum_default = { id: id20, compile: compile21, interpret: interpret21 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/examples.js -var id21 = "https://json-schema.org/keyword/examples"; -var compile22 = (schema) => value(schema); -var interpret22 = () => true; -var annotation7 = (examples) => examples; -var examples_default = { id: id21, compile: compile22, interpret: interpret22, annotation: annotation7 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/exclusiveMaximum.js -var id22 = "https://json-schema.org/keyword/exclusiveMaximum"; -var compile23 = (schema) => value(schema); -var interpret23 = (exclusiveMaximum, instance) => typeOf2(instance) !== "number" || value2(instance) < exclusiveMaximum; -var exclusiveMaximum_default = { id: id22, compile: compile23, interpret: interpret23 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/exclusiveMinimum.js -var id23 = "https://json-schema.org/keyword/exclusiveMinimum"; -var compile24 = (schema) => value(schema); -var interpret24 = (exclusiveMinimum, instance) => typeOf2(instance) !== "number" || value2(instance) > exclusiveMinimum; -var exclusiveMinimum_default = { id: id23, compile: compile24, interpret: interpret24 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/format.js -var id24 = "https://json-schema.org/keyword/format"; -var compile25 = (schema) => value(schema); -var interpret25 = (format, instance) => { - const handler = getFormatHandler(formats[format]); - if (!handler) { - throw Error(`The '${format}' format is not supported.`); - } - return handler(value2(instance)); -}; -var annotation8 = (format) => format; -var formats = { - "date-time": "https://json-schema.org/format/date-time", - "date": "https://json-schema.org/format/date", - "time": "https://json-schema.org/format/time", - "duration": "https://json-schema.org/format/duration", - "email": "https://json-schema.org/format/email", - "idn-email": "https://json-schema.org/format/idn-email", - "hostname": "https://json-schema.org/format/hostname", - "idn-hostname": "https://json-schema.org/format/idn-hostname", - "ipv4": "https://json-schema.org/format/ipv4", - "ipv6": "https://json-schema.org/format/ipv6", - "uri": "https://json-schema.org/format/uri", - "uri-reference": "https://json-schema.org/format/uri-reference", - "iri": "https://json-schema.org/format/iri", - "iri-reference": "https://json-schema.org/format/iri-reference", - "uuid": "https://json-schema.org/format/uuid", - "uri-template": "https://json-schema.org/format/uri-template", - "json-pointer": "https://json-schema.org/format/json-pointer", - "relative-json-pointer": "https://json-schema.org/format/relative-json-pointer", - "regex": "https://json-schema.org/format/regex" -}; -var format_default = { id: id24, compile: compile25, interpret: interpret25, annotation: annotation8, formats }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/id.js -var id_default = { id: "https://json-schema.org/keyword/id" }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/if.js -var id25 = "https://json-schema.org/keyword/if"; -var compile26 = (schema, ast) => validation_default.compile(schema, ast); -var interpret26 = (ifSchema, instance, context) => { - validation_default.interpret(ifSchema, instance, context); - return true; -}; -var simpleApplicator6 = true; -var if_default = { id: id25, compile: compile26, interpret: interpret26, simpleApplicator: simpleApplicator6 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/nfa.js -var fromEpsilon = () => { - const start = createState(false); - const end = createState(true); - addEpsilonTransition(start, end); - return { start, end }; -}; -var fromSchema = (schema) => { - const start = createState(false); - const end = createState(true); - addTransition(start, end, schema); - return { start, end }; -}; -var concat2 = (first, second) => { - if (first === void 0) { - return second; - } - addEpsilonTransition(first.end, second.start); - first.end.isEnd = false; - return { start: first.start, end: second.end }; -}; -var union = (first, second) => { - const start = createState(false); - addEpsilonTransition(start, first.start); - addEpsilonTransition(start, second.start); - const end = createState(true); - addEpsilonTransition(first.end, end); - first.end.isEnd = false; - addEpsilonTransition(second.end, end); - second.end.isEnd = false; - return { start, end }; -}; -var closure = (nfa) => { - const start = createState(false); - const end = createState(true); - addEpsilonTransition(start, end); - addEpsilonTransition(start, nfa.start); - addEpsilonTransition(nfa.end, end); - addEpsilonTransition(nfa.end, nfa.start); - nfa.end.isEnd = false; - return { start, end }; -}; -var zeroOrOne = (nfa) => { - const start = createState(false); - const end = createState(true); - addEpsilonTransition(start, end); - addEpsilonTransition(start, nfa.start); - addEpsilonTransition(nfa.end, end); - nfa.end.isEnd = false; - return { start, end }; -}; -var oneOrMore = (nfa) => { - const start = createState(false); - const end = createState(true); - addEpsilonTransition(start, nfa.start); - addEpsilonTransition(nfa.end, end); - addEpsilonTransition(nfa.end, nfa.start); - nfa.end.isEnd = false; - return { start, end }; -}; -var addEpsilonTransition = (from, to) => { - from.epsilonTransitions.push(to); -}; -var addTransition = (from, to, symbol) => { - from.transition[symbol] = to; -}; -var createState = (isEnd) => { - return { - isEnd, - transition: {}, - epsilonTransitions: [] - }; -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/itemPattern.js -var id26 = "https://json-schema.org/keyword/itemPattern"; -var compile27 = async (schema, ast) => { - const groups = [[]]; - let group = groups[0]; - for await (const rule of iter(schema)) { - if (typeOf(rule) === "string") { - const operator = value(rule); - if (operator === "*") { - group.push(closure(group.pop())); - } else if (operator === "?") { - group.push(zeroOrOne(group.pop())); - } else if (operator === "+") { - group.push(oneOrMore(group.pop())); - } else if (operator === "|") { - group = []; - groups.push(group); - } else { - throw Error(`Unsupported pattern syntax: ${operator}`); - } - } else { - const node = typeOf(rule) === "array" ? compile27(rule, ast) : fromSchema(await validation_default.compile(rule, ast)); - group.push(await node); - } - } - return length(schema) === 0 ? fromEpsilon() : groups.map((group2) => group2.reduce(concat2)).reduce(union); -}; -var interpret27 = (nfa, instance, context) => { - if (typeOf2(instance) !== "array") { - return true; - } - let currentStates = []; - addNextState(nfa.start, currentStates, []); - for (const item of iter2(instance)) { - const nextStates = []; - for (const state of currentStates) { - const nextState = transition(state.transition, item, context); - if (nextState) { - addNextState(nextState, nextStates, []); - } - } - currentStates = nextStates; - } - return Boolean(currentStates.find((s) => s.isEnd)); -}; -var addNextState = (state, nextStates, visited) => { - if (state.epsilonTransitions.length) { - for (const epsilonState of state.epsilonTransitions) { - if (!visited.find((visited2) => visited2 === epsilonState)) { - visited.push(epsilonState); - addNextState(epsilonState, nextStates, visited); - } - } - } else { - nextStates.push(state); - } -}; -var transition = (transitions, instance, context) => { - for (const schema in transitions) { - if (validation_default.interpret(schema, instance, context)) { - return transitions[schema]; - } - } -}; -var itemPattern_default = { id: id26, compile: compile27, interpret: interpret27 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/items.js -var id27 = "https://json-schema.org/keyword/items"; -var compile28 = async (schema, ast, parentSchema) => { - const prefixItemKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/prefixItems"); - const prefixItems = await step(prefixItemKeyword, parentSchema); - const numberOfPrefixItems = typeOf(prefixItems) === "array" ? length(prefixItems) : 0; - return [numberOfPrefixItems, await validation_default.compile(schema, ast)]; -}; -var interpret28 = ([numberOfPrefixItems, items], instance, context) => { - if (typeOf2(instance) !== "array") { - return true; - } - let isValid = true; - let index = numberOfPrefixItems; - for (const item of drop(numberOfPrefixItems, iter2(instance))) { - if (!validation_default.interpret(items, item, context)) { - isValid = false; - } - context.evaluatedItems?.add(index); - index++; - } - return isValid; -}; -var simpleApplicator7 = true; -var items_default = { id: id27, compile: compile28, interpret: interpret28, simpleApplicator: simpleApplicator7 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/maxContains.js -var id28 = "https://json-schema.org/keyword/maxContains"; -var compile29 = (schema) => value(schema); -var interpret29 = () => true; -var maxContains_default = { id: id28, compile: compile29, interpret: interpret29 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/maxItems.js -var id29 = "https://json-schema.org/keyword/maxItems"; -var compile30 = (schema) => value(schema); -var interpret30 = (maxItems, instance) => { - return typeOf2(instance) !== "array" || length2(instance) <= maxItems; -}; -var maxItems_default = { id: id29, compile: compile30, interpret: interpret30 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/maxLength.js -var id30 = "https://json-schema.org/keyword/maxLength"; -var compile31 = (schema) => value(schema); -var interpret31 = (maxLength, instance) => { - return typeOf2(instance) !== "string" || [...value2(instance)].length <= maxLength; -}; -var maxLength_default = { id: id30, compile: compile31, interpret: interpret31 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/maxProperties.js -var id31 = "https://json-schema.org/keyword/maxProperties"; -var compile32 = (schema) => value(schema); -var interpret32 = (maxProperties, instance) => { - return typeOf2(instance) !== "object" || [...keys2(instance)].length <= maxProperties; -}; -var maxProperties_default = { id: id31, compile: compile32, interpret: interpret32 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/maximum.js -var id32 = "https://json-schema.org/keyword/maximum"; -var compile33 = (schema) => value(schema); -var interpret33 = (maximum, instance) => typeOf2(instance) !== "number" || value2(instance) <= maximum; -var maximum_default = { id: id32, compile: compile33, interpret: interpret33 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/minContains.js -var id33 = "https://json-schema.org/keyword/minContains"; -var compile34 = (schema) => value(schema); -var interpret34 = () => true; -var minContains_default = { id: id33, compile: compile34, interpret: interpret34 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/minItems.js -var id34 = "https://json-schema.org/keyword/minItems"; -var compile35 = (schema) => value(schema); -var interpret35 = (minItems, instance) => { - return typeOf2(instance) !== "array" || length2(instance) >= minItems; -}; -var minItems_default = { id: id34, compile: compile35, interpret: interpret35 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/minLength.js -var id35 = "https://json-schema.org/keyword/minLength"; -var compile36 = (schema) => value(schema); -var interpret36 = (minLength, instance) => { - return typeOf2(instance) !== "string" || [...value2(instance)].length >= minLength; -}; -var minLength_default = { id: id35, compile: compile36, interpret: interpret36 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/minProperties.js -var id36 = "https://json-schema.org/keyword/minProperties"; -var compile37 = (schema) => value(schema); -var interpret37 = (minProperties, instance) => { - return typeOf2(instance) !== "object" || [...keys2(instance)].length >= minProperties; -}; -var minProperties_default = { id: id36, compile: compile37, interpret: interpret37 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/minimum.js -var id37 = "https://json-schema.org/keyword/minimum"; -var compile38 = (schema) => value(schema); -var interpret38 = (minimum, instance) => typeOf2(instance) !== "number" || value2(instance) >= minimum; -var minimum_default = { id: id37, compile: compile38, interpret: interpret38 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/multipleOf.js -var id38 = "https://json-schema.org/keyword/multipleOf"; -var compile39 = (schema) => value(schema); -var interpret39 = (multipleOf, instance) => { - if (typeOf2(instance) !== "number") { - return true; - } - const remainder = value2(instance) % multipleOf; - return numberEqual(0, remainder) || numberEqual(multipleOf, remainder); -}; -var numberEqual = (a, b) => Math.abs(a - b) < 11920929e-14; -var multipleOf_default = { id: id38, compile: compile39, interpret: interpret39 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/not.js -var id39 = "https://json-schema.org/keyword/not"; -var compile40 = (...args) => validation_default.compile(...args); -var interpret40 = (...args) => !validation_default.interpret(...args); -var not_default = { id: id39, compile: compile40, interpret: interpret40 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/oneOf.js -var id40 = "https://json-schema.org/keyword/oneOf"; -var compile41 = (schema, ast) => pipe( - iter(schema), - asyncMap((itemSchema) => validation_default.compile(itemSchema, ast)), - asyncCollectArray -); -var interpret41 = (oneOf, instance, context) => { - let validCount = 0; - for (const schemaUrl of oneOf) { - if (validation_default.interpret(schemaUrl, instance, context)) { - validCount++; - } - } - return validCount === 1; -}; -var oneOf_default = { id: id40, compile: compile41, interpret: interpret41 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/pattern.js -var id41 = "https://json-schema.org/keyword/pattern"; -var compile42 = (schema) => new RegExp(value(schema), "u"); -var interpret42 = (pattern, instance) => { - return typeOf2(instance) !== "string" || pattern.test(value2(instance)); -}; -var pattern_default = { id: id41, compile: compile42, interpret: interpret42 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/patternProperties.js -var id42 = "https://json-schema.org/keyword/patternProperties"; -var compile43 = (schema, ast) => pipe( - entries(schema), - asyncMap(async ([pattern, propertySchema]) => [ - new RegExp(pattern, "u"), - await validation_default.compile(propertySchema, ast) - ]), - asyncCollectArray -); -var interpret43 = (patternProperties, instance, context) => { - if (typeOf2(instance) !== "object") { - return true; - } - let isValid = true; - for (const [pattern, schemaUri] of patternProperties) { - for (const [propertyNameNode, propertyValue] of entries2(instance)) { - const propertyName = value2(propertyNameNode); - if (pattern.test(propertyName)) { - if (!validation_default.interpret(schemaUri, propertyValue, context)) { - isValid = false; - } - context.evaluatedProperties?.add(propertyName); - } - } - } - return isValid; -}; -var simpleApplicator8 = true; -var patternProperties_default = { id: id42, compile: compile43, interpret: interpret43, simpleApplicator: simpleApplicator8 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/prefixItems.js -var id43 = "https://json-schema.org/keyword/prefixItems"; -var compile44 = (schema, ast) => pipe( - iter(schema), - asyncMap((itemSchema) => validation_default.compile(itemSchema, ast)), - asyncCollectArray -); -var interpret44 = (prefixItems, instance, context) => { - if (typeOf2(instance) !== "array") { - return true; - } - let isValid = true; - let index = 0; - const instanceLength = length2(instance); - for (const [schemaUri, item] of zip(prefixItems, iter2(instance))) { - if (index >= instanceLength) { - break; - } - if (!validation_default.interpret(schemaUri, item, context)) { - isValid = false; - } - context.evaluatedItems?.add(index); - index++; - } - return isValid; -}; -var simpleApplicator9 = true; -var prefixItems_default = { id: id43, compile: compile44, interpret: interpret44, simpleApplicator: simpleApplicator9 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/properties.js -var id44 = "https://json-schema.org/keyword/properties"; -var compile45 = (schema, ast) => pipe( - entries(schema), - asyncMap(async ([propertyName, propertySchema]) => [propertyName, await validation_default.compile(propertySchema, ast)]), - asyncCollectObject -); -var interpret45 = (properties, instance, context) => { - if (typeOf2(instance) !== "object") { - return true; - } - let isValid = true; - for (const [propertyNameNode, property] of entries2(instance)) { - const propertyName = value2(propertyNameNode); - if (propertyName in properties) { - if (!validation_default.interpret(properties[propertyName], property, context)) { - isValid = false; - } - context.evaluatedProperties?.add(propertyName); - } - } - return isValid; -}; -var simpleApplicator10 = true; -var properties_default = { id: id44, compile: compile45, interpret: interpret45, simpleApplicator: simpleApplicator10 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/propertyDependencies.js -var id45 = "https://json-schema.org/keyword/propertyDependencies"; -var compile46 = (schema, ast) => { - return pipe( - entries(schema), - asyncMap(async ([propertyName, valueMappings]) => { - return [propertyName, await pipe( - entries(valueMappings), - asyncMap(async ([propertyValue, conditionalSchema]) => [propertyValue, await validation_default.compile(conditionalSchema, ast)]), - asyncCollectObject - )]; - }), - asyncCollectObject - ); -}; -var interpret46 = (propertyDependencies, instance, context) => { - if (typeOf2(instance) !== "object") { - return true; - } - let isValid = true; - const instanceValue = value2(instance); - for (const [propertyName, valueMappings] of Object.entries(propertyDependencies)) { - const propertyValue = instanceValue[propertyName]; - if (has2(propertyName, instance) && propertyValue in valueMappings && !validation_default.interpret(valueMappings[propertyValue], instance, context)) { - isValid = false; - } - } - return isValid; -}; -var simpleApplicator11 = true; -var propertyDependencies_default = { id: id45, compile: compile46, interpret: interpret46, simpleApplicator: simpleApplicator11 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/propertyNames.js -var id46 = "https://json-schema.org/keyword/propertyNames"; -var compile47 = (schema, ast) => validation_default.compile(schema, ast); -var interpret47 = (propertyNames, instance, context) => { - if (typeOf2(instance) !== "object") { - return true; - } - let isValid = true; - for (const key of keys2(instance)) { - if (!validation_default.interpret(propertyNames, key, context)) { - isValid = false; - } - } - return isValid; -}; -var simpleApplicator12 = true; -var propertyNames_default = { id: id46, compile: compile47, interpret: interpret47, simpleApplicator: simpleApplicator12 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/readOnly.js -var id47 = "https://json-schema.org/keyword/readOnly"; -var compile48 = (schema) => value(schema); -var interpret48 = () => true; -var annotation9 = (readOnly) => readOnly; -var readOnly_default = { id: id47, compile: compile48, interpret: interpret48, annotation: annotation9 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/ref.js -var id48 = "https://json-schema.org/keyword/ref"; -var compile49 = (...args) => validation_default.compile(...args); -var interpret49 = (...args) => validation_default.interpret(...args); -var simpleApplicator13 = true; -var ref_default = { id: id48, compile: compile49, interpret: interpret49, simpleApplicator: simpleApplicator13 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/requireAllExcept.js -var id49 = "https://json-schema.org/keyword/requireAllExcept"; -var compile50 = async (schema, _ast, parentSchema) => { - const requireAllExcept = await value(schema); - const propertiesKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/properties"); - const propertiesSchema = await step(propertiesKeyword, parentSchema); - const propertyNames = typeOf(propertiesSchema) === "object" ? keys(propertiesSchema) : []; - const required = new Set(propertyNames); - requireAllExcept.forEach((propertyName) => required.delete(propertyName)); - return [...required]; -}; -var interpret50 = (required, instance) => { - return typeOf2(instance) !== "object" || required.every((propertyName) => Object.hasOwn(value2(instance), propertyName)); -}; -var requireAllExcept_default = { id: id49, compile: compile50, interpret: interpret50 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/required.js -var id50 = "https://json-schema.org/keyword/required"; -var compile51 = (schema) => value(schema); -var interpret51 = (required, instance) => { - return typeOf2(instance) !== "object" || required.every((propertyName) => Object.hasOwn(value2(instance), propertyName)); -}; -var required_default = { id: id50, compile: compile51, interpret: interpret51 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/title.js -var id51 = "https://json-schema.org/keyword/title"; -var compile52 = (schema) => value(schema); -var interpret52 = () => true; -var annotation10 = (title) => title; -var title_default = { id: id51, compile: compile52, interpret: interpret52, annotation: annotation10 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/then.js -var id52 = "https://json-schema.org/keyword/then"; -var compile53 = async (schema, ast, parentSchema) => { - const ifKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/if"); - if (has(ifKeyword, parentSchema)) { - const ifSchema = await step(ifKeyword, parentSchema); - return [await validation_default.compile(ifSchema, ast), await validation_default.compile(schema, ast)]; - } else { - return []; - } -}; -var interpret53 = ([ifSchema, thenSchema], instance, context) => { - return ifSchema === void 0 || !validation_default.interpret(ifSchema, instance, { ...context, plugins: context.ast.plugins }) || validation_default.interpret(thenSchema, instance, context); -}; -var simpleApplicator14 = true; -var then_default = { id: id52, compile: compile53, interpret: interpret53, simpleApplicator: simpleApplicator14 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/type.js -var id53 = "https://json-schema.org/keyword/type"; -var compile54 = (schema) => value(schema); -var interpret54 = (type, instance) => typeof type === "string" ? isTypeOf(instance)(type) : type.some(isTypeOf(instance)); -var isTypeOf = (instance) => (type) => type === "integer" ? typeOf2(instance) === "number" && Number.isInteger(value2(instance)) : typeOf2(instance) === type; -var type_default = { id: id53, compile: compile54, interpret: interpret54 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/unevaluatedItems.js -var id54 = "https://json-schema.org/keyword/unevaluatedItems"; -var compile55 = (schema, ast) => validation_default.compile(schema, ast); -var interpret55 = (unevaluatedItems, instance, context) => { - if (typeOf2(instance) !== "array") { - return true; - } - const evaluatedItems = context.schemaEvaluatedItems; - let isValid = true; - let index = 0; - for (const item of iter2(instance)) { - if (!evaluatedItems.has(index)) { - if (!validation_default.interpret(unevaluatedItems, item, context)) { - isValid = false; - } - context.evaluatedItems?.add(index); - } - index++; - } - return isValid; -}; -var simpleApplicator15 = true; -var plugin2 = { - beforeSchema(_url, instance, context) { - context.evaluatedItems ??= /* @__PURE__ */ new Set(); - context.schemaEvaluatedItems = /* @__PURE__ */ new Set(); - context.instanceLocation ??= uri3(instance); - }, - beforeKeyword(_node, instance, context, schemaContext) { - context.evaluatedItems = /* @__PURE__ */ new Set(); - context.schemaEvaluatedItems = schemaContext.schemaEvaluatedItems; - context.instanceLocation = uri3(instance); - }, - afterKeyword(_node, _instance, context, _valid, schemaContext) { - for (const property of context.evaluatedItems) { - schemaContext.schemaEvaluatedItems.add(property); - } - }, - afterSchema(_node, instance, context, valid) { - if (valid && uri3(instance) === context.instanceLocation) { - for (const property of context.schemaEvaluatedItems) { - context.evaluatedItems.add(property); - } - } - } -}; -var unevaluatedItems_default = { id: id54, compile: compile55, interpret: interpret55, simpleApplicator: simpleApplicator15, plugin: plugin2 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/unevaluatedProperties.js -var id55 = "https://json-schema.org/keyword/unevaluatedProperties"; -var compile56 = (schema, ast) => validation_default.compile(schema, ast); -var interpret56 = (unevaluatedProperties, instance, context) => { - if (typeOf2(instance) !== "object") { - return true; - } - const evaluatedProperties = context.schemaEvaluatedProperties; - let isValid = true; - for (const [propertyNameNode, property] of entries2(instance)) { - const propertyName = value2(propertyNameNode); - if (evaluatedProperties.has(propertyName)) { - continue; - } - if (!validation_default.interpret(unevaluatedProperties, property, context)) { - isValid = false; - } - context.evaluatedProperties?.add(propertyName); - } - return isValid; -}; -var simpleApplicator16 = true; -var plugin3 = { - beforeSchema(_url, instance, context) { - context.evaluatedProperties ??= /* @__PURE__ */ new Set(); - context.schemaEvaluatedProperties = /* @__PURE__ */ new Set(); - context.instanceLocation ??= uri3(instance); - }, - beforeKeyword(_node, instance, context, schemaContext) { - context.evaluatedProperties = /* @__PURE__ */ new Set(); - context.schemaEvaluatedProperties = schemaContext.schemaEvaluatedProperties; - context.instanceLocation = uri3(instance); - }, - afterKeyword(_node, _instance, context, _valid, schemaContext) { - for (const property of context.evaluatedProperties) { - schemaContext.schemaEvaluatedProperties.add(property); - } - }, - afterSchema(_node, instance, context, valid) { - if (valid && uri3(instance) === context.instanceLocation) { - for (const property of context.schemaEvaluatedProperties) { - context.evaluatedProperties.add(property); - } - } - } -}; -var unevaluatedProperties_default = { id: id55, compile: compile56, interpret: interpret56, simpleApplicator: simpleApplicator16, plugin: plugin3 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/uniqueItems.js -var import_json_stringify_deterministic3 = __toESM(require_lib(), 1); -var id56 = "https://json-schema.org/keyword/uniqueItems"; -var compile57 = (schema) => value(schema); -var interpret57 = (uniqueItems, instance) => { - if (typeOf2(instance) !== "array" || uniqueItems === false) { - return true; - } - const normalizedItems = value2(instance).map(import_json_stringify_deterministic3.default); - return new Set(normalizedItems).size === normalizedItems.length; -}; -var uniqueItems_default = { id: id56, compile: compile57, interpret: interpret57 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/unknown.js -var id57 = "https://json-schema.org/keyword/unknown"; -var compile58 = (schema) => { - const keywordName = [...pointerSegments(schema.cursor)].pop(); - return [keywordName, value(schema)]; -}; -var interpret58 = () => true; -var annotation11 = ([, value3]) => value3; -var unknown_default = { id: id57, compile: compile58, interpret: interpret58, annotation: annotation11 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/vocabulary.js -var vocabulary_default = { id: "https://json-schema.org/keyword/vocabulary" }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/keywords/writeOnly.js -var id58 = "https://json-schema.org/keyword/writeOnly"; -var compile59 = (schema) => value(schema); -var interpret59 = () => true; -var annotation12 = (writeOnly) => writeOnly; -var writeOnly_default = { id: id58, compile: compile59, interpret: interpret59, annotation: annotation12 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/lib/index.js -addMediaTypePlugin("application/schema+json", schemaPlugin); -addKeyword(additionalProperties_default); -addKeyword(allOf_default); -addKeyword(anchor_default); -addKeyword(anyOf_default); -addKeyword(conditional_default); -addKeyword(const_default); -addKeyword(contains_default); -addKeyword(comment_default); -addKeyword(contentEncoding_default); -addKeyword(contentMediaType_default); -addKeyword(contentSchema_default); -addKeyword(default_default); -addKeyword(definitions_default); -addKeyword(dependentRequired_default); -addKeyword(dependentSchemas_default); -addKeyword(deprecated_default); -addKeyword(description_default); -addKeyword(dynamicAnchor_default); -addKeyword(dynamicRef_default); -addKeyword(else_default); -addKeyword(enum_default); -addKeyword(examples_default); -addKeyword(exclusiveMaximum_default); -addKeyword(exclusiveMinimum_default); -addKeyword(format_default); -addKeyword(id_default); -addKeyword(if_default); -addKeyword(itemPattern_default); -addKeyword(items_default); -addKeyword(maxContains_default); -addKeyword(maxItems_default); -addKeyword(maxLength_default); -addKeyword(maxProperties_default); -addKeyword(maximum_default); -addKeyword(minContains_default); -addKeyword(minItems_default); -addKeyword(minLength_default); -addKeyword(minProperties_default); -addKeyword(minimum_default); -addKeyword(multipleOf_default); -addKeyword(not_default); -addKeyword(oneOf_default); -addKeyword(pattern_default); -addKeyword(patternProperties_default); -addKeyword(prefixItems_default); -addKeyword(properties_default); -addKeyword(propertyDependencies_default); -addKeyword(propertyNames_default); -addKeyword(readOnly_default); -addKeyword(ref_default); -addKeyword(requireAllExcept_default); -addKeyword(required_default); -addKeyword(title_default); -addKeyword(then_default); -addKeyword(type_default); -addKeyword(unevaluatedItems_default); -addKeyword(unevaluatedProperties_default); -addKeyword(uniqueItems_default); -addKeyword(unknown_default); -addKeyword(vocabulary_default); -addKeyword(writeOnly_default); - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/schema.js -var schema_default = { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://json-schema.org/draft/2020-12/schema", - "$vocabulary": { - "https://json-schema.org/draft/2020-12/vocab/core": true, - "https://json-schema.org/draft/2020-12/vocab/applicator": true, - "https://json-schema.org/draft/2020-12/vocab/unevaluated": true, - "https://json-schema.org/draft/2020-12/vocab/validation": true, - "https://json-schema.org/draft/2020-12/vocab/meta-data": true, - "https://json-schema.org/draft/2020-12/vocab/format-annotation": true, - "https://json-schema.org/draft/2020-12/vocab/content": true - }, - "$dynamicAnchor": "meta", - "title": "Core and Validation specifications meta-schema", - "allOf": [ - { "$ref": "meta/core" }, - { "$ref": "meta/applicator" }, - { "$ref": "meta/unevaluated" }, - { "$ref": "meta/validation" }, - { "$ref": "meta/meta-data" }, - { "$ref": "meta/format-annotation" }, - { "$ref": "meta/content" } - ], - "type": ["object", "boolean"], - "properties": { - "definitions": { - "$comment": "While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.", - "type": "object", - "additionalProperties": { "$dynamicRef": "#meta" }, - "default": {} - }, - "dependencies": { - "$comment": '"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"', - "type": "object", - "additionalProperties": { - "anyOf": [ - { "$dynamicRef": "#meta" }, - { "$ref": "meta/validation#/$defs/stringArray" } - ] - } - } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/meta/core.js -var core_default = { - "$id": "https://json-schema.org/draft/2020-12/meta/core", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$dynamicAnchor": "meta", - "title": "Core vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "$id": { - "type": "string", - "format": "uri-reference", - "$comment": "Non-empty fragments not allowed.", - "pattern": "^[^#]*#?$" - }, - "$schema": { - "type": "string", - "format": "uri" - }, - "$anchor": { - "type": "string", - "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$" - }, - "$ref": { - "type": "string", - "format": "uri-reference" - }, - "$dynamicRef": { - "type": "string", - "format": "uri-reference" - }, - "$dynamicAnchor": { - "type": "string", - "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$" - }, - "$vocabulary": { - "type": "object", - "propertyNames": { - "type": "string", - "format": "uri" - }, - "additionalProperties": { - "type": "boolean" - } - }, - "$comment": { - "type": "string" - }, - "$defs": { - "type": "object", - "additionalProperties": { "$dynamicRef": "#meta" }, - "default": {} - } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/meta/applicator.js -var applicator_default = { - "$id": "https://json-schema.org/draft/2020-12/meta/applicator", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$dynamicAnchor": "meta", - "title": "Applicator vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "prefixItems": { "$ref": "#/$defs/schemaArray" }, - "items": { "$dynamicRef": "#meta" }, - "contains": { "$dynamicRef": "#meta" }, - "additionalProperties": { "$dynamicRef": "#meta" }, - "properties": { - "type": "object", - "additionalProperties": { "$dynamicRef": "#meta" }, - "default": {} - }, - "patternProperties": { - "type": "object", - "additionalProperties": { "$dynamicRef": "#meta" }, - "propertyNames": { "format": "regex" }, - "default": {} - }, - "dependentSchemas": { - "type": "object", - "additionalProperties": { - "$dynamicRef": "#meta" - } - }, - "propertyNames": { "$dynamicRef": "#meta" }, - "if": { "$dynamicRef": "#meta" }, - "then": { "$dynamicRef": "#meta" }, - "else": { "$dynamicRef": "#meta" }, - "allOf": { "$ref": "#/$defs/schemaArray" }, - "anyOf": { "$ref": "#/$defs/schemaArray" }, - "oneOf": { "$ref": "#/$defs/schemaArray" }, - "not": { "$dynamicRef": "#meta" } - }, - "$defs": { - "schemaArray": { - "type": "array", - "minItems": 1, - "items": { "$dynamicRef": "#meta" } - } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/meta/validation.js -var validation_default2 = { - "$id": "https://json-schema.org/draft/2020-12/meta/validation", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$dynamicAnchor": "meta", - "title": "Validation vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "multipleOf": { - "type": "number", - "exclusiveMinimum": 0 - }, - "maximum": { - "type": "number" - }, - "exclusiveMaximum": { - "type": "number" - }, - "minimum": { - "type": "number" - }, - "exclusiveMinimum": { - "type": "number" - }, - "maxLength": { "$ref": "#/$defs/nonNegativeInteger" }, - "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "pattern": { - "type": "string", - "format": "regex" - }, - "maxItems": { "$ref": "#/$defs/nonNegativeInteger" }, - "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "uniqueItems": { - "type": "boolean", - "default": false - }, - "maxContains": { "$ref": "#/$defs/nonNegativeInteger" }, - "minContains": { - "$ref": "#/$defs/nonNegativeInteger", - "default": 1 - }, - "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" }, - "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/$defs/stringArray" }, - "dependentRequired": { - "type": "object", - "additionalProperties": { - "$ref": "#/$defs/stringArray" - } - }, - "const": true, - "enum": { - "type": "array", - "items": true - }, - "type": { - "anyOf": [ - { "$ref": "#/$defs/simpleTypes" }, - { - "type": "array", - "items": { "$ref": "#/$defs/simpleTypes" }, - "minItems": 1, - "uniqueItems": true - } - ] - } - }, - "$defs": { - "nonNegativeInteger": { - "type": "integer", - "minimum": 0 - }, - "nonNegativeIntegerDefault0": { - "$ref": "#/$defs/nonNegativeInteger", - "default": 0 - }, - "simpleTypes": { - "enum": [ - "array", - "boolean", - "integer", - "null", - "number", - "object", - "string" - ] - }, - "stringArray": { - "type": "array", - "items": { "type": "string" }, - "uniqueItems": true, - "default": [] - } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/meta/meta-data.js -var meta_data_default = { - "$id": "https://json-schema.org/draft/2020-12/meta/meta-data", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$dynamicAnchor": "meta", - "title": "Meta-data vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "title": { - "type": "string" - }, - "description": { - "type": "string" - }, - "default": true, - "deprecated": { - "type": "boolean", - "default": false - }, - "readOnly": { - "type": "boolean", - "default": false - }, - "writeOnly": { - "type": "boolean", - "default": false - }, - "examples": { - "type": "array", - "items": true - } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/meta/format-annotation.js -var format_annotation_default = { - "$id": "https://json-schema.org/draft/2020-12/meta/format-annotation", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$dynamicAnchor": "meta", - "title": "Format vocabulary meta-schema for annotation results", - "type": ["object", "boolean"], - "properties": { - "format": { "type": "string" } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/meta/format-assertion.js -var format_assertion_default = { - "$id": "https://json-schema.org/draft/2020-12/meta/format-assertion", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$dynamicAnchor": "meta", - "title": "Format vocabulary meta-schema for assertion results", - "type": ["object", "boolean"], - "properties": { - "format": { "type": "string" } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/meta/content.js -var content_default = { - "$id": "https://json-schema.org/draft/2020-12/meta/content", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$dynamicAnchor": "meta", - "title": "Content vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "contentMediaType": { "type": "string" }, - "contentEncoding": { "type": "string" }, - "contentSchema": { "$dynamicRef": "#meta" } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/meta/unevaluated.js -var unevaluated_default = { - "$id": "https://json-schema.org/draft/2020-12/meta/unevaluated", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$dynamicAnchor": "meta", - "title": "Unevaluated applicator vocabulary meta-schema", - "type": ["object", "boolean"], - "properties": { - "unevaluatedItems": { "$dynamicRef": "#meta" }, - "unevaluatedProperties": { "$dynamicRef": "#meta" } - } -}; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/dynamicAnchor.js -var dynamicAnchor_default2 = { id: "https://json-schema.org/keyword/draft-2020-12/dynamicAnchor" }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/dynamicRef.js -var id59 = "https://json-schema.org/keyword/draft-2020-12/dynamicRef"; -var compile60 = async (dynamicRef, ast) => { - const fragment3 = uriFragment(value(dynamicRef)); - const referencedSchema = await get2(value(dynamicRef), dynamicRef); - await validation_default.compile(referencedSchema, ast); - return [referencedSchema.document.baseUri, fragment3, canonicalUri(referencedSchema)]; -}; -var interpret60 = ([id62, fragment3, ref], instance, context) => { - if (fragment3 in context.ast.metaData[id62].dynamicAnchors) { - context.dynamicAnchors = { ...context.ast.metaData[id62].dynamicAnchors, ...context.dynamicAnchors }; - return validation_default.interpret(context.dynamicAnchors[fragment3], instance, context); - } else { - return validation_default.interpret(ref, instance, context); - } -}; -var simpleApplicator17 = true; -var plugin4 = { - beforeSchema(url, _instance, context) { - context.dynamicAnchors = { - ...context.ast.metaData[toAbsoluteUri2(url)].dynamicAnchors, - ...context.dynamicAnchors - }; - }, - beforeKeyword(_url, _instance, context, schemaContext) { - context.dynamicAnchors = schemaContext.dynamicAnchors; - } -}; -var dynamicRef_default2 = { id: id59, compile: compile60, interpret: interpret60, simpleApplicator: simpleApplicator17, plugin: plugin4 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/format.js -var id60 = "https://json-schema.org/keyword/draft-2020-12/format"; -var compile61 = (schema) => value(schema); -var interpret61 = (format, instance) => { - if (!getShouldValidateFormat()) { - return true; - } - const handler = getFormatHandler(formats2[format]); - return handler?.(value2(instance)) ?? true; -}; -var annotation13 = (format) => format; -var formats2 = { - "date-time": "https://json-schema.org/format/date-time", - "date": "https://json-schema.org/format/date", - "time": "https://json-schema.org/format/time", - "duration": "https://json-schema.org/format/duration", - "email": "https://json-schema.org/format/email", - "idn-email": "https://json-schema.org/format/idn-email", - "hostname": "https://json-schema.org/format/hostname", - "idn-hostname": "https://json-schema.org/format/idn-hostname", - "ipv4": "https://json-schema.org/format/ipv4", - "ipv6": "https://json-schema.org/format/ipv6", - "uri": "https://json-schema.org/format/uri", - "uri-reference": "https://json-schema.org/format/uri-reference", - "iri": "https://json-schema.org/format/iri", - "iri-reference": "https://json-schema.org/format/iri-reference", - "uuid": "https://json-schema.org/format/uuid", - "uri-template": "https://json-schema.org/format/uri-template", - "json-pointer": "https://json-schema.org/format/json-pointer", - "relative-json-pointer": "https://json-schema.org/format/relative-json-pointer", - "regex": "https://json-schema.org/format/regex" -}; -var format_default2 = { id: id60, compile: compile61, interpret: interpret61, annotation: annotation13, formats: formats2 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/format-assertion.js -var id61 = "https://json-schema.org/keyword/draft-2020-12/format-assertion"; -var compile62 = (schema) => value(schema); -var interpret62 = (format, instance) => { - const handler = getFormatHandler(formats3[format]); - if (!handler) { - throw Error(`The '${format}' format is not supported.`); - } - return handler(value2(instance)); -}; -var annotation14 = (format) => format; -var formats3 = { - "date-time": "https://json-schema.org/format/date-time", - "date": "https://json-schema.org/format/date", - "time": "https://json-schema.org/format/time", - "duration": "https://json-schema.org/format/duration", - "email": "https://json-schema.org/format/email", - "idn-email": "https://json-schema.org/format/idn-email", - "hostname": "https://json-schema.org/format/hostname", - "idn-hostname": "https://json-schema.org/format/idn-hostname", - "ipv4": "https://json-schema.org/format/ipv4", - "ipv6": "https://json-schema.org/format/ipv6", - "uri": "https://json-schema.org/format/uri", - "uri-reference": "https://json-schema.org/format/uri-reference", - "iri": "https://json-schema.org/format/iri", - "iri-reference": "https://json-schema.org/format/iri-reference", - "uuid": "https://json-schema.org/format/uuid", - "uri-template": "https://json-schema.org/format/uri-template", - "json-pointer": "https://json-schema.org/format/json-pointer", - "relative-json-pointer": "https://json-schema.org/format/relative-json-pointer", - "regex": "https://json-schema.org/format/regex" -}; -var format_assertion_default2 = { id: id61, compile: compile62, interpret: interpret62, annotation: annotation14, formats: formats3 }; - -// ../../node_modules/.pnpm/@hyperjump+json-schema@1.17.6_@hyperjump+browser@1.3.1/node_modules/@hyperjump/json-schema/draft-2020-12/index.js -addKeyword(dynamicRef_default2); -addKeyword(dynamicAnchor_default2); -addKeyword(format_default2); -addKeyword(format_assertion_default2); -defineVocabulary("https://json-schema.org/draft/2020-12/vocab/core", { - "$anchor": "https://json-schema.org/keyword/anchor", - "$comment": "https://json-schema.org/keyword/comment", - "$defs": "https://json-schema.org/keyword/definitions", - "$dynamicAnchor": "https://json-schema.org/keyword/draft-2020-12/dynamicAnchor", - "$dynamicRef": "https://json-schema.org/keyword/draft-2020-12/dynamicRef", - "$id": "https://json-schema.org/keyword/id", - "$ref": "https://json-schema.org/keyword/ref", - "$vocabulary": "https://json-schema.org/keyword/vocabulary" -}); -defineVocabulary("https://json-schema.org/draft/2020-12/vocab/applicator", { - "additionalProperties": "https://json-schema.org/keyword/additionalProperties", - "allOf": "https://json-schema.org/keyword/allOf", - "anyOf": "https://json-schema.org/keyword/anyOf", - "contains": "https://json-schema.org/keyword/contains", - "dependentSchemas": "https://json-schema.org/keyword/dependentSchemas", - "if": "https://json-schema.org/keyword/if", - "then": "https://json-schema.org/keyword/then", - "else": "https://json-schema.org/keyword/else", - "items": "https://json-schema.org/keyword/items", - "not": "https://json-schema.org/keyword/not", - "oneOf": "https://json-schema.org/keyword/oneOf", - "patternProperties": "https://json-schema.org/keyword/patternProperties", - "prefixItems": "https://json-schema.org/keyword/prefixItems", - "properties": "https://json-schema.org/keyword/properties", - "propertyNames": "https://json-schema.org/keyword/propertyNames" -}); -defineVocabulary("https://json-schema.org/draft/2020-12/vocab/validation", { - "const": "https://json-schema.org/keyword/const", - "dependentRequired": "https://json-schema.org/keyword/dependentRequired", - "enum": "https://json-schema.org/keyword/enum", - "exclusiveMaximum": "https://json-schema.org/keyword/exclusiveMaximum", - "exclusiveMinimum": "https://json-schema.org/keyword/exclusiveMinimum", - "maxContains": "https://json-schema.org/keyword/maxContains", - "maxItems": "https://json-schema.org/keyword/maxItems", - "maxLength": "https://json-schema.org/keyword/maxLength", - "maxProperties": "https://json-schema.org/keyword/maxProperties", - "maximum": "https://json-schema.org/keyword/maximum", - "minContains": "https://json-schema.org/keyword/minContains", - "minItems": "https://json-schema.org/keyword/minItems", - "minLength": "https://json-schema.org/keyword/minLength", - "minProperties": "https://json-schema.org/keyword/minProperties", - "minimum": "https://json-schema.org/keyword/minimum", - "multipleOf": "https://json-schema.org/keyword/multipleOf", - "pattern": "https://json-schema.org/keyword/pattern", - "required": "https://json-schema.org/keyword/required", - "type": "https://json-schema.org/keyword/type", - "uniqueItems": "https://json-schema.org/keyword/uniqueItems" -}); -defineVocabulary("https://json-schema.org/draft/2020-12/vocab/meta-data", { - "default": "https://json-schema.org/keyword/default", - "deprecated": "https://json-schema.org/keyword/deprecated", - "description": "https://json-schema.org/keyword/description", - "examples": "https://json-schema.org/keyword/examples", - "readOnly": "https://json-schema.org/keyword/readOnly", - "title": "https://json-schema.org/keyword/title", - "writeOnly": "https://json-schema.org/keyword/writeOnly" -}); -defineVocabulary("https://json-schema.org/draft/2020-12/vocab/format-annotation", { - "format": "https://json-schema.org/keyword/draft-2020-12/format" -}); -defineVocabulary("https://json-schema.org/draft/2020-12/vocab/format-assertion", { - "format": "https://json-schema.org/keyword/draft-2020-12/format-assertion" -}); -defineVocabulary("https://json-schema.org/draft/2020-12/vocab/content", { - "contentEncoding": "https://json-schema.org/keyword/contentEncoding", - "contentMediaType": "https://json-schema.org/keyword/contentMediaType", - "contentSchema": "https://json-schema.org/keyword/contentSchema" -}); -defineVocabulary("https://json-schema.org/draft/2020-12/vocab/unevaluated", { - "unevaluatedItems": "https://json-schema.org/keyword/unevaluatedItems", - "unevaluatedProperties": "https://json-schema.org/keyword/unevaluatedProperties" -}); -loadDialect("https://json-schema.org/draft/2020-12/schema", { - "https://json-schema.org/draft/2020-12/vocab/core": true, - "https://json-schema.org/draft/2020-12/vocab/applicator": true, - "https://json-schema.org/draft/2020-12/vocab/validation": true, - "https://json-schema.org/draft/2020-12/vocab/meta-data": true, - "https://json-schema.org/draft/2020-12/vocab/format-annotation": true, - "https://json-schema.org/draft/2020-12/vocab/content": true, - "https://json-schema.org/draft/2020-12/vocab/unevaluated": true -}, true); -registerSchema(schema_default); -registerSchema(core_default); -registerSchema(applicator_default); -registerSchema(validation_default2); -registerSchema(meta_data_default); -registerSchema(format_annotation_default); -registerSchema(format_assertion_default); -registerSchema(content_default); -registerSchema(unevaluated_default); - -// src/derive-session-context/read-preferences.ts -var import_yaml = __toESM(require_dist(), 1); - -// schemas/preferences.json -var preferences_default = { - $schema: "https://json-schema.org/draft/2020-12/schema", - $id: "https://github.com/williamthorsen/codeassembly/raw/agents-v0.1.0/packages/agents/schemas/preferences.json", - title: "Preferences", - description: "Configuration consumed by orchestrated agent skills. Resolved from .agents/preferences.yaml at the project level, with ~/.agents/preferences.yaml as a global fallback.", - type: "object", - properties: { - $schema: { - type: "string", - description: "JSON Schema reference URI for editor tooling." - }, - artifacts: { - type: "object", - description: "Artifact storage configuration: where generated artifacts live and how they are categorized.", - properties: { - base_dir: { - type: "string", - description: "Root directory for all generated artifacts. Supports `~` expansion. Default: `~/ai-artifacts`." - }, - paths: { - type: "object", - description: "Maps artifact category names (e.g., `chats`, `devlogs`, `plans`) to subdirectory names relative to the project artifact directory. Any category key is permitted; values must be strings.", - additionalProperties: { - type: "string" - } - } - } - }, - commit: { - type: "object", - description: "Commit-title rendering configuration consumed by the `describe-change.sh` script.", - properties: { - title_format: { - type: "string", - description: "Template string used to render commit titles. Supports tokens such as `{scope}`, `{type}`, `{title}`, `{ticket_ref}` and optional `[...]` groups that drop when their tokens are empty." - } - }, - required: ["title_format"] - }, - editors: { - type: "array", - description: "Optional list of editor configurations mapping file extensions to an editor command.", - items: { - type: "object", - properties: { - name: { - type: "string", - description: "Display name of the editor." - }, - command: { - type: "string", - description: "Shell command to open files. The file path is appended as an argument." - }, - extensions: { - type: "string", - description: "Glob pattern for file types this editor handles (e.g., `*.md`)." - } - }, - required: ["name", "command", "extensions"] - } - }, - integrations: { - type: "object", - description: "Per-integration configuration. Keys are integration names (e.g., `jira`, `github`, `linear`); each integration object must declare an `enabled` boolean.", - additionalProperties: { - type: "object", - properties: { - enabled: { - type: "boolean", - description: "Whether the integration is enabled." - } - }, - required: ["enabled"] - } - }, - merge: { - type: "object", - description: "Squash-merge title rendering configuration for the `merge-pr` skill family.", - properties: { - title_format: { - type: "string", - description: "Template string used to render the squash-merge commit title. Supports the same token vocabulary as `commit.title_format`, plus `{pr_number}`." - }, - strategy: { - type: "string", - description: "Reserved key. Not yet honored by the `merge-pr` skill family \u2014 the skill currently performs squash merges unconditionally. Recorded here so the schema does not flag the key as unknown when projects opt to set it in anticipation of future support." - }, - delete_branch: { - type: "boolean", - description: "Reserved key. Not yet honored by the `merge-pr` skill family \u2014 branch deletion is currently controlled by command-line flags and platform defaults. Recorded here so the schema does not flag the key as unknown when projects opt to set it in anticipation of future support." - } - } - }, - orchestration: { - type: "object", - description: "Configuration for the multi-phase orchestration pipeline (review rounds, severity thresholds, MCP policy, model overrides).", - properties: { - max_review_rounds: { - type: "integer", - description: "Maximum iterative review rounds before marking the run `needs_manual_review`. Overridden by `--max-review-rounds`." - }, - approval_threshold: { - type: "string", - description: "Minimum finding severity required for code approval. Overridden by `--approval-threshold`.", - enum: ["none", "low", "medium", "high"] - }, - budget_threshold: { - type: "string", - description: "Minimum finding severity for spending remaining review-round budget. Overridden by `--budget-threshold`.", - enum: ["none", "low", "medium", "high"] - }, - models: { - type: "object", - description: "Per-role model overrides (e.g., `coder`, `architect`, `holistic_reviewer`). Any role key is permitted; values must be strings naming a model.", - additionalProperties: { - type: "string" - } - }, - mcp_policy: { - type: "string", - description: "How to handle MCP unavailability: `required` aborts, `optional` continues with a warning, `prompt` asks the developer." - } - } - }, - platform: { - type: "string", - description: "Development platform. Initial supported values are `github` and `bitbucket`; new platforms can be added additively.", - enum: ["github", "bitbucket"] - }, - pr: { - type: "object", - description: "Pull-request title rendering configuration.", - properties: { - title_format: { - type: "string", - description: "Template string used to render pull-request titles. Supports the same token vocabulary as `commit.title_format`." - } - }, - required: ["title_format"] - }, - project: { - type: "object", - description: "Project identification configuration.", - properties: { - slug: { - type: "string", - description: "Project identifier used for namespacing artifacts under `{base_dir}/projects/{slug}/`." - }, - ticket_ref_prefix: { - type: "string", - description: "Prefix that appears at the start of `ticket_ref`. Use `#` for GitHub issues (added at render time, omitted from file paths) or a Jira project key like `MAC-` (part of the canonical ticket ID)." - } - } - }, - repository: { - type: "object", - description: "Repository configuration: default remote and (deprecated) project slug fallback.", - properties: { - default_remote: { - type: "object", - description: "Default git remote used when constructing remote refs such as `origin/main`.", - properties: { - name: { - type: "string", - description: "Name of the default git remote (e.g., `origin`)." - }, - default_branch: { - type: "string", - description: "Default branch of the remote (e.g., `main`)." - } - }, - required: ["name", "default_branch"] - }, - slug: { - type: "string", - description: "Deprecated. Use `project.slug` instead. Kept as a fallback." - } - } - }, - ticket: { - type: "object", - description: "Ticket (issue) title rendering configuration.", - properties: { - title_format: { - type: "string", - description: "Template string used to render ticket (issue) titles. Supports the same token vocabulary as `commit.title_format`." - } - }, - required: ["title_format"] - } - }, - additionalProperties: false -}; - -// src/derive-session-context/read-preferences.ts -var SCHEMA_ID = preferences_default.$id; -async function readPreferences(input) { - const home = input.home ?? homedir(); - const projectPath = path4.join(input.cwd, ".agents", "preferences.yaml"); - const globalPath = path4.join(home, ".agents", "preferences.yaml"); - const project = await readOptionalYaml(projectPath); - const global = await readOptionalYaml(globalPath); - const merged = mergeTopLevel(global?.value, project?.value); - await assertValidatesAgainstSchema(merged); - const sources = { - ...project !== null && { project: projectPath }, - ...global !== null && { global: globalPath } - }; - return { - preferences: merged, - sources - }; -} -async function readOptionalYaml(filePath) { - let text; - try { - text = await readFile(filePath, "utf8"); - } catch (error) { - if (isEnoentError(error)) { - return null; - } - throw error; - } - let parsed; - try { - parsed = (0, import_yaml.parse)(text); - } catch (error) { - const message = error instanceof Error ? error.message : String(error); - throw new Error(`${filePath}: malformed YAML \u2014 ${message}`); - } - return { value: parsed ?? {} }; -} -function mergeTopLevel(global, project) { - const result = {}; - if (isRecord(global)) { - for (const [key, value3] of Object.entries(global)) { - result[key] = value3; - } - } - if (isRecord(project)) { - for (const [key, value3] of Object.entries(project)) { - result[key] = value3; - } - } - return result; -} -async function assertValidatesAgainstSchema(merged) { - ensureSchemaRegistered(); - const jsonValue = toJsonValue(merged); - const output = await validate(SCHEMA_ID, jsonValue, "BASIC"); - if (!output.valid) { - throw new Error(formatValidationErrorMessage(output.errors)); - } -} -function formatValidationErrorMessage(errors) { - const tail = `Check the contents of .agents/preferences.yaml (or the global ~/.agents/preferences.yaml).`; - const error = pickMostSpecificError(errors); - if (!error) { - return `preferences failed schema validation against ${SCHEMA_ID}. ${tail}`; - } - const location = formatInstanceLocation(error.instanceLocation); - return `preferences failed schema validation at ${location} (failed keyword: ${error.keyword}). ${tail}`; -} -function pickMostSpecificError(errors) { - if (!errors) { - return void 0; - } - let best; - for (const candidate of errors) { - if (best === void 0 || candidate.instanceLocation.length > best.instanceLocation.length) { - best = candidate; - } - } - return best; -} -function formatInstanceLocation(raw) { - const fragmentIndex = raw.indexOf("#"); - const pointer = fragmentIndex !== -1 ? raw.slice(fragmentIndex + 1) : raw; - const decoded = decodeURI(pointer); - if (decoded === "" || decoded === "/") { - return '"(root)"'; - } - return `"${decoded.replace(/^\//, "")}"`; -} -function ensureSchemaRegistered() { - if (!hasSchema(SCHEMA_ID)) { - registerSchema(preferences_default, SCHEMA_ID); - } -} -function isRecord(value3) { - return typeof value3 === "object" && value3 !== null && !Array.isArray(value3); -} -function isEnoentError(error) { - if (!isRecord(error)) { - return false; - } - return error.code === "ENOENT"; -} -function toJsonValue(value3) { - if (value3 === null) { - return null; - } - if (typeof value3 === "string") { - return value3; - } - if (typeof value3 === "number") { - return value3; - } - if (typeof value3 === "boolean") { - return value3; - } - if (Array.isArray(value3)) { - return value3.map((entry) => toJsonValue(entry)); - } - if (isRecord(value3)) { - const result = {}; - for (const [key, entry] of Object.entries(value3)) { - result[key] = toJsonValue(entry); - } - return result; - } - throw new TypeError(`unexpected non-JSON value of type ${typeof value3}`); -} - -// src/derive-session-context/cli.ts -var execFileAsync = promisify(execFile); -var REQUIRED_MANIFEST_FIELDS = [ - "ticket_id", - "ticket_ref", - "project_slug", - "platform", - "default_branch", - "branch_name", - "artifact_base_dir", - "artifact_paths", - "created_at" -]; -async function main() { - try { - const parsed = parseArgs(process.argv.slice(2)); - const cwd2 = parsed.cwd ?? process.cwd(); - const branch = parsed.branch ?? await resolveCurrentBranch(cwd2); - const manifest = await deriveSessionContext({ - cwd: cwd2, - branch, - now: /* @__PURE__ */ new Date(), - ...parsed.home !== null && { home: parsed.home } - }); - process.stdout.write(`${JSON.stringify(manifest, null, 2)} -`); - } catch (error) { - const message = error instanceof Error ? error.message : String(error); - process.stderr.write(`derive-session-context: ${message} -`); - process.exit(1); - } -} -async function deriveSessionContext(input) { - if (input.branch === "" || input.branch === "HEAD") { - throw new Error("Detached HEAD: this script requires an active branch. Create or check out a branch first."); - } - const home = input.home ?? homedir2(); - const sanitizedBranch = sanitizeBranch(input.branch); - const newPath = path5.join(input.cwd, ".agents", `${sanitizedBranch}.branch-manifest.json`); - const oldPath = path5.join(input.cwd, ".agents", `${sanitizedBranch}.manifest.json`); - const cached = await tryReadManifest(newPath); - if (cached !== null) { - return cached; - } - const cachedOld = await tryReadManifest(oldPath); - if (cachedOld !== null) { - await mkdir(path5.dirname(newPath), { recursive: true }); - await writeFile(newPath, `${JSON.stringify(cachedOld, null, 2)} -`, "utf8"); - return cachedOld; - } - const readResult = await readPreferences({ cwd: input.cwd, home }); - const manifest = composeManifest({ - preferences: readResult.preferences, - branchName: input.branch, - cwd: input.cwd, - home, - now: input.now - }); - await mkdir(path5.dirname(newPath), { recursive: true }); - await writeFile(newPath, `${JSON.stringify(manifest, null, 2)} -`, "utf8"); - return manifest; -} -function sanitizeBranch(branch) { - let sanitized = branch.trim().replaceAll("/", "-"); - while (sanitized.endsWith("-")) { - sanitized = sanitized.slice(0, -1); - } - return sanitized; -} -async function tryReadManifest(filePath) { - let text; - try { - text = await readFile2(filePath, "utf8"); - } catch (error) { - if (isEnoentError2(error)) { - return null; - } - throw error; - } - let parsed; - try { - parsed = JSON.parse(text); - } catch { - process.stderr.write(`derive-session-context: warning: manifest at ${filePath} is corrupt; recomposing -`); - return null; - } - if (!isCurrentSchema(parsed)) { - return null; - } - return parsed; -} -function isCurrentSchema(value3) { - if (!isRecord2(value3)) { - return false; - } - for (const field of REQUIRED_MANIFEST_FIELDS) { - if (!(field in value3)) { - return false; - } - } - if (!isStringOrNull(value3.ticket_id) || !isStringOrNull(value3.ticket_ref)) { - return false; - } - if (!isRecord2(value3.artifact_paths)) { - return false; - } - if (value3.platform !== "github" && value3.platform !== "bitbucket") { - return false; + if (value.platform !== "github" && value.platform !== "bitbucket") { + return false; } return true; } -function isStringOrNull(value3) { - return value3 === null || typeof value3 === "string"; +function isStringOrNull(value) { + return value === null || typeof value === "string"; } function isEnoentError2(error) { if (!isRecord2(error)) { @@ -11447,12 +7726,12 @@ function isEnoentError2(error) { } return error.code === "ENOENT"; } -function isRecord2(value3) { - return typeof value3 === "object" && value3 !== null && !Array.isArray(value3); +function isRecord2(value) { + return typeof value === "object" && value !== null && !Array.isArray(value); } -async function resolveCurrentBranch(cwd2) { +async function resolveCurrentBranch(cwd) { try { - const { stdout } = await execFileAsync("git", ["-C", cwd2, "branch", "--show-current"]); + const { stdout } = await execFileAsync("git", ["-C", cwd, "branch", "--show-current"]); return stdout.trim(); } catch (error) { const message = error instanceof Error ? error.message : String(error); @@ -11461,7 +7740,7 @@ async function resolveCurrentBranch(cwd2) { } function parseArgs(argv) { let branch = null; - let cwd2 = null; + let cwd = null; let home = null; for (let i = 0; i < argv.length; i += 1) { const arg = argv[i]; @@ -11474,10 +7753,10 @@ function parseArgs(argv) { } else if (arg.startsWith("--branch=")) { branch = arg.slice("--branch=".length); } else if (arg === "--cwd") { - cwd2 = consumeValue(argv, i, "--cwd"); + cwd = consumeValue(argv, i, "--cwd"); i += 1; } else if (arg.startsWith("--cwd=")) { - cwd2 = arg.slice("--cwd=".length); + cwd = arg.slice("--cwd=".length); } else if (arg === "--home") { home = consumeValue(argv, i, "--home"); i += 1; @@ -11487,14 +7766,14 @@ function parseArgs(argv) { throw new Error(`unknown argument: ${arg}`); } } - return { branch, cwd: cwd2, home }; + return { branch, cwd, home }; } function consumeValue(argv, index, flag) { - const value3 = argv[index + 1]; - if (value3 === void 0 || value3.startsWith("--")) { + const value = argv[index + 1]; + if (value === void 0 || value.startsWith("--")) { throw new Error(`${flag} requires a value`); } - return value3; + return value; } if (isMain()) { await main(); @@ -11505,7 +7784,7 @@ function isMain() { return false; } try { - return realpathSync(fileURLToPath2(import.meta.url)) === realpathSync(entry); + return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(entry); } catch (error) { const message = error instanceof Error ? error.message : String(error); process.stderr.write(`derive-session-context: warning: could not determine entry point: ${message} @@ -11518,12 +7797,3 @@ export { parseArgs, sanitizeBranch }; -/*! Bundled license information: - -content-type/index.js: - (*! - * content-type - * Copyright(c) 2015 Douglas Christopher Wilson - * MIT Licensed - *) -*/ diff --git a/packages/agents/src/derive-session-context/__tests__/read-preferences.test.ts b/packages/agents/src/derive-session-context/__tests__/read-preferences.test.ts index c3a15341..8f0f8e00 100644 --- a/packages/agents/src/derive-session-context/__tests__/read-preferences.test.ts +++ b/packages/agents/src/derive-session-context/__tests__/read-preferences.test.ts @@ -64,27 +64,61 @@ describe(readPreferences, () => { await expect(readPreferences({ cwd: projectDir, home: homeDir })).rejects.toThrow(/malformed YAML/); }); - it('throws on schema-validation failure', async () => { - // Unknown top-level key violates the schema's `additionalProperties: false` root constraint. + it('tolerates unknown top-level keys', async () => { await writeProjectYaml(projectDir, 'mystery_key: "mystery value"\n'); - await expect(readPreferences({ cwd: projectDir, home: homeDir })).rejects.toThrow(/schema validation/); + const result = await readPreferences({ cwd: projectDir, home: homeDir }); + expect(result.preferences).toEqual({}); + }); + + it('tolerates unknown keys inside nested sections', async () => { + await writeProjectYaml(projectDir, 'artifacts:\n enabled: true\n base_dir: ~/foo\n'); + const result = await readPreferences({ cwd: projectDir, home: homeDir }); + expect(result.preferences.artifacts).toEqual({ base_dir: '~/foo' }); }); - it('throws on schema-violating enum value with the offending key in the message', async () => { - // `platform: gitlab` violates the `platform` enum (`github` | `bitbucket`). The thrown message - // must name the failing key path so the developer can find the offending line in their YAML. + it('tolerates a mix of unknown top-level and nested keys', async () => { + await writeProjectYaml( + projectDir, + [ + 'artifacts:', + ' enabled: true', + ' base_dir: ~/ai-artifacts', + 'merge_commit:', + " title_format: '[{ticket_ref}] {title}'", + 'platform: github', + 'project:', + ' slug: my-project', + 'worktrees:', + ' location: sibling', + '', + ].join('\n'), + ); + const result = await readPreferences({ cwd: projectDir, home: homeDir }); + expect(result.preferences).toEqual({ + artifacts: { base_dir: '~/ai-artifacts' }, + platform: 'github', + project: { slug: 'my-project' }, + }); + }); + + it('throws with the offending key path when `platform` is outside the allowed enum', async () => { await writeProjectYaml(projectDir, 'platform: gitlab\n'); - await expect(readPreferences({ cwd: projectDir, home: homeDir })).rejects.toThrow(/at "platform"/); + await expect(readPreferences({ cwd: projectDir, home: homeDir })).rejects.toThrow( + /'platform' must be "github" or "bitbucket"/, + ); + }); + + it('throws with the offending key path when a consumed string field has the wrong type', async () => { + await writeProjectYaml(projectDir, 'artifacts:\n base_dir: 42\n'); + await expect(readPreferences({ cwd: projectDir, home: homeDir })).rejects.toThrow( + /'artifacts\.base_dir' must be a string/, + ); }); - it('points at deeply nested keys in the validation error message', async () => { - // `repository.default_remote.name` is declared `type: string` in the schema; supplying an - // integer triggers a type violation at a nested instance location. The thrown message must - // surface that nested path so a typo or wrong-type value can be located without reading the - // whole file. + it('throws with the offending key path when a consumed nested string field has the wrong type', async () => { await writeProjectYaml(projectDir, 'repository:\n default_remote:\n name: 1234\n default_branch: main\n'); await expect(readPreferences({ cwd: projectDir, home: homeDir })).rejects.toThrow( - /at "repository\/default_remote\/name"/, + /'repository\.default_remote\.name' must be a string/, ); }); }); diff --git a/packages/agents/src/derive-session-context/read-preferences.ts b/packages/agents/src/derive-session-context/read-preferences.ts index 62cb757a..9dc9070e 100644 --- a/packages/agents/src/derive-session-context/read-preferences.ts +++ b/packages/agents/src/derive-session-context/read-preferences.ts @@ -1,33 +1,28 @@ /** - * Read `.agents/preferences.yaml` (project-local) and `~/.agents/preferences.yaml` (global), - * merge with project-overrides-global precedence, validate against `schemas/preferences.json`, - * and return a typed object alongside the source paths that were actually read. + * Read `.agents/preferences.yaml` (project-local) and `~/.agents/preferences.yaml` (global), merge + * with project-overrides-global precedence, project to the typed shape the deriver consumes, and + * return that alongside the source paths actually read. + * + * Unknown sibling keys at any depth are tolerated. Schema validation is an authoring-time concern, + * not a read-time one. */ import { readFile } from 'node:fs/promises'; import { homedir } from 'node:os'; import path from 'node:path'; -import { hasSchema, type OutputUnit, registerSchema, validate } from '@hyperjump/json-schema/draft-2020-12'; import { parse as parseYaml } from 'yaml'; -// Inline the preferences schema at bundle time. esbuild resolves the `.json` import via its built-in -// JSON loader, embedding the parsed object directly in the `.mjs`. tsx in dev mode also supports the -// import attribute, so the source-tree run works identically to the bundled run. -import preferencesSchema from '../../schemas/preferences.json' with { type: 'json' }; -import type { PreferencesReadResult } from './types.ts'; - -/** Recursive shape of any JSON-decoded value, matching the validator's `Json` parameter. */ -type JsonValue = string | number | boolean | null | { [key: string]: JsonValue } | JsonValue[]; - -const SCHEMA_ID = preferencesSchema.$id; +import type { PreferencesReadResult, ResolvedPreferences } from './types.ts'; /** * Reads project and global preferences files (both optional), merges them with project values - * winning over global, validates against `schemas/preferences.json`, and returns the typed result. + * winning over global, projects to the typed `ResolvedPreferences` shape by reading only the + * fields the deriver consumes, and returns the result. * * - Missing files (project or global) are not errors — treated as empty and the other source is used. * - Malformed YAML throws with a message that names the offending file. - * - Schema-validation failure throws with a message identifying the offending key path. + * - Wrong type or out-of-enum value on a consumed field throws with a key-path-anchored message. + * - Unknown sibling keys at any depth pass through silently. */ export async function readPreferences(input: { cwd: string; home?: string }): Promise { const home = input.home ?? homedir(); @@ -38,8 +33,7 @@ export async function readPreferences(input: { cwd: string; home?: string }): Pr const global = await readOptionalYaml(globalPath); const merged = mergeTopLevel(global?.value, project?.value); - - await assertValidatesAgainstSchema(merged); + const preferences = projectPreferences(merged); const sources: PreferencesReadResult['sources'] = { ...(project !== null && { project: projectPath }), @@ -47,7 +41,7 @@ export async function readPreferences(input: { cwd: string; home?: string }): Pr }; return { - preferences: merged, + preferences, sources, }; } @@ -105,79 +99,132 @@ function mergeTopLevel(global: unknown, project: unknown): Record): Promise { - ensureSchemaRegistered(); - // The validator's parameter is `Json`; convert the merged record through `toJsonValue` so it - // arrives as a fully-typed `JsonValue` shape (no `any` assertion needed at the call site). - const jsonValue = toJsonValue(merged); - // `BASIC` output emits a flat list of `OutputUnit` entries, each carrying `keyword` and - // `instanceLocation`. `FLAG` would only return `{valid: boolean}`, leaving no way to surface - // the offending key in the thrown message. - const output = await validate(SCHEMA_ID, jsonValue, 'BASIC'); - if (!output.valid) { - throw new Error(formatValidationErrorMessage(output.errors)); +function projectPreferences(merged: Record): ResolvedPreferences { + const result: WritablePreferences = {}; + + if (merged.platform !== undefined) { + result.platform = expectPlatform(merged.platform); } -} -/** - * Renders a user-facing message naming the offending key path and the failed schema keyword. Falls - * back to a generic message when the error list is empty or unparseable. - */ -function formatValidationErrorMessage(errors: readonly OutputUnit[] | undefined): string { - const tail = `Check the contents of .agents/preferences.yaml (or the global ~/.agents/preferences.yaml).`; - const error = pickMostSpecificError(errors); - if (!error) { - return `preferences failed schema validation against ${SCHEMA_ID}. ${tail}`; + if (merged.project !== undefined) { + const section = expectRecord(merged.project, 'project'); + const project: WritablePreferences['project'] = {}; + if (section.slug !== undefined) { + project.slug = expectString(section.slug, 'project.slug'); + } + if (section.ticket_ref_prefix !== undefined) { + project.ticket_ref_prefix = expectString(section.ticket_ref_prefix, 'project.ticket_ref_prefix'); + } + result.project = project; } - const location = formatInstanceLocation(error.instanceLocation); - return `preferences failed schema validation at ${location} (failed keyword: ${error.keyword}). ${tail}`; -} -/** - * Picks the most informative error from a `BASIC`-output error list. Hyperjump emits parent - * errors before child errors, so the deepest `instanceLocation` is the most specific one — that - * is what a user typing into a YAML file most wants to know. - */ -function pickMostSpecificError(errors: readonly OutputUnit[] | undefined): OutputUnit | undefined { - if (!errors) { - return undefined; + if (merged.repository !== undefined) { + const section = expectRecord(merged.repository, 'repository'); + const repository: WritablePreferences['repository'] = {}; + if (section.slug !== undefined) { + repository.slug = expectString(section.slug, 'repository.slug'); + } + if (section.default_remote !== undefined) { + const remoteSection = expectRecord(section.default_remote, 'repository.default_remote'); + const defaultRemote: NonNullable['default_remote'] = {}; + if (remoteSection.name !== undefined) { + defaultRemote.name = expectString(remoteSection.name, 'repository.default_remote.name'); + } + if (remoteSection.default_branch !== undefined) { + defaultRemote.default_branch = expectString( + remoteSection.default_branch, + 'repository.default_remote.default_branch', + ); + } + repository.default_remote = defaultRemote; + } + result.repository = repository; } - let best: OutputUnit | undefined; - for (const candidate of errors) { - if (best === undefined || candidate.instanceLocation.length > best.instanceLocation.length) { - best = candidate; + + if (merged.artifacts !== undefined) { + const section = expectRecord(merged.artifacts, 'artifacts'); + const artifacts: WritablePreferences['artifacts'] = {}; + if (section.base_dir !== undefined) { + artifacts.base_dir = expectString(section.base_dir, 'artifacts.base_dir'); } + if (section.paths !== undefined) { + const pathsSection = expectRecord(section.paths, 'artifacts.paths'); + const paths: Record = {}; + for (const [key, value] of Object.entries(pathsSection)) { + paths[key] = expectString(value, `artifacts.paths.${key}`); + } + artifacts.paths = paths; + } + result.artifacts = artifacts; } - return best; + + return result; +} + +/** Mutable mirror of `ResolvedPreferences` used during projection construction. */ +interface WritablePreferences { + platform?: 'github' | 'bitbucket'; + project?: { + slug?: string; + ticket_ref_prefix?: string; + }; + repository?: { + slug?: string; + default_remote?: { + name?: string; + default_branch?: string; + }; + }; + artifacts?: { + base_dir?: string; + paths?: Record; + }; } /** - * Formats an `instanceLocation` for human-readable display. Hyperjump emits the location as - * `{baseUri}#{json-pointer}` (e.g., `#/platform`); strip the URI and the leading `/`. The root - * instance renders as `"(root)"`. + * Narrows `value` to the `platform` enum. Throws with the offending key path when the value is + * neither `"github"` nor `"bitbucket"`. */ -function formatInstanceLocation(raw: string): string { - const fragmentIndex = raw.indexOf('#'); - const pointer = fragmentIndex !== -1 ? raw.slice(fragmentIndex + 1) : raw; - const decoded = decodeURI(pointer); - if (decoded === '' || decoded === '/') { - return '"(root)"'; +function expectPlatform(value: unknown): 'github' | 'bitbucket' { + if (value === 'github' || value === 'bitbucket') { + return value; + } + throw new Error(`preferences: 'platform' must be "github" or "bitbucket" (got ${formatValue(value)})`); +} + +/** Narrows `value` to `string`. Throws with the offending key path when the value is not a string. */ +function expectString(value: unknown, keyPath: string): string { + if (typeof value === 'string') { + return value; + } + throw new Error(`preferences: '${keyPath}' must be a string (got ${formatValue(value)})`); +} + +/** Narrows `value` to a plain object. Throws with the offending key path when the value is not one. */ +function expectRecord(value: unknown, keyPath: string): Record { + if (isRecord(value)) { + return value; } - return `"${decoded.replace(/^\//, '')}"`; + throw new Error(`preferences: '${keyPath}' must be an object (got ${formatValue(value)})`); } /** - * Registers the inlined schema if not already registered. `hasSchema` checks the library's global - * schema registry, so registrations from earlier vitest runs or repeated CLI invocations within a - * single process are correctly recognized — avoiding the duplicate-registration error that - * `@hyperjump/json-schema` throws on re-registration. + * Renders an unknown value for an error message. Strings are quoted; everything else goes through + * `JSON.stringify` so arrays, numbers, booleans, and `null` render distinguishably. Symbols and + * other non-serializable values fall back to `String(value)`. */ -function ensureSchemaRegistered(): void { - if (!hasSchema(SCHEMA_ID)) { - registerSchema(preferencesSchema, SCHEMA_ID); +function formatValue(value: unknown): string { + if (typeof value === 'string') { + return JSON.stringify(value); + } + try { + return JSON.stringify(value); + } catch { + return String(value); } } @@ -194,36 +241,4 @@ function isEnoentError(error: unknown): boolean { return error.code === 'ENOENT'; } -/** - * Recursively converts an arbitrary JSON-compatible value (e.g., the output of `JSON.parse` or - * `yaml.parse`) into the structural `JsonValue` shape. Throws if a non-JSON value (function, - * symbol, `undefined`, `bigint`) is encountered — none of these can occur in valid YAML or JSON, - * so the throw is a defensive guard rather than an expected path. - */ -function toJsonValue(value: unknown): JsonValue { - if (value === null) { - return null; - } - if (typeof value === 'string') { - return value; - } - if (typeof value === 'number') { - return value; - } - if (typeof value === 'boolean') { - return value; - } - if (Array.isArray(value)) { - return value.map((entry) => toJsonValue(entry)); - } - if (isRecord(value)) { - const result: { [key: string]: JsonValue } = {}; - for (const [key, entry] of Object.entries(value)) { - result[key] = toJsonValue(entry); - } - return result; - } - throw new TypeError(`unexpected non-JSON value of type ${typeof value}`); -} - // endregion | Helpers diff --git a/packages/agents/src/derive-session-context/types.ts b/packages/agents/src/derive-session-context/types.ts index 133d67f5..c2485e9c 100644 --- a/packages/agents/src/derive-session-context/types.ts +++ b/packages/agents/src/derive-session-context/types.ts @@ -1,6 +1,6 @@ /** Shared types for the session-context deriver. */ -/** Resolved preferences object — narrow projection of `schemas/preferences.json` covering the fields the deriver consumes. */ +/** A narrow projection of `schemas/preferences.json` covering the fields the deriver consumes. */ export interface ResolvedPreferences { /** Top-level `platform` (`"github"` or `"bitbucket"`); may be undefined when not configured. */ readonly platform?: 'github' | 'bitbucket'; @@ -26,7 +26,10 @@ export interface ResolvedPreferences { /** Result of reading and merging the project and global preferences files. */ export interface PreferencesReadResult { - /** The merged, schema-validated preferences object. */ + /** + * The merged preferences, projected to the fields the deriver consumes. + * Unknown sibling keys at any depth are dropped; wrong-typed consumed fields throw at read time. + */ readonly preferences: ResolvedPreferences; /** Source-file paths actually present and read (project, global). */ readonly sources: { @@ -41,7 +44,7 @@ export interface TicketIdResult { readonly ticket_ref: string | null; } -/** Branch-manifest JSON object — the canonical session-context manifest persisted at `.agents/{sanitized-branch}.branch-manifest.json`. */ +/** The canonical session-context manifest persisted at `.agents/{sanitized-branch}.branch-manifest.json`. */ export interface BranchManifest { readonly ticket_id: string | null; readonly ticket_ref: string | null;