buddy-agent-harness 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/dist/cli.mjs +243 -11
- package/dist/index.d.mts +68 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +248 -12
- package/dist/index.mjs.map +1 -1
- package/dist/skill-scripts/doctor.mjs +44 -43
- package/dist/skill-scripts/init.mjs +44 -43
- package/dist/skill-scripts/mcp.mjs +44 -43
- package/dist/skill-scripts/reference.mjs +44 -43
- package/llms.txt +3 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skills/doctor-buddy-agent-harness/SKILL.md +5 -1
- package/skills/doctor-buddy-agent-harness/references/global-instructions.md +30 -0
- package/skills/doctor-buddy-agent-harness/references/harnesses/claude-code.md +3 -2
- package/skills/doctor-buddy-agent-harness/references/harnesses/codex.md +4 -2
- package/skills/doctor-buddy-agent-harness/references/harnesses/copilot-cli.md +3 -2
- package/skills/doctor-buddy-agent-harness/references/harnesses/cursor.md +1 -1
- package/skills/doctor-buddy-agent-harness/references/harnesses/gemini-cli.md +2 -2
- package/skills/doctor-buddy-agent-harness/scripts/doctor.mjs +44 -43
- package/skills/enhance/SKILL.md +16 -5
- package/skills/enhance/references/session-scope.history.md +9 -0
- package/skills/enhance/references/session-scope.md +75 -0
- package/skills/enhance/scripts/doctor.mjs +486 -0
- package/skills/init-buddy-agent-harness/SKILL.md +1 -1
- package/skills/init-buddy-agent-harness/scripts/doctor.mjs +44 -43
- package/skills/init-buddy-agent-harness/scripts/init.mjs +44 -43
- package/skills/reference/SKILL.md +1 -1
- package/skills/reference/scripts/reference.mjs +44 -43
- package/skills/repair/SKILL.md +3 -1
- package/skills/repair/scripts/doctor.mjs +44 -43
- package/skills/repair/scripts/mcp.mjs +44 -43
- package/src/diagnose-bridges/diagnose-bridges.ts +27 -2
- package/src/diagnose-bridges/diagnose-global-instructions.ts +154 -0
- package/src/diagnose-bridges/diagnose-instructions.ts +7 -2
- package/src/diagnose-bridges/doctor-guidance.ts +152 -6
- package/src/diagnose-bridges/doctor.command.ts +6 -1
- package/src/harness-registry/harness-registry.ts +38 -4
- package/src/harness-registry/instruction-bridge.ts +25 -9
- package/src/index.ts +8 -0
- package/src/skill-scripts/launchers.ts +1 -0
|
@@ -90,7 +90,7 @@ ${toPrettyType(e.config)}`:``}function toPrettyType(e){return tersify(toTypeObje
|
|
|
90
90
|
`)?e:`${e}\n`)}function encodeResult(e,t){return t===`json`?JSON.stringify(e):t===`text`?renderText(e):encode(e)}function cell(e){return e===void 0?``:String(e)}function table(e){let t=[...new Set(e.flatMap(e=>Object.keys(e)))],n=t.map(t=>Math.max(t.length,...e.map(e=>cell(e[t]).length))),line=e=>` ${e.map((e,t)=>e.padEnd(n[t])).join(` `)}`.trimEnd();return[line(t),...e.map(e=>line(t.map(t=>cell(e[t]))))]}function renderText(e){let t=Object.entries(e).map(([e,t])=>{if(!Array.isArray(t))return[`${e}: ${isRecord$1(t)?JSON.stringify(t):String(t)}`];if(!t.length)return[`${e}: (none)`];let n=t.every(isRecord$1)?table(t):t.map(e=>` - ${String(e)}`);return[`${e}:`,...n]});return t.flatMap((e,n)=>{let r=t[n-1];return r&&(r.length>1||e.length>1)?[``,...e]:e}).join(`
|
|
91
91
|
`)}function collapseHome(e,t){return e&&t.startsWith(e+C)?`~${t.slice(e.length)}`:t}function displayBinPath(e,t){return t?collapseHome(e,t):`buddy-agent-harness`}const ua=new Set([`deps`,`dependencies`,`local`,`plugins`,`marketplace`,`plugin`,`default`]);function isGenericName(e){return ua.has(e.toLowerCase())}function marketplaceName$1(e){return e.replace(/^@/,``).replace(/\//g,`-`).replace(/[^a-zA-Z0-9-_.]/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)||`agent-plugins`}__name(marketplaceName$1,`marketplaceName`);function declaredDependencies(e){if(!e||typeof e!=`object`)return[];let t=e,n=new Set;for(let e of[`dependencies`,`devDependencies`]){let r=t[e];if(r&&typeof r==`object`)for(let e of Object.keys(r))n.add(e)}return[...n].sort()}function buildCatalog({name:e,owner:t,plugins:n}){let r=[...n].sort((e,t)=>e.plugin.localeCompare(t.plugin)).map(({plugin:e,package:t,version:n,description:r})=>{let i={source:`npm`,package:t,version:n};return r?{name:e,source:i,description:r}:{name:e,source:i}});return{name:e,owner:{name:t},description:`Plugins provided by this repository’s dependencies. Generated — do not edit.`,plugins:r}}function serializeCatalog(e){return`${JSON.stringify(e,null,` `)}\n`}function readJson$2(e){try{return JSON.parse(o(e,`utf8`))}catch{return}}__name(readJson$2,`readJson`);function ancestorCandidates(e,t){let n=t.split(`/`),r=[],i=e;for(;;){r.push(v(i,`node_modules`,...n));let e=g(i);if(e===i)break;i=e}return r}function packageDir(t,n){try{let r=e(n);return g(r.resolve(`${t}/package.json`))}catch{}for(let e of ancestorCandidates(g(n),t))if(r(v(e,`package.json`)))return e}function readDepPlugin(e,t){let n=packageDir(e,t);if(!n)return{ok:!1,package:e,reason:`unresolved`};let r=readJson$2(v(n,`plugin.json`));if(!r||typeof r!=`object`)return{ok:!1,package:e,reason:`no-manifest`};let i=r,a=typeof i.name==`string`?i.name:void 0;if(!a)return{ok:!1,package:e,reason:`unnamed`};let o=readJson$2(v(n,`package.json`)),s=typeof o?.version==`string`?o.version:void 0;if(!s)return{ok:!1,package:e,reason:`no-manifest`};let c=typeof i.description==`string`?i.description:void 0;return{ok:!0,plugin:c?{package:e,plugin:a,version:s,description:c}:{package:e,plugin:a,version:s}}}function isPnp(){return!!process.versions.pnp}const da=v(`.agents`,`buddy-agent-harness`),fa=v(da,`.claude-plugin`,`marketplace.json`);function readManifest(e){return JSON.parse(o(e,`utf8`))}function deriveCatalog(e){let t=v(e,`package.json`),n=readManifest(t),r=[],i=[];for(let e of declaredDependencies(n)){let n=readDepPlugin(e,t);n.ok?r.push(n.plugin):n.reason===`unresolved`&&i.push({package:e,reason:n.reason})}let a=typeof n.name==`string`?n.name:`unknown`,o=marketplaceName$1(a);return{catalog:buildCatalog({name:o,owner:a,plugins:r}),plugins:r,unresolved:i,genericName:isGenericName(o),pnp:isPnp()}}function catalogStatus(e,t){let n;try{n=o(v(e,fa),`utf8`)}catch{n=void 0}return n===serializeCatalog(t)?`unchanged`:n===void 0?`created`:`updated`}function writeCatalog(e,t){let n=catalogStatus(e,t);if(n===`unchanged`)return n;let r=v(e,fa);return a(g(r),{recursive:!0}),m(r,serializeCatalog(t)),n}function readJson$1(e){try{return JSON.parse(o(e,`utf8`))}catch{return}}__name(readJson$1,`readJson`);function directories$1(e){try{return s(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}__name(directories$1,`directories`);function claudeConfigDir(e,t=process.env){return t.CLAUDE_CONFIG_DIR||v(e,`.claude`)}function readClaudeState(e){let t=readJson$1(v(e,`plugins`,`installed_plugins.json`)),n=[];for(let[e,r]of Object.entries(t?.plugins??{}))if(Array.isArray(r))for(let t of r){if(!t||typeof t!=`object`)continue;let r=t,i=typeof r.version==`string`?r.version:void 0,a=typeof r.scope==`string`?r.scope:void 0;if(!i||!a)continue;let o=typeof r.projectPath==`string`?r.projectPath:void 0;n.push(o?{id:e,version:i,scope:a,projectPath:o}:{id:e,version:i,scope:a})}let r=readJson$1(v(e,`plugins`,`known_marketplaces.json`)),i=[];for(let[e,t]of Object.entries(r??{}))i.push({name:e,path:typeof t?.source?.path==`string`?t.source.path:``});return{installed:n,marketplaces:i}}const pa={name:`claude-code`,scoped:!0,installedOnMachine:(e,t=process.env)=>r(claudeConfigDir(e,t)),state:(e,t=process.env)=>readClaudeState(claudeConfigDir(e,t)),register:e=>`claude plugin marketplace add ./${e} --scope project`,install:e=>`claude plugin install ${e} --scope project`,update:e=>`claude plugin update ${e} --scope project`,uninstall:e=>`claude plugin uninstall ${e} --scope project`,refreshMarketplace:e=>`claude plugin marketplace update ${e}`};function codexHome(e,t=process.env){return t.CODEX_HOME||v(e,`.codex`)}function readCodexState(e){let t=v(e,`plugins`,`cache`),n=[];for(let e of directories$1(t))for(let r of directories$1(v(t,e)))for(let i of directories$1(v(t,e,r)))n.push({id:`${r}@${e}`,version:i,scope:`user`});let r=[],i=``;try{i=o(v(e,`config.toml`),`utf8`)}catch{i=``}let a;for(let e of i.split(`
|
|
92
92
|
`)){let t=/^\s*\[marketplaces\.(?:"([^"]+)"|([^\]]+))\]\s*$/.exec(e);if(t){a={name:t[1]??t[2],path:``},r.push(a);continue}if(/^\s*\[/.test(e)){a=void 0;continue}let n=a?/^\s*source\s*=\s*"([^"]*)"\s*$/.exec(e):void 0;n?.[1]&&a&&(a.path=n[1])}return{installed:n,marketplaces:r}}const ma=[pa,{name:`codex`,scoped:!1,installedOnMachine:(e,t=process.env)=>r(codexHome(e,t)),state:(e,t=process.env)=>readCodexState(codexHome(e,t)),register:e=>`codex plugin marketplace add ./${e}`,install:e=>`codex plugin add ${e}`,update:e=>`codex plugin add ${e}`,uninstall:e=>`codex plugin remove ${e}`,refreshMarketplace:()=>``}];function ours(e,t,n,r){let i=`@${t}`;return e.filter(e=>e.id.endsWith(i)&&(!r||e.projectPath===n))}function reconcile({catalog:e,catalogDir:t,root:n,installed:r,marketplaces:i,scoped:a=!0}){let o=i.find(t=>t.name===e.name),s=[],c=t.split(/[\\/]/).filter(Boolean),l=o?c.every(e=>o.path.includes(e)):!1,u=o&&!l?o.path:void 0;o||s.push({kind:`register`,subject:e.name,detail:`marketplace is not registered with this harness`});let d=ours(r,e.name,n,a),p=new Map(d.map(e=>[e.id,e]));for(let t of e.plugins){let n=`${t.name}@${e.name}`,r=p.get(n);if(!r){s.push({kind:`install`,subject:n,detail:`not installed; catalog pins ${t.source.version}`});continue}r.version!==t.source.version&&s.push({kind:`update`,subject:n,detail:`installed ${r.version}, catalog pins ${t.source.version}`})}let m=new Set(e.plugins.map(t=>`${t.name}@${e.name}`));for(let e of d)m.has(e.id)||s.push({kind:`uninstall`,subject:e.id,detail:`installed but no longer in the catalog; it will report a load failure until removed`});return{actions:s,...u?{collision:u}:{},unregistered:!o}}function commandFor(e,t,n){switch(t.kind){case`register`:return e.register(da);case`install`:return e.install(t.subject);case`update`:{let r=e.refreshMarketplace(n),i=e.update(t.subject);return r?`${r} && ${i}`:i}case`uninstall`:return e.uninstall(t.subject)}}function notesFor(e){let t=[];e.pnp&&t.push(`Yarn Plug’n’Play is active: dependencies live inside zip archives, so no harness can install from them. Set nodeLinker: node-modules, or unplug the plugin dependencies.`),e.genericName&&t.push(`Marketplace name "${e.catalog.name}" is generic. Registering a second marketplace under a name already in use replaces the first silently, and the install that follows reports "already installed" — the repository then runs the other one's versions.`);for(let{package:n}of e.unresolved)t.push(`Declared dependency "${n}" is not installed; install dependencies before generating.`);return t}const ha=command({name:`dep-plugins`,description:`Derive the marketplace catalog for plugins shipped by this repository’s dependencies, so a harness can install them. Writes the catalog; installing is the harness’s own job.`,options:{root:{description:`Repository directory. Defaults to the current directory.`,type:q(K())},check:{description:`Report whether the catalog is current without writing it. For CI and postinstall.`,type:q(Fn())},format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`}},run(e){try{let t=parseFormat(e.format),n=e.root??process.cwd(),r=deriveCatalog(n),i=e.check?catalogStatus(n,r.catalog)===`unchanged`?`current`:`would-change`:writeCatalog(n,r.catalog),a=E(),o=notesFor(r),s=ma.filter(e=>e.installedOnMachine(a)),c=[],l=[];for(let e of s){let t=e.state(a),i=reconcile({catalog:r.catalog,catalogDir:da,root:S(n),installed:t.installed,marketplaces:t.marketplaces,scoped:e.scoped});i.collision&&o.push(`${e.name}: marketplace "${r.catalog.name}" is already registered against ${i.collision}. Registering over it replaces the other repository's silently, and the install that follows reports "already installed" — rename this repository's marketplace instead.`),c.push({runtime:e.name,status:i.actions.length?`${i.actions.length} to apply`:`in sync`});for(let t of i.actions)l.push({runtime:e.name,do:commandFor(e,t,r.catalog.name),subject:t.subject,why:t.detail})}return r.plugins.length&&o.push(`Copilot CLI rejects an npm marketplace source, so it cannot install from this catalog. It needs a path-sourced catalog, which cannot reach node_modules from a subdirectory.`),writeResult({catalog:fa,marketplace:r.catalog.name,outcome:i,plugins:r.plugins.length?r.plugins.map(({plugin:e,package:t,version:n})=>({name:e,package:t,version:n})):`0 dependencies ship a plugin — nothing to install`,harness:c.length?c:`no supported harness detected on this machine`,actions:l.length?l:`0 actions — every detected harness matches the catalog`,...o.length?{notes:o}:{}},t),i===`would-change`?O.error:O.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Catalog generation failed.`}\n`),O.error}}});function filesUnder(e){try{return s(e,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(t=>x(e,v(t.parentPath,t.name)).split(C).join(b.sep)).sort()}catch{return[]}}const isOne=e=>e===`1`,isSet=e=>e!==``,ga={name:`CLAUDECODE`,matches:isOne,description:`Claude Code sets CLAUDECODE=1 in subprocesses it spawns; IDE extensions also set it in integrated terminals`,research:`E-CC-D1`},_a=[{harness:`claude-code`,all:[ga,{name:`CLAUDE_CODE_CHILD_SESSION`,matches:isOne,description:`Claude Code sets CLAUDE_CODE_CHILD_SESSION=1 for tool, hook, and status line subprocesses`,research:`E-CC-D3`}]},{harness:`claude-code`,all:[ga,{name:`CLAUDE_CODE_SESSION_ID`,matches:isSet,description:`Claude Code sets CLAUDE_CODE_SESSION_ID in tool, hook, and stdio MCP server subprocesses`,research:`E-CC-D6`}]},{harness:`cursor`,all:[{name:`CURSOR_AGENT`,matches:isOne,description:`Cursor sets CURSOR_AGENT=1 on terminal commands its agent runs`,research:`E-CUR-D1`}]},{harness:`cursor`,all:[{name:`CURSOR_VERSION`,matches:isSet,description:`Cursor sets CURSOR_VERSION for hook commands`,research:`E-CUR-D10`},{name:`CURSOR_PROJECT_DIR`,matches:isSet,description:`Cursor sets CURSOR_PROJECT_DIR for hook commands`,research:`E-CUR-D10`}]},{harness:`codex`,all:[{name:`CODEX_THREAD_ID`,matches:isSet,description:`Codex injects CODEX_THREAD_ID into shell tool commands, even under a restrictive shell env policy`,research:`E-CODEX-D2`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_CLI`,matches:isOne,description:`Copilot CLI sets COPILOT_CLI=1 in its subprocesses`,research:`E-COPILOT-D1`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_AGENT_SESSION_ID`,matches:isSet,description:`Copilot CLI passes COPILOT_AGENT_SESSION_ID to shell commands and MCP servers`,research:`E-COPILOT-D2`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_PLUGIN_ROOT`,matches:isSet,description:`Copilot CLI passes COPILOT_PLUGIN_ROOT to plugin hooks`,research:`E-COPILOT-D6`}]},{harness:`opencode`,all:[{name:`OPENCODE`,matches:isOne,description:`OpenCode sets OPENCODE=1 for shell tool commands and MCP servers; Kilo Code, its fork, sets it too`,research:`E-OC-D1`},{name:`OPENCODE_PID`,matches:isSet,description:`OpenCode sets OPENCODE_PID for shell tool commands and MCP servers; Kilo Code sets KILO_PID instead`,research:`E-OC-D2`}]},{harness:`kilo`,all:[{name:`KILO`,matches:isOne,description:`Kilo Code sets KILO=1 for shell tool commands and MCP servers`,research:`E-KILO-D2`},{name:`KILO_PID`,matches:isSet,description:`Kilo Code sets KILO_PID for shell tool commands and MCP servers`,research:`E-KILO-D1`}]},{harness:`gemini-cli`,all:[{name:`GEMINI_CLI`,matches:isOne,description:`Gemini CLI sets GEMINI_CLI=1 for shell tool commands and MCP stdio servers`,research:`E-GEM-D1`}]},{harness:`qwen-code`,all:[{name:`QWEN_CODE`,matches:isOne,description:`Qwen Code sets QWEN_CODE=1 for shell tool commands, not for MCP servers or hooks`,research:`E-QWEN-D1`}]},{harness:`vscode-copilot`,all:[{name:`COPILOT_AGENT`,matches:isOne,description:`VS Code 1.121+ sets COPILOT_AGENT=1 on terminals its Copilot agent runs commands in`,research:`E-VSC-D1`}]},{harness:`cline`,all:[{name:`CLINE_ACTIVE`,matches:e=>e===`true`,description:`Cline's VS Code extension sets CLINE_ACTIVE=true on the terminals it creates; the Cline CLI does not`,research:`E-CLINE-D1`}]},{harness:`crush`,all:[{name:`CRUSH`,matches:isOne,description:`Crush sets CRUSH=1 for bash tool and hook commands, not for MCP servers`,research:`E-CRUSH-D1`}]},{harness:`openhands`,all:[{name:`AI_AGENT`,matches:e=>e===`openhands`,description:`OpenHands sets AI_AGENT=openhands for terminal tool and hook commands when AI_AGENT is unset; other vendors use the name with other values`,research:`E-OH-D1`}]},{harness:`openhands`,all:[{name:`OPENHANDS_EVENT_TYPE`,matches:isSet,description:`OpenHands sets OPENHANDS_EVENT_TYPE for hook commands`,research:`E-OH-D4`},{name:`OPENHANDS_PROJECT_DIR`,matches:isSet,description:`OpenHands sets OPENHANDS_PROJECT_DIR for hook commands`,research:`E-OH-D4`}]},{harness:`augment`,all:[{name:`AUGMENT_HOOK_EVENT`,matches:isSet,description:`The Auggie CLI sets AUGMENT_HOOK_EVENT for hook commands; its shell commands carry no marker`,research:`E-AUG-D3`},{name:`AUGMENT_PROJECT_DIR`,matches:isSet,description:`The Auggie CLI sets AUGMENT_PROJECT_DIR for hook commands`,research:`E-AUG-D3`}]}];function detectHarness(e={}){let t=e.env??process.env,n=[],r=[];for(let e of _a){let i=e.all.filter(e=>{let n=t[e.name];return n!==void 0&&e.matches(n)});for(let t of i)n.some(n=>n.harness===e.harness&&n.signal===t.name)||n.push({harness:e.harness,signal:t.name,description:t.description,research:t.research});i.length===e.all.length&&!r.includes(e.harness)&&r.push(e.harness)}return{harness:r.length===1?r[0]:`unknown`,evidence:n,candidates:r}}function managedPolicyLocations(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;return va[e](n,r)}const joinFor=e=>e===`win32`?w.join:b.join,dirnameFor=e=>e===`win32`?w.dirname:b.dirname;function opencodeFamily(e,t,n,r){let i={darwin:`/Library/Application Support/${n}`,linux:`/etc/${n}`,win32:w.join(t.ProgramData??`C:\\ProgramData`,n)}[e];return[...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`ai.opencode.managed`,description:`MDM configuration profile; outranks the managed config folder`,research:r.preferences}),...when(i!==void 0,{kind:`directory`,location:i??``,description:`Managed config files; outrank user and project config`,research:r.directory})]}function geminiFamily(e,t,n){let r=e===`darwin`||e===`win32`?n.dirs[e]:n.dirs.linux,i=t[n.settingsVariable]||joinFor(e)(r,`settings.json`),a=t[n.defaultsVariable]||joinFor(e)(dirnameFor(e)(i),`system-defaults.json`);return[{kind:`file`,location:i,description:`System settings; outrank user and workspace settings. ${n.settingsVariable} overrides the path`,research:n.research},{kind:`file`,location:a,description:`System defaults; user and workspace settings override them. ${n.defaultsVariable} overrides the path`,research:n.research}]}const when=(e,...t)=>e?t:[],va={"claude-code":e=>{let t={darwin:`/Library/Application Support/ClaudeCode`,linux:`/etc/claude-code`,win32:`C:\\Program Files\\ClaudeCode`}[e],n=joinFor(e);return[{kind:`server`,location:`claude.ai admin console or a self-hosted Claude apps gateway`,description:`Server-managed settings; the highest-ranked managed source`,research:`E-CC-M6`},...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.anthropic.claudecode`,description:`MDM configuration profile with the same top-level keys as managed-settings.json`,research:`E-CC-M6`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKLM\\SOFTWARE\\Policies\\ClaudeCode`,description:`MDM or Group Policy; the Settings value holds managed-settings JSON`,research:`E-CC-M6`}),...when(t!==void 0,{kind:`file`,location:n(t??``,`managed-settings.json`),description:`Managed settings, same shape as settings.json`,research:`E-CC-M1`},{kind:`directory`,location:n(t??``,`managed-settings.d`),description:`Drop-in managed settings files, merged with managed-settings.json`,research:`E-CC-M1`},{kind:`file`,location:n(t??``,`managed-mcp.json`),description:`Managed MCP servers`,research:`E-CC-M1`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKCU\\SOFTWARE\\Policies\\ClaudeCode`,description:`User-writable; used only when no other managed source delivers a policy key`,research:`E-CC-M6`})]},cursor:e=>{let t={darwin:`/Library/Application Support/Cursor/hooks.json`,linux:`/etc/cursor/hooks.json`,win32:`C:\\ProgramData\\Cursor\\hooks.json`}[e];return[...when(t!==void 0,{kind:`file`,location:t??``,description:`Enterprise hooks deployed by MDM; hooks only, not other enterprise settings`,research:`E-CUR-M1`}),{kind:`server`,location:`Cursor dashboard`,description:`Team hooks and other enterprise settings, synced from the dashboard`,research:`E-CUR-M1`}]},codex:(e,t)=>{let n={kind:`server`,location:`ChatGPT workspace admin settings`,description:`Cloud-managed requirements; outrank every local source`,research:`E-CODEX-M8`};return e===`win32`?[n,{kind:`file`,location:w.join(t.ProgramData??`C:\\ProgramData`,`OpenAI`,`Codex`,`requirements.toml`),description:`Admin-enforced requirements users cannot override`,research:`E-CODEX-M4`}]:[n,...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.openai.codex`,description:`MDM keys requirements_toml_base64 (enforced) and config_toml_base64 (managed defaults)`,research:`E-CODEX-M6`}),{kind:`file`,location:`/etc/codex/requirements.toml`,description:`Admin-enforced requirements users cannot override`,research:`E-CODEX-M3`},{kind:`file`,location:`/etc/codex/managed_config.toml`,description:`Managed defaults; a user can override them within a session`,research:`E-CODEX-M2`},{kind:`file`,location:`/etc/codex/config.toml`,description:`System-wide config`,research:`E-CODEX-M1`}]},"copilot-cli":(e,t)=>{let n={darwin:`/Library/Application Support/GitHubCopilot/managed-settings.json`,linux:`/etc/github-copilot/managed-settings.json`,win32:w.join(t.ProgramFiles??`C:\\Program Files`,`GitHubCopilot`,`managed-settings.json`)}[e];return[...when(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.github.copilot`,description:`MDM-managed settings; the highest-ranked source`,research:`E-COPILOT-M2`}),...when(e===`win32`,{kind:`windows-registry`,location:`HKLM\\SOFTWARE\\Policies\\GitHubCopilot`,description:`MDM-managed settings as REG_SZ values; the highest-ranked source`,research:`E-COPILOT-M2`}),{kind:`server`,location:`copilot/managed-settings.json in the enterprise's .github-private repository`,description:`Server-managed settings, fetched for the signed-in account`,research:`E-COPILOT-M3`},...when(n!==void 0,{kind:`file`,location:n??``,description:`File-based managed settings; on macOS and Linux it must be a root-owned regular file`,research:`E-COPILOT-M1`})]},opencode:(e,t)=>[...opencodeFamily(e,t,`opencode`,{directory:`E-OC-M1`,preferences:`E-OC-M1`}),{kind:`server`,location:`Remote config at the organization domain /.well-known/opencode`,description:`Organization defaults; the lowest-ranked config source, so user config overrides them`,research:`E-OC-M2`}],kilo:(e,t)=>opencodeFamily(e,t,`kilo`,{directory:`E-KILO-M1`,preferences:`E-KILO-M2`}),"gemini-cli":(e,t)=>geminiFamily(e,t,{settingsVariable:`GEMINI_CLI_SYSTEM_SETTINGS_PATH`,defaultsVariable:`GEMINI_CLI_SYSTEM_DEFAULTS_PATH`,dirs:{darwin:`/Library/Application Support/GeminiCli`,linux:`/etc/gemini-cli`,win32:`C:\\ProgramData\\gemini-cli`},research:`E-GEM-M1`}),"qwen-code":(e,t)=>geminiFamily(e,t,{settingsVariable:`QWEN_CODE_SYSTEM_SETTINGS_PATH`,defaultsVariable:`QWEN_CODE_SYSTEM_DEFAULTS_PATH`,dirs:{darwin:`/Library/Application Support/QwenCode`,linux:`/etc/qwen-code`,win32:`C:\\ProgramData\\qwen-code`},research:`E-QWEN-M1`}),"vscode-copilot":e=>[...when(e===`win32`,{kind:`windows-registry`,location:`Software\\Policies\\Microsoft\\VSCode`,description:`VS Code policies set by Group Policy (ADMX templates ship with VS Code)`,research:`E-VSC-M1`}),...when(e===`linux`,{kind:`file`,location:`/etc/vscode/policy.json`,description:`VS Code policies as JSON, read by VS Code 1.106 and later`,research:`E-VSC-M3`})],cline:()=>[{kind:`server`,location:`Cline Enterprise admin console`,description:`Provider, model, and tool policy pushed to clients; no local policy file is documented`,research:`E-CLINE-M1`}],crush:e=>when(e!==`win32`,{kind:`file`,location:`/etc/crush/crush.json`,description:`System config; the lowest-ranked source, so user and project config override it`,research:`E-CRUSH-M1`}),openhands:()=>[{kind:`server`,location:`OpenHands Cloud or Enterprise deployment`,description:`Organization controls held server-side; no local policy file is known`,research:`E-OH-D8`}],augment:(e,t)=>[{kind:`file`,location:e===`win32`?w.join(t.ProgramData||`C:\\ProgramData`,`augment`,`settings.json`):`/etc/augment/settings.json`,description:`System settings, read from the Auggie CLI bundle; its rank against user settings is not documented`,research:`E-AUG-M1`}]};function resolveHarnessEnvironment(e={}){return{env:e.env??process.env,homedir:e.homedir??E(),cwd:e.cwd??process.cwd(),platform:e.platform??process.platform}}async function readText(e){try{return await ne(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return;throw e}}function stripJsonComments$1(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`"`){let r=n+1;for(;r<e.length&&e[r]!==`"`;)r+=e[r]===`\\`?2:1;t+=e.slice(n,r+1),n=r+1}else if(r===`/`&&e[n+1]===`/`)for(;n<e.length&&e[n]!==`
|
|
93
|
-
`;)n++;else if(r===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t===-1?e.length:t+2}else t+=r,n++}return t.replace(/,(\s*[}\]])/g,`$1`)}__name(stripJsonComments$1,`stripJsonComments`);function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pluginStorage(e,t={}){return ya[e](resolveHarnessEnvironment(t))}const xdgConfig=({env:e,homedir:t})=>e.XDG_CONFIG_HOME||v(t,`.config`);function vscodeAgentPlugins({env:e,homedir:t,platform:n}){if(n===`win32`){let n=w.join(e.APPDATA||w.join(t,`AppData`,`Roaming`),`Code`);return{configDir:n,path:w.join(n,`agentPlugins`)}}let r=n===`darwin`?v(t,`Library`,`Application Support`,`Code`):v(t,`.config`,`Code`);return{configDir:r,path:v(r,`agentPlugins`)}}const ya={"claude-code":({env:e,homedir:t})=>{let n=e.CLAUDE_CONFIG_DIR||v(t,`.claude`),r=v(n,`plugins`);return{harness:`claude-code`,configDir:n,locations:[{kind:`plugin-cache`,path:v(r,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CC-P1`},{kind:`marketplaces`,path:v(r,`marketplaces`),description:`Marketplace checkouts`,research:`E-CC-P1`},{kind:`install-record`,path:v(r,`installed_plugins.json`),description:`Installs keyed by plugin@marketplace, each with scope, installPath, and version`,research:`E-CC-P2`},{kind:`enabled-record`,path:v(n,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-CC-P3`}]}},cursor:({homedir:e})=>{let t=v(e,`.cursor`);return{harness:`cursor`,configDir:t,locations:[{kind:`local-plugins`,path:v(t,`plugins`,`local`),description:`Plugins under development, one folder each`,research:`E-CUR-P2`},{kind:`marketplaces`,path:v(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-CUR-P3`}]}},codex:({env:e,homedir:t})=>{let n=e.CODEX_HOME||v(t,`.codex`);return{harness:`codex`,configDir:n,locations:[{kind:`plugin-cache`,path:v(n,`plugins`,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CODEX-P3`},{kind:`enabled-record`,path:v(n,`config.toml`),description:`User config; [plugins."<plugin>@<marketplace>"] tables carry enabled = <bool>`,research:`E-CODEX-P2`}]}},"copilot-cli":({env:e,homedir:t})=>{let n=e.COPILOT_HOME||v(t,`.copilot`);return{harness:`copilot-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:v(n,`installed-plugins`),description:`Installed plugins as <marketplace>/<plugin>/, or _direct/<source-id>/ for direct installs`,research:`E-COPILOT-P9`},{kind:`install-record`,path:v(n,`config.json`),description:`Application state, including installedPlugins`,research:`E-COPILOT-P9`},{kind:`enabled-record`,path:v(n,`settings.json`),description:`User settings (JSON with comments); enabledPlugins maps plugin specs to a boolean`,research:`E-COPILOT-P4`}]}},opencode:e=>{let t=v(xdgConfig(e),`opencode`);return{harness:`opencode`,configDir:t,locations:[{kind:`local-plugins`,path:v(t,`plugins`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-OC-P2`}]}},kilo:e=>{let t=v(xdgConfig(e),`kilo`);return{harness:`kilo`,configDir:t,locations:[{kind:`local-plugins`,path:v(t,`plugin`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-KILO-P2`}]}},"gemini-cli":({env:e,homedir:t})=>{let n=v(e.GEMINI_CLI_HOME||t,`.gemini`),r=v(n,`extensions`);return{harness:`gemini-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a gemini-extension.json manifest`,research:`E-GEM-P1`},{kind:`enabled-record`,path:v(r,`extension-enablement.json`),description:`Per-extension path-glob overrides that enable or disable it by folder, not a boolean`,research:`E-GEM-P3`}]}},"qwen-code":({env:e,homedir:t})=>{let n=e.QWEN_HOME||v(t,`.qwen`),r=v(n,`extensions`);return{harness:`qwen-code`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a qwen-extension.json manifest`,research:`E-QWEN-P1`},{kind:`enabled-record`,path:v(r,`extension-enablement.json`),description:`Extension enable/disable state, inherited from Gemini CLI's format`,research:`E-QWEN-P2`}]}},"vscode-copilot":e=>{let{configDir:t,path:n}=vscodeAgentPlugins(e);return{harness:`vscode-copilot`,configDir:t,locations:[{kind:`installed-plugins`,path:n,description:`Installed agent plugins as <host>/<org>/<repo>/`,research:`E-VSC-P3`}]}},cline:({homedir:e})=>{let t=v(e,`.cline`);return{harness:`cline`,configDir:t,locations:[{kind:`installed-plugins`,path:v(t,`plugins`,`_installed`),description:`Installed plugins, grouped by source: npm, git, remote, or local`,research:`E-CLINE-P3`}]}},crush:({env:e,homedir:t})=>({harness:`crush`,configDir:e.CRUSH_GLOBAL_CONFIG||v(e.XDG_CONFIG_HOME||v(t,`.config`),`crush`),locations:[]}),openhands:({env:e,homedir:t})=>{let n=e.OH_PERSISTENCE_DIR||e.OPENHANDS_PERSISTENCE_DIR||v(t,`.openhands`),r=v(n,`plugins`,`installed`);return{harness:`openhands`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed plugins, one folder each`,research:`E-OH-P3`},{kind:`enabled-record`,path:v(r,`.installed.json`),description:`Install metadata keyed by plugin name, each with enabled: <bool>`,research:`E-OH-P4`}]}},augment:({homedir:e})=>{let t=v(e,`.augment`);return{harness:`augment`,configDir:t,locations:[{kind:`marketplaces`,path:v(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-AUG-P2`},{kind:`enabled-record`,path:v(t,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-AUG-P4`}]}}};async function enabledPlugins(e,t={}){let n=Ca[e](resolveHarnessEnvironment(t),t.managedSettingsPath),r=new Map,i=[];for(let e of n.sources){let t;try{let n=await readText(e.path);if(n===void 0){i.push({scope:e.scope,path:e.path,found:!1});continue}t=e.parse(n)}catch(t){i.push({scope:e.scope,path:e.path,found:!0,error:String(t)});continue}i.push({scope:e.scope,path:e.path,found:!0});for(let[n,i]of Object.entries(t))r.has(n)||r.set(n,{id:n,enabled:i,scope:e.scope,source:e.path})}return{harness:e,supported:n.supported,plugins:[...r.values()],sources:i,unread:n.unread,research:n.research}}function jsonEnabledPlugins(e){let t=JSON.parse(e),n=isRecord(t)?t.enabledPlugins:void 0;return isRecord(n)?Object.fromEntries(Object.entries(n).filter(e=>typeof e[1]==`boolean`)):{}}const ba=/^\[\s*plugins\s*\.\s*(?:"([^"]*)"|'([^']*)'|([A-Za-z0-9_-]+))\s*\]\s*(?:#.*)?$/,xa=/^enabled\s*=\s*(true|false)\s*(?:#.*)?$/;function tomlEnabledPlugins(e){let t={},n;for(let r of e.split(/\r?\n/)){let e=r.trim();if(e.startsWith(`[`)){let t=ba.exec(e);n=t?t[1]??t[2]??t[3]:void 0;continue}let i=n===void 0?null:xa.exec(e);n!==void 0&&i&&(t[n]=i[1]===`true`)}return t}const Sa={server:`server-managed settings`,"macos-managed-preferences":`MDM managed preferences`,"windows-registry":`Windows registry policy`,directory:`drop-in managed settings`,file:`managed file`};function unreadPolicy(e,t,n=[]){return e.filter(e=>e.location!==t&&!n.some(t=>e.location.endsWith(t))).map(e=>`${Sa[e.kind]} (${e.location})`)}function managedFile(e,t){return e.find(e=>e.kind===`file`&&e.location.endsWith(t))?.location}function jsoncEnabledPlugins(e){return jsonEnabledPlugins(stripJsonComments$1(e))}const unsupported$1=(...e)=>({supported:!1,sources:[],unread:[],research:e}),Ca={"claude-code":(e,t)=>{let{configDir:n}=pluginStorage(`claude-code`,e),r=managedPolicyLocations(`claude-code`,e),i=managedFile(r,`managed-settings.json`),a=t??i,o=v(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:jsonEnabledPlugins}],{scope:`local`,path:v(o,`settings.local.json`),parse:jsonEnabledPlugins},{scope:`project`,path:v(o,`settings.json`),parse:jsonEnabledPlugins},{scope:`user`,path:v(n,`settings.json`),parse:jsonEnabledPlugins}],unread:unreadPolicy(r,i,[`managed-mcp.json`]),research:[`E-CC-P3`,`E-CC-P7`,`E-CC-M1`,`E-CC-M6`]}},cursor:()=>unsupported$1(),opencode:()=>unsupported$1(`E-OC-P3`),kilo:()=>unsupported$1(`E-KILO-P3`),"gemini-cli":()=>unsupported$1(`E-GEM-P3`),"qwen-code":()=>unsupported$1(`E-QWEN-P2`),"vscode-copilot":()=>unsupported$1(`E-VSC-P4`),cline:()=>unsupported$1(`E-CLINE-P4`),crush:()=>unsupported$1(`E-CRUSH-P2`),openhands:()=>unsupported$1(`E-OH-P4`),augment:()=>unsupported$1(`E-AUG-P4`),codex:e=>{let t=pluginStorage(`codex`,e);return{supported:!0,sources:[{scope:`user`,path:v(t.configDir,`config.toml`),parse:tomlEnabledPlugins}],unread:unreadPolicy(managedPolicyLocations(`codex`,e),void 0),research:[`E-CODEX-P2`,`E-CODEX-M7`]}},"copilot-cli":(e,t)=>{let n=pluginStorage(`copilot-cli`,e),r=managedPolicyLocations(`copilot-cli`,e),i=managedFile(r,`managed-settings.json`),a=t??i,o=v(e.cwd,`.github`,`copilot`),s=v(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:jsoncEnabledPlugins}],{scope:`local`,path:v(o,`settings.local.json`),parse:jsoncEnabledPlugins},{scope:`project`,path:v(o,`settings.json`),parse:jsoncEnabledPlugins},{scope:`user`,path:v(n.configDir,`settings.json`),parse:jsoncEnabledPlugins}],unread:[...unreadPolicy(r,i),`Claude Code project settings (${v(s,`settings.json`)})`,`Claude Code local settings (${v(s,`settings.local.json`)})`],research:[`E-COPILOT-P4`,`E-COPILOT-M1`,`E-COPILOT-M2`,`E-COPILOT-M4`]}}};async function installedPlugins(e,t={}){let n=Ma[e](resolveHarnessEnvironment(t)),r={harness:e,supported:n.supported,unread:n.unread,research:n.research};if(n.source===void 0)return{...r,plugins:[],unresolved:[],sources:[]};let i=n.source;try{let e=await n.read(i);return e===void 0?{...r,plugins:[],unresolved:[],sources:[{path:i,found:!1}]}:{...r,plugins:e.plugins,unresolved:e.unresolved??[],sources:[{path:i,found:!0}]}}catch(e){return{...r,plugins:[],unresolved:[],sources:[{path:i,found:!0,error:String(e)}]}}}const wa=[`managed`,`local`,`project`,`user`],optionalString=e=>typeof e==`string`&&e!==``?e:void 0;async function readClaudeInstalls(e){let t=await readText(e);if(t===void 0)return;let n=JSON.parse(t),r=isRecord(n)?n.plugins:void 0;if(!isRecord(r))return{plugins:[]};let i=[];for(let[e,t]of Object.entries(r))if(Array.isArray(t))for(let n of t){let t=isRecord(n)?optionalString(n.installPath):void 0;if(!isRecord(n)||t===void 0)continue;let r=optionalString(n.version),a=typeof n.scope==`string`&&wa.includes(n.scope)?n.scope:void 0,o=optionalString(n.projectPath);i.push({id:e,path:t,...r===void 0?{}:{version:r},...a===void 0?{}:{scope:a},...o===void 0?{}:{projectPath:o},research:[`E-CC-P2`]})}return{plugins:i}}async function readCopilotInstalls(e){let t=await readText(e);if(t===void 0)return;let n=JSON.parse(stripJsonComments$1(t)),r=isRecord(n)?n.installedPlugins:void 0;if(!Array.isArray(r))return{plugins:[]};let i=[];for(let e of r){if(!isRecord(e))continue;let t=optionalString(e.name),n=optionalString(e.cache_path);if(t===void 0||n===void 0)continue;let r=optionalString(e.marketplace),a=optionalString(e.version);i.push({id:r===void 0?t:`${t}@${r}`,path:n,...a===void 0?{}:{version:a},research:r===void 0?[`E-COPILOT-P10`,`E-COPILOT-P11`]:[`E-COPILOT-P10`]})}return{plugins:i}}const Ta=`local`,Ea=/^[A-Za-z0-9_-]+$/,Da=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/,Oa=/^[A-Za-z0-9._+-]+$/;async function readCodexInstalls(e){let t=await directories(e);if(t===void 0)return;let n=[],r=[];for(let i of t.filter(e=>Ea.test(e)))for(let t of await directories(v(e,i))??[]){if(!Da.test(t))continue;let a=`${t}@${i}`,o=(await directories(v(e,i,t))??[]).filter(e=>Oa.test(e)&&e!==`.`&&e!==`..`);if(o.length===0)continue;let s=activeCodexVersion(o);if(s===void 0){r.push(a);continue}n.push({id:a,path:v(e,i,t,s),version:s,research:[`E-CODEX-P3`,`E-CODEX-P8`]})}return{plugins:n,unresolved:r}}function activeCodexVersion(e){if(e.includes(Ta))return Ta;let t=e.filter(e=>parseSemver(e)!==void 0).length;if(!(e.length>2&&t!==0&&t!==e.length))return[...e].sort(compareCodexVersions).at(-1)}async function directories(e){try{return(await re(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(e.code===`ENOENT`)return;throw e}}const ka=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;function parseSemver(e){let t=ka.exec(e);if(t)return{core:[t[1],t[2],t[3]],pre:t[4]===void 0?[]:t[4].split(`.`),build:t[5]===void 0?[]:t[5].split(`.`)}}function compareCodexVersions(e,t){let n=parseSemver(e),r=parseSemver(t);if(n===void 0||r===void 0)return compareStrings(e,t);for(let e=0;e<3;e++){let t=compareNumeric(n.core[e],r.core[e]);if(t!==0)return t}let i=n.pre.length===0||r.pre.length===0?r.pre.length-n.pre.length:compareIdentifiers(n.pre,r.pre);return i===0?compareIdentifiers(n.build,r.build):Math.sign(i)}const Aa=/^\d+$/;function compareIdentifiers(e,t){for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n],i=t[n],a=Aa.test(r),o=Aa.test(i),s=a&&o?compareNumeric(r,i):a===o?compareStrings(r,i):a?-1:1;if(s!==0)return s}return e.length-t.length}function compareNumeric(e,t){let n=e.replace(/^0+(?=\d)/,``),r=t.replace(/^0+(?=\d)/,``);return n.length-r.length||compareStrings(n,r)||e.length-t.length}const compareStrings=(e,t)=>e<t?-1:+(e>t),ja={supported:!1,read:async()=>void 0,unread:[],research:[]},Ma={"claude-code":e=>({supported:!0,source:v(pluginStorage(`claude-code`,e).configDir,`plugins`,`installed_plugins.json`),read:readClaudeInstalls,unread:[],research:[`E-CC-P2`]}),codex:e=>({supported:!0,source:v(pluginStorage(`codex`,e).configDir,`plugins`,`cache`),read:readCodexInstalls,unread:[],research:[`E-CODEX-P3`,`E-CODEX-P8`]}),"copilot-cli":e=>{let{configDir:t}=pluginStorage(`copilot-cli`,e);return{supported:!0,source:v(t,`config.json`),read:readCopilotInstalls,unread:[`plugins from marketplaces added by local path (extraKnownMarketplaces in ${v(t,`settings.json`)})`],research:[`E-COPILOT-P10`,`E-COPILOT-P11`,`E-COPILOT-P12`,`E-COPILOT-P13`]}},cursor:()=>ja,opencode:()=>ja,kilo:()=>ja,"gemini-cli":()=>ja,"qwen-code":()=>ja,"vscode-copilot":()=>ja,cline:()=>ja,crush:()=>ja,openhands:()=>ja,augment:()=>ja};function skillsDirectories(e){switch(e){case`claude-code`:return{project:[`.claude/skills`],user:[`.claude/skills`],research:[`E-CC-L1`]};case`cursor`:return{project:[`.agents/skills`,`.cursor/skills`,`.claude/skills`,`.codex/skills`],user:[`.agents/skills`,`.cursor/skills`,`.claude/skills`,`.codex/skills`],research:[`E-CUR-L1`]};case`codex`:return{project:[`.agents/skills`],user:[`.agents/skills`],research:[`E-CODEX-L1`]};case`copilot-cli`:return{project:[`.github/skills`,`.agents/skills`,`.claude/skills`],user:[`.copilot/skills`,`.agents/skills`],research:[`E-COPILOT-S5`]};case`vscode-copilot`:return{project:[`.github/skills`,`.claude/skills`,`.agents/skills`],user:[`.copilot/skills`,`.claude/skills`,`.agents/skills`],research:[`E-VSC-P1`]};case`opencode`:return{project:[`.opencode/skills`,`.claude/skills`,`.agents/skills`],user:[`.config/opencode/skills`,`.claude/skills`,`.agents/skills`],research:[`E-OC-S1`]};case`gemini-cli`:return{project:[`.agents/skills`,`.gemini/skills`],user:[`.agents/skills`,`.gemini/skills`],research:[`E-GEM-L1`]};case`cline`:return{project:[`.cline/skills`,`.clinerules/skills`,`.claude/skills`],user:[`.cline/skills`],research:[`E-CLINE-S1`]};case`augment`:return{project:[`.augment/skills`],user:[`.augment/skills`],research:[`E-AUG-S1`]};case`kilo`:case`qwen-code`:case`crush`:case`openhands`:return}}function skillsProjection(e,t,n=skillsDirectories(e)?.[t]){let r=n??[],[i]=r;if(i===void 0)throw Error(`@cyberuni/agent-harness records no ${t} skills directories for ${e}.`);return r.includes(`.agents/skills`)?{}:{skillsDirectory:i}}const Na=[{name:`claude-code`,project:{detect:`.claude`,...skillsProjection(`claude-code`,`project`),shadowedBy:[`CLAUDE.md`,`.claude/CLAUDE.md`,`CLAUDE.local.md`],mcpConfig:{path:`.mcp.json`,key:`mcpServers`,format:`json`,dialect:`claude-code`},nonstandard:[{path:`.claude/commands`,shape:`directory`,kind:`command`},{path:`.claude/rules`,shape:`directory`,kind:`rule`},{path:`.claude/agents`,shape:`directory`,kind:`subagent`}]},user:{detect:`.claude`,...skillsProjection(`claude-code`,`user`)}},{name:`cursor`,project:{detect:`.cursor`,...skillsProjection(`cursor`,`project`),mcpConfig:{path:`.cursor/mcp.json`,key:`mcpServers`,format:`json`,dialect:`cursor`},nonstandard:[{path:`.cursorrules`,shape:`file`,kind:`instructions`},{path:`.cursor/rules`,shape:`directory`,kind:`rule`},{path:`.cursor/commands`,shape:`directory`,kind:`command`},{path:`.cursor/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.cursor`,...skillsProjection(`cursor`,`user`)}},{name:`codex`,project:{detect:`.codex`,...skillsProjection(`codex`,`project`),mcpConfig:{path:`.codex/config.toml`,key:`mcp_servers`,format:`toml`,dialect:`codex`,shared:!0},nonstandard:[{path:`.codex/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.codex`,...skillsProjection(`codex`,`user`)}},{name:`copilot-cli`,project:{detect:`.github/skills`,...skillsProjection(`copilot-cli`,`project`),nonstandard:[{path:`.github/copilot-instructions.md`,shape:`file`,kind:`instructions`},{path:`.github/instructions`,shape:`directory`,kind:`instructions`},{path:`.github/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.copilot`,...skillsProjection(`copilot-cli`,`user`)}},{name:`gemini-cli`,project:{detect:`.gemini`,...skillsProjection(`gemini-cli`,`project`),instructionBridge:{kind:`settings-entry`,path:`.gemini/settings.json`,key:`context.fileName`},mcpConfig:{path:`.gemini/settings.json`,key:`mcpServers`,format:`json`,dialect:`gemini-cli`,shared:!0},nonstandard:[{path:`GEMINI.md`,shape:`file`,kind:`instructions`},{path:`.gemini/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.gemini`,...skillsProjection(`gemini-cli`,`user`)}},{name:`devin-desktop`,project:{detect:`.devin`}},{name:`windsurf`,project:{detect:`.windsurf`,skillsDirectory:`.windsurf/skills`,nonstandard:[{path:`.windsurfrules`,shape:`file`,kind:`instructions`},{path:`.windsurf/rules`,shape:`directory`,kind:`rule`}]},deprecated:`devin-desktop`}],Pa=new Set(Na.map(e=>e.name));function isHarnessName(e){return Pa.has(e)}function parseHarnesses(e){let t=(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),n=t.filter(e=>!isHarnessName(e));if(n.length)throw Error(`Unsupported harness: ${n.join(`, `)}. Supported: ${Na.map(e=>e.name).join(`, `)}.`);return t.filter(isHarnessName)}const Fa=[`claude-code`,`cursor`];function directoryExists(e){try{return i(e).isDirectory()}catch{return!1}}function selectHarnesses(e,t){let n=new Set([...Fa,...t]);return Na.filter(t=>n.has(t.name)||directoryExists(v(e,t.project.detect)))}function locatorText({file:e,server:t,field:n,position:r}){return r?`${e}#L${r.line}:${r.column}`:t===void 0?e:`${e}#servers.${t}${n===void 0?``:`.${n}`}`}function repairsOf(e){return Object.entries(e).map(([e,t])=>({problem:e,...t}))}const Ia=`buddy-agent-harness`,La=`/buddy-agent-harness:repair`,X=`/buddy-agent-harness:init-buddy-agent-harness`,Ra=`.agents/buddy-agent-harness/mcp.toml`,za={"no-canonical":{detail:`the canonical skill directory does not exist, so no bridge can resolve`,repair:(e,t)=>({command:`${t} init`,instruction:`run \`${t} init\` to create .agents/skills and the bridges into it`}),skillRepair:()=>`run \`${X}\`, which creates \`.agents/skills\` and the bridges`},missing:{detail:`no bridge at this path — the harness sees zero project skills`,repair:({file:e},t)=>({command:`${t} init`,instruction:`run \`${t} init\` to create the bridge at ${e}`}),skillRepair:()=>`run \`${X}\``},degraded:{detail:`expected a directory but found a regular file — checkout without core.symlinks`,repair:({file:e},t)=>({command:`${t} init --copy --force ${e}`,instruction:`run \`${t} init --copy --force ${e}\` to rebuild ${e} as a real directory`}),skillRepair:({file:e})=>`run \`${X} --copy --force ${e}\``},stale:{detail:`symlink does not resolve to .agents/skills`,repair:({file:e},t)=>({command:`${t} init --force ${e}`,instruction:`run \`${t} init --force ${e}\` to repoint ${e} at .agents/skills`}),skillRepair:({file:e})=>`run \`${X} --force ${e}\``},"diverged-bridge":{detail:`only the bridge changed since the two last agreed — an agent wrote through the copy`,repair:({file:e},t)=>({command:``,instruction:`replace .agents/skills with ${e} to keep the newer edit, then run \`${t} init --force ${e}\``}),skillRepair:({file:e})=>`replace .agents/skills with ${e} to keep the newer edit, then run \`${X} --force ${e}\``},"diverged-canonical":{detail:`only .agents/skills changed since the two last agreed — the copy is stale`,repair:({file:e},t)=>({command:`${t} init --copy --force ${e}`,instruction:`run \`${t} init --copy --force ${e}\` to rebuild ${e} from the newer .agents/skills`}),skillRepair:({file:e})=>`run \`${X} --copy --force ${e}\``},"diverged-both":{detail:`both sides changed since they last agreed — rebuilding would discard one of them`,repair:({file:e})=>({command:``,instruction:`reconcile .agents/skills with ${e} by hand — rebuilding would discard one of them; \`git diff --no-index .agents/skills ${e}\` shows what differs`}),skillRepair:({file:e})=>`run \`git diff --no-index .agents/skills ${e}\` and reconcile by hand`},"diverged-unknown":{detail:`contents differ and no commit where they agreed was found — which side moved is unknown`,repair:({file:e})=>({command:``,instruction:`reconcile .agents/skills with ${e} by hand — which side moved is unknown; \`git diff --no-index .agents/skills ${e}\` shows what differs`}),skillRepair:({file:e})=>`run \`git diff --no-index .agents/skills ${e}\` and reconcile by hand`},"unpinned-copy":{detail:`tracked copy without the skip-worktree bit — the tree is dirty with content that must not be committed`,repair:({file:e})=>({command:`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree`,instruction:`run \`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree\` to restore the skip-worktree bit`}),skillRepair:({file:e})=>`run \`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree\``}};repairsOf(za);const Ba={"no-instructions":{detail:`no AGENTS.md at the repository root, so the instructions this repository has reach one harness at most`,repair:()=>({command:``,instruction:`hand this to \`${X}\`, which consolidates what the repository has into AGENTS.md, or derives it`}),skillRepair:()=>`run \`${X}\`, which consolidates or derives AGENTS.md`},"instructions-missing":{detail:`no instruction bridge at this path — the harness reads none of AGENTS.md`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${X}\`, which writes the bridge into it`}),skillRepair:()=>`run \`${X}\``},"instructions-unbridged":{detail:`the file is present but names AGENTS.md nowhere — the harness reads none of it`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${X}\`, which adds the bridge without discarding what the file already says`}),skillRepair:()=>`run \`${X}\`, which adds the bridge without discarding what the file already says`},"instructions-shadowing":{detail:`this file suppresses the AGENTS.md beside it — the harness reads this instead, and none of AGENTS.md`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${X}\`, which consolidates what it says into AGENTS.md, or adds an @AGENTS.md import above it where the file has to stay`}),skillRepair:()=>`run \`${X}\`, which consolidates the file into AGENTS.md or imports AGENTS.md from it`},"instructions-superseded":{detail:`a bridge from before the harness read AGENTS.md itself — it still works, and nothing needs it`,repair:({file:e})=>({command:``,instruction:`remove ${e}, or keep it for sessions that cannot read AGENTS.md directly — \`${X}\` offers the choice`}),skillRepair:()=>`run \`${X}\`, which offers to remove it`},"instructions-unreadable":{detail:`the settings file does not parse, so the harness reads none of it`,repair:({file:e})=>({command:``,instruction:`fix the JSON in ${e} by hand, then hand it to \`${X}\``}),skillRepair:()=>`fix the JSON by hand, then run \`${X}\``}};repairsOf(Ba);const Va={"deprecated-harness":{detail:`a projection under a harness name that has been superseded — the replacement reads .agents/skills natively and needs no projection at all`,repair:({file:e})=>({command:``,instruction:`remove ${e} and enable the harness that replaced it — \`${La}\` offers the correction`}),skillRepair:()=>`run \`${La}\``},"ignored-bridge":{detail:`a .gitignore rule matches this bridge — an untracked bridge swallows a real edit silently`,repair:({file:e})=>({command:``,instruction:`narrow or remove the .gitignore rule matching ${e} — \`${La}\` offers the correction`}),skillRepair:()=>`run \`${La}\``},"unread-local-override":{detail:`no harness reads this filename, so everything in it is invisible to every agent`,repair:({file:e})=>({command:``,instruction:`move ${e} to CLAUDE.local.md, or consolidate it into AGENTS.md — \`${La}\` offers the correction`}),skillRepair:()=>`run \`${La}\``},"unloadable-skill":{detail:`frontmatter that does not parse, or no description — either one makes a harness skip the skill outright`,repair:({file:e})=>({command:``,instruction:`quote the description in ${e}, or add one — \`${La}\` offers the correction`}),skillRepair:()=>`run \`${La}\``}};repairsOf(Va);const Ha={"mcp-golden-unreadable":{detail:`the golden MCP set does not parse — the locator gives the line and column, and nothing else can be said about it`,repair:e=>({command:``,instruction:`fix the TOML at ${locatorText(e)}`}),skillRepair:e=>`fix the TOML at ${locatorText(e)} by hand — the reported line and column are all that can be quoted, because the parser's own message repeats the offending line and that line is the one holding the credential`},"mcp-target-unreadable":{detail:`this harness config does not parse, so the harness starts none of its servers and nothing in it can be compared`,repair:e=>({command:``,instruction:`fix the syntax of ${locatorText(e)}`}),skillRepair:e=>`fix the syntax of ${locatorText(e)} by hand`},"mcp-unprojected":{detail:`the golden set declares this server and the harness config does not carry it`,repair:({file:e,server:t})=>({command:``,instruction:`add the server ${t} to ${e}, or drop it from the golden set — \`${La}\` offers the correction`}),skillRepair:e=>`hand ${locatorText(e)} to \`${La}\`, which projects it from its golden entry with \`mcp project\` — or drop it from the golden set`},"mcp-undeclared":{detail:`the harness config carries this server and the golden set does not declare it`,repair:({file:e,server:t})=>({command:``,instruction:`add the server ${t} to ${Ra}, or drop it from ${e} — \`${La}\` offers the import`}),skillRepair:e=>`hand ${locatorText(e)} to \`${La}\`, which imports it field by field with \`mcp reconcile\`, refusing any literal credential — or drop it from ${e.file}`},"mcp-diverged-target":{detail:`only the harness config changed since the two last agreed — the edit was made through the copy`,repair:e=>({command:``,instruction:`reconcile the value at ${locatorText(e)} back into ${Ra} — \`${La}\` offers the import`}),skillRepair:e=>`hand ${locatorText(e)} to \`${La}\`, which imports the field into ${Ra} with \`mcp reconcile\` once approved`},"mcp-diverged-golden":{detail:`only the golden set changed since the two last agreed — the harness copy is stale`,repair:e=>({command:``,instruction:`update ${locatorText(e)} from the golden entry — \`${La}\` offers the correction`}),skillRepair:e=>`hand ${locatorText(e)} to \`${La}\`, which updates it from the golden entry with \`mcp project\``},"mcp-diverged-both":{detail:`both sides changed since they last agreed — merging either way would discard the other`,repair:e=>({command:``,instruction:`reconcile ${locatorText(e)} against ${Ra} by hand`}),skillRepair:e=>`reconcile ${locatorText(e)} against ${Ra} by hand — never merge a three-way conflict automatically`},"mcp-diverged-unknown":{detail:`the two disagree and no baseline says which side moved — neither history nor a last-projected record covers this server`,repair:e=>({command:``,instruction:`compare ${locatorText(e)} against ${Ra} by hand`}),skillRepair:e=>`compare ${locatorText(e)} against ${Ra} by hand`},"mcp-literal-secret":{detail:`a credential-bearing field holds a literal rather than a reference to an environment variable`,repair:e=>({command:``,instruction:`move the value at ${locatorText(e)} into an environment variable and reference it`}),skillRepair:e=>`move the value at ${locatorText(e)} into an environment variable and reference it — read the value from the file, never from this report, and never repeat it back`},"mcp-committed-secret":{detail:`a credential-bearing field holds a literal in a git-tracked file — the credential is committed, and moving it does not un-commit it`,repair:e=>({command:``,instruction:`rotate the credential behind ${locatorText(e)}, then reference it from an environment variable`}),skillRepair:e=>`rotate the credential behind ${locatorText(e)} at its issuer, then reference it from an environment variable — it is in the repository's history, so moving it is not enough`}};repairsOf(Ha);const Ua={"nonstandard-instructions":{detail:`instruction content only one harness reads — AGENTS.md carries the same prose to all of them`,repair:({file:e})=>({command:``,instruction:`consolidate ${e} into AGENTS.md — \`${X}\` offers the consolidation, and keeps the content reachable where this harness needs it`}),skillRepair:({file:e})=>`hand ${e} to \`${X}\`, which consolidates it into AGENTS.md`},"nonstandard-rule":{detail:`a path-scoped rule only one harness reads — a skill reaches every harness where the scoping is incidental`,repair:({file:e})=>({command:``,instruction:`convert ${e} into a skill under .agents/skills where its guidance is not tied to the paths it names — \`${X}\` offers the conversion; keep it where the path scoping is the point`}),skillRepair:({file:e})=>`hand ${e} to \`${X}\` to convert into a skill, unless the path scoping is load-bearing`},"nonstandard-command":{detail:`a harness command file — a skill is the portable form, and this harness reads skills too`,repair:({file:e})=>({command:``,instruction:`move ${e} to .agents/skills/<name>/SKILL.md — \`${X}\` offers the move`}),skillRepair:({file:e})=>`hand ${e} to \`${X}\`, which moves it to .agents/skills`},"nonstandard-skill":{detail:`a skill under a harness directory rather than the canonical one, where only that harness finds it`,repair:({file:e})=>({command:``,instruction:`move ${e} to .agents/skills and project it back where the harness needs one — \`${X}\` offers the move`}),skillRepair:({file:e})=>`hand ${e} to \`${X}\`, which moves it to .agents/skills`},"nonstandard-subagent":{detail:`a subagent definition with no cross-harness form — nothing outside this harness can read it, and no canonical form exists yet`,repair:({file:e})=>({command:``,instruction:`leave ${e} where it is and record that it reaches one harness only — no portable form exists to convert it to`}),skillRepair:({file:e})=>`leave ${e} in place — no portable form exists yet, so this is work for a person rather than a skill`}};repairsOf(Ua);const Wa={...za,...Ba,...Va,...Ha,...Ua};repairsOf(Wa);function repairFor(e){return{problem:e,...Wa[e]}}const Ga=`.agents/skills`,Ka=`AGENTS.local.md`;function frontmatterFault(e){let t=/^---\n([\s\S]*?)\n---/.exec(e);if(!t)return`unparseable`;let n=/^description:[ \t]*(.*)$/m.exec(t[1])?.[1]?.trim();if(!n)return`no-description`;if(!/^(['"]).*\1$/.test(n)&&/:\s/.test(n))return`unparseable`}function diagnoseConfiguration({root:e,git:t,cli:n}){let i=[],add=(e,t)=>{let{detail:r,repair:a}=repairFor(t);i.push({path:e,problem:t,detail:r,repair:a({file:e},n)})},a=selectHarnesses(e,[]);for(let t of a){let n=t.project.skillsDirectory;t.deprecated&&n&&r(v(e,n))&&add(n,`deprecated-harness`)}for(let n of a){let i=n.project.skillsDirectory;i&&r(v(e,i))&&t.isIgnored(i)&&add(i,`ignored-bridge`)}r(v(e,Ka))&&add(Ka,`unread-local-override`);for(let t of filesUnder(v(e,Ga)).filter(e=>e.endsWith(`SKILL.md`)))frontmatterFault(o(v(e,Ga,t),`utf8`))&&add(`${Ga}/${t}`,`unloadable-skill`);return i}const qa=[`transport`,`command`,`args`,`env`,`url`,`headers`,`description`,`enabled`,`timeout`,`source`],Ja=new Set([`env`,`headers`]);function sameValue(e,t,n){if(Ja.has(e)&&isRecord$1(t)&&isRecord$1(n)){let e=Object.keys(t);return e.length===Object.keys(n).length&&e.every(e=>t[e]===n[e])}return JSON.stringify(t)===JSON.stringify(n)}function divergingFields(e,t,n=new Set(qa)){return qa.filter(r=>{if(!n.has(r))return!1;let i=e[r];if(i===void 0)return!1;if(Ja.has(r)&&isRecord$1(i)&&isRecord$1(t[r])){let e=t[r];return Object.keys(i).some(t=>i[t]!==e[t])}return!sameValue(r,i,t[r])})}function sameField(e,t,n){return sameValue(e,t?.[e],n?.[e])}function stringMap(e){if(!isRecord$1(e))return;let t=Object.entries(e).filter(([,e])=>typeof e==`string`);return t.length?Object.fromEntries(t):void 0}const Ya=new Set([`stdio`,`http`,`sse`]);function transportOf(e){let t=e.type??e.transport;if(typeof t==`string`&&Ya.has(t))return t;if(typeof e.url==`string`)return`http`;if(typeof e.command==`string`)return`stdio`}function serverFrom(e){let t=Array.isArray(e.args)&&e.args.every(e=>typeof e==`string`),n=transportOf(e),r=stringMap(e.env),i=stringMap(e.headers);return{...n?{transport:n}:{},...typeof e.command==`string`?{command:e.command}:{},...t?{args:e.args}:{},...r?{env:r}:{},...typeof e.url==`string`?{url:e.url}:{},...i?{headers:i}:{},...typeof e.description==`string`?{description:e.description}:{},...typeof e.enabled==`boolean`?{enabled:e.enabled}:{},...typeof e.timeout==`number`?{timeout:e.timeout}:{},...typeof e.source==`string`?{source:e.source}:{}}}const Xa=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/,Za=/\$\{[^}]*\}|\$[A-Za-z_]/;var Refusal=class extends Error{field;reason;constructor(e,t){super(t),this.field=e,this.reason=t}};function refuse(e,t){throw new Refusal(e,t)}function rendering(e){try{return{kind:`entry`,entry:e()}}catch(e){if(!(e instanceof Refusal))throw e;return{kind:`refused`,field:e.field,reason:e.reason}}}function assertRunnable(e){(e.transport===`stdio`?!e.command:!e.url)&&refuse(e.transport===`stdio`?`command`:`url`,`the golden set leaves it unset and the target requires it`)}function defined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function mapValues(e,t){return e&&Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)]))}function noReferenceIn(e,t,n){for(let r of t){let t=e[r];(Array.isArray(t)?t:[t]).some(e=>typeof e==`string`&&Za.test(e))&&refuse(r,`${n} documents no reference expansion here`)}}const Qa={fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`description`,`timeout`]),read:serverFrom,write:e=>rendering(()=>(assertRunnable(e),defined({type:e.transport,command:e.command,args:e.args,env:e.env,url:e.url,headers:e.headers,description:e.description,timeout:e.timeout})))};function toCursor(e,t){return e.replace(/\$\{([^}]*)\}|\$[A-Za-z_]/g,(e,n)=>((n===void 0||!Xa.test(e))&&refuse(t,`Cursor expands only a plain variable reference, with no default`),`\${env:${n}}`))}function fromCursor(e){return e.replace(/\$\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,t)=>`\${${t}}`)}function fromCursorEntry(e){let strings=e=>typeof e==`string`?fromCursor(e):e,map=e=>isRecord$1(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,strings(t)])):e;return{...e,command:strings(e.command),args:Array.isArray(e.args)?e.args.map(strings):e.args,env:map(e.env),url:strings(e.url),headers:map(e.headers)}}const $a={fields:new Set([`command`,`args`,`env`,`url`,`headers`]),read:e=>serverFrom(fromCursorEntry(e)),write:e=>rendering(()=>(assertRunnable(e),defined({type:e.transport===`stdio`?`stdio`:void 0,command:e.command&&toCursor(e.command,`command`),args:e.args?.map(e=>toCursor(e,`args`)),env:mapValues(e.env,e=>toCursor(e,`env`)),url:e.url&&toCursor(e.url,`url`),headers:mapValues(e.headers,e=>toCursor(e,`headers`))})))},eo=/^Bearer \$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;function codexEnv(e){let t={},n=[];for(let[r,i]of Object.entries(e??{}))Xa.exec(i)?.[1]===r?n.push(r):Za.test(i)?refuse(`env`,`Codex passes a variable through only under its own name`):t[r]=i;return defined({env:Object.keys(t).length?t:void 0,env_vars:n.length?n:void 0})}function codexHeaders(e){let t={},n={},r;for(let[i,a]of Object.entries(e??{})){let e=Xa.exec(a)?.[1],o=eo.exec(a)?.[1];o&&i===`Authorization`?r=o:e?n[i]=e:Za.test(a)?refuse(`headers`,`Codex fills a header only from a whole variable reference, or Bearer and one`):t[i]=a}return defined({http_headers:Object.keys(t).length?t:void 0,env_http_headers:Object.keys(n).length?n:void 0,bearer_token_env_var:r})}function stringRecord(e){return isRecord$1(e)?Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`)):{}}function fromCodex(e){let t=Array.isArray(e.env_vars)?e.env_vars.filter(e=>typeof e==`string`):[],n={...stringRecord(e.env),...Object.fromEntries(t.map(e=>[e,`\${${e}}`]))},r=e.bearer_token_env_var,i={...stringRecord(e.http_headers),...Object.fromEntries(Object.entries(stringRecord(e.env_http_headers)).map(([e,t])=>[e,`\${${t}}`])),...typeof r==`string`?{Authorization:`Bearer \${${r}}`}:{}},a=e.tool_timeout_sec;return{command:e.command,args:e.args,env:n,url:e.url,headers:i,enabled:e.enabled,timeout:typeof a==`number`?Math.round(a*1e3):void 0}}const to={fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`enabled`,`timeout`]),defaults:{timeout:6e4},read:e=>serverFrom(fromCodex(e)),write:e=>rendering(()=>(e.transport===`sse`&&refuse(`transport`,`Codex supports no SSE transport`),assertRunnable(e),noReferenceIn(e,[`command`,`args`,`url`],`Codex`),defined({command:e.command,args:e.args,...codexEnv(e.env),url:e.url,...codexHeaders(e.headers),enabled:e.enabled,tool_timeout_sec:e.timeout===void 0?void 0:e.timeout/1e3})))};function fromGemini(e){let{httpUrl:t,url:n,...r}=e;return typeof t==`string`?{...r,type:`http`,url:t}:typeof n==`string`?{...r,type:`sse`,url:n}:r}const no={"claude-code":Qa,cursor:$a,codex:to,"gemini-cli":{fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`timeout`]),defaults:{timeout:6e5},read:e=>serverFrom(fromGemini(e)),write:e=>rendering(()=>(assertRunnable(e),defined({command:e.command,args:e.args,env:e.env,url:e.transport===`sse`?e.url:void 0,httpUrl:e.transport===`http`?e.url:void 0,headers:e.headers,timeout:e.timeout})))}};function stripJsonComments(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(r){t+=a,i?i=!1:a===`\\`?i=!0:a===`"`&&(r=!1),n+=1;continue}if(a===`"`){r=!0,t+=a,n+=1;continue}if(a===`/`&&e[n+1]===`/`){for(;n<e.length&&e[n]!==`
|
|
93
|
+
`;)n++;else if(r===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t===-1?e.length:t+2}else t+=r,n++}return t.replace(/,(\s*[}\]])/g,`$1`)}__name(stripJsonComments$1,`stripJsonComments`);function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pluginStorage(e,t={}){return ya[e](resolveHarnessEnvironment(t))}const xdgConfig=({env:e,homedir:t})=>e.XDG_CONFIG_HOME||v(t,`.config`);function vscodeAgentPlugins({env:e,homedir:t,platform:n}){if(n===`win32`){let n=w.join(e.APPDATA||w.join(t,`AppData`,`Roaming`),`Code`);return{configDir:n,path:w.join(n,`agentPlugins`)}}let r=n===`darwin`?v(t,`Library`,`Application Support`,`Code`):v(t,`.config`,`Code`);return{configDir:r,path:v(r,`agentPlugins`)}}const ya={"claude-code":({env:e,homedir:t})=>{let n=e.CLAUDE_CONFIG_DIR||v(t,`.claude`),r=v(n,`plugins`);return{harness:`claude-code`,configDir:n,locations:[{kind:`plugin-cache`,path:v(r,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CC-P1`},{kind:`marketplaces`,path:v(r,`marketplaces`),description:`Marketplace checkouts`,research:`E-CC-P1`},{kind:`install-record`,path:v(r,`installed_plugins.json`),description:`Installs keyed by plugin@marketplace, each with scope, installPath, and version`,research:`E-CC-P2`},{kind:`enabled-record`,path:v(n,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-CC-P3`}]}},cursor:({homedir:e})=>{let t=v(e,`.cursor`);return{harness:`cursor`,configDir:t,locations:[{kind:`local-plugins`,path:v(t,`plugins`,`local`),description:`Plugins under development, one folder each`,research:`E-CUR-P2`},{kind:`marketplaces`,path:v(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-CUR-P3`}]}},codex:({env:e,homedir:t})=>{let n=e.CODEX_HOME||v(t,`.codex`);return{harness:`codex`,configDir:n,locations:[{kind:`plugin-cache`,path:v(n,`plugins`,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CODEX-P3`},{kind:`enabled-record`,path:v(n,`config.toml`),description:`User config; [plugins."<plugin>@<marketplace>"] tables carry enabled = <bool>`,research:`E-CODEX-P2`}]}},"copilot-cli":({env:e,homedir:t})=>{let n=e.COPILOT_HOME||v(t,`.copilot`);return{harness:`copilot-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:v(n,`installed-plugins`),description:`Installed plugins as <marketplace>/<plugin>/, or _direct/<source-id>/ for direct installs`,research:`E-COPILOT-P9`},{kind:`install-record`,path:v(n,`config.json`),description:`Application state, including installedPlugins`,research:`E-COPILOT-P9`},{kind:`enabled-record`,path:v(n,`settings.json`),description:`User settings (JSON with comments); enabledPlugins maps plugin specs to a boolean`,research:`E-COPILOT-P4`}]}},opencode:e=>{let t=v(xdgConfig(e),`opencode`);return{harness:`opencode`,configDir:t,locations:[{kind:`local-plugins`,path:v(t,`plugins`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-OC-P2`}]}},kilo:e=>{let t=v(xdgConfig(e),`kilo`);return{harness:`kilo`,configDir:t,locations:[{kind:`local-plugins`,path:v(t,`plugin`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-KILO-P2`}]}},"gemini-cli":({env:e,homedir:t})=>{let n=v(e.GEMINI_CLI_HOME||t,`.gemini`),r=v(n,`extensions`);return{harness:`gemini-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a gemini-extension.json manifest`,research:`E-GEM-P1`},{kind:`enabled-record`,path:v(r,`extension-enablement.json`),description:`Per-extension path-glob overrides that enable or disable it by folder, not a boolean`,research:`E-GEM-P3`}]}},"qwen-code":({env:e,homedir:t})=>{let n=e.QWEN_HOME||v(t,`.qwen`),r=v(n,`extensions`);return{harness:`qwen-code`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a qwen-extension.json manifest`,research:`E-QWEN-P1`},{kind:`enabled-record`,path:v(r,`extension-enablement.json`),description:`Extension enable/disable state, inherited from Gemini CLI's format`,research:`E-QWEN-P2`}]}},"vscode-copilot":e=>{let{configDir:t,path:n}=vscodeAgentPlugins(e);return{harness:`vscode-copilot`,configDir:t,locations:[{kind:`installed-plugins`,path:n,description:`Installed agent plugins as <host>/<org>/<repo>/`,research:`E-VSC-P3`}]}},cline:({homedir:e})=>{let t=v(e,`.cline`);return{harness:`cline`,configDir:t,locations:[{kind:`installed-plugins`,path:v(t,`plugins`,`_installed`),description:`Installed plugins, grouped by source: npm, git, remote, or local`,research:`E-CLINE-P3`}]}},crush:({env:e,homedir:t})=>({harness:`crush`,configDir:e.CRUSH_GLOBAL_CONFIG||v(e.XDG_CONFIG_HOME||v(t,`.config`),`crush`),locations:[]}),openhands:({env:e,homedir:t})=>{let n=e.OH_PERSISTENCE_DIR||e.OPENHANDS_PERSISTENCE_DIR||v(t,`.openhands`),r=v(n,`plugins`,`installed`);return{harness:`openhands`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed plugins, one folder each`,research:`E-OH-P3`},{kind:`enabled-record`,path:v(r,`.installed.json`),description:`Install metadata keyed by plugin name, each with enabled: <bool>`,research:`E-OH-P4`}]}},augment:({homedir:e})=>{let t=v(e,`.augment`);return{harness:`augment`,configDir:t,locations:[{kind:`marketplaces`,path:v(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-AUG-P2`},{kind:`enabled-record`,path:v(t,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-AUG-P4`}]}}};async function enabledPlugins(e,t={}){let n=Ca[e](resolveHarnessEnvironment(t),t.managedSettingsPath),r=new Map,i=[];for(let e of n.sources){let t;try{let n=await readText(e.path);if(n===void 0){i.push({scope:e.scope,path:e.path,found:!1});continue}t=e.parse(n)}catch(t){i.push({scope:e.scope,path:e.path,found:!0,error:String(t)});continue}i.push({scope:e.scope,path:e.path,found:!0});for(let[n,i]of Object.entries(t))r.has(n)||r.set(n,{id:n,enabled:i,scope:e.scope,source:e.path})}return{harness:e,supported:n.supported,plugins:[...r.values()],sources:i,unread:n.unread,research:n.research}}function jsonEnabledPlugins(e){let t=JSON.parse(e),n=isRecord(t)?t.enabledPlugins:void 0;return isRecord(n)?Object.fromEntries(Object.entries(n).filter(e=>typeof e[1]==`boolean`)):{}}const ba=/^\[\s*plugins\s*\.\s*(?:"([^"]*)"|'([^']*)'|([A-Za-z0-9_-]+))\s*\]\s*(?:#.*)?$/,xa=/^enabled\s*=\s*(true|false)\s*(?:#.*)?$/;function tomlEnabledPlugins(e){let t={},n;for(let r of e.split(/\r?\n/)){let e=r.trim();if(e.startsWith(`[`)){let t=ba.exec(e);n=t?t[1]??t[2]??t[3]:void 0;continue}let i=n===void 0?null:xa.exec(e);n!==void 0&&i&&(t[n]=i[1]===`true`)}return t}const Sa={server:`server-managed settings`,"macos-managed-preferences":`MDM managed preferences`,"windows-registry":`Windows registry policy`,directory:`drop-in managed settings`,file:`managed file`};function unreadPolicy(e,t,n=[]){return e.filter(e=>e.location!==t&&!n.some(t=>e.location.endsWith(t))).map(e=>`${Sa[e.kind]} (${e.location})`)}function managedFile(e,t){return e.find(e=>e.kind===`file`&&e.location.endsWith(t))?.location}function jsoncEnabledPlugins(e){return jsonEnabledPlugins(stripJsonComments$1(e))}const unsupported$1=(...e)=>({supported:!1,sources:[],unread:[],research:e}),Ca={"claude-code":(e,t)=>{let{configDir:n}=pluginStorage(`claude-code`,e),r=managedPolicyLocations(`claude-code`,e),i=managedFile(r,`managed-settings.json`),a=t??i,o=v(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:jsonEnabledPlugins}],{scope:`local`,path:v(o,`settings.local.json`),parse:jsonEnabledPlugins},{scope:`project`,path:v(o,`settings.json`),parse:jsonEnabledPlugins},{scope:`user`,path:v(n,`settings.json`),parse:jsonEnabledPlugins}],unread:unreadPolicy(r,i,[`managed-mcp.json`]),research:[`E-CC-P3`,`E-CC-P7`,`E-CC-M1`,`E-CC-M6`]}},cursor:()=>unsupported$1(),opencode:()=>unsupported$1(`E-OC-P3`),kilo:()=>unsupported$1(`E-KILO-P3`),"gemini-cli":()=>unsupported$1(`E-GEM-P3`),"qwen-code":()=>unsupported$1(`E-QWEN-P2`),"vscode-copilot":()=>unsupported$1(`E-VSC-P4`),cline:()=>unsupported$1(`E-CLINE-P4`),crush:()=>unsupported$1(`E-CRUSH-P2`),openhands:()=>unsupported$1(`E-OH-P4`),augment:()=>unsupported$1(`E-AUG-P4`),codex:e=>{let t=pluginStorage(`codex`,e);return{supported:!0,sources:[{scope:`user`,path:v(t.configDir,`config.toml`),parse:tomlEnabledPlugins}],unread:unreadPolicy(managedPolicyLocations(`codex`,e),void 0),research:[`E-CODEX-P2`,`E-CODEX-M7`]}},"copilot-cli":(e,t)=>{let n=pluginStorage(`copilot-cli`,e),r=managedPolicyLocations(`copilot-cli`,e),i=managedFile(r,`managed-settings.json`),a=t??i,o=v(e.cwd,`.github`,`copilot`),s=v(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:jsoncEnabledPlugins}],{scope:`local`,path:v(o,`settings.local.json`),parse:jsoncEnabledPlugins},{scope:`project`,path:v(o,`settings.json`),parse:jsoncEnabledPlugins},{scope:`user`,path:v(n.configDir,`settings.json`),parse:jsoncEnabledPlugins}],unread:[...unreadPolicy(r,i),`Claude Code project settings (${v(s,`settings.json`)})`,`Claude Code local settings (${v(s,`settings.local.json`)})`],research:[`E-COPILOT-P4`,`E-COPILOT-M1`,`E-COPILOT-M2`,`E-COPILOT-M4`]}}};async function installedPlugins(e,t={}){let n=Ma[e](resolveHarnessEnvironment(t)),r={harness:e,supported:n.supported,unread:n.unread,research:n.research};if(n.source===void 0)return{...r,plugins:[],unresolved:[],sources:[]};let i=n.source;try{let e=await n.read(i);return e===void 0?{...r,plugins:[],unresolved:[],sources:[{path:i,found:!1}]}:{...r,plugins:e.plugins,unresolved:e.unresolved??[],sources:[{path:i,found:!0}]}}catch(e){return{...r,plugins:[],unresolved:[],sources:[{path:i,found:!0,error:String(e)}]}}}const wa=[`managed`,`local`,`project`,`user`],optionalString=e=>typeof e==`string`&&e!==``?e:void 0;async function readClaudeInstalls(e){let t=await readText(e);if(t===void 0)return;let n=JSON.parse(t),r=isRecord(n)?n.plugins:void 0;if(!isRecord(r))return{plugins:[]};let i=[];for(let[e,t]of Object.entries(r))if(Array.isArray(t))for(let n of t){let t=isRecord(n)?optionalString(n.installPath):void 0;if(!isRecord(n)||t===void 0)continue;let r=optionalString(n.version),a=typeof n.scope==`string`&&wa.includes(n.scope)?n.scope:void 0,o=optionalString(n.projectPath);i.push({id:e,path:t,...r===void 0?{}:{version:r},...a===void 0?{}:{scope:a},...o===void 0?{}:{projectPath:o},research:[`E-CC-P2`]})}return{plugins:i}}async function readCopilotInstalls(e){let t=await readText(e);if(t===void 0)return;let n=JSON.parse(stripJsonComments$1(t)),r=isRecord(n)?n.installedPlugins:void 0;if(!Array.isArray(r))return{plugins:[]};let i=[];for(let e of r){if(!isRecord(e))continue;let t=optionalString(e.name),n=optionalString(e.cache_path);if(t===void 0||n===void 0)continue;let r=optionalString(e.marketplace),a=optionalString(e.version);i.push({id:r===void 0?t:`${t}@${r}`,path:n,...a===void 0?{}:{version:a},research:r===void 0?[`E-COPILOT-P10`,`E-COPILOT-P11`]:[`E-COPILOT-P10`]})}return{plugins:i}}const Ta=`local`,Ea=/^[A-Za-z0-9_-]+$/,Da=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/,Oa=/^[A-Za-z0-9._+-]+$/;async function readCodexInstalls(e){let t=await directories(e);if(t===void 0)return;let n=[],r=[];for(let i of t.filter(e=>Ea.test(e)))for(let t of await directories(v(e,i))??[]){if(!Da.test(t))continue;let a=`${t}@${i}`,o=(await directories(v(e,i,t))??[]).filter(e=>Oa.test(e)&&e!==`.`&&e!==`..`);if(o.length===0)continue;let s=activeCodexVersion(o);if(s===void 0){r.push(a);continue}n.push({id:a,path:v(e,i,t,s),version:s,research:[`E-CODEX-P3`,`E-CODEX-P8`]})}return{plugins:n,unresolved:r}}function activeCodexVersion(e){if(e.includes(Ta))return Ta;let t=e.filter(e=>parseSemver(e)!==void 0).length;if(!(e.length>2&&t!==0&&t!==e.length))return[...e].sort(compareCodexVersions).at(-1)}async function directories(e){try{return(await re(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(e.code===`ENOENT`)return;throw e}}const ka=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;function parseSemver(e){let t=ka.exec(e);if(t)return{core:[t[1],t[2],t[3]],pre:t[4]===void 0?[]:t[4].split(`.`),build:t[5]===void 0?[]:t[5].split(`.`)}}function compareCodexVersions(e,t){let n=parseSemver(e),r=parseSemver(t);if(n===void 0||r===void 0)return compareStrings(e,t);for(let e=0;e<3;e++){let t=compareNumeric(n.core[e],r.core[e]);if(t!==0)return t}let i=n.pre.length===0||r.pre.length===0?r.pre.length-n.pre.length:compareIdentifiers(n.pre,r.pre);return i===0?compareIdentifiers(n.build,r.build):Math.sign(i)}const Aa=/^\d+$/;function compareIdentifiers(e,t){for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n],i=t[n],a=Aa.test(r),o=Aa.test(i),s=a&&o?compareNumeric(r,i):a===o?compareStrings(r,i):a?-1:1;if(s!==0)return s}return e.length-t.length}function compareNumeric(e,t){let n=e.replace(/^0+(?=\d)/,``),r=t.replace(/^0+(?=\d)/,``);return n.length-r.length||compareStrings(n,r)||e.length-t.length}const compareStrings=(e,t)=>e<t?-1:+(e>t),ja={supported:!1,read:async()=>void 0,unread:[],research:[]},Ma={"claude-code":e=>({supported:!0,source:v(pluginStorage(`claude-code`,e).configDir,`plugins`,`installed_plugins.json`),read:readClaudeInstalls,unread:[],research:[`E-CC-P2`]}),codex:e=>({supported:!0,source:v(pluginStorage(`codex`,e).configDir,`plugins`,`cache`),read:readCodexInstalls,unread:[],research:[`E-CODEX-P3`,`E-CODEX-P8`]}),"copilot-cli":e=>{let{configDir:t}=pluginStorage(`copilot-cli`,e);return{supported:!0,source:v(t,`config.json`),read:readCopilotInstalls,unread:[`plugins from marketplaces added by local path (extraKnownMarketplaces in ${v(t,`settings.json`)})`],research:[`E-COPILOT-P10`,`E-COPILOT-P11`,`E-COPILOT-P12`,`E-COPILOT-P13`]}},cursor:()=>ja,opencode:()=>ja,kilo:()=>ja,"gemini-cli":()=>ja,"qwen-code":()=>ja,"vscode-copilot":()=>ja,cline:()=>ja,crush:()=>ja,openhands:()=>ja,augment:()=>ja};function skillsDirectories(e){switch(e){case`claude-code`:return{project:[`.claude/skills`],user:[`.claude/skills`],research:[`E-CC-L1`]};case`cursor`:return{project:[`.agents/skills`,`.cursor/skills`,`.claude/skills`,`.codex/skills`],user:[`.agents/skills`,`.cursor/skills`,`.claude/skills`,`.codex/skills`],research:[`E-CUR-L1`]};case`codex`:return{project:[`.agents/skills`],user:[`.agents/skills`],research:[`E-CODEX-L1`]};case`copilot-cli`:return{project:[`.github/skills`,`.agents/skills`,`.claude/skills`],user:[`.copilot/skills`,`.agents/skills`],research:[`E-COPILOT-S5`]};case`vscode-copilot`:return{project:[`.github/skills`,`.claude/skills`,`.agents/skills`],user:[`.copilot/skills`,`.claude/skills`,`.agents/skills`],research:[`E-VSC-P1`]};case`opencode`:return{project:[`.opencode/skills`,`.claude/skills`,`.agents/skills`],user:[`.config/opencode/skills`,`.claude/skills`,`.agents/skills`],research:[`E-OC-S1`]};case`gemini-cli`:return{project:[`.agents/skills`,`.gemini/skills`],user:[`.agents/skills`,`.gemini/skills`],research:[`E-GEM-L1`]};case`cline`:return{project:[`.cline/skills`,`.clinerules/skills`,`.claude/skills`],user:[`.cline/skills`],research:[`E-CLINE-S1`]};case`augment`:return{project:[`.augment/skills`],user:[`.augment/skills`],research:[`E-AUG-S1`]};case`kilo`:case`qwen-code`:case`crush`:case`openhands`:return}}function skillsProjection(e,t,n=skillsDirectories(e)?.[t]){let r=n??[],[i]=r;if(i===void 0)throw Error(`@cyberuni/agent-harness records no ${t} skills directories for ${e}.`);return r.includes(`.agents/skills`)?{}:{skillsDirectory:i}}const Na=`.agents/AGENTS.md`,Pa=[{name:`claude-code`,project:{detect:`.claude`,...skillsProjection(`claude-code`,`project`),shadowedBy:[`CLAUDE.md`,`.claude/CLAUDE.md`,`CLAUDE.local.md`],mcpConfig:{path:`.mcp.json`,key:`mcpServers`,format:`json`,dialect:`claude-code`},nonstandard:[{path:`.claude/commands`,shape:`directory`,kind:`command`},{path:`.claude/rules`,shape:`directory`,kind:`rule`},{path:`.claude/agents`,shape:`directory`,kind:`subagent`}]},user:{detect:`.claude`,...skillsProjection(`claude-code`,`user`),relocatedBy:`CLAUDE_CONFIG_DIR`,instructionBridge:{kind:`import`,path:`.claude/CLAUDE.md`,line:`@~/${Na}`}}},{name:`cursor`,project:{detect:`.cursor`,...skillsProjection(`cursor`,`project`),mcpConfig:{path:`.cursor/mcp.json`,key:`mcpServers`,format:`json`,dialect:`cursor`},nonstandard:[{path:`.cursorrules`,shape:`file`,kind:`instructions`},{path:`.cursor/rules`,shape:`directory`,kind:`rule`},{path:`.cursor/commands`,shape:`directory`,kind:`command`},{path:`.cursor/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.cursor`,...skillsProjection(`cursor`,`user`)}},{name:`codex`,project:{detect:`.codex`,...skillsProjection(`codex`,`project`),mcpConfig:{path:`.codex/config.toml`,key:`mcp_servers`,format:`toml`,dialect:`codex`,shared:!0},nonstandard:[{path:`.codex/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.codex`,...skillsProjection(`codex`,`user`),instructionBridge:{kind:`symlink`,path:`.codex/AGENTS.md`},shadowedBy:[`.codex/AGENTS.override.md`],relocatedBy:`CODEX_HOME`}},{name:`copilot-cli`,project:{detect:`.github/skills`,...skillsProjection(`copilot-cli`,`project`),nonstandard:[{path:`.github/copilot-instructions.md`,shape:`file`,kind:`instructions`},{path:`.github/instructions`,shape:`directory`,kind:`instructions`},{path:`.github/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.copilot`,...skillsProjection(`copilot-cli`,`user`),relocatedBy:`COPILOT_HOME`,instructionBridge:{kind:`symlink`,path:`.copilot/copilot-instructions.md`}}},{name:`gemini-cli`,project:{detect:`.gemini`,...skillsProjection(`gemini-cli`,`project`),instructionBridge:{kind:`settings-entry`,path:`.gemini/settings.json`,key:`context.fileName`},mcpConfig:{path:`.gemini/settings.json`,key:`mcpServers`,format:`json`,dialect:`gemini-cli`,shared:!0},nonstandard:[{path:`GEMINI.md`,shape:`file`,kind:`instructions`},{path:`.gemini/skills`,shape:`directory`,kind:`skill`}]},user:{detect:`.gemini`,...skillsProjection(`gemini-cli`,`user`),instructionBridge:{kind:`symlink`,path:`.gemini/GEMINI.md`}}},{name:`devin-desktop`,project:{detect:`.devin`}},{name:`windsurf`,project:{detect:`.windsurf`,skillsDirectory:`.windsurf/skills`,nonstandard:[{path:`.windsurfrules`,shape:`file`,kind:`instructions`},{path:`.windsurf/rules`,shape:`directory`,kind:`rule`}]},deprecated:`devin-desktop`}],Fa=new Set(Pa.map(e=>e.name));function isHarnessName(e){return Fa.has(e)}function parseHarnesses(e){let t=(e??``).split(`,`).map(e=>e.trim()).filter(Boolean),n=t.filter(e=>!isHarnessName(e));if(n.length)throw Error(`Unsupported harness: ${n.join(`, `)}. Supported: ${Pa.map(e=>e.name).join(`, `)}.`);return t.filter(isHarnessName)}const Ia=[`claude-code`,`cursor`];function directoryExists(e){try{return i(e).isDirectory()}catch{return!1}}function selectHarnesses(e,t){let n=new Set([...Ia,...t]);return Pa.filter(t=>n.has(t.name)||directoryExists(v(e,t.project.detect)))}function locatorText({file:e,server:t,field:n,position:r}){return r?`${e}#L${r.line}:${r.column}`:t===void 0?e:`${e}#servers.${t}${n===void 0?``:`.${n}`}`}function repairsOf(e){return Object.entries(e).map(([e,t])=>({problem:e,...t}))}const La=`buddy-agent-harness`,Ra=`/buddy-agent-harness:repair`,X=`/buddy-agent-harness:init-buddy-agent-harness`,za=`.agents/buddy-agent-harness/mcp.toml`,Ba={"no-canonical":{detail:`the canonical skill directory does not exist, so no bridge can resolve`,repair:(e,t)=>({command:`${t} init`,instruction:`run \`${t} init\` to create .agents/skills and the bridges into it`}),skillRepair:()=>`run \`${X}\`, which creates \`.agents/skills\` and the bridges`},missing:{detail:`no bridge at this path — the harness sees zero project skills`,repair:({file:e},t)=>({command:`${t} init`,instruction:`run \`${t} init\` to create the bridge at ${e}`}),skillRepair:()=>`run \`${X}\``},degraded:{detail:`expected a directory but found a regular file — checkout without core.symlinks`,repair:({file:e},t)=>({command:`${t} init --copy --force ${e}`,instruction:`run \`${t} init --copy --force ${e}\` to rebuild ${e} as a real directory`}),skillRepair:({file:e})=>`run \`${X} --copy --force ${e}\``},stale:{detail:`symlink does not resolve to .agents/skills`,repair:({file:e},t)=>({command:`${t} init --force ${e}`,instruction:`run \`${t} init --force ${e}\` to repoint ${e} at .agents/skills`}),skillRepair:({file:e})=>`run \`${X} --force ${e}\``},"diverged-bridge":{detail:`only the bridge changed since the two last agreed — an agent wrote through the copy`,repair:({file:e},t)=>({command:``,instruction:`replace .agents/skills with ${e} to keep the newer edit, then run \`${t} init --force ${e}\``}),skillRepair:({file:e})=>`replace .agents/skills with ${e} to keep the newer edit, then run \`${X} --force ${e}\``},"diverged-canonical":{detail:`only .agents/skills changed since the two last agreed — the copy is stale`,repair:({file:e},t)=>({command:`${t} init --copy --force ${e}`,instruction:`run \`${t} init --copy --force ${e}\` to rebuild ${e} from the newer .agents/skills`}),skillRepair:({file:e})=>`run \`${X} --copy --force ${e}\``},"diverged-both":{detail:`both sides changed since they last agreed — rebuilding would discard one of them`,repair:({file:e})=>({command:``,instruction:`reconcile .agents/skills with ${e} by hand — rebuilding would discard one of them; \`git diff --no-index .agents/skills ${e}\` shows what differs`}),skillRepair:({file:e})=>`run \`git diff --no-index .agents/skills ${e}\` and reconcile by hand`},"diverged-unknown":{detail:`contents differ and no commit where they agreed was found — which side moved is unknown`,repair:({file:e})=>({command:``,instruction:`reconcile .agents/skills with ${e} by hand — which side moved is unknown; \`git diff --no-index .agents/skills ${e}\` shows what differs`}),skillRepair:({file:e})=>`run \`git diff --no-index .agents/skills ${e}\` and reconcile by hand`},"unpinned-copy":{detail:`tracked copy without the skip-worktree bit — the tree is dirty with content that must not be committed`,repair:({file:e})=>({command:`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree`,instruction:`run \`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree\` to restore the skip-worktree bit`}),skillRepair:({file:e})=>`run \`git ls-files -z ${e} | xargs -0 git update-index --skip-worktree\``}};repairsOf(Ba);const Va={"no-instructions":{detail:`no AGENTS.md at the repository root, so the instructions this repository has reach one harness at most`,repair:()=>({command:``,instruction:`hand this to \`${X}\`, which consolidates what the repository has into AGENTS.md, or derives it`}),skillRepair:()=>`run \`${X}\`, which consolidates or derives AGENTS.md`},"instructions-missing":{detail:`no instruction bridge at this path — the harness reads none of AGENTS.md`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${X}\`, which writes the bridge into it`}),skillRepair:()=>`run \`${X}\``},"instructions-unbridged":{detail:`the file is present but names AGENTS.md nowhere — the harness reads none of it`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${X}\`, which adds the bridge without discarding what the file already says`}),skillRepair:()=>`run \`${X}\`, which adds the bridge without discarding what the file already says`},"instructions-shadowing":{detail:`this file suppresses the AGENTS.md beside it — the harness reads this instead, and none of AGENTS.md`,repair:({file:e})=>({command:``,instruction:`hand ${e} to \`${X}\`, which consolidates what it says into AGENTS.md, or adds an @AGENTS.md import above it where the file has to stay`}),skillRepair:()=>`run \`${X}\`, which consolidates the file into AGENTS.md or imports AGENTS.md from it`},"instructions-superseded":{detail:`a bridge from before the harness read AGENTS.md itself — it still works, and nothing needs it`,repair:({file:e})=>({command:``,instruction:`remove ${e}, or keep it for sessions that cannot read AGENTS.md directly — \`${X}\` offers the choice`}),skillRepair:()=>`run \`${X}\`, which offers to remove it`},"instructions-unreadable":{detail:`the settings file does not parse, so the harness reads none of it`,repair:({file:e})=>({command:``,instruction:`fix the JSON in ${e} by hand, then hand it to \`${X}\``}),skillRepair:()=>`fix the JSON by hand, then run \`${X}\``}};repairsOf(Va);const Ha=`~/${Na}`;function globalBridgeStep(e,t=`~/${e.path}`){return e.kind===`import`?`add the line \`${e.line}\` to ${t}`:`run \`ln -s ${Ha} ${t}\``}function userSpellings(e,t){let n=`${e.detect}/`;return e.relocatedBy!==void 0&&t.startsWith(n)?[`~/${t}`,`$${e.relocatedBy}/${t.slice(n.length)}`]:[`~/${t}`]}function userBridgeAt(e){for(let{user:t}of Pa){let n=t?.instructionBridge;if(t&&n&&userSpellings(t,n.path).includes(e))return n}}function stepAt(e,t){let n=userBridgeAt(e);return n===void 0?`add the bridge the harness page names for ${e}`:`${t&&n.kind!==`import`?`move what ${e} says into ${Ha} and remove it, then `:``}${globalBridgeStep(n,e)}`}const Ua=`hand the user this step, since nothing here writes outside the repository:`,Wa={"global-instructions-missing":{detail:`no user-scope instruction file at this path — the harness loads none of ${Ha}`,repair:({file:e})=>({command:``,instruction:`${Ua} ${stepAt(e,!1)}`}),skillRepair:()=>`hand the user the step the harness page names for that file; write nothing yourself`},"global-instructions-unbridged":{detail:`the file holds its own content and does not load ${Ha} — text placed there reaches no session of this harness`,repair:({file:e})=>({command:``,instruction:`${Ua} ${stepAt(e,!0)}`}),skillRepair:()=>`hand the user the step the harness page names for that file, keeping what the file says; write nothing yourself`},"global-instructions-overridden":{detail:`the harness reads this file in place of its own user-scope file, so whatever that file loads goes unread, and this one does not load ${Ha}`,repair:({file:e})=>({command:``,instruction:`${Ua} move what ${e} says into ${Ha} and remove it`}),skillRepair:()=>`hand the user the move of what that file says into the global file, and its removal; write nothing yourself`}};repairsOf(Wa);const Ga={"deprecated-harness":{detail:`a projection under a harness name that has been superseded — the replacement reads .agents/skills natively and needs no projection at all`,repair:({file:e})=>({command:``,instruction:`remove ${e} and enable the harness that replaced it — \`${Ra}\` offers the correction`}),skillRepair:()=>`run \`${Ra}\``},"ignored-bridge":{detail:`a .gitignore rule matches this bridge — an untracked bridge swallows a real edit silently`,repair:({file:e})=>({command:``,instruction:`narrow or remove the .gitignore rule matching ${e} — \`${Ra}\` offers the correction`}),skillRepair:()=>`run \`${Ra}\``},"unread-local-override":{detail:`no harness reads this filename, so everything in it is invisible to every agent`,repair:({file:e})=>({command:``,instruction:`move ${e} to CLAUDE.local.md, or consolidate it into AGENTS.md — \`${Ra}\` offers the correction`}),skillRepair:()=>`run \`${Ra}\``},"unloadable-skill":{detail:`frontmatter that does not parse, or no description — either one makes a harness skip the skill outright`,repair:({file:e})=>({command:``,instruction:`quote the description in ${e}, or add one — \`${Ra}\` offers the correction`}),skillRepair:()=>`run \`${Ra}\``}};repairsOf(Ga);const Ka={"mcp-golden-unreadable":{detail:`the golden MCP set does not parse — the locator gives the line and column, and nothing else can be said about it`,repair:e=>({command:``,instruction:`fix the TOML at ${locatorText(e)}`}),skillRepair:e=>`fix the TOML at ${locatorText(e)} by hand — the reported line and column are all that can be quoted, because the parser's own message repeats the offending line and that line is the one holding the credential`},"mcp-target-unreadable":{detail:`this harness config does not parse, so the harness starts none of its servers and nothing in it can be compared`,repair:e=>({command:``,instruction:`fix the syntax of ${locatorText(e)}`}),skillRepair:e=>`fix the syntax of ${locatorText(e)} by hand`},"mcp-unprojected":{detail:`the golden set declares this server and the harness config does not carry it`,repair:({file:e,server:t})=>({command:``,instruction:`add the server ${t} to ${e}, or drop it from the golden set — \`${Ra}\` offers the correction`}),skillRepair:e=>`hand ${locatorText(e)} to \`${Ra}\`, which projects it from its golden entry with \`mcp project\` — or drop it from the golden set`},"mcp-undeclared":{detail:`the harness config carries this server and the golden set does not declare it`,repair:({file:e,server:t})=>({command:``,instruction:`add the server ${t} to ${za}, or drop it from ${e} — \`${Ra}\` offers the import`}),skillRepair:e=>`hand ${locatorText(e)} to \`${Ra}\`, which imports it field by field with \`mcp reconcile\`, refusing any literal credential — or drop it from ${e.file}`},"mcp-diverged-target":{detail:`only the harness config changed since the two last agreed — the edit was made through the copy`,repair:e=>({command:``,instruction:`reconcile the value at ${locatorText(e)} back into ${za} — \`${Ra}\` offers the import`}),skillRepair:e=>`hand ${locatorText(e)} to \`${Ra}\`, which imports the field into ${za} with \`mcp reconcile\` once approved`},"mcp-diverged-golden":{detail:`only the golden set changed since the two last agreed — the harness copy is stale`,repair:e=>({command:``,instruction:`update ${locatorText(e)} from the golden entry — \`${Ra}\` offers the correction`}),skillRepair:e=>`hand ${locatorText(e)} to \`${Ra}\`, which updates it from the golden entry with \`mcp project\``},"mcp-diverged-both":{detail:`both sides changed since they last agreed — merging either way would discard the other`,repair:e=>({command:``,instruction:`reconcile ${locatorText(e)} against ${za} by hand`}),skillRepair:e=>`reconcile ${locatorText(e)} against ${za} by hand — never merge a three-way conflict automatically`},"mcp-diverged-unknown":{detail:`the two disagree and no baseline says which side moved — neither history nor a last-projected record covers this server`,repair:e=>({command:``,instruction:`compare ${locatorText(e)} against ${za} by hand`}),skillRepair:e=>`compare ${locatorText(e)} against ${za} by hand`},"mcp-literal-secret":{detail:`a credential-bearing field holds a literal rather than a reference to an environment variable`,repair:e=>({command:``,instruction:`move the value at ${locatorText(e)} into an environment variable and reference it`}),skillRepair:e=>`move the value at ${locatorText(e)} into an environment variable and reference it — read the value from the file, never from this report, and never repeat it back`},"mcp-committed-secret":{detail:`a credential-bearing field holds a literal in a git-tracked file — the credential is committed, and moving it does not un-commit it`,repair:e=>({command:``,instruction:`rotate the credential behind ${locatorText(e)}, then reference it from an environment variable`}),skillRepair:e=>`rotate the credential behind ${locatorText(e)} at its issuer, then reference it from an environment variable — it is in the repository's history, so moving it is not enough`}};repairsOf(Ka);const qa={"nonstandard-instructions":{detail:`instruction content only one harness reads — AGENTS.md carries the same prose to all of them`,repair:({file:e})=>({command:``,instruction:`consolidate ${e} into AGENTS.md — \`${X}\` offers the consolidation, and keeps the content reachable where this harness needs it`}),skillRepair:({file:e})=>`hand ${e} to \`${X}\`, which consolidates it into AGENTS.md`},"nonstandard-rule":{detail:`a path-scoped rule only one harness reads — a skill reaches every harness where the scoping is incidental`,repair:({file:e})=>({command:``,instruction:`convert ${e} into a skill under .agents/skills where its guidance is not tied to the paths it names — \`${X}\` offers the conversion; keep it where the path scoping is the point`}),skillRepair:({file:e})=>`hand ${e} to \`${X}\` to convert into a skill, unless the path scoping is load-bearing`},"nonstandard-command":{detail:`a harness command file — a skill is the portable form, and this harness reads skills too`,repair:({file:e})=>({command:``,instruction:`move ${e} to .agents/skills/<name>/SKILL.md — \`${X}\` offers the move`}),skillRepair:({file:e})=>`hand ${e} to \`${X}\`, which moves it to .agents/skills`},"nonstandard-skill":{detail:`a skill under a harness directory rather than the canonical one, where only that harness finds it`,repair:({file:e})=>({command:``,instruction:`move ${e} to .agents/skills and project it back where the harness needs one — \`${X}\` offers the move`}),skillRepair:({file:e})=>`hand ${e} to \`${X}\`, which moves it to .agents/skills`},"nonstandard-subagent":{detail:`a subagent definition with no cross-harness form — nothing outside this harness can read it, and no canonical form exists yet`,repair:({file:e})=>({command:``,instruction:`leave ${e} where it is and record that it reaches one harness only — no portable form exists to convert it to`}),skillRepair:({file:e})=>`leave ${e} in place — no portable form exists yet, so this is work for a person rather than a skill`}};repairsOf(qa);const Ja={...Ba,...Va,...Wa,...Ga,...Ka,...qa};repairsOf(Ja);function repairFor(e){return{problem:e,...Ja[e]}}const Ya=`.agents/skills`,Xa=`AGENTS.local.md`;function frontmatterFault(e){let t=/^---\n([\s\S]*?)\n---/.exec(e);if(!t)return`unparseable`;let n=/^description:[ \t]*(.*)$/m.exec(t[1])?.[1]?.trim();if(!n)return`no-description`;if(!/^(['"]).*\1$/.test(n)&&/:\s/.test(n))return`unparseable`}function diagnoseConfiguration({root:e,git:t,cli:n}){let i=[],add=(e,t)=>{let{detail:r,repair:a}=repairFor(t);i.push({path:e,problem:t,detail:r,repair:a({file:e},n)})},a=selectHarnesses(e,[]);for(let t of a){let n=t.project.skillsDirectory;t.deprecated&&n&&r(v(e,n))&&add(n,`deprecated-harness`)}for(let n of a){let i=n.project.skillsDirectory;i&&r(v(e,i))&&t.isIgnored(i)&&add(i,`ignored-bridge`)}r(v(e,Xa))&&add(Xa,`unread-local-override`);for(let t of filesUnder(v(e,Ya)).filter(e=>e.endsWith(`SKILL.md`)))frontmatterFault(o(v(e,Ya,t),`utf8`))&&add(`${Ya}/${t}`,`unloadable-skill`);return i}const Za=[`transport`,`command`,`args`,`env`,`url`,`headers`,`description`,`enabled`,`timeout`,`source`],Qa=new Set([`env`,`headers`]);function sameValue(e,t,n){if(Qa.has(e)&&isRecord$1(t)&&isRecord$1(n)){let e=Object.keys(t);return e.length===Object.keys(n).length&&e.every(e=>t[e]===n[e])}return JSON.stringify(t)===JSON.stringify(n)}function divergingFields(e,t,n=new Set(Za)){return Za.filter(r=>{if(!n.has(r))return!1;let i=e[r];if(i===void 0)return!1;if(Qa.has(r)&&isRecord$1(i)&&isRecord$1(t[r])){let e=t[r];return Object.keys(i).some(t=>i[t]!==e[t])}return!sameValue(r,i,t[r])})}function sameField(e,t,n){return sameValue(e,t?.[e],n?.[e])}function stringMap(e){if(!isRecord$1(e))return;let t=Object.entries(e).filter(([,e])=>typeof e==`string`);return t.length?Object.fromEntries(t):void 0}const $a=new Set([`stdio`,`http`,`sse`]);function transportOf(e){let t=e.type??e.transport;if(typeof t==`string`&&$a.has(t))return t;if(typeof e.url==`string`)return`http`;if(typeof e.command==`string`)return`stdio`}function serverFrom(e){let t=Array.isArray(e.args)&&e.args.every(e=>typeof e==`string`),n=transportOf(e),r=stringMap(e.env),i=stringMap(e.headers);return{...n?{transport:n}:{},...typeof e.command==`string`?{command:e.command}:{},...t?{args:e.args}:{},...r?{env:r}:{},...typeof e.url==`string`?{url:e.url}:{},...i?{headers:i}:{},...typeof e.description==`string`?{description:e.description}:{},...typeof e.enabled==`boolean`?{enabled:e.enabled}:{},...typeof e.timeout==`number`?{timeout:e.timeout}:{},...typeof e.source==`string`?{source:e.source}:{}}}const eo=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/,to=/\$\{[^}]*\}|\$[A-Za-z_]/;var Refusal=class extends Error{field;reason;constructor(e,t){super(t),this.field=e,this.reason=t}};function refuse(e,t){throw new Refusal(e,t)}function rendering(e){try{return{kind:`entry`,entry:e()}}catch(e){if(!(e instanceof Refusal))throw e;return{kind:`refused`,field:e.field,reason:e.reason}}}function assertRunnable(e){(e.transport===`stdio`?!e.command:!e.url)&&refuse(e.transport===`stdio`?`command`:`url`,`the golden set leaves it unset and the target requires it`)}function defined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}function mapValues(e,t){return e&&Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)]))}function noReferenceIn(e,t,n){for(let r of t){let t=e[r];(Array.isArray(t)?t:[t]).some(e=>typeof e==`string`&&to.test(e))&&refuse(r,`${n} documents no reference expansion here`)}}const no={fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`description`,`timeout`]),read:serverFrom,write:e=>rendering(()=>(assertRunnable(e),defined({type:e.transport,command:e.command,args:e.args,env:e.env,url:e.url,headers:e.headers,description:e.description,timeout:e.timeout})))};function toCursor(e,t){return e.replace(/\$\{([^}]*)\}|\$[A-Za-z_]/g,(e,n)=>((n===void 0||!eo.test(e))&&refuse(t,`Cursor expands only a plain variable reference, with no default`),`\${env:${n}}`))}function fromCursor(e){return e.replace(/\$\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,t)=>`\${${t}}`)}function fromCursorEntry(e){let strings=e=>typeof e==`string`?fromCursor(e):e,map=e=>isRecord$1(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,strings(t)])):e;return{...e,command:strings(e.command),args:Array.isArray(e.args)?e.args.map(strings):e.args,env:map(e.env),url:strings(e.url),headers:map(e.headers)}}const ro={fields:new Set([`command`,`args`,`env`,`url`,`headers`]),read:e=>serverFrom(fromCursorEntry(e)),write:e=>rendering(()=>(assertRunnable(e),defined({type:e.transport===`stdio`?`stdio`:void 0,command:e.command&&toCursor(e.command,`command`),args:e.args?.map(e=>toCursor(e,`args`)),env:mapValues(e.env,e=>toCursor(e,`env`)),url:e.url&&toCursor(e.url,`url`),headers:mapValues(e.headers,e=>toCursor(e,`headers`))})))},io=/^Bearer \$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;function codexEnv(e){let t={},n=[];for(let[r,i]of Object.entries(e??{}))eo.exec(i)?.[1]===r?n.push(r):to.test(i)?refuse(`env`,`Codex passes a variable through only under its own name`):t[r]=i;return defined({env:Object.keys(t).length?t:void 0,env_vars:n.length?n:void 0})}function codexHeaders(e){let t={},n={},r;for(let[i,a]of Object.entries(e??{})){let e=eo.exec(a)?.[1],o=io.exec(a)?.[1];o&&i===`Authorization`?r=o:e?n[i]=e:to.test(a)?refuse(`headers`,`Codex fills a header only from a whole variable reference, or Bearer and one`):t[i]=a}return defined({http_headers:Object.keys(t).length?t:void 0,env_http_headers:Object.keys(n).length?n:void 0,bearer_token_env_var:r})}function stringRecord(e){return isRecord$1(e)?Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`)):{}}function fromCodex(e){let t=Array.isArray(e.env_vars)?e.env_vars.filter(e=>typeof e==`string`):[],n={...stringRecord(e.env),...Object.fromEntries(t.map(e=>[e,`\${${e}}`]))},r=e.bearer_token_env_var,i={...stringRecord(e.http_headers),...Object.fromEntries(Object.entries(stringRecord(e.env_http_headers)).map(([e,t])=>[e,`\${${t}}`])),...typeof r==`string`?{Authorization:`Bearer \${${r}}`}:{}},a=e.tool_timeout_sec;return{command:e.command,args:e.args,env:n,url:e.url,headers:i,enabled:e.enabled,timeout:typeof a==`number`?Math.round(a*1e3):void 0}}const ao={fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`enabled`,`timeout`]),defaults:{timeout:6e4},read:e=>serverFrom(fromCodex(e)),write:e=>rendering(()=>(e.transport===`sse`&&refuse(`transport`,`Codex supports no SSE transport`),assertRunnable(e),noReferenceIn(e,[`command`,`args`,`url`],`Codex`),defined({command:e.command,args:e.args,...codexEnv(e.env),url:e.url,...codexHeaders(e.headers),enabled:e.enabled,tool_timeout_sec:e.timeout===void 0?void 0:e.timeout/1e3})))};function fromGemini(e){let{httpUrl:t,url:n,...r}=e;return typeof t==`string`?{...r,type:`http`,url:t}:typeof n==`string`?{...r,type:`sse`,url:n}:r}const oo={"claude-code":no,cursor:ro,codex:ao,"gemini-cli":{fields:new Set([`transport`,`command`,`args`,`env`,`url`,`headers`,`timeout`]),defaults:{timeout:6e5},read:e=>serverFrom(fromGemini(e)),write:e=>rendering(()=>(assertRunnable(e),defined({command:e.command,args:e.args,env:e.env,url:e.transport===`sse`?e.url:void 0,httpUrl:e.transport===`http`?e.url:void 0,headers:e.headers,timeout:e.timeout})))}};function stripJsonComments(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(r){t+=a,i?i=!1:a===`\\`?i=!0:a===`"`&&(r=!1),n+=1;continue}if(a===`"`){r=!0,t+=a,n+=1;continue}if(a===`/`&&e[n+1]===`/`){for(;n<e.length&&e[n]!==`
|
|
94
94
|
`;)n+=1;continue}if(a===`/`&&e[n+1]===`*`){for(n+=2;n<e.length&&(e[n]!==`*`||e[n+1]!==`/`);)n+=1;n+=2;continue}t+=a,n+=1}return t}function parseJsonWithComments(e){try{return JSON.parse(stripJsonComments(e))}catch{return}}
|
|
95
95
|
/*!
|
|
96
96
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -119,7 +119,7 @@ ${toPrettyType(e.config)}`:``}function toPrettyType(e){return tersify(toTypeObje
|
|
|
119
119
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
120
120
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
121
121
|
*/
|
|
122
|
-
let
|
|
122
|
+
let so=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var co=class TomlDate extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(so);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(e,t=`Z`){let n=new TomlDate(e);return n.#n=t,n}static wrapAsLocalDateTime(e){let t=new TomlDate(e);return t.#n=null,t}static wrapAsLocalDate(e){let t=new TomlDate(e);return t.#t=!1,t.#n=null,t}static wrapAsLocalTime(e){let t=new TomlDate(e);return t.#e=!1,t.#n=null,t}};
|
|
123
123
|
/*!
|
|
124
124
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
125
125
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -206,8 +206,8 @@ function indexOfNewline(e,t=0){let n=e.indexOf(`
|
|
|
206
206
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
207
207
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
208
208
|
*/
|
|
209
|
-
let
|
|
210
|
-
`;else if(n===102)o+=`\f`;else if(n===114)o+=`\r`;else if(n===101)o+=`\x1B`;else if(n===34)o+=`"`;else if(n===92)o+=`\\`;else throw new TomlError(`unrecognized escape sequence`,{toml:e.s,ptr:e.p});s=e.p+1,c=0}}else if(n!==32&&n!==9){if(c===2)throw new TomlError(`invalid escape: only line-ending whitespace may be escaped`,{toml:e.s,ptr:s});c=+(!i&&n===92),s=e.p}throw new TomlError(`unfinished string`,{toml:e.s,ptr:t})}function sliceAndTrimEndOf(e,t,n){let r=e.s.slice(t,n),i=r.indexOf(`#`);return i>0&&(skipComment({s:r,p:i,d:0}),r=r.slice(0,i)),r.trimEnd()}function parseValue(e,t,n){let r=e.p,i={toml:e.s,ptr:r};skipUntil(e,44,n);let a=sliceAndTrimEndOf(e,r,e.p);if(!a)throw new TomlError(`incomplete declaration: value expected`,i);if(a===`-inf`)return-1/0;if(a===`inf`||a===`+inf`)return 1/0;if(a===`nan`||a===`+nan`||a===`-nan`)return NaN;if(a===`-0`)return t?0n:0;let o=
|
|
209
|
+
let lo=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,uo=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,fo=/^[+-]?0[0-9_]/;function parseString(e){let t=e.p,n=e.s.charCodeAt(e.p++),r=n,i=n===39,a=n===e.s.charCodeAt(e.p)&&n===e.s.charCodeAt(e.p+1);a&&((n=e.s.charCodeAt(e.p+=2))===10?e.p++:n===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let o=``,s=e.p,c=0;for(;e.p<e.s.length;e.p++)if(n=e.s.charCodeAt(e.p),a&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10))c&&=3;else if(n<32&&n!==9||n===127)throw new TomlError(`control characters are not allowed in strings`,{toml:e.s,ptr:e.p});else if((!c||c===3)&&n===r&&(!a||e.s.charCodeAt(e.p+1)===r&&e.s.charCodeAt(e.p+2)===r))return a&&(e.s.charCodeAt(e.p+3)===r&&e.p++,e.s.charCodeAt(e.p+3)===r&&e.p++),c||(o+=e.s.slice(s,e.p)),e.p+=a?3:1,o;else if(!c)!i&&n===92&&(o+=e.s.slice(s,s=e.p),c=1);else if(c===1){if(n===120||n===117||n===85){let t=0,r=n===120?2:n===117?4:8;for(let n=0;n<r;n++,e.p++){let n=e.s.charCodeAt(e.p+1),r=n>=48&&n<=57?n-48:n>=65&&n<=70?n-65+10:n>=97&&n<=102?n-97+10:-1;if(r<0)throw new TomlError(`invalid non-hex character in unicode escape`,{toml:e.s,ptr:e.p+1});t=t<<4|r}if(t<0||t>1114111||t>=55296&&t<=57343)throw new TomlError(`invalid unicode escape`,{toml:e.s,ptr:e.p});o+=String.fromCodePoint(t),s=e.p+1,c=0}else if(n===32||n===9)c=2;else{if(n===98)o+=`\b`;else if(n===116)o+=` `;else if(n===110)o+=`
|
|
210
|
+
`;else if(n===102)o+=`\f`;else if(n===114)o+=`\r`;else if(n===101)o+=`\x1B`;else if(n===34)o+=`"`;else if(n===92)o+=`\\`;else throw new TomlError(`unrecognized escape sequence`,{toml:e.s,ptr:e.p});s=e.p+1,c=0}}else if(n!==32&&n!==9){if(c===2)throw new TomlError(`invalid escape: only line-ending whitespace may be escaped`,{toml:e.s,ptr:s});c=+(!i&&n===92),s=e.p}throw new TomlError(`unfinished string`,{toml:e.s,ptr:t})}function sliceAndTrimEndOf(e,t,n){let r=e.s.slice(t,n),i=r.indexOf(`#`);return i>0&&(skipComment({s:r,p:i,d:0}),r=r.slice(0,i)),r.trimEnd()}function parseValue(e,t,n){let r=e.p,i={toml:e.s,ptr:r};skipUntil(e,44,n);let a=sliceAndTrimEndOf(e,r,e.p);if(!a)throw new TomlError(`incomplete declaration: value expected`,i);if(a===`-inf`)return-1/0;if(a===`inf`||a===`+inf`)return 1/0;if(a===`nan`||a===`+nan`||a===`-nan`)return NaN;if(a===`-0`)return t?0n:0;let o=lo.test(a);if(o||uo.test(a)){if(fo.test(a))throw new TomlError(`leading zeroes are not allowed`,i);a=a.replace(/_/g,``);let e=+a;if(isNaN(e))throw new TomlError(`invalid number`,i);if(o){if((o=!Number.isSafeInteger(e))&&!t)throw new TomlError(`integer value cannot be represented losslessly`,i);(o||t===!0)&&(e=BigInt(a))}return e}let s=new co(a);if(!s.isValid())throw new TomlError(`invalid value`,i);return s}
|
|
211
211
|
/*!
|
|
212
212
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
213
213
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -263,7 +263,7 @@ function extractValue(e,t,n){let r=e.p,i=e.s.charCodeAt(r);if(i===91||i===123){i
|
|
|
263
263
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
264
264
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
265
265
|
*/
|
|
266
|
-
let
|
|
266
|
+
let po=/^[a-zA-Z0-9-_]+[ \t]*$/;function parseKey(e,t=`=`){let n=e.p,r=n-1,i=[],a=e.s.indexOf(t,n);if(a<0)throw new TomlError(`incomplete key-value: cannot find end of key`,{toml:e.s,ptr:n});do{let o=e.s.charCodeAt(e.p=++r);if(o!==32&&o!==9){if(o===34||o===39){if(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2))throw new TomlError(`multiline strings are not allowed in keys`,{toml:e.s,ptr:e.p});let s=parseString(e);r=e.s.indexOf(`.`,e.p);let c=e.s.slice(e.p,r<0||r>a?a:r),l=indexOfNewline(c);if(l>-1)throw new TomlError(`newlines are not allowed in keys`,{toml:e.s,ptr:l});if(c.trimStart())throw new TomlError(`found extra tokens after the string part`,{toml:e.s,ptr:e.p});if(a<e.p&&(a=e.s.indexOf(t,e.p),a<0))throw new TomlError(`incomplete key-value: cannot find end of key`,{toml:e.s,ptr:n});i.push(s)}else{r=e.s.indexOf(`.`,e.p);let t=e.s.slice(e.p,r<0||r>a?a:r);if(!po.test(t))throw new TomlError(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e.s,ptr:e.p});i.push(t.trimEnd())}}}while(r+1&&r<a);return e.p=a+1,skipVoid(e,!0,!0),i}function parseInlineTable(e,t){let n={},r=new Set,i;for(e.p++;e.p<e.s.length;){if(skipVoid(e),(i=e.s.charCodeAt(e.p))===125)return e.p++,n;let a,o=n,s=!1,c=e.p,l=parseKey(e);for(let t=0;t<l.length;t++){if(t&&(o=s?o[a]:o[a]={}),a=l[t],(s=Object.hasOwn(o,a))&&(typeof o[a]!=`object`||r.has(o[a])))throw new TomlError(`trying to redefine an already defined value`,{toml:e.s,ptr:c});!s&&a===`__proto__`&&Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0})}if(s)throw new TomlError(`trying to redefine an already defined value`,{toml:e.s,ptr:e.p});let u=extractValue(e,125,t);if(r.add(o[a]=u),skipVoid(e),(i=e.s.charCodeAt(e.p++))===125)return n;if(i!==44)throw new TomlError(`expected comma or end of structure`,{toml:e.s,ptr:e.p-1})}throw new TomlError(`unfinished table encountered`,{toml:e.s,ptr:e.p})}function parseArray(e,t){let n=[],r;for(e.p++;e.p<e.s.length;){if(skipVoid(e),(r=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(extractValue(e,93,t)),skipVoid(e),(r=e.s.charCodeAt(e.p++))===93)return n;if(r!==44)throw new TomlError(`expected comma or end of structure`,{toml:e.s,ptr:e.p-1})}throw new TomlError(`unfinished array encountered`,{toml:e.s,ptr:e.p})}
|
|
267
267
|
/*!
|
|
268
268
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
269
269
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -319,21 +319,21 @@ function peekTable(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(
|
|
|
319
319
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
320
320
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
321
321
|
*/
|
|
322
|
-
let
|
|
323
|
-
`}[[${t}]]\n`,i+=stringifyTable(0,e[a],t,n,r);return i}function stringifyTable(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=extendedTypeOf(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=
|
|
322
|
+
let mo=/^[a-z0-9-_]+$/i;function extendedTypeOf(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(typeof e?.getUTCDate==`function`&&e instanceof Date)return`date`;if(globalThis.Temporal&&typeof e?.since==`function`&&(e instanceof Temporal.Instant||e instanceof Temporal.PlainDate||e instanceof Temporal.PlainDateTime||e instanceof Temporal.PlainTime||e instanceof Temporal.ZonedDateTime))return`temporal`}return t}function isArrayOfTables(e){for(let t=0;t<e.length;t++)if(extendedTypeOf(e[t])!==`object`)return!1;return e.length!=0}function formatString(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function stringifyTemporal(e){return e.toString({calendarName:`never`,timeZoneName:`never`})}function stringifyValue(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);switch(t){case`number`:if(isNaN(e))return`nan`;if(e===1/0)return`inf`;if(e===-1/0)return`-inf`;if(Number.isInteger(e)&&(r||!Number.isSafeInteger(e)))return e.toFixed(1);case`bigint`:case`boolean`:return e.toString();case`string`:return formatString(e);case`date`:if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString();case`object`:return stringifyInlineTable(e,n,r);case`array`:return stringifyArray(e,n,r);case`temporal`:return stringifyTemporal(e)}}function stringifyInlineTable(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=mo.test(o)?o:formatString(o),i+=` = `,i+=stringifyValue(e[o],extendedTypeOf(e[o]),t-1,n)}return i+` }`}function stringifyArray(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=stringifyValue(e[i],extendedTypeOf(e[i]),t-1,n)}return r+` ]`}function stringifyArrayTable(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
|
|
323
|
+
`}[[${t}]]\n`,i+=stringifyTable(0,e[a],t,n,r);return i}function stringifyTable(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=extendedTypeOf(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=mo.test(c)?c:formatString(c);if(e===`array`&&isArrayOfTables(t[c]))o+=(o&&`
|
|
324
324
|
`)+stringifyArrayTable(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
|
|
325
325
|
`)+stringifyTable(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=stringifyValue(t[c],e,r,i),a+=`
|
|
326
326
|
`}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function stringify(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(extendedTypeOf(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=stringifyTable(0,e,``,t,n);return r[r.length-1]===`
|
|
327
327
|
`?r:r+`
|
|
328
|
-
`}const uo=`.agents/buddy-agent-harness/mcp.toml`;function mcpTargets(e){let t=new Set;return selectHarnesses(e,[]).map(e=>e.project.mcpConfig).filter(e=>e!==void 0).filter(e=>!t.has(e.path)&&t.add(e.path))}function serversUnder(e,t,n=serverFrom){let r=isRecord$1(e)?e[t]:void 0;return isRecord$1(r)?new Map(Object.entries(r).filter(([,e])=>isRecord$1(e)).map(([e,t])=>[e,n(t)])):new Map}function positionOf(e){if(!isRecord$1(e))return;let{line:t,column:n}=e;return typeof t==`number`&&typeof n==`number`?{line:t,column:n}:void 0}function parseGoldenSet(e){if(e===void 0)return{kind:`absent`};try{return{kind:`servers`,servers:serversUnder(parse$2(e),`servers`)}}catch(e){return{kind:`unreadable`,position:positionOf(e)}}}function parseTarget(e,t){if(t===void 0)return{kind:`absent`};if(e.format===`toml`)try{return{kind:`servers`,servers:serversUnder(parse$2(t),e.key,no[e.dialect].read)}}catch{return{kind:`unreadable`}}let n=parseJsonWithComments(t);return n===void 0?{kind:`unreadable`}:{kind:`servers`,servers:serversUnder(n,e.key,no[e.dialect].read)}}const fo=`.agents/buddy-agent-harness/mcp.projected.json`;function parseProjectionRecord(e){let t=e===void 0?void 0:parseJsonWithComments(e),n=isRecord$1(t)?t.targets:void 0;return isRecord$1(n)?new Map(Object.entries(n).filter(([,e])=>isRecord$1(e)).map(([e,t])=>[e,new Map(Object.entries(t).filter(([,e])=>isRecord$1(e)).map(([e,t])=>[e,t]))])):new Map}function formatProjectionRecord(e){let t=Object.fromEntries([...e].map(([e,t])=>[e,Object.fromEntries(t)]));return`${JSON.stringify({targets:t},null,2)}\n`}var McpBaseline=class{options;constructor(e){this.options=e}parsed=new Map;walked=new Map;directionOf(e,t,n,r,i){let a=this.baseFor(e,t,n);if(a===void 0)return`unknown`;let o=!sameField(n,r,a),s=!sameField(n,i,a);return o&&s?`both`:s?`target`:`golden`}baseFor(e,t,n){return this.options.record.get(e.path)?.get(t)||this.lastAgreed(e,t,n)}lastAgreed(e,t,n){for(let r of this.commitsTouching(e)){let i=this.parseAt(r,uo,parseGoldenSet),a=this.parseAt(r,e.path,t=>parseTarget(e,t));if(i.kind!==`servers`||a.kind!==`servers`)continue;let o=i.servers.get(t),s=a.servers.get(t);if(o&&s&&sameField(n,o,s))return o}}commitsTouching(e){let t=this.walked.get(e.path);if(t)return t;let n=this.options.git.commitsTouching([uo,e.path]);return this.walked.set(e.path,n),n}parseAt(e,t,n){let r=`${e}\u0000${t}`,i=this.parsed.get(r);if(i)return i;let a=n(this.options.git.contentAt(e,t));return this.parsed.set(r,a),a}};const po=/token|secret|password|passwd|credential/i,mo=new Set([`key`,`apikey`,`auth`,`authorization`,`bearer`]);function segmentsOf(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}const ho=/\$\{[^}]+\}|\$[A-Za-z_][A-Za-z0-9_]*/;function holdsLiteral(e){return!ho.test(e)}function credentialKey(e){return po.test(e)||segmentsOf(e).some(e=>mo.has(e))}function urlHoldsCredential(e){let t;try{t=new URL(e)}catch{return!1}if(t.password)return!0;for(let[e,n]of t.searchParams)if(credentialKey(e)&&holdsLiteral(n))return!0;return!1}function literalsIn$1(e,t){return Object.entries(t??{}).filter(([e,t])=>credentialKey(e)&&holdsLiteral(t)).map(([t])=>`${e}.${t}`)}__name(literalsIn$1,`literalsIn`);function credentialFields(e){return[...literalsIn$1(`env`,e.env),...literalsIn$1(`headers`,e.headers),...e.url&&urlHoldsCredential(e.url)?[`url`]:[]]}function nonSecretArgs(e){return(e??[]).filter(e=>{let t=e.indexOf(`=`);return t===-1||!(credentialKey(e.slice(0,t))&&holdsLiteral(e.slice(t+1)))})}function read$2(e,t){let n=v(e,t);return r(n)?o(n,`utf8`):void 0}__name(read$2,`read`);const go={target:`mcp-diverged-target`,golden:`mcp-diverged-golden`,both:`mcp-diverged-both`,unknown:`mcp-diverged-unknown`};function diagnoseMcp({root:e,git:t,cli:n}){let r=[],add=(e,t)=>{let{detail:i,repair:a}=repairFor(t);r.push({path:locatorText(e),problem:t,detail:i,repair:a(e,n)})},reportSecrets=(e,n)=>{let r=t.trackingOf(e)!==`untracked`;for(let[t,i]of n)for(let n of credentialFields(i))add({file:e,server:t,field:n},r?`mcp-committed-secret`:`mcp-literal-secret`)},i=new Map,a=[];for(let t of mcpTargets(e)){let n=parseTarget(t,read$2(e,t.path));if(n.kind===`unreadable`){add({file:t.path},`mcp-target-unreadable`);continue}n.kind!==`absent`&&(reportSecrets(t.path,n.servers),i.set(t.path,n.servers),a.push(t))}let o=parseGoldenSet(read$2(e,uo));if(o.kind===`unreadable`)return add({file:uo,position:o.position},`mcp-golden-unreadable`),r;if(o.kind===`absent`)return r;reportSecrets(uo,o.servers);let s=new McpBaseline({git:t,record:parseProjectionRecord(read$2(e,fo))});for(let e of a){let t=i.get(e.path);for(let[n,r]of o.servers){let i=t.get(n);if(!i){add({file:e.path,server:n},`mcp-unprojected`);continue}for(let t of divergingFields(r,i,no[e.dialect].fields))add({file:e.path,server:n,field:t},go[s.directionOf(e,n,t,r,i)])}for(let n of t.keys())o.servers.has(n)||add({file:e.path,server:n},`mcp-undeclared`)}return r}const _o={instructions:`nonstandard-instructions`,rule:`nonstandard-rule`,command:`nonstandard-command`,skill:`nonstandard-skill`,subagent:`nonstandard-subagent`};function scopedByGlobs(e){let t=/^---\n([\s\S]*?)\n---/.exec(e);if(!t)return!1;let n=/^globs:[ \t]*(.*)$/m.exec(t[1])?.[1]?.trim();return n!==void 0&&n.length>0&&n!==`[]`}function skillFiles(e){return filesUnder(e).filter(e=>e.endsWith(`SKILL.md`))}function authoredHere(e){try{return!i(e).isSymbolicLink()}catch{return!1}}function artifactFiles(e,t){let n=v(e,t.path);return authoredHere(n)?t.shape===`file`?[t.path]:(t.kind===`skill`?skillFiles(n):filesUnder(n)).map(e=>b.join(t.path,e)):[]}function diagnoseNonstandard({root:e,cli:t}){let n=[];for(let r of Na)for(let i of r.project.nonstandard??[])for(let r of artifactFiles(e,i)){let a=i.kind===`rule`&&r.endsWith(`.mdc`)&&!scopedByGlobs(o(v(e,r),`utf8`))?`instructions`:i.kind,s=_o[a],{detail:c,repair:l}=repairFor(s);n.push({path:r,problem:s,detail:c,repair:l({file:r},t)})}return n.sort((e,t)=>e.path.localeCompare(t.path))}var Z=__commonJSMin((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),isAlias=e=>!!e&&typeof e==`object`&&e[s]===t,isDocument=e=>!!e&&typeof e==`object`&&e[s]===n,isMap=e=>!!e&&typeof e==`object`&&e[s]===r,isPair=e=>!!e&&typeof e==`object`&&e[s]===i,isScalar=e=>!!e&&typeof e==`object`&&e[s]===a,isSeq=e=>!!e&&typeof e==`object`&&e[s]===o;function isCollection(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function isNode(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}let hasAnchor=e=>(isScalar(e)||isCollection(e))&&!!e.anchor;e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=hasAnchor,e.isAlias=isAlias,e.isCollection=isCollection,e.isDocument=isDocument,e.isMap=isMap,e.isNode=isNode,e.isPair=isPair,e.isScalar=isScalar,e.isSeq=isSeq})),vo=__commonJSMin((e=>{var t=Z();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function visit(e,n){let r=initVisitor(n);t.isDocument(e)?visit_(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):visit_(null,e,r,Object.freeze([]))}visit.BREAK=n,visit.SKIP=r,visit.REMOVE=i;function visit_(e,r,a,o){let s=callVisitor(e,r,a,o);if(t.isNode(s)||t.isPair(s))return replaceNode(e,o,s),visit_(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=visit_(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=visit_(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=visit_(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}async function visitAsync(e,n){let r=initVisitor(n);t.isDocument(e)?await visitAsync_(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await visitAsync_(null,e,r,Object.freeze([]))}visitAsync.BREAK=n,visitAsync.SKIP=r,visitAsync.REMOVE=i;async function visitAsync_(e,r,a,o){let s=await callVisitor(e,r,a,o);if(t.isNode(s)||t.isPair(s))return replaceNode(e,o,s),visitAsync_(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await visitAsync_(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await visitAsync_(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await visitAsync_(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function initVisitor(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function callVisitor(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function replaceNode(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=visit,e.visitAsync=visitAsync})),yo=__commonJSMin((e=>{var t=Z(),n=vo();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},escapeTagName=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var i=class Directives{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Directives.defaultYaml,e),this.tags=Object.assign({},Directives.defaultTags,t)}clone(){let e=new Directives(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new Directives(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:Directives.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},Directives.defaultTags)}return e}add(e,t){this.atNextDocument&&=(this.yaml={explicit:Directives.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},Directives.defaultTags),!1);let n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case`%TAG`:{if(n.length!==2&&(t(0,`%TAG directive should contain exactly two parts`),n.length<2))return!1;let[e,r]=n;return this.tags[e]=r,!0}case`%YAML`:{if(this.yaml.explicit=!0,n.length!==1)return t(0,`%YAML directive should contain exactly one part`),!1;let[e]=n;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let n=/^\d+\.\d+$/.test(e);return t(6,`Unsupported YAML version ${e}`,n),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+escapeTagName(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)(t!==`!!`||n!==`tag:yaml.org,2002:`)&&(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
|
|
329
|
-
`)}};i.defaultYaml={explicit:!1,version:`1.2`},i.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=i})),
|
|
328
|
+
`}const ho=`.agents/buddy-agent-harness/mcp.toml`;function mcpTargets(e){let t=new Set;return selectHarnesses(e,[]).map(e=>e.project.mcpConfig).filter(e=>e!==void 0).filter(e=>!t.has(e.path)&&t.add(e.path))}function serversUnder(e,t,n=serverFrom){let r=isRecord$1(e)?e[t]:void 0;return isRecord$1(r)?new Map(Object.entries(r).filter(([,e])=>isRecord$1(e)).map(([e,t])=>[e,n(t)])):new Map}function positionOf(e){if(!isRecord$1(e))return;let{line:t,column:n}=e;return typeof t==`number`&&typeof n==`number`?{line:t,column:n}:void 0}function parseGoldenSet(e){if(e===void 0)return{kind:`absent`};try{return{kind:`servers`,servers:serversUnder(parse$2(e),`servers`)}}catch(e){return{kind:`unreadable`,position:positionOf(e)}}}function parseTarget(e,t){if(t===void 0)return{kind:`absent`};if(e.format===`toml`)try{return{kind:`servers`,servers:serversUnder(parse$2(t),e.key,oo[e.dialect].read)}}catch{return{kind:`unreadable`}}let n=parseJsonWithComments(t);return n===void 0?{kind:`unreadable`}:{kind:`servers`,servers:serversUnder(n,e.key,oo[e.dialect].read)}}const go=`.agents/buddy-agent-harness/mcp.projected.json`;function parseProjectionRecord(e){let t=e===void 0?void 0:parseJsonWithComments(e),n=isRecord$1(t)?t.targets:void 0;return isRecord$1(n)?new Map(Object.entries(n).filter(([,e])=>isRecord$1(e)).map(([e,t])=>[e,new Map(Object.entries(t).filter(([,e])=>isRecord$1(e)).map(([e,t])=>[e,t]))])):new Map}function formatProjectionRecord(e){let t=Object.fromEntries([...e].map(([e,t])=>[e,Object.fromEntries(t)]));return`${JSON.stringify({targets:t},null,2)}\n`}var McpBaseline=class{options;constructor(e){this.options=e}parsed=new Map;walked=new Map;directionOf(e,t,n,r,i){let a=this.baseFor(e,t,n);if(a===void 0)return`unknown`;let o=!sameField(n,r,a),s=!sameField(n,i,a);return o&&s?`both`:s?`target`:`golden`}baseFor(e,t,n){return this.options.record.get(e.path)?.get(t)||this.lastAgreed(e,t,n)}lastAgreed(e,t,n){for(let r of this.commitsTouching(e)){let i=this.parseAt(r,ho,parseGoldenSet),a=this.parseAt(r,e.path,t=>parseTarget(e,t));if(i.kind!==`servers`||a.kind!==`servers`)continue;let o=i.servers.get(t),s=a.servers.get(t);if(o&&s&&sameField(n,o,s))return o}}commitsTouching(e){let t=this.walked.get(e.path);if(t)return t;let n=this.options.git.commitsTouching([ho,e.path]);return this.walked.set(e.path,n),n}parseAt(e,t,n){let r=`${e}\u0000${t}`,i=this.parsed.get(r);if(i)return i;let a=n(this.options.git.contentAt(e,t));return this.parsed.set(r,a),a}};const _o=/token|secret|password|passwd|credential/i,vo=new Set([`key`,`apikey`,`auth`,`authorization`,`bearer`]);function segmentsOf(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}const yo=/\$\{[^}]+\}|\$[A-Za-z_][A-Za-z0-9_]*/;function holdsLiteral(e){return!yo.test(e)}function credentialKey(e){return _o.test(e)||segmentsOf(e).some(e=>vo.has(e))}function urlHoldsCredential(e){let t;try{t=new URL(e)}catch{return!1}if(t.password)return!0;for(let[e,n]of t.searchParams)if(credentialKey(e)&&holdsLiteral(n))return!0;return!1}function literalsIn$1(e,t){return Object.entries(t??{}).filter(([e,t])=>credentialKey(e)&&holdsLiteral(t)).map(([t])=>`${e}.${t}`)}__name(literalsIn$1,`literalsIn`);function credentialFields(e){return[...literalsIn$1(`env`,e.env),...literalsIn$1(`headers`,e.headers),...e.url&&urlHoldsCredential(e.url)?[`url`]:[]]}function nonSecretArgs(e){return(e??[]).filter(e=>{let t=e.indexOf(`=`);return t===-1||!(credentialKey(e.slice(0,t))&&holdsLiteral(e.slice(t+1)))})}function read$2(e,t){let n=v(e,t);return r(n)?o(n,`utf8`):void 0}__name(read$2,`read`);const bo={target:`mcp-diverged-target`,golden:`mcp-diverged-golden`,both:`mcp-diverged-both`,unknown:`mcp-diverged-unknown`};function diagnoseMcp({root:e,git:t,cli:n}){let r=[],add=(e,t)=>{let{detail:i,repair:a}=repairFor(t);r.push({path:locatorText(e),problem:t,detail:i,repair:a(e,n)})},reportSecrets=(e,n)=>{let r=t.trackingOf(e)!==`untracked`;for(let[t,i]of n)for(let n of credentialFields(i))add({file:e,server:t,field:n},r?`mcp-committed-secret`:`mcp-literal-secret`)},i=new Map,a=[];for(let t of mcpTargets(e)){let n=parseTarget(t,read$2(e,t.path));if(n.kind===`unreadable`){add({file:t.path},`mcp-target-unreadable`);continue}n.kind!==`absent`&&(reportSecrets(t.path,n.servers),i.set(t.path,n.servers),a.push(t))}let o=parseGoldenSet(read$2(e,ho));if(o.kind===`unreadable`)return add({file:ho,position:o.position},`mcp-golden-unreadable`),r;if(o.kind===`absent`)return r;reportSecrets(ho,o.servers);let s=new McpBaseline({git:t,record:parseProjectionRecord(read$2(e,go))});for(let e of a){let t=i.get(e.path);for(let[n,r]of o.servers){let i=t.get(n);if(!i){add({file:e.path,server:n},`mcp-unprojected`);continue}for(let t of divergingFields(r,i,oo[e.dialect].fields))add({file:e.path,server:n,field:t},bo[s.directionOf(e,n,t,r,i)])}for(let n of t.keys())o.servers.has(n)||add({file:e.path,server:n},`mcp-undeclared`)}return r}const xo={instructions:`nonstandard-instructions`,rule:`nonstandard-rule`,command:`nonstandard-command`,skill:`nonstandard-skill`,subagent:`nonstandard-subagent`};function scopedByGlobs(e){let t=/^---\n([\s\S]*?)\n---/.exec(e);if(!t)return!1;let n=/^globs:[ \t]*(.*)$/m.exec(t[1])?.[1]?.trim();return n!==void 0&&n.length>0&&n!==`[]`}function skillFiles(e){return filesUnder(e).filter(e=>e.endsWith(`SKILL.md`))}function authoredHere(e){try{return!i(e).isSymbolicLink()}catch{return!1}}function artifactFiles(e,t){let n=v(e,t.path);return authoredHere(n)?t.shape===`file`?[t.path]:(t.kind===`skill`?skillFiles(n):filesUnder(n)).map(e=>b.join(t.path,e)):[]}function diagnoseNonstandard({root:e,cli:t}){let n=[];for(let r of Pa)for(let i of r.project.nonstandard??[])for(let r of artifactFiles(e,i)){let a=i.kind===`rule`&&r.endsWith(`.mdc`)&&!scopedByGlobs(o(v(e,r),`utf8`))?`instructions`:i.kind,s=xo[a],{detail:c,repair:l}=repairFor(s);n.push({path:r,problem:s,detail:c,repair:l({file:r},t)})}return n.sort((e,t)=>e.path.localeCompare(t.path))}var Z=__commonJSMin((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),isAlias=e=>!!e&&typeof e==`object`&&e[s]===t,isDocument=e=>!!e&&typeof e==`object`&&e[s]===n,isMap=e=>!!e&&typeof e==`object`&&e[s]===r,isPair=e=>!!e&&typeof e==`object`&&e[s]===i,isScalar=e=>!!e&&typeof e==`object`&&e[s]===a,isSeq=e=>!!e&&typeof e==`object`&&e[s]===o;function isCollection(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function isNode(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}let hasAnchor=e=>(isScalar(e)||isCollection(e))&&!!e.anchor;e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=hasAnchor,e.isAlias=isAlias,e.isCollection=isCollection,e.isDocument=isDocument,e.isMap=isMap,e.isNode=isNode,e.isPair=isPair,e.isScalar=isScalar,e.isSeq=isSeq})),So=__commonJSMin((e=>{var t=Z();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function visit(e,n){let r=initVisitor(n);t.isDocument(e)?visit_(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):visit_(null,e,r,Object.freeze([]))}visit.BREAK=n,visit.SKIP=r,visit.REMOVE=i;function visit_(e,r,a,o){let s=callVisitor(e,r,a,o);if(t.isNode(s)||t.isPair(s))return replaceNode(e,o,s),visit_(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=visit_(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=visit_(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=visit_(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}async function visitAsync(e,n){let r=initVisitor(n);t.isDocument(e)?await visitAsync_(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await visitAsync_(null,e,r,Object.freeze([]))}visitAsync.BREAK=n,visitAsync.SKIP=r,visitAsync.REMOVE=i;async function visitAsync_(e,r,a,o){let s=await callVisitor(e,r,a,o);if(t.isNode(s)||t.isPair(s))return replaceNode(e,o,s),visitAsync_(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await visitAsync_(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await visitAsync_(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await visitAsync_(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function initVisitor(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function callVisitor(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function replaceNode(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=visit,e.visitAsync=visitAsync})),Co=__commonJSMin((e=>{var t=Z(),n=So();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},escapeTagName=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var i=class Directives{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Directives.defaultYaml,e),this.tags=Object.assign({},Directives.defaultTags,t)}clone(){let e=new Directives(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new Directives(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:Directives.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},Directives.defaultTags)}return e}add(e,t){this.atNextDocument&&=(this.yaml={explicit:Directives.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},Directives.defaultTags),!1);let n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case`%TAG`:{if(n.length!==2&&(t(0,`%TAG directive should contain exactly two parts`),n.length<2))return!1;let[e,r]=n;return this.tags[e]=r,!0}case`%YAML`:{if(this.yaml.explicit=!0,n.length!==1)return t(0,`%YAML directive should contain exactly one part`),!1;let[e]=n;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let n=/^\d+\.\d+$/.test(e);return t(6,`Unsupported YAML version ${e}`,n),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+escapeTagName(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)(t!==`!!`||n!==`tag:yaml.org,2002:`)&&(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
|
|
329
|
+
`)}};i.defaultYaml={explicit:!1,version:`1.2`},i.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=i})),wo=__commonJSMin((e=>{var t=Z(),n=So();function anchorIsValid(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function anchorNames(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function findNewAnchor(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function createNodeAnchors(e,n){let r=[],i=new Map,a=null;return{onAnchor:t=>{r.push(t),a??=anchorNames(e);let i=findNewAnchor(n,a);return a.add(i),i},setAnchors:()=>{for(let e of r){let n=i.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:i}}e.anchorIsValid=anchorIsValid,e.anchorNames=anchorNames,e.createNodeAnchors=createNodeAnchors,e.findNewAnchor=findNewAnchor})),To=__commonJSMin((e=>{function applyReviver(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=applyReviver(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=applyReviver(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=applyReviver(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=applyReviver(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}e.applyReviver=applyReviver})),Eo=__commonJSMin((e=>{var t=Z();function toJS(e,n,r){if(Array.isArray(e))return e.map((e,t)=>toJS(e,String(t),r));if(e&&typeof e.toJSON==`function`){if(!r||!t.hasAnchor(e))return e.toJSON(n,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=e=>{i.res=e,delete r.onCreate};let a=e.toJSON(n,r);return r.onCreate&&r.onCreate(a),a}return typeof e==`bigint`&&!r?.keep?Number(e):e}e.toJS=toJS})),Do=__commonJSMin((e=>{var t=To(),n=Z(),r=Eo(),NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}};e.NodeBase=NodeBase})),Oo=__commonJSMin((e=>{var t=wo(),n=So(),r=Z(),i=Do(),a=Eo(),Alias=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let a;for(let e of i){if(e===this)break;e.anchor===this.source&&(a=e)}return a}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,o=this.resolve(r,t);if(!o){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let s=n.get(o);if(s||=(a.toJS(o,null,t),n.get(o)),s?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=getAliasCount(r,o,n)),s.count*s.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return s.res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function getAliasCount(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=getAliasCount(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=getAliasCount(e,t.key,n),i=getAliasCount(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=Alias})),Q=__commonJSMin((e=>{var t=Z(),n=Do(),r=Eo();let isScalarValue=e=>!e||typeof e!=`function`&&typeof e!=`object`;var Scalar=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};Scalar.BLOCK_FOLDED=`BLOCK_FOLDED`,Scalar.BLOCK_LITERAL=`BLOCK_LITERAL`,Scalar.PLAIN=`PLAIN`,Scalar.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Scalar.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=Scalar,e.isScalarValue=isScalarValue})),ko=__commonJSMin((e=>{var t=Oo(),n=Z(),r=Q();function findTagObject(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function createNode(e,i,a){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=a.schema[n.MAP].createNode?.(a.schema,null,a);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:o,onAnchor:s,onTagObj:c,schema:l,sourceObjects:u}=a,d;if(o&&e&&typeof e==`object`){if(d=u.get(e),d)return d.anchor??(d.anchor=s(e)),new t.Alias(d.anchor);d={anchor:null,node:null},u.set(e,d)}i?.startsWith(`!!`)&&(i=`tag:yaml.org,2002:`+i.slice(2));let p=findTagObject(e,i,l.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return d&&(d.node=t),t}p=e instanceof Map?l[n.MAP]:Symbol.iterator in Object(e)?l[n.SEQ]:l[n.MAP]}c&&(c(p),delete a.onTagObj);let m=p?.createNode?p.createNode(a.schema,e,a):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(a.schema,e,a):new r.Scalar(e);return i?m.tag=i:p.default||(m.tag=p.tag),d&&(d.node=m),m}e.createNode=createNode})),Ao=__commonJSMin((e=>{var t=ko(),n=Z(),r=Do();function collectionFromPath(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let isEmptyPath=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(isEmptyPath(e))this.add(t);else{let[r,...i]=e,a=this.get(r,!0);if(n.isCollection(a))a.addIn(i,t);else if(a===void 0&&this.schema)this.set(r,collectionFromPath(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...i]=e;if(i.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(i,t);else if(e===void 0&&this.schema)this.set(r,collectionFromPath(this.schema,i,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};e.Collection=Collection,e.collectionFromPath=collectionFromPath,e.isEmptyPath=isEmptyPath})),jo=__commonJSMin((e=>{let stringifyComment=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function indentComment(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}let lineComment=(e,t,n)=>e.endsWith(`
|
|
330
330
|
`)?indentComment(n,t):n.includes(`
|
|
331
331
|
`)?`
|
|
332
|
-
`+indentComment(n,t):(e.endsWith(` `)?``:` `)+n;e.indentComment=indentComment,e.lineComment=lineComment,e.stringifyComment=stringifyComment})),
|
|
332
|
+
`+indentComment(n,t):(e.endsWith(` `)?``:` `)+n;e.indentComment=indentComment,e.lineComment=lineComment,e.stringifyComment=stringifyComment})),Mo=__commonJSMin((e=>{let t=`block`,n=`quoted`;function foldFlowLines(e,r,i=`flow`,{indentAtStart:a,lineWidth:o=80,minContentWidth:s=20,onFold:c,onOverflow:l}={}){if(!o||o<0)return e;o<s&&(s=0);let u=Math.max(1+s,1+o-r.length);if(e.length<=u)return e;let d=[],p={},m=o-r.length;typeof a==`number`&&(a>o-Math.max(2,s)?d.push(0):m=o-a);let h,g,_=!1,v=-1,y=-1,b=-1;i===t&&(v=consumeMoreIndentedLines(e,v,r.length),v!==-1&&(m=v+u));for(let a;a=e[v+=1];){if(i===n&&a===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(a===`
|
|
333
333
|
`)i===t&&(v=consumeMoreIndentedLines(e,v,r.length)),m=v+r.length+u,h=void 0;else{if(a===` `&&g&&g!==` `&&g!==`
|
|
334
334
|
`&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
|
|
335
335
|
`&&t!==` `&&(h=v)}if(v>=m){if(h)d.push(h),m=h+u,h=void 0;else if(i===n){for(;g===` `||g===` `;)g=a,a=e[v+=1],_=!0;let t=v>b+1?v-2:y-1;if(p[t])return e;d.push(t),p[t]=!0,m=t+u,h=void 0}else _=!0}}g=a}if(_&&l&&l(),d.length===0)return e;c&&c();let x=e.slice(0,d[0]);for(let t=0;t<d.length;++t){let a=d[t],o=d[t+1]||e.length;a===0?x=`\n${r}${e.slice(0,o)}`:(i===n&&p[a]&&(x+=`${e[a]}\\`),x+=`\n${r}${e.slice(a+1,o)}`)}return x}function consumeMoreIndentedLines(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
336
|
-
`);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=foldFlowLines})),
|
|
336
|
+
`);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=foldFlowLines})),No=__commonJSMin((e=>{var t=Q(),n=Mo();let getFoldOptions=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),containsDocumentMarker=e=>/^(%|---|\.\.\.)/m.test(e);function lineLengthOverLimit(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
337
337
|
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function doubleQuotedString(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=t,a=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(containsDocumentMarker(e)?` `:``),s=``,c=0;for(let e=0,t=r[e];t;t=r[++e])if(t===` `&&r[e+1]===`\\`&&r[e+2]===`n`&&(s+=r.slice(c,e)+`\\ `,e+=1,c=e,t=`\\`),t===`\\`)switch(r[e+1]){case`u`:{s+=r.slice(c,e);let t=r.substr(e+2,4);switch(t){case`0000`:s+=`\\0`;break;case`0007`:s+=`\\a`;break;case`000b`:s+=`\\v`;break;case`001b`:s+=`\\e`;break;case`0085`:s+=`\\N`;break;case`00a0`:s+=`\\_`;break;case`2028`:s+=`\\L`;break;case`2029`:s+=`\\P`;break;default:t.substr(0,2)===`00`?s+=`\\x`+t.substr(2):s+=r.substr(e,6)}e+=5,c=e+1}break;case`n`:if(i||r[e+2]===`"`||r.length<a)e+=1;else{for(s+=r.slice(c,e)+`
|
|
338
338
|
|
|
339
339
|
`;r[e+2]===`\\`&&r[e+3]===`n`&&r[e+4]!==`"`;)s+=`
|
|
@@ -351,29 +351,29 @@ let lo=/^[a-z0-9-_]+$/i;function extendedTypeOf(e){let t=typeof e;if(t===`object
|
|
|
351
351
|
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${p}`),r=!1,s=getFoldOptions(o,!0);l!==`folded`&&i!==t.Scalar.BLOCK_FOLDED&&(s.onOverflow=()=>{r=!0});let c=n.foldFlowLines(`${S}${e}${_}`,p,n.FOLD_BLOCK,s);if(!r)return`>${C}\n${p}${c}`}return a=a.replace(/\n+/g,`$&${p}`),`|${C}\n${p}${S}${a}${_}`}function plainString(e,r,i,a){let{type:o,value:s}=e,{actualString:c,implicitKey:l,indent:u,indentStep:d,inFlow:p}=r;if(l&&s.includes(`
|
|
352
352
|
`)||p&&/[[\]{},]/.test(s))return quotedString(s,r);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return l||p||!s.includes(`
|
|
353
353
|
`)?quotedString(s,r):blockString(e,r,i,a);if(!l&&!p&&o!==t.Scalar.PLAIN&&s.includes(`
|
|
354
|
-
`))return blockString(e,r,i,a);if(containsDocumentMarker(s)){if(u===``)return r.forceBlockIndent=!0,blockString(e,r,i,a);if(l&&u===d)return quotedString(s,r)}let m=s.replace(/\n+/g,`$&\n${u}`);if(c){let test=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(m),{compat:e,tags:t}=r.doc.schema;if(t.some(test)||e?.some(test))return quotedString(s,r)}return l?m:n.foldFlowLines(m,u,n.FOLD_FLOW,getFoldOptions(r,!1))}function stringifyString(e,n,r,i){let{implicitKey:a,inFlow:o}=n,s=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:c}=e;c!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(c=t.Scalar.QUOTE_DOUBLE);let _stringify=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||o?quotedString(s.value,n):blockString(s,n,r,i);case t.Scalar.QUOTE_DOUBLE:return doubleQuotedString(s.value,n);case t.Scalar.QUOTE_SINGLE:return singleQuotedString(s.value,n);case t.Scalar.PLAIN:return plainString(s,n,r,i);default:return null}},l=_stringify(c);if(l===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(l=_stringify(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}e.stringifyString=stringifyString})),
|
|
354
|
+
`))return blockString(e,r,i,a);if(containsDocumentMarker(s)){if(u===``)return r.forceBlockIndent=!0,blockString(e,r,i,a);if(l&&u===d)return quotedString(s,r)}let m=s.replace(/\n+/g,`$&\n${u}`);if(c){let test=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(m),{compat:e,tags:t}=r.doc.schema;if(t.some(test)||e?.some(test))return quotedString(s,r)}return l?m:n.foldFlowLines(m,u,n.FOLD_FLOW,getFoldOptions(r,!1))}function stringifyString(e,n,r,i){let{implicitKey:a,inFlow:o}=n,s=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:c}=e;c!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(c=t.Scalar.QUOTE_DOUBLE);let _stringify=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||o?quotedString(s.value,n):blockString(s,n,r,i);case t.Scalar.QUOTE_DOUBLE:return doubleQuotedString(s.value,n);case t.Scalar.QUOTE_SINGLE:return singleQuotedString(s.value,n);case t.Scalar.PLAIN:return plainString(s,n,r,i);default:return null}},l=_stringify(c);if(l===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(l=_stringify(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}e.stringifyString=stringifyString})),Po=__commonJSMin((e=>{var t=wo(),n=Z(),r=jo(),i=No();function createStringifyContext(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function getTagObject(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function stringifyProps(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function stringify(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let o,s=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>o=e});o??=getTagObject(t.doc.schema.tags,s);let c=stringifyProps(s,o,t);c.length>0&&(t.indentAtStart=(t.indentAtStart??0)+c.length+1);let l=typeof o.stringify==`function`?o.stringify(s,t,r,a):n.isScalar(s)?i.stringifyString(s,t,r,a):s.toString(t,r,a);return c?n.isScalar(s)||l[0]===`{`||l[0]===`[`?`${c} ${l}`:`${c}\n${t.indent}${l}`:l}e.createStringifyContext=createStringifyContext,e.stringify=stringify})),Fo=__commonJSMin((e=>{var t=Z(),n=Q(),r=Po(),i=jo();function stringifyPair({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:p,options:{commentString:m,indentSeq:h,simpleKeys:g}}=o,_=t.isNode(e)&&e.comment||null;if(g){if(_)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let v=!g&&(!e||_&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!v&&(g||!l),indent:d+p});let y=!1,b=!1,x=r.stringify(e,o,()=>y=!0,()=>b=!0);if(!v&&!o.inFlow&&x.length>1024){if(g)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);v=!0}if(o.inFlow){if(l||a==null)return y&&s&&s(),x===``?`?`:v?`? ${x}`:x}else if(l&&!g||a==null&&v)return x=`? ${x}`,_&&!y?x+=i.lineComment(x,o.indent,m(_)):b&&c&&c(),x;y&&(_=null),v?(_&&(x+=i.lineComment(x,o.indent,m(_))),x=`? ${x}\n${d}:`):(x=`${x}:`,_&&(x+=i.lineComment(x,o.indent,m(_))));let S,C,w;t.isNode(a)?(S=!!a.spaceBefore,C=a.commentBefore,w=a.comment):(S=!1,C=null,w=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!v&&!_&&t.isScalar(a)&&(o.indentAtStart=x.length+1),b=!1,!h&&p.length>=2&&!o.inFlow&&!v&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let ee=!1,T=r.stringify(a,o,()=>ee=!0,()=>b=!0),E=` `;if(_||S||C){if(E=S?`
|
|
355
355
|
`:``,C){let e=m(C);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
|
|
356
356
|
`&&w&&(E=`
|
|
357
357
|
|
|
358
358
|
`):E+=`\n${o.indent}`}else if(!v&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
|
|
359
359
|
`),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(E=`\n${o.indent}`)}}else(T===``||T[0]===`
|
|
360
|
-
`)&&(E=``);return x+=E+T,o.inFlow?ee&&s&&s():w&&!ee?x+=i.lineComment(x,o.indent,m(w)):b&&c&&c(),x}e.stringifyPair=stringifyPair})),
|
|
360
|
+
`)&&(E=``);return x+=E+T,o.inFlow?ee&&s&&s():w&&!ee?x+=i.lineComment(x,o.indent,m(w)):b&&c&&c(),x}e.stringifyPair=stringifyPair})),Io=__commonJSMin((e=>{var t=D(`process`);function debug(e,...t){e===`debug`&&console.log(...t)}function warn(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=debug,e.warn=warn})),Lo=__commonJSMin((e=>{var t=Z(),n=Q();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:addMergeToJSMap}),stringify:()=>`<<`},isMergeKey=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function addMergeToJSMap(e,n,r){let i=resolveAliasValue(e,r);if(t.isSeq(i))for(let t of i.items)mergeValue(e,n,t);else if(Array.isArray(i))for(let t of i)mergeValue(e,n,t);else mergeValue(e,n,i)}function mergeValue(e,n,r){let i=resolveAliasValue(e,r);if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}function resolveAliasValue(e,n){return e&&t.isAlias(n)?n.resolve(e.doc,e):n}e.addMergeToJSMap=addMergeToJSMap,e.isMergeKey=isMergeKey,e.merge=r})),Ro=__commonJSMin((e=>{var t=Io(),n=Lo(),r=Po(),i=Z(),a=Eo();function addPairToJSMap(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=stringifyKey(r,n,e),s=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:s,writable:!0,enumerable:!0,configurable:!0}):t[i]=s}}return t}function stringifyKey(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=addPairToJSMap})),zo=__commonJSMin((e=>{var t=ko(),n=Fo(),r=Ro(),i=Z();function createPair(e,n,r){return new a(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var a=class Pair{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return i.isNode(t)&&(t=t.clone(e)),i.isNode(n)&&(n=n.clone(e)),new Pair(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=a,e.createPair=createPair})),Bo=__commonJSMin((e=>{var t=Z(),n=Po(),r=jo();function stringifyCollection(e,t,n){return(t.inFlow??e.flow?stringifyFlowCollection:stringifyBlockCollection)(e,t,n)}function stringifyBlockCollection({comment:e,items:i},a,{blockItemPrefix:o,flowChars:s,itemIndent:c,onChompKeep:l,onComment:u}){let{indent:d,options:{commentString:p}}=a,m=Object.assign({},a,{indent:c,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let s=i[e],l=null;if(t.isNode(s))!h&&s.spaceBefore&&g.push(``),addCommentBefore(a,g,s.commentBefore,h),s.comment&&(l=s.comment);else if(t.isPair(s)){let e=t.isNode(s.key)?s.key:null;e&&(!h&&e.spaceBefore&&g.push(``),addCommentBefore(a,g,e.commentBefore,h))}h=!1;let u=n.stringify(s,m,()=>l=null,()=>h=!0);l&&(u+=r.lineComment(u,c,p(l))),h&&l&&(h=!1),g.push(o+u)}let _;if(g.length===0)_=s.start+s.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${d}${t}`:`
|
|
361
361
|
`}}return e?(_+=`
|
|
362
362
|
`+r.indentComment(p(e),d),u&&u()):h&&l&&l(),_}function stringifyFlowCollection({items:e},i,{flowChars:a,itemIndent:o}){let{indent:s,indentStep:c,flowCollectionPadding:l,options:{commentString:u}}=i;o+=c;let d=Object.assign({},i,{indent:o,inFlow:!0,type:null}),p=!1,m=0,h=[];for(let a=0;a<e.length;++a){let s=e[a],c=null;if(t.isNode(s))s.spaceBefore&&h.push(``),addCommentBefore(i,h,s.commentBefore,!1),s.comment&&(c=s.comment);else if(t.isPair(s)){let e=t.isNode(s.key)?s.key:null;e&&(e.spaceBefore&&h.push(``),addCommentBefore(i,h,e.commentBefore,!1),e.comment&&(p=!0));let n=t.isNode(s.value)?s.value:null;n?(n.comment&&(c=n.comment),n.commentBefore&&(p=!0)):s.value==null&&e?.comment&&(c=e.comment)}c&&(p=!0);let l=n.stringify(s,d,()=>c=null);p||=h.length>m||l.includes(`
|
|
363
363
|
`),a<e.length-1?l+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(p||=h.reduce((e,t)=>e+t.length+2,2)+(l.length+2)>i.options.lineWidth),p&&(l+=`,`)),c&&(l+=r.lineComment(l,o,u(c))),h.push(l),m=h.length}let{start:g,end:_}=a;if(h.length===0)return g+_;if(!p){let e=h.reduce((e,t)=>e+t.length+2,2);p=i.options.lineWidth>0&&e>i.options.lineWidth}if(p){let e=g;for(let t of h)e+=t?`\n${c}${s}${t}`:`
|
|
364
|
-
`;return`${e}\n${s}${_}`}return`${g}${l}${h.join(` `)}${l}${_}`}function addCommentBefore({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=stringifyCollection})),
|
|
365
|
-
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),Xo=__commonJSMin((e=>{var t=Z(),n=Fo(),r=Q(),i=zo();function resolvePairs(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function createPairs(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let a={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:resolvePairs,createNode:createPairs};e.createPairs=createPairs,e.pairs=a,e.resolvePairs=resolvePairs})),Zo=__commonJSMin((e=>{var t=Z(),n=So(),r=Lo(),i=zo(),a=Xo(),o=class YAMLOMap extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=YAMLOMap.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),Qo=__commonJSMin((e=>{var t=Q();function boolStringify({value:e,source:t},i){return t&&(e?n:r).test.test(t)?t:e?i.options.trueStr:i.options.falseStr}let n={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:boolStringify},r={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:boolStringify};e.falseTag=r,e.trueTag=n})),$o=__commonJSMin((e=>{var t=Q(),n=Wo();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),es=__commonJSMin((e=>{var t=Wo();let intIdentify=e=>typeof e==`bigint`||Number.isInteger(e);function intResolve(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function intStringify(e,n,r){let{value:i}=e;if(intIdentify(i)){let e=i.toString(n);return i<0?`-`+r+e.substr(1):r+e}return t.stringifyNumber(e)}let n={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>intResolve(e,2,2,n),stringify:e=>intStringify(e,2,`0b`)},r={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>intResolve(e,1,8,n),stringify:e=>intStringify(e,8,`0`)},i={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>intResolve(e,0,10,n),stringify:t.stringifyNumber},a={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>intResolve(e,2,16,n),stringify:e=>intStringify(e,16,`0x`)};e.int=i,e.intBin=n,e.intHex=a,e.intOct=r})),ts=__commonJSMin((e=>{var t=Z(),n=Fo(),r=Lo(),i=class YAMLSet extends r.YAMLMap{constructor(e){super(e),this.tag=YAMLSet.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),ns=__commonJSMin((e=>{var t=Wo();function parseSexagesimal(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,num=e=>t?BigInt(e):Number(e),i=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*num(60)+num(t),num(0));return n===`-`?num(-1)*i:i}function stringifySexagesimal(e){let{value:n}=e,num=e=>e;if(typeof n==`bigint`)num=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let r=``;n<0&&(r=`-`,n*=num(-1));let i=num(60),a=[n%i];return n<60?a.unshift(0):(n=(n-a[0])/i,a.unshift(n%i),n>=60&&(n=(n-a[0])/i,a.unshift(n))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let n={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>parseSexagesimal(e,n),stringify:stringifySexagesimal},r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>parseSexagesimal(e,!1),stringify:stringifySexagesimal},i={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(i.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,a,o,s,c]=t.map(Number),l=t[7]?Number((t[7]+`00`).substr(1,3)):0,u=Date.UTC(n,r-1,a,o||0,s||0,c||0,l),d=t[8];if(d&&d!==`Z`){let e=parseSexagesimal(d,!1);Math.abs(e)<30&&(e*=60),u-=6e4*e}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=r,e.intTime=n,e.timestamp=i})),rs=__commonJSMin((e=>{var t=Ro(),n=Ho(),r=Bo(),i=Vo(),a=Yo(),o=Qo(),s=$o(),c=es(),l=No(),u=Zo(),d=Xo(),p=ts(),m=ns();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,p.set,m.intTime,m.floatTime,m.timestamp]})),is=__commonJSMin((e=>{var t=Ro(),n=Ho(),r=Bo(),i=Vo(),a=Uo(),o=Go(),s=Ko(),c=qo(),l=Jo(),u=Yo(),d=No(),p=Zo(),m=Xo(),h=rs(),g=ts(),_=ns();let v=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,h.schema],[`yaml-1.1`,h.schema]]),y={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:_.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:_.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:p.omap,pairs:m.pairs,seq:r.seq,set:g.set,timestamp:_.timestamp},b={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":p.omap,"tag:yaml.org,2002:pairs":m.pairs,"tag:yaml.org,2002:set":g.set,"tag:yaml.org,2002:timestamp":_.timestamp};function getTags(e,t,n){let r=v.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(v.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?y[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(y).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=b,e.getTags=getTags})),as=__commonJSMin((e=>{var t=Z(),n=Ro(),r=Bo(),i=Vo(),a=is();let sortMapEntriesByKey=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class Schema{constructor({compat:e,customTags:o,merge:s,resolveKnownTags:c,schema:l,sortMapEntries:u,toStringDefaults:d}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof l==`string`&&l||`core`,this.knownTags=c?a.coreKnownTags:{},this.tags=a.getTags(o,this.name,s),this.toStringOptions=d??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof u==`function`?u:u===!0?sortMapEntriesByKey:null}clone(){let e=Object.create(Schema.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}})),os=__commonJSMin((e=>{var t=Z(),n=Ao(),r=Do();function stringifyDocument(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
|
|
364
|
+
`;return`${e}\n${s}${_}`}return`${g}${l}${h.join(` `)}${l}${_}`}function addCommentBefore({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=stringifyCollection})),Vo=__commonJSMin((e=>{var t=Bo(),n=Ro(),r=Ao(),i=Z(),a=zo(),o=Q();function findPair(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}var YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),add=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)add(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))add(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=findPair(this.items,n.key),s=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(s){let e=this.items.findIndex(e=>s(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=findPair(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=findPair(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!findPair(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}};e.YAMLMap=YAMLMap,e.findPair=findPair})),Ho=__commonJSMin((e=>{var t=Z(),n=Vo();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),Uo=__commonJSMin((e=>{var t=ko(),n=Bo(),r=Ao(),i=Z(),a=Q(),o=Eo(),YAMLSeq=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=asItemIndex(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=asItemIndex(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=asItemIndex(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=asItemIndex(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function asItemIndex(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=YAMLSeq})),Wo=__commonJSMin((e=>{var t=Z(),n=Uo();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),Go=__commonJSMin((e=>{var t=No();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),Ko=__commonJSMin((e=>{var t=Q();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),qo=__commonJSMin((e=>{var t=Q();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),Jo=__commonJSMin((e=>{function stringifyNumber({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}e.stringifyNumber=stringifyNumber})),Yo=__commonJSMin((e=>{var t=Q(),n=Jo();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Xo=__commonJSMin((e=>{var t=Jo();let intIdentify=e=>typeof e==`bigint`||Number.isInteger(e),intResolve=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function intStringify(e,n,r){let{value:i}=e;return intIdentify(i)&&i>=0?r+i.toString(n):t.stringifyNumber(e)}e.int={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>intResolve(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>intIdentify(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>intResolve(e,2,16,n),stringify:e=>intStringify(e,16,`0x`)},e.intOct={identify:e=>intIdentify(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>intResolve(e,2,8,n),stringify:e=>intStringify(e,8,`0o`)}})),Zo=__commonJSMin((e=>{var t=Ho(),n=Ko(),r=Wo(),i=Go(),a=qo(),o=Yo(),s=Xo();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),Qo=__commonJSMin((e=>{var t=Q(),n=Ho(),r=Wo();function intIdentify(e){return typeof e==`bigint`||Number.isInteger(e)}let stringifyJSON=({value:e})=>JSON.stringify(e),i=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:stringifyJSON},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:stringifyJSON},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:stringifyJSON},{identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>intIdentify(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:stringifyJSON}];e.schema=[n.map,r.seq].concat(i,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),$o=__commonJSMin((e=>{var t=D(`buffer`),n=Q(),r=No();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
|
|
365
|
+
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),es=__commonJSMin((e=>{var t=Z(),n=zo(),r=Q(),i=Uo();function resolvePairs(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function createPairs(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let a={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:resolvePairs,createNode:createPairs};e.createPairs=createPairs,e.pairs=a,e.resolvePairs=resolvePairs})),ts=__commonJSMin((e=>{var t=Z(),n=Eo(),r=Vo(),i=Uo(),a=es(),o=class YAMLOMap extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=YAMLOMap.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),ns=__commonJSMin((e=>{var t=Q();function boolStringify({value:e,source:t},i){return t&&(e?n:r).test.test(t)?t:e?i.options.trueStr:i.options.falseStr}let n={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:boolStringify},r={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:boolStringify};e.falseTag=r,e.trueTag=n})),rs=__commonJSMin((e=>{var t=Q(),n=Jo();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),is=__commonJSMin((e=>{var t=Jo();let intIdentify=e=>typeof e==`bigint`||Number.isInteger(e);function intResolve(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function intStringify(e,n,r){let{value:i}=e;if(intIdentify(i)){let e=i.toString(n);return i<0?`-`+r+e.substr(1):r+e}return t.stringifyNumber(e)}let n={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>intResolve(e,2,2,n),stringify:e=>intStringify(e,2,`0b`)},r={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>intResolve(e,1,8,n),stringify:e=>intStringify(e,8,`0`)},i={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>intResolve(e,0,10,n),stringify:t.stringifyNumber},a={identify:intIdentify,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>intResolve(e,2,16,n),stringify:e=>intStringify(e,16,`0x`)};e.int=i,e.intBin=n,e.intHex=a,e.intOct=r})),as=__commonJSMin((e=>{var t=Z(),n=zo(),r=Vo(),i=class YAMLSet extends r.YAMLMap{constructor(e){super(e),this.tag=YAMLSet.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),os=__commonJSMin((e=>{var t=Jo();function parseSexagesimal(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,num=e=>t?BigInt(e):Number(e),i=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*num(60)+num(t),num(0));return n===`-`?num(-1)*i:i}function stringifySexagesimal(e){let{value:n}=e,num=e=>e;if(typeof n==`bigint`)num=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let r=``;n<0&&(r=`-`,n*=num(-1));let i=num(60),a=[n%i];return n<60?a.unshift(0):(n=(n-a[0])/i,a.unshift(n%i),n>=60&&(n=(n-a[0])/i,a.unshift(n))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let n={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>parseSexagesimal(e,n),stringify:stringifySexagesimal},r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>parseSexagesimal(e,!1),stringify:stringifySexagesimal},i={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(i.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,a,o,s,c]=t.map(Number),l=t[7]?Number((t[7]+`00`).substr(1,3)):0,u=Date.UTC(n,r-1,a,o||0,s||0,c||0,l),d=t[8];if(d&&d!==`Z`){let e=parseSexagesimal(d,!1);Math.abs(e)<30&&(e*=60),u-=6e4*e}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=r,e.intTime=n,e.timestamp=i})),ss=__commonJSMin((e=>{var t=Ho(),n=Ko(),r=Wo(),i=Go(),a=$o(),o=ns(),s=rs(),c=is(),l=Lo(),u=ts(),d=es(),p=as(),m=os();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,p.set,m.intTime,m.floatTime,m.timestamp]})),cs=__commonJSMin((e=>{var t=Ho(),n=Ko(),r=Wo(),i=Go(),a=qo(),o=Yo(),s=Xo(),c=Zo(),l=Qo(),u=$o(),d=Lo(),p=ts(),m=es(),h=ss(),g=as(),_=os();let v=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,h.schema],[`yaml-1.1`,h.schema]]),y={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:_.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:_.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:p.omap,pairs:m.pairs,seq:r.seq,set:g.set,timestamp:_.timestamp},b={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":p.omap,"tag:yaml.org,2002:pairs":m.pairs,"tag:yaml.org,2002:set":g.set,"tag:yaml.org,2002:timestamp":_.timestamp};function getTags(e,t,n){let r=v.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(v.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?y[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(y).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=b,e.getTags=getTags})),ls=__commonJSMin((e=>{var t=Z(),n=Ho(),r=Wo(),i=Go(),a=cs();let sortMapEntriesByKey=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class Schema{constructor({compat:e,customTags:o,merge:s,resolveKnownTags:c,schema:l,sortMapEntries:u,toStringDefaults:d}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof l==`string`&&l||`core`,this.knownTags=c?a.coreKnownTags:{},this.tags=a.getTags(o,this.name,s),this.toStringOptions=d??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof u==`function`?u:u===!0?sortMapEntriesByKey:null}clone(){let e=Object.create(Schema.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}})),us=__commonJSMin((e=>{var t=Z(),n=Po(),r=jo();function stringifyDocument(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
|
|
366
366
|
`)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`)}else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
|
|
367
367
|
`)+`
|
|
368
|
-
`}e.stringifyDocument=stringifyDocument})),
|
|
369
|
-
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};e.YAMLError=YAMLError,e.YAMLParseError=YAMLParseError,e.YAMLWarning=YAMLWarning,e.prettifyError=prettifyError})),
|
|
370
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(containsNewline(t.key)||containsNewline(t.value))return!0}return!1;default:return!0}}e.containsNewline=containsNewline})),
|
|
368
|
+
`}e.stringifyDocument=stringifyDocument})),ds=__commonJSMin((e=>{var t=Oo(),n=Ao(),r=Z(),i=zo(),a=Eo(),o=ls(),s=us(),c=wo(),l=To(),u=ko(),d=Co(),p=class Document{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let e=Object.create(Document.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=r.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){assertCollection(this.contents)&&this.contents.add(e)}addIn(e,t){assertCollection(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let keyToStr=e=>typeof e==`number`||e instanceof String||e instanceof Number,e=t.filter(keyToStr).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:p}=n??{},{onAnchor:m,setAnchors:h,sourceObjects:g}=c.createNodeAnchors(this,o||`a`),_={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:m,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:g},v=u.createNode(e,p,_);return s&&r.isCollection(v)&&(v.flow=!0),h(),v}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return assertCollection(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents!=null&&(this.contents=null,!0):assertCollection(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):assertCollection(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):assertCollection(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function assertCollection(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=p})),fs=__commonJSMin((e=>{var YAMLError=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},YAMLParseError=class extends YAMLError{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},YAMLWarning=class extends YAMLError{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};let prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
|
|
369
|
+
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};e.YAMLError=YAMLError,e.YAMLParseError=YAMLParseError,e.YAMLWarning=YAMLWarning,e.prettifyError=prettifyError})),ps=__commonJSMin((e=>{function resolveProps(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,p=``,m=!1,h=!1,g=null,_=null,v=null,y=null,b=null,x=null,S=null;for(let i of e)switch(h&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),g&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(g,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(g=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=p+e:d=e,p=``,l=!1;break}case`newline`:l?d?d+=i.source:(!x||n!==`seq-item-ind`)&&(c=!0):p+=i.source,l=!0,m=!0,(_||v)&&(y=i),u=!0;break;case`anchor`:_&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),_=i,S??=i.offset,l=!1,u=!1,h=!0;break;case`tag`:v&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),v=i,S??=i.offset,l=!1,u=!1,h=!0;break;case n:(_||v)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),x&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),x=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),b=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let C=e[e.length-1],w=C?C.offset+C.source.length:i;return h&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),g&&(l&&g.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(g,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:b,found:x,spaceBefore:c,comment:d,hasNewline:m,anchor:_,tag:v,newlineAfterProp:y,end:w,start:S??w}}e.resolveProps=resolveProps})),ms=__commonJSMin((e=>{function containsNewline(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
370
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(containsNewline(t.key)||containsNewline(t.value))return!0}return!1;default:return!0}}e.containsNewline=containsNewline})),hs=__commonJSMin((e=>{var t=ms();function flowIndentCheck(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=flowIndentCheck})),gs=__commonJSMin((e=>{var t=Z();function mapIncludes(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=mapIncludes})),_s=__commonJSMin((e=>{var t=zo(),n=Vo(),r=ps(),i=ms(),a=hs(),o=gs();let s=`All mapping items must start at the same column`;function resolveBlockMap({composeNode:e,composeEmptyNode:c},l,u,d,p){let m=new((p?.nodeClass)??n.YAMLMap)(l.schema);l.atRoot&&=!1;let h=u.offset,g=null;for(let n of u.items){let{start:p,key:_,sep:v,value:y}=n,b=r.resolveProps(p,{indicator:`explicit-key-ind`,next:_??v?.[0],offset:h,onError:d,parentIndent:u.indent,startOnNewline:!0}),x=!b.found;if(x){if(_&&(_.type===`block-seq`?d(h,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in _&&_.indent!==u.indent&&d(h,`BAD_INDENT`,s)),!b.anchor&&!b.tag&&!v){g=b.end,b.comment&&(m.comment?m.comment+=`
|
|
371
371
|
`+b.comment:m.comment=b.comment);continue}(b.newlineAfterProp||i.containsNewline(_))&&d(_??p[p.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else b.found?.indent!==u.indent&&d(h,`BAD_INDENT`,s);l.atKey=!0;let S=b.end,C=_?e(l,_,b,d):c(l,S,p,null,b,d);l.schema.compat&&a.flowIndentCheck(u.indent,_,d),l.atKey=!1,o.mapIncludes(l,m.items,C)&&d(S,`DUPLICATE_KEY`,`Map keys must be unique`);let w=r.resolveProps(v??[],{indicator:`map-value-ind`,next:y,offset:C.range[2],onError:d,parentIndent:u.indent,startOnNewline:!_||_.type===`block-scalar`});if(h=w.end,w.found){x&&(y?.type===`block-map`&&!w.hasNewline&&d(h,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&b.start<w.found.offset-1024&&d(C.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=y?e(l,y,w,d):c(l,h,v,null,w,d);l.schema.compat&&a.flowIndentCheck(u.indent,y,d),h=r.range[2];let i=new t.Pair(C,r);l.options.keepSourceTokens&&(i.srcToken=n),m.items.push(i)}else{x&&d(C.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),w.comment&&(C.comment?C.comment+=`
|
|
372
|
-
`+w.comment:C.comment=w.comment);let e=new t.Pair(C);l.options.keepSourceTokens&&(e.srcToken=n),m.items.push(e)}}return g&&g<h&&d(g,`IMPOSSIBLE`,`Map comment with trailing content`),m.range=[u.offset,h,g??h],m}e.resolveBlockMap=resolveBlockMap})),
|
|
372
|
+
`+w.comment:C.comment=w.comment);let e=new t.Pair(C);l.options.keepSourceTokens&&(e.srcToken=n),m.items.push(e)}}return g&&g<h&&d(g,`IMPOSSIBLE`,`Map comment with trailing content`),m.range=[u.offset,h,g??h],m}e.resolveBlockMap=resolveBlockMap})),vs=__commonJSMin((e=>{var t=Uo(),n=ps(),r=hs();function resolveBlockSeq({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new((c?.nodeClass)??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let p=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!p.found){if(p.anchor||p.tag||c)c?.type===`block-seq`?s(p.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=p.end,p.comment&&(l.comment=p.comment);continue}}let m=c?e(a,c,p,s):i(a,p.end,t,null,p,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=m.range[2],l.items.push(m)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=resolveBlockSeq})),ys=__commonJSMin((e=>{function resolveEnd(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=resolveEnd})),bs=__commonJSMin((e=>{var t=Z(),n=zo(),r=Vo(),i=Uo(),a=ys(),o=ps(),s=ms(),c=gs();let l=`Block collections are not allowed within flow collections`,isBlock=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function resolveFlowCollection({composeNode:e,composeEmptyNode:u},d,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new((h?.nodeClass)??(g?r.YAMLMap:i.YAMLSeq))(d.schema);v.flow=!0;let y=d.atRoot;y&&(d.atRoot=!1),d.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
|
|
373
373
|
`+C.comment:v.comment=C.comment),b=C.end;continue}!g&&d.options.strict&&s.containsNewline(y)&&m(y,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)C.comma&&m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`);else if(C.comma||m(C.start,`MISSING_CHAR`,`Missing , between ${_} items`),C.comment){let e=``;loop:for(let t of h)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=v.items[v.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
|
|
374
374
|
`+e:n.comment=e,C.comment=C.comment.substring(e.length+1)}}if(!g&&!x&&!C.found){let t=S?e(d,S,C,m):u(d,C.end,x,null,C,m);v.items.push(t),b=t.range[2],isBlock(S)&&m(t.range,`BLOCK_IN_FLOW`,l)}else{d.atKey=!0;let t=C.end,i=y?e(d,y,C,m):u(d,t,h,null,C,m);isBlock(y)&&m(i.range,`BLOCK_IN_FLOW`,l),d.atKey=!1;let s=o.resolveProps(x??[],{flow:_,indicator:`map-value-ind`,next:S,offset:i.range[2],onError:m,parentIndent:p.indent,startOnNewline:!1});if(s.found){if(!g&&!C.found&&d.options.strict){if(x)for(let e of x){if(e===s.found)break;if(e.type===`newline`){m(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}C.start<s.found.offset-1024&&m(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else S&&(`source`in S&&S.source?.[0]===`:`?m(S,`MISSING_CHAR`,`Missing space after : in ${_}`):m(s.start,`MISSING_CHAR`,`Missing , or : between ${_} items`));let w=S?e(d,S,s,m):s.found?u(d,s.end,x,null,s,m):null;w?isBlock(S)&&m(w.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
|
|
375
375
|
`+s.comment:i.comment=s.comment);let ee=new n.Pair(i,w);if(d.options.keepSourceTokens&&(ee.srcToken=a),g){let e=v;c.mapIncludes(d,e.items,i)&&m(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(ee)}else{let e=new r.YAMLMap(d.schema);e.flow=!0,e.items.push(ee);let t=(w??i).range;e.range=[i.range[0],t[1],t[2]],v.items.push(e)}b=w?w.range[2]:s.end}}let x=g?`}`:`]`,[S,...C]=p.end,w=b;if(S?.source===x)w=S.offset+S.source.length;else{let e=_[0].toUpperCase()+_.substring(1),t=y?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;m(b,y?`MISSING_CHAR`:`BAD_INDENT`,t),S&&S.source.length!==1&&C.unshift(S)}if(C.length>0){let e=a.resolveEnd(C,w,d.options.strict,m);e.comment&&(v.comment?v.comment+=`
|
|
376
|
-
`+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=resolveFlowCollection})),
|
|
376
|
+
`+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=resolveFlowCollection})),xs=__commonJSMin((e=>{var t=Z(),n=Q(),r=Vo(),i=Uo(),a=_s(),o=vs(),s=bs();function resolveCollection(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function composeCollection(e,a,o,s,c){let l=s.tag,u=l?a.directives.tagName(l.source,e=>c(l,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&l?e.offset>l.offset?e:l:e??l;n&&(!t||t.offset<n.offset)&&c(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let d=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!l||!u||u===`!`||u===r.YAMLMap.tagName&&d===`map`||u===i.YAMLSeq.tagName&&d===`seq`)return resolveCollection(e,a,o,c,u);let p=a.schema.tags.find(e=>e.tag===u&&e.collection===d);if(!p){let t=a.schema.knownTags[u];if(t?.collection===d)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?c(l,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${d} collection, but expects ${t.collection??`scalar`}`,!0):c(l,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${u}`,!0),resolveCollection(e,a,o,c,u)}let m=resolveCollection(e,a,o,c,u,p),h=p.resolve?.(m,e=>c(l,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=u,p?.format&&(g.format=p.format),g}e.composeCollection=composeCollection})),Ss=__commonJSMin((e=>{var t=Q();function resolveBlockScalar(e,n,r){let i=n.offset,a=parseBlockScalarHeader(n,e.options.strict,r);if(!a)return{value:``,type:null,comment:``,range:[i,i,i]};let o=a.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,s=n.source?splitLines(n.source):[],c=s.length;for(let e=s.length-1;e>=0;--e){let t=s[e][1];if(t===``||t===`\r`)c=e;else break}if(c===0){let e=a.chomp===`+`&&s.length>0?`
|
|
377
377
|
`.repeat(Math.max(1,s.length-1)):``,t=i+a.length;return n.source&&(t+=n.source.length),{value:e,type:o,comment:a.comment,range:[i,t,t]}}let l=n.indent+a.indent,u=n.offset+a.length,d=0;for(let t=0;t<c;++t){let[n,i]=s[t];if(i===``||i===`\r`)a.indent===0&&n.length>l&&(l=n.length);else{n.length<l&&r(u+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),a.indent===0&&(l=n.length),d=t,l===0&&!e.atRoot&&r(u,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}u+=n.length+i.length+1}for(let e=s.length-1;e>=c;--e)s[e][0].length>l&&(c=e+1);let p=``,m=``,h=!1;for(let e=0;e<d;++e)p+=s[e][0].slice(l)+`
|
|
378
378
|
`;for(let e=d;e<c;++e){let[n,i]=s[e];u+=n.length+i.length+1;let c=i[i.length-1]===`\r`;if(c&&(i=i.slice(0,-1)),i&&n.length<l){let e=`Block scalar lines must not be less indented than their ${a.indent?`explicit indentation indicator`:`first line`}`;r(u-i.length-(c?2:1),`BAD_INDENT`,e),n=``}o===t.Scalar.BLOCK_LITERAL?(p+=m+n.slice(l)+i,m=`
|
|
379
379
|
`):n.length>l||i[0]===` `?(m===` `?m=`
|
|
@@ -388,7 +388,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
388
388
|
`+s[e][0].slice(l);p[p.length-1]!==`
|
|
389
389
|
`&&(p+=`
|
|
390
390
|
`);break;default:p+=`
|
|
391
|
-
`}let g=i+a.length+n.source.length;return{value:p,type:o,comment:a.comment,range:[i,g,g]}}function parseBlockScalarHeader({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function splitLines(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=resolveBlockScalar})),
|
|
391
|
+
`}let g=i+a.length+n.source.length;return{value:p,type:o,comment:a.comment,range:[i,g,g]}}function parseBlockScalarHeader({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function splitLines(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=resolveBlockScalar})),Cs=__commonJSMin((e=>{var t=Q(),n=ys();function resolveFlowScalar(e,r,i){let{offset:a,type:o,source:s,end:c}=e,l,u,_onError=(e,t,n)=>i(a+e,t,n);switch(o){case`scalar`:l=t.Scalar.PLAIN,u=plainValue(s,_onError);break;case`single-quoted-scalar`:l=t.Scalar.QUOTE_SINGLE,u=singleQuotedValue(s,_onError);break;case`double-quoted-scalar`:l=t.Scalar.QUOTE_DOUBLE,u=doubleQuotedValue(s,_onError);break;default:return i(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${o}`),{value:``,type:null,comment:``,range:[a,a+s.length,a+s.length]}}let d=a+s.length,p=n.resolveEnd(c,d,r,i);return{value:u,type:l,comment:p.comment,range:[a,d,p.offset]}}function plainValue(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),foldLines(e)}function singleQuotedValue(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),foldLines(e.slice(1,-1)).replace(/''/g,`'`)}function foldLines(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
392
392
|
`,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
393
393
|
`,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
|
|
394
394
|
`?i+=a:a=`
|
|
@@ -403,10 +403,10 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
403
403
|
`);)r===`
|
|
404
404
|
`&&(n+=`
|
|
405
405
|
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let r={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
406
|
-
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function parseCharCode(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=resolveFlowScalar})),
|
|
406
|
+
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function parseCharCode(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=resolveFlowScalar})),ws=__commonJSMin((e=>{var t=Z(),n=Q(),r=Ss(),i=Cs();function composeScalar(e,a,o,s){let{value:c,type:l,comment:u,range:d}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,s):i.resolveFlowScalar(a,e.options.strict,s),p=o?e.directives.tagName(o.source,e=>s(o,`TAG_RESOLVE_FAILED`,e)):null,m;m=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:p?findScalarTagByName(e.schema,c,p,o,s):a.type===`scalar`?findScalarTagByTest(e,c,a,s):e.schema[t.SCALAR];let h;try{let r=m.resolve(c,e=>s(o??a,`TAG_RESOLVE_FAILED`,e),e.options);h=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);s(o??a,`TAG_RESOLVE_FAILED`,t),h=new n.Scalar(c)}return h.range=d,h.source=c,l&&(h.type=l),p&&(h.tag=p),m.format&&(h.format=m.format),u&&(h.comment=u),h}function findScalarTagByName(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r){if(t.default&&t.test)o.push(t);else return t}for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function findScalarTagByTest({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=composeScalar})),Ts=__commonJSMin((e=>{function emptyScalarPosition(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=emptyScalarPosition})),Es=__commonJSMin((e=>{var t=Oo(),n=Z(),r=xs(),i=ws(),a=ys(),o=Ts();let s={composeNode,composeEmptyNode};function composeNode(e,t,a,o){let c=e.atKey,{spaceBefore:l,comment:u,anchor:d,tag:p}=a,m,h=!0;switch(t.type){case`alias`:m=composeAlias(e,t,o),(d||p)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:m=i.composeScalar(e,t,p,o),d&&(m.anchor=d.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{m=r.composeCollection(s,e,t,a,o),d&&(m.anchor=d.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),h=!1}return m??=composeEmptyNode(e,t.offset,void 0,null,a,o),d&&m.anchor===``&&o(d,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(m)||typeof m.value!=`string`||m.tag&&m.tag!==`tag:yaml.org,2002:str`)&&o(p??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),l&&(m.spaceBefore=!0),u&&(t.type===`scalar`&&t.source===``?m.comment=u:m.commentBefore=u),e.options.keepSourceTokens&&h&&(m.srcToken=t),m}function composeEmptyNode(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let p={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},m=i.composeScalar(e,p,l,d);return c&&(m.anchor=c.source.substring(1),m.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(m.spaceBefore=!0),s&&(m.comment=s,m.range[2]=u),m}function composeAlias({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=composeEmptyNode,e.composeNode=composeNode})),Ds=__commonJSMin((e=>{var t=ds(),n=Es(),r=ys(),i=ps();function composeDoc(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),p=new t.Document(void 0,d),m={atKey:!1,atRoot:!0,directives:p.directives,options:p.options,schema:p.schema},h=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});h.found&&(p.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!h.hasNewline&&u(h.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),p.contents=c?n.composeNode(m,c,h,u):n.composeEmptyNode(m,h.end,s,null,h,u);let g=p.contents.range[2],_=r.resolveEnd(l,g,!1,u);return _.comment&&(p.comment=_.comment),p.range=[o,g,_.offset],p}e.composeDoc=composeDoc})),Os=__commonJSMin((e=>{var t=D(`process`),n=Co(),r=ds(),i=fs(),a=Z(),o=Ds(),s=ys();function getErrorPos(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function parsePrelude(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
407
407
|
|
|
408
408
|
`:`
|
|
409
|
-
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=getErrorPos(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=parsePrelude(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:parsePrelude(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=getErrorPos(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}};e.Composer=Composer})),
|
|
409
|
+
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=getErrorPos(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=parsePrelude(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:parsePrelude(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=getErrorPos(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(getErrorPos(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}};e.Composer=Composer})),ks=__commonJSMin((e=>{var t=Ss(),n=Cs(),r=fs(),i=No();function resolveAsScalar(e,i=!0,a){if(e){let _onError=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,_onError);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,_onError)}}return null}function createScalarToken(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:`newline`,offset:-1,indent:r,source:`
|
|
410
410
|
`}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
|
|
411
411
|
`),t=c.substring(0,e),n=c.substring(e+1)+`
|
|
412
412
|
`,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return addEndtoBlockProps(i,l)||i.push({type:`newline`,offset:-1,indent:r,source:`
|
|
@@ -414,9 +414,9 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
414
414
|
`),r=t.substring(0,n),i=t.substring(n+1)+`
|
|
415
415
|
`;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];addEndtoBlockProps(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
|
|
416
416
|
`});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function addEndtoBlockProps(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function setFlowScalarValue(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
|
|
417
|
-
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=createScalarToken,e.resolveAsScalar=resolveAsScalar,e.setScalarValue=setScalarValue})),
|
|
417
|
+
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=createScalarToken,e.resolveAsScalar=resolveAsScalar,e.setScalarValue=setScalarValue})),As=__commonJSMin((e=>{let stringify=e=>`type`in e?stringifyToken(e):stringifyItem(e);function stringifyToken(e){switch(e.type){case`block-scalar`:{let t=``;for(let n of e.props)t+=stringifyToken(n);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=stringifyItem(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=stringifyItem(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=stringifyItem(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function stringifyItem({start:e,key:t,sep:n,value:r}){let i=``;for(let t of e)i+=t.source;if(t&&(i+=stringifyToken(t)),n)for(let e of n)i+=e.source;return r&&(i+=stringifyToken(r)),i}e.stringify=stringify})),js=__commonJSMin((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function visit(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),_visit(Object.freeze([]),e,t)}visit.BREAK=t,visit.SKIP=n,visit.REMOVE=r,visit.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},visit.parentCollection=(e,t)=>{let n=visit.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function _visit(e,n,i){let a=i(n,e);if(typeof a==`symbol`)return a;for(let o of[`key`,`value`]){let s=n[o];if(s&&`items`in s){for(let n=0;n<s.items.length;++n){let a=_visit(Object.freeze(e.concat([[o,n]])),s.items[n],i);if(typeof a==`number`)n=a-1;else if(a===t)return t;else a===r&&(s.items.splice(n,1),--n)}typeof a==`function`&&o===`key`&&(a=a(n,e))}}return typeof a==`function`?a(n,e):a}e.visit=visit})),Ms=__commonJSMin((e=>{var t=ks(),n=As(),r=js();let isCollection=e=>!!e&&`items`in e,isScalar=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);function prettyToken(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function tokenType(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
418
418
|
`:case`\r
|
|
419
|
-
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=isCollection,e.isScalar=isScalar,e.prettyToken=prettyToken,e.tokenType=tokenType})),
|
|
419
|
+
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=isCollection,e.isScalar=isScalar,e.prettyToken=prettyToken,e.tokenType=tokenType})),Ns=__commonJSMin((e=>{var t=Ms();function isEmpty(e){switch(e){case void 0:case` `:case`
|
|
420
420
|
`:case`\r`:case` `:return!0;default:return!1}}let n=new Set(`0123456789ABCDEFabcdef`),r=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),i=new Set(`,[]{}`),a=new Set(` ,[]{}
|
|
421
421
|
\r `),isNotAnchorChar=e=>!e||a.has(e);var Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
|
|
422
422
|
`||t===`\r`&&this.buffer[e+1]===`
|
|
@@ -435,34 +435,35 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
435
435
|
`,t=this.buffer[r+1]):n=r),t===`#`||e&&i.has(t))break;if(a===`
|
|
436
436
|
`){let e=this.continueScalar(r+1);if(e===-1)break;r=Math.max(r,e-2)}}else{if(e&&i.has(a))break;n=r}return!a&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(n+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(isNotAnchorChar),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(isEmpty(n)||t&&i.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!isEmpty(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(r.has(t))t=this.buffer[++e];else if(t===`%`&&n.has(this.buffer[e+1])&&n.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
437
437
|
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
438
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};e.Lexer=Lexer})),
|
|
438
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};e.Lexer=Lexer})),Ps=__commonJSMin((e=>{var LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};e.LineCounter=LineCounter})),Fs=__commonJSMin((e=>{var t=D(`process`),n=Ms(),r=Ns();function includesToken(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function findNonEmptyIndex(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function isFlowToken(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function getPrevProps(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function getFirstKeyStartProps(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function arrayPushArray(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function fixFlowSeqItems(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!includesToken(t.start,`explicit-key-ind`)&&!includesToken(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,isFlowToken(t.value)?t.value.end?arrayPushArray(t.value.end,t.sep):t.value.end=t.sep:arrayPushArray(t.start,t.sep),delete t.sep)}var Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&fixFlowSeqItems(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&findNonEmptyIndex(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:findNonEmptyIndex(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=getFirstKeyStartProps(getPrevProps(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
|
|
439
439
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
440
440
|
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){arrayPushArray(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(includesToken(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=getFirstKeyStartProps(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(includesToken(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(isFlowToken(t.key)&&!includesToken(t.sep,`newline`)){let e=getFirstKeyStartProps(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):includesToken(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!includesToken(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){arrayPushArray(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||includesToken(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=getFirstKeyStartProps(getPrevProps(t));fixFlowSeqItems(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
441
441
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
442
|
-
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=getFirstKeyStartProps(getPrevProps(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=getFirstKeyStartProps(getPrevProps(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};e.Parser=Parser})),
|
|
443
|
-
`).filter(e=>t(e)||!
|
|
442
|
+
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=getFirstKeyStartProps(getPrevProps(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=getFirstKeyStartProps(getPrevProps(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};e.Parser=Parser})),Is=__commonJSMin((e=>{var t=Os(),n=ds(),r=fs(),i=Io(),a=Z(),o=Ps(),s=Fs();function parseOptions(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function parseAllDocuments(e,n={}){let{lineCounter:i,prettyErrors:a}=parseOptions(n),o=new s.Parser(i?.addNewLine),c=new t.Composer(n),l=Array.from(c.compose(o.parse(e)));if(a&&i)for(let t of l)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return l.length>0?l:Object.assign([],{empty:!0},c.streamInfo())}function parseDocument(e,n={}){let{lineCounter:i,prettyErrors:a}=parseOptions(n),o=new s.Parser(i?.addNewLine),c=new t.Composer(n),l=null;for(let t of c.compose(o.parse(e),!0,e.length))if(!l)l=t;else if(l.options.logLevel!==`silent`){l.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(l.errors.forEach(r.prettifyError(e,i)),l.warnings.forEach(r.prettifyError(e,i))),l}function parse(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=parseDocument(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function stringify(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=parse,e.parseAllDocuments=parseAllDocuments,e.parseDocument=parseDocument,e.stringify=stringify})),Ls=__commonJSMin((e=>{var t=Os(),n=ds(),r=ls(),i=fs(),a=Oo(),o=Z(),s=zo(),c=Q(),l=Vo(),u=Uo();Ms();var d=Ns(),p=Ps(),m=Fs(),h=Is(),g=So();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=p.LineCounter,e.Parser=m.Parser,e.parse=h.parse,e.parseAllDocuments=h.parseAllDocuments,e.parseDocument=h.parseDocument,e.stringify=h.stringify,e.visit=g.visit,e.visitAsync=g.visitAsync}))();const Rs=[`first-wins`,`combine`,`merge-sections`],zs=/^---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/;function parseDocument(e,t){let n=zs.exec(e);if(!n)return{metadata:{},body:e};let r=e.slice(n[0].length);try{let e=(0,Ls.parse)(n[1]);if(e==null)return{metadata:{},body:r};if(isRecord$1(e))return{metadata:e,body:r}}catch{}return t(`frontmatter is not a YAML mapping; it is ignored`),{metadata:{},body:r}}function readMergeMode(e,t){let n=e.merge;return n===void 0?`first-wins`:Rs.includes(n)?n:(t(`unknown merge mode "${String(n)}"; read as first-wins`),`first-wins`)}const Bs=/^\s*<!--\s*merge:\s*([\w-]*)\s*-->\s*$/,Vs=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,Hs=/^ {0,3}(`{3,}|~{3,})/;function fenceTracker(){let e;return t=>{if(e)return RegExp(`^ {0,3}${e[0]==="`"?"`":`~`}{${e.length},}\\s*$`).test(t)&&(e=void 0),!0;let n=Hs.exec(t);return n?(e=n[1],!0):!1}}function stripMergeComments(e){let t=fenceTracker();return e.split(`
|
|
443
|
+
`).filter(e=>t(e)||!Bs.test(e)).join(`
|
|
444
444
|
`)}function titleHeadings(e){let t=fenceTracker();return e.split(`
|
|
445
|
-
`).filter(e=>!t(e)&&
|
|
446
|
-
`)){let e=r.at(-1),s=i(o),c=s?null:
|
|
445
|
+
`).filter(e=>!t(e)&&Vs.exec(e)?.[1]===`#`)}function sectionKey(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}function displayHeading(e){return`${`#`.repeat(e.level)} ${e.title}`}function parseSections(e,t){let n={preamble:[],children:[]},r=[],i=fenceTracker(),a;for(let o of e.split(`
|
|
446
|
+
`)){let e=r.at(-1),s=i(o),c=s?null:Vs.exec(o);if(c){let e=c[1].length,t={level:e,title:(c[2]??``).trim(),heading:o.trimEnd(),op:`replace`,body:[],children:[]};for(;(r.at(-1)?.level??0)>=e;)r.pop();(r.at(-1)?.children??n.children).push(t),r.push(t),a=t;continue}if(a&&!s){if(!o.trim())continue;let e=Bs.exec(o);if(e){let n=e[1];n===`replace`||n===`combine`||n===`remove`?a.op=n:t(`unknown section merge "${n}" under "${displayHeading(a)}"; read as replace`),a=void 0;continue}}a=void 0,(e?.body??n.preamble).push(o)}return n}function trimBlank(e){let t=0,n=e.length;for(;t<n&&!e[t].trim();)t++;for(;n>t&&!e[n-1].trim();)n--;return e.slice(t,n)}function warnDuplicates(e,t,n,r){let i=new Set;for(let a of e){let e=sectionKey(a.title);i.has(e)&&r(`heading path "${t}${displayHeading(a)}" appears more than once in ${n}; the first is matched`),i.add(e)}}function warnUnmatched(e,t,n,r){r(`"<!-- merge: ${e.op} -->" on "${t}${displayHeading(e)}" in ${n} matches no section below`)}function place(e,t,n,r){let i=`${t}${displayHeading(e)} > `,a=e.children.flatMap(e=>(e.op!==`replace`&&warnUnmatched(e,i,n,r),e.op===`remove`?[]:[place(e,i,n,r)]));return{...e,children:a}}function mergeChildren(e,t,n,r,i){warnDuplicates(e,n,`the layers below`,i),warnDuplicates(t,n,r,i);let a=[...e],o=[],s=new Set;for(let c of t){let t=sectionKey(c.title),l=e.findIndex((e,n)=>!s.has(n)&§ionKey(e.title)===t);if(l===-1){c.op!==`replace`&&warnUnmatched(c,n,r,i),c.op!==`remove`&&o.push(place(c,n,r,i));continue}for(let n=0;n<e.length;n++)sectionKey(e[n].title)===t&&s.add(n);let u=e[l];if(c.op===`remove`)a[l]=void 0;else if(c.op===`combine`){let e=trimBlank(u.body),t=trimBlank(c.body);a[l]={...u,body:e.length&&t.length?[...e,``,...t]:[...e,...t],children:mergeChildren(u.children,c.children,`${n}${displayHeading(u)} > `,r,i)}}else a[l]=place(c,n,r,i)}return[...a.filter(e=>e!==void 0),...o]}function mergeSections(e,t,n,r){let i=trimBlank(t.preamble);return{preamble:i.length?i:e.preamble,children:mergeChildren(e.children,t.children,``,n,r)}}function renderSections(e){let t=[],n=trimBlank(e.preamble);n.length&&t.push(n.join(`
|
|
447
447
|
`));let visit=e=>{let n=trimBlank(e.body);t.push(n.length?`${e.heading}\n\n${n.join(`
|
|
448
448
|
`)}`:e.heading);for(let t of e.children)visit(t)};for(let t of e.children)visit(t);return`${t.join(`
|
|
449
449
|
|
|
450
|
-
`)}\n`}const
|
|
450
|
+
`)}\n`}const Us=/^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i,Ws=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i;function parseReferenceName(e){if(e.endsWith(`.md`))throw Error(`"${e}" names a file. Ask for the reference by name, without the .md extension.`);let t=e.lastIndexOf(`/`),n=t===-1?e:e.slice(t+1),r=t===-1?void 0:e.slice(0,t);if(!Us.test(n)||r!==void 0&&!Ws.test(r))throw Error(`"${e}" is not a reference name. A name is letters, digits, hyphens, and dots, optionally after "<plugin>/" — not a path.`);return{name:n,plugin:r,raw:e}}const Gs=[`README.md`,`index.md`,`SKILL.md`];function candidateFiles(e){return[`${e}.md`,...Gs.map(t=>`${e}/${t}`)]}function tryRead(e){try{return o(e,`utf8`)}catch{return}}function pluginLabel(e){return e.plugins[0]??``}function layerName(e){return e.tier===`plugin`?`plugin ${pluginLabel(e)}`:e.tier}function layersFor$2(e,t){let n=e.plugin;if(n===void 0)return[...t];let r=t.filter(e=>e.tier!==`plugin`||e.plugins.includes(n));return r.some(e=>e.tier===`plugin`)?r:[...r,{tier:`plugin`,dir:`(no dependency named ${n})`,plugins:[n],status:``}]}__name(layersFor$2,`layersFor`);function resolveReference(e,t,{display:n=e=>e}={}){let r=[],i=[],a=[];for(let o of layersFor$2(e,t)){let t={tier:o.tier,plugin:pluginLabel(o),path:o.dir,found:!1,candidate:``,merge:``,outcome:`missing`,description:``};if(i.push(t),o.skipped){t.outcome=o.skipped;continue}let[s,...c]=candidateFiles(e.name).flatMap(e=>{let t=tryRead(v(o.dir,e));return t===void 0?[]:[{candidate:e,raw:t}]});if(!s)continue;for(let e of c)r.push(`${n(v(o.dir,e.candidate))} is ignored: ${s.candidate} answers first in that folder`);let l=v(o.dir,s.candidate),warn=e=>r.push(`${n(l)}: ${e}`),{metadata:u,body:d}=parseDocument(s.raw,warn),p=readMergeMode(u,warn),m=typeof u.description==`string`?u.description:``;Object.assign(t,{path:l,found:!0,candidate:s.candidate,merge:p,outcome:``,description:m}),a.push({layer:o,entry:t,metadata:u,body:d,merge:p})}let o={name:e.raw,status:`missing`,layers:[],warnings:r,plugins:[],trace:i},s=a.findIndex(({merge:e})=>e===`first-wins`),c=s===-1?a:a.slice(0,s+1),l=s===-1?[]:a.slice(s+1),u=c.at(-1),d=[...new Set(a.filter(({layer:e})=>e.tier===`plugin`).map(({entry:e})=>e.plugin))];if(e.plugin===void 0&&d.length>1&&c.some(({layer:e})=>e.tier===`plugin`)){for(let{entry:e}of a)e.outcome=`ambiguous`;return o.status=`ambiguous`,o.plugins=d.map(t=>`${t}/${e.name}`),o}for(let e of l)e.entry.outcome=`shadowed by ${u.layer.tier} (first-wins)`;if(!u)return o;for(let{entry:e}of c)e.outcome=`used`;let p=c[0];return{...o,status:`found`,tier:p.layer.tier,plugin:p.entry.plugin,path:p.entry.path,merge:p.merge,metadata:Object.assign({},...[...c].reverse().map(({metadata:e})=>e)),content:withNewline(stripMergeComments(fold(c,n,e=>r.push(e)))),layers:c.map(({layer:e,entry:t,merge:n})=>({tier:e.tier,plugin:t.plugin,path:t.path,merge:n}))}}function fold(e,t,n){let label=({layer:e,entry:n})=>`${layerName(e)} ${t(n.path)}`,[r,...i]=[...e].reverse(),a=[{labels:[label(r)],body:r.body}];for(let e of i){if(e.merge===`combine`){a=[{labels:[label(e)],body:e.body},...a];continue}let t=mergeSections(parseSections(a.map(({body:e})=>e.trim()).join(`
|
|
451
451
|
|
|
452
452
|
`),n),parseSections(e.body,n),label(e),n);a=[{labels:[label(e),...a.flatMap(({labels:e})=>e)],body:renderSections(t)}]}return a.length===1?a[0].body:[`> Combined from ${a.length} layers, highest precedence first. Where they conflict, the first layer wins.`,...a.map(({labels:e,body:t})=>`<!-- layer: ${e.join(`, `)} -->\n\n${t.trim()}`)].join(`
|
|
453
453
|
|
|
454
454
|
`)}function withNewline(e){return e.endsWith(`
|
|
455
|
-
`)?e:`${e}\n`}function layerNames(e){let t;try{t=s(e,{withFileTypes:!0})}catch{return[]}let n=new Set;for(let r of t){let t=r.isFile()&&r.name.endsWith(`.md`)?r.name.slice(0,-3):r.name;
|
|
455
|
+
`)?e:`${e}\n`}function layerNames(e){let t;try{t=s(e,{withFileTypes:!0})}catch{return[]}let n=new Set;for(let r of t){let t=r.isFile()&&r.name.endsWith(`.md`)?r.name.slice(0,-3):r.name;Us.test(t)&&(r.isFile()?r.name.endsWith(`.md`):Gs.some(n=>tryRead(v(e,t,n))!==void 0))&&n.add(t)}return[...n]}function referenceNames(e){return[...new Set(e.flatMap(({dir:e,skipped:t})=>t?[]:layerNames(e)))].sort((e,t)=>e.localeCompare(t))}function listReferences(e,t={}){let n=[],r=new Set;for(let i of referenceNames(e)){let a=resolveReference(parseReferenceName(i),e,t);for(let e of a.warnings)r.add(e);for(let e of a.trace)e.found&&n.push({name:i,tier:e.tier,plugin:e.plugin,path:e.path,status:e.outcome===`ambiguous`?`ambiguous — ask for one of ${a.plugins.join(`, `)}`:e.outcome,description:e.description})}return{rows:n,warnings:[...r]}}const Ks=[`name`,`prefix`,`close name`,`description`,`heading`,`body`];function distance(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++){let o=n[a-1]+(e[r-1]===t[a-1]?0:1);i.push(Math.min(n[a]+1,i[a-1]+1,o))}n=i}return n[t.length]}function headings(e){let t=!1,n=[];for(let r of e.split(`
|
|
456
456
|
`))/^ {0,3}(`{3,}|~{3,})/.test(r)?t=!t:!t&&/^ {0,3}#{1,6}\s/.test(r)&&n.push(r);return n.join(`
|
|
457
457
|
`)}function tagText(e){return Array.isArray(e)?e.map(String).join(` `):typeof e==`string`?e:``}function matchKind(e,t,n){let r=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(r===n||e.toLowerCase()===n)return`name`;if(r.startsWith(n))return`prefix`;if(r.includes(n)||distance(r,n)<=Math.max(1,Math.floor(n.length/4)))return`close name`;let i=n.split(/\s+/),holds=e=>{let t=e.toLowerCase();return i.every(e=>t.includes(e))},a=t.metadata;if(holds(`${typeof a.description==`string`?a.description:``} ${tagText(a.tags)}`))return`description`;let o=t.content;if(holds(headings(o)))return`heading`;if(holds(o))return`body`}function searchReferences(e,t,n={}){let r=e.trim().toLowerCase(),i=[];for(let e of referenceNames(t)){let a=resolveReference(parseReferenceName(e),t,n),o=a.status===`ambiguous`?a.plugins.map(e=>resolveReference(parseReferenceName(e),t,n)):[a];for(let e of o.filter(({status:e})=>e===`found`)){let t=matchKind(e.name,e,r);if(!t)continue;let n=e.metadata.description;i.push({name:e.name,tier:e.tier,match:t,description:typeof n==`string`&&n.split(`
|
|
458
|
-
`)[0]?.trim()||``})}}return i.sort((e,t)=>
|
|
458
|
+
`)[0]?.trim()||``})}}return i.sort((e,t)=>Ks.indexOf(e.match)-Ks.indexOf(t.match)||e.name.localeCompare(t.name))}function managedGovernancesDir(e,t){return e===`darwin`?`/Library/Application Support/BuddyAgentHarness/governances`:e===`win32`?v(t||`C:\\ProgramData`,`BuddyAgentHarness`,`governances`):`/etc/buddy-agent-harness/governances`}function deprecatedManagedGovernancesDir(e,t){return e===`darwin`?`/Library/Application Support/UniPlugin/governances`:e===`win32`?v(t||`C:\\ProgramData`,`UniPlugin`,`governances`):`/etc/universal-plugin/governances`}function projectGovernancesDir(e){return v(e,`.agents`,`governances`)}function userGovernancesDir(e){return v(e,`.agents`,`governances`)}function packageGovernancesDir(e=ee(import.meta.url)){let t=g(e);for(;;){if(r(v(t,`package.json`)))return v(t,`governances`);let e=g(t);if(e===t)return v(t,`governances`);t=e}}function governanceLayers({root:e,home:t,platform:n,programData:r}){return[{scope:`project`,dir:projectGovernancesDir(e)},{scope:`user`,dir:userGovernancesDir(t)},{scope:`managed`,dir:managedGovernancesDir(n,r)},{scope:`managed-deprecated`,dir:deprecatedManagedGovernancesDir(n,r)},{scope:`package`,dir:packageGovernancesDir()}]}function overrideLayers(e){return e.filter(e=>e.scope!==`package`)}const qs=/^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i;function parseGovernanceName(e){if(e.endsWith(`.md`))throw Error(`"${e}" names a file. Ask for the governance by name, without the .md extension.`);if(!qs.test(e))throw Error(`"${e}" is not a governance name. A name is letters, digits, hyphens, and dots — not a path.`);return e}function tryReadDocument(e){try{return o(e,`utf8`)}catch{return}}function documentNames(e){try{return s(e,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>e.name.slice(0,-3))}catch{return[]}}function resolveGovernance(e,t){for(let{scope:n,dir:r}of t){let t=v(r,`${e}.md`),i=tryReadDocument(t);if(i!==void 0)return{name:e,scope:n,path:t,content:i}}}function listGovernances(e){let t=new Map;for(let{scope:n,dir:r}of e)for(let e of documentNames(r))t.has(e)||t.set(e,{name:e,scope:n,path:v(r,`${e}.md`)});return[...t.values()].sort((e,t)=>e.name.localeCompare(t.name))}function detectedHarnesses(e){return detectHarness({env:e}).candidates}const Js={"macos-managed-preferences":`a macOS managed-preferences domain delivered by MDM`,"windows-registry":`a Windows registry key delivered by MDM or Group Policy`,server:`server-side settings`};function skippedLayer(e,t,n,r=[]){return{tier:e,dir:t,plugins:r,status:n,skipped:n}}function managedFolders(e,t,n){let r=t===`win32`?w:b,i=managedPolicyLocations(e,{platform:t,env:n}),a=[...new Set(i.flatMap(({kind:e,location:t})=>e===`file`?[r.dirname(t)]:e===`directory`?[t]:[]))];return{read:a.filter(e=>!a.some(t=>e.startsWith(t+r.sep))).map(e=>r.join(e,`references`)),unread:i.flatMap(({kind:t,location:n})=>{let r=Js[t];return r?[{location:n,reason:`not read — ${e} keeps this policy in ${r}, which cannot be read locally`}]:[]})}}function harnessManagedLayers(e,t,n){return e.length?e.flatMap(e=>{let{read:r,unread:i}=managedFolders(e,t,n);return[...r.map(e=>({tier:`managed`,dir:e,plugins:[],status:``})),...i.map(({location:e,reason:t})=>skippedLayer(`managed`,e,t))]}):[skippedLayer(`managed`,`(no harness detected)`,`not read — no harness detected, so no harness managed folder`)]}function activeInstall(e,t){for(let n of t){let t=e.find(({projectPath:e})=>e===n);if(t)return t}return e.find(({projectPath:e})=>e===void 0)}async function enabledPluginLayers(e,t,n){let r=[];for(let i of e){let[e,a]=await Promise.all([enabledPlugins(i,n),installedPlugins(i,n)]);if(!e.supported){r.push(skippedLayer(`plugin`,`(${i} enabled plugins)`,`not read — ${i} keeps no readable record of enabled plugins`));continue}e.unread.length&&r.push(skippedLayer(`plugin`,`(${i} plugin policy)`,`not read — ${e.unread.join(`; `)} may also enable or disable ${i} plugins`));for(let{id:n,enabled:o}of e.plugins){if(!o)continue;let e=n.split(`@`)[0],s=activeInstall(a.plugins.filter(e=>e.id===n),t);if(s){r.push({tier:`plugin`,dir:v(s.path,`references`),plugins:[e],status:``});continue}r.push(skippedLayer(`plugin`,`(${n})`,`not read — enabled in ${i}, but no install folder for this project is recorded`,[e]))}}return r}const Ys=`legacy — move these documents to references/ beside it`;function managedReferencesDir(e,t){return v(g(managedGovernancesDir(e,t)),`references`)}function projectReferencesDir(e){return v(e,`.agents`,`references`)}function projectReferenceLayers(e){return[{tier:`project`,dir:projectReferencesDir(e),plugins:[],status:``},{tier:`project`,dir:v(e,`.agents`,`governances`),plugins:[],status:Ys}]}function readJson(e){try{return JSON.parse(o(e,`utf8`))}catch{return}}function isRepositoryRoot(e){if(r(v(e,`.git`))||r(v(e,`pnpm-workspace.yaml`)))return!0;let t=readJson(v(e,`package.json`));return isRecord$1(t)&&t.workspaces!==void 0}function projectChain(e){let t=S(e),n=[],r=t;for(;;){if(n.push(r),isRepositoryRoot(r))return n;let e=g(r);if(e===r)return[t];r=e}}function isDirectory$2(e){try{return d(e).isDirectory()}catch{return!1}}__name(isDirectory$2,`isDirectory`);function nearestManifest(e){let t=e;for(;;){let e=v(t,`package.json`);if(r(e))return e;let n=g(t);if(n===t)return;t=n}}function canonical(e){try{return l(e)}catch{return e}}function dependencyLayers(e,t){let n=nearestManifest(e);if(!n)return[];let r=[];for(let e of declaredDependencies(readJson(n))){let i=packageDir(e,n);if(!i||t.has(canonical(i)))continue;let a=v(i,`references`);if(!isDirectory$2(a))continue;let o=readJson(v(i,`plugin.json`)),s=isRecord$1(o)&&typeof o.name==`string`?o.name:void 0,c=s&&s!==e?[e,s]:[e];r.push({tier:`plugin`,dir:a,plugins:c,status:``})}return r}async function referenceLayers({root:e,home:t,platform:n,programData:r,packageRoot:i=g(packageGovernancesDir()),env:a=process.env}){let layer=(e,t,n=``)=>({tier:e,dir:t,plugins:[],status:n}),o=[`buddy-agent-harness`],s=detectedHarnesses(a),c=projectChain(e),l=canonical(i),u=await enabledPluginLayers(s,c,{env:a,homedir:t,cwd:S(e),platform:n}),d=[layer(`managed`,managedReferencesDir(n,r)),...harnessManagedLayers(s,n,a),layer(`managed`,managedGovernancesDir(n,r),Ys),layer(`managed`,deprecatedManagedGovernancesDir(n,r),`deprecated — move these documents to the managed references/ layer`),...c.flatMap(projectReferenceLayers),layer(`user`,v(t,`.agents`,`references`)),layer(`user`,v(t,`.agents`,`governances`),Ys),{tier:`plugin`,dir:v(i,`references`),plugins:o,status:``},{tier:`plugin`,dir:v(i,`governances`),plugins:o,status:Ys},...u.filter(({dir:e,skipped:t})=>t||isDirectory$2(e)&&canonical(g(e))!==l),...dependencyLayers(e,new Set([l]))],p=new Set;return d.filter(({dir:e})=>!p.has(e)&&p.add(e))}function skillNames(e){return s(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).sort()}function pathOccupied(e){try{return i(e),!0}catch{return!1}}function linksTo(e,t){try{return i(e).isSymbolicLink()?l(e)===l(t):!1}catch{return!1}}function countSkills(e){return a(e,{recursive:!0}),skillNames(e).length}function linkTarget(e,t){return te()===`win32`?S(t):x(g(e),t)}function parseForce(e){return e===`true`||e!==`false`&&e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function namesTarget(e,t,n){return S(e,n)===S(t)}function projectSkills({root:e,canonicalSkills:t,harnesses:r,copy:i,force:o}){let s=r.filter(e=>e.project.skillsDirectory).map(t=>({harness:t,target:v(e,t.project.skillsDirectory)})),c=Array.isArray(o)?o:[],l=c.filter(t=>!s.some(({target:n})=>namesTarget(e,n,t)));if(l.length)throw Error(`No skill target matches:\n${l.map(e=>`- ${e}`).join(`
|
|
459
459
|
`)}\nTargets for the enabled harnesses:\n${s.map(({target:t})=>`- ${x(e,t)}`).join(`
|
|
460
460
|
`)}`);let forces=t=>o===!0||c.some(n=>namesTarget(e,t,n)),d=s.filter(({target:e})=>pathOccupied(e)&&!linksTo(e,t)).filter(({target:e})=>!forces(e));if(d.length&&c.length===0)throw Error(`Refusing to replace existing skill targets:\n${d.map(({target:t})=>`- ${x(e,t)}`).join(`
|
|
461
|
-
`)}`);let m=new Set(d.map(({harness:e})=>e.name));for(let{harness:e,target:r}of s)if(!m.has(e.name)&&(a(g(r),{recursive:!0}),!linksTo(r,t))){if(pathOccupied(r)&&u(r,{recursive:!0,force:!0}),i){n(t,r,{recursive:!0});continue}try{p(linkTarget(r,t),r,te()===`win32`?`junction`:void 0)}catch(e){if(pathOccupied(r))throw e;n(t,r,{recursive:!0})}}return{linked:s.filter(({harness:e})=>!m.has(e.name)).map(({harness:e})=>e.name),skipped:s.filter(({harness:e})=>m.has(e.name)).map(({harness:e})=>e.name)}}
|
|
462
|
-
`).some(e=>e.trim()
|
|
461
|
+
`)}`);let m=new Set(d.map(({harness:e})=>e.name));for(let{harness:e,target:r}of s)if(!m.has(e.name)&&(a(g(r),{recursive:!0}),!linksTo(r,t))){if(pathOccupied(r)&&u(r,{recursive:!0,force:!0}),i){n(t,r,{recursive:!0});continue}try{p(linkTarget(r,t),r,te()===`win32`?`junction`:void 0)}catch(e){if(pathOccupied(r))throw e;n(t,r,{recursive:!0})}}return{linked:s.filter(({harness:e})=>!m.has(e.name)).map(({harness:e})=>e.name),skipped:s.filter(({harness:e})=>m.has(e.name)).map(({harness:e})=>e.name)}}function isDirectory$1(e){try{return i(e).isDirectory()}catch{return!1}}__name(isDirectory$1,`isDirectory`);function exists$1(e){try{return i(e),!0}catch{return!1}}__name(exists$1,`exists`);function importsGlobal(e,t,n){let r=t.kind===`import`?[t.line,`@${v(n,Na)}`]:[];return e.split(`
|
|
462
|
+
`).some(e=>r.includes(e.trim()))}function locate(e,t,n,r){let i=t.relocatedBy,a=i===void 0?void 0:n[i];if(!a||r!==t.detect&&!r.startsWith(`${t.detect}/`))return{absolute:v(e,r),display:`~/${r}`};let o=r.slice(t.detect.length);return{absolute:v(S(a),o),display:`$${i}${o}`}}function readsAsShadow(e){try{return d(e).isFile()&&o(e,`utf8`).trim()!==``}catch{return!1}}function inspect$1(e,t,n){let r;try{r=i(t)}catch{return{kind:`none`,status:`missing`,problem:`global-instructions-missing`}}if(r.isSymbolicLink())return S(g(t),c(t))===v(e,`.agents/AGENTS.md`)?{kind:`symlink`,status:`ok`}:{kind:`symlink`,status:`unbridged`,problem:`global-instructions-unbridged`};let a;try{a=o(t,`utf8`)}catch{return{kind:`file`,status:`unbridged`,problem:`global-instructions-unbridged`}}return importsGlobal(a,n,e)?{kind:`import`,status:`ok`}:{kind:`file`,status:`unbridged`,problem:`global-instructions-unbridged`}}__name(inspect$1,`inspect`);function finding(e,t,n){let{detail:r,repair:i}=repairFor(t);return{path:e,problem:t,detail:r,repair:i({file:e},n)}}function diagnoseGlobalInstructions(e,t,n,r={}){let i=exists$1(v(e,Na)),a=[],o=[];for(let s of Pa){let c=s.user,l=c?.instructionBridge;if(!c||!l||!t.includes(s.name)&&!isDirectory$1(locate(e,c,r,c.detect).absolute))continue;let u=locate(e,c,r,l.path),d=inspect$1(e,u.absolute,l),p=(c.shadowedBy??[]).map(t=>locate(e,c,r,t)).find(({absolute:e})=>readsAsShadow(e));if(p!==void 0){let t=inspect$1(e,p.absolute,l);if(t.status===`ok`){a.push({harness:s.name,path:p.display,kind:t.kind,status:`ok`});continue}a.push({harness:s.name,path:u.display,kind:d.kind,status:`overridden`}),i&&o.push(finding(p.display,`global-instructions-overridden`,n))}else a.push({harness:s.name,path:u.display,kind:d.kind,status:d.status});i&&d.problem&&o.push(finding(u.display,d.problem,n))}return{globalInstructions:a,findings:o}}const Xs=new Set([`node_modules`]);function agentsFileDirectories(e){let t=[],walk=n=>{r(v(e,n,`AGENTS.md`))&&t.push(n);let i;try{i=s(v(e,n),{withFileTypes:!0})}catch{return}for(let e of i)!e.isDirectory()||e.name.startsWith(`.`)||Xs.has(e.name)||walk(n?b.join(n,e.name):e.name)};return walk(``),t.sort()}const Zs=`AGENTS.md`;function valueAt(e,t){return t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e)return e[t]},e)}function exists(e){try{return i(e),!0}catch{return!1}}function inspectSettingsEntry(e,t){let n;try{n=o(e,`utf8`)}catch{return{kind:`none`,status:`missing`,problem:`instructions-missing`}}let r=parseJsonWithComments(n);if(r===void 0)return{kind:`file`,status:`unreadable`,problem:`instructions-unreadable`};let i=valueAt(r,t);return Array.isArray(i)&&i.includes(`AGENTS.md`)?{kind:`settings-entry`,status:`ok`}:{kind:`file`,status:`unbridged`,problem:`instructions-unbridged`}}function inspectShadow(e){let t;try{t=i(e)}catch{return}if(t.isSymbolicLink())return c(e)===`AGENTS.md`?{kind:`symlink`,status:`superseded`,problem:`instructions-superseded`}:{kind:`symlink`,status:`shadowing`,problem:`instructions-shadowing`};let n;try{n=o(e,`utf8`)}catch{return{kind:`file`,status:`unreadable`,problem:`instructions-unreadable`}}return n.split(`
|
|
463
|
+
`).some(e=>e.trim()===`@AGENTS.md`)?{kind:`import`,status:`superseded`,problem:`instructions-superseded`}:{kind:`file`,status:`shadowing`,problem:`instructions-shadowing`}}function diagnoseInstructions(e,t,n){let r=t.map(e=>({name:e.name,bridge:e.project.instructionBridge})).filter(e=>e.bridge?.kind===`settings-entry`),i=[],a=[],o=agentsFileDirectories(e),s=t.some(t=>(t.project.shadowedBy??[]).some(t=>exists(v(e,t))));if((r.length||s)&&!o.includes(``)){let{detail:e,repair:t}=repairFor(`no-instructions`);a.push({path:Zs,problem:`no-instructions`,detail:e,repair:t({file:Zs},n)})}for(let{name:t,bridge:o}of r){let r=inspectSettingsEntry(v(e,o.path),o.key);if(i.push({harness:t,path:o.path,kind:r.kind,status:r.status}),r.problem){let{detail:e,repair:t}=repairFor(r.problem);a.push({path:o.path,problem:r.problem,detail:e,repair:t({file:o.path},n)})}}for(let r of t)for(let t of r.project.shadowedBy??[])for(let s of o){let o=s?b.join(s,t):t,c=inspectShadow(v(e,o));if(!c)continue;i.push({harness:r.name,path:o,kind:c.kind,status:c.status});let{detail:l,repair:u}=repairFor(c.problem);a.push({path:o,problem:c.problem,detail:l,repair:u({file:o},n)})}return{instructions:i,findings:a}}function git(e,t,n){try{return ie(`git`,t,{cwd:e,encoding:`utf8`,...n===void 0?{}:{input:n},stdio:[`pipe`,`pipe`,`pipe`]})}catch{return}}function lines(e){return(e??``).split(`
|
|
463
464
|
`).filter(Boolean)}var GitBridgeState=class{root;repoRootPrefix;constructor(e){this.root=e,this.repoRootPrefix=git(e,[`rev-parse`,`--show-prefix`])?.trim()}trackingOf(e){if(this.repoRootPrefix===void 0)return`untracked`;let t=lines(git(this.root,[`ls-files`,`-v`,`--`,e]));return t.length?t.every(e=>e.startsWith(`S`))?`skip-worktree`:`tracked`:`untracked`}isIgnored(e){return this.repoRootPrefix!==void 0&&git(this.root,[`check-ignore`,`-q`,`--`,e])!==void 0}commitsTouching(e){return this.repoRootPrefix===void 0?[]:lines(git(this.root,[`rev-list`,`-n`,`200`,`HEAD`,`--`,...e]))}contentAt(e,t){if(this.repoRootPrefix!==void 0)return git(this.root,[`show`,`${e}:${this.repoRootPrefix}${t}`])}directionOf(e,t){if(this.repoRootPrefix===void 0)return`unknown`;let n=this.lastAgreedTree(e,t);if(n===void 0)return`unknown`;let r=!this.matchesTree(e,n),i=!this.matchesTree(t,n);return r&&i?`both`:r?`bridge`:`canonical`}lastAgreedTree(e,t){for(let n of lines(git(this.root,[`rev-list`,`-n`,`200`,`HEAD`,`--`,e,t]))){let r=git(this.root,[`rev-parse`,`-q`,`--verify`,`${n}:${this.repoRootPrefix}${e}`])?.trim();if(r&&r===git(this.root,[`rev-parse`,`-q`,`--verify`,`${n}:${this.repoRootPrefix}${t}`])?.trim())return r}}matchesTree(e,t){let n=new Map(lines(git(this.root,[`ls-tree`,`-r`,t])).map(e=>{let[t,n]=e.split(` `);return[n,t.split(` `)[2]]})),r=filesUnder(v(this.root,e));if(r.length!==n.size||r.some(e=>!n.has(e)))return!1;let i=lines(git(this.root,[`hash-object`,`--stdin-paths`],r.map(t=>v(e,t)).join(`
|
|
464
|
-
`)));return i.length===r.length&&r.every((e,t)=>n.get(e)===i[t])}};const
|
|
465
|
-
`,
|
|
465
|
+
`)));return i.length===r.length&&r.every((e,t)=>n.get(e)===i[t])}};const Qs=`.agents/skills`;function pathState(e){try{let t=i(e);return t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`}catch{return`missing`}}function isDirectory(e){try{return d(e).isDirectory()}catch{return!1}}function sameContent(e,t){let n=filesUnder(e),r=filesUnder(t);return n.length===r.length&&n.every((n,i)=>r[i]===n&&o(v(e,n)).equals(o(v(t,n))))}function inspect(e,t,n,r){switch(pathState(e)){case`missing`:return{kind:`none`,status:`missing`,problem:`missing`};case`file`:return{kind:`file`,status:`degraded`,problem:`degraded`};case`symlink`:return linksTo(e,n)?{kind:`symlink`,status:`ok`}:{kind:`symlink`,status:`stale`,problem:`stale`};default:if(!sameContent(e,n)){let e=r.directionOf(t,Qs);return{kind:`copy`,status:`diverged`,problem:`diverged-${e}`,direction:e}}return r.trackingOf(t)===`tracked`?{kind:`copy`,status:`ok`,problem:`unpinned-copy`}:{kind:`copy`,status:`ok`}}}function diagnoseBridges({root:e,harnesses:t=[],cli:n,home:r,env:i}){let a=v(e,`.agents`,`skills`),o=new GitBridgeState(e),s=selectHarnesses(e,t),c=s.map(e=>({name:e.name,skillsDirectory:e.project.skillsDirectory})).filter(e=>!!e.skillsDirectory),l=[],u=[],d=[];if(!isDirectory(a)){let{detail:e,repair:t}=repairFor(`no-canonical`);d.push({path:Qs,problem:`no-canonical`,detail:e,repair:t({file:Qs},n)})}for(let t of c){let r=t.skillsDirectory,i=inspect(v(e,r),r,a,o);if(l.push({harness:t.name,path:r,kind:i.kind,status:i.status}),i.direction&&u.push({path:r,direction:i.direction}),i.problem){let{detail:e,repair:t}=repairFor(i.problem);d.push({path:r,problem:i.problem,detail:e,repair:t({file:r},n)})}}let p=diagnoseInstructions(e,s,n);d.push(...p.findings);let m=r===void 0?{globalInstructions:[],findings:[]}:diagnoseGlobalInstructions(r,t,n,i);return d.push(...m.findings),{bridges:l,instructions:p.instructions,globalInstructions:m.globalInstructions,divergence:u,findings:d}}function buildDoctorReport(e,t,n=[],r=[]){let i=[...t.findings,...n],a=r.length?r:`0 references — no layer outside the plugin tier holds one`;if(!i.length){let n=t.bridges.length+t.instructions.length,r=n===1?`the 1 bridge resolves`:`all ${n} bridges resolve`;return{bin:e,bridges:t.bridges,instructions:t.instructions,globalInstructions:t.globalInstructions,references:a,findings:`0 problems found — ${r} and the configuration around them is current`}}return{bin:e,bridges:t.bridges,instructions:t.instructions,globalInstructions:t.globalInstructions,references:a,...t.divergence.length?{divergence:t.divergence}:{},findings:i.map(({path:e,problem:t,detail:n})=>({path:e,problem:t,detail:n})),help:[...new Map(i.map(e=>[`${e.repair.command}\u0000${e.repair.instruction}`,e.repair])).values()]}}const $s=command({name:`doctor`,description:`Report whether this repository's harness bridges still resolve — skills into .agents/skills, instructions into AGENTS.md — and whether each harness's user-scope file loads ~/.agents/AGENTS.md. Read-only.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:q(K())},harness:{description:`Comma-separated harnesses to check in addition to Claude Code and Cursor, e.g. codex,gemini-cli.`,type:q(K())},format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`}},async run(e){try{let t=parseFormat(e.format),n=parseHarnesses(e.harness),r=e.root??process.cwd(),i=E(),a=diagnoseBridges({root:r,...n.length?{harnesses:n}:{},cli:La,home:i,env:process.env}),o=new GitBridgeState(r),s=[...diagnoseConfiguration({root:r,git:o,cli:La}),...diagnoseMcp({root:r,git:o,cli:La}),...diagnoseNonstandard({root:r,cli:La})],{rows:c}=listReferences(await referenceLayers({root:r,home:i,platform:process.platform,programData:process.env.ProgramData,env:process.env})),l=c.filter(({tier:e})=>e!==`plugin`).map(({name:e,tier:t,path:n,status:r})=>({name:e,tier:t,path:collapseHome(i,n),status:r}));return writeResult(buildDoctorReport(displayBinPath(i,process.argv[1]),a,s,l),t),O.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Harness diagnosis failed.`}\n`),O.error}}});function layersFor$1(e){let t=governanceLayers({root:e.root??process.cwd(),home:E(),platform:process.platform,programData:process.env.ProgramData});return e[`overrides-only`]?overrideLayers(t):t}__name(layersFor$1,`layersFor`);const ec=`warning: "governance" is deprecated and will be removed in the next major version; use "reference show|list" instead.
|
|
466
|
+
`,tc={description:`Repository or package directory. Defaults to the current directory.`,type:q(K())},nc={description:`Resolve only the project, user, and machine-wide layers. Never returns a governance this package ships, and exits non-zero when no layer has one.`,type:q(Fn())},rc=command({name:`governance`,description:"Deprecated: use `reference`. Read the governance documents the project, user, and machine-wide override layers hold. Read-only.",commands:[command({name:`list`,description:`List every governance the override layers hold, each at the layer that would win.`,options:{root:tc,"overrides-only":nc,format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`}},run(e){process.stderr.write(ec);try{let t=parseFormat(e.format),n=E(),r=layersFor$1(e),i=listGovernances(r);return writeResult({layers:r.map(({scope:e,dir:t})=>({scope:e,path:collapseHome(n,t),status:e===`managed-deprecated`?`deprecated — move these documents to the managed layer above`:``})),governances:i.length?i.map(({name:e,scope:t,path:r})=>({name:e,scope:t,path:collapseHome(n,r)})):`0 governances — no layer holds one`},t),O.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Governance listing failed.`}\n`),O.error}}}),command({name:`show`,description:`Print one governance document, resolved through the layers in order.`,arguments:[{name:`name`,description:"The governance name, without the `.md` extension.",type:K()}],options:{root:tc,"overrides-only":nc,format:{description:`Output format: text (default) writes the document itself; toon and json wrap it with the layer it came from.`,type:q(K()),default:`text`}},run(e){process.stderr.write(ec);try{let t=parseFormat(e.format),n=parseGovernanceName(e.name),r=resolveGovernance(n,layersFor$1(e));return r?(t===`text`?writeDocument(r.content):writeResult({name:r.name,scope:r.scope,path:collapseHome(E(),r.path),content:r.content},t),O.success):(process.stderr.write(e[`overrides-only`]?`error: no override for governance "${n}" in the project, user, or machine-wide layer.\n`:`error: no governance named "${n}" in any layer.\n`),O.error)}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Governance lookup failed.`}\n`),O.error}}})]});function readTemplate(e){if(e===void 0)return parseTemplate(`---
|
|
466
467
|
description: What this reference covers, and when an agent should read it.
|
|
467
468
|
tags: [topic]
|
|
468
469
|
---
|
|
@@ -470,16 +471,16 @@ tags: [topic]
|
|
|
470
471
|
## Overview
|
|
471
472
|
|
|
472
473
|
Write the guidance here. Give each topic its own top-level \`##\` section.
|
|
473
|
-
`,`the default template`);let t;try{t=o(e,`utf8`)}catch(t){throw Error(`cannot read the template ${e}: ${t.message}`)}return parseTemplate(t,`the template ${e}`)}function parseTemplate(e,t){let n=!0,{metadata:r,body:i}=parseDocument(e,()=>{n=!1});if(!n)throw Error(`${t} has frontmatter that is not a YAML mapping.`);return{content:e,metadata:r,body:i}}function withMergeSections(e){let t=
|
|
474
|
+
`,`the default template`);let t;try{t=o(e,`utf8`)}catch(t){throw Error(`cannot read the template ${e}: ${t.message}`)}return parseTemplate(t,`the template ${e}`)}function parseTemplate(e,t){let n=!0,{metadata:r,body:i}=parseDocument(e,()=>{n=!1});if(!n)throw Error(`${t} has frontmatter that is not a YAML mapping.`);return{content:e,metadata:r,body:i}}function withMergeSections(e){let t=zs.exec(e);if(!t)return`---\nmerge: merge-sections\n---\n\n${e}`;let n=t[0].indexOf(`
|
|
474
475
|
`)+1,r=t[0][n-2]===`\r`?`\r
|
|
475
476
|
`:`
|
|
476
|
-
`,i=n+t[1].length;return`${e.slice(0,i)}${r}merge: merge-sections${e.slice(i)}`}function templateWarnings({metadata:e,body:t}){let n=titleHeadings(t).map(e=>`"${e.trim()}" is a heading with one hash; merge-sections matches by heading path, so an override would replace or duplicate the whole document. Use top-level ## sections.`);return(typeof e.description!=`string`||!e.description.trim())&&n.push("the reference has no `description` in its frontmatter; `list` and `search` show it blank."),n}const
|
|
477
|
+
`,i=n+t[1].length;return`${e.slice(0,i)}${r}merge: merge-sections${e.slice(i)}`}function templateWarnings({metadata:e,body:t}){let n=titleHeadings(t).map(e=>`"${e.trim()}" is a heading with one hash; merge-sections matches by heading path, so an override would replace or duplicate the whole document. Use top-level ## sections.`);return(typeof e.description!=`string`||!e.description.trim())&&n.push("the reference has no `description` in its frontmatter; `list` and `search` show it blank."),n}const ic={description:`Directory the project tier is read from, and each folder above it up to the repository root. Defaults to the current directory.`,type:q(K())};function layersFor(e,t){return referenceLayers({root:e.root??process.cwd(),home:t,platform:process.platform,programData:process.env.ProgramData,env:process.env})}function fail(e,t){return process.stderr.write(`error: ${e instanceof Error?e.message:t}\n`),O.error}function traceOf(e,t){return e.trace.map(({description:e,...n})=>({...n,path:collapseHome(t,n.path)}))}function showEntry(e,t,n,r){let i={name:e.name,status:e.status,warnings:[]};return e.status===`found`&&Object.assign(i,{tier:e.tier,plugin:e.plugin,path:collapseHome(t,e.path),merge:e.merge,metadata:e.metadata,content:e.content,layers:e.layers.map(e=>({...e,path:collapseHome(t,e.path)}))}),e.status===`missing`&&(i.suggestions=n),e.status===`ambiguous`&&(i.plugins=e.plugins),i.warnings=e.warnings,r&&(i.trace=traceOf(e,t)),i}function missReason(e){if(e.status===`ambiguous`)return`"${e.name}" is held by more than one plugin; ask for one of ${e.plugins.join(`, `)}.`;let t=e.suggestions?.length?` Did you mean: ${e.suggestions.join(`, `)}?`:``;return`no reference named "${e.name}" in any tier.${t}`}function writeShowText(e){if(e.length===1){let[t]=e;t.content!==void 0&&writeDocument(t.content);return}writeDocument(e.map(e=>e.content===void 0?`<reference name="${e.name}" status="${e.status}" />`:`<reference name="${e.name}" tier="${e.tier}">\n${e.content}</reference>`).join(`
|
|
477
478
|
|
|
478
|
-
`))}function writeShowStderr(e,t){for(let n of e){if(t===`text`){for(let e of n.warnings)process.stderr.write(`warning: ${e}\n`);n.trace&&process.stderr.write(`${renderText({[`trace ${n.name}`]:n.trace})}\n`)}n.status!==`found`&&process.stderr.write(`error: ${missReason(n)}\n`)}}const tc=command({name:`show`,description:`Print one or more references, each resolved through the tiers and combined as its layers ask.`,arguments:[{name:`names`,description:"Reference names, without the `.md` extension; `<plugin>/<name>` picks one plugin.",type:In(K())}],options:{root:ec,trace:{description:`Report every path checked, the file that matched, the merge mode, and why a layer was dropped.`,type:q(Fn())},format:{description:`Output format: text (default) writes the documents themselves; toon and json return an array with metadata.`,type:q(K()),default:`text`}},async run(e){try{let t=parseFormat(e.format),n=e.names.map(parseReferenceName);if(!n.length)throw Error(`Name at least one reference.`);let r=E(),i=await layersFor(e,r),display=e=>collapseHome(r,e),a=n.map(t=>{let n=resolveReference(t,i,{display}),a=n.status===`missing`?searchReferences(t.name,i,{display}).slice(0,3).map(e=>e.name):[];return showEntry(n,r,a,!!e.trace)});return t===`text`?writeShowText(a):writeResult(a,t),writeShowStderr(a,t),a.every(e=>e.status===`found`)?O.success:O.error}catch(e){return fail(e,`Reference lookup failed.`)}}}),nc={description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`},rc=command({name:`list`,description:`List every layer, and every reference at every layer that holds it, marked used or shadowed.`,options:{root:ec,format:nc},async run(e){try{let t=parseFormat(e.format),n=E(),r=await layersFor(e,n),{rows:i,warnings:a}=listReferences(r,{display:e=>collapseHome(n,e)}),o={layers:r.map(({tier:e,plugins:t,dir:r,status:i})=>({tier:e,plugin:t[0]??``,path:collapseHome(n,r),status:i})),references:i.length?i.map(e=>({...e,path:collapseHome(n,e.path)})):`0 references — no layer holds one`};return a.length&&(o.warnings=a),writeResult(o,t),O.success}catch(e){return fail(e,`Reference listing failed.`)}}}),ic=command({name:`search`,description:`Find references by name, description, tags, headings, or body, best match first.`,arguments:[{name:`query`,description:`What the reference is about.`,type:K()}],options:{root:ec,format:nc},async run(e){try{let t=parseFormat(e.format),n=e.query.trim();if(!n)throw Error(`Search needs a query.`);let r=E(),i=searchReferences(n,await layersFor(e,r),{display:e=>collapseHome(r,e)});return writeResult({query:n,references:i.length?i:`0 references match "${n}"`},t),O.success}catch(e){return fail(e,`Reference search failed.`)}}}),ac={project:`everyone working in this repository`,user:`only you, in every repository`,plugin:`read-only; override it with the project or user file`};function slotStatus(e){return e===`missing`?`empty`:e.startsWith(`shadowed`)?`shadowed`:e}function callerCopy(e,t){return[v(e,`references`,`${t}.md`),v(e,`references`,`governances`,`${t}.md`)].find(e=>r(e))}function callerStatus(e){return e.status===`missing`?`used`:e.status===`ambiguous`?`not read — the name is ambiguous`:`shadowed`}const oc=command({name:`where`,description:`List the project and user files an override of a reference can be written to, highest precedence first, with the copy each overrides and who it applies to.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension; `<plugin>/<name>` picks one plugin.",type:K()}],options:{root:ec,caller:{description:`Folder of the skill that loads the reference, so its own copy is reported as the reference skill's Load mode reads it.`,type:q(K())},format:nc},async run(e){try{let t=parseFormat(e.format),n=parseReferenceName(e.name),r=E(),i=await layersFor(e,r),a=S(e.root??process.cwd()),display=e=>collapseHome(r,e),o=resolveReference(n,i,{display}),s=layersFor$2(n,i),c=[];for(let[e,t]of o.trace.entries()){let r=s[e],i=ac[t.tier];if(!i||(r.status||t.tier===`plugin`)&&!t.found)continue;let o=t.found?t.path:v(r.dir,`${n.name}.md`);c.push({layer:t.tier===`plugin`?`plugin ${t.plugin}`:t.tier,path:t.tier===`project`?x(a,o):display(o),status:slotStatus(t.outcome),scope:i})}let l=e.caller===void 0?void 0:callerCopy(S(e.caller),n.name);l&&c.push({layer:`caller`,path:display(l),status:callerStatus(o),scope:`read-only; the calling skill's own copy, read only when no layer holds the name`});let u={name:n.name,root:display(a),slots:c,merge:"The default, first-wins, makes the override replace the whole document. Set `merge: merge-sections` in its frontmatter to keep the sections it does not redefine."};return o.status===`ambiguous`&&(u.plugins=o.plugins),o.warnings.length&&(u.warnings=o.warnings),writeResult(u,t),o.status===`ambiguous`?(process.stderr.write(`error: ${missReason({name:n.raw,status:`ambiguous`,plugins:o.plugins,warnings:[]})}\n`),O.error):O.success}catch(e){return fail(e,`Reference placement lookup failed.`)}}});function parseScope(e){if(e!==`project`&&e!==`user`)throw Error(`--scope must be project or user.`);return e}const sc=command({name:`reference`,description:`Read on-demand reference documents by name, layered across the managed, project, user, and plugin tiers, and start a new one in the project or user tier.`,commands:[tc,rc,ic,oc,command({name:`create`,description:`Start a new reference in the project or user tier from a template, marked merge-sections when it overrides a copy below. Never overwrites.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:K()}],options:{root:ec,template:{description:"File whose text is written as it is, frontmatter included. Defaults to a built-in template of top-level `##` sections with no `#` title.",type:q(K())},scope:{description:"Tier to write: project (default), `.agents/references/` at the root, or user, `~/.agents/references/`.",type:q(K()),default:`project`},"dry-run":{description:`Print the target path and the exact content, and write nothing.`,type:q(Fn())},format:{description:`Output format: text (default) writes the path, then the content or the trace; toon and json return an object.`,type:q(K()),default:`text`}},async run(e){try{let t=parseFormat(e.format),n=parseReferenceName(e.name);if(n.plugin!==void 0)throw Error(`an override is written under the bare name, which every tier resolves; ask for "${n.name}".`);let r=parseScope(e.scope),i=readTemplate(e.template===void 0?void 0:S(e.template)),o=E(),s=r===`project`?projectReferencesDir(S(e.root??process.cwd())):v(o,`.agents`,`references`),c=v(s,`${n.name}.md`),display=e=>collapseHome(o,e),l=await layersFor(e,o),{trace:u}=resolveReference(n,l,{display}),d=l.findIndex(e=>e.dir===s);if(u[d]?.found)throw Error(`${display(u[d].path)} already holds "${n.name}"; change it with the reference skill's Update mode.`);let p=u.slice(0,d).find(e=>e.found&&e.merge===`first-wins`);if(p)throw Error(`the ${p.tier} copy ${display(p.path)} is first-wins, so nothing would read a new ${r} file; change that copy instead.`);let h=u.slice(d+1).some(e=>e.found)&&i.metadata.merge===void 0?withMergeSections(i.content):i.content,g=templateWarnings(i),_={name:n.name,scope:r,path:display(c),dryRun:!!e[`dry-run`],content:h,warnings:g};if(_.dryRun||(a(s,{recursive:!0}),m(c,h,{flag:`wx`}),_.trace=traceOf(resolveReference(n,l,{display}),o)),t!==`text`)writeResult(_,t);else{for(let e of g)process.stderr.write(`warning: ${e}\n`);_.trace?process.stdout.write(`${_.path}\n\n${renderText({trace:_.trace})}\n`):writeDocument(`${_.path}\n\n${h}`)}return O.success}catch(e){return fail(e,`Reference creation failed.`)}}})]});function initializeHarnesses({root:e,harnesses:t=[],copy:n=!1,force:r=!1}){let i=v(e,`.agents`,`skills`),o=countSkills(i);a(projectReferencesDir(e),{recursive:!0});let s=referenceNames(projectReferenceLayers(e)).length,c=selectHarnesses(e,t),{linked:l,skipped:u}=projectSkills({root:e,canonicalSkills:i,harnesses:c,copy:n,force:r});return{root:e,harnesses:c.map(e=>e.name),native:c.filter(e=>!e.project.skillsDirectory).map(e=>e.name),linked:l,skipped:u,deprecated:c.filter(e=>e.deprecated).map(e=>({name:e.name,replacedBy:e.deprecated})),skills:o,references:s,copied:n}}const cc=command({name:`init`,description:`Set up canonical agent skills for the harnesses already enabled in a repository.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:q(K())},harness:{description:`Comma-separated harnesses to enable in addition to Claude Code and Cursor, e.g. codex,gemini-cli.`,type:q(K())},copy:{description:`Copy skills instead of linking them.`,type:q(Fn())},force:{description:`Replace conflicting target skill directories. Names the targets to replace, comma-separated (e.g. .claude/skills); given alone it replaces every conflicting target.`,type:q(K())},format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`}},run(e){try{let t=parseFormat(e.format),n=parseHarnesses(e.harness);return writeResult(initializeHarnesses({root:e.root??process.cwd(),...n.length?{harnesses:n}:{},...e.copy===void 0?{}:{copy:e.copy},...e.force===void 0?{}:{force:parseForce(e.force)}}),t),O.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Harness initialization failed.`}\n`),O.error}}}),lc={ArrayExpression:[`elements`],ArrayPattern:[`elements`],ArrowFunctionExpression:[`params`,`body`],AssignmentExpression:[`left`,`right`],AssignmentPattern:[`left`,`right`],AwaitExpression:[`argument`],BinaryExpression:[`left`,`right`],BlockStatement:[`body`],BreakStatement:[`label`],CallExpression:[`callee`,`arguments`],CatchClause:[`param`,`body`],ChainExpression:[`expression`],ClassBody:[`body`],ClassDeclaration:[`id`,`superClass`,`body`],ClassExpression:[`id`,`superClass`,`body`],ConditionalExpression:[`test`,`consequent`,`alternate`],ContinueStatement:[`label`],DebuggerStatement:[],DoWhileStatement:[`body`,`test`],EmptyStatement:[],ExperimentalRestProperty:[`argument`],ExperimentalSpreadProperty:[`argument`],ExportAllDeclaration:[`exported`,`source`,`attributes`],ExportDefaultDeclaration:[`declaration`],ExportNamedDeclaration:[`declaration`,`specifiers`,`source`,`attributes`],ExportSpecifier:[`local`,`exported`],ExpressionStatement:[`expression`],ForInStatement:[`left`,`right`,`body`],ForOfStatement:[`left`,`right`,`body`],ForStatement:[`init`,`test`,`update`,`body`],FunctionDeclaration:[`id`,`params`,`body`],FunctionExpression:[`id`,`params`,`body`],Identifier:[],IfStatement:[`test`,`consequent`,`alternate`],ImportAttribute:[`key`,`value`],ImportDeclaration:[`specifiers`,`source`,`attributes`],ImportDefaultSpecifier:[`local`],ImportExpression:[`source`,`options`],ImportNamespaceSpecifier:[`local`],ImportSpecifier:[`imported`,`local`],JSXAttribute:[`name`,`value`],JSXClosingElement:[`name`],JSXClosingFragment:[],JSXElement:[`openingElement`,`children`,`closingElement`],JSXEmptyExpression:[],JSXExpressionContainer:[`expression`],JSXFragment:[`openingFragment`,`children`,`closingFragment`],JSXIdentifier:[],JSXMemberExpression:[`object`,`property`],JSXNamespacedName:[`namespace`,`name`],JSXOpeningElement:[`name`,`attributes`],JSXOpeningFragment:[],JSXSpreadAttribute:[`argument`],JSXSpreadChild:[`expression`],JSXText:[],LabeledStatement:[`label`,`body`],Literal:[],LogicalExpression:[`left`,`right`],MemberExpression:[`object`,`property`],MetaProperty:[`meta`,`property`],MethodDefinition:[`key`,`value`],NewExpression:[`callee`,`arguments`],ObjectExpression:[`properties`],ObjectPattern:[`properties`],PrivateIdentifier:[],Program:[`body`],Property:[`key`,`value`],PropertyDefinition:[`key`,`value`],RestElement:[`argument`],ReturnStatement:[`argument`],SequenceExpression:[`expressions`],SpreadElement:[`argument`],StaticBlock:[`body`],Super:[],SwitchCase:[`test`,`consequent`],SwitchStatement:[`discriminant`,`cases`],TaggedTemplateExpression:[`tag`,`quasi`],TemplateElement:[],TemplateLiteral:[`quasis`,`expressions`],ThisExpression:[],ThrowStatement:[`argument`],TryStatement:[`block`,`handler`,`finalizer`],UnaryExpression:[`argument`],UpdateExpression:[`argument`],VariableDeclaration:[`declarations`],VariableDeclarator:[`id`,`init`],WhileStatement:[`test`,`body`],WithStatement:[`object`,`body`],YieldExpression:[`argument`]},uc=Object.keys(lc);for(let e of uc)Object.freeze(lc[e]);Object.freeze(lc);function unionWith(e){let t=Object.assign({},lc);for(let n of Object.keys(e))if(Object.hasOwn(t,n)){let r=new Set(e[n]);for(let e of t[n])r.add(e);t[n]=Object.freeze(Array.from(r))}else t[n]=Object.freeze(Array.from(e[n]));return Object.freeze(t)}function last(e){return e[e.length-1]??null}function toKeyName(e){return e.type===`TOMLBare`?e.name:e.value}var TOMLVerImpl=class{constructor(e,t){this.major=e,this.minor=t}lt(e,t){return this.major<e||this.major===e&&this.minor<t}gte(e,t){return this.major>e||this.major===e&&this.minor>=t}};const dc=new TOMLVerImpl(1,0),fc=new TOMLVerImpl(1,1),pc=fc,mc={"1.0":dc,"1.0.0":dc,"1.1":fc,"1.1.0":fc,latest:fc,next:fc};function getTOMLVer(e){return e&&mc[e]||pc}const hc={"unterminated-string":`Unterminated string constant`,"unterminated-table-key":`Unterminated table-key`,"unterminated-array":`Unterminated array`,"unterminated-inline-table":`Unterminated inline table`,"missing-key":`Empty bare keys are not allowed`,"missing-newline":`Must be a newline`,"missing-equals-sign":`Expected equal (=) token`,"missing-value":`Unspecified values are invalid`,"missing-comma":`Expected comma (,) token`,"dupe-keys":`Defining a key multiple times is invalid`,"unexpected-char":`Unexpected character`,"unexpected-token":`Unexpected token`,"invalid-control-character":`Control characters (codes < 0x1f and 0x7f) are not allowed`,"invalid-comment-character":`Invalid code point {{cp}} within comments`,"invalid-key-value-newline":`The key, equals sign, and value must be on the same line`,"invalid-inline-table-newline":`No newlines are allowed between the curly braces unless they are valid within a value`,"invalid-underscore":`Underscores are allowed between digits`,"invalid-space":`Unexpected spaces`,"invalid-three-quotes":`Three or more quotes are not permitted`,"invalid-date":`Unexpected invalid date`,"invalid-time":`Unexpected invalid time`,"invalid-leading-zero":`Leading zeros are not allowed`,"invalid-trailing-comma-in-inline-table":`Trailing comma is not permitted in an inline table`,"invalid-char-in-escape-sequence":`Invalid character in escape sequence`,"invalid-consecutive-dots-in-key":`Consecutive dots are not permitted in keys`,"invalid-code-point":`Invalid code point {{cp}}`,"invalid-trailing-dot-in-key":`Keys cannot end with a dot`,"invalid-leading-dot-in-key":`Keys cannot start with a dot`};function getMessage(e,t){return t?hc[e].replace(/\{\{(.*?)\}\}/gu,(e,n)=>n in t?t[n]:`{{${n}}}`):hc[e]}var ParseError=class extends SyntaxError{constructor(e,t,n,r,i){super(getMessage(e,i)),this.index=t,this.lineNumber=n,this.column=r}};const $={EOF:-1,NULL:0,SOH:1,BACKSPACE:8,TABULATION:9,LINE_FEED:10,FORM_FEED:12,CARRIAGE_RETURN:13,ESCAPE:27,SO:14,US:31,SPACE:32,QUOTATION_MARK:34,HASH:35,SINGLE_QUOTE:39,PLUS_SIGN:43,COMMA:44,DASH:45,DOT:46,DIGIT_0:48,DIGIT_1:49,DIGIT_2:50,DIGIT_3:51,DIGIT_7:55,DIGIT_9:57,COLON:58,EQUALS_SIGN:61,LATIN_CAPITAL_A:65,LATIN_CAPITAL_E:69,LATIN_CAPITAL_F:70,LATIN_CAPITAL_T:84,LATIN_CAPITAL_U:85,LATIN_CAPITAL_Z:90,LEFT_BRACKET:91,BACKSLASH:92,RIGHT_BRACKET:93,UNDERSCORE:95,LATIN_SMALL_A:97,LATIN_SMALL_B:98,LATIN_SMALL_E:101,LATIN_SMALL_F:102,LATIN_SMALL_I:105,LATIN_SMALL_L:108,LATIN_SMALL_N:110,LATIN_SMALL_O:111,LATIN_SMALL_R:114,LATIN_SMALL_S:115,LATIN_SMALL_T:116,LATIN_SMALL_U:117,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,LEFT_BRACE:123,RIGHT_BRACE:125,TILDE:126,DELETE:127,PAD:128,SUPERSCRIPT_TWO:178,SUPERSCRIPT_THREE:179,SUPERSCRIPT_ONE:185,VULGAR_FRACTION_ONE_QUARTER:188,VULGAR_FRACTION_THREE_QUARTERS:190,LATIN_CAPITAL_LETTER_A_WITH_GRAVE:192,LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS:214,LATIN_CAPITAL_LETTER_O_WITH_STROKE:216,LATIN_SMALL_LETTER_O_WITH_DIAERESIS:246,LATIN_SMALL_LETTER_O_WITH_STROKE:248,GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL:891,GREEK_CAPITAL_LETTER_YOT:895,CP_1FFF:8191,ZERO_WIDTH_NON_JOINER:8204,ZERO_WIDTH_JOINER:8205,UNDERTIE:8255,CHARACTER_TIE:8256,SUPERSCRIPT_ZERO:8304,CP_218F:8591,CIRCLED_DIGIT_ONE:9312,NEGATIVE_CIRCLED_DIGIT_ZERO:9471,GLAGOLITIC_CAPITAL_LETTER_AZU:11264,CP_2FEF:12271,IDEOGRAPHIC_COMMA:12289,CP_D7FF:55295,CP_E000:57344,CJK_COMPATIBILITY_IDEOGRAPH_F900:63744,ARABIC_LIGATURE_SALAAMUHU_ALAYNAA:64975,ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM:65008,REPLACEMENT_CHARACTER:65533,LINEAR_B_SYLLABLE_B008_A:65536,CP_EFFFF:983039,CP_10FFFF:1114111};function isControl(e){return e>=$.NULL&&e<=$.US}function isWhitespace(e){return e===$.TABULATION||e===$.SPACE}function isEOL(e){return e===$.LINE_FEED||e===$.CARRIAGE_RETURN}function isUpperLetter(e){return e>=$.LATIN_CAPITAL_A&&e<=$.LATIN_CAPITAL_Z}function isLowerLetter(e){return e>=$.LATIN_SMALL_A&&e<=$.LATIN_SMALL_Z}function isLetter(e){return isLowerLetter(e)||isUpperLetter(e)}function isDigit(e){return e>=$.DIGIT_0&&e<=$.DIGIT_9}function isHexDig(e){return isDigit(e)||e>=$.LATIN_SMALL_A&&e<=$.LATIN_SMALL_F||e>=$.LATIN_CAPITAL_A&&e<=$.LATIN_CAPITAL_F}function isOctalDig(e){return e>=$.DIGIT_0&&e<=$.DIGIT_7}function isUnicodeScalarValue(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function sortedLastIndex(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1,a=e[i];if(a===t)return i+1;a<t?n=i+1:r=i}return n}var Locations=class{constructor(){this.offsets=[]}addOffset(e){for(let t=this.offsets.length-1;t>=0;t--){let n=this.offsets[t];if(n===e)return;if(n<e)break}this.offsets.push(e)}getLocFromIndex(e){let t=sortedLastIndex(this.offsets,e)+1;return{line:t,column:e-(t===1?0:this.offsets[t-2])}}},CodePointIterator=class{constructor(e){this.locs=new Locations,this.lastCodePoint=$.NULL,this.start=-1,this.end=0,this.text=e}next(){return this.lastCodePoint===$.EOF?$.EOF:this.lastCodePoint=this.moveAt(this.end)}getLocFromIndex(e){return this.locs.getLocFromIndex(e)}eat(e){return this.text.codePointAt(this.end)===e&&(this.next(),!0)}moveAt(e){this.start=this.end=e;let t=this.text.codePointAt(this.start)??$.EOF;if(t===$.EOF)return this.end=this.start,t;if(this.end+=t>=65536?2:1,t===$.LINE_FEED)this.locs.addOffset(this.end);else if(t===$.CARRIAGE_RETURN)return this.text.codePointAt(this.end)===$.LINE_FEED&&(this.end++,this.locs.addOffset(this.end)),$.LINE_FEED;return t}};const gc=typeof BigInt<`u`,_c={16:`0x`,10:``,8:`0o`,2:`0b`},vc={[$.QUOTATION_MARK]:$.QUOTATION_MARK,[$.BACKSLASH]:$.BACKSLASH,[$.LATIN_SMALL_B]:$.BACKSPACE,[$.LATIN_SMALL_F]:$.FORM_FEED,[$.LATIN_SMALL_N]:$.LINE_FEED,[$.LATIN_SMALL_R]:$.CARRIAGE_RETURN,[$.LATIN_SMALL_T]:$.TABULATION},yc={...vc,[$.LATIN_SMALL_E]:$.ESCAPE};var Tokenizer=class{constructor(e,t){this.backCode=!1,this.lastCodePoint=$.NULL,this.state=`DATA`,this.token=null,this.tokenStart=-1,this.valuesEnabled=!1,this.text=e,this.parserOptions=t||{},this.codePointIterator=new CodePointIterator(e),this.tomlVersion=getTOMLVer(this.parserOptions.tomlVersion),this.ESCAPES=this.tomlVersion.gte(1,1)?yc:vc}get start(){return this.codePointIterator.start}get end(){return this.codePointIterator.end}getLocFromIndex(e){return this.codePointIterator.getLocFromIndex(e)}reportParseError(e,t){let n=this.codePointIterator.start,r=this.codePointIterator.getLocFromIndex(n);throw new ParseError(e,n,r.line,r.column,t)}nextToken(){let e=this.token;if(e!=null)return this.token=null,e;let t=this.lastCodePoint;for(;t!==$.EOF&&!this.token;){t=this.nextCode();let e=this[this.state](t);if(!e)throw Error(`Unknown error: pre state=${this.state}`);this.state=e}return e=this.token,this.token=null,e}nextCode(){return this.lastCodePoint===$.EOF?$.EOF:this.backCode?(this.backCode=!1,this.lastCodePoint):this.lastCodePoint=this.codePointIterator.next()}eatCode(e){return this.lastCodePoint===$.EOF?!1:this.backCode?this.lastCodePoint===e&&(this.backCode=!1,!0):this.codePointIterator.eat(e)}moveAt(e){this.backCode&&=!1,this.lastCodePoint=this.codePointIterator.moveAt(e)}back(e){return this.backCode=!0,e}punctuatorToken(){this.startToken(),this.endToken(`Punctuator`,`end`)}startToken(){this.tokenStart=this.codePointIterator.start}endToken(e,t,n,r){let{tokenStart:i}=this,a=this.codePointIterator[t],o=[i,a],s={start:this.codePointIterator.getLocFromIndex(i),end:this.codePointIterator.getLocFromIndex(a)};if(e===`Block`)this.token={type:e,value:this.text.slice(i+1,a),range:o,loc:s};else{let t,c=this.text.slice(i,a);if(e===`BasicString`||e===`LiteralString`||e===`MultiLineBasicString`||e===`MultiLineLiteralString`)t={type:e,value:c,string:n,range:o,loc:s};else if(e===`Integer`){let i=n;t={type:e,value:c,number:parseInt(i,r),bigint:gc?BigInt(_c[r]+i):null,range:o,loc:s}}else t=e===`Float`?{type:e,value:c,number:n,range:o,loc:s}:e===`Boolean`?{type:e,value:c,boolean:n,range:o,loc:s}:e===`LocalDate`||e===`LocalTime`||e===`LocalDateTime`||e===`OffsetDateTime`?{type:e,value:c,date:n,range:o,loc:s}:{type:e,value:c,range:o,loc:s};this.token=t}}DATA(e){for(;isWhitespace(e)||isEOL(e);)e=this.nextCode();if(e===$.HASH)return this.startToken(),`COMMENT`;if(e===$.QUOTATION_MARK)return this.startToken(),`BASIC_STRING`;if(e===$.SINGLE_QUOTE)return this.startToken(),`LITERAL_STRING`;if(e===$.DOT||e===$.EQUALS_SIGN||e===$.LEFT_BRACKET||e===$.RIGHT_BRACKET||e===$.LEFT_BRACE||e===$.RIGHT_BRACE||e===$.COMMA)return this.punctuatorToken(),`DATA`;if(this.valuesEnabled){if(e===$.DASH||e===$.PLUS_SIGN)return this.startToken(),`SIGN`;if(e===$.LATIN_SMALL_N||e===$.LATIN_SMALL_I)return this.startToken(),this.back(`NAN_OR_INF`);if(isDigit(e))return this.startToken(),this.back(`NUMBER`);if(e===$.LATIN_SMALL_T||e===$.LATIN_SMALL_F)return this.startToken(),this.back(`BOOLEAN`)}else if(isUnquotedKeyChar(e,this.tomlVersion))return this.startToken(),`BARE`;return e===$.EOF?`DATA`:this.reportParseError(`unexpected-char`)}COMMENT(e){let t=this.tomlVersion.gte(1,1)?e=>{isNonEOL(e)||this.reportParseError(`invalid-comment-character`,{cp:JSON.stringify(String.fromCodePoint(e)).slice(1,-1)})}:e=>{isControlOtherThanTab(e)&&this.reportParseErrorControlChar()};for(;!isEOL(e)&&e!==$.EOF;)t(e),e=this.nextCode();return this.endToken(`Block`,`start`),`DATA`}BARE(e){for(;isUnquotedKeyChar(e,this.tomlVersion);)e=this.nextCode();return this.endToken(`Bare`,`start`),this.back(`DATA`)}BASIC_STRING(e){if(e===$.QUOTATION_MARK)return e=this.nextCode(),e===$.QUOTATION_MARK?`MULTI_LINE_BASIC_STRING`:(this.endToken(`BasicString`,`start`,``),this.back(`DATA`));let t=[];for(;e!==$.QUOTATION_MARK&&e!==$.EOF&&e!==$.LINE_FEED;){if(isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.BACKSLASH){e=this.nextCode();let n=this.ESCAPES[e];if(n){t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}return this.reportParseError(`invalid-char-in-escape-sequence`)}t.push(e),e=this.nextCode()}return e===$.QUOTATION_MARK?(this.endToken(`BasicString`,`end`,String.fromCodePoint(...t)),`DATA`):this.reportParseError(`unterminated-string`)}MULTI_LINE_BASIC_STRING(e){let t=[];for(e===$.LINE_FEED&&(e=this.nextCode());e!==$.EOF;){if(e!==$.LINE_FEED&&isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.QUOTATION_MARK){let e=this.codePointIterator.start;if(this.eatCode($.QUOTATION_MARK)&&this.eatCode($.QUOTATION_MARK))return this.eatCode($.QUOTATION_MARK)&&(t.push($.QUOTATION_MARK),this.eatCode($.QUOTATION_MARK)&&(t.push($.QUOTATION_MARK),this.eatCode($.QUOTATION_MARK)))?(this.moveAt(e),this.reportParseError(`invalid-three-quotes`)):(this.endToken(`MultiLineBasicString`,`end`,String.fromCodePoint(...t)),`DATA`);this.moveAt(e)}if(e===$.BACKSLASH){e=this.nextCode();let n=this.ESCAPES[e];if(n){t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}if(e===$.LINE_FEED){for(e=this.nextCode();isWhitespace(e)||e===$.LINE_FEED;)e=this.nextCode();continue}if(isWhitespace(e)){let t=!0,n=this.codePointIterator.start,r;for(;(r=this.nextCode())!==$.EOF&&r!==$.LINE_FEED;)if(!isWhitespace(r)){this.moveAt(n),t=!1;break}if(t){for(e=this.nextCode();isWhitespace(e)||e===$.LINE_FEED;)e=this.nextCode();continue}}return this.reportParseError(`invalid-char-in-escape-sequence`)}t.push(e),e=this.nextCode()}return this.reportParseError(`unterminated-string`)}LITERAL_STRING(e){if(e===$.SINGLE_QUOTE)return e=this.nextCode(),e===$.SINGLE_QUOTE?`MULTI_LINE_LITERAL_STRING`:(this.endToken(`LiteralString`,`start`,``),this.back(`DATA`));let t=[];for(;e!==$.SINGLE_QUOTE&&e!==$.EOF&&e!==$.LINE_FEED;){if(isControlOtherThanTab(e))return this.reportParseErrorControlChar();t.push(e),e=this.nextCode()}return e===$.SINGLE_QUOTE?(this.endToken(`LiteralString`,`end`,String.fromCodePoint(...t)),`DATA`):this.reportParseError(`unterminated-string`)}MULTI_LINE_LITERAL_STRING(e){let t=[];for(e===$.LINE_FEED&&(e=this.nextCode());e!==$.EOF;){if(e!==$.LINE_FEED&&isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.SINGLE_QUOTE){let e=this.codePointIterator.start;if(this.eatCode($.SINGLE_QUOTE)&&this.eatCode($.SINGLE_QUOTE))return this.eatCode($.SINGLE_QUOTE)&&(t.push($.SINGLE_QUOTE),this.eatCode($.SINGLE_QUOTE)&&(t.push($.SINGLE_QUOTE),this.eatCode($.SINGLE_QUOTE)))?(this.moveAt(e),this.reportParseError(`invalid-three-quotes`)):(this.endToken(`MultiLineLiteralString`,`end`,String.fromCodePoint(...t)),`DATA`);this.moveAt(e)}t.push(e),e=this.nextCode()}return this.reportParseError(`unterminated-string`)}SIGN(e){return e===$.LATIN_SMALL_N||e===$.LATIN_SMALL_I?this.back(`NAN_OR_INF`):isDigit(e)?this.back(`NUMBER`):this.reportParseError(`unexpected-char`)}NAN_OR_INF(e){if(e===$.LATIN_SMALL_N){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_A)&&this.eatCode($.LATIN_SMALL_N))return this.endToken(`Float`,`end`,NaN),`DATA`;this.moveAt(e)}else if(e===$.LATIN_SMALL_I){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_N)&&this.eatCode($.LATIN_SMALL_F))return this.endToken(`Float`,`end`,this.text[this.tokenStart]===`-`?-1/0:1/0),`DATA`;this.moveAt(e)}return this.reportParseError(`unexpected-char`)}NUMBER(e){let t=this.text[this.tokenStart],n=t===`+`?$.PLUS_SIGN:t===`-`?$.DASH:$.NULL;if(e===$.DIGIT_0){if(n===$.NULL){let e=this.codePointIterator.start,t=this.nextCode();if(isDigit(t)){let n=this.nextCode();if(n===$.COLON)return this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint($.DIGIT_0,t)),minute:0,second:0},`TIME_MINUTE`;if(isDigit(n)){let e=this.nextCode();if(isDigit(e)&&this.eatCode($.DASH))return this.data={hasDate:!0,year:Number(String.fromCodePoint($.DIGIT_0,t,n,e)),month:0,day:0,hour:0,minute:0,second:0},`DATE_MONTH`}return this.moveAt(e),this.reportParseError(`invalid-leading-zero`)}this.moveAt(e)}return e=this.nextCode(),e===$.LATIN_SMALL_X||e===$.LATIN_SMALL_O||e===$.LATIN_SMALL_B?n===$.NULL?e===$.LATIN_SMALL_X?`HEX`:e===$.LATIN_SMALL_O?`OCTAL`:`BINARY`:this.reportParseError(`unexpected-char`):e===$.LATIN_SMALL_E||e===$.LATIN_CAPITAL_E?(this.data={minus:n===$.DASH,left:[$.DIGIT_0]},`EXPONENT_RIGHT`):e===$.DOT?(this.data={minus:n===$.DASH,absInt:[$.DIGIT_0]},`FRACTIONAL_RIGHT`):(this.endToken(`Integer`,`start`,`0`,10),this.back(`DATA`))}let{out:r,nextCp:i,hasUnderscore:a}=this.parseDigits(e,isDigit);return i===$.DASH&&n===$.NULL&&!a&&r.length===4?(this.data={hasDate:!0,year:Number(String.fromCodePoint(...r)),month:0,day:0,hour:0,minute:0,second:0},`DATE_MONTH`):i===$.COLON&&n===$.NULL&&!a&&r.length===2?(this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint(...r)),minute:0,second:0},`TIME_MINUTE`):i===$.LATIN_SMALL_E||i===$.LATIN_CAPITAL_E?(this.data={minus:n===$.DASH,left:r},`EXPONENT_RIGHT`):i===$.DOT?(this.data={minus:n===$.DASH,absInt:r},`FRACTIONAL_RIGHT`):(this.endToken(`Integer`,`start`,n===$.DASH?String.fromCodePoint($.DASH,...r):String.fromCodePoint(...r),10),this.back(`DATA`))}HEX(e){let{out:t}=this.parseDigits(e,isHexDig);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),16),this.back(`DATA`)}OCTAL(e){let{out:t}=this.parseDigits(e,isOctalDig);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),8),this.back(`DATA`)}BINARY(e){let{out:t}=this.parseDigits(e,e=>e===$.DIGIT_0||e===$.DIGIT_1);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),2),this.back(`DATA`)}FRACTIONAL_RIGHT(e){let{minus:t,absInt:n}=this.data,{out:r,nextCp:i}=this.parseDigits(e,isDigit),a=[...n,$.DOT,...r];if(i===$.LATIN_SMALL_E||i===$.LATIN_CAPITAL_E)return this.data={minus:t,left:a},`EXPONENT_RIGHT`;let o=Number(t?String.fromCodePoint($.DASH,...a):String.fromCodePoint(...a));return this.endToken(`Float`,`start`,o),this.back(`DATA`)}EXPONENT_RIGHT(e){let{left:t,minus:n}=this.data,r=!1;(e===$.DASH||e===$.PLUS_SIGN)&&(r=e===$.DASH,e=this.nextCode());let{out:i}=this.parseDigits(e,isDigit),a=i;r&&a.unshift($.DASH);let o=Number(n?String.fromCodePoint($.DASH,...t,$.LATIN_SMALL_E,...a):String.fromCodePoint(...t,$.LATIN_SMALL_E,...a));return this.endToken(`Float`,`start`,o),this.back(`DATA`)}BOOLEAN(e){if(e===$.LATIN_SMALL_T){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_R)&&this.eatCode($.LATIN_SMALL_U)&&this.eatCode($.LATIN_SMALL_E))return this.endToken(`Boolean`,`end`,!0),`DATA`;this.moveAt(e)}else if(e===$.LATIN_SMALL_F){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_A)&&this.eatCode($.LATIN_SMALL_L)&&this.eatCode($.LATIN_SMALL_S)&&this.eatCode($.LATIN_SMALL_E))return this.endToken(`Boolean`,`end`,!1),`DATA`;this.moveAt(e)}return this.reportParseError(`unexpected-char`)}DATE_MONTH(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e))||(e=this.nextCode(),e!==$.DASH))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start,r=this.data;return r.month=Number(this.text.slice(t,n)),`DATE_DAY`}DATE_DAY(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;if(r.day=Number(this.text.slice(t,n)),!isValidDate(r.year,r.month,r.day))return this.reportParseError(`invalid-date`);if(e=this.nextCode(),e===$.LATIN_CAPITAL_T||e===$.LATIN_SMALL_T)return`TIME_HOUR`;if(e===$.SPACE){let e=this.codePointIterator.start;if(isDigit(this.nextCode())&&isDigit(this.nextCode()))return this.moveAt(e),`TIME_HOUR`;this.moveAt(e)}let i=getDateFromDateTimeData(r,``);return this.endToken(`LocalDate`,`start`,i),this.back(`DATA`)}TIME_HOUR(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e))||(e=this.nextCode(),e!==$.COLON))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start,r=this.data;return r.hour=Number(this.text.slice(t,n)),`TIME_MINUTE`}TIME_MINUTE(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;return r.minute=Number(this.text.slice(t,n)),e=this.nextCode(),e===$.COLON?`TIME_SECOND`:this.tomlVersion.lt(1,1)?this.reportParseError(`unexpected-char`):isValidTime(r.hour,r.minute,r.second)?this.processTimeEnd(e,r):this.reportParseError(`invalid-time`)}TIME_SECOND(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;return r.second=Number(this.text.slice(t,n)),isValidTime(r.hour,r.minute,r.second)?(e=this.nextCode(),e===$.DOT?`TIME_SEC_FRAC`:this.processTimeEnd(e,r)):this.reportParseError(`invalid-time`)}TIME_SEC_FRAC(e){if(!isDigit(e))return this.reportParseError(`unexpected-char`);let t=this.codePointIterator.start;for(;isDigit(e);)e=this.nextCode();let n=this.codePointIterator.start,r=this.data;return r.frac=this.text.slice(t,n),this.processTimeEnd(e,r)}processTimeEnd(e,t){if(t.hasDate){if(e===$.DASH||e===$.PLUS_SIGN)return t.offsetSign=e,`TIME_OFFSET`;if(e===$.LATIN_CAPITAL_Z||e===$.LATIN_SMALL_Z){let e=getDateFromDateTimeData(t,`Z`);return this.endToken(`OffsetDateTime`,`end`,e),`DATA`}let n=getDateFromDateTimeData(t,``);return this.endToken(`LocalDateTime`,`start`,n),this.back(`DATA`)}let n=getDateFromDateTimeData(t,``);return this.endToken(`LocalTime`,`start`,n),this.back(`DATA`)}TIME_OFFSET(e){if(!isDigit(e))return this.reportParseError(`unexpected-char`);let t=this.codePointIterator.start;if(e=this.nextCode(),!isDigit(e)||(e=this.nextCode(),e!==$.COLON))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start;e=this.nextCode();let r=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let i=this.codePointIterator.end,a=Number(this.text.slice(t,n)),o=Number(this.text.slice(r,i));if(!isValidTime(a,o,0))return this.reportParseError(`invalid-time`);let s=this.data,c=getDateFromDateTimeData(s,`${String.fromCodePoint(s.offsetSign)}${padStart(a,2)}:${padStart(o,2)}`);return this.endToken(`OffsetDateTime`,`end`,c),`DATA`}parseDigits(e,t){if(e===$.UNDERSCORE)return this.reportParseError(`invalid-underscore`);if(!t(e))return this.reportParseError(`unexpected-char`);let n=[],r=$.NULL,i=!1;for(;t(e)||e===$.UNDERSCORE;){if(e===$.UNDERSCORE){if(i=!0,r===$.UNDERSCORE)return this.reportParseError(`invalid-underscore`)}else n.push(e);r=e,e=this.nextCode()}return r===$.UNDERSCORE?this.reportParseError(`invalid-underscore`):{out:n,nextCp:e,hasUnderscore:i}}parseUnicode(e){let t=this.codePointIterator.start,n=this.codePointIterator.end,r=0,i;for(;(i=this.nextCode())!==$.EOF;){if(!isHexDig(i))return this.moveAt(t),this.reportParseError(`invalid-char-in-escape-sequence`);if(r++,r>=e)break}let a=this.codePointIterator.end,o=this.text.slice(n,a),s=parseInt(o,16);return isUnicodeScalarValue(s)?s:this.reportParseError(`invalid-code-point`,{cp:o})}reportParseErrorControlChar(){return this.reportParseError(`invalid-control-character`)}};function isUnquotedKeyChar(e,t){return isLetter(e)||isDigit(e)||e===$.UNDERSCORE||e===$.DASH?!0:(t.lt(1,1),!1)}function isControlOtherThanTab(e){return isControl(e)&&e!==$.TABULATION||e===$.DELETE}function isNonEOL(e){return e===$.TABULATION||$.SPACE<=e&&e<=$.TILDE||isNonAscii(e)}function isNonAscii(e){return $.PAD<=e&&e<=$.CP_D7FF||$.CP_E000<=e&&e<=$.CP_10FFFF}function isValidDate(e,t,n){return e>=0&&t<=12&&t>=1&&n>=1&&n<=(t===2?e&3||!(e%25)&&e&15?28:29:30+(t+(t>>3)&1))}function isValidTime(e,t,n){return!(e>=24||e<0||t>59||t<0||n>60||n<0)}function getDateFromDateTimeData(e,t){let n=padStart(e.year,4),r=e.month?padStart(e.month,2):`01`,i=e.day?padStart(e.day,2):`01`,a=padStart(e.hour,2),o=padStart(e.minute,2),s=padStart(e.second,2),c=`${n}-${r}-${i}`,l=e.frac?`.${e.frac}`:``,u=new Date(`${c}T${a}:${o}:${s}${l}${t}`);return!isNaN(u.getTime())||e.second!==60?u:new Date(`${c}T${a}:${o}:59${l}${t}`)}function padStart(e,t){return String(e).padStart(t,`0`)}const bc=Symbol(`VALUE_KIND_VALUE`),xc=Symbol(`VALUE_KIND_INTERMEDIATE`);var KeysResolver=class{constructor(e){this.rootKeys=new Map,this.tables=[],this.ctx=e}applyResolveKeyForTable(e){let t=this.rootKeys,n=e.key.keys.length-1;for(let r=0;r<n;r++){let n=e.key.keys[r],i=toKeyName(n);e.resolvedKey.push(i);let a=t.get(i);if(!a)a={node:n,keys:new Map},t.set(i,a);else if(a.table===`array`){let t=a.peekIndex;e.resolvedKey.push(t),a=a.keys.get(t)}t=a.keys}let r=e.key.keys[n],i=toKeyName(r);e.resolvedKey.push(i);let a=t.get(i);if(!a){if(e.kind===`array`){e.resolvedKey.push(0);let n={node:r,keys:new Map};t.set(i,{table:e.kind,node:r,keys:new Map([[0,n]]),peekIndex:0}),this.tables.push({node:e,keys:n.keys})}else{let n={table:e.kind,node:r,keys:new Map};t.set(i,n),this.tables.push({node:e,keys:n.keys})}}else if(!a.table){if(e.kind===`array`)this.ctx.reportParseError(`dupe-keys`,r);else{let n={table:e.kind,node:r,keys:a.keys};t.set(i,n),this.tables.push({node:e,keys:n.keys})}}else if(a.table===`array`){if(e.kind===`array`){let t={node:r,keys:new Map},n=a.peekIndex+1;e.resolvedKey.push(n),a.keys.set(n,t),a.peekIndex=n,this.tables.push({node:e,keys:t.keys})}else this.ctx.reportParseError(`dupe-keys`,r)}else this.ctx.reportParseError(`dupe-keys`,r)}verifyDuplicateKeys(e){for(let t of e.body)t.type===`TOMLKeyValue`&&verifyDuplicateKeysForKeyValue(this.ctx,this.rootKeys,t);for(let{node:e,keys:t}of this.tables)for(let n of e.body)verifyDuplicateKeysForKeyValue(this.ctx,t,n)}};function verifyDuplicateKeysForKeyValue(e,t,n){let r=t,i=last(n.key.keys);for(let t of n.key.keys){let n=toKeyName(t),a=r.get(n);a?((a.value===bc||i===t||a.table)&&e.reportParseError(`dupe-keys`,getAfterNode(t,a.node)),a.value=xc):(a=i===t?{value:bc,node:t,keys:new Map}:{value:xc,node:t,keys:new Map},r.set(n,a)),r=a.keys}n.value.type===`TOMLInlineTable`?verifyDuplicateKeysForInlineTable(e,r,n.value):n.value.type===`TOMLArray`&&verifyDuplicateKeysForArray(e,r,n.value)}function verifyDuplicateKeysForInlineTable(e,t,n){for(let r of n.body)verifyDuplicateKeysForKeyValue(e,t,r)}function verifyDuplicateKeysForArray(e,t,n){let r=t;for(let i=0;i<n.elements.length;i++){let a=n.elements[i],o=r.get(i);o?e.reportParseError(`dupe-keys`,getAfterNode(a,o.node)):(o={value:bc,node:a,keys:new Map},t.set(i,o),a.type===`TOMLInlineTable`?verifyDuplicateKeysForInlineTable(e,o.keys,a):a.type===`TOMLArray`&&verifyDuplicateKeysForArray(e,o.keys,a))}}function getAfterNode(e,t){return e.range[0]<=t.range[0]?t:e}var Context=class{constructor(e){this.tokens=[],this.comments=[],this.back=null,this.stateStack=[],this.needNewLine=!1,this.needSameLine=!1,this.currToken=null,this.prevToken=null,this.valueContainerStack=[],this.tokenizer=new Tokenizer(e.text,e.parserOptions),this.topLevelTable=e.topLevelTable,this.table=e.topLevelTable,this.keysResolver=new KeysResolver(this)}nextToken(e){if(this.prevToken=this.currToken,this.back?(this.currToken=this.back,this.back=null):this.currToken=this._nextTokenFromTokenizer(e),(this.needNewLine||this.needSameLine||e?.needSameLine)&&this.prevToken&&this.currToken){if(this.prevToken.loc.end.line===this.currToken.loc.start.line){if(this.needNewLine)return this.reportParseError(`missing-newline`,this.currToken)}else{let t=this.needSameLine||e?.needSameLine;if(t)return this.reportParseError(t,this.currToken)}}return this.needNewLine=!1,this.needSameLine=!1,this.currToken}_nextTokenFromTokenizer(e){let t=this.tokenizer.valuesEnabled;e?.valuesEnabled&&(this.tokenizer.valuesEnabled=e.valuesEnabled);let n=this.tokenizer.nextToken();for(;n&&n.type===`Block`;)this.comments.push(n),n=this.tokenizer.nextToken();return n&&this.tokens.push(n),this.tokenizer.valuesEnabled=t,n}backToken(){if(this.back)throw Error(`Illegal state`);this.back=this.currToken,this.currToken=this.prevToken}addValueContainer(e){this.valueContainerStack.push(e),this.tokenizer.valuesEnabled=!0}consumeValueContainer(){let e=this.valueContainerStack.pop();return this.tokenizer.valuesEnabled=this.valueContainerStack.length>0,e}applyResolveKeyForTable(e){this.keysResolver.applyResolveKeyForTable(e)}verifyDuplicateKeys(){this.keysResolver.verifyDuplicateKeys(this.topLevelTable)}reportParseError(e,t){let n,r,i;if(t)n=t.range[0],r=t.loc.start.line,i=t.loc.start.column;else{n=this.tokenizer.start;let e=this.tokenizer.getLocFromIndex(n);r=e.line,i=e.column}throw new ParseError(e,n,r,i)}};const Sc={VALUE:`missing-value`},Cc={BasicString:`basic`,MultiLineBasicString:`basic`,LiteralString:`literal`,MultiLineLiteralString:`literal`},wc={BasicString:`basic`,LiteralString:`literal`},Tc={OffsetDateTime:`offset-date-time`,LocalDateTime:`local-date-time`,LocalDate:`local-date`,LocalTime:`local-time`};var TOMLParser=class{constructor(e,t){this.text=e,this.parserOptions=t||{},this.tomlVersion=getTOMLVer(this.parserOptions.tomlVersion)}parse(){let e={type:`Program`,body:[],sourceType:`module`,tokens:[],comments:[],parent:null,range:[0,0],loc:{start:{line:1,column:0},end:{line:1,column:0}}},t={type:`TOMLTopLevelTable`,body:[],parent:e,range:cloneRange(e.range),loc:cloneLoc(e.loc)};e.body=[t];let n=new Context({text:this.text,parserOptions:this.parserOptions,topLevelTable:t}),r=n.nextToken();if(r){for(t.range[0]=r.range[0],t.loc.start=clonePos(r.loc.start);r;){let e=n.stateStack.pop()||`TABLE`;n.stateStack.push(...this[e](r,n)),r=n.nextToken()}let e=n.stateStack.pop()||`TABLE`;if(e in Sc)return n.reportParseError(Sc[e],null);n.table.type===`TOMLTable`&&applyEndLoc(n.table,last(n.table.body)),applyEndLoc(t,last(t.body))}n.verifyDuplicateKeys(),e.tokens=n.tokens,e.comments=n.comments;let i=n.tokenizer.end,a=n.tokenizer.getLocFromIndex(i);return e.range[1]=i,e.loc.end={line:a.line,column:a.column},e}TABLE(e,t){return isBare(e)||isString(e)?this.processKeyValue(e,t.table,t):isLeftBracket(e)?this.processTable(e,t.topLevelTable,t):t.reportParseError(`unexpected-token`,e)}VALUE(e,t){return isString(e)||isMultiLineString(e)?this.processStringValue(e,t):isNumber(e)?this.processNumberValue(e,t):isBoolean(e)?this.processBooleanValue(e,t):isDateTime(e)?this.processDateTimeValue(e,t):isLeftBracket(e)?this.processArray(e,t):isLeftBrace(e)?this.processInlineTable(e,t):t.reportParseError(`unexpected-token`,e)}processTable(e,t,n){let r={type:`TOMLTable`,kind:`standard`,key:null,resolvedKey:[],body:[],parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};n.table.type===`TOMLTable`&&applyEndLoc(n.table,last(n.table.body)),t.body.push(r),n.table=r;let i=n.nextToken({needSameLine:`invalid-key-value-newline`});if(isLeftBracket(i)){if(e.range[1]<i.range[0])return n.reportParseError(`invalid-space`,i);r.kind=`array`,i=n.nextToken({needSameLine:`invalid-key-value-newline`})}if(isRightBracket(i))return n.reportParseError(`missing-key`,i);if(!i)return n.reportParseError(`unterminated-table-key`,null);if(i=this.processKeyNode(i,r,n).nextToken,!isRightBracket(i))return n.reportParseError(`unterminated-table-key`,i);if(r.kind===`array`){let e=i;if(i=n.nextToken({needSameLine:`invalid-key-value-newline`}),!isRightBracket(i))return n.reportParseError(`unterminated-table-key`,i);if(e.range[1]<i.range[0])return n.reportParseError(`invalid-space`,i)}return applyEndLoc(r,i),n.applyResolveKeyForTable(r),n.needNewLine=!0,[]}processKeyValue(e,t,n){let r={type:`TOMLKeyValue`,key:null,value:null,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.body.push(r);let{nextToken:i}=this.processKeyNode(e,r,n);return isEq(i)?(n.addValueContainer({parent:r,set:e=>(r.value=e,applyEndLoc(r,e),n.needNewLine=!0,[])}),n.needSameLine=`invalid-key-value-newline`,[`VALUE`]):n.reportParseError(`missing-equals-sign`,i)}processKeyNode(e,t,n){isDot(e)&&n.reportParseError(`invalid-leading-dot-in-key`,e);let r={type:`TOMLKey`,keys:[],parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.key=r;let i=e,a=null;do{if(isBare(i))this.processBareKey(i,r);else if(isString(i))this.processStringKey(i,r);else break;if(a=null,i=n.nextToken({needSameLine:`invalid-key-value-newline`}),!isDot(i))break;a=i,i=n.nextToken({needSameLine:`invalid-key-value-newline`})}while(i);return a&&n.reportParseError(isDot(i)?`invalid-consecutive-dots-in-key`:`invalid-trailing-dot-in-key`,a),applyEndLoc(r,last(r.keys)),{keyNode:r,nextToken:i}}processBareKey(e,t){let n={type:`TOMLBare`,name:e.value,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.keys.push(n)}processStringKey(e,t){let n={type:`TOMLQuoted`,kind:`string`,value:e.string,style:wc[e.type],multiline:!1,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.keys.push(n)}processStringValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:`string`,value:e.string,style:Cc[e.type],multiline:isMultiLineString(e),parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processNumberValue(e,t){let n=t.consumeValueContainer(),r=this.text,[i,a]=e.range,o=null,getNumberText=()=>o??=r.slice(i,a).replace(/_/g,``),s;return s=e.type===`Integer`?{type:`TOMLValue`,kind:`integer`,value:e.number,bigint:e.bigint,get number(){return getNumberText()},parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)}:{type:`TOMLValue`,kind:`float`,value:e.number,get number(){return getNumberText()},parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},n.set(s)}processBooleanValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:`boolean`,value:e.boolean,parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processDateTimeValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:Tc[e.type],value:e.date,datetime:e.value,parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processArray(e,t){let n=t.consumeValueContainer(),r={type:`TOMLArray`,elements:[],parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},i=t.nextToken({valuesEnabled:!0});return isRightBracket(i)?(applyEndLoc(r,i),n.set(r)):(t.backToken(),this.processArrayValue(r,n,t))}processArrayValue(e,t,n){return n.addValueContainer({parent:e,set:r=>{e.elements.push(r);let i=n.nextToken({valuesEnabled:!0}),a=isComma(i);return a&&(i=n.nextToken({valuesEnabled:!0})),isRightBracket(i)?(applyEndLoc(e,i),t.set(e)):a?(n.backToken(),this.processArrayValue(e,t,n)):n.reportParseError(i?`missing-comma`:`unterminated-array`,i)}}),[`VALUE`]}processInlineTable(e,t){let n=t.consumeValueContainer(),r={type:`TOMLInlineTable`,body:[],parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},i=this.tomlVersion.gte(1,1)?void 0:`invalid-inline-table-newline`,a=t.nextToken({needSameLine:i});if(a){if(isBare(a)||isString(a))return this.processInlineTableKeyValue(a,r,n,t);if(isRightBrace(a))return applyEndLoc(r,a),n.set(r)}return t.reportParseError(`unexpected-token`,a)}processInlineTableKeyValue(e,t,n,r){let i={type:`TOMLKeyValue`,key:null,value:null,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.body.push(i);let{nextToken:a}=this.processKeyNode(e,i,r);if(!isEq(a))return r.reportParseError(`missing-equals-sign`,a);let o=this.tomlVersion.gte(1,1)?void 0:`invalid-inline-table-newline`;return r.addValueContainer({parent:i,set:e=>{i.value=e,applyEndLoc(i,e);let a=r.nextToken({needSameLine:o});if(isComma(a)){if(a=r.nextToken({needSameLine:o}),a&&(isBare(a)||isString(a)))return this.processInlineTableKeyValue(a,t,n,r);if(isRightBrace(a)){if(this.tomlVersion.lt(1,1))return r.reportParseError(`invalid-trailing-comma-in-inline-table`,a)}else return r.reportParseError(a?`unexpected-token`:`unterminated-inline-table`,a)}return isRightBrace(a)?(applyEndLoc(t,a),n.set(t)):r.reportParseError(a?`missing-comma`:`unterminated-inline-table`,a)}}),r.needSameLine=`invalid-key-value-newline`,[`VALUE`]}};function isDot(e){return isPunctuator(e)&&e.value===`.`}function isEq(e){return isPunctuator(e)&&e.value===`=`}function isLeftBracket(e){return isPunctuator(e)&&e.value===`[`}function isRightBracket(e){return isPunctuator(e)&&e.value===`]`}function isLeftBrace(e){return isPunctuator(e)&&e.value===`{`}function isRightBrace(e){return isPunctuator(e)&&e.value===`}`}function isComma(e){return isPunctuator(e)&&e.value===`,`}function isPunctuator(e){return!!(e&&e.type===`Punctuator`)}function isBare(e){return e.type===`Bare`}function isString(e){return e.type===`BasicString`||e.type===`LiteralString`}function isMultiLineString(e){return e.type===`MultiLineBasicString`||e.type===`MultiLineLiteralString`}function isNumber(e){return e.type===`Integer`||e.type===`Float`}function isBoolean(e){return e.type===`Boolean`}function isDateTime(e){return e.type===`OffsetDateTime`||e.type===`LocalDateTime`||e.type===`LocalDate`||e.type===`LocalTime`}function applyEndLoc(e,t){t&&(e.range[1]=t.range[1],e.loc.end=clonePos(t.loc.end))}function cloneRange(e){return[e[0],e[1]]}function cloneLoc(e){return{start:clonePos(e.start),end:clonePos(e.end)}}function clonePos(e){return{line:e.line,column:e.column}}const Ec=unionWith({Program:[`body`],TOMLTopLevelTable:[`body`],TOMLTable:[`key`,`body`],TOMLKeyValue:[`key`,`value`],TOMLKey:[`keys`],TOMLArray:[`elements`],TOMLInlineTable:[`body`],TOMLBare:[],TOMLQuoted:[],TOMLValue:[]});function parseForESLint(e,t){return{ast:new TOMLParser(e,t).parse(),visitorKeys:Ec,services:{isTOML:!0}}}function parseTOML(e,t){return parseForESLint(e,t).ast}function nested(e,t){return e.reduceRight((e,t)=>({[t]:e}),t)}function renderTomlTable(e,t){return stringify(nested(e,t))}function appendTomlTable(e,t,n){return`${e}${e===``||e.endsWith(`
|
|
479
|
+
`))}function writeShowStderr(e,t){for(let n of e){if(t===`text`){for(let e of n.warnings)process.stderr.write(`warning: ${e}\n`);n.trace&&process.stderr.write(`${renderText({[`trace ${n.name}`]:n.trace})}\n`)}n.status!==`found`&&process.stderr.write(`error: ${missReason(n)}\n`)}}const ac=command({name:`show`,description:`Print one or more references, each resolved through the tiers and combined as its layers ask.`,arguments:[{name:`names`,description:"Reference names, without the `.md` extension; `<plugin>/<name>` picks one plugin.",type:In(K())}],options:{root:ic,trace:{description:`Report every path checked, the file that matched, the merge mode, and why a layer was dropped.`,type:q(Fn())},format:{description:`Output format: text (default) writes the documents themselves; toon and json return an array with metadata.`,type:q(K()),default:`text`}},async run(e){try{let t=parseFormat(e.format),n=e.names.map(parseReferenceName);if(!n.length)throw Error(`Name at least one reference.`);let r=E(),i=await layersFor(e,r),display=e=>collapseHome(r,e),a=n.map(t=>{let n=resolveReference(t,i,{display}),a=n.status===`missing`?searchReferences(t.name,i,{display}).slice(0,3).map(e=>e.name):[];return showEntry(n,r,a,!!e.trace)});return t===`text`?writeShowText(a):writeResult(a,t),writeShowStderr(a,t),a.every(e=>e.status===`found`)?O.success:O.error}catch(e){return fail(e,`Reference lookup failed.`)}}}),oc={description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`},sc=command({name:`list`,description:`List every layer, and every reference at every layer that holds it, marked used or shadowed.`,options:{root:ic,format:oc},async run(e){try{let t=parseFormat(e.format),n=E(),r=await layersFor(e,n),{rows:i,warnings:a}=listReferences(r,{display:e=>collapseHome(n,e)}),o={layers:r.map(({tier:e,plugins:t,dir:r,status:i})=>({tier:e,plugin:t[0]??``,path:collapseHome(n,r),status:i})),references:i.length?i.map(e=>({...e,path:collapseHome(n,e.path)})):`0 references — no layer holds one`};return a.length&&(o.warnings=a),writeResult(o,t),O.success}catch(e){return fail(e,`Reference listing failed.`)}}}),cc=command({name:`search`,description:`Find references by name, description, tags, headings, or body, best match first.`,arguments:[{name:`query`,description:`What the reference is about.`,type:K()}],options:{root:ic,format:oc},async run(e){try{let t=parseFormat(e.format),n=e.query.trim();if(!n)throw Error(`Search needs a query.`);let r=E(),i=searchReferences(n,await layersFor(e,r),{display:e=>collapseHome(r,e)});return writeResult({query:n,references:i.length?i:`0 references match "${n}"`},t),O.success}catch(e){return fail(e,`Reference search failed.`)}}}),lc={project:`everyone working in this repository`,user:`only you, in every repository`,plugin:`read-only; override it with the project or user file`};function slotStatus(e){return e===`missing`?`empty`:e.startsWith(`shadowed`)?`shadowed`:e}function callerCopy(e,t){return[v(e,`references`,`${t}.md`),v(e,`references`,`governances`,`${t}.md`)].find(e=>r(e))}function callerStatus(e){return e.status===`missing`?`used`:e.status===`ambiguous`?`not read — the name is ambiguous`:`shadowed`}const uc=command({name:`where`,description:`List the project and user files an override of a reference can be written to, highest precedence first, with the copy each overrides and who it applies to.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension; `<plugin>/<name>` picks one plugin.",type:K()}],options:{root:ic,caller:{description:`Folder of the skill that loads the reference, so its own copy is reported as the reference skill's Load mode reads it.`,type:q(K())},format:oc},async run(e){try{let t=parseFormat(e.format),n=parseReferenceName(e.name),r=E(),i=await layersFor(e,r),a=S(e.root??process.cwd()),display=e=>collapseHome(r,e),o=resolveReference(n,i,{display}),s=layersFor$2(n,i),c=[];for(let[e,t]of o.trace.entries()){let r=s[e],i=lc[t.tier];if(!i||(r.status||t.tier===`plugin`)&&!t.found)continue;let o=t.found?t.path:v(r.dir,`${n.name}.md`);c.push({layer:t.tier===`plugin`?`plugin ${t.plugin}`:t.tier,path:t.tier===`project`?x(a,o):display(o),status:slotStatus(t.outcome),scope:i})}let l=e.caller===void 0?void 0:callerCopy(S(e.caller),n.name);l&&c.push({layer:`caller`,path:display(l),status:callerStatus(o),scope:`read-only; the calling skill's own copy, read only when no layer holds the name`});let u={name:n.name,root:display(a),slots:c,merge:"The default, first-wins, makes the override replace the whole document. Set `merge: merge-sections` in its frontmatter to keep the sections it does not redefine."};return o.status===`ambiguous`&&(u.plugins=o.plugins),o.warnings.length&&(u.warnings=o.warnings),writeResult(u,t),o.status===`ambiguous`?(process.stderr.write(`error: ${missReason({name:n.raw,status:`ambiguous`,plugins:o.plugins,warnings:[]})}\n`),O.error):O.success}catch(e){return fail(e,`Reference placement lookup failed.`)}}});function parseScope(e){if(e!==`project`&&e!==`user`)throw Error(`--scope must be project or user.`);return e}const dc=command({name:`reference`,description:`Read on-demand reference documents by name, layered across the managed, project, user, and plugin tiers, and start a new one in the project or user tier.`,commands:[ac,sc,cc,uc,command({name:`create`,description:`Start a new reference in the project or user tier from a template, marked merge-sections when it overrides a copy below. Never overwrites.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:K()}],options:{root:ic,template:{description:"File whose text is written as it is, frontmatter included. Defaults to a built-in template of top-level `##` sections with no `#` title.",type:q(K())},scope:{description:"Tier to write: project (default), `.agents/references/` at the root, or user, `~/.agents/references/`.",type:q(K()),default:`project`},"dry-run":{description:`Print the target path and the exact content, and write nothing.`,type:q(Fn())},format:{description:`Output format: text (default) writes the path, then the content or the trace; toon and json return an object.`,type:q(K()),default:`text`}},async run(e){try{let t=parseFormat(e.format),n=parseReferenceName(e.name);if(n.plugin!==void 0)throw Error(`an override is written under the bare name, which every tier resolves; ask for "${n.name}".`);let r=parseScope(e.scope),i=readTemplate(e.template===void 0?void 0:S(e.template)),o=E(),s=r===`project`?projectReferencesDir(S(e.root??process.cwd())):v(o,`.agents`,`references`),c=v(s,`${n.name}.md`),display=e=>collapseHome(o,e),l=await layersFor(e,o),{trace:u}=resolveReference(n,l,{display}),d=l.findIndex(e=>e.dir===s);if(u[d]?.found)throw Error(`${display(u[d].path)} already holds "${n.name}"; change it with the reference skill's Update mode.`);let p=u.slice(0,d).find(e=>e.found&&e.merge===`first-wins`);if(p)throw Error(`the ${p.tier} copy ${display(p.path)} is first-wins, so nothing would read a new ${r} file; change that copy instead.`);let h=u.slice(d+1).some(e=>e.found)&&i.metadata.merge===void 0?withMergeSections(i.content):i.content,g=templateWarnings(i),_={name:n.name,scope:r,path:display(c),dryRun:!!e[`dry-run`],content:h,warnings:g};if(_.dryRun||(a(s,{recursive:!0}),m(c,h,{flag:`wx`}),_.trace=traceOf(resolveReference(n,l,{display}),o)),t!==`text`)writeResult(_,t);else{for(let e of g)process.stderr.write(`warning: ${e}\n`);_.trace?process.stdout.write(`${_.path}\n\n${renderText({trace:_.trace})}\n`):writeDocument(`${_.path}\n\n${h}`)}return O.success}catch(e){return fail(e,`Reference creation failed.`)}}})]});function initializeHarnesses({root:e,harnesses:t=[],copy:n=!1,force:r=!1}){let i=v(e,`.agents`,`skills`),o=countSkills(i);a(projectReferencesDir(e),{recursive:!0});let s=referenceNames(projectReferenceLayers(e)).length,c=selectHarnesses(e,t),{linked:l,skipped:u}=projectSkills({root:e,canonicalSkills:i,harnesses:c,copy:n,force:r});return{root:e,harnesses:c.map(e=>e.name),native:c.filter(e=>!e.project.skillsDirectory).map(e=>e.name),linked:l,skipped:u,deprecated:c.filter(e=>e.deprecated).map(e=>({name:e.name,replacedBy:e.deprecated})),skills:o,references:s,copied:n}}const fc=command({name:`init`,description:`Set up canonical agent skills for the harnesses already enabled in a repository.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:q(K())},harness:{description:`Comma-separated harnesses to enable in addition to Claude Code and Cursor, e.g. codex,gemini-cli.`,type:q(K())},copy:{description:`Copy skills instead of linking them.`,type:q(Fn())},force:{description:`Replace conflicting target skill directories. Names the targets to replace, comma-separated (e.g. .claude/skills); given alone it replaces every conflicting target.`,type:q(K())},format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`}},run(e){try{let t=parseFormat(e.format),n=parseHarnesses(e.harness);return writeResult(initializeHarnesses({root:e.root??process.cwd(),...n.length?{harnesses:n}:{},...e.copy===void 0?{}:{copy:e.copy},...e.force===void 0?{}:{force:parseForce(e.force)}}),t),O.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Harness initialization failed.`}\n`),O.error}}}),pc={ArrayExpression:[`elements`],ArrayPattern:[`elements`],ArrowFunctionExpression:[`params`,`body`],AssignmentExpression:[`left`,`right`],AssignmentPattern:[`left`,`right`],AwaitExpression:[`argument`],BinaryExpression:[`left`,`right`],BlockStatement:[`body`],BreakStatement:[`label`],CallExpression:[`callee`,`arguments`],CatchClause:[`param`,`body`],ChainExpression:[`expression`],ClassBody:[`body`],ClassDeclaration:[`id`,`superClass`,`body`],ClassExpression:[`id`,`superClass`,`body`],ConditionalExpression:[`test`,`consequent`,`alternate`],ContinueStatement:[`label`],DebuggerStatement:[],DoWhileStatement:[`body`,`test`],EmptyStatement:[],ExperimentalRestProperty:[`argument`],ExperimentalSpreadProperty:[`argument`],ExportAllDeclaration:[`exported`,`source`,`attributes`],ExportDefaultDeclaration:[`declaration`],ExportNamedDeclaration:[`declaration`,`specifiers`,`source`,`attributes`],ExportSpecifier:[`local`,`exported`],ExpressionStatement:[`expression`],ForInStatement:[`left`,`right`,`body`],ForOfStatement:[`left`,`right`,`body`],ForStatement:[`init`,`test`,`update`,`body`],FunctionDeclaration:[`id`,`params`,`body`],FunctionExpression:[`id`,`params`,`body`],Identifier:[],IfStatement:[`test`,`consequent`,`alternate`],ImportAttribute:[`key`,`value`],ImportDeclaration:[`specifiers`,`source`,`attributes`],ImportDefaultSpecifier:[`local`],ImportExpression:[`source`,`options`],ImportNamespaceSpecifier:[`local`],ImportSpecifier:[`imported`,`local`],JSXAttribute:[`name`,`value`],JSXClosingElement:[`name`],JSXClosingFragment:[],JSXElement:[`openingElement`,`children`,`closingElement`],JSXEmptyExpression:[],JSXExpressionContainer:[`expression`],JSXFragment:[`openingFragment`,`children`,`closingFragment`],JSXIdentifier:[],JSXMemberExpression:[`object`,`property`],JSXNamespacedName:[`namespace`,`name`],JSXOpeningElement:[`name`,`attributes`],JSXOpeningFragment:[],JSXSpreadAttribute:[`argument`],JSXSpreadChild:[`expression`],JSXText:[],LabeledStatement:[`label`,`body`],Literal:[],LogicalExpression:[`left`,`right`],MemberExpression:[`object`,`property`],MetaProperty:[`meta`,`property`],MethodDefinition:[`key`,`value`],NewExpression:[`callee`,`arguments`],ObjectExpression:[`properties`],ObjectPattern:[`properties`],PrivateIdentifier:[],Program:[`body`],Property:[`key`,`value`],PropertyDefinition:[`key`,`value`],RestElement:[`argument`],ReturnStatement:[`argument`],SequenceExpression:[`expressions`],SpreadElement:[`argument`],StaticBlock:[`body`],Super:[],SwitchCase:[`test`,`consequent`],SwitchStatement:[`discriminant`,`cases`],TaggedTemplateExpression:[`tag`,`quasi`],TemplateElement:[],TemplateLiteral:[`quasis`,`expressions`],ThisExpression:[],ThrowStatement:[`argument`],TryStatement:[`block`,`handler`,`finalizer`],UnaryExpression:[`argument`],UpdateExpression:[`argument`],VariableDeclaration:[`declarations`],VariableDeclarator:[`id`,`init`],WhileStatement:[`test`,`body`],WithStatement:[`object`,`body`],YieldExpression:[`argument`]},mc=Object.keys(pc);for(let e of mc)Object.freeze(pc[e]);Object.freeze(pc);function unionWith(e){let t=Object.assign({},pc);for(let n of Object.keys(e))if(Object.hasOwn(t,n)){let r=new Set(e[n]);for(let e of t[n])r.add(e);t[n]=Object.freeze(Array.from(r))}else t[n]=Object.freeze(Array.from(e[n]));return Object.freeze(t)}function last(e){return e[e.length-1]??null}function toKeyName(e){return e.type===`TOMLBare`?e.name:e.value}var TOMLVerImpl=class{constructor(e,t){this.major=e,this.minor=t}lt(e,t){return this.major<e||this.major===e&&this.minor<t}gte(e,t){return this.major>e||this.major===e&&this.minor>=t}};const hc=new TOMLVerImpl(1,0),gc=new TOMLVerImpl(1,1),_c=gc,vc={"1.0":hc,"1.0.0":hc,"1.1":gc,"1.1.0":gc,latest:gc,next:gc};function getTOMLVer(e){return e&&vc[e]||_c}const yc={"unterminated-string":`Unterminated string constant`,"unterminated-table-key":`Unterminated table-key`,"unterminated-array":`Unterminated array`,"unterminated-inline-table":`Unterminated inline table`,"missing-key":`Empty bare keys are not allowed`,"missing-newline":`Must be a newline`,"missing-equals-sign":`Expected equal (=) token`,"missing-value":`Unspecified values are invalid`,"missing-comma":`Expected comma (,) token`,"dupe-keys":`Defining a key multiple times is invalid`,"unexpected-char":`Unexpected character`,"unexpected-token":`Unexpected token`,"invalid-control-character":`Control characters (codes < 0x1f and 0x7f) are not allowed`,"invalid-comment-character":`Invalid code point {{cp}} within comments`,"invalid-key-value-newline":`The key, equals sign, and value must be on the same line`,"invalid-inline-table-newline":`No newlines are allowed between the curly braces unless they are valid within a value`,"invalid-underscore":`Underscores are allowed between digits`,"invalid-space":`Unexpected spaces`,"invalid-three-quotes":`Three or more quotes are not permitted`,"invalid-date":`Unexpected invalid date`,"invalid-time":`Unexpected invalid time`,"invalid-leading-zero":`Leading zeros are not allowed`,"invalid-trailing-comma-in-inline-table":`Trailing comma is not permitted in an inline table`,"invalid-char-in-escape-sequence":`Invalid character in escape sequence`,"invalid-consecutive-dots-in-key":`Consecutive dots are not permitted in keys`,"invalid-code-point":`Invalid code point {{cp}}`,"invalid-trailing-dot-in-key":`Keys cannot end with a dot`,"invalid-leading-dot-in-key":`Keys cannot start with a dot`};function getMessage(e,t){return t?yc[e].replace(/\{\{(.*?)\}\}/gu,(e,n)=>n in t?t[n]:`{{${n}}}`):yc[e]}var ParseError=class extends SyntaxError{constructor(e,t,n,r,i){super(getMessage(e,i)),this.index=t,this.lineNumber=n,this.column=r}};const $={EOF:-1,NULL:0,SOH:1,BACKSPACE:8,TABULATION:9,LINE_FEED:10,FORM_FEED:12,CARRIAGE_RETURN:13,ESCAPE:27,SO:14,US:31,SPACE:32,QUOTATION_MARK:34,HASH:35,SINGLE_QUOTE:39,PLUS_SIGN:43,COMMA:44,DASH:45,DOT:46,DIGIT_0:48,DIGIT_1:49,DIGIT_2:50,DIGIT_3:51,DIGIT_7:55,DIGIT_9:57,COLON:58,EQUALS_SIGN:61,LATIN_CAPITAL_A:65,LATIN_CAPITAL_E:69,LATIN_CAPITAL_F:70,LATIN_CAPITAL_T:84,LATIN_CAPITAL_U:85,LATIN_CAPITAL_Z:90,LEFT_BRACKET:91,BACKSLASH:92,RIGHT_BRACKET:93,UNDERSCORE:95,LATIN_SMALL_A:97,LATIN_SMALL_B:98,LATIN_SMALL_E:101,LATIN_SMALL_F:102,LATIN_SMALL_I:105,LATIN_SMALL_L:108,LATIN_SMALL_N:110,LATIN_SMALL_O:111,LATIN_SMALL_R:114,LATIN_SMALL_S:115,LATIN_SMALL_T:116,LATIN_SMALL_U:117,LATIN_SMALL_X:120,LATIN_SMALL_Z:122,LEFT_BRACE:123,RIGHT_BRACE:125,TILDE:126,DELETE:127,PAD:128,SUPERSCRIPT_TWO:178,SUPERSCRIPT_THREE:179,SUPERSCRIPT_ONE:185,VULGAR_FRACTION_ONE_QUARTER:188,VULGAR_FRACTION_THREE_QUARTERS:190,LATIN_CAPITAL_LETTER_A_WITH_GRAVE:192,LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS:214,LATIN_CAPITAL_LETTER_O_WITH_STROKE:216,LATIN_SMALL_LETTER_O_WITH_DIAERESIS:246,LATIN_SMALL_LETTER_O_WITH_STROKE:248,GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL:891,GREEK_CAPITAL_LETTER_YOT:895,CP_1FFF:8191,ZERO_WIDTH_NON_JOINER:8204,ZERO_WIDTH_JOINER:8205,UNDERTIE:8255,CHARACTER_TIE:8256,SUPERSCRIPT_ZERO:8304,CP_218F:8591,CIRCLED_DIGIT_ONE:9312,NEGATIVE_CIRCLED_DIGIT_ZERO:9471,GLAGOLITIC_CAPITAL_LETTER_AZU:11264,CP_2FEF:12271,IDEOGRAPHIC_COMMA:12289,CP_D7FF:55295,CP_E000:57344,CJK_COMPATIBILITY_IDEOGRAPH_F900:63744,ARABIC_LIGATURE_SALAAMUHU_ALAYNAA:64975,ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM:65008,REPLACEMENT_CHARACTER:65533,LINEAR_B_SYLLABLE_B008_A:65536,CP_EFFFF:983039,CP_10FFFF:1114111};function isControl(e){return e>=$.NULL&&e<=$.US}function isWhitespace(e){return e===$.TABULATION||e===$.SPACE}function isEOL(e){return e===$.LINE_FEED||e===$.CARRIAGE_RETURN}function isUpperLetter(e){return e>=$.LATIN_CAPITAL_A&&e<=$.LATIN_CAPITAL_Z}function isLowerLetter(e){return e>=$.LATIN_SMALL_A&&e<=$.LATIN_SMALL_Z}function isLetter(e){return isLowerLetter(e)||isUpperLetter(e)}function isDigit(e){return e>=$.DIGIT_0&&e<=$.DIGIT_9}function isHexDig(e){return isDigit(e)||e>=$.LATIN_SMALL_A&&e<=$.LATIN_SMALL_F||e>=$.LATIN_CAPITAL_A&&e<=$.LATIN_CAPITAL_F}function isOctalDig(e){return e>=$.DIGIT_0&&e<=$.DIGIT_7}function isUnicodeScalarValue(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function sortedLastIndex(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1,a=e[i];if(a===t)return i+1;a<t?n=i+1:r=i}return n}var Locations=class{constructor(){this.offsets=[]}addOffset(e){for(let t=this.offsets.length-1;t>=0;t--){let n=this.offsets[t];if(n===e)return;if(n<e)break}this.offsets.push(e)}getLocFromIndex(e){let t=sortedLastIndex(this.offsets,e)+1;return{line:t,column:e-(t===1?0:this.offsets[t-2])}}},CodePointIterator=class{constructor(e){this.locs=new Locations,this.lastCodePoint=$.NULL,this.start=-1,this.end=0,this.text=e}next(){return this.lastCodePoint===$.EOF?$.EOF:this.lastCodePoint=this.moveAt(this.end)}getLocFromIndex(e){return this.locs.getLocFromIndex(e)}eat(e){return this.text.codePointAt(this.end)===e&&(this.next(),!0)}moveAt(e){this.start=this.end=e;let t=this.text.codePointAt(this.start)??$.EOF;if(t===$.EOF)return this.end=this.start,t;if(this.end+=t>=65536?2:1,t===$.LINE_FEED)this.locs.addOffset(this.end);else if(t===$.CARRIAGE_RETURN)return this.text.codePointAt(this.end)===$.LINE_FEED&&(this.end++,this.locs.addOffset(this.end)),$.LINE_FEED;return t}};const bc=typeof BigInt<`u`,xc={16:`0x`,10:``,8:`0o`,2:`0b`},Sc={[$.QUOTATION_MARK]:$.QUOTATION_MARK,[$.BACKSLASH]:$.BACKSLASH,[$.LATIN_SMALL_B]:$.BACKSPACE,[$.LATIN_SMALL_F]:$.FORM_FEED,[$.LATIN_SMALL_N]:$.LINE_FEED,[$.LATIN_SMALL_R]:$.CARRIAGE_RETURN,[$.LATIN_SMALL_T]:$.TABULATION},Cc={...Sc,[$.LATIN_SMALL_E]:$.ESCAPE};var Tokenizer=class{constructor(e,t){this.backCode=!1,this.lastCodePoint=$.NULL,this.state=`DATA`,this.token=null,this.tokenStart=-1,this.valuesEnabled=!1,this.text=e,this.parserOptions=t||{},this.codePointIterator=new CodePointIterator(e),this.tomlVersion=getTOMLVer(this.parserOptions.tomlVersion),this.ESCAPES=this.tomlVersion.gte(1,1)?Cc:Sc}get start(){return this.codePointIterator.start}get end(){return this.codePointIterator.end}getLocFromIndex(e){return this.codePointIterator.getLocFromIndex(e)}reportParseError(e,t){let n=this.codePointIterator.start,r=this.codePointIterator.getLocFromIndex(n);throw new ParseError(e,n,r.line,r.column,t)}nextToken(){let e=this.token;if(e!=null)return this.token=null,e;let t=this.lastCodePoint;for(;t!==$.EOF&&!this.token;){t=this.nextCode();let e=this[this.state](t);if(!e)throw Error(`Unknown error: pre state=${this.state}`);this.state=e}return e=this.token,this.token=null,e}nextCode(){return this.lastCodePoint===$.EOF?$.EOF:this.backCode?(this.backCode=!1,this.lastCodePoint):this.lastCodePoint=this.codePointIterator.next()}eatCode(e){return this.lastCodePoint===$.EOF?!1:this.backCode?this.lastCodePoint===e&&(this.backCode=!1,!0):this.codePointIterator.eat(e)}moveAt(e){this.backCode&&=!1,this.lastCodePoint=this.codePointIterator.moveAt(e)}back(e){return this.backCode=!0,e}punctuatorToken(){this.startToken(),this.endToken(`Punctuator`,`end`)}startToken(){this.tokenStart=this.codePointIterator.start}endToken(e,t,n,r){let{tokenStart:i}=this,a=this.codePointIterator[t],o=[i,a],s={start:this.codePointIterator.getLocFromIndex(i),end:this.codePointIterator.getLocFromIndex(a)};if(e===`Block`)this.token={type:e,value:this.text.slice(i+1,a),range:o,loc:s};else{let t,c=this.text.slice(i,a);if(e===`BasicString`||e===`LiteralString`||e===`MultiLineBasicString`||e===`MultiLineLiteralString`)t={type:e,value:c,string:n,range:o,loc:s};else if(e===`Integer`){let i=n;t={type:e,value:c,number:parseInt(i,r),bigint:bc?BigInt(xc[r]+i):null,range:o,loc:s}}else t=e===`Float`?{type:e,value:c,number:n,range:o,loc:s}:e===`Boolean`?{type:e,value:c,boolean:n,range:o,loc:s}:e===`LocalDate`||e===`LocalTime`||e===`LocalDateTime`||e===`OffsetDateTime`?{type:e,value:c,date:n,range:o,loc:s}:{type:e,value:c,range:o,loc:s};this.token=t}}DATA(e){for(;isWhitespace(e)||isEOL(e);)e=this.nextCode();if(e===$.HASH)return this.startToken(),`COMMENT`;if(e===$.QUOTATION_MARK)return this.startToken(),`BASIC_STRING`;if(e===$.SINGLE_QUOTE)return this.startToken(),`LITERAL_STRING`;if(e===$.DOT||e===$.EQUALS_SIGN||e===$.LEFT_BRACKET||e===$.RIGHT_BRACKET||e===$.LEFT_BRACE||e===$.RIGHT_BRACE||e===$.COMMA)return this.punctuatorToken(),`DATA`;if(this.valuesEnabled){if(e===$.DASH||e===$.PLUS_SIGN)return this.startToken(),`SIGN`;if(e===$.LATIN_SMALL_N||e===$.LATIN_SMALL_I)return this.startToken(),this.back(`NAN_OR_INF`);if(isDigit(e))return this.startToken(),this.back(`NUMBER`);if(e===$.LATIN_SMALL_T||e===$.LATIN_SMALL_F)return this.startToken(),this.back(`BOOLEAN`)}else if(isUnquotedKeyChar(e,this.tomlVersion))return this.startToken(),`BARE`;return e===$.EOF?`DATA`:this.reportParseError(`unexpected-char`)}COMMENT(e){let t=this.tomlVersion.gte(1,1)?e=>{isNonEOL(e)||this.reportParseError(`invalid-comment-character`,{cp:JSON.stringify(String.fromCodePoint(e)).slice(1,-1)})}:e=>{isControlOtherThanTab(e)&&this.reportParseErrorControlChar()};for(;!isEOL(e)&&e!==$.EOF;)t(e),e=this.nextCode();return this.endToken(`Block`,`start`),`DATA`}BARE(e){for(;isUnquotedKeyChar(e,this.tomlVersion);)e=this.nextCode();return this.endToken(`Bare`,`start`),this.back(`DATA`)}BASIC_STRING(e){if(e===$.QUOTATION_MARK)return e=this.nextCode(),e===$.QUOTATION_MARK?`MULTI_LINE_BASIC_STRING`:(this.endToken(`BasicString`,`start`,``),this.back(`DATA`));let t=[];for(;e!==$.QUOTATION_MARK&&e!==$.EOF&&e!==$.LINE_FEED;){if(isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.BACKSLASH){e=this.nextCode();let n=this.ESCAPES[e];if(n){t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}return this.reportParseError(`invalid-char-in-escape-sequence`)}t.push(e),e=this.nextCode()}return e===$.QUOTATION_MARK?(this.endToken(`BasicString`,`end`,String.fromCodePoint(...t)),`DATA`):this.reportParseError(`unterminated-string`)}MULTI_LINE_BASIC_STRING(e){let t=[];for(e===$.LINE_FEED&&(e=this.nextCode());e!==$.EOF;){if(e!==$.LINE_FEED&&isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.QUOTATION_MARK){let e=this.codePointIterator.start;if(this.eatCode($.QUOTATION_MARK)&&this.eatCode($.QUOTATION_MARK))return this.eatCode($.QUOTATION_MARK)&&(t.push($.QUOTATION_MARK),this.eatCode($.QUOTATION_MARK)&&(t.push($.QUOTATION_MARK),this.eatCode($.QUOTATION_MARK)))?(this.moveAt(e),this.reportParseError(`invalid-three-quotes`)):(this.endToken(`MultiLineBasicString`,`end`,String.fromCodePoint(...t)),`DATA`);this.moveAt(e)}if(e===$.BACKSLASH){e=this.nextCode();let n=this.ESCAPES[e];if(n){t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_U){let n=this.parseUnicode(4);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_CAPITAL_U){let n=this.parseUnicode(8);t.push(n),e=this.nextCode();continue}if(e===$.LATIN_SMALL_X&&this.tomlVersion.gte(1,1)){let n=this.parseUnicode(2);t.push(n),e=this.nextCode();continue}if(e===$.LINE_FEED){for(e=this.nextCode();isWhitespace(e)||e===$.LINE_FEED;)e=this.nextCode();continue}if(isWhitespace(e)){let t=!0,n=this.codePointIterator.start,r;for(;(r=this.nextCode())!==$.EOF&&r!==$.LINE_FEED;)if(!isWhitespace(r)){this.moveAt(n),t=!1;break}if(t){for(e=this.nextCode();isWhitespace(e)||e===$.LINE_FEED;)e=this.nextCode();continue}}return this.reportParseError(`invalid-char-in-escape-sequence`)}t.push(e),e=this.nextCode()}return this.reportParseError(`unterminated-string`)}LITERAL_STRING(e){if(e===$.SINGLE_QUOTE)return e=this.nextCode(),e===$.SINGLE_QUOTE?`MULTI_LINE_LITERAL_STRING`:(this.endToken(`LiteralString`,`start`,``),this.back(`DATA`));let t=[];for(;e!==$.SINGLE_QUOTE&&e!==$.EOF&&e!==$.LINE_FEED;){if(isControlOtherThanTab(e))return this.reportParseErrorControlChar();t.push(e),e=this.nextCode()}return e===$.SINGLE_QUOTE?(this.endToken(`LiteralString`,`end`,String.fromCodePoint(...t)),`DATA`):this.reportParseError(`unterminated-string`)}MULTI_LINE_LITERAL_STRING(e){let t=[];for(e===$.LINE_FEED&&(e=this.nextCode());e!==$.EOF;){if(e!==$.LINE_FEED&&isControlOtherThanTab(e))return this.reportParseErrorControlChar();if(e===$.SINGLE_QUOTE){let e=this.codePointIterator.start;if(this.eatCode($.SINGLE_QUOTE)&&this.eatCode($.SINGLE_QUOTE))return this.eatCode($.SINGLE_QUOTE)&&(t.push($.SINGLE_QUOTE),this.eatCode($.SINGLE_QUOTE)&&(t.push($.SINGLE_QUOTE),this.eatCode($.SINGLE_QUOTE)))?(this.moveAt(e),this.reportParseError(`invalid-three-quotes`)):(this.endToken(`MultiLineLiteralString`,`end`,String.fromCodePoint(...t)),`DATA`);this.moveAt(e)}t.push(e),e=this.nextCode()}return this.reportParseError(`unterminated-string`)}SIGN(e){return e===$.LATIN_SMALL_N||e===$.LATIN_SMALL_I?this.back(`NAN_OR_INF`):isDigit(e)?this.back(`NUMBER`):this.reportParseError(`unexpected-char`)}NAN_OR_INF(e){if(e===$.LATIN_SMALL_N){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_A)&&this.eatCode($.LATIN_SMALL_N))return this.endToken(`Float`,`end`,NaN),`DATA`;this.moveAt(e)}else if(e===$.LATIN_SMALL_I){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_N)&&this.eatCode($.LATIN_SMALL_F))return this.endToken(`Float`,`end`,this.text[this.tokenStart]===`-`?-1/0:1/0),`DATA`;this.moveAt(e)}return this.reportParseError(`unexpected-char`)}NUMBER(e){let t=this.text[this.tokenStart],n=t===`+`?$.PLUS_SIGN:t===`-`?$.DASH:$.NULL;if(e===$.DIGIT_0){if(n===$.NULL){let e=this.codePointIterator.start,t=this.nextCode();if(isDigit(t)){let n=this.nextCode();if(n===$.COLON)return this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint($.DIGIT_0,t)),minute:0,second:0},`TIME_MINUTE`;if(isDigit(n)){let e=this.nextCode();if(isDigit(e)&&this.eatCode($.DASH))return this.data={hasDate:!0,year:Number(String.fromCodePoint($.DIGIT_0,t,n,e)),month:0,day:0,hour:0,minute:0,second:0},`DATE_MONTH`}return this.moveAt(e),this.reportParseError(`invalid-leading-zero`)}this.moveAt(e)}return e=this.nextCode(),e===$.LATIN_SMALL_X||e===$.LATIN_SMALL_O||e===$.LATIN_SMALL_B?n===$.NULL?e===$.LATIN_SMALL_X?`HEX`:e===$.LATIN_SMALL_O?`OCTAL`:`BINARY`:this.reportParseError(`unexpected-char`):e===$.LATIN_SMALL_E||e===$.LATIN_CAPITAL_E?(this.data={minus:n===$.DASH,left:[$.DIGIT_0]},`EXPONENT_RIGHT`):e===$.DOT?(this.data={minus:n===$.DASH,absInt:[$.DIGIT_0]},`FRACTIONAL_RIGHT`):(this.endToken(`Integer`,`start`,`0`,10),this.back(`DATA`))}let{out:r,nextCp:i,hasUnderscore:a}=this.parseDigits(e,isDigit);return i===$.DASH&&n===$.NULL&&!a&&r.length===4?(this.data={hasDate:!0,year:Number(String.fromCodePoint(...r)),month:0,day:0,hour:0,minute:0,second:0},`DATE_MONTH`):i===$.COLON&&n===$.NULL&&!a&&r.length===2?(this.data={hasDate:!1,year:0,month:0,day:0,hour:Number(String.fromCodePoint(...r)),minute:0,second:0},`TIME_MINUTE`):i===$.LATIN_SMALL_E||i===$.LATIN_CAPITAL_E?(this.data={minus:n===$.DASH,left:r},`EXPONENT_RIGHT`):i===$.DOT?(this.data={minus:n===$.DASH,absInt:r},`FRACTIONAL_RIGHT`):(this.endToken(`Integer`,`start`,n===$.DASH?String.fromCodePoint($.DASH,...r):String.fromCodePoint(...r),10),this.back(`DATA`))}HEX(e){let{out:t}=this.parseDigits(e,isHexDig);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),16),this.back(`DATA`)}OCTAL(e){let{out:t}=this.parseDigits(e,isOctalDig);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),8),this.back(`DATA`)}BINARY(e){let{out:t}=this.parseDigits(e,e=>e===$.DIGIT_0||e===$.DIGIT_1);return this.endToken(`Integer`,`start`,String.fromCodePoint(...t),2),this.back(`DATA`)}FRACTIONAL_RIGHT(e){let{minus:t,absInt:n}=this.data,{out:r,nextCp:i}=this.parseDigits(e,isDigit),a=[...n,$.DOT,...r];if(i===$.LATIN_SMALL_E||i===$.LATIN_CAPITAL_E)return this.data={minus:t,left:a},`EXPONENT_RIGHT`;let o=Number(t?String.fromCodePoint($.DASH,...a):String.fromCodePoint(...a));return this.endToken(`Float`,`start`,o),this.back(`DATA`)}EXPONENT_RIGHT(e){let{left:t,minus:n}=this.data,r=!1;(e===$.DASH||e===$.PLUS_SIGN)&&(r=e===$.DASH,e=this.nextCode());let{out:i}=this.parseDigits(e,isDigit),a=i;r&&a.unshift($.DASH);let o=Number(n?String.fromCodePoint($.DASH,...t,$.LATIN_SMALL_E,...a):String.fromCodePoint(...t,$.LATIN_SMALL_E,...a));return this.endToken(`Float`,`start`,o),this.back(`DATA`)}BOOLEAN(e){if(e===$.LATIN_SMALL_T){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_R)&&this.eatCode($.LATIN_SMALL_U)&&this.eatCode($.LATIN_SMALL_E))return this.endToken(`Boolean`,`end`,!0),`DATA`;this.moveAt(e)}else if(e===$.LATIN_SMALL_F){let e=this.codePointIterator.start;if(this.eatCode($.LATIN_SMALL_A)&&this.eatCode($.LATIN_SMALL_L)&&this.eatCode($.LATIN_SMALL_S)&&this.eatCode($.LATIN_SMALL_E))return this.endToken(`Boolean`,`end`,!1),`DATA`;this.moveAt(e)}return this.reportParseError(`unexpected-char`)}DATE_MONTH(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e))||(e=this.nextCode(),e!==$.DASH))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start,r=this.data;return r.month=Number(this.text.slice(t,n)),`DATE_DAY`}DATE_DAY(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;if(r.day=Number(this.text.slice(t,n)),!isValidDate(r.year,r.month,r.day))return this.reportParseError(`invalid-date`);if(e=this.nextCode(),e===$.LATIN_CAPITAL_T||e===$.LATIN_SMALL_T)return`TIME_HOUR`;if(e===$.SPACE){let e=this.codePointIterator.start;if(isDigit(this.nextCode())&&isDigit(this.nextCode()))return this.moveAt(e),`TIME_HOUR`;this.moveAt(e)}let i=getDateFromDateTimeData(r,``);return this.endToken(`LocalDate`,`start`,i),this.back(`DATA`)}TIME_HOUR(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e))||(e=this.nextCode(),e!==$.COLON))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start,r=this.data;return r.hour=Number(this.text.slice(t,n)),`TIME_MINUTE`}TIME_MINUTE(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;return r.minute=Number(this.text.slice(t,n)),e=this.nextCode(),e===$.COLON?`TIME_SECOND`:this.tomlVersion.lt(1,1)?this.reportParseError(`unexpected-char`):isValidTime(r.hour,r.minute,r.second)?this.processTimeEnd(e,r):this.reportParseError(`invalid-time`)}TIME_SECOND(e){let t=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.end,r=this.data;return r.second=Number(this.text.slice(t,n)),isValidTime(r.hour,r.minute,r.second)?(e=this.nextCode(),e===$.DOT?`TIME_SEC_FRAC`:this.processTimeEnd(e,r)):this.reportParseError(`invalid-time`)}TIME_SEC_FRAC(e){if(!isDigit(e))return this.reportParseError(`unexpected-char`);let t=this.codePointIterator.start;for(;isDigit(e);)e=this.nextCode();let n=this.codePointIterator.start,r=this.data;return r.frac=this.text.slice(t,n),this.processTimeEnd(e,r)}processTimeEnd(e,t){if(t.hasDate){if(e===$.DASH||e===$.PLUS_SIGN)return t.offsetSign=e,`TIME_OFFSET`;if(e===$.LATIN_CAPITAL_Z||e===$.LATIN_SMALL_Z){let e=getDateFromDateTimeData(t,`Z`);return this.endToken(`OffsetDateTime`,`end`,e),`DATA`}let n=getDateFromDateTimeData(t,``);return this.endToken(`LocalDateTime`,`start`,n),this.back(`DATA`)}let n=getDateFromDateTimeData(t,``);return this.endToken(`LocalTime`,`start`,n),this.back(`DATA`)}TIME_OFFSET(e){if(!isDigit(e))return this.reportParseError(`unexpected-char`);let t=this.codePointIterator.start;if(e=this.nextCode(),!isDigit(e)||(e=this.nextCode(),e!==$.COLON))return this.reportParseError(`unexpected-char`);let n=this.codePointIterator.start;e=this.nextCode();let r=this.codePointIterator.start;if(!isDigit(e)||(e=this.nextCode(),!isDigit(e)))return this.reportParseError(`unexpected-char`);let i=this.codePointIterator.end,a=Number(this.text.slice(t,n)),o=Number(this.text.slice(r,i));if(!isValidTime(a,o,0))return this.reportParseError(`invalid-time`);let s=this.data,c=getDateFromDateTimeData(s,`${String.fromCodePoint(s.offsetSign)}${padStart(a,2)}:${padStart(o,2)}`);return this.endToken(`OffsetDateTime`,`end`,c),`DATA`}parseDigits(e,t){if(e===$.UNDERSCORE)return this.reportParseError(`invalid-underscore`);if(!t(e))return this.reportParseError(`unexpected-char`);let n=[],r=$.NULL,i=!1;for(;t(e)||e===$.UNDERSCORE;){if(e===$.UNDERSCORE){if(i=!0,r===$.UNDERSCORE)return this.reportParseError(`invalid-underscore`)}else n.push(e);r=e,e=this.nextCode()}return r===$.UNDERSCORE?this.reportParseError(`invalid-underscore`):{out:n,nextCp:e,hasUnderscore:i}}parseUnicode(e){let t=this.codePointIterator.start,n=this.codePointIterator.end,r=0,i;for(;(i=this.nextCode())!==$.EOF;){if(!isHexDig(i))return this.moveAt(t),this.reportParseError(`invalid-char-in-escape-sequence`);if(r++,r>=e)break}let a=this.codePointIterator.end,o=this.text.slice(n,a),s=parseInt(o,16);return isUnicodeScalarValue(s)?s:this.reportParseError(`invalid-code-point`,{cp:o})}reportParseErrorControlChar(){return this.reportParseError(`invalid-control-character`)}};function isUnquotedKeyChar(e,t){return isLetter(e)||isDigit(e)||e===$.UNDERSCORE||e===$.DASH?!0:(t.lt(1,1),!1)}function isControlOtherThanTab(e){return isControl(e)&&e!==$.TABULATION||e===$.DELETE}function isNonEOL(e){return e===$.TABULATION||$.SPACE<=e&&e<=$.TILDE||isNonAscii(e)}function isNonAscii(e){return $.PAD<=e&&e<=$.CP_D7FF||$.CP_E000<=e&&e<=$.CP_10FFFF}function isValidDate(e,t,n){return e>=0&&t<=12&&t>=1&&n>=1&&n<=(t===2?e&3||!(e%25)&&e&15?28:29:30+(t+(t>>3)&1))}function isValidTime(e,t,n){return!(e>=24||e<0||t>59||t<0||n>60||n<0)}function getDateFromDateTimeData(e,t){let n=padStart(e.year,4),r=e.month?padStart(e.month,2):`01`,i=e.day?padStart(e.day,2):`01`,a=padStart(e.hour,2),o=padStart(e.minute,2),s=padStart(e.second,2),c=`${n}-${r}-${i}`,l=e.frac?`.${e.frac}`:``,u=new Date(`${c}T${a}:${o}:${s}${l}${t}`);return!isNaN(u.getTime())||e.second!==60?u:new Date(`${c}T${a}:${o}:59${l}${t}`)}function padStart(e,t){return String(e).padStart(t,`0`)}const wc=Symbol(`VALUE_KIND_VALUE`),Tc=Symbol(`VALUE_KIND_INTERMEDIATE`);var KeysResolver=class{constructor(e){this.rootKeys=new Map,this.tables=[],this.ctx=e}applyResolveKeyForTable(e){let t=this.rootKeys,n=e.key.keys.length-1;for(let r=0;r<n;r++){let n=e.key.keys[r],i=toKeyName(n);e.resolvedKey.push(i);let a=t.get(i);if(!a)a={node:n,keys:new Map},t.set(i,a);else if(a.table===`array`){let t=a.peekIndex;e.resolvedKey.push(t),a=a.keys.get(t)}t=a.keys}let r=e.key.keys[n],i=toKeyName(r);e.resolvedKey.push(i);let a=t.get(i);if(!a){if(e.kind===`array`){e.resolvedKey.push(0);let n={node:r,keys:new Map};t.set(i,{table:e.kind,node:r,keys:new Map([[0,n]]),peekIndex:0}),this.tables.push({node:e,keys:n.keys})}else{let n={table:e.kind,node:r,keys:new Map};t.set(i,n),this.tables.push({node:e,keys:n.keys})}}else if(!a.table){if(e.kind===`array`)this.ctx.reportParseError(`dupe-keys`,r);else{let n={table:e.kind,node:r,keys:a.keys};t.set(i,n),this.tables.push({node:e,keys:n.keys})}}else if(a.table===`array`){if(e.kind===`array`){let t={node:r,keys:new Map},n=a.peekIndex+1;e.resolvedKey.push(n),a.keys.set(n,t),a.peekIndex=n,this.tables.push({node:e,keys:t.keys})}else this.ctx.reportParseError(`dupe-keys`,r)}else this.ctx.reportParseError(`dupe-keys`,r)}verifyDuplicateKeys(e){for(let t of e.body)t.type===`TOMLKeyValue`&&verifyDuplicateKeysForKeyValue(this.ctx,this.rootKeys,t);for(let{node:e,keys:t}of this.tables)for(let n of e.body)verifyDuplicateKeysForKeyValue(this.ctx,t,n)}};function verifyDuplicateKeysForKeyValue(e,t,n){let r=t,i=last(n.key.keys);for(let t of n.key.keys){let n=toKeyName(t),a=r.get(n);a?((a.value===wc||i===t||a.table)&&e.reportParseError(`dupe-keys`,getAfterNode(t,a.node)),a.value=Tc):(a=i===t?{value:wc,node:t,keys:new Map}:{value:Tc,node:t,keys:new Map},r.set(n,a)),r=a.keys}n.value.type===`TOMLInlineTable`?verifyDuplicateKeysForInlineTable(e,r,n.value):n.value.type===`TOMLArray`&&verifyDuplicateKeysForArray(e,r,n.value)}function verifyDuplicateKeysForInlineTable(e,t,n){for(let r of n.body)verifyDuplicateKeysForKeyValue(e,t,r)}function verifyDuplicateKeysForArray(e,t,n){let r=t;for(let i=0;i<n.elements.length;i++){let a=n.elements[i],o=r.get(i);o?e.reportParseError(`dupe-keys`,getAfterNode(a,o.node)):(o={value:wc,node:a,keys:new Map},t.set(i,o),a.type===`TOMLInlineTable`?verifyDuplicateKeysForInlineTable(e,o.keys,a):a.type===`TOMLArray`&&verifyDuplicateKeysForArray(e,o.keys,a))}}function getAfterNode(e,t){return e.range[0]<=t.range[0]?t:e}var Context=class{constructor(e){this.tokens=[],this.comments=[],this.back=null,this.stateStack=[],this.needNewLine=!1,this.needSameLine=!1,this.currToken=null,this.prevToken=null,this.valueContainerStack=[],this.tokenizer=new Tokenizer(e.text,e.parserOptions),this.topLevelTable=e.topLevelTable,this.table=e.topLevelTable,this.keysResolver=new KeysResolver(this)}nextToken(e){if(this.prevToken=this.currToken,this.back?(this.currToken=this.back,this.back=null):this.currToken=this._nextTokenFromTokenizer(e),(this.needNewLine||this.needSameLine||e?.needSameLine)&&this.prevToken&&this.currToken){if(this.prevToken.loc.end.line===this.currToken.loc.start.line){if(this.needNewLine)return this.reportParseError(`missing-newline`,this.currToken)}else{let t=this.needSameLine||e?.needSameLine;if(t)return this.reportParseError(t,this.currToken)}}return this.needNewLine=!1,this.needSameLine=!1,this.currToken}_nextTokenFromTokenizer(e){let t=this.tokenizer.valuesEnabled;e?.valuesEnabled&&(this.tokenizer.valuesEnabled=e.valuesEnabled);let n=this.tokenizer.nextToken();for(;n&&n.type===`Block`;)this.comments.push(n),n=this.tokenizer.nextToken();return n&&this.tokens.push(n),this.tokenizer.valuesEnabled=t,n}backToken(){if(this.back)throw Error(`Illegal state`);this.back=this.currToken,this.currToken=this.prevToken}addValueContainer(e){this.valueContainerStack.push(e),this.tokenizer.valuesEnabled=!0}consumeValueContainer(){let e=this.valueContainerStack.pop();return this.tokenizer.valuesEnabled=this.valueContainerStack.length>0,e}applyResolveKeyForTable(e){this.keysResolver.applyResolveKeyForTable(e)}verifyDuplicateKeys(){this.keysResolver.verifyDuplicateKeys(this.topLevelTable)}reportParseError(e,t){let n,r,i;if(t)n=t.range[0],r=t.loc.start.line,i=t.loc.start.column;else{n=this.tokenizer.start;let e=this.tokenizer.getLocFromIndex(n);r=e.line,i=e.column}throw new ParseError(e,n,r,i)}};const Ec={VALUE:`missing-value`},Dc={BasicString:`basic`,MultiLineBasicString:`basic`,LiteralString:`literal`,MultiLineLiteralString:`literal`},Oc={BasicString:`basic`,LiteralString:`literal`},kc={OffsetDateTime:`offset-date-time`,LocalDateTime:`local-date-time`,LocalDate:`local-date`,LocalTime:`local-time`};var TOMLParser=class{constructor(e,t){this.text=e,this.parserOptions=t||{},this.tomlVersion=getTOMLVer(this.parserOptions.tomlVersion)}parse(){let e={type:`Program`,body:[],sourceType:`module`,tokens:[],comments:[],parent:null,range:[0,0],loc:{start:{line:1,column:0},end:{line:1,column:0}}},t={type:`TOMLTopLevelTable`,body:[],parent:e,range:cloneRange(e.range),loc:cloneLoc(e.loc)};e.body=[t];let n=new Context({text:this.text,parserOptions:this.parserOptions,topLevelTable:t}),r=n.nextToken();if(r){for(t.range[0]=r.range[0],t.loc.start=clonePos(r.loc.start);r;){let e=n.stateStack.pop()||`TABLE`;n.stateStack.push(...this[e](r,n)),r=n.nextToken()}let e=n.stateStack.pop()||`TABLE`;if(e in Ec)return n.reportParseError(Ec[e],null);n.table.type===`TOMLTable`&&applyEndLoc(n.table,last(n.table.body)),applyEndLoc(t,last(t.body))}n.verifyDuplicateKeys(),e.tokens=n.tokens,e.comments=n.comments;let i=n.tokenizer.end,a=n.tokenizer.getLocFromIndex(i);return e.range[1]=i,e.loc.end={line:a.line,column:a.column},e}TABLE(e,t){return isBare(e)||isString(e)?this.processKeyValue(e,t.table,t):isLeftBracket(e)?this.processTable(e,t.topLevelTable,t):t.reportParseError(`unexpected-token`,e)}VALUE(e,t){return isString(e)||isMultiLineString(e)?this.processStringValue(e,t):isNumber(e)?this.processNumberValue(e,t):isBoolean(e)?this.processBooleanValue(e,t):isDateTime(e)?this.processDateTimeValue(e,t):isLeftBracket(e)?this.processArray(e,t):isLeftBrace(e)?this.processInlineTable(e,t):t.reportParseError(`unexpected-token`,e)}processTable(e,t,n){let r={type:`TOMLTable`,kind:`standard`,key:null,resolvedKey:[],body:[],parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};n.table.type===`TOMLTable`&&applyEndLoc(n.table,last(n.table.body)),t.body.push(r),n.table=r;let i=n.nextToken({needSameLine:`invalid-key-value-newline`});if(isLeftBracket(i)){if(e.range[1]<i.range[0])return n.reportParseError(`invalid-space`,i);r.kind=`array`,i=n.nextToken({needSameLine:`invalid-key-value-newline`})}if(isRightBracket(i))return n.reportParseError(`missing-key`,i);if(!i)return n.reportParseError(`unterminated-table-key`,null);if(i=this.processKeyNode(i,r,n).nextToken,!isRightBracket(i))return n.reportParseError(`unterminated-table-key`,i);if(r.kind===`array`){let e=i;if(i=n.nextToken({needSameLine:`invalid-key-value-newline`}),!isRightBracket(i))return n.reportParseError(`unterminated-table-key`,i);if(e.range[1]<i.range[0])return n.reportParseError(`invalid-space`,i)}return applyEndLoc(r,i),n.applyResolveKeyForTable(r),n.needNewLine=!0,[]}processKeyValue(e,t,n){let r={type:`TOMLKeyValue`,key:null,value:null,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.body.push(r);let{nextToken:i}=this.processKeyNode(e,r,n);return isEq(i)?(n.addValueContainer({parent:r,set:e=>(r.value=e,applyEndLoc(r,e),n.needNewLine=!0,[])}),n.needSameLine=`invalid-key-value-newline`,[`VALUE`]):n.reportParseError(`missing-equals-sign`,i)}processKeyNode(e,t,n){isDot(e)&&n.reportParseError(`invalid-leading-dot-in-key`,e);let r={type:`TOMLKey`,keys:[],parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.key=r;let i=e,a=null;do{if(isBare(i))this.processBareKey(i,r);else if(isString(i))this.processStringKey(i,r);else break;if(a=null,i=n.nextToken({needSameLine:`invalid-key-value-newline`}),!isDot(i))break;a=i,i=n.nextToken({needSameLine:`invalid-key-value-newline`})}while(i);return a&&n.reportParseError(isDot(i)?`invalid-consecutive-dots-in-key`:`invalid-trailing-dot-in-key`,a),applyEndLoc(r,last(r.keys)),{keyNode:r,nextToken:i}}processBareKey(e,t){let n={type:`TOMLBare`,name:e.value,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.keys.push(n)}processStringKey(e,t){let n={type:`TOMLQuoted`,kind:`string`,value:e.string,style:Oc[e.type],multiline:!1,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.keys.push(n)}processStringValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:`string`,value:e.string,style:Dc[e.type],multiline:isMultiLineString(e),parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processNumberValue(e,t){let n=t.consumeValueContainer(),r=this.text,[i,a]=e.range,o=null,getNumberText=()=>o??=r.slice(i,a).replace(/_/g,``),s;return s=e.type===`Integer`?{type:`TOMLValue`,kind:`integer`,value:e.number,bigint:e.bigint,get number(){return getNumberText()},parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)}:{type:`TOMLValue`,kind:`float`,value:e.number,get number(){return getNumberText()},parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},n.set(s)}processBooleanValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:`boolean`,value:e.boolean,parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processDateTimeValue(e,t){let n=t.consumeValueContainer(),r={type:`TOMLValue`,kind:kc[e.type],value:e.date,datetime:e.value,parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)};return n.set(r)}processArray(e,t){let n=t.consumeValueContainer(),r={type:`TOMLArray`,elements:[],parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},i=t.nextToken({valuesEnabled:!0});return isRightBracket(i)?(applyEndLoc(r,i),n.set(r)):(t.backToken(),this.processArrayValue(r,n,t))}processArrayValue(e,t,n){return n.addValueContainer({parent:e,set:r=>{e.elements.push(r);let i=n.nextToken({valuesEnabled:!0}),a=isComma(i);return a&&(i=n.nextToken({valuesEnabled:!0})),isRightBracket(i)?(applyEndLoc(e,i),t.set(e)):a?(n.backToken(),this.processArrayValue(e,t,n)):n.reportParseError(i?`missing-comma`:`unterminated-array`,i)}}),[`VALUE`]}processInlineTable(e,t){let n=t.consumeValueContainer(),r={type:`TOMLInlineTable`,body:[],parent:n.parent,range:cloneRange(e.range),loc:cloneLoc(e.loc)},i=this.tomlVersion.gte(1,1)?void 0:`invalid-inline-table-newline`,a=t.nextToken({needSameLine:i});if(a){if(isBare(a)||isString(a))return this.processInlineTableKeyValue(a,r,n,t);if(isRightBrace(a))return applyEndLoc(r,a),n.set(r)}return t.reportParseError(`unexpected-token`,a)}processInlineTableKeyValue(e,t,n,r){let i={type:`TOMLKeyValue`,key:null,value:null,parent:t,range:cloneRange(e.range),loc:cloneLoc(e.loc)};t.body.push(i);let{nextToken:a}=this.processKeyNode(e,i,r);if(!isEq(a))return r.reportParseError(`missing-equals-sign`,a);let o=this.tomlVersion.gte(1,1)?void 0:`invalid-inline-table-newline`;return r.addValueContainer({parent:i,set:e=>{i.value=e,applyEndLoc(i,e);let a=r.nextToken({needSameLine:o});if(isComma(a)){if(a=r.nextToken({needSameLine:o}),a&&(isBare(a)||isString(a)))return this.processInlineTableKeyValue(a,t,n,r);if(isRightBrace(a)){if(this.tomlVersion.lt(1,1))return r.reportParseError(`invalid-trailing-comma-in-inline-table`,a)}else return r.reportParseError(a?`unexpected-token`:`unterminated-inline-table`,a)}return isRightBrace(a)?(applyEndLoc(t,a),n.set(t)):r.reportParseError(a?`missing-comma`:`unterminated-inline-table`,a)}}),r.needSameLine=`invalid-key-value-newline`,[`VALUE`]}};function isDot(e){return isPunctuator(e)&&e.value===`.`}function isEq(e){return isPunctuator(e)&&e.value===`=`}function isLeftBracket(e){return isPunctuator(e)&&e.value===`[`}function isRightBracket(e){return isPunctuator(e)&&e.value===`]`}function isLeftBrace(e){return isPunctuator(e)&&e.value===`{`}function isRightBrace(e){return isPunctuator(e)&&e.value===`}`}function isComma(e){return isPunctuator(e)&&e.value===`,`}function isPunctuator(e){return!!(e&&e.type===`Punctuator`)}function isBare(e){return e.type===`Bare`}function isString(e){return e.type===`BasicString`||e.type===`LiteralString`}function isMultiLineString(e){return e.type===`MultiLineBasicString`||e.type===`MultiLineLiteralString`}function isNumber(e){return e.type===`Integer`||e.type===`Float`}function isBoolean(e){return e.type===`Boolean`}function isDateTime(e){return e.type===`OffsetDateTime`||e.type===`LocalDateTime`||e.type===`LocalDate`||e.type===`LocalTime`}function applyEndLoc(e,t){t&&(e.range[1]=t.range[1],e.loc.end=clonePos(t.loc.end))}function cloneRange(e){return[e[0],e[1]]}function cloneLoc(e){return{start:clonePos(e.start),end:clonePos(e.end)}}function clonePos(e){return{line:e.line,column:e.column}}const Ac=unionWith({Program:[`body`],TOMLTopLevelTable:[`body`],TOMLTable:[`key`,`body`],TOMLKeyValue:[`key`,`value`],TOMLKey:[`keys`],TOMLArray:[`elements`],TOMLInlineTable:[`body`],TOMLBare:[],TOMLQuoted:[],TOMLValue:[]});function parseForESLint(e,t){return{ast:new TOMLParser(e,t).parse(),visitorKeys:Ac,services:{isTOML:!0}}}function parseTOML(e,t){return parseForESLint(e,t).ast}function nested(e,t){return e.reduceRight((e,t)=>({[t]:e}),t)}function renderTomlTable(e,t){return stringify(nested(e,t))}function appendTomlTable(e,t,n){return`${e}${e===``||e.endsWith(`
|
|
479
480
|
`)?``:`
|
|
480
|
-
`}\n${renderTomlTable(t,n)}`}function keyNames(e){return e.keys.map(e=>e.type===`TOMLBare`?e.name:e.value)}function startsWith(e,t){return t.length<=e.length&&t.every((t,n)=>e[n]===t)}function overlaps(e,t){return startsWith(e,t)||startsWith(t,e)}function replaceTomlTable(e,t,n){let r;try{r=parseTOML(e)}catch{return{kind:`refused`,reason:`unreadable`}}let i=[];for(let e of r.body[0].body){if(e.type===`TOMLKeyValue`){if(overlaps(keyNames(e.key),t))return{kind:`refused`,reason:`shape`};continue}if(startsWith(e.resolvedKey,t)){if(e.kind===`array`)return{kind:`refused`,reason:`shape`};i.push(e);continue}let n=e.resolvedKey;if(e.body.some(e=>overlaps([...n,...keyNames(e.key)],t)))return{kind:`refused`,reason:`shape`}}if(!i.length)return{kind:`refused`,reason:`absent`};if(!i.some(e=>e.resolvedKey.length===t.length))return{kind:`refused`,reason:`shape`};let a=i.map(t=>{let n=e.slice(t.range[1]).search(/\r?\n/);return[t.range[0],n<0?e.length:t.range[1]+n]}),inside=e=>a.some(([t,n])=>t<=e&&e<n);if(r.comments.some(e=>inside(e.range[0])))return{kind:`refused`,reason:`comment`};let[o,...s]=a,c=e;for(let[e,t]of s.reverse()){let n=c.slice(0,e),r=c.slice(t).replace(/^\r?\n/,``);c=/\n\r?\n$/.test(n)?`${n}${r.replace(/^\r?\n/,``)}`:`${n}${r}`}let l=renderTomlTable(t,n).trimEnd();return{kind:`edited`,text:`${c.slice(0,o[0])}${l}${c.slice(o[1])}`}}const
|
|
481
|
+
`}\n${renderTomlTable(t,n)}`}function keyNames(e){return e.keys.map(e=>e.type===`TOMLBare`?e.name:e.value)}function startsWith(e,t){return t.length<=e.length&&t.every((t,n)=>e[n]===t)}function overlaps(e,t){return startsWith(e,t)||startsWith(t,e)}function replaceTomlTable(e,t,n){let r;try{r=parseTOML(e)}catch{return{kind:`refused`,reason:`unreadable`}}let i=[];for(let e of r.body[0].body){if(e.type===`TOMLKeyValue`){if(overlaps(keyNames(e.key),t))return{kind:`refused`,reason:`shape`};continue}if(startsWith(e.resolvedKey,t)){if(e.kind===`array`)return{kind:`refused`,reason:`shape`};i.push(e);continue}let n=e.resolvedKey;if(e.body.some(e=>overlaps([...n,...keyNames(e.key)],t)))return{kind:`refused`,reason:`shape`}}if(!i.length)return{kind:`refused`,reason:`absent`};if(!i.some(e=>e.resolvedKey.length===t.length))return{kind:`refused`,reason:`shape`};let a=i.map(t=>{let n=e.slice(t.range[1]).search(/\r?\n/);return[t.range[0],n<0?e.length:t.range[1]+n]}),inside=e=>a.some(([t,n])=>t<=e&&e<n);if(r.comments.some(e=>inside(e.range[0])))return{kind:`refused`,reason:`comment`};let[o,...s]=a,c=e;for(let[e,t]of s.reverse()){let n=c.slice(0,e),r=c.slice(t).replace(/^\r?\n/,``);c=/\n\r?\n$/.test(n)?`${n}${r.replace(/^\r?\n/,``)}`:`${n}${r}`}let l=renderTomlTable(t,n).trimEnd();return{kind:`edited`,text:`${c.slice(0,o[0])}${l}${c.slice(o[1])}`}}const jc=/^[A-Za-z0-9_-]+$/;function tomlKey(e){return jc.test(e)?e:JSON.stringify(e)}function renderTomlInline(e){return typeof e==`object`&&e&&!Array.isArray(e)?`{ ${Object.entries(e).map(([e,t])=>`${tomlKey(e)} = ${renderTomlInline(t)}`).join(`, `)} }`:stringify({v:e}).slice(4).trimEnd()}function appendInlineTomlTable(e,t,n){let r=e===``||e.endsWith(`
|
|
481
482
|
`)?``:`
|
|
482
483
|
`,i=Object.entries(n).map(([e,t])=>`${tomlKey(e)} = ${renderTomlInline(t)}\n`);return`${e}${r}\n[${t.map(tomlKey).join(`.`)}]\n${i.join(``)}`}function lineEndAt(e,t){let n=e.indexOf(`
|
|
483
484
|
`,t);return n===-1?e.length:n}function setTomlKey(e,t,n,r){let i;try{i=parseTOML(e)}catch{return{kind:`refused`,reason:`unreadable`}}let a=i.body[0].body.filter(e=>e.type===`TOMLTable`),o=a.find(e=>e.kind===`standard`&&e.resolvedKey.length===t.length&&startsWith(e.resolvedKey,t));if(!o)return{kind:`refused`,reason:`absent`};let s=o.body;if(a.some(e=>startsWith(e.resolvedKey,[...t,n]))||s.some(e=>keyNames(e.key)[0]===n&&e.key.keys.length>1))return{kind:`refused`,reason:`shape`};let c=s.find(e=>e.key.keys.length===1&&keyNames(e.key)[0]===n);if(c&&r!==void 0)return{kind:`edited`,text:`${e.slice(0,c.value.range[0])}${renderTomlInline(r)}${e.slice(c.value.range[1])}`};if(c){let t=e.lastIndexOf(`
|
|
484
|
-
`,c.range[0]-1)+1,n=lineEndAt(e,c.range[1]);return{kind:`edited`,text:`${e.slice(0,t)}${e.slice(Math.min(n+1,e.length))}`}}if(r===void 0)return{kind:`edited`,text:e};let l=lineEndAt(e,s.at(-1)?.range[1]??o.range[0]);return{kind:`edited`,text:`${e.slice(0,l)}\n${tomlKey(n)} = ${renderTomlInline(r)}${e.slice(l)}`}}function read$1(e,t){let n=v(e,t);return r(n)?o(n,`utf8`):void 0}__name(read$1,`read`);const
|
|
485
|
-
`,`\n${t.repeat(n)}`)}function objectAt(e,t){let n=e&&(t.length?zi(e,t):e);return n?.type===`object`?n:void 0}function insertJsonProperty(e,t,n,r){let i=objectAt(Ri(e),t);if(!i||zi(i,[n]))return;let a=t.length+1,o=indentUnit(e),s=`${o.repeat(a)}${JSON.stringify(n)}: ${jsonAt(r,o,a)}`,c=i.children?.at(-1);if(c){let t=c.offset+c.length;return`${e.slice(0,t)},\n${s}${e.slice(t)}`}let l=i.offset+1,u=i.offset+i.length-1;return`${e.slice(0,l)}\n${s}\n${o.repeat(a-1)}${e.slice(u)}`}function replaceJsonValue(e,t,n){let r=Ri(e),i=r&&zi(r,t);if(!i)return{kind:`refused`,reason:`absent`};let a=i.offset+i.length,o=e.slice(i.offset,a);return stripJsonComments(o)===o?{kind:`edited`,text:`${e.slice(0,i.offset)}${jsonAt(n,indentUnit(e),t.length)}${e.slice(a)}`}:{kind:`refused`,reason:`comment`}}function createFile(e,t,n){return e.format===`toml`?renderTomlTable([e.key,t],n):`${JSON.stringify({[e.key]:{[t]:n}},null,2)}\n`}function appendServer(e,t,n,r){return e.format===`toml`?appendTomlTable(t,[e.key,n],r):insertJsonProperty(t,[e.key],n,r)??insertJsonProperty(t,[],e.key,{[n]:r})}function replaceServer(e,t,n,r){let i=e.format===`toml`?replaceTomlTable(t,[e.key,n],r):replaceJsonValue(t,[e.key,n],r);return i.kind===`edited`?i.text:void 0}function renderEntry(e,t,n){return e.format===`toml`?renderTomlTable([e.key,t],n):JSON.stringify({[t]:n},null,2)}function read(e,t){let n=v(e,t);return r(n)?o(n,`utf8`):void 0}const
|
|
485
|
+
`,c.range[0]-1)+1,n=lineEndAt(e,c.range[1]);return{kind:`edited`,text:`${e.slice(0,t)}${e.slice(Math.min(n+1,e.length))}`}}if(r===void 0)return{kind:`edited`,text:e};let l=lineEndAt(e,s.at(-1)?.range[1]??o.range[0]);return{kind:`edited`,text:`${e.slice(0,l)}\n${tomlKey(n)} = ${renderTomlInline(r)}${e.slice(l)}`}}function read$1(e,t){let n=v(e,t);return r(n)?o(n,`utf8`):void 0}__name(read$1,`read`);const Mc={both:`both sides changed since the last projection — a three-way conflict for a person to settle, never imported`,unknown:`no baseline says which side changed — compare the two by hand; never imported`};function inferredTransport(e){return e.url===void 0?`stdio`:`http`}function mapValue(e,t){let n=Object.entries(e).flatMap(([e])=>{let n=isRecord$1(t)?t[e]:void 0;return typeof n==`string`?[[e,n]]:[]});return n.length?Object.fromEntries(n):void 0}function reconcileMcp({root:e,git:t,accept:n}){let r=read$1(e,ho),i=parseGoldenSet(r);if(i.kind!==`servers`)return i;let a=parseProjectionRecord(read$1(e,go)),o=new McpBaseline({git:t,record:a}),s=[],c=[];for(let t of mcpTargets(e)){let n=parseTarget(t,read$1(e,t.path));if(n.kind===`unreadable`){s.push({path:t.path,action:`refuse`,detail:`the target does not parse`});continue}if(n.kind===`absent`)continue;let r=oo[t.dialect];for(let[e,a]of n.servers){let n=i.servers.get(e),at=n=>locatorText({file:t.path,server:e,field:n}),offer=(i,o)=>{let l=literalsIn(i,o);for(let e of l)s.push({path:at(e),action:`refuse`,detail:`${e} holds a literal credential, which never enters the golden set — set it in the environment and reference it as \${VAR}`});let u=withoutLiterals(i,o,l,n);if(l.length&&(u===void 0||sameField(i,{[i]:u},n)))return;let d=r.defaults?.[i];if(d!==void 0&&sameField(i,{[i]:u},{[i]:d})){s.push({path:at(i),action:`skip`,detail:`${t.dialect} fills this in by default, so it may not be the user's — set it in the golden set by hand if it is`});return}let p={path:at(i),action:`import`,detail:n?`only the harness changed it — approve to take it into the golden set`:`the golden set does not declare this server — approve each field to add it`,value:u===void 0?`(unset)`:`${i} = ${renderTomlInline(u)}`};s.push(p),c.push({row:p,config:t,server:e,field:i,value:u,carried:a,adds:!n})};if(!n){for(let e of Za)r.fields.has(e)&&a[e]!==void 0&&(e!==`transport`||a.transport!==inferredTransport(a))&&offer(e,a[e]);continue}for(let i of divergingFields(n,a,r.fields)){let r=o.directionOf(t,e,i,n,a);r!==`golden`&&(r===`target`?offer(i,i===`env`||i===`headers`?mapValue(n[i],a[i]):a[i]):s.push({path:at(i),action:`skip`,detail:Mc[r]}))}}}if(!n.length)return{kind:`planned`,rows:s,written:!1};let l=approve(c,s,n);if(l.kind===`rejected`)return l;let u=r,d=[];for(let[e,t]of groupByServer(l.offers)){if(t[0]?.adds){let n=Object.fromEntries(Za.flatMap(e=>{let n=t.find(t=>t.field===e);return n?[[e,n.value]]:[]}));u=land(u,appendInlineTomlTable(u,[`servers`,e],n),e,n,t,d);continue}for(let n of t){let t={...parseGoldenSet(u).servers.get(e),[n.field]:n.value};n.value===void 0&&delete t[n.field];let r=setTomlKey(u,[`servers`,e],n.field,n.value);u=land(u,r.kind===`edited`?r.text:void 0,e,t,[n],d)}}return u!==r&&(m(v(e,ho),u),writeRecord$1(e,a,o,d,parseGoldenSet(u))),{kind:`planned`,rows:s,written:!0}}function literalsIn(e,t){return t===void 0?[]:e===`args`?nonSecretArgs(t).length===t.length?[]:[`args`]:e!==`env`&&e!==`headers`&&e!==`url`?[]:credentialFields({[e]:t})}function withoutLiterals(e,t,n,r){if(!n.length)return t;if(e!==`env`&&e!==`headers`)return;let i={...t};for(let t of n){let n=t.slice(e.length+1),a=r?.[e]?.[n];a===void 0?delete i[n]:i[n]=a}return Object.keys(i).length?i:void 0}function approve(e,t,n){let r=[],i=[];for(let a of new Set(n)){let n=e.find(e=>e.row.path===a);if(n)i.push(n);else{let e=t.find(e=>e.path===a);r.push(e?`${a} is ${e.action}, not importable: ${e.detail}`:`${a} names no importable field`)}}for(let[e,t]of groupByServer(i)){for(let n of new Set(t.map(e=>e.field))){let i=t.filter(e=>e.field===n);i.some(e=>!sameField(n,{[n]:e.value},{[n]:i[0]?.value}))&&r.push(`servers.${e}.${n} is approved from more than one target with different values — approve one`)}t[0]?.adds&&!t.some(e=>e.field===`command`||e.field===`url`)&&r.push(`servers.${e} would be added with nothing to run — approve its command or url too`)}return r.length?{kind:`rejected`,reasons:r}:{kind:`approved`,offers:i}}function groupByServer(e){let t=new Map;for(let n of e)t.set(n.server,[...t.get(n.server)??[],n]);return t}function land(e,t,n,r,i,a){let o=parseGoldenSet(e),s=t===void 0?void 0:parseGoldenSet(t),c=s?.kind===`servers`&&Za.every(e=>e===`transport`&&r.transport===void 0||sameField(e,s.servers.get(n),r))&&[...o.servers].every(([e,t])=>e===n||JSON.stringify(s.servers.get(e))===JSON.stringify(t));for(let e of i)e.row.action=c?`imported`:`edit`,e.row.detail=c?`written into the golden set`:`the golden set writes this server in a shape that cannot be edited byte-safely — apply the value by hand`;return c?(a.push(...i),t):e}function writeRecord$1(e,t,n,r,i){for(let e of r){let r=t.get(e.config.path)??new Map,a=r.get(e.server),o=a?{...a,[e.field]:e.value}:baseEntry(e,n,i.servers.get(e.server));o&&(e.value===void 0&&delete o[e.field],r.set(e.server,o),t.set(e.config.path,r))}let o=v(e,go);a(g(o),{recursive:!0}),m(o,formatProjectionRecord(t))}__name(writeRecord$1,`writeRecord`);function baseEntry(e,t,n){if(e.adds)return{...n};let r={};for(let i of oo[e.config.dialect].fields){if(n[i]===void 0)continue;if(sameField(i,n,e.carried)){r[i]=n[i];continue}let a=t.baseFor(e.config,e.server,i);if(!a)return;r[i]=a[i]}return r}const Nc=command({name:`reconcile`,description:`Import a harness-side MCP change into the golden set, one approved field at a time. A dry run unless --accept names a field.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:q(K())},accept:{description:`Approve one field by the path a dry run lists for it; repeat for each field. There is no approve-all.`,type:q(In(K()))},format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`}},run(e){try{let t=parseFormat(e.format),n=e.root??process.cwd(),r=e.accept??[],i=reconcileMcp({root:n,git:new GitBridgeState(n),accept:r});if(i.kind===`unreadable`){let e=i.position?` at line ${i.position.line}, column ${i.position.column}`:``;return process.stderr.write(`error: ${ho} does not parse${e}.\n`),O.error}return i.kind===`rejected`?(process.stderr.write(`error: nothing written.\n${i.reasons.map(e=>`- ${e}\n`).join(``)}`),O.error):i.kind===`absent`?(writeResult({golden:`0 servers — no golden set at ${ho}`,mode:`nothing to reconcile into`,fields:`0 fields`,record:`not written`},t),O.success):(writeResult({golden:ho,mode:i.written?`written — only the fields named by --accept`:`dry run — nothing written; re-run with --accept <path> for each approved field`,fields:i.rows.length?i.rows:`0 fields — no harness holds a change the golden set lacks`,record:i.written?go:`not written — dry run`},t),O.success)}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`MCP reconcile failed.`}\n`),O.error}}});function indentUnit(e){let t=/\n([ \t]+)\S/.exec(e);return t?t[1]:` `}function jsonAt(e,t,n){return JSON.stringify(e,null,t).replaceAll(`
|
|
486
|
+
`,`\n${t.repeat(n)}`)}function objectAt(e,t){let n=e&&(t.length?zi(e,t):e);return n?.type===`object`?n:void 0}function insertJsonProperty(e,t,n,r){let i=objectAt(Ri(e),t);if(!i||zi(i,[n]))return;let a=t.length+1,o=indentUnit(e),s=`${o.repeat(a)}${JSON.stringify(n)}: ${jsonAt(r,o,a)}`,c=i.children?.at(-1);if(c){let t=c.offset+c.length;return`${e.slice(0,t)},\n${s}${e.slice(t)}`}let l=i.offset+1,u=i.offset+i.length-1;return`${e.slice(0,l)}\n${s}\n${o.repeat(a-1)}${e.slice(u)}`}function replaceJsonValue(e,t,n){let r=Ri(e),i=r&&zi(r,t);if(!i)return{kind:`refused`,reason:`absent`};let a=i.offset+i.length,o=e.slice(i.offset,a);return stripJsonComments(o)===o?{kind:`edited`,text:`${e.slice(0,i.offset)}${jsonAt(n,indentUnit(e),t.length)}${e.slice(a)}`}:{kind:`refused`,reason:`comment`}}function createFile(e,t,n){return e.format===`toml`?renderTomlTable([e.key,t],n):`${JSON.stringify({[e.key]:{[t]:n}},null,2)}\n`}function appendServer(e,t,n,r){return e.format===`toml`?appendTomlTable(t,[e.key,n],r):insertJsonProperty(t,[e.key],n,r)??insertJsonProperty(t,[],e.key,{[n]:r})}function replaceServer(e,t,n,r){let i=e.format===`toml`?replaceTomlTable(t,[e.key,n],r):replaceJsonValue(t,[e.key,n],r);return i.kind===`edited`?i.text:void 0}function renderEntry(e,t,n){return e.format===`toml`?renderTomlTable([e.key,t],n):JSON.stringify({[t]:n},null,2)}function read(e,t){let n=v(e,t);return r(n)?o(n,`utf8`):void 0}const Pc={target:`the target changed since the last projection — reconcile it into the golden set first`,both:`both sides changed since the last projection — a three-way conflict for a person to settle`,unknown:`no baseline says which side changed — compare the two by hand`};function heldBack(e){return[`both`,`unknown`,`target`].find(t=>e.includes(t))}function projectMcp({root:e,git:t,write:n}){let r=parseGoldenSet(read(e,ho));if(r.kind!==`servers`)return r;let i=parseProjectionRecord(read(e,go)),a=new McpBaseline({git:t,record:i}),o=[],s=[],c=[];for(let t of mcpTargets(e)){let n=read(e,t.path),i=parseTarget(t,n);if(i.kind===`unreadable`){o.push({target:t.path,server:``,action:`refuse`,detail:`the target does not parse`});continue}let l={config:t,source:n,created:n===void 0,servers:i.kind===`servers`?i.servers:new Map,agreed:new Map};c.push(l);let u=oo[t.dialect];for(let[e,n]of r.servers){let row=(n,r)=>o.push({target:t.path,server:e,action:n,detail:r}),r=credentialFields(n)[0];if(r){row(`refuse`,`the golden set holds a literal credential at ${r} — reference it as \${VAR} first`);continue}let i=u.write(n);if(i.kind===`refused`){row(`refuse`,`${i.field}: ${i.reason}`);continue}let c=l.servers.get(e);if(!c){let r=l.source===void 0?createFile(t,e,i.entry):appendServer(t,l.source,e,i.entry);apply(l,e,n,i.entry,r,l.created?`creates the file`:`appends the server`,row,s);continue}let d=divergingFields(n,c,u.fields);if(!d.length){l.agreed.set(e,n);continue}let p=heldBack(d.map(r=>a.directionOf(t,e,r,n,c)));if(p){row(`skip`,Pc[p]);continue}let m=replaceServer(t,l.source,e,i.entry);apply(l,e,n,i.entry,m,`replaces ${d.join(`, `)}`,row,s)}}if(n){for(let t of c)t.source!==void 0&&t.source!==read(e,t.config.path)&&writeTarget(e,t);writeRecord(e,i,c)}return{kind:`planned`,rows:o,entries:s,written:n}}function apply(e,t,n,r,i,a,o,s){let c=!e.servers.has(t),l=i!==void 0&&readsBack(e,t,n,i),u=l?c?`add`:`update`:`edit`;if(s.push({target:e.config.path,server:t,action:u,entry:renderEntry(e.config,t,r)}),!l){o(`edit`,c?`the file has no safe place to add it — apply the entry by hand`:`an in-place change here is applied by hand`);return}e.source=i,e.servers=parseTarget(e.config,i).servers,e.agreed.set(t,n),o(u,a)}function readsBack(e,t,n,r){let i=parseTarget(e.config,r);if(i.kind!==`servers`)return!1;let a=i.servers.get(t),o=oo[e.config.dialect].fields;return!a||divergingFields(n,a,o).length?!1:[...e.servers].every(([e,n])=>{if(e===t)return!0;let r=i.servers.get(e);return r!==void 0&&JSON.stringify(r)===JSON.stringify(n)})}function writeTarget(e,t){let n=v(e,t.config.path);a(g(n),{recursive:!0}),m(n,t.source)}function writeRecord(e,t,n){for(let e of n){let n=t.get(e.config.path)??new Map;for(let[t,r]of e.agreed)n.set(t,r);n.size&&t.set(e.config.path,n)}let r=v(e,go);a(g(r),{recursive:!0}),m(r,formatProjectionRecord(t))}const Fc={name:`buddy-agent-harness`,description:`Initialize agent harness skill compatibility in consumer repositories.`,commands:[fc,$s,command({name:`mcp`,description:`Work with the golden MCP server set at .agents/buddy-agent-harness/mcp.toml.`,commands:[command({name:`project`,description:`Project the golden MCP server set into each enabled harness. A dry run unless --write; never overwrites a change made on the harness side.`,options:{root:{description:`Repository or package directory. Defaults to the current directory.`,type:q(K())},write:{description:`Apply the plan and record what was projected. Without it nothing on disk changes.`,type:q(Fn())},format:{description:`Output format: toon (default), json, or text for a human-readable report.`,type:q(K()),default:`toon`}},run(e){try{let t=parseFormat(e.format),n=e.root??process.cwd(),r=e.write===!0,i=projectMcp({root:n,git:new GitBridgeState(n),write:r});if(i.kind===`unreadable`){let e=i.position?` at line ${i.position.line}, column ${i.position.column}`:``;return process.stderr.write(`error: ${ho} does not parse${e}.\n`),O.error}return i.kind===`absent`?(writeResult({golden:`0 servers — no golden set at ${ho}`,mode:`nothing to project`,actions:`0 changes`,record:`not written`},t),O.success):(writeResult({golden:ho,mode:r?`written`:`dry run — nothing written; re-run with --write to apply`,actions:i.rows.length?i.rows:`0 changes — every enabled harness already carries the golden set`,...i.entries.length?{entries:i.entries}:{},record:r?go:`not written — dry run`},t),O.success)}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`MCP projection failed.`}\n`),O.error}}}),Nc]}),ha,dc,rc]};function app(){let[e,...t]=Fc.commands;return t.reduce((e,t)=>e.command(t),cli({name:Fc.name,version:`0.18.0`,description:Fc.description}).command(e))}async function run(e){try{let t=await app().parse(e);return typeof t==`number`?t:O.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Invalid command.`}\n`),O.usage}}process.exitCode=await run([...process.argv.slice(0,2),`doctor`,...process.argv.slice(2)]);export{};
|