@rpamis/comet 0.4.0-rc.6 → 0.4.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/LICENSE +21 -21
- package/README.md +332 -333
- package/assets/manifest.json +1 -1
- package/assets/skills/comet/scripts/comet-archive.mjs +56 -51
- package/assets/skills/comet/scripts/comet-entry-runtime.mjs +22 -20
- package/assets/skills/comet/scripts/comet-guard.mjs +93 -88
- package/assets/skills/comet/scripts/comet-handoff.mjs +111 -106
- package/assets/skills/comet/scripts/comet-hook-guard.mjs +54 -49
- package/assets/skills/comet/scripts/comet-hook-router.mjs +106 -106
- package/assets/skills/comet/scripts/comet-intent.mjs +12 -7
- package/assets/skills/comet/scripts/comet-resume-probe.mjs +50 -45
- package/assets/skills/comet/scripts/comet-runtime.mjs +180 -175
- package/assets/skills/comet/scripts/comet-state.mjs +80 -75
- package/assets/skills/comet/scripts/comet-yaml-validate.mjs +57 -52
- package/assets/skills/comet-classic/reference/scripts.md +1 -1
- package/assets/skills/comet-native/SKILL.md +3 -3
- package/assets/skills/comet-native/scripts/comet-native-archive.mjs +31 -31
- package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +51 -51
- package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +3 -3
- package/assets/skills/comet-native/scripts/comet-native-init.mjs +37 -37
- package/assets/skills/comet-native/scripts/comet-native-new.mjs +33 -33
- package/assets/skills/comet-native/scripts/comet-native-next.mjs +43 -43
- package/assets/skills/comet-native/scripts/comet-native-root.mjs +3 -3
- package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +71 -71
- package/assets/skills/comet-native/scripts/comet-native-select.mjs +36 -36
- package/assets/skills/comet-native/scripts/comet-native-show.mjs +27 -27
- package/assets/skills/comet-native/scripts/comet-native-spec.mjs +23 -23
- package/assets/skills/comet-native/scripts/comet-native-status.mjs +39 -39
- package/assets/skills-zh/comet-classic/reference/scripts.md +1 -1
- package/assets/skills-zh/comet-native/SKILL.md +3 -3
- package/bin/fast-runtime-router.js +1 -1
- package/dist/app/cli/index.js +7 -1
- package/dist/app/cli/index.js.map +1 -1
- package/dist/app/commands/classic.js +4 -0
- package/dist/app/commands/classic.js.map +1 -1
- package/dist/app/commands/doctor.d.ts +1 -1
- package/dist/app/commands/doctor.d.ts.map +1 -1
- package/dist/app/commands/doctor.js +2 -1
- package/dist/app/commands/doctor.js.map +1 -1
- package/dist/app/commands/eval.js +2 -2
- package/dist/app/commands/eval.js.map +1 -1
- package/dist/app/commands/init.d.ts.map +1 -1
- package/dist/app/commands/init.js +16 -5
- package/dist/app/commands/init.js.map +1 -1
- package/dist/app/commands/personal-memory.d.ts.map +1 -1
- package/dist/app/commands/personal-memory.js +5 -0
- package/dist/app/commands/personal-memory.js.map +1 -1
- package/dist/app/commands/project-knowledge.d.ts.map +1 -1
- package/dist/app/commands/project-knowledge.js +26 -2
- package/dist/app/commands/project-knowledge.js.map +1 -1
- package/dist/app/commands/status.d.ts.map +1 -1
- package/dist/app/commands/status.js +17 -10
- package/dist/app/commands/status.js.map +1 -1
- package/dist/app/commands/uninstall.d.ts.map +1 -1
- package/dist/app/commands/uninstall.js +5 -1
- package/dist/app/commands/uninstall.js.map +1 -1
- package/dist/app/commands/update.d.ts.map +1 -1
- package/dist/app/commands/update.js +10 -4
- package/dist/app/commands/update.js.map +1 -1
- package/dist/domains/agent-learning/context-director.d.ts.map +1 -1
- package/dist/domains/agent-learning/context-director.js +14 -10
- package/dist/domains/agent-learning/context-director.js.map +1 -1
- package/dist/domains/comet-classic/classic-archive.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-archive.js +3 -0
- package/dist/domains/comet-classic/classic-archive.js.map +1 -1
- package/dist/domains/comet-classic/classic-cli-help.d.ts +3 -0
- package/dist/domains/comet-classic/classic-cli-help.d.ts.map +1 -0
- package/dist/domains/comet-classic/classic-cli-help.js +40 -0
- package/dist/domains/comet-classic/classic-cli-help.js.map +1 -0
- package/dist/domains/comet-classic/classic-cli.d.ts +1 -0
- package/dist/domains/comet-classic/classic-cli.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-cli.js +5 -0
- package/dist/domains/comet-classic/classic-cli.js.map +1 -1
- package/dist/domains/comet-classic/classic-guard.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-guard.js +12 -2
- package/dist/domains/comet-classic/classic-guard.js.map +1 -1
- package/dist/domains/comet-classic/classic-handoff.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-handoff.js +11 -10
- package/dist/domains/comet-classic/classic-handoff.js.map +1 -1
- package/dist/domains/comet-classic/classic-script-entry.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-script-entry.js +4 -1
- package/dist/domains/comet-classic/classic-script-entry.js.map +1 -1
- package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-state-command.js +37 -18
- package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
- package/dist/domains/comet-classic/classic-validate-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-validate-command.js +2 -0
- package/dist/domains/comet-classic/classic-validate-command.js.map +1 -1
- package/dist/domains/comet-classic/classic-workspace.d.ts +1 -0
- package/dist/domains/comet-classic/classic-workspace.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-workspace.js +2 -1
- package/dist/domains/comet-classic/classic-workspace.js.map +1 -1
- package/dist/domains/comet-entry/entry-runtime.d.ts.map +1 -1
- package/dist/domains/comet-entry/entry-runtime.js +13 -3
- package/dist/domains/comet-entry/entry-runtime.js.map +1 -1
- package/dist/domains/comet-memory/plugin.js +4 -9
- package/dist/domains/comet-memory/plugin.js.map +1 -1
- package/dist/domains/comet-memory/repository.d.ts +3 -0
- package/dist/domains/comet-memory/repository.d.ts.map +1 -1
- package/dist/domains/comet-memory/repository.js +117 -25
- package/dist/domains/comet-memory/repository.js.map +1 -1
- package/dist/domains/comet-memory/review-contract.d.ts.map +1 -1
- package/dist/domains/comet-memory/review-contract.js +4 -2
- package/dist/domains/comet-memory/review-contract.js.map +1 -1
- package/dist/domains/comet-native/native-check-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-check-command.js +5 -1
- package/dist/domains/comet-native/native-check-command.js.map +1 -1
- package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli-help.js +7 -2
- package/dist/domains/comet-native/native-cli-help.js.map +1 -1
- package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-next-command.js +22 -1
- package/dist/domains/comet-native/native-next-command.js.map +1 -1
- package/dist/domains/comet-native/native-output-language.d.ts.map +1 -1
- package/dist/domains/comet-native/native-output-language.js +3 -1
- package/dist/domains/comet-native/native-output-language.js.map +1 -1
- package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-continuation.js +11 -0
- package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
- package/dist/domains/comet-plugin/integration.d.ts.map +1 -1
- package/dist/domains/comet-plugin/integration.js +14 -8
- package/dist/domains/comet-plugin/integration.js.map +1 -1
- package/dist/domains/comet-plugin/plugin-runtime.d.ts +2 -2
- package/dist/domains/comet-plugin/plugin-runtime.d.ts.map +1 -1
- package/dist/domains/comet-plugin/plugin-runtime.js +89 -77
- package/dist/domains/comet-plugin/plugin-runtime.js.map +1 -1
- package/dist/domains/comet-plugin/types.d.ts +2 -0
- package/dist/domains/comet-plugin/types.d.ts.map +1 -1
- package/dist/domains/dashboard/server.d.ts.map +1 -1
- package/dist/domains/dashboard/server.js +20 -0
- package/dist/domains/dashboard/server.js.map +1 -1
- package/dist/domains/dashboard/web/index.html +14 -14
- package/dist/domains/integrations/openspec.d.ts.map +1 -1
- package/dist/domains/integrations/openspec.js +4 -3
- package/dist/domains/integrations/openspec.js.map +1 -1
- package/dist/domains/integrations/superpowers.js +2 -2
- package/dist/domains/integrations/superpowers.js.map +1 -1
- package/dist/domains/project-knowledge/corpus.d.ts.map +1 -1
- package/dist/domains/project-knowledge/corpus.js +5 -2
- package/dist/domains/project-knowledge/corpus.js.map +1 -1
- package/dist/domains/skill/languages.d.ts +3 -1
- package/dist/domains/skill/languages.d.ts.map +1 -1
- package/dist/domains/skill/languages.js +26 -1
- package/dist/domains/skill/languages.js.map +1 -1
- package/dist/domains/skill/uninstall.d.ts.map +1 -1
- package/dist/domains/skill/uninstall.js +16 -0
- package/dist/domains/skill/uninstall.js.map +1 -1
- package/dist/platform/process/git-environment.d.ts +3 -0
- package/dist/platform/process/git-environment.d.ts.map +1 -0
- package/dist/platform/process/git-environment.js +26 -0
- package/dist/platform/process/git-environment.js.map +1 -0
- package/eval/langsmith/tests/tasks/test_tasks.py +6 -0
- package/eval/local/tests/scaffold/test_langsmith_conftest.py +10 -0
- package/package.json +2 -2
|
@@ -1,166 +1,171 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cometCreateRequire } from 'module';
|
|
3
3
|
const require = __cometCreateRequire(import.meta.url);
|
|
4
|
-
var
|
|
5
|
-
`)}};Ot.defaultYaml={explicit:!1,version:"1.2"};Ot.defaultTags={"!!":"tag:yaml.org,2002:"}
|
|
4
|
+
var Zu=Object.create;var nr=Object.defineProperty;var ef=Object.getOwnPropertyDescriptor;var tf=Object.getOwnPropertyNames;var nf=Object.getPrototypeOf,rf=Object.prototype.hasOwnProperty;var bn=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(i){throw n=[i],i}};var v=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}},of=(t,e)=>{for(var n in e)nr(t,n,{get:e[n],enumerable:!0})},sf=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of tf(e))!rf.call(t,r)&&r!==n&&nr(t,r,{get:()=>e[r],enumerable:!(i=ef(e,r))||i.enumerable});return t};var Pt=(t,e,n)=>(n=t!=null?Zu(nf(t)):{},sf(e||!t||!t.__esModule?nr(n,"default",{value:t,enumerable:!0}):n,t));var x=v(W=>{"use strict";var ir=Symbol.for("yaml.alias"),xs=Symbol.for("yaml.document"),Sn=Symbol.for("yaml.map"),Ps=Symbol.for("yaml.pair"),rr=Symbol.for("yaml.scalar"),Cn=Symbol.for("yaml.seq"),pe=Symbol.for("yaml.node.type"),af=t=>!!t&&typeof t=="object"&&t[pe]===ir,cf=t=>!!t&&typeof t=="object"&&t[pe]===xs,lf=t=>!!t&&typeof t=="object"&&t[pe]===Sn,uf=t=>!!t&&typeof t=="object"&&t[pe]===Ps,Rs=t=>!!t&&typeof t=="object"&&t[pe]===rr,ff=t=>!!t&&typeof t=="object"&&t[pe]===Cn;function Os(t){if(t&&typeof t=="object")switch(t[pe]){case Sn:case Cn:return!0}return!1}function df(t){if(t&&typeof t=="object")switch(t[pe]){case ir:case Sn:case rr:case Cn:return!0}return!1}var pf=t=>(Rs(t)||Os(t))&&!!t.anchor;W.ALIAS=ir;W.DOC=xs;W.MAP=Sn;W.NODE_TYPE=pe;W.PAIR=Ps;W.SCALAR=rr;W.SEQ=Cn;W.hasAnchor=pf;W.isAlias=af;W.isCollection=Os;W.isDocument=cf;W.isMap=lf;W.isNode=df;W.isPair=uf;W.isScalar=Rs;W.isSeq=ff});var Rt=v(or=>{"use strict";var q=x(),H=Symbol("break visit"),As=Symbol("skip children"),ae=Symbol("remove node");function En(t,e){let n=Ns(e);q.isDocument(t)?st(null,t.contents,n,Object.freeze([t]))===ae&&(t.contents=null):st(null,t,n,Object.freeze([]))}En.BREAK=H;En.SKIP=As;En.REMOVE=ae;function st(t,e,n,i){let r=js(t,e,n,i);if(q.isNode(r)||q.isPair(r))return Ts(t,i,r),st(t,r,n,i);if(typeof r!="symbol"){if(q.isCollection(e)){i=Object.freeze(i.concat(e));for(let o=0;o<e.items.length;++o){let s=st(o,e.items[o],n,i);if(typeof s=="number")o=s-1;else{if(s===H)return H;s===ae&&(e.items.splice(o,1),o-=1)}}}else if(q.isPair(e)){i=Object.freeze(i.concat(e));let o=st("key",e.key,n,i);if(o===H)return H;o===ae&&(e.key=null);let s=st("value",e.value,n,i);if(s===H)return H;s===ae&&(e.value=null)}}return r}async function _n(t,e){let n=Ns(e);q.isDocument(t)?await at(null,t.contents,n,Object.freeze([t]))===ae&&(t.contents=null):await at(null,t,n,Object.freeze([]))}_n.BREAK=H;_n.SKIP=As;_n.REMOVE=ae;async function at(t,e,n,i){let r=await js(t,e,n,i);if(q.isNode(r)||q.isPair(r))return Ts(t,i,r),at(t,r,n,i);if(typeof r!="symbol"){if(q.isCollection(e)){i=Object.freeze(i.concat(e));for(let o=0;o<e.items.length;++o){let s=await at(o,e.items[o],n,i);if(typeof s=="number")o=s-1;else{if(s===H)return H;s===ae&&(e.items.splice(o,1),o-=1)}}}else if(q.isPair(e)){i=Object.freeze(i.concat(e));let o=await at("key",e.key,n,i);if(o===H)return H;o===ae&&(e.key=null);let s=await at("value",e.value,n,i);if(s===H)return H;s===ae&&(e.value=null)}}return r}function Ns(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function js(t,e,n,i){if(typeof n=="function")return n(t,e,i);if(q.isMap(e))return n.Map?.(t,e,i);if(q.isSeq(e))return n.Seq?.(t,e,i);if(q.isPair(e))return n.Pair?.(t,e,i);if(q.isScalar(e))return n.Scalar?.(t,e,i);if(q.isAlias(e))return n.Alias?.(t,e,i)}function Ts(t,e,n){let i=e[e.length-1];if(q.isCollection(i))i.items[t]=n;else if(q.isPair(i))t==="key"?i.key=n:i.value=n;else if(q.isDocument(i))i.contents=n;else{let r=q.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}or.visit=En;or.visitAsync=_n});var sr=v($s=>{"use strict";var Is=x(),mf=Rt(),hf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},gf=t=>t.replace(/[!,[\]{}]/g,e=>hf[e]),Ot=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \t]+/),r=i.shift();switch(r){case"%TAG":{if(i.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[o,s]=i;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[o]=i;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return n(6,`Unsupported YAML version ${o}`,s),!1}}default:return n(0,`Unknown directive ${r}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);return s==="!"||s==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),s)}let[,i,r]=e.match(/^(.*!)([^!]*)$/s);r||n(`The ${e} tag has no suffix`);let o=this.tags[i];if(o)try{return o+decodeURIComponent(r)}catch(s){return n(String(s)),null}return i==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,i]of Object.entries(this.tags))if(e.startsWith(i))return n+gf(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),r;if(e&&i.length>0&&Is.isNode(e.contents)){let o={};mf.visit(e.contents,(s,a)=>{Is.isNode(a)&&a.tag&&(o[a.tag]=!0)}),r=Object.keys(o)}else r=[];for(let[o,s]of i)o==="!!"&&s==="tag:yaml.org,2002:"||(!e||r.some(a=>a.startsWith(s)))&&n.push(`%TAG ${o} ${s}`);return n.join(`
|
|
5
|
+
`)}};Ot.defaultYaml={explicit:!1,version:"1.2"};Ot.defaultTags={"!!":"tag:yaml.org,2002:"};$s.Directives=Ot});var xn=v(At=>{"use strict";var qs=x(),wf=Rt();function yf(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function Ls(t){let e=new Set;return wf.visit(t,{Value(n,i){i.anchor&&e.add(i.anchor)}}),e}function Ws(t,e){for(let n=1;;++n){let i=`${t}${n}`;if(!e.has(i))return i}}function vf(t,e){let n=[],i=new Map,r=null;return{onAnchor:o=>{n.push(o),r??(r=Ls(t));let s=Ws(e,r);return r.add(s),s},setAnchors:()=>{for(let o of n){let s=i.get(o);if(typeof s=="object"&&s.anchor&&(qs.isScalar(s.node)||qs.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:i}}At.anchorIsValid=yf;At.anchorNames=Ls;At.createNodeAnchors=vf;At.findNewAnchor=Ws});var ar=v(Ds=>{"use strict";function Nt(t,e,n,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let r=0,o=i.length;r<o;++r){let s=i[r],a=Nt(t,i,String(r),s);a===void 0?delete i[r]:a!==s&&(i[r]=a)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let o=i.get(r),s=Nt(t,i,r,o);s===void 0?i.delete(r):s!==o&&i.set(r,s)}else if(i instanceof Set)for(let r of Array.from(i)){let o=Nt(t,i,r,r);o===void 0?i.delete(r):o!==r&&(i.delete(r),i.add(o))}else for(let[r,o]of Object.entries(i)){let s=Nt(t,i,r,o);s===void 0?delete i[r]:s!==o&&(i[r]=s)}return t.call(e,n,i)}Ds.applyReviver=Nt});var Ee=v(Ms=>{"use strict";var kf=x();function Fs(t,e,n){if(Array.isArray(t))return t.map((i,r)=>Fs(i,String(r),n));if(t&&typeof t.toJSON=="function"){if(!n||!kf.hasAnchor(t))return t.toJSON(e,n);let i={aliasCount:0,count:1,res:void 0};n.anchors.set(t,i),n.onCreate=o=>{i.res=o,delete n.onCreate};let r=t.toJSON(e,n);return n.onCreate&&n.onCreate(r),r}return typeof t=="bigint"&&!n?.keep?Number(t):t}Ms.toJS=Fs});var Pn=v(Ks=>{"use strict";var bf=ar(),Bs=x(),Sf=Ee(),cr=class{constructor(e){Object.defineProperty(this,Bs.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:n,maxAliasCount:i,onAnchor:r,reviver:o}={}){if(!Bs.isDocument(e))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},a=Sf.toJS(this,"",s);if(typeof r=="function")for(let{count:c,res:l}of s.anchors.values())r(l,c);return typeof o=="function"?bf.applyReviver(o,{"":a},"",a):a}};Ks.NodeBase=cr});var jt=v(Hs=>{"use strict";var Cf=xn(),Ef=Rt(),ct=x(),_f=Pn(),xf=Ee(),lr=class extends _f.NodeBase{constructor(e){super(ct.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;n?.aliasResolveCache?i=n.aliasResolveCache:(i=[],Ef.visit(e,{Node:(o,s)=>{(ct.isAlias(s)||ct.hasAnchor(s))&&i.push(s)}}),n&&(n.aliasResolveCache=i));let r;for(let o of i){if(o===this)break;o.anchor===this.source&&(r=o)}return r}toJSON(e,n){if(!n)return{source:this.source};let{anchors:i,doc:r,maxAliasCount:o}=n,s=this.resolve(r,n);if(!s){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=i.get(s);if(a||(xf.toJS(s,null,n),a=i.get(s)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Rn(r,s,i)),a.count*a.aliasCount>o)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,n,i){let r=`*${this.source}`;if(e){if(Cf.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${r} `}return r}};function Rn(t,e,n){if(ct.isAlias(e)){let i=e.resolve(t),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(ct.isCollection(e)){let i=0;for(let r of e.items){let o=Rn(t,r,n);o>i&&(i=o)}return i}else if(ct.isPair(e)){let i=Rn(t,e.key,n),r=Rn(t,e.value,n);return Math.max(i,r)}return 1}Hs.Alias=lr});var T=v(ur=>{"use strict";var Pf=x(),Rf=Pn(),Of=Ee(),Af=t=>!t||typeof t!="function"&&typeof t!="object",_e=class extends Rf.NodeBase{constructor(e){super(Pf.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:Of.toJS(this.value,e,n)}toString(){return String(this.value)}};_e.BLOCK_FOLDED="BLOCK_FOLDED";_e.BLOCK_LITERAL="BLOCK_LITERAL";_e.PLAIN="PLAIN";_e.QUOTE_DOUBLE="QUOTE_DOUBLE";_e.QUOTE_SINGLE="QUOTE_SINGLE";ur.Scalar=_e;ur.isScalarValue=Af});var Tt=v(Ys=>{"use strict";var Nf=jt(),Ve=x(),Us=T(),jf="tag:yaml.org,2002:";function Tf(t,e,n){if(e){let i=n.filter(o=>o.tag===e),r=i.find(o=>!o.format)??i[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return n.find(i=>i.identify?.(t)&&!i.format)}function If(t,e,n){if(Ve.isDocument(t)&&(t=t.contents),Ve.isNode(t))return t;if(Ve.isPair(t)){let f=n.schema[Ve.MAP].createNode?.(n.schema,null,n);return f.items.push(t),f}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:i,onAnchor:r,onTagObj:o,schema:s,sourceObjects:a}=n,c;if(i&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=r(t)),new Nf.Alias(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=jf+e.slice(2));let l=Tf(t,e,s.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let f=new Us.Scalar(t);return c&&(c.node=f),f}l=t instanceof Map?s[Ve.MAP]:Symbol.iterator in Object(t)?s[Ve.SEQ]:s[Ve.MAP]}o&&(o(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,t,n):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(n.schema,t,n):new Us.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}Ys.createNode=If});var An=v(On=>{"use strict";var $f=Tt(),ce=x(),qf=Pn();function fr(t,e,n){let i=n;for(let r=e.length-1;r>=0;--r){let o=e[r];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=i,i=s}else i=new Map([[o,i]])}return $f.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Js=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,dr=class extends qf.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(i=>ce.isNode(i)||ce.isPair(i)?i.clone(e):i),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(Js(e))this.add(n);else{let[i,...r]=e,o=this.get(i,!0);if(ce.isCollection(o))o.addIn(r,n);else if(o===void 0&&this.schema)this.set(i,fr(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}deleteIn(e){let[n,...i]=e;if(i.length===0)return this.delete(n);let r=this.get(n,!0);if(ce.isCollection(r))return r.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(e,n){let[i,...r]=e,o=this.get(i,!0);return r.length===0?!n&&ce.isScalar(o)?o.value:o:ce.isCollection(o)?o.getIn(r,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!ce.isPair(n))return!1;let i=n.value;return i==null||e&&ce.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[n,...i]=e;if(i.length===0)return this.has(n);let r=this.get(n,!0);return ce.isCollection(r)?r.hasIn(i):!1}setIn(e,n){let[i,...r]=e;if(r.length===0)this.set(i,n);else{let o=this.get(i,!0);if(ce.isCollection(o))o.setIn(r,n);else if(o===void 0&&this.schema)this.set(i,fr(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}};On.Collection=dr;On.collectionFromPath=fr;On.isEmptyPath=Js});var It=v(Nn=>{"use strict";var Lf=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function pr(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Wf=(t,e,n)=>t.endsWith(`
|
|
6
6
|
`)?pr(n,e):n.includes(`
|
|
7
7
|
`)?`
|
|
8
|
-
`+pr(n,e):(t.endsWith(" ")?"":" ")+n;Nn.indentComment=pr;Nn.lineComment
|
|
9
|
-
`)n===mr&&(p=
|
|
10
|
-
`&&h!==" "){let
|
|
11
|
-
`&&
|
|
12
|
-
${e}${t.slice(0,C)}`:(n===jn&&
|
|
13
|
-
${e}${t.slice(
|
|
14
|
-
`);i=e,r=e+1,o=t[r]}return i}$t.FOLD_BLOCK=mr;$t.FOLD_FLOW=
|
|
15
|
-
`){if(o-s>i)return!0;if(s=o+1,r-s<=i)return!1}return!0}function qt(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:i}=e,r=e.options.doubleQuotedMinMultiLineLength,o=e.indent||($n(t)?" ":""),s="",a=0;for(let c=0,l=n[c];l;l=n[++c])if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(s+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(n[c+1]){case"u":{s+=n.slice(a,c);let
|
|
8
|
+
`+pr(n,e):(t.endsWith(" ")?"":" ")+n;Nn.indentComment=pr;Nn.lineComment=Wf;Nn.stringifyComment=Lf});var Gs=v($t=>{"use strict";var Df="flow",mr="block",jn="quoted";function Ff(t,e,n="flow",{indentAtStart:i,lineWidth:r=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!r||r<0)return t;r<o&&(o=0);let c=Math.max(1+o,1+r-e.length);if(t.length<=c)return t;let l=[],u={},f=r-e.length;typeof i=="number"&&(i>r-Math.max(2,o)?l.push(0):f=r-i);let d,h,g=!1,p=-1,m=-1,w=-1;n===mr&&(p=Vs(t,p,e.length),p!==-1&&(f=p+c));for(let S;S=t[p+=1];){if(n===jn&&S==="\\"){switch(m=p,t[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}w=p}if(S===`
|
|
9
|
+
`)n===mr&&(p=Vs(t,p,e.length)),f=p+e.length+c,d=void 0;else{if(S===" "&&h&&h!==" "&&h!==`
|
|
10
|
+
`&&h!==" "){let k=t[p+1];k&&k!==" "&&k!==`
|
|
11
|
+
`&&k!==" "&&(d=p)}if(p>=f)if(d)l.push(d),f=d+c,d=void 0;else if(n===jn){for(;h===" "||h===" ";)h=S,S=t[p+=1],g=!0;let k=p>w+1?p-2:m-1;if(u[k])return t;l.push(k),u[k]=!0,f=k+c,d=void 0}else g=!0}h=S}if(g&&a&&a(),l.length===0)return t;s&&s();let y=t.slice(0,l[0]);for(let S=0;S<l.length;++S){let k=l[S],C=l[S+1]||t.length;k===0?y=`
|
|
12
|
+
${e}${t.slice(0,C)}`:(n===jn&&u[k]&&(y+=`${t[k]}\\`),y+=`
|
|
13
|
+
${e}${t.slice(k+1,C)}`)}return y}function Vs(t,e,n){let i=e,r=e+1,o=t[r];for(;o===" "||o===" ";)if(e<r+n)o=t[++e];else{do o=t[++e];while(o&&o!==`
|
|
14
|
+
`);i=e,r=e+1,o=t[r]}return i}$t.FOLD_BLOCK=mr;$t.FOLD_FLOW=Df;$t.FOLD_QUOTED=jn;$t.foldFlowLines=Ff});var Lt=v(zs=>{"use strict";var ee=T(),xe=Gs(),In=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),$n=t=>/^(%|---|\.\.\.)/m.test(t);function Mf(t,e,n){if(!e||e<0)return!1;let i=e-n,r=t.length;if(r<=i)return!1;for(let o=0,s=0;o<r;++o)if(t[o]===`
|
|
15
|
+
`){if(o-s>i)return!0;if(s=o+1,r-s<=i)return!1}return!0}function qt(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:i}=e,r=e.options.doubleQuotedMinMultiLineLength,o=e.indent||($n(t)?" ":""),s="",a=0;for(let c=0,l=n[c];l;l=n[++c])if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(s+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(n[c+1]){case"u":{s+=n.slice(a,c);let u=n.substr(c+2,4);switch(u){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:u.substr(0,2)==="00"?s+="\\x"+u.substr(2):s+=n.substr(c,6)}c+=5,a=c+1}break;case"n":if(i||n[c+2]==='"'||n.length<r)c+=1;else{for(s+=n.slice(a,c)+`
|
|
16
16
|
|
|
17
17
|
`;n[c+2]==="\\"&&n[c+3]==="n"&&n[c+4]!=='"';)s+=`
|
|
18
|
-
`,c+=2;s+=o,n[c+2]===" "&&(s+="\\"),c+=1,a=c+1}break;default:c+=1}return s=a?s+n.slice(a):n,i?s:
|
|
18
|
+
`,c+=2;s+=o,n[c+2]===" "&&(s+="\\"),c+=1,a=c+1}break;default:c+=1}return s=a?s+n.slice(a):n,i?s:xe.foldFlowLines(s,o,xe.FOLD_QUOTED,In(e,!1))}function hr(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
19
19
|
`)||/[ \t]\n|\n[ \t]/.test(t))return qt(t,e);let n=e.indent||($n(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
20
|
-
${n}`)+"'";return e.implicitKey?i:
|
|
20
|
+
${n}`)+"'";return e.implicitKey?i:xe.foldFlowLines(i,n,xe.FOLD_FLOW,In(e,!1))}function lt(t,e){let{singleQuote:n}=e.options,i;if(n===!1)i=qt;else{let r=t.includes('"'),o=t.includes("'");r&&!o?i=hr:o&&!r?i=qt:i=n?hr:qt}return i(t,e)}var gr;try{gr=new RegExp(`(^|(?<!
|
|
21
21
|
))
|
|
22
22
|
+(?!
|
|
23
|
-
|$)`,"g")}catch{gr=/\n+(?!\n|$)/g}function Tn({comment:t,type:e,value:n},i,r,o){let{blockQuote:s,commentString:a,lineWidth:c}=i.options;if(!s||/\n[\t ]+$/.test(n))return
|
|
23
|
+
|$)`,"g")}catch{gr=/\n+(?!\n|$)/g}function Tn({comment:t,type:e,value:n},i,r,o){let{blockQuote:s,commentString:a,lineWidth:c}=i.options;if(!s||/\n[\t ]+$/.test(n))return lt(n,i);let l=i.indent||(i.forceBlockIndent||$n(n)?" ":""),u=s==="literal"?!0:s==="folded"||e===ee.Scalar.BLOCK_FOLDED?!1:e===ee.Scalar.BLOCK_LITERAL?!0:!Mf(n,c,l.length);if(!n)return u?`|
|
|
24
24
|
`:`>
|
|
25
|
-
`;let
|
|
26
|
-
`&&C!==" "&&C!==" ")break}let h=n.substring(d),
|
|
27
|
-
`);
|
|
28
|
-
`&&(h=h.slice(0,-1)),h=h.replace(gr,`$&${l}`));let p=!1,m,
|
|
29
|
-
`)
|
|
30
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,
|
|
31
|
-
${l}${
|
|
32
|
-
${l}${
|
|
33
|
-
`)||
|
|
34
|
-
`)?
|
|
35
|
-
`))return Tn(t,e,n,i);if($n(o)){if(c==="")return e.forceBlockIndent=!0,Tn(t,e,n,i);if(a&&c===l)return
|
|
36
|
-
${c}`);if(s){let d=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(
|
|
37
|
-
${e.indent}${a}`:a}wr.createStringifyContext=
|
|
38
|
-
${a}:`):(m=`${m}:`,d&&(m+=Dt.lineComment(m,n.indent,l(d))));let y,
|
|
39
|
-
`:"",
|
|
40
|
-
${Dt.indentComment(
|
|
41
|
-
`&&
|
|
25
|
+
`;let f,d;for(d=n.length;d>0;--d){let C=n[d-1];if(C!==`
|
|
26
|
+
`&&C!==" "&&C!==" ")break}let h=n.substring(d),g=h.indexOf(`
|
|
27
|
+
`);g===-1?f="-":n===h||g!==h.length-1?(f="+",o&&o()):f="",h&&(n=n.slice(0,-h.length),h[h.length-1]===`
|
|
28
|
+
`&&(h=h.slice(0,-1)),h=h.replace(gr,`$&${l}`));let p=!1,m,w=-1;for(m=0;m<n.length;++m){let C=n[m];if(C===" ")p=!0;else if(C===`
|
|
29
|
+
`)w=m;else break}let y=n.substring(0,w<m?w+1:m);y&&(n=n.substring(y.length),y=y.replace(/\n+/g,`$&${l}`));let k=(p?l?"2":"1":"")+f;if(t&&(k+=" "+a(t.replace(/ ?[\r\n]+/g," ")),r&&r()),!u){let C=n.replace(/\n+/g,`
|
|
30
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,P=In(i,!0);s!=="folded"&&e!==ee.Scalar.BLOCK_FOLDED&&(P.onOverflow=()=>{E=!0});let b=xe.foldFlowLines(`${y}${C}${h}`,l,xe.FOLD_BLOCK,P);if(!E)return`>${k}
|
|
31
|
+
${l}${b}`}return n=n.replace(/\n+/g,`$&${l}`),`|${k}
|
|
32
|
+
${l}${y}${n}${h}`}function Bf(t,e,n,i){let{type:r,value:o}=t,{actualString:s,implicitKey:a,indent:c,indentStep:l,inFlow:u}=e;if(a&&o.includes(`
|
|
33
|
+
`)||u&&/[[\]{},]/.test(o))return lt(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes(`
|
|
34
|
+
`)?lt(o,e):Tn(t,e,n,i);if(!a&&!u&&r!==ee.Scalar.PLAIN&&o.includes(`
|
|
35
|
+
`))return Tn(t,e,n,i);if($n(o)){if(c==="")return e.forceBlockIndent=!0,Tn(t,e,n,i);if(a&&c===l)return lt(o,e)}let f=o.replace(/\n+/g,`$&
|
|
36
|
+
${c}`);if(s){let d=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(f),{compat:h,tags:g}=e.doc.schema;if(g.some(d)||h?.some(d))return lt(o,e)}return a?f:xe.foldFlowLines(f,c,xe.FOLD_FLOW,In(e,!1))}function Kf(t,e,n,i){let{implicitKey:r,inFlow:o}=e,s=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==ee.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=ee.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case ee.Scalar.BLOCK_FOLDED:case ee.Scalar.BLOCK_LITERAL:return r||o?lt(s.value,e):Tn(s,e,n,i);case ee.Scalar.QUOTE_DOUBLE:return qt(s.value,e);case ee.Scalar.QUOTE_SINGLE:return hr(s.value,e);case ee.Scalar.PLAIN:return Bf(s,e,n,i);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:f}=e.options,d=r&&u||f;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}zs.stringifyString=Kf});var Wt=v(wr=>{"use strict";var Hf=xn(),Pe=x(),Uf=It(),Yf=Lt();function Jf(t,e){let n=Object.assign({blockQuote:!0,commentString:Uf.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},t.schema.toStringOptions,e),i;switch(n.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:i,options:n}}function Vf(t,e){if(e.tag){let r=t.filter(o=>o.tag===e.tag);if(r.length>0)return r.find(o=>o.format===e.format)??r[0]}let n,i;if(Pe.isScalar(e)){i=e.value;let r=t.filter(o=>o.identify?.(i));if(r.length>1){let o=r.filter(s=>s.test);o.length>0&&(r=o)}n=r.find(o=>o.format===e.format)??r.find(o=>!o.format)}else i=e,n=t.find(r=>r.nodeClass&&i instanceof r.nodeClass);if(!n){let r=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${r} value`)}return n}function Gf(t,e,{anchors:n,doc:i}){if(!i.directives)return"";let r=[],o=(Pe.isScalar(t)||Pe.isCollection(t))&&t.anchor;o&&Hf.anchorIsValid(o)&&(n.add(o),r.push(`&${o}`));let s=t.tag??(e.default?null:e.tag);return s&&r.push(i.directives.tagString(s)),r.join(" ")}function zf(t,e,n,i){if(Pe.isPair(t))return t.toString(e,n,i);if(Pe.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let r,o=Pe.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>r=c});r??(r=Vf(e.doc.schema.tags,o));let s=Gf(o,r,e);s.length>0&&(e.indentAtStart=(e.indentAtStart??0)+s.length+1);let a=typeof r.stringify=="function"?r.stringify(o,e,n,i):Pe.isScalar(o)?Yf.stringifyString(o,e,n,i):o.toString(e,n,i);return s?Pe.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
|
|
37
|
+
${e.indent}${a}`:a}wr.createStringifyContext=Jf;wr.stringify=zf});var ea=v(Zs=>{"use strict";var me=x(),Qs=T(),Xs=Wt(),Dt=It();function Qf({key:t,value:e},n,i,r){let{allNullValues:o,doc:s,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:f}}=n,d=me.isNode(t)&&t.comment||null;if(f){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(me.isCollection(t)||!me.isNode(t)&&typeof t=="object"){let P="With simple keys, collection cannot be used as a key value";throw new Error(P)}}let h=!f&&(!t||d&&e==null&&!n.inFlow||me.isCollection(t)||(me.isScalar(t)?t.type===Qs.Scalar.BLOCK_FOLDED||t.type===Qs.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(f||!o),indent:a+c});let g=!1,p=!1,m=Xs.stringify(t,n,()=>g=!0,()=>p=!0);if(!h&&!n.inFlow&&m.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(n.inFlow){if(o||e==null)return g&&i&&i(),m===""?"?":h?`? ${m}`:m}else if(o&&!f||e==null&&h)return m=`? ${m}`,d&&!g?m+=Dt.lineComment(m,n.indent,l(d)):p&&r&&r(),m;g&&(d=null),h?(d&&(m+=Dt.lineComment(m,n.indent,l(d))),m=`? ${m}
|
|
38
|
+
${a}:`):(m=`${m}:`,d&&(m+=Dt.lineComment(m,n.indent,l(d))));let w,y,S;me.isNode(e)?(w=!!e.spaceBefore,y=e.commentBefore,S=e.comment):(w=!1,y=null,S=null,e&&typeof e=="object"&&(e=s.createNode(e))),n.implicitKey=!1,!h&&!d&&me.isScalar(e)&&(n.indentAtStart=m.length+1),p=!1,!u&&c.length>=2&&!n.inFlow&&!h&&me.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let k=!1,C=Xs.stringify(e,n,()=>k=!0,()=>p=!0),E=" ";if(d||w||y){if(E=w?`
|
|
39
|
+
`:"",y){let P=l(y);E+=`
|
|
40
|
+
${Dt.indentComment(P,n.indent)}`}C===""&&!n.inFlow?E===`
|
|
41
|
+
`&&S&&(E=`
|
|
42
42
|
|
|
43
43
|
`):E+=`
|
|
44
|
-
${n.indent}`}else if(!h&&me.isCollection(e)){let
|
|
45
|
-
`),
|
|
44
|
+
${n.indent}`}else if(!h&&me.isCollection(e)){let P=C[0],b=C.indexOf(`
|
|
45
|
+
`),_=b!==-1,V=n.inFlow??e.flow??e.items.length===0;if(_||!V){let Ce=!1;if(_&&(P==="&"||P==="!")){let j=C.indexOf(" ");P==="&"&&j!==-1&&j<b&&C[j+1]==="!"&&(j=C.indexOf(" ",j+1)),(j===-1||b<j)&&(Ce=!0)}Ce||(E=`
|
|
46
46
|
${n.indent}`)}}else(C===""||C[0]===`
|
|
47
|
-
`)&&(E="");return m+=E+C,n.inFlow?
|
|
47
|
+
`)&&(E="");return m+=E+C,n.inFlow?k&&i&&i():S&&!k?m+=Dt.lineComment(m,n.indent,l(S)):p&&r&&r(),m}Zs.stringifyPair=Qf});var vr=v(yr=>{"use strict";var ta=bn("process");function Xf(t,...e){t==="debug"&&console.log(...e)}function Zf(t,e){(t==="debug"||t==="warn")&&(typeof ta.emitWarning=="function"?ta.emitWarning(e):console.warn(e))}yr.debug=Xf;yr.warn=Zf});var Fn=v(Dn=>{"use strict";var Wn=x(),na=T(),qn="<<",Ln={identify:t=>t===qn||typeof t=="symbol"&&t.description===qn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new na.Scalar(Symbol(qn)),{addToJSMap:ia}),stringify:()=>qn},ed=(t,e)=>(Ln.identify(e)||Wn.isScalar(e)&&(!e.type||e.type===na.Scalar.PLAIN)&&Ln.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===Ln.tag&&n.default);function ia(t,e,n){let i=ra(t,n);if(Wn.isSeq(i))for(let r of i.items)kr(t,e,r);else if(Array.isArray(i))for(let r of i)kr(t,e,r);else kr(t,e,i)}function kr(t,e,n){let i=ra(t,n);if(!Wn.isMap(i))throw new Error("Merge sources must be maps or map aliases");let r=i.toJSON(null,t,Map);for(let[o,s]of r)e instanceof Map?e.has(o)||e.set(o,s):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0});return e}function ra(t,e){return t&&Wn.isAlias(e)?e.resolve(t.doc,t):e}Dn.addMergeToJSMap=ia;Dn.isMergeKey=ed;Dn.merge=Ln});var Sr=v(aa=>{"use strict";var td=vr(),oa=Fn(),nd=Wt(),sa=x(),br=Ee();function id(t,e,{key:n,value:i}){if(sa.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,i);else if(oa.isMergeKey(t,n))oa.addMergeToJSMap(t,e,i);else{let r=br.toJS(n,"",t);if(e instanceof Map)e.set(r,br.toJS(i,r,t));else if(e instanceof Set)e.add(r);else{let o=rd(n,r,t),s=br.toJS(i,o,t);o in e?Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0}):e[o]=s}}return e}function rd(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(sa.isNode(t)&&n?.doc){let i=nd.createStringifyContext(n.doc,{});i.anchors=new Set;for(let o of n.anchors.keys())i.anchors.add(o.anchor);i.inFlow=!0,i.inStringifyKey=!0;let r=t.toString(i);if(!n.mapKeyWarned){let o=JSON.stringify(r);o.length>40&&(o=o.substring(0,36)+'..."'),td.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(e)}aa.addPairToJSMap=id});var Re=v(Cr=>{"use strict";var ca=Tt(),od=ea(),sd=Sr(),Mn=x();function ad(t,e,n){let i=ca.createNode(t,void 0,n),r=ca.createNode(e,void 0,n);return new Bn(i,r)}var Bn=class t{constructor(e,n=null){Object.defineProperty(this,Mn.NODE_TYPE,{value:Mn.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:i}=this;return Mn.isNode(n)&&(n=n.clone(e)),Mn.isNode(i)&&(i=i.clone(e)),new t(n,i)}toJSON(e,n){let i=n?.mapAsMap?new Map:{};return sd.addPairToJSMap(n,i,this)}toString(e,n,i){return e?.doc?od.stringifyPair(this,e,n,i):JSON.stringify(this)}};Cr.Pair=Bn;Cr.createPair=ad});var Er=v(ua=>{"use strict";var Ge=x(),la=Wt(),Kn=It();function cd(t,e,n){return(e.inFlow??t.flow?ud:ld)(t,e,n)}function ld({comment:t,items:e},n,{blockItemPrefix:i,flowChars:r,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:o,type:null}),f=!1,d=[];for(let g=0;g<e.length;++g){let p=e[g],m=null;if(Ge.isNode(p))!f&&p.spaceBefore&&d.push(""),Hn(n,d,p.commentBefore,f),p.comment&&(m=p.comment);else if(Ge.isPair(p)){let y=Ge.isNode(p.key)?p.key:null;y&&(!f&&y.spaceBefore&&d.push(""),Hn(n,d,y.commentBefore,f))}f=!1;let w=la.stringify(p,u,()=>m=null,()=>f=!0);m&&(w+=Kn.lineComment(w,o,l(m))),f&&m&&(f=!1),d.push(i+w)}let h;if(d.length===0)h=r.start+r.end;else{h=d[0];for(let g=1;g<d.length;++g){let p=d[g];h+=p?`
|
|
48
48
|
${c}${p}`:`
|
|
49
49
|
`}}return t?(h+=`
|
|
50
|
-
`+Kn.indentComment(l(t),c),a&&a()):
|
|
51
|
-
`)),
|
|
50
|
+
`+Kn.indentComment(l(t),c),a&&a()):f&&s&&s(),h}function ud({items:t},e,{flowChars:n,itemIndent:i}){let{indent:r,indentStep:o,flowCollectionPadding:s,options:{commentString:a}}=e;i+=o;let c=Object.assign({},e,{indent:i,inFlow:!0,type:null}),l=!1,u=0,f=[];for(let g=0;g<t.length;++g){let p=t[g],m=null;if(Ge.isNode(p))p.spaceBefore&&f.push(""),Hn(e,f,p.commentBefore,!1),p.comment&&(m=p.comment);else if(Ge.isPair(p)){let y=Ge.isNode(p.key)?p.key:null;y&&(y.spaceBefore&&f.push(""),Hn(e,f,y.commentBefore,!1),y.comment&&(l=!0));let S=Ge.isNode(p.value)?p.value:null;S?(S.comment&&(m=S.comment),S.commentBefore&&(l=!0)):p.value==null&&y?.comment&&(m=y.comment)}m&&(l=!0);let w=la.stringify(p,c,()=>m=null);l||(l=f.length>u||w.includes(`
|
|
51
|
+
`)),g<t.length-1?w+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=f.reduce((y,S)=>y+S.length+2,2)+(w.length+2)>e.options.lineWidth)),l&&(w+=",")),m&&(w+=Kn.lineComment(w,i,a(m))),f.push(w),u=f.length}let{start:d,end:h}=n;if(f.length===0)return d+h;if(!l){let g=f.reduce((p,m)=>p+m.length+2,2);l=e.options.lineWidth>0&&g>e.options.lineWidth}if(l){let g=d;for(let p of f)g+=p?`
|
|
52
52
|
${o}${r}${p}`:`
|
|
53
|
-
`;return`${
|
|
54
|
-
${r}${h}`}else return`${d}${s}${
|
|
55
|
-
`:" ")}return
|
|
53
|
+
`;return`${g}
|
|
54
|
+
${r}${h}`}else return`${d}${s}${f.join(" ")}${s}${h}`}function Hn({indent:t,options:{commentString:e}},n,i,r){if(i&&r&&(i=i.replace(/^\n+/,"")),i){let o=Kn.indentComment(e(i),t);n.push(o.trimStart())}}ua.stringifyCollection=cd});var Ae=v(xr=>{"use strict";var fd=Er(),dd=Sr(),pd=An(),Oe=x(),Un=Re(),md=T();function Ft(t,e){let n=Oe.isScalar(e)?e.value:e;for(let i of t)if(Oe.isPair(i)&&(i.key===e||i.key===n||Oe.isScalar(i.key)&&i.key.value===n))return i}var _r=class extends pd.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Oe.MAP,e),this.items=[]}static from(e,n,i){let{keepUndefined:r,replacer:o}=i,s=new this(e),a=(c,l)=>{if(typeof o=="function")l=o.call(n,c,l);else if(Array.isArray(o)&&!o.includes(c))return;(l!==void 0||r)&&s.items.push(Un.createPair(c,l,i))};if(n instanceof Map)for(let[c,l]of n)a(c,l);else if(n&&typeof n=="object")for(let c of Object.keys(n))a(c,n[c]);return typeof e.sortMapEntries=="function"&&s.items.sort(e.sortMapEntries),s}add(e,n){let i;Oe.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new Un.Pair(e,e?.value):i=new Un.Pair(e.key,e.value);let r=Ft(this.items,i.key),o=this.schema?.sortMapEntries;if(r){if(!n)throw new Error(`Key ${i.key} already set`);Oe.isScalar(r.value)&&md.isScalarValue(i.value)?r.value.value=i.value:r.value=i.value}else if(o){let s=this.items.findIndex(a=>o(i,a)<0);s===-1?this.items.push(i):this.items.splice(s,0,i)}else this.items.push(i)}delete(e){let n=Ft(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let r=Ft(this.items,e)?.value;return(!n&&Oe.isScalar(r)?r.value:r)??void 0}has(e){return!!Ft(this.items,e)}set(e,n){this.add(new Un.Pair(e,n),!0)}toJSON(e,n,i){let r=i?new i:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(r);for(let o of this.items)dd.addPairToJSMap(n,r,o);return r}toString(e,n,i){if(!e)return JSON.stringify(this);for(let r of this.items)if(!Oe.isPair(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),fd.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:n})}};xr.YAMLMap=_r;xr.findPair=Ft});var ut=v(da=>{"use strict";var hd=x(),fa=Ae(),gd={collection:"map",default:!0,nodeClass:fa.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return hd.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>fa.YAMLMap.from(t,e,n)};da.map=gd});var Ne=v(pa=>{"use strict";var wd=Tt(),yd=Er(),vd=An(),Jn=x(),kd=T(),bd=Ee(),Pr=class extends vd.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Jn.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=Yn(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let i=Yn(e);if(typeof i!="number")return;let r=this.items[i];return!n&&Jn.isScalar(r)?r.value:r}has(e){let n=Yn(e);return typeof n=="number"&&n<this.items.length}set(e,n){let i=Yn(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let r=this.items[i];Jn.isScalar(r)&&kd.isScalarValue(n)?r.value=n:this.items[i]=n}toJSON(e,n){let i=[];n?.onCreate&&n.onCreate(i);let r=0;for(let o of this.items)i.push(bd.toJS(o,String(r++),n));return i}toString(e,n,i){return e?yd.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:n}):JSON.stringify(this)}static from(e,n,i){let{replacer:r}=i,o=new this(e);if(n&&Symbol.iterator in Object(n)){let s=0;for(let a of n){if(typeof r=="function"){let c=n instanceof Set?a:String(s++);a=r.call(n,c,a)}o.items.push(wd.createNode(a,void 0,i))}}return o}};function Yn(t){let e=Jn.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}pa.YAMLSeq=Pr});var ft=v(ha=>{"use strict";var Sd=x(),ma=Ne(),Cd={collection:"seq",default:!0,nodeClass:ma.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Sd.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>ma.YAMLSeq.from(t,e,n)};ha.seq=Cd});var Mt=v(ga=>{"use strict";var Ed=Lt(),_d={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,i){return e=Object.assign({actualString:!0},e),Ed.stringifyString(t,e,n,i)}};ga.string=_d});var Vn=v(va=>{"use strict";var wa=T(),ya={identify:t=>t==null,createNode:()=>new wa.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new wa.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&ya.test.test(t)?t:e.options.nullStr};va.nullTag=ya});var Rr=v(ba=>{"use strict";var xd=T(),ka={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new xd.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&ka.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?n.options.trueStr:n.options.falseStr}};ba.boolTag=ka});var dt=v(Sa=>{"use strict";function Pd({format:t,minFractionDigits:e,tag:n,value:i}){if(typeof i=="bigint")return String(i);let r=typeof i=="number"?i:Number(i);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let o=Object.is(i,-0)?"-0":JSON.stringify(i);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let s=o.indexOf(".");s<0&&(s=o.length,o+=".");let a=e-(o.length-s-1);for(;a-- >0;)o+="0"}return o}Sa.stringifyNumber=Pd});var Ar=v(Gn=>{"use strict";var Rd=T(),Or=dt(),Od={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Or.stringifyNumber},Ad={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Or.stringifyNumber(t)}},Nd={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new Rd.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Or.stringifyNumber};Gn.float=Nd;Gn.floatExp=Ad;Gn.floatNaN=Od});var jr=v(Qn=>{"use strict";var Ca=dt(),zn=t=>typeof t=="bigint"||Number.isInteger(t),Nr=(t,e,n,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),n);function Ea(t,e,n){let{value:i}=t;return zn(i)&&i>=0?n+i.toString(e):Ca.stringifyNumber(t)}var jd={identify:t=>zn(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Nr(t,2,8,n),stringify:t=>Ea(t,8,"0o")},Td={identify:zn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Nr(t,0,10,n),stringify:Ca.stringifyNumber},Id={identify:t=>zn(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Nr(t,2,16,n),stringify:t=>Ea(t,16,"0x")};Qn.int=Td;Qn.intHex=Id;Qn.intOct=jd});var xa=v(_a=>{"use strict";var $d=ut(),qd=Vn(),Ld=ft(),Wd=Mt(),Dd=Rr(),Tr=Ar(),Ir=jr(),Fd=[$d.map,Ld.seq,Wd.string,qd.nullTag,Dd.boolTag,Ir.intOct,Ir.int,Ir.intHex,Tr.floatNaN,Tr.floatExp,Tr.float];_a.schema=Fd});var Oa=v(Ra=>{"use strict";var Md=T(),Bd=ut(),Kd=ft();function Pa(t){return typeof t=="bigint"||Number.isInteger(t)}var Xn=({value:t})=>JSON.stringify(t),Hd=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Xn},{identify:t=>t==null,createNode:()=>new Md.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Xn},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Xn},{identify:Pa,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>Pa(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:Xn}],Ud={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Yd=[Bd.map,Kd.seq].concat(Hd,Ud);Ra.schema=Yd});var qr=v(Aa=>{"use strict";var Bt=bn("buffer"),$r=T(),Jd=Lt(),Vd={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Bt.Buffer=="function")return Bt.Buffer.from(t,"base64");if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),i=new Uint8Array(n.length);for(let r=0;r<n.length;++r)i[r]=n.charCodeAt(r);return i}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},i,r,o){if(!n)return"";let s=n,a;if(typeof Bt.Buffer=="function")a=s instanceof Bt.Buffer?s.toString("base64"):Bt.Buffer.from(s.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<s.length;++l)c+=String.fromCharCode(s[l]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=$r.Scalar.BLOCK_LITERAL),e!==$r.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(a.length/c),u=new Array(l);for(let f=0,d=0;f<l;++f,d+=c)u[f]=a.substr(d,c);a=u.join(e===$r.Scalar.BLOCK_LITERAL?`
|
|
55
|
+
`:" ")}return Jd.stringifyString({comment:t,type:e,value:a},i,r,o)}};Aa.binary=Vd});var ti=v(ei=>{"use strict";var Zn=x(),Lr=Re(),Gd=T(),zd=Ne();function Na(t,e){if(Zn.isSeq(t))for(let n=0;n<t.items.length;++n){let i=t.items[n];if(!Zn.isPair(i)){if(Zn.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let r=i.items[0]||new Lr.Pair(new Gd.Scalar(null));if(i.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${i.commentBefore}
|
|
56
56
|
${r.key.commentBefore}`:i.commentBefore),i.comment){let o=r.value??r.key;o.comment=o.comment?`${i.comment}
|
|
57
|
-
${o.comment}`:i.comment}i=r}t.items[n]=Zn.isPair(i)?i:new Lr.Pair(i)}}else e("Expected a sequence for this tag");return t}function Aa(t,e,n){let{replacer:i}=n,r=new Jd.YAMLSeq(t);r.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let s of e){typeof i=="function"&&(s=i.call(e,String(o++),s));let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw new TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let l=Object.keys(s);if(l.length===1)a=l[0],c=s[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;r.items.push(Lr.createPair(a,c,n))}return r}var Vd={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Oa,createNode:Aa};ei.createPairs=Aa;ei.pairs=Vd;ei.resolvePairs=Oa});var Fr=v(Dr=>{"use strict";var Na=x(),Wr=Ce(),Kt=Oe(),Gd=Ae(),ja=ti(),Ge=class t extends Gd.YAMLSeq{constructor(){super(),this.add=Kt.YAMLMap.prototype.add.bind(this),this.delete=Kt.YAMLMap.prototype.delete.bind(this),this.get=Kt.YAMLMap.prototype.get.bind(this),this.has=Kt.YAMLMap.prototype.has.bind(this),this.set=Kt.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let i=new Map;n?.onCreate&&n.onCreate(i);for(let r of this.items){let o,s;if(Na.isPair(r)?(o=Wr.toJS(r.key,"",n),s=Wr.toJS(r.value,o,n)):o=Wr.toJS(r,"",n),i.has(o))throw new Error("Ordered maps must not include duplicate keys");i.set(o,s)}return i}static from(e,n,i){let r=ja.createPairs(e,n,i),o=new this;return o.items=r.items,o}};Ge.tag="tag:yaml.org,2002:omap";var zd={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ge,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=ja.resolvePairs(t,e),i=[];for(let{key:r}of n.items)Na.isScalar(r)&&(i.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):i.push(r.value));return Object.assign(new Ge,n)},createNode:(t,e,n)=>Ge.from(t,e,n)};Dr.YAMLOMap=Ge;Dr.omap=zd});var La=v(Mr=>{"use strict";var Ta=T();function Ia({value:t,source:e},n){return e&&(t?$a:qa).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var $a={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ta.Scalar(!0),stringify:Ia},qa={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ta.Scalar(!1),stringify:Ia};Mr.falseTag=qa;Mr.trueTag=$a});var Wa=v(ni=>{"use strict";var Qd=T(),Br=ft(),Xd={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Br.stringifyNumber},Zd={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Br.stringifyNumber(t)}},ep={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new Qd.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let i=t.substring(n+1).replace(/_/g,"");i[i.length-1]==="0"&&(e.minFractionDigits=i.length)}return e},stringify:Br.stringifyNumber};ni.float=ep;ni.floatExp=Zd;ni.floatNaN=Xd});var Fa=v(Ut=>{"use strict";var Da=ft(),Ht=t=>typeof t=="bigint"||Number.isInteger(t);function ii(t,e,n,{intAsBigInt:i}){let r=t[0];if((r==="-"||r==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),i){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let s=BigInt(t);return r==="-"?BigInt(-1)*s:s}let o=parseInt(t,n);return r==="-"?-1*o:o}function Kr(t,e,n){let{value:i}=t;if(Ht(i)){let r=i.toString(e);return i<0?"-"+n+r.substr(1):n+r}return Da.stringifyNumber(t)}var tp={identify:Ht,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>ii(t,2,2,n),stringify:t=>Kr(t,2,"0b")},np={identify:Ht,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>ii(t,1,8,n),stringify:t=>Kr(t,8,"0")},ip={identify:Ht,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>ii(t,0,10,n),stringify:Da.stringifyNumber},rp={identify:Ht,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>ii(t,2,16,n),stringify:t=>Kr(t,16,"0x")};Ut.int=ip;Ut.intBin=tp;Ut.intHex=rp;Ut.intOct=np});var Ur=v(Hr=>{"use strict";var si=x(),ri=Pe(),oi=Oe(),ze=class t extends oi.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;si.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new ri.Pair(e.key,null):n=new ri.Pair(e,null),oi.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let i=oi.findPair(this.items,e);return!n&&si.isPair(i)?si.isScalar(i.key)?i.key.value:i.key:i}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let i=oi.findPair(this.items,e);i&&!n?this.items.splice(this.items.indexOf(i),1):!i&&n&&this.items.push(new ri.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,i);throw new Error("Set items must all have null values")}static from(e,n,i){let{replacer:r}=i,o=new this(e);if(n&&Symbol.iterator in Object(n))for(let s of n)typeof r=="function"&&(s=r.call(n,s,s)),o.items.push(ri.createPair(s,null,i));return o}};ze.tag="tag:yaml.org,2002:set";var op={collection:"map",identify:t=>t instanceof Set,nodeClass:ze,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>ze.from(t,e,n),resolve(t,e){if(si.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new ze,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Hr.YAMLSet=ze;Hr.set=op});var Jr=v(ai=>{"use strict";var sp=ft();function Yr(t,e){let n=t[0],i=n==="-"||n==="+"?t.substring(1):t,r=s=>e?BigInt(s):Number(s),o=i.replace(/_/g,"").split(":").reduce((s,a)=>s*r(60)+r(a),r(0));return n==="-"?r(-1)*o:o}function Ma(t){let{value:e}=t,n=s=>s;if(typeof e=="bigint")n=s=>BigInt(s);else if(isNaN(e)||!isFinite(e))return sp.stringifyNumber(t);let i="";e<0&&(i="-",e*=n(-1));let r=n(60),o=[e%r];return e<60?o.unshift(0):(e=(e-o[0])/r,o.unshift(e%r),e>=60&&(e=(e-o[0])/r,o.unshift(e))),i+o.map(s=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var ap={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Yr(t,n),stringify:Ma},cp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Yr(t,!1),stringify:Ma},Ba={identify:t=>t 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(t){let e=t.match(Ba.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,r,o,s,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(n,i-1,r,o||0,s||0,a||0,c),f=e[8];if(f&&f!=="Z"){let u=Yr(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ai.floatTime=cp;ai.intTime=ap;ai.timestamp=Ba});var Ua=v(Ha=>{"use strict";var lp=lt(),up=Vn(),fp=ut(),dp=Mt(),pp=qr(),Ka=La(),Vr=Wa(),ci=Fa(),mp=Fn(),hp=Fr(),gp=ti(),wp=Ur(),Gr=Jr(),yp=[lp.map,fp.seq,dp.string,up.nullTag,Ka.trueTag,Ka.falseTag,ci.intBin,ci.intOct,ci.int,ci.intHex,Vr.floatNaN,Vr.floatExp,Vr.float,pp.binary,mp.merge,hp.omap,gp.pairs,wp.set,Gr.intTime,Gr.floatTime,Gr.timestamp];Ha.schema=yp});var tc=v(Xr=>{"use strict";var Ga=lt(),vp=Vn(),za=ut(),kp=Mt(),bp=Rr(),zr=Ar(),Qr=jr(),Sp=Ea(),Cp=Pa(),Qa=qr(),Yt=Fn(),Xa=Fr(),Za=ti(),Ya=Ua(),ec=Ur(),li=Jr(),Ja=new Map([["core",Sp.schema],["failsafe",[Ga.map,za.seq,kp.string]],["json",Cp.schema],["yaml11",Ya.schema],["yaml-1.1",Ya.schema]]),Va={binary:Qa.binary,bool:bp.boolTag,float:zr.float,floatExp:zr.floatExp,floatNaN:zr.floatNaN,floatTime:li.floatTime,int:Qr.int,intHex:Qr.intHex,intOct:Qr.intOct,intTime:li.intTime,map:Ga.map,merge:Yt.merge,null:vp.nullTag,omap:Xa.omap,pairs:Za.pairs,seq:za.seq,set:ec.set,timestamp:li.timestamp},Ep={"tag:yaml.org,2002:binary":Qa.binary,"tag:yaml.org,2002:merge":Yt.merge,"tag:yaml.org,2002:omap":Xa.omap,"tag:yaml.org,2002:pairs":Za.pairs,"tag:yaml.org,2002:set":ec.set,"tag:yaml.org,2002:timestamp":li.timestamp};function _p(t,e,n){let i=Ja.get(e);if(i&&!t)return n&&!i.includes(Yt.merge)?i.concat(Yt.merge):i.slice();let r=i;if(!r)if(Array.isArray(t))r=[];else{let o=Array.from(Ja.keys()).filter(s=>s!=="yaml11").map(s=>JSON.stringify(s)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)r=r.concat(o);else typeof t=="function"&&(r=t(r.slice()));return n&&(r=r.concat(Yt.merge)),r.reduce((o,s)=>{let a=typeof s=="string"?Va[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(Va).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}Xr.coreKnownTags=Ep;Xr.getTags=_p});var to=v(nc=>{"use strict";var Zr=x(),xp=lt(),Pp=ut(),Rp=Mt(),ui=tc(),Op=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,eo=class t{constructor({compat:e,customTags:n,merge:i,resolveKnownTags:r,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(e)?ui.getTags(e,"compat"):e?ui.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?ui.coreKnownTags:{},this.tags=ui.getTags(n,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Zr.MAP,{value:xp.map}),Object.defineProperty(this,Zr.SCALAR,{value:Rp.string}),Object.defineProperty(this,Zr.SEQ,{value:Pp.seq}),this.sortMapEntries=typeof s=="function"?s:s===!0?Op:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};nc.Schema=eo});var rc=v(ic=>{"use strict";var Ap=x(),no=Wt(),Jt=It();function Np(t,e){let n=[],i=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(n.push(c),i=!0):t.directives.docStart&&(i=!0)}i&&n.push("---");let r=no.createStringifyContext(t,e),{commentString:o}=r.options;if(t.commentBefore){n.length!==1&&n.unshift("");let c=o(t.commentBefore);n.unshift(Jt.indentComment(c,""))}let s=!1,a=null;if(t.contents){if(Ap.isNode(t.contents)){if(t.contents.spaceBefore&&i&&n.push(""),t.contents.commentBefore){let f=o(t.contents.commentBefore);n.push(Jt.indentComment(f,""))}r.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>s=!0,l=no.stringify(t.contents,r,()=>a=null,c);a&&(l+=Jt.lineComment(l,"",o(a))),(l[0]==="|"||l[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${l}`:n.push(l)}else n.push(no.stringify(t.contents,r));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
|
|
57
|
+
${o.comment}`:i.comment}i=r}t.items[n]=Zn.isPair(i)?i:new Lr.Pair(i)}}else e("Expected a sequence for this tag");return t}function ja(t,e,n){let{replacer:i}=n,r=new zd.YAMLSeq(t);r.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let s of e){typeof i=="function"&&(s=i.call(e,String(o++),s));let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw new TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let l=Object.keys(s);if(l.length===1)a=l[0],c=s[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;r.items.push(Lr.createPair(a,c,n))}return r}var Qd={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Na,createNode:ja};ei.createPairs=ja;ei.pairs=Qd;ei.resolvePairs=Na});var Fr=v(Dr=>{"use strict";var Ta=x(),Wr=Ee(),Kt=Ae(),Xd=Ne(),Ia=ti(),ze=class t extends Xd.YAMLSeq{constructor(){super(),this.add=Kt.YAMLMap.prototype.add.bind(this),this.delete=Kt.YAMLMap.prototype.delete.bind(this),this.get=Kt.YAMLMap.prototype.get.bind(this),this.has=Kt.YAMLMap.prototype.has.bind(this),this.set=Kt.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let i=new Map;n?.onCreate&&n.onCreate(i);for(let r of this.items){let o,s;if(Ta.isPair(r)?(o=Wr.toJS(r.key,"",n),s=Wr.toJS(r.value,o,n)):o=Wr.toJS(r,"",n),i.has(o))throw new Error("Ordered maps must not include duplicate keys");i.set(o,s)}return i}static from(e,n,i){let r=Ia.createPairs(e,n,i),o=new this;return o.items=r.items,o}};ze.tag="tag:yaml.org,2002:omap";var Zd={collection:"seq",identify:t=>t instanceof Map,nodeClass:ze,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Ia.resolvePairs(t,e),i=[];for(let{key:r}of n.items)Ta.isScalar(r)&&(i.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):i.push(r.value));return Object.assign(new ze,n)},createNode:(t,e,n)=>ze.from(t,e,n)};Dr.YAMLOMap=ze;Dr.omap=Zd});var Da=v(Mr=>{"use strict";var $a=T();function qa({value:t,source:e},n){return e&&(t?La:Wa).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var La={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new $a.Scalar(!0),stringify:qa},Wa={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new $a.Scalar(!1),stringify:qa};Mr.falseTag=Wa;Mr.trueTag=La});var Fa=v(ni=>{"use strict";var ep=T(),Br=dt(),tp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Br.stringifyNumber},np={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Br.stringifyNumber(t)}},ip={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new ep.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let i=t.substring(n+1).replace(/_/g,"");i[i.length-1]==="0"&&(e.minFractionDigits=i.length)}return e},stringify:Br.stringifyNumber};ni.float=ip;ni.floatExp=np;ni.floatNaN=tp});var Ba=v(Ut=>{"use strict";var Ma=dt(),Ht=t=>typeof t=="bigint"||Number.isInteger(t);function ii(t,e,n,{intAsBigInt:i}){let r=t[0];if((r==="-"||r==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),i){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let s=BigInt(t);return r==="-"?BigInt(-1)*s:s}let o=parseInt(t,n);return r==="-"?-1*o:o}function Kr(t,e,n){let{value:i}=t;if(Ht(i)){let r=i.toString(e);return i<0?"-"+n+r.substr(1):n+r}return Ma.stringifyNumber(t)}var rp={identify:Ht,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>ii(t,2,2,n),stringify:t=>Kr(t,2,"0b")},op={identify:Ht,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>ii(t,1,8,n),stringify:t=>Kr(t,8,"0")},sp={identify:Ht,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>ii(t,0,10,n),stringify:Ma.stringifyNumber},ap={identify:Ht,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>ii(t,2,16,n),stringify:t=>Kr(t,16,"0x")};Ut.int=sp;Ut.intBin=rp;Ut.intHex=ap;Ut.intOct=op});var Ur=v(Hr=>{"use strict";var si=x(),ri=Re(),oi=Ae(),Qe=class t extends oi.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;si.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new ri.Pair(e.key,null):n=new ri.Pair(e,null),oi.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let i=oi.findPair(this.items,e);return!n&&si.isPair(i)?si.isScalar(i.key)?i.key.value:i.key:i}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let i=oi.findPair(this.items,e);i&&!n?this.items.splice(this.items.indexOf(i),1):!i&&n&&this.items.push(new ri.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,i);throw new Error("Set items must all have null values")}static from(e,n,i){let{replacer:r}=i,o=new this(e);if(n&&Symbol.iterator in Object(n))for(let s of n)typeof r=="function"&&(s=r.call(n,s,s)),o.items.push(ri.createPair(s,null,i));return o}};Qe.tag="tag:yaml.org,2002:set";var cp={collection:"map",identify:t=>t instanceof Set,nodeClass:Qe,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>Qe.from(t,e,n),resolve(t,e){if(si.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Qe,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Hr.YAMLSet=Qe;Hr.set=cp});var Jr=v(ai=>{"use strict";var lp=dt();function Yr(t,e){let n=t[0],i=n==="-"||n==="+"?t.substring(1):t,r=s=>e?BigInt(s):Number(s),o=i.replace(/_/g,"").split(":").reduce((s,a)=>s*r(60)+r(a),r(0));return n==="-"?r(-1)*o:o}function Ka(t){let{value:e}=t,n=s=>s;if(typeof e=="bigint")n=s=>BigInt(s);else if(isNaN(e)||!isFinite(e))return lp.stringifyNumber(t);let i="";e<0&&(i="-",e*=n(-1));let r=n(60),o=[e%r];return e<60?o.unshift(0):(e=(e-o[0])/r,o.unshift(e%r),e>=60&&(e=(e-o[0])/r,o.unshift(e))),i+o.map(s=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var up={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Yr(t,n),stringify:Ka},fp={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Yr(t,!1),stringify:Ka},Ha={identify:t=>t 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(t){let e=t.match(Ha.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,r,o,s,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(n,i-1,r,o||0,s||0,a||0,c),u=e[8];if(u&&u!=="Z"){let f=Yr(u,!1);Math.abs(f)<30&&(f*=60),l-=6e4*f}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ai.floatTime=fp;ai.intTime=up;ai.timestamp=Ha});var Ja=v(Ya=>{"use strict";var dp=ut(),pp=Vn(),mp=ft(),hp=Mt(),gp=qr(),Ua=Da(),Vr=Fa(),ci=Ba(),wp=Fn(),yp=Fr(),vp=ti(),kp=Ur(),Gr=Jr(),bp=[dp.map,mp.seq,hp.string,pp.nullTag,Ua.trueTag,Ua.falseTag,ci.intBin,ci.intOct,ci.int,ci.intHex,Vr.floatNaN,Vr.floatExp,Vr.float,gp.binary,wp.merge,yp.omap,vp.pairs,kp.set,Gr.intTime,Gr.floatTime,Gr.timestamp];Ya.schema=bp});var ic=v(Xr=>{"use strict";var Qa=ut(),Sp=Vn(),Xa=ft(),Cp=Mt(),Ep=Rr(),zr=Ar(),Qr=jr(),_p=xa(),xp=Oa(),Za=qr(),Yt=Fn(),ec=Fr(),tc=ti(),Va=Ja(),nc=Ur(),li=Jr(),Ga=new Map([["core",_p.schema],["failsafe",[Qa.map,Xa.seq,Cp.string]],["json",xp.schema],["yaml11",Va.schema],["yaml-1.1",Va.schema]]),za={binary:Za.binary,bool:Ep.boolTag,float:zr.float,floatExp:zr.floatExp,floatNaN:zr.floatNaN,floatTime:li.floatTime,int:Qr.int,intHex:Qr.intHex,intOct:Qr.intOct,intTime:li.intTime,map:Qa.map,merge:Yt.merge,null:Sp.nullTag,omap:ec.omap,pairs:tc.pairs,seq:Xa.seq,set:nc.set,timestamp:li.timestamp},Pp={"tag:yaml.org,2002:binary":Za.binary,"tag:yaml.org,2002:merge":Yt.merge,"tag:yaml.org,2002:omap":ec.omap,"tag:yaml.org,2002:pairs":tc.pairs,"tag:yaml.org,2002:set":nc.set,"tag:yaml.org,2002:timestamp":li.timestamp};function Rp(t,e,n){let i=Ga.get(e);if(i&&!t)return n&&!i.includes(Yt.merge)?i.concat(Yt.merge):i.slice();let r=i;if(!r)if(Array.isArray(t))r=[];else{let o=Array.from(Ga.keys()).filter(s=>s!=="yaml11").map(s=>JSON.stringify(s)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)r=r.concat(o);else typeof t=="function"&&(r=t(r.slice()));return n&&(r=r.concat(Yt.merge)),r.reduce((o,s)=>{let a=typeof s=="string"?za[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(za).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}Xr.coreKnownTags=Pp;Xr.getTags=Rp});var to=v(rc=>{"use strict";var Zr=x(),Op=ut(),Ap=ft(),Np=Mt(),ui=ic(),jp=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,eo=class t{constructor({compat:e,customTags:n,merge:i,resolveKnownTags:r,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(e)?ui.getTags(e,"compat"):e?ui.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?ui.coreKnownTags:{},this.tags=ui.getTags(n,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Zr.MAP,{value:Op.map}),Object.defineProperty(this,Zr.SCALAR,{value:Np.string}),Object.defineProperty(this,Zr.SEQ,{value:Ap.seq}),this.sortMapEntries=typeof s=="function"?s:s===!0?jp:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};rc.Schema=eo});var sc=v(oc=>{"use strict";var Tp=x(),no=Wt(),Jt=It();function Ip(t,e){let n=[],i=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(n.push(c),i=!0):t.directives.docStart&&(i=!0)}i&&n.push("---");let r=no.createStringifyContext(t,e),{commentString:o}=r.options;if(t.commentBefore){n.length!==1&&n.unshift("");let c=o(t.commentBefore);n.unshift(Jt.indentComment(c,""))}let s=!1,a=null;if(t.contents){if(Tp.isNode(t.contents)){if(t.contents.spaceBefore&&i&&n.push(""),t.contents.commentBefore){let u=o(t.contents.commentBefore);n.push(Jt.indentComment(u,""))}r.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>s=!0,l=no.stringify(t.contents,r,()=>a=null,c);a&&(l+=Jt.lineComment(l,"",o(a))),(l[0]==="|"||l[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${l}`:n.push(l)}else n.push(no.stringify(t.contents,r));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
|
|
58
58
|
`)?(n.push("..."),n.push(Jt.indentComment(c,""))):n.push(`... ${c}`)}else n.push("...");else{let c=t.comment;c&&s&&(c=c.replace(/^\n+/,"")),c&&((!s||a)&&n[n.length-1]!==""&&n.push(""),n.push(Jt.indentComment(o(c),"")))}return n.join(`
|
|
59
59
|
`)+`
|
|
60
|
-
`}
|
|
60
|
+
`}oc.stringifyDocument=Ip});var Vt=v(ac=>{"use strict";var $p=jt(),pt=An(),z=x(),qp=Re(),Lp=Ee(),Wp=to(),Dp=sc(),io=xn(),Fp=ar(),Mp=Tt(),ro=sr(),oo=class t{constructor(e,n,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,z.NODE_TYPE,{value:z.DOC});let r=null;typeof n=="function"||Array.isArray(n)?r=n:i===void 0&&n&&(i=n,n=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=o;let{version:s}=o;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new ro.Directives({version:s}),this.setSchema(s,i),this.contents=e===void 0?null:this.createNode(e,r,i)}clone(){let e=Object.create(t.prototype,{[z.NODE_TYPE]:{value:z.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=z.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){mt(this.contents)&&this.contents.add(e)}addIn(e,n){mt(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let i=io.anchorNames(this);e.anchor=!n||i.has(n)?io.findNewAnchor(n||"a",i):n}return new $p.Alias(e.anchor)}createNode(e,n,i){let r;if(typeof n=="function")e=n.call({"":e},"",e),r=n;else if(Array.isArray(n)){let m=y=>typeof y=="number"||y instanceof String||y instanceof Number,w=n.filter(m).map(String);w.length>0&&(n=n.concat(w)),r=n}else i===void 0&&n&&(i=n,n=void 0);let{aliasDuplicateObjects:o,anchorPrefix:s,flow:a,keepUndefined:c,onTagObj:l,tag:u}=i??{},{onAnchor:f,setAnchors:d,sourceObjects:h}=io.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:o??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:l,replacer:r,schema:this.schema,sourceObjects:h},p=Mp.createNode(e,u,g);return a&&z.isCollection(p)&&(p.flow=!0),d(),p}createPair(e,n,i={}){let r=this.createNode(e,null,i),o=this.createNode(n,null,i);return new qp.Pair(r,o)}delete(e){return mt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return pt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):mt(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return z.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return pt.isEmptyPath(e)?!n&&z.isScalar(this.contents)?this.contents.value:this.contents:z.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return z.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return pt.isEmptyPath(e)?this.contents!==void 0:z.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=pt.collectionFromPath(this.schema,[e],n):mt(this.contents)&&this.contents.set(e,n)}setIn(e,n){pt.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=pt.collectionFromPath(this.schema,Array.from(e),n):mt(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let i;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new ro.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new ro.Directives({version:e}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let r=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(i)this.schema=new Wp.Schema(Object.assign(i,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:i,maxAliasCount:r,onAnchor:o,reviver:s}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=Lp.toJS(this.contents,n??"",a);if(typeof o=="function")for(let{count:l,res:u}of a.anchors.values())o(u,l);return typeof s=="function"?Fp.applyReviver(s,{"":c},"",c):c}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return Dp.stringifyDocument(this,e)}};function mt(t){if(z.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}ac.Document=oo});var Qt=v(zt=>{"use strict";var Gt=class extends Error{constructor(e,n,i,r){super(),this.name=e,this.code=i,this.message=r,this.pos=n}},so=class extends Gt{constructor(e,n,i){super("YAMLParseError",e,n,i)}},ao=class extends Gt{constructor(e,n,i){super("YAMLWarning",e,n,i)}},Bp=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:i,col:r}=n.linePos[0];n.message+=` at line ${i}, column ${r}`;let o=r-1,s=t.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(o>=60&&s.length>80){let a=Math.min(o-39,s.length-79);s="…"+s.substring(a),o-=a-1}if(s.length>80&&(s=s.substring(0,79)+"…"),i>1&&/^ *$/.test(s.substring(0,o))){let a=t.substring(e.lineStarts[i-2],e.lineStarts[i-1]);a.length>80&&(a=a.substring(0,79)+`…
|
|
61
61
|
`),s=a+s}if(/[^ ]/.test(s)){let a=1,c=n.linePos[1];c?.line===i&&c.col>r&&(a=Math.max(1,Math.min(c.col-r,80-o)));let l=" ".repeat(o)+"^".repeat(a);n.message+=`:
|
|
62
62
|
|
|
63
63
|
${s}
|
|
64
64
|
${l}
|
|
65
|
-
`}};zt.YAMLError=Gt;zt.YAMLParseError=so;zt.YAMLWarning=ao;zt.prettifyError=
|
|
66
|
-
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(co(e.key)||co(e.value))return!0}return!1;default:return!0}}
|
|
67
|
-
`+p.comment:a.comment=p.comment);continue}(p.newlineAfterProp||
|
|
68
|
-
`+
|
|
69
|
-
`+E.comment:l.comment=E.comment),
|
|
70
|
-
`+
|
|
71
|
-
`+
|
|
72
|
-
`+m.comment:l.comment=m.comment),l.range=[i.offset,p,m.offset]}else l.range=[i.offset,p,p];return l}
|
|
73
|
-
`.repeat(Math.max(1,s.length-1)):"",m=i+r.length;return e.source&&(m+=e.source.length),{value:p,type:o,comment:r.comment,range:[i,m,m]}}let c=e.indent+r.indent,l=e.offset+r.length,
|
|
74
|
-
`;for(let p=
|
|
75
|
-
`):m.length>c||
|
|
65
|
+
`}};zt.YAMLError=Gt;zt.YAMLParseError=so;zt.YAMLWarning=ao;zt.prettifyError=Bp});var Xt=v(cc=>{"use strict";function Kp(t,{flow:e,indicator:n,next:i,offset:r,onError:o,parentIndent:s,startOnNewline:a}){let c=!1,l=a,u=a,f="",d="",h=!1,g=!1,p=null,m=null,w=null,y=null,S=null,k=null,C=null;for(let b of t)switch(g&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&o(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),p&&(l&&b.type!=="comment"&&b.type!=="newline"&&o(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),b.type){case"space":!e&&(n!=="doc-start"||i?.type!=="flow-collection")&&b.source.includes(" ")&&(p=b),u=!0;break;case"comment":{u||o(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=b.source.substring(1)||" ";f?f+=d+_:f=_,d="",l=!1;break}case"newline":l?f?f+=b.source:(!k||n!=="seq-item-ind")&&(c=!0):d+=b.source,l=!0,h=!0,(m||w)&&(y=b),u=!0;break;case"anchor":m&&o(b,"MULTIPLE_ANCHORS","A node can have at most one anchor"),b.source.endsWith(":")&&o(b.offset+b.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=b,C??(C=b.offset),l=!1,u=!1,g=!0;break;case"tag":{w&&o(b,"MULTIPLE_TAGS","A node can have at most one tag"),w=b,C??(C=b.offset),l=!1,u=!1,g=!0;break}case n:(m||w)&&o(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),k&&o(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${e??"collection"}`),k=b,l=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(e){S&&o(b,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),S=b,l=!1,u=!1;break}default:o(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,u=!1}let E=t[t.length-1],P=E?E.offset+E.source.length:r;return g&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&o(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(l&&p.indent<=s||i?.type==="block-map"||i?.type==="block-seq")&&o(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:S,found:k,spaceBefore:c,comment:f,hasNewline:h,anchor:m,tag:w,newlineAfterProp:y,end:P,start:C??P}}cc.resolveProps=Kp});var fi=v(lc=>{"use strict";function co(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
|
|
66
|
+
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(co(e.key)||co(e.value))return!0}return!1;default:return!0}}lc.containsNewline=co});var lo=v(uc=>{"use strict";var Hp=fi();function Up(t,e,n){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&Hp.containsNewline(e)&&n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}uc.flowIndentCheck=Up});var uo=v(dc=>{"use strict";var fc=x();function Yp(t,e,n){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let r=typeof i=="function"?i:(o,s)=>o===s||fc.isScalar(o)&&fc.isScalar(s)&&o.value===s.value;return e.some(o=>r(o.key,n))}dc.mapIncludes=Yp});var yc=v(wc=>{"use strict";var pc=Re(),Jp=Ae(),mc=Xt(),Vp=fi(),hc=lo(),Gp=uo(),gc="All mapping items must start at the same column";function zp({composeNode:t,composeEmptyNode:e},n,i,r,o){let s=o?.nodeClass??Jp.YAMLMap,a=new s(n.schema);n.atRoot&&(n.atRoot=!1);let c=i.offset,l=null;for(let u of i.items){let{start:f,key:d,sep:h,value:g}=u,p=mc.resolveProps(f,{indicator:"explicit-key-ind",next:d??h?.[0],offset:c,onError:r,parentIndent:i.indent,startOnNewline:!0}),m=!p.found;if(m){if(d&&(d.type==="block-seq"?r(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==i.indent&&r(c,"BAD_INDENT",gc)),!p.anchor&&!p.tag&&!h){l=p.end,p.comment&&(a.comment?a.comment+=`
|
|
67
|
+
`+p.comment:a.comment=p.comment);continue}(p.newlineAfterProp||Vp.containsNewline(d))&&r(d??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==i.indent&&r(c,"BAD_INDENT",gc);n.atKey=!0;let w=p.end,y=d?t(n,d,p,r):e(n,w,f,null,p,r);n.schema.compat&&hc.flowIndentCheck(i.indent,d,r),n.atKey=!1,Gp.mapIncludes(n,a.items,y)&&r(w,"DUPLICATE_KEY","Map keys must be unique");let S=mc.resolveProps(h??[],{indicator:"map-value-ind",next:g,offset:y.range[2],onError:r,parentIndent:i.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=S.end,S.found){m&&(g?.type==="block-map"&&!S.hasNewline&&r(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&p.start<S.found.offset-1024&&r(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=g?t(n,g,S,r):e(n,c,h,null,S,r);n.schema.compat&&hc.flowIndentCheck(i.indent,g,r),c=k.range[2];let C=new pc.Pair(y,k);n.options.keepSourceTokens&&(C.srcToken=u),a.items.push(C)}else{m&&r(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(y.comment?y.comment+=`
|
|
68
|
+
`+S.comment:y.comment=S.comment);let k=new pc.Pair(y);n.options.keepSourceTokens&&(k.srcToken=u),a.items.push(k)}}return l&&l<c&&r(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[i.offset,c,l??c],a}wc.resolveBlockMap=zp});var kc=v(vc=>{"use strict";var Qp=Ne(),Xp=Xt(),Zp=lo();function em({composeNode:t,composeEmptyNode:e},n,i,r,o){let s=o?.nodeClass??Qp.YAMLSeq,a=new s(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let c=i.offset,l=null;for(let{start:u,value:f}of i.items){let d=Xp.resolveProps(u,{indicator:"seq-item-ind",next:f,offset:c,onError:r,parentIndent:i.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||f)f?.type==="block-seq"?r(d.end,"BAD_INDENT","All sequence items must start at the same column"):r(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(a.comment=d.comment);continue}let h=f?t(n,f,d,r):e(n,d.end,u,null,d,r);n.schema.compat&&Zp.flowIndentCheck(i.indent,f,r),c=h.range[2],a.items.push(h)}return a.range=[i.offset,c,l??c],a}vc.resolveBlockSeq=em});var ht=v(bc=>{"use strict";function tm(t,e,n,i){let r="";if(t){let o=!1,s="";for(let a of t){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{n&&!o&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";r?r+=s+u:r=u,s="";break}case"newline":r&&(s+=c),o=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:r,offset:e}}bc.resolveEnd=tm});var _c=v(Ec=>{"use strict";var nm=x(),im=Re(),Sc=Ae(),rm=Ne(),om=ht(),Cc=Xt(),sm=fi(),am=uo(),fo="Block collections are not allowed within flow collections",po=t=>t&&(t.type==="block-map"||t.type==="block-seq");function cm({composeNode:t,composeEmptyNode:e},n,i,r,o){let s=i.start.source==="{",a=s?"flow map":"flow sequence",c=o?.nodeClass??(s?Sc.YAMLMap:rm.YAMLSeq),l=new c(n.schema);l.flow=!0;let u=n.atRoot;u&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let f=i.offset+i.start.source.length;for(let m=0;m<i.items.length;++m){let w=i.items[m],{start:y,key:S,sep:k,value:C}=w,E=Cc.resolveProps(y,{flow:a,indicator:"explicit-key-ind",next:S??k?.[0],offset:f,onError:r,parentIndent:i.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!k&&!C){m===0&&E.comma?r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):m<i.items.length-1&&r(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),E.comment&&(l.comment?l.comment+=`
|
|
69
|
+
`+E.comment:l.comment=E.comment),f=E.end;continue}!s&&n.options.strict&&sm.containsNewline(S)&&r(S,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)E.comma&&r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(E.comma||r(E.start,"MISSING_CHAR",`Missing , between ${a} items`),E.comment){let P="";e:for(let b of y)switch(b.type){case"comma":case"space":break;case"comment":P=b.source.substring(1);break e;default:break e}if(P){let b=l.items[l.items.length-1];nm.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
|
|
70
|
+
`+P:b.comment=P,E.comment=E.comment.substring(P.length+1)}}if(!s&&!k&&!E.found){let P=C?t(n,C,E,r):e(n,E.end,k,null,E,r);l.items.push(P),f=P.range[2],po(C)&&r(P.range,"BLOCK_IN_FLOW",fo)}else{n.atKey=!0;let P=E.end,b=S?t(n,S,E,r):e(n,P,y,null,E,r);po(S)&&r(b.range,"BLOCK_IN_FLOW",fo),n.atKey=!1;let _=Cc.resolveProps(k??[],{flow:a,indicator:"map-value-ind",next:C,offset:b.range[2],onError:r,parentIndent:i.indent,startOnNewline:!1});if(_.found){if(!s&&!E.found&&n.options.strict){if(k)for(let j of k){if(j===_.found)break;if(j.type==="newline"){r(j,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<_.found.offset-1024&&r(_.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else C&&("source"in C&&C.source?.[0]===":"?r(C,"MISSING_CHAR",`Missing space after : in ${a}`):r(_.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let V=C?t(n,C,_,r):_.found?e(n,_.end,k,null,_,r):null;V?po(C)&&r(V.range,"BLOCK_IN_FLOW",fo):_.comment&&(b.comment?b.comment+=`
|
|
71
|
+
`+_.comment:b.comment=_.comment);let Ce=new im.Pair(b,V);if(n.options.keepSourceTokens&&(Ce.srcToken=w),s){let j=l;am.mapIncludes(n,j.items,b)&&r(P,"DUPLICATE_KEY","Map keys must be unique"),j.items.push(Ce)}else{let j=new Sc.YAMLMap(n.schema);j.flow=!0,j.items.push(Ce);let se=(V??b).range;j.range=[b.range[0],se[1],se[2]],l.items.push(j)}f=V?V.range[2]:_.end}}let d=s?"}":"]",[h,...g]=i.end,p=f;if(h?.source===d)p=h.offset+h.source.length;else{let m=a[0].toUpperCase()+a.substring(1),w=u?`${m} must end with a ${d}`:`${m} in block collection must be sufficiently indented and end with a ${d}`;r(f,u?"MISSING_CHAR":"BAD_INDENT",w),h&&h.source.length!==1&&g.unshift(h)}if(g.length>0){let m=om.resolveEnd(g,p,n.options.strict,r);m.comment&&(l.comment?l.comment+=`
|
|
72
|
+
`+m.comment:l.comment=m.comment),l.range=[i.offset,p,m.offset]}else l.range=[i.offset,p,p];return l}Ec.resolveFlowCollection=cm});var Pc=v(xc=>{"use strict";var lm=x(),um=T(),fm=Ae(),dm=Ne(),pm=yc(),mm=kc(),hm=_c();function mo(t,e,n,i,r,o){let s=n.type==="block-map"?pm.resolveBlockMap(t,e,n,i,o):n.type==="block-seq"?mm.resolveBlockSeq(t,e,n,i,o):hm.resolveFlowCollection(t,e,n,i,o),a=s.constructor;return r==="!"||r===a.tagName?(s.tag=a.tagName,s):(r&&(s.tag=r),s)}function gm(t,e,n,i,r){let o=i.tag,s=o?e.directives.tagName(o.source,d=>r(o,"TAG_RESOLVE_FAILED",d)):null;if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=i,g=d&&o?d.offset>o.offset?d:o:d??o;g&&(!h||h.offset<g.offset)&&r(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!o||!s||s==="!"||s===fm.YAMLMap.tagName&&a==="map"||s===dm.YAMLSeq.tagName&&a==="seq")return mo(t,e,n,r,s);let c=e.schema.tags.find(d=>d.tag===s&&d.collection===a);if(!c){let d=e.schema.knownTags[s];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?r(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):r(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0),mo(t,e,n,r,s)}let l=mo(t,e,n,r,s,c),u=c.resolve?.(l,d=>r(o,"TAG_RESOLVE_FAILED",d),e.options)??l,f=lm.isNode(u)?u:new um.Scalar(u);return f.range=l.range,f.tag=s,c?.format&&(f.format=c.format),f}xc.composeCollection=gm});var go=v(Rc=>{"use strict";var ho=T();function wm(t,e,n){let i=e.offset,r=ym(e,t.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};let o=r.mode===">"?ho.Scalar.BLOCK_FOLDED:ho.Scalar.BLOCK_LITERAL,s=e.source?vm(e.source):[],a=s.length;for(let p=s.length-1;p>=0;--p){let m=s[p][1];if(m===""||m==="\r")a=p;else break}if(a===0){let p=r.chomp==="+"&&s.length>0?`
|
|
73
|
+
`.repeat(Math.max(1,s.length-1)):"",m=i+r.length;return e.source&&(m+=e.source.length),{value:p,type:o,comment:r.comment,range:[i,m,m]}}let c=e.indent+r.indent,l=e.offset+r.length,u=0;for(let p=0;p<a;++p){let[m,w]=s[p];if(w===""||w==="\r")r.indent===0&&m.length>c&&(c=m.length);else{m.length<c&&n(l+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(c=m.length),u=p,c===0&&!t.atRoot&&n(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+w.length+1}for(let p=s.length-1;p>=a;--p)s[p][0].length>c&&(a=p+1);let f="",d="",h=!1;for(let p=0;p<u;++p)f+=s[p][0].slice(c)+`
|
|
74
|
+
`;for(let p=u;p<a;++p){let[m,w]=s[p];l+=m.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&m.length<c){let k=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;n(l-w.length-(y?2:1),"BAD_INDENT",k),m=""}o===ho.Scalar.BLOCK_LITERAL?(f+=d+m.slice(c)+w,d=`
|
|
75
|
+
`):m.length>c||w[0]===" "?(d===" "?d=`
|
|
76
76
|
`:!h&&d===`
|
|
77
77
|
`&&(d=`
|
|
78
78
|
|
|
79
|
-
`),
|
|
80
|
-
`,h=!0):
|
|
81
|
-
`?
|
|
79
|
+
`),f+=d+m.slice(c)+w,d=`
|
|
80
|
+
`,h=!0):w===""?d===`
|
|
81
|
+
`?f+=`
|
|
82
82
|
`:d=`
|
|
83
|
-
`:(
|
|
84
|
-
`+s[p][0].slice(c);
|
|
85
|
-
`&&(
|
|
86
|
-
`);break;default:
|
|
87
|
-
`}let
|
|
83
|
+
`:(f+=d+w,d=" ",h=!1)}switch(r.chomp){case"-":break;case"+":for(let p=a;p<s.length;++p)f+=`
|
|
84
|
+
`+s[p][0].slice(c);f[f.length-1]!==`
|
|
85
|
+
`&&(f+=`
|
|
86
|
+
`);break;default:f+=`
|
|
87
|
+
`}let g=i+r.length+e.source.length;return{value:f,type:o,comment:r.comment,range:[i,g,g]}}function ym({offset:t,props:e},n,i){if(e[0].type!=="block-scalar-header")return i(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=e[0],o=r[0],s=0,a="",c=-1;for(let d=1;d<r.length;++d){let h=r[d];if(!a&&(h==="-"||h==="+"))a=h;else{let g=Number(h);!s&&g?s=g:c===-1&&(c=t+d)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let l=!1,u="",f=r.length;for(let d=1;d<e.length;++d){let h=e[d];switch(h.type){case"space":l=!0;case"newline":f+=h.source.length;break;case"comment":n&&!l&&i(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=h.source.length,u=h.source.substring(1);break;case"error":i(h,"UNEXPECTED_TOKEN",h.message),f+=h.source.length;break;default:{let g=`Unexpected token in block scalar header: ${h.type}`;i(h,"UNEXPECTED_TOKEN",g);let p=h.source;p&&typeof p=="string"&&(f+=p.length)}}}return{mode:o,indent:s,chomp:a,comment:u,length:f}}function vm(t){let e=t.split(/\n( *)/),n=e[0],i=n.match(/^( *)/),o=[i?.[1]?[i[1],n.slice(i[1].length)]:["",n]];for(let s=1;s<e.length;s+=2)o.push([e[s],e[s+1]]);return o}Rc.resolveBlockScalar=wm});var yo=v(Ac=>{"use strict";var wo=T(),km=ht();function bm(t,e,n){let{offset:i,type:r,source:o,end:s}=t,a,c,l=(d,h,g)=>n(i+d,h,g);switch(r){case"scalar":a=wo.Scalar.PLAIN,c=Sm(o,l);break;case"single-quoted-scalar":a=wo.Scalar.QUOTE_SINGLE,c=Cm(o,l);break;case"double-quoted-scalar":a=wo.Scalar.QUOTE_DOUBLE,c=Em(o,l);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[i,i+o.length,i+o.length]}}let u=i+o.length,f=km.resolveEnd(s,u,e,n);return{value:c,type:a,comment:f.comment,range:[i,u,f.offset]}}function Sm(t,e){let n="";switch(t[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 ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Oc(t)}function Cm(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Oc(t.slice(1,-1)).replace(/''/g,"'")}function Oc(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
88
88
|
`,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
89
89
|
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=e.exec(t);if(!i)return t;let r=i[1],o=" ",s=e.lastIndex;for(n.lastIndex=s;i=n.exec(t);)i[1]===""?o===`
|
|
90
90
|
`?r+=o:o=`
|
|
91
|
-
`:(r+=o+i[1],o=" "),s=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=s,i=a.exec(t),r+o+(i?.[1]??"")}function
|
|
91
|
+
`:(r+=o+i[1],o=" "),s=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=s,i=a.exec(t),r+o+(i?.[1]??"")}function Em(t,e){let n="";for(let i=1;i<t.length-1;++i){let r=t[i];if(!(r==="\r"&&t[i+1]===`
|
|
92
92
|
`))if(r===`
|
|
93
|
-
`){let{fold:o,offset:s}=
|
|
93
|
+
`){let{fold:o,offset:s}=_m(t,i);n+=o,i=s}else if(r==="\\"){let o=t[++i],s=xm[o];if(s)n+=s;else if(o===`
|
|
94
94
|
`)for(o=t[i+1];o===" "||o===" ";)o=t[++i+1];else if(o==="\r"&&t[i+1]===`
|
|
95
|
-
`)for(o=t[++i+1];o===" "||o===" ";)o=t[++i+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=
|
|
95
|
+
`)for(o=t[++i+1];o===" "||o===" ";)o=t[++i+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=Pm(t,i+1,a,e),i+=a}else{let a=t.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(r===" "||r===" "){let o=i,s=t[i+1];for(;s===" "||s===" ";)s=t[++i+1];s!==`
|
|
96
96
|
`&&!(s==="\r"&&t[i+2]===`
|
|
97
|
-
`)&&(n+=i>o?t.slice(o,i+1):r)}else n+=r}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function
|
|
97
|
+
`)&&(n+=i>o?t.slice(o,i+1):r)}else n+=r}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function _m(t,e){let n="",i=t[e+1];for(;(i===" "||i===" "||i===`
|
|
98
98
|
`||i==="\r")&&!(i==="\r"&&t[e+2]!==`
|
|
99
99
|
`);)i===`
|
|
100
100
|
`&&(n+=`
|
|
101
|
-
`),e+=1,i=t[e+1];return n||(n=" "),{fold:n,offset:e}}var
|
|
102
|
-
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
101
|
+
`),e+=1,i=t[e+1];return n||(n=" "),{fold:n,offset:e}}var xm={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Pm(t,e,n,i){let r=t.substr(e,n),s=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(s)}catch{let a=t.substr(e-2,n+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Ac.resolveFlowScalar=bm});var Tc=v(jc=>{"use strict";var Xe=x(),Nc=T(),Rm=go(),Om=yo();function Am(t,e,n,i){let{value:r,type:o,comment:s,range:a}=e.type==="block-scalar"?Rm.resolveBlockScalar(t,e,i):Om.resolveFlowScalar(e,t.options.strict,i),c=n?t.directives.tagName(n.source,f=>i(n,"TAG_RESOLVE_FAILED",f)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Xe.SCALAR]:c?l=Nm(t.schema,r,c,n,i):e.type==="scalar"?l=jm(t,r,e,i):l=t.schema[Xe.SCALAR];let u;try{let f=l.resolve(r,d=>i(n??e,"TAG_RESOLVE_FAILED",d),t.options);u=Xe.isScalar(f)?f:new Nc.Scalar(f)}catch(f){let d=f instanceof Error?f.message:String(f);i(n??e,"TAG_RESOLVE_FAILED",d),u=new Nc.Scalar(r)}return u.range=a,u.source=r,o&&(u.type=o),c&&(u.tag=c),l.format&&(u.format=l.format),s&&(u.comment=s),u}function Nm(t,e,n,i,r){if(n==="!")return t[Xe.SCALAR];let o=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(e))return a;let s=t.knownTags[n];return s&&!s.collection?(t.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[Xe.SCALAR])}function jm({atKey:t,directives:e,schema:n},i,r,o){let s=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(i))||n[Xe.SCALAR];if(n.compat){let a=n.compat.find(c=>c.default&&c.test?.test(i))??n[Xe.SCALAR];if(s.tag!==a.tag){let c=e.tagString(s.tag),l=e.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;o(r,"TAG_RESOLVE_FAILED",u,!0)}}return s}jc.composeScalar=Am});var $c=v(Ic=>{"use strict";function Tm(t,e,n){if(e){n??(n=e.length);for(let i=n-1;i>=0;--i){let r=e[i];switch(r.type){case"space":case"comment":case"newline":t-=r.source.length;continue}for(r=e[++i];r?.type==="space";)t+=r.source.length,r=e[++i];break}}return t}Ic.emptyScalarPosition=Tm});var Wc=v(ko=>{"use strict";var Im=jt(),$m=x(),qm=Pc(),qc=Tc(),Lm=ht(),Wm=$c(),Dm={composeNode:Lc,composeEmptyNode:vo};function Lc(t,e,n,i){let r=t.atKey,{spaceBefore:o,comment:s,anchor:a,tag:c}=n,l,u=!0;switch(e.type){case"alias":l=Fm(t,e,i),(a||c)&&i(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=qc.composeScalar(t,e,c,i),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=qm.composeCollection(Dm,t,e,n,i),a&&(l.anchor=a.source.substring(1))}catch(f){let d=f instanceof Error?f.message:String(f);i(e,"RESOURCE_EXHAUSTION",d)}break;default:{let f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",f),u=!1}}return l??(l=vo(t,e.offset,void 0,null,n,i)),a&&l.anchor===""&&i(a,"BAD_ALIAS","Anchor cannot be an empty string"),r&&t.options.stringKeys&&(!$m.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&i(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(l.spaceBefore=!0),s&&(e.type==="scalar"&&e.source===""?l.comment=s:l.commentBefore=s),t.options.keepSourceTokens&&u&&(l.srcToken=e),l}function vo(t,e,n,i,{spaceBefore:r,comment:o,anchor:s,tag:a,end:c},l){let u={type:"scalar",offset:Wm.emptyScalarPosition(e,n,i),indent:-1,source:""},f=qc.composeScalar(t,u,a,l);return s&&(f.anchor=s.source.substring(1),f.anchor===""&&l(s,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(f.spaceBefore=!0),o&&(f.comment=o,f.range[2]=c),f}function Fm({options:t},{offset:e,source:n,end:i},r){let o=new Im.Alias(n.substring(1));o.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&r(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=e+n.length,a=Lm.resolveEnd(i,s,t.strict,r);return o.range=[e,s,a.offset],a.comment&&(o.comment=a.comment),o}ko.composeEmptyNode=vo;ko.composeNode=Lc});var Mc=v(Fc=>{"use strict";var Mm=Vt(),Dc=Wc(),Bm=ht(),Km=Xt();function Hm(t,e,{offset:n,start:i,value:r,end:o},s){let a=Object.assign({_directives:e},t),c=new Mm.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=Km.resolveProps(i,{indicator:"doc-start",next:r??o?.[0],offset:n,onError:s,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!u.hasNewline&&s(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=r?Dc.composeNode(l,r,u,s):Dc.composeEmptyNode(l,u.end,i,null,u,s);let f=c.contents.range[2],d=Bm.resolveEnd(o,f,!1,s);return d.comment&&(c.comment=d.comment),c.range=[n,f,d.offset],c}Fc.composeDoc=Hm});var So=v(Hc=>{"use strict";var Um=bn("process"),Ym=sr(),Jm=Vt(),Zt=Qt(),Bc=x(),Vm=Mc(),Gm=ht();function en(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function Kc(t){let e="",n=!1,i=!1;for(let r=0;r<t.length;++r){let o=t[r];switch(o[0]){case"#":e+=(e===""?"":i?`
|
|
103
103
|
|
|
104
104
|
`:`
|
|
105
|
-
`)+(o.substring(1)||" "),n=!0,i=!1;break;case"%":t[r+1]?.[0]!=="#"&&(r+=1),n=!1;break;default:n||(i=!0),n=!1}}return{comment:e,afterEmptyLine:i}}var bo=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,i,r,o)=>{let s=en(n);o?this.warnings.push(new Zt.YAMLWarning(s,i,r)):this.errors.push(new Zt.YAMLParseError(s,i,r))},this.directives=new
|
|
106
|
-
${i}`:i;else if(r||e.directives.docStart||!o)e.commentBefore=i;else if(
|
|
105
|
+
`)+(o.substring(1)||" "),n=!0,i=!1;break;case"%":t[r+1]?.[0]!=="#"&&(r+=1),n=!1;break;default:n||(i=!0),n=!1}}return{comment:e,afterEmptyLine:i}}var bo=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,i,r,o)=>{let s=en(n);o?this.warnings.push(new Zt.YAMLWarning(s,i,r)):this.errors.push(new Zt.YAMLParseError(s,i,r))},this.directives=new Ym.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:i,afterEmptyLine:r}=Kc(this.prelude);if(i){let o=e.contents;if(n)e.comment=e.comment?`${e.comment}
|
|
106
|
+
${i}`:i;else if(r||e.directives.docStart||!o)e.commentBefore=i;else if(Bc.isCollection(o)&&!o.flow&&o.items.length>0){let s=o.items[0];Bc.isPair(s)&&(s=s.key);let a=s.commentBefore;s.commentBefore=a?`${i}
|
|
107
107
|
${a}`:i}else{let s=o.commentBefore;o.commentBefore=s?`${i}
|
|
108
|
-
${s}`:i}}if(n){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
109
|
-
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new Zt.YAMLParseError(en(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let i=Object.assign({_directives:this.directives},this.options),r=new
|
|
108
|
+
${s}`:i}}if(n){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Kc(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,i=-1){for(let r of e)yield*this.next(r);yield*this.end(n,i)}*next(e){switch(Um.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,i,r)=>{let o=en(e);o[0]+=n,this.onError(o,"BAD_DIRECTIVE",i,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=Vm.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,i=new Zt.YAMLParseError(en(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new Zt.YAMLParseError(en(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let n=Gm.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
|
|
109
|
+
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new Zt.YAMLParseError(en(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let i=Object.assign({_directives:this.directives},this.options),r=new Jm.Document(void 0,i);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,n,n],this.decorate(r,!1),yield r}}};Hc.Composer=bo});var Jc=v(di=>{"use strict";var zm=go(),Qm=yo(),Xm=Qt(),Uc=Lt();function Zm(t,e=!0,n){if(t){let i=(r,o,s)=>{let a=typeof r=="number"?r:Array.isArray(r)?r[0]:r.offset;if(n)n(a,o,s);else throw new Xm.YAMLParseError([a,a+1],o,s)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Qm.resolveFlowScalar(t,e,i);case"block-scalar":return zm.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function eh(t,e){let{implicitKey:n=!1,indent:i,inFlow:r=!1,offset:o=-1,type:s="PLAIN"}=e,a=Uc.stringifyString({type:s,value:t},{implicitKey:n,indent:i>0?" ".repeat(i):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:i,source:`
|
|
110
110
|
`}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
|
|
111
|
-
`),
|
|
112
|
-
`,d=[{type:"block-scalar-header",offset:o,indent:i,source:
|
|
113
|
-
`}),{type:"block-scalar",offset:o,indent:i,props:d,source:
|
|
111
|
+
`),u=a.substring(0,l),f=a.substring(l+1)+`
|
|
112
|
+
`,d=[{type:"block-scalar-header",offset:o,indent:i,source:u}];return Yc(d,c)||d.push({type:"newline",offset:-1,indent:i,source:`
|
|
113
|
+
`}),{type:"block-scalar",offset:o,indent:i,props:d,source:f}}case'"':return{type:"double-quoted-scalar",offset:o,indent:i,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:i,source:a,end:c};default:return{type:"scalar",offset:o,indent:i,source:a,end:c}}}function th(t,e,n={}){let{afterKey:i=!1,implicitKey:r=!1,inFlow:o=!1,type:s}=n,a="indent"in t?t.indent:null;if(i&&typeof a=="number"&&(a+=2),!s)switch(t.type){case"single-quoted-scalar":s="QUOTE_SINGLE";break;case"double-quoted-scalar":s="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");s=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=Uc.stringifyString({type:s,value:e},{implicitKey:r||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":nh(t,c);break;case'"':Co(t,c,"double-quoted-scalar");break;case"'":Co(t,c,"single-quoted-scalar");break;default:Co(t,c,"scalar")}}function nh(t,e){let n=e.indexOf(`
|
|
114
114
|
`),i=e.substring(0,n),r=e.substring(n+1)+`
|
|
115
|
-
`;if(t.type==="block-scalar"){let o=t.props[0];if(o.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o.source=i,t.source=r}else{let{offset:o}=t,s="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:s,source:i}];
|
|
116
|
-
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:s,props:a,source:r})}}function
|
|
117
|
-
`};delete t.items,Object.assign(t,{type:n,source:e,end:[r]});break}default:{let i="indent"in t?t.indent:-1,r="end"in t&&Array.isArray(t.end)?t.end.filter(o=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(t))o!=="type"&&o!=="offset"&&delete t[o];Object.assign(t,{type:n,indent:i,source:e,end:r})}}}di.createScalarToken=
|
|
115
|
+
`;if(t.type==="block-scalar"){let o=t.props[0];if(o.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o.source=i,t.source=r}else{let{offset:o}=t,s="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:s,source:i}];Yc(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:s,source:`
|
|
116
|
+
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:s,props:a,source:r})}}function Yc(t,e){if(e)for(let n of e)switch(n.type){case"space":case"comment":t.push(n);break;case"newline":return t.push(n),!0}return!1}function Co(t,e,n){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=n,t.source=e;break;case"block-scalar":{let i=t.props.slice(1),r=e.length;t.props[0].type==="block-scalar-header"&&(r-=t.props[0].source.length);for(let o of i)o.offset+=r;delete t.props,Object.assign(t,{type:n,source:e,end:i});break}case"block-map":case"block-seq":{let r={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
|
|
117
|
+
`};delete t.items,Object.assign(t,{type:n,source:e,end:[r]});break}default:{let i="indent"in t?t.indent:-1,r="end"in t&&Array.isArray(t.end)?t.end.filter(o=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(t))o!=="type"&&o!=="offset"&&delete t[o];Object.assign(t,{type:n,indent:i,source:e,end:r})}}}di.createScalarToken=eh;di.resolveAsScalar=Zm;di.setScalarValue=th});var Gc=v(Vc=>{"use strict";var ih=t=>"type"in t?mi(t):pi(t);function mi(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=mi(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=pi(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=pi(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=pi(t);if(t.end)for(let n of t.end)e+=n.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let n of t.end)e+=n.source;return e}}}function pi({start:t,key:e,sep:n,value:i}){let r="";for(let o of t)r+=o.source;if(e&&(r+=mi(e)),n)for(let o of n)r+=o.source;return i&&(r+=mi(i)),r}Vc.stringify=ih});var Zc=v(Xc=>{"use strict";var Eo=Symbol("break visit"),rh=Symbol("skip children"),zc=Symbol("remove item");function Ze(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Qc(Object.freeze([]),t,e)}Ze.BREAK=Eo;Ze.SKIP=rh;Ze.REMOVE=zc;Ze.itemAtPath=(t,e)=>{let n=t;for(let[i,r]of e){let o=n?.[i];if(o&&"items"in o)n=o.items[r];else return}return n};Ze.parentCollection=(t,e)=>{let n=Ze.itemAtPath(t,e.slice(0,-1)),i=e[e.length-1][0],r=n?.[i];if(r&&"items"in r)return r;throw new Error("Parent collection not found")};function Qc(t,e,n){let i=n(e,t);if(typeof i=="symbol")return i;for(let r of["key","value"]){let o=e[r];if(o&&"items"in o){for(let s=0;s<o.items.length;++s){let a=Qc(Object.freeze(t.concat([[r,s]])),o.items[s],n);if(typeof a=="number")s=a-1;else{if(a===Eo)return Eo;a===zc&&(o.items.splice(s,1),s-=1)}}typeof i=="function"&&r==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}Xc.visit=Ze});var hi=v(U=>{"use strict";var _o=Jc(),oh=Gc(),sh=Zc(),xo="\uFEFF",Po="",Ro="",Oo="",ah=t=>!!t&&"items"in t,ch=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function lh(t){switch(t){case xo:return"<BOM>";case Po:return"<DOC>";case Ro:return"<FLOW_END>";case Oo:return"<SCALAR>";default:return JSON.stringify(t)}}function uh(t){switch(t){case xo:return"byte-order-mark";case Po:return"doc-mode";case Ro:return"flow-error-end";case Oo:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
118
118
|
`:case`\r
|
|
119
|
-
`: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(t[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}
|
|
120
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
121
|
-
\r `),Ao=t=>!t||
|
|
119
|
+
`: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(t[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}U.createScalarToken=_o.createScalarToken;U.resolveAsScalar=_o.resolveAsScalar;U.setScalarValue=_o.setScalarValue;U.stringify=oh.stringify;U.visit=sh.visit;U.BOM=xo;U.DOCUMENT=Po;U.FLOW_END=Ro;U.SCALAR=Oo;U.isCollection=ah;U.isScalar=ch;U.prettyToken=lh;U.tokenType=uh});var jo=v(tl=>{"use strict";var tn=hi();function te(t){switch(t){case void 0:case" ":case`
|
|
120
|
+
`:case"\r":case" ":return!0;default:return!1}}var el=new Set("0123456789ABCDEFabcdef"),fh=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),gi=new Set(",[]{}"),dh=new Set(` ,[]{}
|
|
121
|
+
\r `),Ao=t=>!t||dh.has(t),No=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,n=!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=!n;let i=this.next??"stream";for(;i&&(n||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
|
|
122
122
|
`?!0:n==="\r"?this.buffer[e+1]===`
|
|
123
123
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let i=0;for(;n===" ";)n=this.buffer[++i+e];if(n==="\r"){let r=this.buffer[i+e+1];if(r===`
|
|
124
124
|
`||!r&&!this.atEnd)return e+i+1}return n===`
|
|
125
|
-
`||i>=this.indentNext||!n&&!this.atEnd?e+i:-1}if(n==="-"||n==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&
|
|
126
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===tn.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,i=e.indexOf("#");for(;i!==-1;){let o=e[i-1];if(o===" "||o===" "){n=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let o=e[n-1];if(o===" "||o===" ")n-=1;else break}let r=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield tn.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&
|
|
125
|
+
`||i>=this.indentNext||!n&&!this.atEnd?e+i:-1}if(n==="-"||n==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&te(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
126
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===tn.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,i=e.indexOf("#");for(;i!==-1;){let o=e[i-1];if(o===" "||o===" "){n=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let o=e[n-1];if(o===" "||o===" ")n-=1;else break}let r=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield tn.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&te(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!te(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&te(n)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Ao),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,i=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=i=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let r=this.getLine();if(r===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&r[0]!=="#"||i===0&&(r.startsWith("---")||r.startsWith("..."))&&te(r[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield tn.FLOW_END,yield*this.parseLineStart();let o=0;for(;r[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),r[o]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-o),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Ao),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let s=this.charAt(1);if(this.flowKey||te(s)||s===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let o=0;for(;this.buffer[n-1-o]==="\\";)o+=1;if(o%2===0)break;n=this.buffer.indexOf('"',n+1)}let i=this.buffer.substring(0,n),r=i.indexOf(`
|
|
127
127
|
`,this.pos);if(r!==-1){for(;r!==-1;){let o=this.continueScalar(r+1);if(o===-1)break;r=i.indexOf(`
|
|
128
|
-
`,o)}r!==-1&&(n=r-(i[r-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>
|
|
128
|
+
`,o)}r!==-1&&(n=r-(i[r-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>te(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,i;e:for(let o=this.pos;i=this.buffer[o];++o)switch(i){case" ":n+=1;break;case`
|
|
129
129
|
`:e=o,n=0;break;case"\r":{let s=this.buffer[o+1];if(!s&&!this.atEnd)return this.setNext("block-scalar");if(s===`
|
|
130
130
|
`)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(e+1);if(o===-1)break;e=this.buffer.indexOf(`
|
|
131
131
|
`,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let r=e+1;for(i=this.buffer[r];i===" ";)i=this.buffer[++r];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
|
|
132
132
|
`;)i=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let o=e-1,s=this.buffer[o];s==="\r"&&(s=this.buffer[--o]);let a=o;for(;s===" ";)s=this.buffer[--o];if(s===`
|
|
133
|
-
`&&o>=this.pos&&o+1+n>a)e=o;else break}while(!0);return yield tn.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,i=this.pos-1,r;for(;r=this.buffer[++i];)if(r===":"){let o=this.buffer[i+1];if(
|
|
133
|
+
`&&o>=this.pos&&o+1+n>a)e=o;else break}while(!0);return yield tn.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,i=this.pos-1,r;for(;r=this.buffer[++i];)if(r===":"){let o=this.buffer[i+1];if(te(o)||e&&gi.has(o))break;n=i}else if(te(r)){let o=this.buffer[i+1];if(r==="\r"&&(o===`
|
|
134
134
|
`?(i+=1,r=`
|
|
135
135
|
`,o=this.buffer[i+1]):n=i),o==="#"||e&&gi.has(o))break;if(r===`
|
|
136
|
-
`){let s=this.continueScalar(i+1);if(s===-1)break;i=Math.max(i,s-2)}}else{if(e&&gi.has(r))break;n=i}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield tn.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,n){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(n&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Ao),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,i=this.charAt(1);if(
|
|
136
|
+
`){let s=this.continueScalar(i+1);if(s===-1)break;i=Math.max(i,s-2)}}else{if(e&&gi.has(r))break;n=i}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield tn.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,n){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(n&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Ao),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,i=this.charAt(1);if(te(i)||n&&gi.has(i)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!te(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(fh.has(n))n=this.buffer[++e];else if(n==="%"&&el.has(this.buffer[e+1])&&el.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
137
137
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
138
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,i;do i=this.buffer[++n];while(i===" "||e&&i===" ");let r=n-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=n),r}*pushUntil(e){let n=this.pos,i=this.buffer[n];for(;!e(i);)i=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};
|
|
138
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,i;do i=this.buffer[++n];while(i===" "||e&&i===" ");let r=n-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=n),r}*pushUntil(e){let n=this.pos,i=this.buffer[n];for(;!e(i);)i=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};tl.Lexer=No});var Io=v(nl=>{"use strict";var To=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,i=this.lineStarts.length;for(;n<i;){let o=n+i>>1;this.lineStarts[o]<e?n=o+1:i=o}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let r=this.lineStarts[n-1];return{line:n,col:e-r+1}}}};nl.LineCounter=To});var qo=v(al=>{"use strict";var ph=bn("process"),il=hi(),mh=jo();function je(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function rl(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function sl(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function wi(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function gt(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function yi(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let n=0;n<e.length;++n)t.push(e[n])}function ol(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!je(e.start,"explicit-key-ind")&&!je(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,sl(e.value)?e.value.end?yi(e.value.end,e.sep):e.value.end=e.sep:yi(e.start,e.sep),delete e.sep)}var $o=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 mh.Lexer,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(e,n))yield*this.next(i);n||(yield*this.end())}*next(e){if(this.source=e,ph.env.LOG_TOKENS&&console.log("|",il.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=il.tokenType(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){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}else{let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),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 n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let i=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in i?i.indent:0:n.type==="flow-collection"&&i.type==="document"&&(n.indent=0),n.type==="flow-collection"&&ol(n),i.type){case"document":i.value=n;break;case"block-scalar":i.props.push(n);break;case"block-map":{let r=i.items[i.items.length-1];if(r.value){i.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=n;else{Object.assign(r,{key:n,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=i.items[i.items.length-1];r.value?i.items.push({start:[],value:n}):r.value=n;break}case"flow-collection":{let r=i.items[i.items.length-1];!r||r.value?i.items.push({start:[],key:n,sep:[]}):r.sep?r.value=n:Object.assign(r,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let r=n.items[n.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&rl(r.start)===-1&&(n.indent===0||r.start.every(o=>o.type!=="comment"||o.indent<n.indent))&&(i.type==="document"?i.end=r.start:i.items.push({start:r.start}),n.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":{rl(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):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 n=wi(this.peek(2)),i=gt(n),r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}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 n=this.source.indexOf(`
|
|
139
139
|
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
|
|
140
|
-
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let i="end"in n.value?n.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){yi(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,r=i&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",o=[];if(r&&n.sep&&!n.value){let s=[];for(let a=0;a<n.sep.length;++a){let c=n.sep[a];switch(c.type){case"newline":s.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(s.length=0);break;default:s.length=0}}s.length>=2&&(o=n.sep.splice(s[1]))}switch(this.type){case"anchor":case"tag":r||n.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):r||n.value?(o.push(this.sourceToken),e.items.push({start:o,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(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(
|
|
140
|
+
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let i="end"in n.value?n.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){yi(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,r=i&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",o=[];if(r&&n.sep&&!n.value){let s=[];for(let a=0;a<n.sep.length;++a){let c=n.sep[a];switch(c.type){case"newline":s.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(s.length=0);break;default:s.length=0}}s.length>=2&&(o=n.sep.splice(s[1]))}switch(this.type){case"anchor":case"tag":r||n.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):r||n.value?(o.push(this.sourceToken),e.items.push({start:o,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(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(je(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(sl(n.key)&&!je(n.sep,"newline")){let s=gt(n.start),a=n.key,c=n.sep;c.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:a,sep:c}]})}else o.length>0?n.sep=n.sep.concat(o,this.sourceToken):n.sep.push(this.sourceToken);else if(je(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let s=gt(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||r?e.items.push({start:o,key:null,sep:[this.sourceToken]}):je(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);r||n.value?(e.items.push({start:o,key:s,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(s):(Object.assign(n,{key:s,sep:[]}),this.onKeyLine=!0);return}default:{let s=this.startBlockValue(e);if(s){if(s.type==="block-seq"){if(!n.explicitKey&&n.sep&&!je(n.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 i&&e.items.push({start:o});this.stack.push(s);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let i="end"in n.value?n.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){yi(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||je(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:r,sep:[]}):n.sep?this.stack.push(r):Object.assign(n,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let r=wi(i),o=gt(r);ol(e);let s=e.end.splice(1,e.end.length);s.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
|
|
141
141
|
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
|
|
142
|
-
`,n)+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 n=wi(e),i=ht(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=wi(e),i=ht(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(i=>i.type==="newline"||i.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())}}};ol.Parser=$o});var ul=v(rn=>{"use strict";var sl=So(),dh=Vt(),nn=Qt(),ph=vr(),mh=x(),hh=Io(),al=qo();function cl(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new hh.LineCounter||null,prettyErrors:e}}function gh(t,e={}){let{lineCounter:n,prettyErrors:i}=cl(e),r=new al.Parser(n?.addNewLine),o=new sl.Composer(e),s=Array.from(o.compose(r.parse(t)));if(i&&n)for(let a of s)a.errors.forEach(nn.prettifyError(t,n)),a.warnings.forEach(nn.prettifyError(t,n));return s.length>0?s:Object.assign([],{empty:!0},o.streamInfo())}function ll(t,e={}){let{lineCounter:n,prettyErrors:i}=cl(e),r=new al.Parser(n?.addNewLine),o=new sl.Composer(e),s=null;for(let a of o.compose(r.parse(t),!0,t.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new nn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(s.errors.forEach(nn.prettifyError(t,n)),s.warnings.forEach(nn.prettifyError(t,n))),s}function wh(t,e,n){let i;typeof e=="function"?i=e:n===void 0&&e&&typeof e=="object"&&(n=e);let r=ll(t,n);if(!r)return null;if(r.warnings.forEach(o=>ph.warn(r.options.logLevel,o)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:i},n))}function yh(t,e,n){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let r=Math.round(n);n=r<1?void 0:r>8?{indent:8}:{indent:r}}if(t===void 0){let{keepUndefined:r}=n??e??{};if(!r)return}return mh.isDocument(t)&&!i?t.toString(n):new dh.Document(t,i,n).toString(n)}rn.parse=wh;rn.parseAllDocuments=gh;rn.parseDocument=ll;rn.stringify=yh});var gt=v(P=>{"use strict";var vh=So(),kh=Vt(),bh=to(),Lo=Qt(),Sh=jt(),je=x(),Ch=Pe(),Eh=T(),_h=Oe(),xh=Ae(),Ph=hi(),Rh=jo(),Oh=Io(),Ah=qo(),vi=ul(),fl=Rt();P.Composer=vh.Composer;P.Document=kh.Document;P.Schema=bh.Schema;P.YAMLError=Lo.YAMLError;P.YAMLParseError=Lo.YAMLParseError;P.YAMLWarning=Lo.YAMLWarning;P.Alias=Sh.Alias;P.isAlias=je.isAlias;P.isCollection=je.isCollection;P.isDocument=je.isDocument;P.isMap=je.isMap;P.isNode=je.isNode;P.isPair=je.isPair;P.isScalar=je.isScalar;P.isSeq=je.isSeq;P.Pair=Ch.Pair;P.Scalar=Eh.Scalar;P.YAMLMap=_h.YAMLMap;P.YAMLSeq=xh.YAMLSeq;P.CST=Ph;P.Lexer=Rh.Lexer;P.LineCounter=Oh.LineCounter;P.Parser=Ah.Parser;P.parse=vi.parse;P.parseAllDocuments=vi.parseAllDocuments;P.parseDocument=vi.parseDocument;P.stringify=vi.stringify;P.visit=fl.visit;P.visitAsync=fl.visitAsync});import Te from"path";function Dh(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||Te.posix.isAbsolute(n)||Te.win32.isAbsolute(n)||/^(?:~|[\\/])/u.test(n))throw new Error(`${e} must be a project-relative path`);if(n===".")return[];let i=n.replaceAll("\\","/").split("/");if(i.some(r=>r===".."))throw new Error(`${e} must stay inside the project root`);if(i.some(r=>r===""||r==="."))throw new Error(`${e} must not contain empty or dot path segments`);return i}function ki(t){let e=Dh(t,"native.artifact_root");return e.length===0?".":e.join("/")}function gl(t,e="docs"){let n=t??e;if(n!=="legacy"&&n!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return n}function we(t,e,n=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim().replaceAll("\\","/");if(i.length===0||Te.posix.isAbsolute(i)||Te.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be relative to its declared path base`);let r=i.split("/");if(r.some(o=>o===".."))throw new Error(`${e} must stay inside its declared path base`);if(r.some(o=>o===""||o==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!n&&/[*?]/u.test(i))throw new Error(`${e} cannot contain wildcards`);return r.join("/")}function ge(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function wl(t,e,n){let i=t??e;if(i!=="en"&&i!=="zh-CN")throw new Error(`${n} must be en or zh-CN`);return i}function yl(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>Fo)throw new Error(`${e} exceeds ${Fo} characters`);let n=0;for(let i=0;i<t.length;i+=1)t[i]==="?"?n+=1:t[i]==="*"&&(n+=1,t[i+1]==="*"&&(i+=1));if(n>Mo)throw new Error(`${e} contains more than ${Mo} wildcard tokens`);return t}function hl(t,e,n){if(t===void 0)return[...n];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(i=>yl(i,e)))].sort((i,r)=>i.localeCompare(r,"en"))}function Do(t,e,n){let i=t??e;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${n} must be a positive integer`);return i}function Fh(t){if(t===void 0)return{...he,include:[...he.include],exclude:[...he.exclude]};let e=ge(t,"native.snapshot");return{include:hl(e.include,"native.snapshot.include",he.include),exclude:hl(e.exclude,"native.snapshot.exclude",he.exclude),max_files:Do(e.max_files,he.max_files,"native.snapshot.max_files"),max_total_bytes:Do(e.max_total_bytes,he.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Do(e.max_duration_ms,he.max_duration_ms,"native.snapshot.max_duration_ms")}}function Mh(t){if(t===void 0)return;let e=ge(t,"native.pending_root_move"),n=e.id,i=e.from_artifact_root,r=e.to_artifact_root,o=e.stage;if(typeof n!="string"||!/^[a-f0-9-]{8,}$/u.test(n))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof r!="string")throw new Error("native.pending_root_move roots must be strings");if(o!=="copying"&&o!=="ready"&&o!=="switched")throw new Error("native.pending_root_move.stage is invalid");let s;if(e.cleanup!==void 0){let a=ge(e.cleanup,"native.pending_root_move.cleanup"),c=a.kind,l=a.state,f=a.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof f!="string"||!/^[a-f0-9]{64}$/u.test(f))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");s={kind:c,state:l,manifestHash:f}}return{id:n,fromArtifactRoot:ki(i),toArtifactRoot:ki(r),stage:o,...s?{cleanup:s}:{}}}function Bh(t){if(t===void 0)return;let e=ge(t,"native.finish");if(e.pull_request===void 0)return{};let n=ge(e.pull_request,"native.finish.pull_request");if(n.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(n.command)||n.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(n.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=n.command.map((o,s)=>{if(typeof o!="string"||o.trim().length===0||o.length>4096||/[\0\r\n]/u.test(o))throw new Error(`native.finish.pull_request.command[${s}] must be a non-empty single-line string of at most 4096 characters`);return o});if(Te.posix.isAbsolute(i[0])||Te.win32.isAbsolute(i[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let r=n.timeout_ms??$h;if(!Number.isSafeInteger(r)||r<1||r>ml)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${ml}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:r}}}function Kh(t,e={}){let n=ge(t,"native"),i=n.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let r=n.clarification_mode??"batch";if(r!=="sequential"&&r!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let o=n.archive_confirmation??"automatic";if(o!=="automatic"&&o!=="required")throw new Error("native.archive_confirmation must be automatic or required");let s=n.max_verify_failures??Th;if(!Number.isSafeInteger(s)||s<1)throw new Error("native.max_verify_failures must be a positive integer");let a=Mh(n.pending_root_move),c=Bh(n.finish);return{artifact_root:ki(i),language:wl(n.language,"en","native.language"),clarification_mode:r,archive_confirmation:o,max_verify_failures:s,snapshot:Fh(n.snapshot),...c?{finish:c}:{},...a?{pending_root_move:a}:{}}}function Hh(t){let e=ge(t,"classic"),n=e.context_compression??"off";if(n!=="off"&&n!=="beta")throw new Error("classic.context_compression must be off or beta");let i=e.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let r=e.auto_transition??!0;if(typeof r!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:gl(e.artifact_layout),language:wl(e.language,"zh-CN","classic.language"),context_compression:n,review_mode:i,auto_transition:r}}function Uh(t){let n=ge(t,"hook").allow_paths??[];if(!Array.isArray(n))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(n.map((i,r)=>we(i,`hook.allow_paths[${r}]`)))]}}function Yh(t){if(t===void 0)return{...Wo};let e=ge(t,"memory"),n=e.learning??Wo.learning,i=e.retrieval??Wo.retrieval;if(typeof n!="boolean")throw new Error("memory.learning must be true or false");if(typeof i!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:n,retrieval:i}}function Ko(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Jh(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||n.includes("\\")||n.includes("\0")||Te.posix.isAbsolute(n)||Te.win32.isAbsolute(n)||n.startsWith("~")||n.split("/").some(r=>r===""||r==="."||r===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!n.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(n.length>dl)throw new Error(`${e} exceeds ${dl} characters`);let i=0;for(let r=0;r<n.length;r+=1)n[r]==="?"?i+=1:n[r]==="*"&&(i+=1,n[r+1]==="*"&&(r+=1));if(i>pl)throw new Error(`${e} contains more than ${pl} wildcard tokens`);return n}function Vh(t){let n=Ko(t,"knowledge.local").include??[];if(!Array.isArray(n))throw new Error("knowledge.local.include must be an array");return{include:[...new Set(n.map((i,r)=>Jh(i,`knowledge.local.include[${r}]`)))]}}function Gh(t){if(typeof t!="string"||t.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(t)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let n=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=n==="localhost"||n==="127.0.0.1"||n==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function zh(t){let e=Ko(t,"knowledge.remote"),n=Gh(e.endpoint),i=e.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let r=e.scope;if(r!==void 0&&(typeof r!="string"||r.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let o=e.timeout_ms??5e3;if(typeof o!="number"||!Number.isSafeInteger(o)||o<100||o>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:n,...i===void 0?{}:{token_env:i},...r===void 0?{}:{scope:r},timeout_ms:o}}function Qh(t){if(t===void 0)return{...Ih};let e=Ko(t,"knowledge"),n=e.provider??"local";if(n!=="local"&&n!=="remote")throw new Error("knowledge.provider must be local or remote");let i=e.local===void 0?void 0:Vh(e.local);if(n==="local")return{provider:n,...i?{local:i}:{}};let r=e.remote===void 0?void 0:zh(e.remote);if(r===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:n,...i?{local:i}:{},remote:r}}function Xh(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function Zh(t,e,n,i,r,o,s,a){let c=t.schema!==void 0;if(!(c||t.default_workflow!==void 0||t.workflows!==void 0||!a.allowPartialProject&&t.native!==void 0)||a.allowPartialProject&&!c)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let f=t.workflows??[t.default_workflow];if(!Array.isArray(f)||f.length===0||f.some(d=>d!=="native"&&d!=="classic"))throw new Error("workflows must contain native and/or classic");let u=[...new Set(f)];if(!u.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(u.includes("native")&&!r)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:u,ambient_resume:s,...e?{hook:e}:{},memory:n,knowledge:i,...r?{native:r}:{},...o?{classic:o}:{}}}function wt(t,e={}){let n=(0,Bo.parseDocument)(t,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${n.errors[0].message}`);let i=n.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let r=i,o=Xh(r.ambient_resume),s=r.hook===void 0?void 0:Uh(r.hook),a=Yh(r.memory),c=Qh(r.knowledge),l=r.native===void 0?void 0:Kh(r.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),f=r.classic===void 0?void 0:Hh(r.classic),u=Zh(r,s,a,c,l,f,o,{allowPartialProject:e.allowPartialProject??!1});return{value:r,config:u,ambient_resume:o,memory:a,knowledge:c,...s?{hook:s}:{},...l?{native:l}:{},...f?{classic:f}:{}}}var Bo,sn,Fo,Mo,dl,pl,Th,Wo,Ih,$h,ml,qh,Lh,Wh,he,ye=$(()=>{"use strict";Bo=Pt(gt(),1),sn=64*1024,Fo=1024,Mo=64,dl=1024,pl=64,Th=5,Wo={learning:!0,retrieval:!0},Ih={provider:"local"},$h=12e4,ml=6e5,qh=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".devin/skills/**",".dsh/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".omp/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],Lh=["**/.idea/**","**/.vscode/**",".codex/skills/**","**/node_modules/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.svelte-kit/**","**/.vite/**","**/.parcel-cache/**","**/.turbo/**","**/.nx/cache/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.nyc_output/**","**/target/**","**/.gradle/**","**/.cxx/**","**/.externalNativeBuild/**","**/captures/**","**/__pycache__/**","**/.pytest_cache/**","**/.mypy_cache/**","**/.ruff_cache/**","**/.tox/**","**/.nox/**","**/.venv/**","**/venv/**","**/obj/**","**/CMakeFiles/**","**/cmake-build-*/**","**/.cache/**","**/tmp/**","**/temp/**","**/logs/**","**/*.tsbuildinfo","**/*.log","**/.DS_Store","**/Thumbs.db"],Wh=[...qh,...Lh].sort((t,e)=>t.localeCompare(e,"en")),he={include:["**/*"],exclude:[...Wh],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4}});function Ie(t){return t!==0&&t!==0n&&t!=="0"}function vl(t,e){return Ie(t.dev)&&Ie(e.dev)&&Ie(t.ino)&&Ie(e.ino)}function $e(t,e){let n=Ie(t.dev)&&Ie(e.dev);if(n&&t.dev!==e.dev)return!1;let i=Ie(t.ino)&&Ie(e.ino);return i&&t.ino!==e.ino?!1:n&&i?!0:t.birthtime===e.birthtime}var bi=$(()=>{"use strict"});import{constants as Si,promises as Ze}from"fs";function Ho(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function kl(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function an(t){return{dev:t.dev,ino:t.ino,birthtime:Ho(t)}}function Ci(t,e){let n=an(t),i=an(e);return vl(n,i)?$e(n,i):$e(n,i)&&Ho(t)===Ho(e)&&kl(t)===kl(e)&&t.size===e.size}async function bl(t,e,n={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let i=n.label??"file",r=n.bigint===!0,o=await Ze.lstat(t,{bigint:r});if(!o.isFile()||o.isSymbolicLink())throw new qe("not-regular-file",`${i} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new qe("too-large",`${i} exceeds ${e} bytes`);let s=await Ze.realpath(t);await n.verify?.("pre-open",{realPath:s,identity:an(o)});let a=process.platform==="win32"?Si.O_RDONLY:Si.O_RDONLY|Si.O_NOFOLLOW|Si.O_NONBLOCK,c;try{c=await Ze.open(t,a)}catch(l){throw l.code==="ELOOP"?new qe("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,f,u]=await Promise.all([c.stat({bigint:r}),Ze.lstat(t,{bigint:r}),Ze.realpath(t)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||u!==s||!Ci(o,l)||!Ci(o,f))throw new qe("changed",`${i} changed while opening`);await n.verify?.("post-open",{realPath:u,identity:an(l)}),await n.hooks?.afterOpen?.();let d=[],h=0,w=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let g=e+1-h,{bytesRead:b}=await c.read(w,0,Math.min(w.length,g),null);if(b===0)break;if(h+=b,h>e)throw new qe("too-large",`${i} exceeds ${e} bytes`);d.push(Buffer.from(w.subarray(0,b)))}await n.hooks?.beforeFinalCheck?.();let[p,m,y]=await Promise.all([c.stat({bigint:r}),Ze.lstat(t,{bigint:r}),Ze.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||y!==s||!Ci(o,p)||!Ci(o,m))throw new qe("changed",`${i} changed while reading`);return await n.verify?.("post-read",{realPath:y,identity:an(p)}),{bytes:Buffer.concat(d,h),stat:p,realPath:y}}finally{await c.close()}}var qe,Sl=$(()=>{"use strict";bi();qe=class extends Error{reason;constructor(e,n,i){super(n,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Le}from"fs";import ie from"path";function Cl(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Ei(t,e){let n=ie.relative(t,e);return n===""||!ie.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${ie.sep}`)}async function Uo(t,e){let n=ie.resolve(t),i=await Le.lstat(n);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Le.realpath(n)}async function Yo(t,e,n,i){let r=t;for(let o=0;o<n.length;o++){r=ie.join(r,n[o]);let s;try{s=await Le.lstat(r)}catch(f){if(Cl(f))return{exists:!1,kind:"missing"};throw f}let a=ie.relative(t,r).replaceAll("\\","/");if(s.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${a}`);let c=o===n.length-1;if(!c&&!s.isDirectory())throw new Error(`${i.label} ancestor ${a} must be a real directory`);if(c&&(i.expected==="file"&&!s.isFile()||i.expected==="directory"&&!s.isDirectory()||i.expected==="any"&&!s.isFile()&&!s.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let l=await Le.realpath(r);if(!Ei(e,l))throw new Error(`${i.label} resolves outside the project root`);if(c)return{exists:!0,kind:s.isFile()?"file":s.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function O(t,e,n){let i=we(e,n.label),r=ie.resolve(t),o=await Uo(r,n.label),s=i.split("/"),a=ie.resolve(r,...s);if(!Ei(r,a))throw new Error(`${n.label} must stay inside the project root`);let c=await Yo(r,o,s,n);return{projectRoot:r,target:a,relative:i,exists:c.exists,kind:c.kind}}async function Jo(t,e,n){let i=we(e,n.label),r=ie.resolve(t),o=await Uo(r,n.label),s=i.split("/"),a=r;for(let c of s){a=ie.join(a,c);let l;try{l=await Le.lstat(a)}catch(d){if(!Cl(d))throw d;try{await Le.mkdir(a)}catch(h){if(h.code!=="EEXIST")throw h}l=await Le.lstat(a)}let f=ie.relative(r,a).replaceAll("\\","/");if(l.isSymbolicLink())throw new Error(`${n.label} crosses a symbolic link or junction at ${f}`);if(!l.isDirectory())throw new Error(`${n.label} directory ${f} must be a real directory`);let u=await Le.realpath(a);if(!Ei(o,u))throw new Error(`${n.label} resolves outside the project root`)}return await Yo(r,o,s,{label:n.label,expected:"directory"}),a}async function _i(t,e,n){return(await O(t,e,{...n,expected:"file"})).exists}async function D(t,e,n,i){let r=await O(t,e,{label:i.label,expected:"file"});if(!r.exists){let s=new Error(`${i.label} does not exist`);throw s.code="ENOENT",s}let o=await Uo(r.projectRoot,i.label);return bl(r.target,n,{...i,verify:async(s,a)=>{if(!Ei(o,a.realPath))throw new Error(`${i.label} resolves outside the project root`);await Yo(r.projectRoot,o,r.relative.split("/"),{label:i.label,expected:"file"})}})}var X=$(()=>{"use strict";Sl();ye()});import{createHash as eg}from"crypto";function tg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function ln(t,e={}){return(await xi(t,e)).document}async function ng(t){try{return(await D(t,cn,sn,{label:cn})).bytes}catch(e){if(tg(e))return null;throw e}}function ig(t){return t?{exists:!0,sha256:eg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function xi(t,e={}){let n=await ng(t);return{document:n?wt(n.toString("utf8"),e):null,identity:ig(n)}}async function Vo(t){return(await ln(t))?.config??null}var cn,yt=$(()=>{"use strict";ye();X();cn=".comet/config.yaml"});import{randomUUID as rg}from"crypto";import{constants as og,promises as A}from"fs";import F from"path";async function Go(t,e){try{return await A.link(t,e),{linked:!0}}catch(n){let i=n.code;if(i!=="ENOTSUP"&&i!=="EOPNOTSUPP")throw n}return await A.copyFile(t,e,og.COPYFILE_EXCL),{linked:!1}}function et(t,e){let n=F.relative(t,e);return n===""||!F.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${F.sep}`)}function Pi(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function sg(t,e){return $e(t,Pi(e))}function Ri(t,e){return $e(Pi(t),Pi(e))}function El(t,e){return Ri(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Oi(t){let e=await A.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Contained atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await A.realpath(t),...Pi(e)}}async function ve(t){for(let e of t){let n=await A.lstat(e.path);if(!n.isDirectory()||n.isSymbolicLink()||!sg(e,n)||await A.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function ag(t,e,n){let[i,r]=await Promise.all([A.lstat(t),A.realpath(t),ve(n)]);if(!i.isFile()||i.isSymbolicLink()||!Ri(i,e)||!et(n[0].realPath,r))throw new Error("Contained atomic write temporary file changed after close");return i}async function cg(t,e){let n=F.resolve(t),i=F.resolve(e);if(!et(n,i))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let r=[await Oi(n)],o=F.relative(n,i).split(F.sep).filter(Boolean),s=n;for(let a of o){await ve(r),s=F.join(s,a);try{await A.mkdir(s)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Oi(s);if(!et(r[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${s}`);r.push(c)}return await ve(r),r}async function lg(t,e){let n=F.resolve(t),i=F.resolve(e);if(!et(n,i))throw new Error(`Contained file parent is outside its managed root: ${e}`);let r=[await Oi(n)],o=F.relative(n,i).split(F.sep).filter(Boolean),s=n;for(let a of o){s=F.join(s,a);try{let c=await Oi(s);if(!et(r[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${s}`);r.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await ve(r),r}async function _l(t){let e;try{e=await A.open(t,"r"),await e.sync()}catch(n){let i=n.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw n}finally{await e?.close()}}async function ug(t,e,n){let i=F.dirname(t),r=await cg(n.containedRoot,i),o=F.join(i,`.${F.basename(t)}.${rg()}.tmp`),s,a,c;try{await n.beforeTemporaryOpen?.(),s=await A.open(o,"wx"),a=await s.stat();let[l,f]=await Promise.all([A.lstat(o),A.realpath(o)]);if(await ve(r),!l.isFile()||l.isSymbolicLink()||!Ri(a,l)||!et(r[0].realPath,f))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await s.writeFile(e,"utf8"):await s.writeFile(e),await s.sync(),c=await s.stat(),!Ri(a,c))throw new Error("Contained atomic write temporary file changed while writing");if(await s.close(),s=void 0,await n.afterTemporaryClose?.(),!c)throw new Error("Contained atomic write temporary file was not written");c=await ag(o,c,r),await n.beforeCommit?.(),await ve(r);let u=await A.lstat(o);if(!u.isFile()||u.isSymbolicLink()||!c||!El(u,c))throw new Error("Contained atomic write temporary file changed before commit");n.exclusive?(await Go(o,t),await A.unlink(o)):await A.rename(o,t),await _l(i)}catch(l){await s?.close();try{await ve(r),await A.rm(o,{force:!0})}catch{}throw l}}async function Z(t,e,n){await ug(t,e,n)}async function zo(t,e){let n=F.dirname(t),i=await lg(e.containedRoot,n);if(!i)return!1;let r,o;try{r=await A.lstat(t),o=await A.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!r.isFile()||r.isSymbolicLink()||!et(i[0].realPath,o))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await ve(i);let[s,a]=await Promise.all([A.lstat(t),A.realpath(t)]);if(!s.isFile()||s.isSymbolicLink()||!El(r,s)||a!==o)throw new Error("Contained file removal target changed before removal");return await A.unlink(t),await ve(i),await _l(n),!0}var We=$(()=>{"use strict";bi()});var uk,Qo=$(()=>{"use strict";We();yt();X();uk=16*1024});var Zo=$(()=>{"use strict";We();ye();yt();X();Qo()});var qi=$(()=>{"use strict"});var Wl=$(()=>{"use strict"});var rs=$(()=>{"use strict";qi()});var Dl=$(()=>{"use strict";qi();rs()});var Fg,Fl=$(()=>{"use strict";Fg=Pt(gt(),1);We();ye();X()});var lb,Ml=$(()=>{"use strict";We();X();lb=4*1024*1024});function Bg(t,e){let n=t;for(let i of e)n+="\0"+(typeof i=="string"?i:JSON.stringify(i));return n}function Bl(t,e){return(...n)=>{let i=Mg;if(i===null)return e(...n);let r=Bg(`async:${t}`,n),o=i.entries.get(r);if(o)return o.value;let s=e(...n).catch(a=>{throw i.entries.delete(r),a});return i.entries.set(r,{value:s}),s}}var Mg,Kl=$(()=>{"use strict";Mg=null});var mb,Hl=$(()=>{"use strict";Kl();yt();mb=Bl("hookWritePolicy",async t=>(await Vo(t))?.hook??{allow_paths:[]})});var Ul=$(()=>{"use strict";qi();We();Wl();Dl();ye();Fl();X();yt();Zo();Ml();Hl();Qo();rs()});import{TextDecoder as Kg}from"util";function Yl(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Hg(t,e){try{return new Kg("utf-8",{fatal:!0}).decode(t.bytes)}catch(n){throw new Error(`${e} is not valid UTF-8`,{cause:n})}}async function os(t,e,n,i,r={}){try{let o=await D(t,e,n,{label:i,hooks:r.hooks});return{result:o,text:Hg(o,i)}}catch(o){let s=o.code;if(s==="ENOENT"||s==="ENOTDIR")return null;throw o}}async function be(t,e,n,i,r={}){return(await os(t,e,n,i,r))?.text??null}async function Fe(t,e,n,i,r,o={}){if(Buffer.byteLength(n,"utf8")>i)throw new Error(`${r} exceeds ${i} bytes`);let s=await os(t,e,i,r),a=await O(t,e,{label:r,expected:"file"});await Z(a.target,n,{containedRoot:a.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await os(t,e,i,r);if(!(!s&&!c)){if(!s||!c)throw new Error(`${r} changed before commit`);if(s.result.realPath!==c.result.realPath||!$e(Yl(s.result.stat),Yl(c.result.stat))||s.text!==c.text)throw new Error(`${r} changed before commit`)}}})}async function Jl(t,e,n,i,r,o={}){let s=await be(t,e,i,r);await Fe(t,e,`${s??""}${n}`,i,r,o)}async function Li(t,e,n,i={}){let r=await O(t,e,{label:n,expected:"file"});return r.exists?zo(r.target,{containedRoot:r.projectRoot,beforeRemove:i.beforeRemove}):!1}var ss=$(()=>{"use strict";Ul();bi()});var zl={};tf(zl,{RUN_STATE_FILE:()=>Di,applyRunStateToDocument:()=>as,readRunState:()=>cs,removeRunState:()=>ls,runStateFromDocument:()=>Wi,writeRunState:()=>Fi});import Ug from"path";function wn(t,e){let n=t[e];if(typeof n!="string"||n.length===0)throw new Error(`Invalid Run state: ${e} must be a non-empty string`);return n}function gn(t,e){let n=wn(t,e);if(Ug.isAbsolute(n)||/^(?:[A-Za-z]:|[\\/]|~)/u.test(n)||n.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Run state: ${e} must stay inside the change directory`);return n}function Yg(t){let e=t.run_retries??"{}",n;try{n=typeof e=="string"?JSON.parse(e):e}catch(i){throw new Error("Invalid Run state: run_retries must be a JSON object",{cause:i})}if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Invalid Run state: run_retries must be a JSON object");for(let i of Object.values(n))if(!Number.isInteger(i)||Number(i)<0)throw new Error("Invalid Run state: retry counts must be non-negative integers");return n}function Wi(t){if(!t.run_id)return null;let e=wn(t,"run_id"),n=wn(t,"skill"),i=wn(t,"skill_version"),r=wn(t,"skill_hash"),o=gn(t,"pending_ref"),s=gn(t,"trajectory_ref"),a=gn(t,"context_ref"),c=gn(t,"artifacts_ref"),l=gn(t,"checkpoint_ref"),f=Number(t.iteration);if(!Number.isInteger(f)||f<0)throw new Error("Invalid Run state: iteration must be a non-negative integer");if(t.orchestration!=="deterministic"&&t.orchestration!=="adaptive")throw new Error("Invalid Run state: orchestration must be deterministic or adaptive");if(t.run_status!=="running"&&t.run_status!=="waiting"&&t.run_status!=="completed"&&t.run_status!=="failed")throw new Error("Invalid Run state: run_status is invalid");return{runId:e,skill:n,skillVersion:i,skillHash:r,orchestration:t.orchestration,currentStep:Vl(t,"current_step"),iteration:f,pending:Vl(t,"pending"),pendingRef:o,trajectoryRef:s,contextRef:a,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:Yg(t)}}function as(t,e){e?t.run_id=e.runId:delete t.run_id}function Jg(t){return{runId:t.runId,skill:t.skill,skillVersion:t.skillVersion,skillHash:t.skillHash,orchestration:t.orchestration,currentStep:t.currentStep,iteration:t.iteration,pending:t.pending,pendingRef:t.pendingRef,trajectoryRef:t.trajectoryRef,contextRef:t.contextRef,artifactsRef:t.artifactsRef,checkpointRef:t.checkpointRef,status:t.status,retries:t.retries}}function Vg(t){let e={run_id:t.runId,skill:t.skill,skill_version:t.skillVersion,skill_hash:t.skillHash,orchestration:t.orchestration,current_step:t.currentStep,iteration:t.iteration,pending:t.pending,pending_ref:t.pendingRef,trajectory_ref:t.trajectoryRef,context_ref:t.contextRef,artifacts_ref:t.artifactsRef,checkpoint_ref:t.checkpointRef,run_status:t.status,run_retries:JSON.stringify(t.retries)};return Wi(e)}async function cs(t,e={}){let n=await be(t,Di,Gl,"Run state",e);if(n===null)return null;let i=JSON.parse(n);return Vg(i)}async function Fi(t,e,n={}){await Fe(t,Di,JSON.stringify(Jg(e),null,2),Gl,"Run state",n)}async function ls(t,e={}){await Li(t,Di,"Run state",e)}var Vl,Di,Gl,Mi=$(()=>{"use strict";ss();Vl=(t,e)=>{let n=t[e];return n==null?null:String(n)};Di=".comet/run-state.json",Gl=256*1024});var Ku=Pt(gt(),1);import{createHash as Fu}from"crypto";import{promises as Mu}from"fs";import Bu from"path";import Il from"path";import{promises as Ol}from"fs";import N from"path";import{promises as Nh}from"fs";async function on(t){try{return await Nh.access(t),!0}catch(e){if(jh(e))return!1;throw e}}function jh(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}ye();yt();Zo();X();var un=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Rl=".comet/config.yaml";function Al(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Nl(t){await O(t,Rl,{label:Rl,expected:"file"})}function Ai(t,e){let n=N.resolve(t),i=e==="docs"?N.join(n,"docs"):n,r=N.join(i,"openspec"),o=N.join(n,"docs","superpowers");return{projectRoot:n,artifactLayout:e,openSpecBase:i,openSpecRoot:r,changesDir:N.join(r,"changes"),archiveDir:N.join(r,"changes","archive"),specsDir:N.join(r,"specs"),superpowersRoot:o,superpowersSpecsDir:N.join(o,"specs"),superpowersPlansDir:N.join(o,"plans"),superpowersReportsDir:N.join(o,"reports")}}async function hg(t){await Nl(t);let e=await ln(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new un;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new un("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function gg(t,e){return Ai(t,e??await hg(t))}async function wg(t){try{return await Ol.lstat(t),!0}catch(e){if(Al(e))return!1;throw e}}async function yg(t,e){let n=await gg(t,e),i=n.artifactLayout==="legacy"?"docs":"legacy",r=Ai(t,i).openSpecRoot,[o,s]=await Promise.all([O(n.projectRoot,M(n.projectRoot,n.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),wg(r)]),a=o.exists;return{paths:n,configuredRootExists:a,alternateRoot:r,alternateRootExists:s,dualRoots:a&&s}}async function vg(t){let e=[t.openSpecRoot,t.changesDir,t.archiveDir,t.specsDir,t.superpowersRoot,t.superpowersSpecsDir,t.superpowersPlansDir,t.superpowersReportsDir];for(let n of e){let i=M(t.projectRoot,n);await O(t.projectRoot,i,{label:`Classic managed physical path ${i}`,expected:"directory"})}}async function De(t,e){let n=await yg(t,e);if(await vg(n.paths),!n.configuredRootExists){let i=M(n.paths.projectRoot,n.paths.openSpecRoot),r=M(n.paths.projectRoot,n.alternateRoot);throw new un(`Configured Classic OpenSpec root is missing: ${i} (alternate ${r} is ${n.alternateRootExists?"present":"missing"})`)}return n.paths}async function es(t,e){let n=N.join(N.resolve(t),".comet","classic-root-move.json");if(await on(n))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let i=await De(t,e);if(!await on(i.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${M(i.projectRoot,i.openSpecRoot)}`);return i}async function tt(t){let e=N.resolve(t),n=null;try{(await Ol.lstat(e)).isDirectory()||(e=N.dirname(e))}catch(i){if(!Al(i))throw i}for(;;){N.basename(e)==="openspec"&&(n=N.dirname(e));let i=N.join(e,".comet","config.yaml"),r=!1;if(await on(i))try{await Nl(e);let s=(await ln(e))?.value;r=!!s&&typeof s=="object"&&!Array.isArray(s)&&(s.schema==="comet.project.v1"||s.default_workflow!==void 0||s.native!==void 0)}catch{}if(r||await on(N.join(e,".git")))return e;let o=N.dirname(e);if(o===e)return n??N.resolve(t);e=o}}function M(t,e){return N.relative(N.resolve(t),e).replaceAll("\\","/")}We();ye();X();import fn from"path";var kg=2*1024*1024;function Ni(t,e,n){let i=fn.resolve(t),r=fn.isAbsolute(e)?fn.resolve(e):fn.resolve(i,e),o=fn.relative(i,r).replaceAll("\\","/");return{root:i,relative:we(o,n),target:r}}async function le(t,e,n){let i=Ni(t,e,n.label);return O(i.root,i.relative,n)}async function ji(t,e,n){return(await le(t,e,{label:n.label,expected:n.expected??"any"})).exists}async function ts(t,e,n,i){return await ji(t,e,{label:n,expected:"file"})?(await jl(t,e,{label:n,hooks:i})).byteLength>0:!1}async function vt(t,e,n){return(await jl(t,e,n)).toString("utf8")}async function jl(t,e,n){let i=Ni(t,e,n.label);return(await D(i.root,i.relative,n.maxBytes??kg,{label:n.label,hooks:n.hooks})).bytes}async function Ti(t,e,n){let i=Ni(t,e,n);return Jo(i.root,i.relative,{label:n})}async function Tl(t,e,n,i){let r=Ni(t,e,i.label);await O(r.root,r.relative,{label:i.label,expected:"file"}),await Z(r.target,n,{containedRoot:r.root,beforeTemporaryOpen:i.beforeTemporaryOpen,beforeCommit:i.beforeCommit,exclusive:i.exclusive})}function ns(t){return t?/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t)?t.includes("..")?"Change name cannot contain '..' (path traversal not allowed)":null:`Invalid change name: '${t}'
|
|
143
|
-
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function is(t){let e=ns(t);if(e)throw new Error(e)}function bg(t,e){return{label:M(t,e),directory:e}}async function Sg(t,e,n){let i=bg(t,e);if(!(await le(t,e,{label:n,expected:"directory"})).exists)return{change:i,exists:!1,stateExists:!1};let o=await le(t,Il.join(e,".comet.yaml"),{label:`${n} state`,expected:"file"});return{change:i,exists:!0,stateExists:o.exists}}async function $l(t,e=process.cwd()){is(t);let n=await De(e),i=await Sg(n.projectRoot,Il.join(n.changesDir,t),`Classic active change ${t}`);return{...i.change,exists:i.exists,stateExists:i.stateExists}}import{promises as Ou}from"fs";import G from"path";import{fileURLToPath as Au}from"url";import{promises as Eg}from"fs";import ke from"path";X();ye();import dn from"path";function Cg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function ql(t,e,n,i){let r=we(n,"Classic handoff artifact pointer");if((await O(t,r,{label:"Classic handoff artifact",expected:"file"})).exists)return null;let s=await De(t),a=`${M(t,s.changesDir)}/`,l=(s.artifactLayout==="docs"?[a,"openspec/changes/"]:[a]).find(g=>r.startsWith(g));if(!l)return null;let f=r.slice(l.length).split("/");if(f.length<4||f[1]!==".comet"||f.slice(2).some(g=>g.length===0))return null;let u=f[0];is(u);let d=f.slice(2),h=dn.resolve(e);if(dn.dirname(h)!==dn.resolve(s.archiveDir))return null;let w=dn.basename(h),p=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(w);if(w!==u&&p?.[1]!==u)return null;await O(t,M(t,h),{label:"Classic archived change directory",expected:"directory"});let m=dn.join(h,".comet",...d),y=M(t,m);try{return await D(t,y,i,{label:"Historical Classic archived handoff artifact"}),y}catch(g){if(Cg(g))return null;throw g}}X();var Ll=2*1024*1024;function pn(t,e){return ke.relative(t,e).split(ke.sep).join("/")}async function mn(t,e,n,i,r){if(!n)return{code:e,satisfied:!1};let o=n.replaceAll("\\","/");if(r)return{code:e,satisfied:!1,source:o,detail:`Classic layout is unsafe or unavailable: ${r instanceof Error?r.message:String(r)}`};try{if(i){let a=i.artifactLayout==="legacy"?"docs":"legacy",c=M(t,Ai(t,a).openSpecRoot);if((o===c||o.startsWith(`${c}/`))&&(await O(t,o,{label:`${e} artifact`,expected:"file"})).exists)return{code:e,satisfied:!1,source:o,detail:"standalone OpenSpec root is not a Comet artifact root"}}let s=await _i(t,o,{label:`${e} artifact`});return{code:e,satisfied:s,source:o,...s?{resolvedSource:o}:{}}}catch(s){return{code:e,satisfied:!1,source:o,detail:`unsafe artifact pointer outside the project or through a special path: ${s instanceof Error?s.message:String(s)}`}}}async function _g(t,e,n,i){try{i??=await De(t)}catch(o){return{code:"design.handoff",satisfied:!1,...n?{source:n.replaceAll("\\","/")}:{},detail:`Classic layout is unsafe or unavailable for handoff evidence: ${o instanceof Error?o.message:String(o)}`}}let r=await mn(t,"design.handoff",n,i);if(!n||r.satisfied||r.detail)return r;try{let o=await ql(t,e,n,Ll);return o?{...r,satisfied:!0,resolvedSource:o,detail:`resolved historical legacy pointer from archived change: ${o}`}:r}catch(o){return{...r,satisfied:!1,detail:`unsafe archived handoff fallback: ${o instanceof Error?o.message:String(o)}`}}}async function Ii(t,e,n){return mn(t,e,pn(t,n))}async function xg(t,e){let n=ke.join(e,"specs"),i;try{let s=pn(t,n);if(!(await O(t,s,{label:"OpenSpec delta-spec directory",expected:"directory"})).exists)return{code:"openspec.delta-spec",satisfied:!1};i=await Eg.readdir(n)}catch(s){return s.code==="ENOENT"?{code:"openspec.delta-spec",satisfied:!1}:{code:"openspec.delta-spec",satisfied:!1,detail:`unsafe delta-spec path: ${s instanceof Error?s.message:String(s)}`}}let r=i.map(s=>ke.join(n,s,"spec.md")),o=(await Promise.all(r.map(async s=>{try{return await _i(t,pn(t,s),{label:"OpenSpec delta spec"})?s:null}catch{return null}}))).filter(s=>s!==null);return{code:"openspec.delta-spec",satisfied:o.length>0,source:o[0]?pn(t,o[0]):void 0,detail:`${o.length} delta spec${o.length===1?"":"s"}`}}async function Pg(t,e){let n,i=pn(t,e);try{n=(await D(t,i,Ll,{label:"Classic tasks artifact"})).bytes.toString("utf8")}catch(s){return s.code==="ENOENT"?{code:"build.tasks-complete",satisfied:!1}:{code:"build.tasks-complete",satisfied:!1,source:i,detail:`unsafe tasks artifact: ${s instanceof Error?s.message:String(s)}`}}let r=[...n.matchAll(/^\s*[-*]\s+\[([ xX])\]\s+/gmu)],o=r.filter(s=>s[1].toLowerCase()==="x").length;return{code:"build.tasks-complete",satisfied:r.length>0&&o===r.length,source:i,detail:`${o} of ${r.length} tasks complete`}}function hn(t,e){return t.some(n=>n.code===e&&n.satisfied)}async function kt(t,e){let n=await tt(t),i=e.classic,r=ke.join(t,"proposal.md"),o=ke.join(t,"design.md"),s=ke.join(t,"tasks.md"),a=e.run?ke.resolve(t,e.run.checkpointRef):ke.join(t,".comet","checkpoint.json"),c,l;try{c=await De(n)}catch(d){l=d}let f=await Promise.all([Ii(n,"openspec.proposal",r),Ii(n,"openspec.design",o),Ii(n,"openspec.tasks",s),xg(n,t),mn(n,"design.document",i?.designDoc??null,c,l),mn(n,"build.plan",i?.plan??null,c,l),Pg(n,s),mn(n,"verification.report",i?.verificationReport??null,c,l),_g(n,t,i?.handoffContext??null,c),Ii(n,"run.checkpoint",a)]),u=f.find(d=>d.code==="design.handoff");return u&&!i?.handoffHash&&(u.satisfied=!1,u.detail="handoff hash is missing"),f.push({code:"archive.confirmed",satisfied:i?.archiveConfirmation==="confirmed"}),f}import{createHash as Mw,randomUUID as Bw}from"crypto";import{promises as ys}from"fs";import Se from"path";function Rg(t){return t.classicProfile??t.workflow}function Og(t){return!t.buildMode||!t.tddMode||!t.isolation||!t.verifyMode?!1:t.buildMode==="subagent-driven-development"?t.subagentDispatch==="confirmed":t.buildMode==="direct"?t.directOverride===!0:!0}function Ag(t){return t.buildMode==="direct"&&t.tddMode==="direct"&&t.isolation!==null&&t.verifyMode==="light"}function Ng(t,e,n){if(e.verifyResult==="fail")return t==="full"?"full.build.fix":`${t}.build.execute`;if(t==="full"){if(!hn(n,"build.plan"))return"full.build.plan";if(e.buildPause==="plan-ready")return"full.build.plan-ready";if(!Og(e))return"full.build.configure"}else if(!Ag(e))throw new Error(`${t} build configuration is incomplete`);return hn(n,"build.tasks-complete")?`${t}.build.complete`:`${t}.build.execute`}function jg(t,e,n){return e.verifyResult!=="pass"||!hn(n,"verification.report")?`${t}.verify.run`:`${t}.verify.branch`}function Tg(t,e){if(e.verifyResult!=="pass")throw new Error("archive requires verify_result=pass");return e.archiveConfirmation==="confirmed"?`${t}.archive.execute`:`${t}.archive.confirm`}function $i(t,e){let n=Rg(t);if(t.archived&&t.phase!=="archive")throw new Error("archived=true requires phase=archive");if(t.archived)return"completed";if(n!=="full"&&t.phase==="design")throw new Error(`${n} workflow cannot enter design`);switch(t.phase){case"open":return`${n}.open`;case"design":return hn(e,"design.handoff")?"full.design.document":"full.design.handoff";case"build":return Ng(n,t,e);case"verify":return jg(n,t,e);case"archive":return Tg(n,t)}}var Ui=Pt(gt(),1);We();X();import Hi from"path";Mi();var Ql=["full","hotfix","tweak"],nt=1,Gg=["open","design","build","verify","archive"],zg=["en","zh-CN"],Qg=["off","beta"],Xg=["subagent-driven-development","executing-plans","direct"],Zg=["plan-ready"],ew=["confirmed"],tw=["tdd","direct"],nw=["off","standard","thorough"],iw=["current","branch","worktree"],rw=["light","full"],ow=["pending","pass","fail"],sw=["pending","handled"],aw=["pending","confirmed"],Ki=["workflow","language","phase","context_compression","build_mode","build_pause","subagent_dispatch","tdd_mode","review_mode","isolation","bound_branch","verify_mode","auto_transition","base_ref","design_doc","plan","verify_result","verify_failures","verification_report","branch_status","created_at","verified_at","archive_confirmation","archived","direct_override","handoff_context","handoff_hash","classic_profile","classic_migration"],cw=["run_id"],lw=new Set([...Ki,...cw]),uw=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function Xl(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function bt(t,e){let n=t[e];if(n==null||n==="")return null;if(typeof n!="string")throw new Error(`Invalid Classic state: ${e} must be a string or null`);return n}function K(t,e,n,i=!0){let r=t[e];if(r==null||r===""){if(i)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof r!="string"||!n.includes(r))throw new Error(`Invalid Classic state: ${e} must be one of ${n.join(", ")}${i?" or null":""}`);return r}function us(t,e,n=!0){let i=t[e];if(i==null||i===""){if(n)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof i!="boolean")throw new Error(`Invalid Classic state: ${e} must be true or false`);return i}function fw(t,e,n=0){let i=t[e];if(i==null||i==="")return n;if(typeof i!="number"||!Number.isInteger(i)||i<0)throw new Error(`Invalid Classic state: ${e} must be a non-negative integer`);return i}function Bi(t,e){let n=bt(t,e);if(n===null)return null;if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(n)||n.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Classic state: ${e} must be a relative repository path`);return n}function dw(t,e){let n=bt(t,e);if(n!==null&&!/^[a-f0-9]{64}$/u.test(n))throw new Error(`Invalid Classic state: ${e} must be a sha256 hex digest`);return n}function pw(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==nt)throw new Error(`Invalid Classic state: classic_migration must be ${nt}`);return e}function mw(t){if(!Ki.some(n=>Xl(t,n)))return null;for(let n of uw)if(!Xl(t,n))return null;return{workflow:K(t,"workflow",Ql,!1),language:K(t,"language",zg),phase:K(t,"phase",Gg,!1),contextCompression:K(t,"context_compression",Qg),buildMode:K(t,"build_mode",Xg),buildPause:K(t,"build_pause",Zg),subagentDispatch:K(t,"subagent_dispatch",ew),tddMode:K(t,"tdd_mode",tw),reviewMode:K(t,"review_mode",nw),isolation:K(t,"isolation",iw),boundBranch:bt(t,"bound_branch"),verifyMode:K(t,"verify_mode",rw),autoTransition:us(t,"auto_transition"),baseRef:bt(t,"base_ref"),designDoc:Bi(t,"design_doc"),plan:Bi(t,"plan"),verifyResult:K(t,"verify_result",ow,!1),verifyFailures:fw(t,"verify_failures"),verificationReport:Bi(t,"verification_report"),branchStatus:K(t,"branch_status",sw),createdAt:bt(t,"created_at"),verifiedAt:bt(t,"verified_at"),archiveConfirmation:K(t,"archive_confirmation",aw),archived:us(t,"archived",!1),directOverride:us(t,"direct_override"),handoffContext:Bi(t,"handoff_context"),handoffHash:dw(t,"handoff_hash"),classicProfile:K(t,"classic_profile",Ql),classicMigration:pw(t)}}function fs(t,e){let n=e??null;if(n===null&&e===void 0&&t.run_id&&t.skill)try{n=Wi(t)}catch(i){let r=i instanceof Error?i.message:String(i);throw new Error(r.replace(/^Invalid Run state:/u,"Invalid Classic state:"),{cause:i})}return{classic:mw(t),run:n,unknownKeys:Object.keys(t).filter(i=>!lw.has(i))}}function Zl(t){return{workflow:t.workflow,language:t.language,phase:t.phase,context_compression:t.contextCompression,build_mode:t.buildMode,build_pause:t.buildPause,subagent_dispatch:t.subagentDispatch,tdd_mode:t.tddMode,review_mode:t.reviewMode,isolation:t.isolation,bound_branch:t.boundBranch,verify_mode:t.verifyMode,auto_transition:t.autoTransition,base_ref:t.baseRef,design_doc:t.designDoc,plan:t.plan,verify_result:t.verifyResult,verify_failures:t.verifyFailures,verification_report:t.verificationReport,branch_status:t.branchStatus,created_at:t.createdAt,verified_at:t.verifiedAt,archive_confirmation:t.archiveConfirmation,archived:t.archived,direct_override:t.directOverride,handoff_context:t.handoffContext,handoff_hash:t.handoffHash,classic_profile:t.classicProfile,classic_migration:t.classicMigration}}Mi();var hw=2*1024*1024;function yn(t){let e=t.toJS();if(e===null)return{};if(typeof e!="object"||Array.isArray(e))throw new Error("Invalid Classic state document: root must be a mapping");return e}function eu(t,e,n){t.get(e)!==n&&t.set(e,n)}function gw(t,e){if(e.classic)for(let[n,i]of Object.entries(Zl(e.classic)))eu(t,n,i);else for(let n of Ki)t.delete(n);as(t.toJS(),e.run),e.run?eu(t,"run_id",e.run.runId):t.delete("run_id")}function ww(t){let e=["skill","skill_version","skill_hash","orchestration","current_step","iteration","pending","pending_ref","trajectory_ref","context_ref","artifacts_ref","checkpoint_ref","run_status","run_retries"];for(let n of e)t.delete(n)}function yw(t){let e=!1;for(let n of["build_command","verify_command"])t.has(n)&&(t.delete(n),e=!0);return e}async function tu(t){let e;try{e=(await D(Hi.dirname(t),Hi.basename(t),hw,{label:"Classic state document"})).bytes.toString("utf8")}catch(i){if(i.code!=="ENOENT")throw i;return new Ui.Document({})}let n=(0,Ui.parseDocument)(e);if(n.errors.length>0)throw new Error(`Invalid Classic state document: ${n.errors[0].message}`);return yn(n),n}async function Me(t,e={}){let n=e.migrate!==!1,i=Hi.join(t,".comet.yaml"),r=await tu(i),o=yn(r),s=yw(r);s&&(o=yn(r));let a=await cs(t);if(!a&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(Mi(),zl));a=c(o),a&&n&&(await Fi(t,a),ww(r),s=!0)}return s&&n&&await Z(i,r.toString(),{containedRoot:t}),fs(yn(r),a)}async function it(t,e,n={}){let i=Hi.join(t,".comet.yaml"),r=await tu(i);gw(r,{...e,unknownKeys:e.unknownKeys??[]}),fs(yn(r),e.run??null),await Z(i,r.toString(),{containedRoot:t,beforeCommit:n.beforeCommit}),e.run?await Fi(t,e.run):await ls(t)}function nu(t,e,n){return{runId:e,skill:t.definition.metadata.name,skillVersion:t.definition.metadata.version,skillHash:n,orchestration:t.definition.orchestration.mode,currentStep:t.definition.orchestration.entry??null,iteration:0,pending:null,pendingRef:".comet/pending-action.json",trajectoryRef:".comet/trajectory.jsonl",contextRef:".comet/context.md",artifactsRef:".comet/artifacts.json",checkpointRef:".comet/checkpoint.json",status:"running",retries:{}}}ss();import Yi from"path";var ue={trajectory:8*1024*1024,artifacts:1024*1024,context:1024*1024,pendingAction:256*1024,checkpoint:256*1024};function re(t,e){if(Yi.isAbsolute(e))throw new Error("Run path must stay inside the change directory");let n=Yi.resolve(t),i=Yi.resolve(n,e);if(i!==n&&!i.startsWith(n+Yi.sep))throw new Error("Run path must stay inside the change directory")}async function St(t,e,n,i={}){re(t,e),await Jl(t,e,`${JSON.stringify(n)}
|
|
144
|
-
`,ue.trajectory,"Run trajectory",i)}async function vn(t,e,n={}){
|
|
145
|
-
`,ue.artifacts,"Run artifacts",i)}async function Vi(t,e,n,i={}){
|
|
146
|
-
`,ue.pendingAction,"Run pending action",i)}async function ps(t,e,n={}){
|
|
147
|
-
`,ue.checkpoint,"Run checkpoint",i)}async function
|
|
148
|
-
`}async function
|
|
149
|
-
`),await L.rename(o,r)}catch(s){if(await
|
|
150
|
-
`));let l=await Xi(a);if(l!==e)throw new Error(`calculated hash is ${l}`);return a}catch(r){throw new Error(`Skill snapshot is invalid or missing: ${e}`,{cause:r})}}async function xu(t){try{return await ys.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Pu(t){return Mw("sha256").update(t).digest("hex")}function Kw(t){return Pu(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}function Hw(t){return t.replaceAll(".","_").replaceAll("-","_")}async function Uw(t,e){let n=await tt(t),i=Object.fromEntries(e.filter(s=>s.satisfied&&s.source).map(s=>[Hw(s.code),s.source])),r=Se.join(t,"subagent-progress.md");await xu(r)&&(i.subagent_progress=Se.relative(n,r).split(Se.sep).join("/"));let o=e.find(s=>s.code==="design.handoff"&&s.satisfied);return o?.source&&(i.handoff_context=o.source),i}function Yw(t,e,n){return[{sequence:1,timestamp:n,type:"run_started",runId:t.runId,data:{skill:t.skill,skillVersion:t.skillVersion,skillHash:t.skillHash}},{sequence:2,timestamp:n,type:"state_migrated",runId:t.runId,data:{kind:"classic",migrationVersion:nt,profile:e,source:"pre-migration"}}]}async function Jw(t){await Promise.all(t.map(e=>ys.rm(e,{recursive:!0,force:!0})))}async function Ru(t,e){let n=await Me(t);if(!n.classic)throw new Error("Classic migration requires a legacy state projection");let i=n.classic,r=i.classicProfile??i.workflow;if(n.run){if(i.classicMigration!==nt)throw new Error("Classic Run exists without a supported classic_migration marker");if(n.run.skill!==e.skillPackage.definition.metadata.name)throw new Error(`Classic Run skill mismatch: expected ${e.skillPackage.definition.metadata.name}, got ${n.run.skill}`);if(await Xi(e.skillPackage)!==n.run.skillHash)return await ws(t,n.run.skillHash),{classic:i,run:n.run,evidence:await kt(t,n),migrated:!1,snapshotDir:Se.join(t,".comet","skill-snapshots",n.run.skillHash)};let d=await gs(e.skillPackage,t);return{classic:i,run:n.run,evidence:await kt(t,n),migrated:!1,snapshotDir:d.snapshotDir}}let o=await kt(t,n),s=$i(i,o);if(!e.skillPackage.definition.orchestration.steps?.some(u=>u.id===s))throw new Error(`Classic Skill package does not define resolved step: ${s}`);let a=await Xi(e.skillPackage),c=Se.join(t,".comet","skill-snapshots",a),l=await xu(c),f=[];try{let u=await gs(e.skillPackage,t),d=nu(e.skillPackage,e.runId?.()??Bw(),u.hash);d.currentStep=s,s==="completed"&&(d.status="completed");let h={...i,classicProfile:r,classicMigration:nt},w=await Uw(t,o),p=await tt(t),m=o.find(S=>S.code==="design.handoff"&&S.satisfied),y=null;m?.source&&(y=await vt(p,m.resolvedSource??m.source,{label:"Classic migration handoff context",hooks:e.handoffReadHooks}),await Vi(t,d.contextRef,y),f.push(Se.resolve(t,d.contextRef))),await Ji(t,d.artifactsRef,w),f.push(Se.resolve(t,d.artifactsRef));let g=(e.now?.()??new Date).toISOString(),b={runId:d.runId,stateVersion:1,trajectoryOffset:2,contextHash:y===null?null:Pu(y),artifactsHash:Kw(w),createdAt:g};await Gi(t,d.checkpointRef,b),f.push(Se.resolve(t,d.checkpointRef)),f.push(Se.resolve(t,d.trajectoryRef));for(let S of Yw(d,r,g))await St(t,d.trajectoryRef,S);return await it(t,{classic:h,run:d,unknownKeys:n.unknownKeys}),{classic:h,run:d,evidence:o,migrated:!0,snapshotDir:u.snapshotDir}}catch(u){throw await Jw(f),l||await ys.rm(c,{recursive:!0,force:!0}),u}}async function Vw(t){try{return(await Ou.stat(t)).isDirectory()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Zi(t){try{return(await Ou.stat(t)).isFile()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Gw(t){return await Vw(t)?await Zi(G.join(t,"skill.yaml"))?!0:await Zi(G.join(t,"SKILL.md"))&&await Zi(G.join(t,"comet","skill.yaml")):!1}function zw(t){return{root:t,packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-classic",version:"1",description:"Internal compatibility orchestration for classic Comet full, hotfix, and tweak workflows"},goal:{statement:"Advance or restore a classic Comet Run without changing the user command surface",inputs:[{name:"classic-state",description:"Validated ClassicState consistent with the Run projection",required:!0},{name:"evidence",description:"Structured evidence produced by the Classic Evidence collector",required:!0}],outputs:[{name:"run-state",description:"Atomically synchronized Classic and Run state",required:!0}],success:["Legacy fields and Run fields remain consistent","Every step invokes only a declared public Comet Skill","The completed state passes its completion eval"]},orchestration:{mode:"deterministic",entry:"full.open",steps:[{id:"full.open",action:{type:"invoke_skill",ref:"comet-open"},next:"full.design.handoff"},{id:"full.design.handoff",action:{type:"invoke_skill",ref:"comet-design"},next:"full.design.document"},{id:"full.design.document",action:{type:"invoke_skill",ref:"comet-design"},next:"full.build.plan"},{id:"full.build.plan",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.plan-ready"},{id:"full.build.plan-ready",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.configure"},{id:"full.build.configure",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.execute"},{id:"full.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.complete"},{id:"full.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"full.verify.run"},{id:"full.build.fix",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.execute"},{id:"full.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"full.verify.branch"},{id:"full.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"full.archive.confirm"},{id:"full.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"full.archive.execute"},{id:"full.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"hotfix.open",action:{type:"invoke_skill",ref:"comet-hotfix"},next:"hotfix.build.execute"},{id:"hotfix.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"hotfix.build.complete"},{id:"hotfix.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"hotfix.verify.run"},{id:"hotfix.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"hotfix.verify.branch"},{id:"hotfix.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"hotfix.archive.confirm"},{id:"hotfix.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"hotfix.archive.execute"},{id:"hotfix.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"tweak.open",action:{type:"invoke_skill",ref:"comet-tweak"},next:"tweak.build.execute"},{id:"tweak.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"tweak.build.complete"},{id:"tweak.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"tweak.verify.run"},{id:"tweak.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"tweak.verify.branch"},{id:"tweak.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"tweak.archive.confirm"},{id:"tweak.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"tweak.archive.execute"},{id:"tweak.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"completed",action:{type:"checkpoint"},completionEvals:["classic-completed"]}]},skills:[{id:"comet-open"},{id:"comet-design"},{id:"comet-build"},{id:"comet-verify"},{id:"comet-archive"},{id:"comet-hotfix"},{id:"comet-tweak"}],agents:[],tools:[]},guardrails:{allowedSkills:["comet-open","comet-design","comet-build","comet-verify","comet-archive","comet-hotfix","comet-tweak"],allowedAgents:[],allowedTools:[],maxIterations:500,maxRetriesPerAction:3,confirmationRequiredFor:[]},evals:[{id:"classic-completed",scope:"completion",type:"state_equals",field:"status",equals:"completed"}]}}async function Qw(){let t=G.dirname(Au(import.meta.url)),e=[process.env.COMET_RUNTIME_CLASSIC_ROOT,G.resolve(t,"..","runtime","classic"),G.resolve(t,"..","..","comet","runtime","classic"),G.resolve(t,"..","..","assets","skills","comet","runtime","classic"),G.resolve("assets","skills","comet","runtime","classic"),process.env.COMET_CLASSIC_SKILL_ROOT,G.resolve(t,"..","..","comet-classic"),G.resolve(t,"..","..","assets","skills","comet-classic"),G.resolve("assets","skills","comet-classic")].filter(n=>!!n);for(let n of e)if(await Gw(n))return n;return null}async function Xw(t){return await Zi(G.join(t,"skill.yaml"))?gu(t):hu(t)}async function Nu(t){let e=await Qw();return Ru(t,{skillPackage:e?await Xw(e):zw(G.dirname(Au(import.meta.url)))})}async function ju(t,e,n,i){let r=await Me(t);if(!r.classic||!r.run)throw new Error("Classic transition requires synchronized Classic and Run projections");let o=await kt(t,{classic:e,run:n,unknownKeys:r.unknownKeys}),s=$i(e,o),a={...n,currentStep:s,iteration:n.iteration+1,status:s==="completed"?"completed":"running"};await it(t,{classic:e,run:a,unknownKeys:r.unknownKeys});let c=await vn(t,a.trajectoryRef);return await St(t,a.trajectoryRef,{sequence:c.length+1,timestamp:new Date().toISOString(),type:"state_transitioned",runId:a.runId,data:{kind:"classic",fromStep:n.currentStep,toStep:s,...i}}),a}import{AsyncLocalStorage as Zw}from"async_hooks";import{promises as Tu}from"fs";import kn from"path";var vs=new Zw;function ey(t,e){let n=kn.relative(t,e);return n===""||!kn.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${kn.sep}`)}async function ty(t){let e=kn.resolve(t.invocationCwd??process.cwd()),n=kn.resolve(t.projectRoot??await tt(e)),[i,r]=await Promise.all([Tu.realpath(e),Tu.realpath(n)]);if(!ey(r,i))throw new Error(`Classic command invocation cwd is outside the discovered project: ${e}`);return{invocationCwd:e,projectRoot:n}}async function ny(t,e){let n=vs.getStore();if(n)return e(n);let i=await ty(t);return vs.run(i,()=>e(i))}function Iu(){let t=vs.getStore();if(!t)throw new Error("Classic command project context is unavailable");return t.projectRoot}function $u(t){return(e,n)=>ny(n,()=>t(e,n))}function ks(t){return t==="zh-CN"?"zh-CN":"en"}function iy(t,e,n){return t==="zh-CN"?n:e}function bs(t){let{name:e,locale:n}=t;return{summary:iy(n,`Handoff context for ${e} was written and recorded; the Build phase can resume from it.`,`需求 ${e} 的交接上下文已写入并记录,Build 阶段可据此继续。`)}}var ry="\x1B[32m",oy="\x1B[31m",sy="\x1B[33m",Cs="\x1B[0m";function He(t){return`${ry}${t}${Cs}`}function z(t){return`${oy}${t}${Cs}`}function qu(t){return`${sy}${t}${Cs}`}var B=class extends Error{constructor(n,i=1){super(n);this.exitCode=i}exitCode},Ss=class{stdout=[];stderr=[];envelope;toResult(e=0){return{exitCode:e,...this.stdout.length>0?{stdout:this.stdout.join(`
|
|
142
|
+
`,n)+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 n=wi(e),i=gt(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=wi(e),i=gt(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(i=>i.type==="newline"||i.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())}}};al.Parser=$o});var dl=v(rn=>{"use strict";var cl=So(),hh=Vt(),nn=Qt(),gh=vr(),wh=x(),yh=Io(),ll=qo();function ul(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new yh.LineCounter||null,prettyErrors:e}}function vh(t,e={}){let{lineCounter:n,prettyErrors:i}=ul(e),r=new ll.Parser(n?.addNewLine),o=new cl.Composer(e),s=Array.from(o.compose(r.parse(t)));if(i&&n)for(let a of s)a.errors.forEach(nn.prettifyError(t,n)),a.warnings.forEach(nn.prettifyError(t,n));return s.length>0?s:Object.assign([],{empty:!0},o.streamInfo())}function fl(t,e={}){let{lineCounter:n,prettyErrors:i}=ul(e),r=new ll.Parser(n?.addNewLine),o=new cl.Composer(e),s=null;for(let a of o.compose(r.parse(t),!0,t.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new nn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(s.errors.forEach(nn.prettifyError(t,n)),s.warnings.forEach(nn.prettifyError(t,n))),s}function kh(t,e,n){let i;typeof e=="function"?i=e:n===void 0&&e&&typeof e=="object"&&(n=e);let r=fl(t,n);if(!r)return null;if(r.warnings.forEach(o=>gh.warn(r.options.logLevel,o)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:i},n))}function bh(t,e,n){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let r=Math.round(n);n=r<1?void 0:r>8?{indent:8}:{indent:r}}if(t===void 0){let{keepUndefined:r}=n??e??{};if(!r)return}return wh.isDocument(t)&&!i?t.toString(n):new hh.Document(t,i,n).toString(n)}rn.parse=kh;rn.parseAllDocuments=vh;rn.parseDocument=fl;rn.stringify=bh});var wt=v(R=>{"use strict";var Sh=So(),Ch=Vt(),Eh=to(),Lo=Qt(),_h=jt(),Te=x(),xh=Re(),Ph=T(),Rh=Ae(),Oh=Ne(),Ah=hi(),Nh=jo(),jh=Io(),Th=qo(),vi=dl(),pl=Rt();R.Composer=Sh.Composer;R.Document=Ch.Document;R.Schema=Eh.Schema;R.YAMLError=Lo.YAMLError;R.YAMLParseError=Lo.YAMLParseError;R.YAMLWarning=Lo.YAMLWarning;R.Alias=_h.Alias;R.isAlias=Te.isAlias;R.isCollection=Te.isCollection;R.isDocument=Te.isDocument;R.isMap=Te.isMap;R.isNode=Te.isNode;R.isPair=Te.isPair;R.isScalar=Te.isScalar;R.isSeq=Te.isSeq;R.Pair=xh.Pair;R.Scalar=Ph.Scalar;R.YAMLMap=Rh.YAMLMap;R.YAMLSeq=Oh.YAMLSeq;R.CST=Ah;R.Lexer=Nh.Lexer;R.LineCounter=jh.LineCounter;R.Parser=Th.Parser;R.parse=vi.parse;R.parseAllDocuments=vi.parseAllDocuments;R.parseDocument=vi.parseDocument;R.stringify=vi.stringify;R.visit=pl.visit;R.visitAsync=pl.visitAsync});import Ie from"path";function Bh(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||Ie.posix.isAbsolute(n)||Ie.win32.isAbsolute(n)||/^(?:~|[\\/])/u.test(n))throw new Error(`${e} must be a project-relative path`);if(n===".")return[];let i=n.replaceAll("\\","/").split("/");if(i.some(r=>r===".."))throw new Error(`${e} must stay inside the project root`);if(i.some(r=>r===""||r==="."))throw new Error(`${e} must not contain empty or dot path segments`);return i}function ki(t){let e=Bh(t,"native.artifact_root");return e.length===0?".":e.join("/")}function yl(t,e="docs"){let n=t??e;if(n!=="legacy"&&n!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return n}function we(t,e,n=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim().replaceAll("\\","/");if(i.length===0||Ie.posix.isAbsolute(i)||Ie.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be relative to its declared path base`);let r=i.split("/");if(r.some(o=>o===".."))throw new Error(`${e} must stay inside its declared path base`);if(r.some(o=>o===""||o==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!n&&/[*?]/u.test(i))throw new Error(`${e} cannot contain wildcards`);return r.join("/")}function ge(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function vl(t,e,n){let i=t??e;if(i!=="en"&&i!=="zh-CN")throw new Error(`${n} must be en or zh-CN`);return i}function kl(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>Fo)throw new Error(`${e} exceeds ${Fo} characters`);let n=0;for(let i=0;i<t.length;i+=1)t[i]==="?"?n+=1:t[i]==="*"&&(n+=1,t[i+1]==="*"&&(i+=1));if(n>Mo)throw new Error(`${e} contains more than ${Mo} wildcard tokens`);return t}function wl(t,e,n){if(t===void 0)return[...n];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(i=>kl(i,e)))].sort((i,r)=>i.localeCompare(r,"en"))}function Do(t,e,n){let i=t??e;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${n} must be a positive integer`);return i}function Kh(t){if(t===void 0)return{...he,include:[...he.include],exclude:[...he.exclude]};let e=ge(t,"native.snapshot");return{include:wl(e.include,"native.snapshot.include",he.include),exclude:wl(e.exclude,"native.snapshot.exclude",he.exclude),max_files:Do(e.max_files,he.max_files,"native.snapshot.max_files"),max_total_bytes:Do(e.max_total_bytes,he.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Do(e.max_duration_ms,he.max_duration_ms,"native.snapshot.max_duration_ms")}}function Hh(t){if(t===void 0)return;let e=ge(t,"native.pending_root_move"),n=e.id,i=e.from_artifact_root,r=e.to_artifact_root,o=e.stage;if(typeof n!="string"||!/^[a-f0-9-]{8,}$/u.test(n))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof r!="string")throw new Error("native.pending_root_move roots must be strings");if(o!=="copying"&&o!=="ready"&&o!=="switched")throw new Error("native.pending_root_move.stage is invalid");let s;if(e.cleanup!==void 0){let a=ge(e.cleanup,"native.pending_root_move.cleanup"),c=a.kind,l=a.state,u=a.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");s={kind:c,state:l,manifestHash:u}}return{id:n,fromArtifactRoot:ki(i),toArtifactRoot:ki(r),stage:o,...s?{cleanup:s}:{}}}function Uh(t){if(t===void 0)return;let e=ge(t,"native.finish");if(e.pull_request===void 0)return{};let n=ge(e.pull_request,"native.finish.pull_request");if(n.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(n.command)||n.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(n.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=n.command.map((o,s)=>{if(typeof o!="string"||o.trim().length===0||o.length>4096||/[\0\r\n]/u.test(o))throw new Error(`native.finish.pull_request.command[${s}] must be a non-empty single-line string of at most 4096 characters`);return o});if(Ie.posix.isAbsolute(i[0])||Ie.win32.isAbsolute(i[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let r=n.timeout_ms??Wh;if(!Number.isSafeInteger(r)||r<1||r>gl)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${gl}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:r}}}function Yh(t,e={}){let n=ge(t,"native"),i=n.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let r=n.clarification_mode??"batch";if(r!=="sequential"&&r!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let o=n.archive_confirmation??"automatic";if(o!=="automatic"&&o!=="required")throw new Error("native.archive_confirmation must be automatic or required");let s=n.max_verify_failures??qh;if(!Number.isSafeInteger(s)||s<1)throw new Error("native.max_verify_failures must be a positive integer");let a=Hh(n.pending_root_move),c=Uh(n.finish);return{artifact_root:ki(i),language:vl(n.language,"en","native.language"),clarification_mode:r,archive_confirmation:o,max_verify_failures:s,snapshot:Kh(n.snapshot),...c?{finish:c}:{},...a?{pending_root_move:a}:{}}}function Jh(t){let e=ge(t,"classic"),n=e.context_compression??"off";if(n!=="off"&&n!=="beta")throw new Error("classic.context_compression must be off or beta");let i=e.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let r=e.auto_transition??!0;if(typeof r!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:yl(e.artifact_layout),language:vl(e.language,"zh-CN","classic.language"),context_compression:n,review_mode:i,auto_transition:r}}function Vh(t){let n=ge(t,"hook").allow_paths??[];if(!Array.isArray(n))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(n.map((i,r)=>we(i,`hook.allow_paths[${r}]`)))]}}function Gh(t){if(t===void 0)return{...Wo};let e=ge(t,"memory"),n=e.learning??Wo.learning,i=e.retrieval??Wo.retrieval;if(typeof n!="boolean")throw new Error("memory.learning must be true or false");if(typeof i!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:n,retrieval:i}}function Ko(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function zh(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||n.includes("\\")||n.includes("\0")||Ie.posix.isAbsolute(n)||Ie.win32.isAbsolute(n)||n.startsWith("~")||n.split("/").some(r=>r===""||r==="."||r===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!n.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(n.length>ml)throw new Error(`${e} exceeds ${ml} characters`);let i=0;for(let r=0;r<n.length;r+=1)n[r]==="?"?i+=1:n[r]==="*"&&(i+=1,n[r+1]==="*"&&(r+=1));if(i>hl)throw new Error(`${e} contains more than ${hl} wildcard tokens`);return n}function Qh(t){let n=Ko(t,"knowledge.local").include??[];if(!Array.isArray(n))throw new Error("knowledge.local.include must be an array");return{include:[...new Set(n.map((i,r)=>zh(i,`knowledge.local.include[${r}]`)))]}}function Xh(t){if(typeof t!="string"||t.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(t)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let n=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=n==="localhost"||n==="127.0.0.1"||n==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function Zh(t){let e=Ko(t,"knowledge.remote"),n=Xh(e.endpoint),i=e.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let r=e.scope;if(r!==void 0&&(typeof r!="string"||r.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let o=e.timeout_ms??5e3;if(typeof o!="number"||!Number.isSafeInteger(o)||o<100||o>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:n,...i===void 0?{}:{token_env:i},...r===void 0?{}:{scope:r},timeout_ms:o}}function eg(t){if(t===void 0)return{...Lh};let e=Ko(t,"knowledge"),n=e.provider??"local";if(n!=="local"&&n!=="remote")throw new Error("knowledge.provider must be local or remote");let i=e.local===void 0?void 0:Qh(e.local);if(n==="local")return{provider:n,...i?{local:i}:{}};let r=e.remote===void 0?void 0:Zh(e.remote);if(r===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:n,...i?{local:i}:{},remote:r}}function tg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function ng(t,e,n,i,r,o,s,a){let c=t.schema!==void 0;if(!(c||t.default_workflow!==void 0||t.workflows!==void 0||!a.allowPartialProject&&t.native!==void 0)||a.allowPartialProject&&!c)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let u=t.workflows??[t.default_workflow];if(!Array.isArray(u)||u.length===0||u.some(d=>d!=="native"&&d!=="classic"))throw new Error("workflows must contain native and/or classic");let f=[...new Set(u)];if(!f.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(f.includes("native")&&!r)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:f,ambient_resume:s,...e?{hook:e}:{},memory:n,knowledge:i,...r?{native:r}:{},...o?{classic:o}:{}}}function yt(t,e={}){let n=(0,Bo.parseDocument)(t,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${n.errors[0].message}`);let i=n.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let r=i,o=tg(r.ambient_resume),s=r.hook===void 0?void 0:Vh(r.hook),a=Gh(r.memory),c=eg(r.knowledge),l=r.native===void 0?void 0:Yh(r.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=r.classic===void 0?void 0:Jh(r.classic),f=ng(r,s,a,c,l,u,o,{allowPartialProject:e.allowPartialProject??!1});return{value:r,config:f,ambient_resume:o,memory:a,knowledge:c,...s?{hook:s}:{},...l?{native:l}:{},...u?{classic:u}:{}}}var Bo,sn,Fo,Mo,ml,hl,qh,Wo,Lh,Wh,gl,Dh,Fh,Mh,he,ye=$(()=>{"use strict";Bo=Pt(wt(),1),sn=64*1024,Fo=1024,Mo=64,ml=1024,hl=64,qh=5,Wo={learning:!0,retrieval:!0},Lh={provider:"local"},Wh=12e4,gl=6e5,Dh=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".devin/skills/**",".dsh/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".omp/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],Fh=["**/.idea/**","**/.vscode/**",".codex/skills/**","**/node_modules/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.svelte-kit/**","**/.vite/**","**/.parcel-cache/**","**/.turbo/**","**/.nx/cache/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.nyc_output/**","**/target/**","**/.gradle/**","**/.cxx/**","**/.externalNativeBuild/**","**/captures/**","**/__pycache__/**","**/.pytest_cache/**","**/.mypy_cache/**","**/.ruff_cache/**","**/.tox/**","**/.nox/**","**/.venv/**","**/venv/**","**/obj/**","**/CMakeFiles/**","**/cmake-build-*/**","**/.cache/**","**/tmp/**","**/temp/**","**/logs/**","**/*.tsbuildinfo","**/*.log","**/.DS_Store","**/Thumbs.db"],Mh=[...Dh,...Fh].sort((t,e)=>t.localeCompare(e,"en")),he={include:["**/*"],exclude:[...Mh],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4}});function $e(t){return t!==0&&t!==0n&&t!=="0"}function bl(t,e){return $e(t.dev)&&$e(e.dev)&&$e(t.ino)&&$e(e.ino)}function qe(t,e){let n=$e(t.dev)&&$e(e.dev);if(n&&t.dev!==e.dev)return!1;let i=$e(t.ino)&&$e(e.ino);return i&&t.ino!==e.ino?!1:n&&i?!0:t.birthtime===e.birthtime}var bi=$(()=>{"use strict"});import{constants as Si,promises as et}from"fs";function Ho(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Sl(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function an(t){return{dev:t.dev,ino:t.ino,birthtime:Ho(t)}}function Ci(t,e){let n=an(t),i=an(e);return bl(n,i)?qe(n,i):qe(n,i)&&Ho(t)===Ho(e)&&Sl(t)===Sl(e)&&t.size===e.size}async function Cl(t,e,n={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let i=n.label??"file",r=n.bigint===!0,o=await et.lstat(t,{bigint:r});if(!o.isFile()||o.isSymbolicLink())throw new Le("not-regular-file",`${i} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new Le("too-large",`${i} exceeds ${e} bytes`);let s=await et.realpath(t);await n.verify?.("pre-open",{realPath:s,identity:an(o)});let a=process.platform==="win32"?Si.O_RDONLY:Si.O_RDONLY|Si.O_NOFOLLOW|Si.O_NONBLOCK,c;try{c=await et.open(t,a)}catch(l){throw l.code==="ELOOP"?new Le("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,u,f]=await Promise.all([c.stat({bigint:r}),et.lstat(t,{bigint:r}),et.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||f!==s||!Ci(o,l)||!Ci(o,u))throw new Le("changed",`${i} changed while opening`);await n.verify?.("post-open",{realPath:f,identity:an(l)}),await n.hooks?.afterOpen?.();let d=[],h=0,g=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let y=e+1-h,{bytesRead:S}=await c.read(g,0,Math.min(g.length,y),null);if(S===0)break;if(h+=S,h>e)throw new Le("too-large",`${i} exceeds ${e} bytes`);d.push(Buffer.from(g.subarray(0,S)))}await n.hooks?.beforeFinalCheck?.();let[p,m,w]=await Promise.all([c.stat({bigint:r}),et.lstat(t,{bigint:r}),et.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||w!==s||!Ci(o,p)||!Ci(o,m))throw new Le("changed",`${i} changed while reading`);return await n.verify?.("post-read",{realPath:w,identity:an(p)}),{bytes:Buffer.concat(d,h),stat:p,realPath:w}}finally{await c.close()}}var Le,El=$(()=>{"use strict";bi();Le=class extends Error{reason;constructor(e,n,i){super(n,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as We}from"fs";import ne from"path";function _l(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Ei(t,e){let n=ne.relative(t,e);return n===""||!ne.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${ne.sep}`)}async function Uo(t,e){let n=ne.resolve(t),i=await We.lstat(n);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return We.realpath(n)}async function Yo(t,e,n,i){let r=t;for(let o=0;o<n.length;o++){r=ne.join(r,n[o]);let s;try{s=await We.lstat(r)}catch(u){if(_l(u))return{exists:!1,kind:"missing"};throw u}let a=ne.relative(t,r).replaceAll("\\","/");if(s.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${a}`);let c=o===n.length-1;if(!c&&!s.isDirectory())throw new Error(`${i.label} ancestor ${a} must be a real directory`);if(c&&(i.expected==="file"&&!s.isFile()||i.expected==="directory"&&!s.isDirectory()||i.expected==="any"&&!s.isFile()&&!s.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let l=await We.realpath(r);if(!Ei(e,l))throw new Error(`${i.label} resolves outside the project root`);if(c)return{exists:!0,kind:s.isFile()?"file":s.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function O(t,e,n){let i=we(e,n.label),r=ne.resolve(t),o=await Uo(r,n.label),s=i.split("/"),a=ne.resolve(r,...s);if(!Ei(r,a))throw new Error(`${n.label} must stay inside the project root`);let c=await Yo(r,o,s,n);return{projectRoot:r,target:a,relative:i,exists:c.exists,kind:c.kind}}async function Jo(t,e,n){let i=we(e,n.label),r=ne.resolve(t),o=await Uo(r,n.label),s=i.split("/"),a=r;for(let c of s){a=ne.join(a,c);let l;try{l=await We.lstat(a)}catch(d){if(!_l(d))throw d;try{await We.mkdir(a)}catch(h){if(h.code!=="EEXIST")throw h}l=await We.lstat(a)}let u=ne.relative(r,a).replaceAll("\\","/");if(l.isSymbolicLink())throw new Error(`${n.label} crosses a symbolic link or junction at ${u}`);if(!l.isDirectory())throw new Error(`${n.label} directory ${u} must be a real directory`);let f=await We.realpath(a);if(!Ei(o,f))throw new Error(`${n.label} resolves outside the project root`)}return await Yo(r,o,s,{label:n.label,expected:"directory"}),a}async function _i(t,e,n){return(await O(t,e,{...n,expected:"file"})).exists}async function D(t,e,n,i){let r=await O(t,e,{label:i.label,expected:"file"});if(!r.exists){let s=new Error(`${i.label} does not exist`);throw s.code="ENOENT",s}let o=await Uo(r.projectRoot,i.label);return Cl(r.target,n,{...i,verify:async(s,a)=>{if(!Ei(o,a.realPath))throw new Error(`${i.label} resolves outside the project root`);await Yo(r.projectRoot,o,r.relative.split("/"),{label:i.label,expected:"file"})}})}var Q=$(()=>{"use strict";El();ye()});import{createHash as ig}from"crypto";function rg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function ln(t,e={}){return(await xi(t,e)).document}async function og(t){try{return(await D(t,cn,sn,{label:cn})).bytes}catch(e){if(rg(e))return null;throw e}}function sg(t){return t?{exists:!0,sha256:ig("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function xi(t,e={}){let n=await og(t);return{document:n?yt(n.toString("utf8"),e):null,identity:sg(n)}}async function Vo(t){return(await ln(t))?.config??null}var cn,vt=$(()=>{"use strict";ye();Q();cn=".comet/config.yaml"});import{randomUUID as ag}from"crypto";import{constants as cg,promises as A}from"fs";import F from"path";async function Go(t,e){try{return await A.link(t,e),{linked:!0}}catch(n){let i=n.code;if(i!=="ENOTSUP"&&i!=="EOPNOTSUPP")throw n}return await A.copyFile(t,e,cg.COPYFILE_EXCL),{linked:!1}}function tt(t,e){let n=F.relative(t,e);return n===""||!F.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${F.sep}`)}function Pi(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function lg(t,e){return qe(t,Pi(e))}function Ri(t,e){return qe(Pi(t),Pi(e))}function xl(t,e){return Ri(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Oi(t){let e=await A.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Contained atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await A.realpath(t),...Pi(e)}}async function ve(t){for(let e of t){let n=await A.lstat(e.path);if(!n.isDirectory()||n.isSymbolicLink()||!lg(e,n)||await A.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function ug(t,e,n){let[i,r]=await Promise.all([A.lstat(t),A.realpath(t),ve(n)]);if(!i.isFile()||i.isSymbolicLink()||!Ri(i,e)||!tt(n[0].realPath,r))throw new Error("Contained atomic write temporary file changed after close");return i}async function fg(t,e){let n=F.resolve(t),i=F.resolve(e);if(!tt(n,i))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let r=[await Oi(n)],o=F.relative(n,i).split(F.sep).filter(Boolean),s=n;for(let a of o){await ve(r),s=F.join(s,a);try{await A.mkdir(s)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Oi(s);if(!tt(r[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${s}`);r.push(c)}return await ve(r),r}async function dg(t,e){let n=F.resolve(t),i=F.resolve(e);if(!tt(n,i))throw new Error(`Contained file parent is outside its managed root: ${e}`);let r=[await Oi(n)],o=F.relative(n,i).split(F.sep).filter(Boolean),s=n;for(let a of o){s=F.join(s,a);try{let c=await Oi(s);if(!tt(r[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${s}`);r.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await ve(r),r}async function Pl(t){let e;try{e=await A.open(t,"r"),await e.sync()}catch(n){let i=n.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw n}finally{await e?.close()}}async function pg(t,e,n){let i=F.dirname(t),r=await fg(n.containedRoot,i),o=F.join(i,`.${F.basename(t)}.${ag()}.tmp`),s,a,c;try{await n.beforeTemporaryOpen?.(),s=await A.open(o,"wx"),a=await s.stat();let[l,u]=await Promise.all([A.lstat(o),A.realpath(o)]);if(await ve(r),!l.isFile()||l.isSymbolicLink()||!Ri(a,l)||!tt(r[0].realPath,u))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await s.writeFile(e,"utf8"):await s.writeFile(e),await s.sync(),c=await s.stat(),!Ri(a,c))throw new Error("Contained atomic write temporary file changed while writing");if(await s.close(),s=void 0,await n.afterTemporaryClose?.(),!c)throw new Error("Contained atomic write temporary file was not written");c=await ug(o,c,r),await n.beforeCommit?.(),await ve(r);let f=await A.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!c||!xl(f,c))throw new Error("Contained atomic write temporary file changed before commit");n.exclusive?(await Go(o,t),await A.unlink(o)):await A.rename(o,t),await Pl(i)}catch(l){await s?.close();try{await ve(r),await A.rm(o,{force:!0})}catch{}throw l}}async function X(t,e,n){await pg(t,e,n)}async function zo(t,e){let n=F.dirname(t),i=await dg(e.containedRoot,n);if(!i)return!1;let r,o;try{r=await A.lstat(t),o=await A.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!r.isFile()||r.isSymbolicLink()||!tt(i[0].realPath,o))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await ve(i);let[s,a]=await Promise.all([A.lstat(t),A.realpath(t)]);if(!s.isFile()||s.isSymbolicLink()||!xl(r,s)||a!==o)throw new Error("Contained file removal target changed before removal");return await A.unlink(t),await ve(i),await Pl(n),!0}var De=$(()=>{"use strict";bi()});var pk,Qo=$(()=>{"use strict";De();vt();Q();pk=16*1024});var Zo=$(()=>{"use strict";De();ye();vt();Q();Qo()});var qi=$(()=>{"use strict"});var Fl=$(()=>{"use strict"});var rs=$(()=>{"use strict";qi()});var Ml=$(()=>{"use strict";qi();rs()});var Kg,Bl=$(()=>{"use strict";Kg=Pt(wt(),1);De();ye();Q()});var db,Kl=$(()=>{"use strict";De();Q();db=4*1024*1024});function Ug(t,e){let n=t;for(let i of e)n+="\0"+(typeof i=="string"?i:JSON.stringify(i));return n}function Hl(t,e){return(...n)=>{let i=Hg;if(i===null)return e(...n);let r=Ug(`async:${t}`,n),o=i.entries.get(r);if(o)return o.value;let s=e(...n).catch(a=>{throw i.entries.delete(r),a});return i.entries.set(r,{value:s}),s}}var Hg,Ul=$(()=>{"use strict";Hg=null});var wb,Yl=$(()=>{"use strict";Ul();vt();wb=Hl("hookWritePolicy",async t=>(await Vo(t))?.hook??{allow_paths:[]})});var Jl=$(()=>{"use strict";qi();De();Fl();Ml();ye();Bl();Q();vt();Zo();Kl();Yl();Qo();rs()});import{TextDecoder as Yg}from"util";function Vl(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Jg(t,e){try{return new Yg("utf-8",{fatal:!0}).decode(t.bytes)}catch(n){throw new Error(`${e} is not valid UTF-8`,{cause:n})}}async function os(t,e,n,i,r={}){try{let o=await D(t,e,n,{label:i,hooks:r.hooks});return{result:o,text:Jg(o,i)}}catch(o){let s=o.code;if(s==="ENOENT"||s==="ENOTDIR")return null;throw o}}async function be(t,e,n,i,r={}){return(await os(t,e,n,i,r))?.text??null}async function Me(t,e,n,i,r,o={}){if(Buffer.byteLength(n,"utf8")>i)throw new Error(`${r} exceeds ${i} bytes`);let s=await os(t,e,i,r),a=await O(t,e,{label:r,expected:"file"});await X(a.target,n,{containedRoot:a.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await os(t,e,i,r);if(!(!s&&!c)){if(!s||!c)throw new Error(`${r} changed before commit`);if(s.result.realPath!==c.result.realPath||!qe(Vl(s.result.stat),Vl(c.result.stat))||s.text!==c.text)throw new Error(`${r} changed before commit`)}}})}async function Gl(t,e,n,i,r,o={}){let s=await be(t,e,i,r);await Me(t,e,`${s??""}${n}`,i,r,o)}async function Li(t,e,n,i={}){let r=await O(t,e,{label:n,expected:"file"});return r.exists?zo(r.target,{containedRoot:r.projectRoot,beforeRemove:i.beforeRemove}):!1}var ss=$(()=>{"use strict";Jl();bi()});var Xl={};of(Xl,{RUN_STATE_FILE:()=>Di,applyRunStateToDocument:()=>as,readRunState:()=>cs,removeRunState:()=>ls,runStateFromDocument:()=>Wi,writeRunState:()=>Fi});import Vg from"path";function wn(t,e){let n=t[e];if(typeof n!="string"||n.length===0)throw new Error(`Invalid Run state: ${e} must be a non-empty string`);return n}function gn(t,e){let n=wn(t,e);if(Vg.isAbsolute(n)||/^(?:[A-Za-z]:|[\\/]|~)/u.test(n)||n.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Run state: ${e} must stay inside the change directory`);return n}function Gg(t){let e=t.run_retries??"{}",n;try{n=typeof e=="string"?JSON.parse(e):e}catch(i){throw new Error("Invalid Run state: run_retries must be a JSON object",{cause:i})}if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Invalid Run state: run_retries must be a JSON object");for(let i of Object.values(n))if(!Number.isInteger(i)||Number(i)<0)throw new Error("Invalid Run state: retry counts must be non-negative integers");return n}function Wi(t){if(!t.run_id)return null;let e=wn(t,"run_id"),n=wn(t,"skill"),i=wn(t,"skill_version"),r=wn(t,"skill_hash"),o=gn(t,"pending_ref"),s=gn(t,"trajectory_ref"),a=gn(t,"context_ref"),c=gn(t,"artifacts_ref"),l=gn(t,"checkpoint_ref"),u=Number(t.iteration);if(!Number.isInteger(u)||u<0)throw new Error("Invalid Run state: iteration must be a non-negative integer");if(t.orchestration!=="deterministic"&&t.orchestration!=="adaptive")throw new Error("Invalid Run state: orchestration must be deterministic or adaptive");if(t.run_status!=="running"&&t.run_status!=="waiting"&&t.run_status!=="completed"&&t.run_status!=="failed")throw new Error("Invalid Run state: run_status is invalid");return{runId:e,skill:n,skillVersion:i,skillHash:r,orchestration:t.orchestration,currentStep:zl(t,"current_step"),iteration:u,pending:zl(t,"pending"),pendingRef:o,trajectoryRef:s,contextRef:a,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:Gg(t)}}function as(t,e){e?t.run_id=e.runId:delete t.run_id}function zg(t){return{runId:t.runId,skill:t.skill,skillVersion:t.skillVersion,skillHash:t.skillHash,orchestration:t.orchestration,currentStep:t.currentStep,iteration:t.iteration,pending:t.pending,pendingRef:t.pendingRef,trajectoryRef:t.trajectoryRef,contextRef:t.contextRef,artifactsRef:t.artifactsRef,checkpointRef:t.checkpointRef,status:t.status,retries:t.retries}}function Qg(t){let e={run_id:t.runId,skill:t.skill,skill_version:t.skillVersion,skill_hash:t.skillHash,orchestration:t.orchestration,current_step:t.currentStep,iteration:t.iteration,pending:t.pending,pending_ref:t.pendingRef,trajectory_ref:t.trajectoryRef,context_ref:t.contextRef,artifacts_ref:t.artifactsRef,checkpoint_ref:t.checkpointRef,run_status:t.status,run_retries:JSON.stringify(t.retries)};return Wi(e)}async function cs(t,e={}){let n=await be(t,Di,Ql,"Run state",e);if(n===null)return null;let i=JSON.parse(n);return Qg(i)}async function Fi(t,e,n={}){await Me(t,Di,JSON.stringify(zg(e),null,2),Ql,"Run state",n)}async function ls(t,e={}){await Li(t,Di,"Run state",e)}var zl,Di,Ql,Mi=$(()=>{"use strict";ss();zl=(t,e)=>{let n=t[e];return n==null?null:String(n)};Di=".comet/run-state.json",Ql=256*1024});var Uu=Pt(wt(),1);import{createHash as Bu}from"crypto";import{promises as Ku}from"fs";import Hu from"path";import ql from"path";import{promises as Nl}from"fs";import N from"path";import{promises as Ih}from"fs";async function on(t){try{return await Ih.access(t),!0}catch(e){if($h(e))return!1;throw e}}function $h(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}ye();vt();Zo();Q();var un=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Al=".comet/config.yaml";function jl(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Tl(t){await O(t,Al,{label:Al,expected:"file"})}function Ai(t,e){let n=N.resolve(t),i=e==="docs"?N.join(n,"docs"):n,r=N.join(i,"openspec"),o=N.join(n,"docs","superpowers");return{projectRoot:n,artifactLayout:e,openSpecBase:i,openSpecRoot:r,changesDir:N.join(r,"changes"),archiveDir:N.join(r,"changes","archive"),specsDir:N.join(r,"specs"),superpowersRoot:o,superpowersSpecsDir:N.join(o,"specs"),superpowersPlansDir:N.join(o,"plans"),superpowersReportsDir:N.join(o,"reports")}}async function yg(t){await Tl(t);let e=await ln(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new un;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new un("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function vg(t,e){return Ai(t,e??await yg(t))}async function kg(t){try{return await Nl.lstat(t),!0}catch(e){if(jl(e))return!1;throw e}}async function bg(t,e){let n=await vg(t,e),i=n.artifactLayout==="legacy"?"docs":"legacy",r=Ai(t,i).openSpecRoot,[o,s]=await Promise.all([O(n.projectRoot,M(n.projectRoot,n.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),kg(r)]),a=o.exists;return{paths:n,configuredRootExists:a,alternateRoot:r,alternateRootExists:s,dualRoots:a&&s}}async function Sg(t){let e=[t.openSpecRoot,t.changesDir,t.archiveDir,t.specsDir,t.superpowersRoot,t.superpowersSpecsDir,t.superpowersPlansDir,t.superpowersReportsDir];for(let n of e){let i=M(t.projectRoot,n);await O(t.projectRoot,i,{label:`Classic managed physical path ${i}`,expected:"directory"})}}async function Fe(t,e){let n=await bg(t,e);if(await Sg(n.paths),!n.configuredRootExists){let i=M(n.paths.projectRoot,n.paths.openSpecRoot),r=M(n.paths.projectRoot,n.alternateRoot);throw new un(`Configured Classic OpenSpec root is missing: ${i} (alternate ${r} is ${n.alternateRootExists?"present":"missing"})`)}return n.paths}async function es(t,e){let n=N.join(N.resolve(t),".comet","classic-root-move.json");if(await on(n))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let i=await Fe(t,e);if(!await on(i.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${M(i.projectRoot,i.openSpecRoot)}`);return i}async function nt(t){let e=N.resolve(t),n=null;try{(await Nl.lstat(e)).isDirectory()||(e=N.dirname(e))}catch(i){if(!jl(i))throw i}for(;;){N.basename(e)==="openspec"&&(n=N.dirname(e));let i=N.join(e,".comet","config.yaml"),r=!1;if(await on(i))try{await Tl(e);let s=(await ln(e))?.value;r=!!s&&typeof s=="object"&&!Array.isArray(s)&&(s.schema==="comet.project.v1"||s.default_workflow!==void 0||s.native!==void 0)}catch{}if(r||await on(N.join(e,".git")))return e;let o=N.dirname(e);if(o===e)return n??N.resolve(t);e=o}}function M(t,e){return N.relative(N.resolve(t),e).replaceAll("\\","/")}De();ye();Q();import fn from"path";var Cg=2*1024*1024;function Ni(t,e,n){let i=fn.resolve(t),r=fn.isAbsolute(e)?fn.resolve(e):fn.resolve(i,e),o=fn.relative(i,r).replaceAll("\\","/");return{root:i,relative:we(o,n),target:r}}async function le(t,e,n){let i=Ni(t,e,n.label);return O(i.root,i.relative,n)}async function ji(t,e,n){return(await le(t,e,{label:n.label,expected:n.expected??"any"})).exists}async function ts(t,e,n,i){return await ji(t,e,{label:n,expected:"file"})?(await Il(t,e,{label:n,hooks:i})).byteLength>0:!1}async function kt(t,e,n){return(await Il(t,e,n)).toString("utf8")}async function Il(t,e,n){let i=Ni(t,e,n.label);return(await D(i.root,i.relative,n.maxBytes??Cg,{label:n.label,hooks:n.hooks})).bytes}async function Ti(t,e,n){let i=Ni(t,e,n);return Jo(i.root,i.relative,{label:n})}async function $l(t,e,n,i){let r=Ni(t,e,i.label);await O(r.root,r.relative,{label:i.label,expected:"file"}),await X(r.target,n,{containedRoot:r.root,beforeTemporaryOpen:i.beforeTemporaryOpen,beforeCommit:i.beforeCommit,exclusive:i.exclusive})}function ns(t){return t?/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t)?t.includes("..")?"Change name cannot contain '..' (path traversal not allowed)":null:`Invalid change name: '${t}'
|
|
143
|
+
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function is(t){let e=ns(t);if(e)throw new Error(e)}function Eg(t,e){return{label:M(t,e),directory:e}}async function _g(t,e,n){let i=Eg(t,e);if(!(await le(t,e,{label:n,expected:"directory"})).exists)return{change:i,exists:!1,stateExists:!1};let o=await le(t,ql.join(e,".comet.yaml"),{label:`${n} state`,expected:"file"});return{change:i,exists:!0,stateExists:o.exists}}async function Ll(t,e=process.cwd()){is(t);let n=await Fe(e),i=await _g(n.projectRoot,ql.join(n.changesDir,t),`Classic active change ${t}`);return{...i.change,exists:i.exists,stateExists:i.stateExists}}import{promises as Nu}from"fs";import G from"path";import{fileURLToPath as ju}from"url";import{promises as Pg}from"fs";import ke from"path";Q();ye();import dn from"path";function xg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Wl(t,e,n,i){let r=we(n,"Classic handoff artifact pointer");if((await O(t,r,{label:"Classic handoff artifact",expected:"file"})).exists)return null;let s=await Fe(t),a=`${M(t,s.changesDir)}/`,l=(s.artifactLayout==="docs"?[a,"openspec/changes/"]:[a]).find(y=>r.startsWith(y));if(!l)return null;let u=r.slice(l.length).split("/");if(u.length<4||u[1]!==".comet"||u.slice(2).some(y=>y.length===0))return null;let f=u[0];is(f);let d=u.slice(2),h=dn.resolve(e);if(dn.dirname(h)!==dn.resolve(s.archiveDir))return null;let g=dn.basename(h),p=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(g);if(g!==f&&p?.[1]!==f)return null;await O(t,M(t,h),{label:"Classic archived change directory",expected:"directory"});let m=dn.join(h,".comet",...d),w=M(t,m);try{return await D(t,w,i,{label:"Historical Classic archived handoff artifact"}),w}catch(y){if(xg(y))return null;throw y}}Q();var Dl=2*1024*1024;function pn(t,e){return ke.relative(t,e).split(ke.sep).join("/")}async function mn(t,e,n,i,r){if(!n)return{code:e,satisfied:!1};let o=n.replaceAll("\\","/");if(r)return{code:e,satisfied:!1,source:o,detail:`Classic layout is unsafe or unavailable: ${r instanceof Error?r.message:String(r)}`};try{if(i){let a=i.artifactLayout==="legacy"?"docs":"legacy",c=M(t,Ai(t,a).openSpecRoot);if((o===c||o.startsWith(`${c}/`))&&(await O(t,o,{label:`${e} artifact`,expected:"file"})).exists)return{code:e,satisfied:!1,source:o,detail:"standalone OpenSpec root is not a Comet artifact root"}}let s=await _i(t,o,{label:`${e} artifact`});return{code:e,satisfied:s,source:o,...s?{resolvedSource:o}:{}}}catch(s){return{code:e,satisfied:!1,source:o,detail:`unsafe artifact pointer outside the project or through a special path: ${s instanceof Error?s.message:String(s)}`}}}async function Rg(t,e,n,i){try{i??=await Fe(t)}catch(o){return{code:"design.handoff",satisfied:!1,...n?{source:n.replaceAll("\\","/")}:{},detail:`Classic layout is unsafe or unavailable for handoff evidence: ${o instanceof Error?o.message:String(o)}`}}let r=await mn(t,"design.handoff",n,i);if(!n||r.satisfied||r.detail)return r;try{let o=await Wl(t,e,n,Dl);return o?{...r,satisfied:!0,resolvedSource:o,detail:`resolved historical legacy pointer from archived change: ${o}`}:r}catch(o){return{...r,satisfied:!1,detail:`unsafe archived handoff fallback: ${o instanceof Error?o.message:String(o)}`}}}async function Ii(t,e,n){return mn(t,e,pn(t,n))}async function Og(t,e){let n=ke.join(e,"specs"),i;try{let s=pn(t,n);if(!(await O(t,s,{label:"OpenSpec delta-spec directory",expected:"directory"})).exists)return{code:"openspec.delta-spec",satisfied:!1};i=await Pg.readdir(n)}catch(s){return s.code==="ENOENT"?{code:"openspec.delta-spec",satisfied:!1}:{code:"openspec.delta-spec",satisfied:!1,detail:`unsafe delta-spec path: ${s instanceof Error?s.message:String(s)}`}}let r=i.map(s=>ke.join(n,s,"spec.md")),o=(await Promise.all(r.map(async s=>{try{return await _i(t,pn(t,s),{label:"OpenSpec delta spec"})?s:null}catch{return null}}))).filter(s=>s!==null);return{code:"openspec.delta-spec",satisfied:o.length>0,source:o[0]?pn(t,o[0]):void 0,detail:`${o.length} delta spec${o.length===1?"":"s"}`}}async function Ag(t,e){let n,i=pn(t,e);try{n=(await D(t,i,Dl,{label:"Classic tasks artifact"})).bytes.toString("utf8")}catch(s){return s.code==="ENOENT"?{code:"build.tasks-complete",satisfied:!1}:{code:"build.tasks-complete",satisfied:!1,source:i,detail:`unsafe tasks artifact: ${s instanceof Error?s.message:String(s)}`}}let r=[...n.matchAll(/^\s*[-*]\s+\[([ xX])\]\s+/gmu)],o=r.filter(s=>s[1].toLowerCase()==="x").length;return{code:"build.tasks-complete",satisfied:r.length>0&&o===r.length,source:i,detail:`${o} of ${r.length} tasks complete`}}function hn(t,e){return t.some(n=>n.code===e&&n.satisfied)}async function bt(t,e){let n=await nt(t),i=e.classic,r=ke.join(t,"proposal.md"),o=ke.join(t,"design.md"),s=ke.join(t,"tasks.md"),a=e.run?ke.resolve(t,e.run.checkpointRef):ke.join(t,".comet","checkpoint.json"),c,l;try{c=await Fe(n)}catch(d){l=d}let u=await Promise.all([Ii(n,"openspec.proposal",r),Ii(n,"openspec.design",o),Ii(n,"openspec.tasks",s),Og(n,t),mn(n,"design.document",i?.designDoc??null,c,l),mn(n,"build.plan",i?.plan??null,c,l),Ag(n,s),mn(n,"verification.report",i?.verificationReport??null,c,l),Rg(n,t,i?.handoffContext??null,c),Ii(n,"run.checkpoint",a)]),f=u.find(d=>d.code==="design.handoff");return f&&!i?.handoffHash&&(f.satisfied=!1,f.detail="handoff hash is missing"),u.push({code:"archive.confirmed",satisfied:i?.archiveConfirmation==="confirmed"}),u}import{createHash as Hw,randomUUID as Uw}from"crypto";import{promises as ys}from"fs";import Se from"path";function Ng(t){return t.classicProfile??t.workflow}function jg(t){return!t.buildMode||!t.tddMode||!t.isolation||!t.verifyMode?!1:t.buildMode==="subagent-driven-development"?t.subagentDispatch==="confirmed":t.buildMode==="direct"?t.directOverride===!0:!0}function Tg(t){return t.buildMode==="direct"&&t.tddMode==="direct"&&t.isolation!==null&&t.verifyMode==="light"}function Ig(t,e,n){if(e.verifyResult==="fail")return t==="full"?"full.build.fix":`${t}.build.execute`;if(t==="full"){if(!hn(n,"build.plan"))return"full.build.plan";if(e.buildPause==="plan-ready")return"full.build.plan-ready";if(!jg(e))return"full.build.configure"}else if(!Tg(e))throw new Error(`${t} build configuration is incomplete`);return hn(n,"build.tasks-complete")?`${t}.build.complete`:`${t}.build.execute`}function $g(t,e,n){return e.verifyResult!=="pass"||!hn(n,"verification.report")?`${t}.verify.run`:`${t}.verify.branch`}function qg(t,e){if(e.verifyResult!=="pass")throw new Error("archive requires verify_result=pass");return e.archiveConfirmation==="confirmed"?`${t}.archive.execute`:`${t}.archive.confirm`}function $i(t,e){let n=Ng(t);if(t.archived&&t.phase!=="archive")throw new Error("archived=true requires phase=archive");if(t.archived)return"completed";if(n!=="full"&&t.phase==="design")throw new Error(`${n} workflow cannot enter design`);switch(t.phase){case"open":return`${n}.open`;case"design":return hn(e,"design.handoff")?"full.design.document":"full.design.handoff";case"build":return Ig(n,t,e);case"verify":return $g(n,t,e);case"archive":return qg(n,t)}}var Ui=Pt(wt(),1);De();Q();import Hi from"path";Mi();var Zl=["full","hotfix","tweak"],it=1,Xg=["open","design","build","verify","archive"],Zg=["en","zh-CN"],ew=["off","beta"],tw=["subagent-driven-development","executing-plans","direct"],nw=["plan-ready"],iw=["confirmed"],rw=["tdd","direct"],ow=["off","standard","thorough"],sw=["current","branch","worktree"],aw=["light","full"],cw=["pending","pass","fail"],lw=["pending","handled"],uw=["pending","confirmed"],Ki=["workflow","language","phase","context_compression","build_mode","build_pause","subagent_dispatch","tdd_mode","review_mode","isolation","bound_branch","verify_mode","auto_transition","base_ref","design_doc","plan","verify_result","verify_failures","verification_report","branch_status","created_at","verified_at","archive_confirmation","archived","direct_override","handoff_context","handoff_hash","classic_profile","classic_migration"],fw=["run_id"],dw=new Set([...Ki,...fw]),pw=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function eu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function St(t,e){let n=t[e];if(n==null||n==="")return null;if(typeof n!="string")throw new Error(`Invalid Classic state: ${e} must be a string or null`);return n}function B(t,e,n,i=!0){let r=t[e];if(r==null||r===""){if(i)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof r!="string"||!n.includes(r))throw new Error(`Invalid Classic state: ${e} must be one of ${n.join(", ")}${i?" or null":""}`);return r}function us(t,e,n=!0){let i=t[e];if(i==null||i===""){if(n)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof i!="boolean")throw new Error(`Invalid Classic state: ${e} must be true or false`);return i}function mw(t,e,n=0){let i=t[e];if(i==null||i==="")return n;if(typeof i!="number"||!Number.isInteger(i)||i<0)throw new Error(`Invalid Classic state: ${e} must be a non-negative integer`);return i}function Bi(t,e){let n=St(t,e);if(n===null)return null;if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(n)||n.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Classic state: ${e} must be a relative repository path`);return n}function hw(t,e){let n=St(t,e);if(n!==null&&!/^[a-f0-9]{64}$/u.test(n))throw new Error(`Invalid Classic state: ${e} must be a sha256 hex digest`);return n}function gw(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==it)throw new Error(`Invalid Classic state: classic_migration must be ${it}`);return e}function ww(t){if(!Ki.some(n=>eu(t,n)))return null;for(let n of pw)if(!eu(t,n))return null;return{workflow:B(t,"workflow",Zl,!1),language:B(t,"language",Zg),phase:B(t,"phase",Xg,!1),contextCompression:B(t,"context_compression",ew),buildMode:B(t,"build_mode",tw),buildPause:B(t,"build_pause",nw),subagentDispatch:B(t,"subagent_dispatch",iw),tddMode:B(t,"tdd_mode",rw),reviewMode:B(t,"review_mode",ow),isolation:B(t,"isolation",sw),boundBranch:St(t,"bound_branch"),verifyMode:B(t,"verify_mode",aw),autoTransition:us(t,"auto_transition"),baseRef:St(t,"base_ref"),designDoc:Bi(t,"design_doc"),plan:Bi(t,"plan"),verifyResult:B(t,"verify_result",cw,!1),verifyFailures:mw(t,"verify_failures"),verificationReport:Bi(t,"verification_report"),branchStatus:B(t,"branch_status",lw),createdAt:St(t,"created_at"),verifiedAt:St(t,"verified_at"),archiveConfirmation:B(t,"archive_confirmation",uw),archived:us(t,"archived",!1),directOverride:us(t,"direct_override"),handoffContext:Bi(t,"handoff_context"),handoffHash:hw(t,"handoff_hash"),classicProfile:B(t,"classic_profile",Zl),classicMigration:gw(t)}}function fs(t,e){let n=e??null;if(n===null&&e===void 0&&t.run_id&&t.skill)try{n=Wi(t)}catch(i){let r=i instanceof Error?i.message:String(i);throw new Error(r.replace(/^Invalid Run state:/u,"Invalid Classic state:"),{cause:i})}return{classic:ww(t),run:n,unknownKeys:Object.keys(t).filter(i=>!dw.has(i))}}function tu(t){return{workflow:t.workflow,language:t.language,phase:t.phase,context_compression:t.contextCompression,build_mode:t.buildMode,build_pause:t.buildPause,subagent_dispatch:t.subagentDispatch,tdd_mode:t.tddMode,review_mode:t.reviewMode,isolation:t.isolation,bound_branch:t.boundBranch,verify_mode:t.verifyMode,auto_transition:t.autoTransition,base_ref:t.baseRef,design_doc:t.designDoc,plan:t.plan,verify_result:t.verifyResult,verify_failures:t.verifyFailures,verification_report:t.verificationReport,branch_status:t.branchStatus,created_at:t.createdAt,verified_at:t.verifiedAt,archive_confirmation:t.archiveConfirmation,archived:t.archived,direct_override:t.directOverride,handoff_context:t.handoffContext,handoff_hash:t.handoffHash,classic_profile:t.classicProfile,classic_migration:t.classicMigration}}Mi();var yw=2*1024*1024;function yn(t){let e=t.toJS();if(e===null)return{};if(typeof e!="object"||Array.isArray(e))throw new Error("Invalid Classic state document: root must be a mapping");return e}function nu(t,e,n){t.get(e)!==n&&t.set(e,n)}function vw(t,e){if(e.classic)for(let[n,i]of Object.entries(tu(e.classic)))nu(t,n,i);else for(let n of Ki)t.delete(n);as(t.toJS(),e.run),e.run?nu(t,"run_id",e.run.runId):t.delete("run_id")}function kw(t){let e=["skill","skill_version","skill_hash","orchestration","current_step","iteration","pending","pending_ref","trajectory_ref","context_ref","artifacts_ref","checkpoint_ref","run_status","run_retries"];for(let n of e)t.delete(n)}function bw(t){let e=!1;for(let n of["build_command","verify_command"])t.has(n)&&(t.delete(n),e=!0);return e}async function iu(t){let e;try{e=(await D(Hi.dirname(t),Hi.basename(t),yw,{label:"Classic state document"})).bytes.toString("utf8")}catch(i){if(i.code!=="ENOENT")throw i;return new Ui.Document({})}let n=(0,Ui.parseDocument)(e);if(n.errors.length>0)throw new Error(`Invalid Classic state document: ${n.errors[0].message}`);return yn(n),n}async function Be(t,e={}){let n=e.migrate!==!1,i=Hi.join(t,".comet.yaml"),r=await iu(i),o=yn(r),s=bw(r);s&&(o=yn(r));let a=await cs(t);if(!a&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(Mi(),Xl));a=c(o),a&&n&&(await Fi(t,a),kw(r),s=!0)}return s&&n&&await X(i,r.toString(),{containedRoot:t}),fs(yn(r),a)}async function rt(t,e,n={}){let i=Hi.join(t,".comet.yaml"),r=await iu(i);vw(r,{...e,unknownKeys:e.unknownKeys??[]}),fs(yn(r),e.run??null),await X(i,r.toString(),{containedRoot:t,beforeCommit:n.beforeCommit}),e.run?await Fi(t,e.run):await ls(t)}function ru(t,e,n){return{runId:e,skill:t.definition.metadata.name,skillVersion:t.definition.metadata.version,skillHash:n,orchestration:t.definition.orchestration.mode,currentStep:t.definition.orchestration.entry??null,iteration:0,pending:null,pendingRef:".comet/pending-action.json",trajectoryRef:".comet/trajectory.jsonl",contextRef:".comet/context.md",artifactsRef:".comet/artifacts.json",checkpointRef:".comet/checkpoint.json",status:"running",retries:{}}}ss();import Yi from"path";var ue={trajectory:8*1024*1024,artifacts:1024*1024,context:1024*1024,pendingAction:256*1024,checkpoint:256*1024};function ie(t,e){if(Yi.isAbsolute(e))throw new Error("Run path must stay inside the change directory");let n=Yi.resolve(t),i=Yi.resolve(n,e);if(i!==n&&!i.startsWith(n+Yi.sep))throw new Error("Run path must stay inside the change directory")}async function Ct(t,e,n,i={}){ie(t,e),await Gl(t,e,`${JSON.stringify(n)}
|
|
144
|
+
`,ue.trajectory,"Run trajectory",i)}async function vn(t,e,n={}){ie(t,e);let i=await be(t,e,ue.trajectory,"Run trajectory",n);return i===null?[]:i.split(/\r?\n/).map((r,o)=>({line:r,number:o+1})).filter(({line:r})=>r.length>0).map(({line:r,number:o})=>{try{return JSON.parse(r)}catch(s){throw new Error(`Invalid Trajectory event at line ${o}`,{cause:s})}})}async function ds(t,e,n={}){ie(t,e);let i=await be(t,e,ue.artifacts,"Run artifacts",n);return i===null?{}:JSON.parse(i)}async function Ji(t,e,n,i={}){ie(t,e),await Me(t,e,JSON.stringify(n,null,2)+`
|
|
145
|
+
`,ue.artifacts,"Run artifacts",i)}async function Vi(t,e,n,i={}){ie(t,e),await Me(t,e,n,ue.context,"Run context",i)}async function ou(t,e,n={}){return ie(t,e),be(t,e,ue.context,"Run context",n)}async function su(t,e,n,i={}){ie(t,e),await Me(t,e,JSON.stringify(n,null,2)+`
|
|
146
|
+
`,ue.pendingAction,"Run pending action",i)}async function ps(t,e,n={}){ie(t,e);let i=await be(t,e,ue.pendingAction,"Run pending action",n);return i===null?null:JSON.parse(i)}async function au(t,e,n={}){ie(t,e),await Li(t,e,"Run pending action",n)}async function Gi(t,e,n,i={}){ie(t,e),await Me(t,e,JSON.stringify(n,null,2)+`
|
|
147
|
+
`,ue.checkpoint,"Run checkpoint",i)}async function cu(t,e,n={}){ie(t,e);let i=await be(t,e,ue.checkpoint,"Run checkpoint",n);return i===null?null:JSON.parse(i)}import{createHash as Su,randomUUID as Dw}from"crypto";import{promises as L}from"fs";import I from"path";var fu=Pt(wt(),1);import{promises as ms}from"fs";import Z from"path";var Sw=["invoke_skill","call_tool","handoff","ask_user","checkpoint"],Cw=["deterministic","adaptive"],Ew=["function","mcp","script","agent"],_w=["none","read","write","external"],xw=["progress","step","completion"],Pw=["artifact_exists","state_equals"];function ot(t,e,n){return new Error(`${t}: ${e} ${n}`)}function Y(t,e,n="document"){if(t===null||typeof t!="object"||Array.isArray(t))throw ot(e,n,"must be an object")}function Ke(t,e,n){if(!Array.isArray(t))throw ot(e,n,"must be an array")}function K(t,e,n){if(typeof t!="string")throw ot(e,n,"must be a string")}function re(t,e,n,i){e in t&&K(t[e],n,`${i}.${e}`)}function du(t,e,n,i){if(e in t&&typeof t[e]!="boolean")throw ot(n,`${i}.${e}`,"must be a boolean")}function He(t,e,n,i){if(typeof t!="string"||!e.includes(t))throw ot(n,i,`must be one of ${e.join(", ")}`)}function zi(t,e,n){Ke(t,e,n),t.forEach((i,r)=>{K(i,e,`${n}[${r}]`)})}function lu(t,e,n){Y(t,e,n),K(t.name,e,`${n}.name`),K(t.description,e,`${n}.description`),du(t,"required",e,n)}function Rw(t,e,n){Y(t,e,n),K(t.id,e,`${n}.id`),re(t,"source",e,n),re(t,"version",e,n)}function Ow(t,e,n){Y(t,e,n),K(t.id,e,`${n}.id`),K(t.role,e,`${n}.role`),re(t,"instructions",e,n)}function Aw(t,e,n){Y(t,e,n),K(t.id,e,`${n}.id`),He(t.kind,Ew,e,`${n}.kind`),K(t.source,e,`${n}.source`),He(t.sideEffect,_w,e,`${n}.sideEffect`),du(t,"requiresConfirmation",e,n)}function Nw(t,e,n){Y(t,e,n),He(t.type,Sw,e,`${n}.type`),re(t,"ref",e,n),re(t,"prompt",e,n),re(t,"question",e,n),"options"in t&&zi(t.options,e,`${n}.options`)}function jw(t,e,n){Y(t,e,n),K(t.id,e,`${n}.id`),Nw(t.action,e,`${n}.action`),re(t,"next",e,n),"completionEvals"in t&&zi(t.completionEvals,e,`${n}.completionEvals`)}function Tw(t,e){let n="goal";Y(t,e,n),K(t.statement,e,`${n}.statement`),Ke(t.inputs,e,`${n}.inputs`),t.inputs.forEach((i,r)=>{lu(i,e,`${n}.inputs[${r}]`)}),Ke(t.outputs,e,`${n}.outputs`),t.outputs.forEach((i,r)=>{lu(i,e,`${n}.outputs[${r}]`)}),zi(t.success,e,`${n}.success`)}function Iw(t,e){let n="orchestration";Y(t,e,n),He(t.mode,Cw,e,`${n}.mode`),re(t,"entry",e,n),"steps"in t&&(Ke(t.steps,e,`${n}.steps`),t.steps.forEach((i,r)=>{jw(i,e,`${n}.steps[${r}]`)}))}function pu(t,e){return Y(t,e),He(t.apiVersion,["comet/v1alpha1"],e,"apiVersion"),He(t.kind,["Skill"],e,"kind"),Y(t.metadata,e,"metadata"),K(t.metadata.name,e,"metadata.name"),K(t.metadata.version,e,"metadata.version"),K(t.metadata.description,e,"metadata.description"),Tw(t.goal,e),Iw(t.orchestration,e),Ke(t.skills,e,"skills"),t.skills.forEach((n,i)=>{Rw(n,e,`skills[${i}]`)}),Ke(t.agents,e,"agents"),t.agents.forEach((n,i)=>{Ow(n,e,`agents[${i}]`)}),Ke(t.tools,e,"tools"),t.tools.forEach((n,i)=>{Aw(n,e,`tools[${i}]`)}),t}function mu(t,e){Y(t,e);for(let n of["allowedSkills","allowedAgents","allowedTools","confirmationRequiredFor"])n in t&&zi(t[n],e,n);for(let n of["maxIterations","maxRetriesPerAction"])if(n in t&&(typeof t[n]!="number"||!Number.isFinite(t[n])))throw ot(e,n,"must be a finite number");return t}function $w(t,e){return Y(t,e),"runtime"in t&&hu(t.runtime,e,"runtime"),t}function hu(t,e,n){return Ke(t,e,n),t.forEach((i,r)=>{let o=`${n}[${r}]`;Y(i,e,o),K(i.id,e,`${o}.id`),He(i.scope,xw,e,`${o}.scope`),He(i.type,Pw,e,`${o}.type`),re(i,"artifact",e,o),re(i,"field",e,o),re(i,"equals",e,o)}),t}async function hs(t){let e=await ms.readFile(t,"utf8");try{return(0,fu.parse)(e)}catch(n){let i=n instanceof Error?n.message:String(n);throw ot(t,"document",i)}}async function qw(t){try{return await hs(t)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function uu(t){try{return await ms.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Lw(t){let e=Z.join(t,"checks.yaml"),n=Z.join(t,"evals.yaml"),[i,r]=await Promise.all([uu(e),uu(n)]);if(r)throw new Error(`${n}: evals.yaml is no longer supported; use checks.yaml`);return i?{document:$w(await hs(e),e)}:{document:null}}async function gu(t){let e=Z.resolve(t.root),n=Z.resolve(t.controlRoot);t.requireSkillMarkdown&&await ms.access(Z.join(e,"SKILL.md"));let i=Z.join(n,"skill.yaml"),r=Z.join(n,"guardrails.yaml"),o=pu(await hs(i),i),s=await qw(r),a=s===null?null:mu(s,r),c=await Lw(n),l={allowedSkills:o.skills.map(u=>u.id),allowedAgents:o.agents.map(u=>u.id),allowedTools:o.tools.map(u=>u.id),maxIterations:50,maxRetriesPerAction:3,confirmationRequiredFor:o.tools.filter(u=>u.requiresConfirmation).map(u=>u.id)};return{root:e,packageKind:t.packageKind==="runtime"?"runtime":void 0,definition:o,guardrails:{...l,...a},evals:c.document?.runtime??[]}}async function wu(t){let e=Z.resolve(t);return gu({root:e,controlRoot:Z.join(e,"comet"),packageKind:"skill",requireSkillMarkdown:!0})}async function yu(t){let e=Z.resolve(t);return gu({root:e,controlRoot:e,packageKind:"runtime",requireSkillMarkdown:!1})}function vu(t,e,n=Z.join(e,"package.json")){Y(t,n);let i=t.packageKind==="runtime"?"runtime":void 0,r=pu(t.definition,n),o=mu(t.guardrails,n),s=hu(t.evals,n,"evals"),a={allowedSkills:r.skills.map(c=>c.id),allowedAgents:r.agents.map(c=>c.id),allowedTools:r.tools.map(c=>c.id),maxIterations:50,maxRetriesPerAction:3,confirmationRequiredFor:r.tools.filter(c=>c.requiresConfirmation).map(c=>c.id)};return{root:Z.resolve(e),packageKind:i,definition:r,guardrails:{...a,...o},evals:s}}import ku from"path";function Ww(t,e,n,i){t.type==="invoke_skill"&&!e.definition.skills.some(r=>r.id===t.ref)&&n.push(`step ${i} references undeclared skill: ${t.ref??"(missing)"}`),t.type==="call_tool"&&!e.definition.tools.some(r=>r.id===t.ref)&&n.push(`step ${i} references undeclared tool: ${t.ref??"(missing)"}`),t.type==="handoff"&&!e.definition.agents.some(r=>r.id===t.ref)&&n.push(`step ${i} references undeclared agent: ${t.ref??"(missing)"}`),t.type==="ask_user"&&!t.question&&n.push(`step ${i} ask_user action requires question`)}function bu(t){let e=[],{definition:n,guardrails:i,evals:r}=t;n.apiVersion!=="comet/v1alpha1"&&e.push("unsupported apiVersion"),n.kind!=="Skill"&&e.push("kind must be Skill"),n.metadata.name||e.push("metadata.name is required"),n.goal.statement||e.push("goal.statement is required"),i.maxIterations<1&&e.push("maxIterations must be at least 1"),i.maxRetriesPerAction<0&&e.push("maxRetriesPerAction must not be negative");let o=n.orchestration.steps??[];if(n.orchestration.mode==="adaptive")(n.orchestration.entry||o.length>0)&&e.push("adaptive orchestration must not define entry or steps");else{let s=new Set;for(let a of o)s.has(a.id)&&e.push(`duplicate step id: ${a.id}`),s.add(a.id),Ww(a.action,t,e,a.id);(!n.orchestration.entry||!s.has(n.orchestration.entry))&&e.push(`orchestration.entry references unknown step: ${n.orchestration.entry??"(missing)"}`);for(let a of o){a.next&&!s.has(a.next)&&e.push(`step ${a.id} has unknown next step: ${a.next}`);for(let c of a.completionEvals??[])r.some(l=>l.id===c)||e.push(`step ${a.id} references unknown eval: ${c}`)}}for(let s of n.tools){if(s.kind!=="script")continue;let a=ku.posix.normalize(s.source.replaceAll("\\","/"));(ku.isAbsolute(s.source)||a===".."||a.startsWith("../"))&&e.push(`script tool ${s.id} must reference a relative path inside the Skill package`)}for(let s of i.allowedSkills)n.skills.some(a=>a.id===s)||e.push(`guardrails allow undeclared skill: ${s}`);for(let s of i.allowedAgents)n.agents.some(a=>a.id===s)||e.push(`guardrails allow undeclared agent: ${s}`);for(let s of i.allowedTools)n.tools.some(a=>a.id===s)||e.push(`guardrails allow undeclared tool: ${s}`);return e}function Qi(t){return Array.isArray(t)?t.map(Qi):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,Qi(n)])):t}function Fw(t){return Qi({...t.packageKind==="runtime"?{packageKind:"runtime"}:{},definition:t.definition,guardrails:t.guardrails,evals:t.evals})}function Mw(t){return I.posix.normalize(t.replaceAll("\\","/"))}function Et(t,e,n){let i=I.relative(t,e);if(!(i===""||!I.isAbsolute(i)&&!i.startsWith(`..${I.sep}`)))throw new Error(`${n} resolves outside the Skill package`)}async function Cu(t,e,n){let i=Mw(e);if(I.posix.isAbsolute(i)||i===".."||i.startsWith("../"))throw new Error(`${n} resolves outside the Skill package`);let r=I.resolve(t,...i.split("/"));Et(t,r,n);let o;try{o=await L.realpath(r)}catch(s){throw s.code==="ENOENT"?new Error(`${n} does not exist: ${e}`,{cause:s}):s}if(Et(t,o,n),!(await L.stat(o)).isFile())throw new Error(`${n} is not a file: ${e}`);return{path:i,content:await L.readFile(o)}}async function Bw(t){let e=await L.realpath(t.root),n=t.packageKind==="runtime"?[]:[await Cu(e,"SKILL.md","SKILL.md")];for(let i of t.definition.tools)i.kind==="script"&&n.push(await Cu(e,i.source,`Script tool ${i.id}`));return n.sort((i,r)=>i.path.localeCompare(r.path))}function Kw(t,e){let n=e.map(i=>({path:i.path,sha256:Su("sha256").update(i.content).digest("hex")}));return Su("sha256").update(JSON.stringify(Qi({package:t,files:n}))).digest("hex")}function xu(t){return JSON.stringify(t,null,2)+`
|
|
148
|
+
`}async function Pu(t){let e=Fw(t),n=await Bw(t);return{document:e,files:n,hash:Kw(e,n)}}async function Xi(t){return(await Pu(t)).hash}async function Eu(t){try{return await L.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function _u(t,e){try{if((await L.readFile(I.join(t,"sha256"),"utf8")).trim()!==e.hash)throw new Error("hash mismatch");if(await L.readFile(I.join(t,"package.json"),"utf8")!==xu(e.document))throw new Error("package mismatch");for(let r of e.files)if(!(await L.readFile(I.join(t,...r.path.split("/")))).equals(r.content))throw new Error(`file mismatch: ${r.path}`)}catch(n){throw new Error(`Existing Skill snapshot is invalid: ${e.hash}`,{cause:n})}}async function gs(t,e){let n=await Pu(t),i=I.resolve(e,".comet","skill-snapshots"),r=I.join(i,n.hash);if(await L.mkdir(i,{recursive:!0}),await Eu(r))return await _u(r,n),{hash:n.hash,snapshotDir:r};let o=I.join(i,`.tmp-${Dw()}`);Et(i,o,"Temporary snapshot"),Et(i,r,"Published snapshot");try{await L.mkdir(o);for(let s of n.files){let a=I.join(o,...s.path.split("/"));Et(o,a,`Snapshot file ${s.path}`),await L.mkdir(I.dirname(a),{recursive:!0}),await L.writeFile(a,s.content)}await L.writeFile(I.join(o,"package.json"),xu(n.document)),await L.writeFile(I.join(o,"sha256"),n.hash+`
|
|
149
|
+
`),await L.rename(o,r)}catch(s){if(await Eu(r)){try{await _u(r,n)}finally{await L.rm(o,{recursive:!0,force:!0})}return{hash:n.hash,snapshotDir:r}}throw await L.rm(o,{recursive:!0,force:!0}),s}return{hash:n.hash,snapshotDir:r}}async function ws(t,e){if(!/^[a-f0-9]{64}$/u.test(e))throw new Error(`Invalid Skill snapshot hash: ${e}`);let n=I.resolve(t,".comet","skill-snapshots"),i=I.join(n,e);Et(n,i,"Skill snapshot");try{let r=(await L.readFile(I.join(i,"sha256"),"utf8")).trim();if(r!==e)throw new Error(`stored hash is ${r||"(empty)"}`);let o=I.join(i,"package.json"),s=JSON.parse(await L.readFile(o,"utf8")),a=vu(s,i,o),c=bu(a);if(c.length>0)throw new Error(c.map(u=>` - ${u}`).join(`
|
|
150
|
+
`));let l=await Xi(a);if(l!==e)throw new Error(`calculated hash is ${l}`);return a}catch(r){throw new Error(`Skill snapshot is invalid or missing: ${e}`,{cause:r})}}async function Ru(t){try{return await ys.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Ou(t){return Hw("sha256").update(t).digest("hex")}function Yw(t){return Ou(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}function Jw(t){return t.replaceAll(".","_").replaceAll("-","_")}async function Vw(t,e){let n=await nt(t),i=Object.fromEntries(e.filter(s=>s.satisfied&&s.source).map(s=>[Jw(s.code),s.source])),r=Se.join(t,"subagent-progress.md");await Ru(r)&&(i.subagent_progress=Se.relative(n,r).split(Se.sep).join("/"));let o=e.find(s=>s.code==="design.handoff"&&s.satisfied);return o?.source&&(i.handoff_context=o.source),i}function Gw(t,e,n){return[{sequence:1,timestamp:n,type:"run_started",runId:t.runId,data:{skill:t.skill,skillVersion:t.skillVersion,skillHash:t.skillHash}},{sequence:2,timestamp:n,type:"state_migrated",runId:t.runId,data:{kind:"classic",migrationVersion:it,profile:e,source:"pre-migration"}}]}async function zw(t){await Promise.all(t.map(e=>ys.rm(e,{recursive:!0,force:!0})))}async function Au(t,e){let n=await Be(t);if(!n.classic)throw new Error("Classic migration requires a legacy state projection");let i=n.classic,r=i.classicProfile??i.workflow;if(n.run){if(i.classicMigration!==it)throw new Error("Classic Run exists without a supported classic_migration marker");if(n.run.skill!==e.skillPackage.definition.metadata.name)throw new Error(`Classic Run skill mismatch: expected ${e.skillPackage.definition.metadata.name}, got ${n.run.skill}`);if(await Xi(e.skillPackage)!==n.run.skillHash)return await ws(t,n.run.skillHash),{classic:i,run:n.run,evidence:await bt(t,n),migrated:!1,snapshotDir:Se.join(t,".comet","skill-snapshots",n.run.skillHash)};let d=await gs(e.skillPackage,t);return{classic:i,run:n.run,evidence:await bt(t,n),migrated:!1,snapshotDir:d.snapshotDir}}let o=await bt(t,n),s=$i(i,o);if(!e.skillPackage.definition.orchestration.steps?.some(f=>f.id===s))throw new Error(`Classic Skill package does not define resolved step: ${s}`);let a=await Xi(e.skillPackage),c=Se.join(t,".comet","skill-snapshots",a),l=await Ru(c),u=[];try{let f=await gs(e.skillPackage,t),d=ru(e.skillPackage,e.runId?.()??Uw(),f.hash);d.currentStep=s,s==="completed"&&(d.status="completed");let h={...i,classicProfile:r,classicMigration:it},g=await Vw(t,o),p=await nt(t),m=o.find(k=>k.code==="design.handoff"&&k.satisfied),w=null;m?.source&&(w=await kt(p,m.resolvedSource??m.source,{label:"Classic migration handoff context",hooks:e.handoffReadHooks}),await Vi(t,d.contextRef,w),u.push(Se.resolve(t,d.contextRef))),await Ji(t,d.artifactsRef,g),u.push(Se.resolve(t,d.artifactsRef));let y=(e.now?.()??new Date).toISOString(),S={runId:d.runId,stateVersion:1,trajectoryOffset:2,contextHash:w===null?null:Ou(w),artifactsHash:Yw(g),createdAt:y};await Gi(t,d.checkpointRef,S),u.push(Se.resolve(t,d.checkpointRef)),u.push(Se.resolve(t,d.trajectoryRef));for(let k of Gw(d,r,y))await Ct(t,d.trajectoryRef,k);return await rt(t,{classic:h,run:d,unknownKeys:n.unknownKeys}),{classic:h,run:d,evidence:o,migrated:!0,snapshotDir:f.snapshotDir}}catch(f){throw await zw(u),l||await ys.rm(c,{recursive:!0,force:!0}),f}}async function Qw(t){try{return(await Nu.stat(t)).isDirectory()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Zi(t){try{return(await Nu.stat(t)).isFile()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Xw(t){return await Qw(t)?await Zi(G.join(t,"skill.yaml"))?!0:await Zi(G.join(t,"SKILL.md"))&&await Zi(G.join(t,"comet","skill.yaml")):!1}function Zw(t){return{root:t,packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-classic",version:"1",description:"Internal compatibility orchestration for classic Comet full, hotfix, and tweak workflows"},goal:{statement:"Advance or restore a classic Comet Run without changing the user command surface",inputs:[{name:"classic-state",description:"Validated ClassicState consistent with the Run projection",required:!0},{name:"evidence",description:"Structured evidence produced by the Classic Evidence collector",required:!0}],outputs:[{name:"run-state",description:"Atomically synchronized Classic and Run state",required:!0}],success:["Legacy fields and Run fields remain consistent","Every step invokes only a declared public Comet Skill","The completed state passes its completion eval"]},orchestration:{mode:"deterministic",entry:"full.open",steps:[{id:"full.open",action:{type:"invoke_skill",ref:"comet-open"},next:"full.design.handoff"},{id:"full.design.handoff",action:{type:"invoke_skill",ref:"comet-design"},next:"full.design.document"},{id:"full.design.document",action:{type:"invoke_skill",ref:"comet-design"},next:"full.build.plan"},{id:"full.build.plan",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.plan-ready"},{id:"full.build.plan-ready",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.configure"},{id:"full.build.configure",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.execute"},{id:"full.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.complete"},{id:"full.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"full.verify.run"},{id:"full.build.fix",action:{type:"invoke_skill",ref:"comet-build"},next:"full.build.execute"},{id:"full.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"full.verify.branch"},{id:"full.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"full.archive.confirm"},{id:"full.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"full.archive.execute"},{id:"full.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"hotfix.open",action:{type:"invoke_skill",ref:"comet-hotfix"},next:"hotfix.build.execute"},{id:"hotfix.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"hotfix.build.complete"},{id:"hotfix.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"hotfix.verify.run"},{id:"hotfix.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"hotfix.verify.branch"},{id:"hotfix.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"hotfix.archive.confirm"},{id:"hotfix.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"hotfix.archive.execute"},{id:"hotfix.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"tweak.open",action:{type:"invoke_skill",ref:"comet-tweak"},next:"tweak.build.execute"},{id:"tweak.build.execute",action:{type:"invoke_skill",ref:"comet-build"},next:"tweak.build.complete"},{id:"tweak.build.complete",action:{type:"invoke_skill",ref:"comet-build"},next:"tweak.verify.run"},{id:"tweak.verify.run",action:{type:"invoke_skill",ref:"comet-verify"},next:"tweak.verify.branch"},{id:"tweak.verify.branch",action:{type:"invoke_skill",ref:"comet-verify"},next:"tweak.archive.confirm"},{id:"tweak.archive.confirm",action:{type:"invoke_skill",ref:"comet-archive"},next:"tweak.archive.execute"},{id:"tweak.archive.execute",action:{type:"invoke_skill",ref:"comet-archive"},next:"completed"},{id:"completed",action:{type:"checkpoint"},completionEvals:["classic-completed"]}]},skills:[{id:"comet-open"},{id:"comet-design"},{id:"comet-build"},{id:"comet-verify"},{id:"comet-archive"},{id:"comet-hotfix"},{id:"comet-tweak"}],agents:[],tools:[]},guardrails:{allowedSkills:["comet-open","comet-design","comet-build","comet-verify","comet-archive","comet-hotfix","comet-tweak"],allowedAgents:[],allowedTools:[],maxIterations:500,maxRetriesPerAction:3,confirmationRequiredFor:[]},evals:[{id:"classic-completed",scope:"completion",type:"state_equals",field:"status",equals:"completed"}]}}async function ey(){let t=G.dirname(ju(import.meta.url)),e=[process.env.COMET_RUNTIME_CLASSIC_ROOT,G.resolve(t,"..","runtime","classic"),G.resolve(t,"..","..","comet","runtime","classic"),G.resolve(t,"..","..","assets","skills","comet","runtime","classic"),G.resolve("assets","skills","comet","runtime","classic"),process.env.COMET_CLASSIC_SKILL_ROOT,G.resolve(t,"..","..","comet-classic"),G.resolve(t,"..","..","assets","skills","comet-classic"),G.resolve("assets","skills","comet-classic")].filter(n=>!!n);for(let n of e)if(await Xw(n))return n;return null}async function ty(t){return await Zi(G.join(t,"skill.yaml"))?yu(t):wu(t)}async function Tu(t){let e=await ey();return Au(t,{skillPackage:e?await ty(e):Zw(G.dirname(ju(import.meta.url)))})}async function Iu(t,e,n,i){let r=await Be(t);if(!r.classic||!r.run)throw new Error("Classic transition requires synchronized Classic and Run projections");let o=await bt(t,{classic:e,run:n,unknownKeys:r.unknownKeys}),s=$i(e,o),a={...n,currentStep:s,iteration:n.iteration+1,status:s==="completed"?"completed":"running"};await rt(t,{classic:e,run:a,unknownKeys:r.unknownKeys});let c=await vn(t,a.trajectoryRef);return await Ct(t,a.trajectoryRef,{sequence:c.length+1,timestamp:new Date().toISOString(),type:"state_transitioned",runId:a.runId,data:{kind:"classic",fromStep:n.currentStep,toStep:s,...i}}),a}import{AsyncLocalStorage as ny}from"async_hooks";import{promises as $u}from"fs";import kn from"path";var vs=new ny;function iy(t,e){let n=kn.relative(t,e);return n===""||!kn.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${kn.sep}`)}async function ry(t){let e=kn.resolve(t.invocationCwd??process.cwd()),n=kn.resolve(t.projectRoot??await nt(e)),[i,r]=await Promise.all([$u.realpath(e),$u.realpath(n)]);if(!iy(r,i))throw new Error(`Classic command invocation cwd is outside the discovered project: ${e}`);return{invocationCwd:e,projectRoot:n}}async function oy(t,e){let n=vs.getStore();if(n)return e(n);let i=await ry(t);return vs.run(i,()=>e(i))}function qu(){let t=vs.getStore();if(!t)throw new Error("Classic command project context is unavailable");return t.projectRoot}function Lu(t){return(e,n)=>oy(n,()=>t(e,n))}function ks(t){return t==="zh-CN"?"zh-CN":"en"}function sy(t,e,n){return t==="zh-CN"?n:e}function bs(t){let{name:e,locale:n}=t;return{summary:sy(n,`Handoff context for ${e} was written and recorded; the Build phase can resume from it.`,`需求 ${e} 的交接上下文已写入并记录,Build 阶段可据此继续。`)}}var ay="\x1B[32m",cy="\x1B[31m",ly="\x1B[33m",Cs="\x1B[0m";function Ue(t){return`${ay}${t}${Cs}`}function oe(t){return`${cy}${t}${Cs}`}function Wu(t){return`${ly}${t}${Cs}`}var J=class extends Error{constructor(n,i=1){super(n);this.exitCode=i}exitCode},Ss=class{stdout=[];stderr=[];envelope;toResult(e=0){return{exitCode:e,...this.stdout.length>0?{stdout:this.stdout.join(`
|
|
151
151
|
`)+`
|
|
152
152
|
`}:{},...this.stderr.length>0?{stderr:this.stderr.join(`
|
|
153
153
|
`)+`
|
|
154
|
-
`}:{},...this.envelope===void 0?{}:{envelope:this.envelope}}}};async function fe(t,e,n){return await ji(t,e,{label:n,expected:"file"})?
|
|
155
|
-
`)).digest("hex")}function
|
|
156
|
-
`&&(n+=1,n===e))return t.slice(0,i+1);return t}async function
|
|
157
|
-
`),"Classic handoff markdown output")}async function
|
|
158
|
-
`),l=["{",` "change": "${
|
|
159
|
-
`);await er(t,s,l,"Classic handoff JSON output")}async function
|
|
160
|
-
`),"Classic handoff spec markdown output")}async function
|
|
161
|
-
`,"Classic handoff spec JSON output")}async function
|
|
162
|
-
`));let
|
|
163
|
-
`))e.stderr.push(
|
|
164
|
-
|
|
154
|
+
`}:{},...this.envelope===void 0?{}:{envelope:this.envelope}}}};async function fe(t,e,n){return await ji(t,e,{label:n,expected:"file"})?kt(t,e,{label:n}):null}async function er(t,e,n,i){await $l(t,e,n,{label:i})}function uy(t){let e=ns(t);if(e)throw new J(oe(`ERROR: ${e}`))}function de(t){return Bu("sha256").update(t).digest("hex")}function Yu(t){return de(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}async function xt(t,e){let n=[`${e}/proposal.md`,`${e}/design.md`,`${e}/tasks.md`],i=`${e}/specs`;if((await le(t,i,{label:"Classic handoff specs directory",expected:"directory"})).exists){let o=(await Ku.readdir(i,{withFileTypes:!0})).sort((s,a)=>s.name.localeCompare(a.name));for(let s of o){if(!s.isDirectory()&&!s.isSymbolicLink())continue;let a=`${i}/${s.name}/spec.md`;(await le(t,`${i}/${s.name}`,{label:`Classic handoff spec directory ${s.name}`,expected:"directory"})).exists&&await ji(t,a,{label:`Classic handoff spec ${s.name}`,expected:"file"})&&n.push(a)}}return n}function _t(t,e,n){let i=Hu.relative(t,n).replaceAll("\\","/");return`${e}/${i}`}async function Du(t,e,n){let i=[];for(let r of await xt(t,e)){let o=_t(e,n,r),s=await fe(t,r,`Classic handoff source ${o}`);s!==null&&i.push(`path:${o}`,`sha256:${de(s)}`)}return Bu("sha256").update(i.join(`
|
|
155
|
+
`)).digest("hex")}function Fu(t){return t.replace(/\\/gu,"\\\\").replace(/"/gu,'\\"')}function Ju(t){return(t.match(/\n/gu)??[]).length}function fy(t,e){let n=0;for(let i=0;i<t.length;i+=1)if(t[i]===`
|
|
156
|
+
`&&(n+=1,n===e))return t.slice(0,i+1);return t}async function dy(t,e,n,i,r,o,s){let a=["# Comet Design Handoff","",`- Change: ${i}`,"- Phase: design",`- Mode: ${r}`,`- Context hash: ${o}`,"","Generated-by: comet-handoff.sh","","OpenSpec remains the canonical capability spec. This handoff is a deterministic, source-traceable context pack, not an agent-authored summary.",""];for(let c of await xt(t,e)){let l=_t(e,n,c),u=await fe(t,c,`Classic handoff source ${l}`);if(u===null)continue;let f=Ju(u);a.push(`## ${l}`,"",`- Source: ${l}`,`- Lines: 1-${f}`,`- SHA256: ${de(u)}`,""),r==="full"||f<=80?a.push("```md",u,"```"):a.push("[TRUNCATED]","","```md",fy(u,80),"```","",`Full source: ${l}`),a.push("")}await er(t,s,a.join(`
|
|
157
|
+
`),"Classic handoff markdown output")}async function py(t,e,n,i,r,o,s){let a=[];for(let u of await xt(t,e)){let f=_t(e,n,u),d=await fe(t,u,`Classic handoff source ${f}`);d!==null&&a.push(` { "path": "${Fu(f)}", "sha256": "${de(d)}" }`)}let c=a.join(`,
|
|
158
|
+
`),l=["{",` "change": "${Fu(i)}",`,' "phase": "design",',` "mode": "${r}",`,' "canonical_spec": "openspec",',' "generated_by": "comet-handoff.sh",',` "context_hash": "${o}",`,' "files": [',c," ]","}",""].join(`
|
|
159
|
+
`);await er(t,s,l,"Classic handoff JSON output")}async function my(t,e){return[`## ${t}`,"",`- Source: ${t}`,`- Lines: 1-${Ju(e)}`,`- SHA256: ${de(e)}`,"","```md",e,"```",""]}async function hy(t,e,n,i,r,o){let s=["# Comet Spec Context","",`- Change: ${i}`,"- Phase: design","- Mode: beta",`- Context hash: ${r}`,"","Generated-by: comet-handoff.sh","","OpenSpec remains the canonical capability spec. This beta context pack verbatim-projects spec files and references supporting artifacts by hash, not an agent-authored summary.","","## Source References",""];for(let u of await xt(t,e)){let f=_t(e,n,u),d=await fe(t,u,`Classic handoff source ${f}`);d!==null&&s.push(`- Source: ${f}`,`- SHA256: ${de(d)}`)}s.push("","## Acceptance Projection","");let a=`${e}/specs`,c=!1;if((await le(t,a,{label:"Classic handoff specs directory",expected:"directory"})).exists){let u=(await Ku.readdir(a,{withFileTypes:!0})).sort((f,d)=>f.name.localeCompare(d.name));for(let f of u){if(!f.isDirectory()&&!f.isSymbolicLink())continue;let d=`${a}/${f.name}/spec.md`,h=await fe(t,d,`Classic handoff spec ${f.name}`);h!==null&&(c=!0,s.push(...await my(_t(e,n,d),h)))}}c||s.push("No delta spec files found.",""),s.push("Full source files remain canonical. If a required heading or scenario is missing here, regenerate the handoff or read the source spec directly. Supporting files (proposal, design, tasks) are referenced by hash only."),await er(t,o,s.join(`
|
|
160
|
+
`),"Classic handoff spec markdown output")}async function gy(t,e,n,i,r,o){let s=[];for(let a of await xt(t,e)){let c=_t(e,n,a),l=await fe(t,a,`Classic handoff source ${c}`);if(l===null)continue;let u=/\/specs\/[^/]+\/spec\.md$/u.test(c)?"spec":"supporting";s.push({path:c,sha256:de(l),role:u})}await er(t,o,`${JSON.stringify({change:i,phase:"design",mode:"beta",canonical_spec:"openspec",generated_by:"comet-handoff.sh",context_hash:r,files:s},null,2)}
|
|
161
|
+
`,"Classic handoff spec JSON output")}async function Mu(t,e,n){let i=Hu.join(e,".comet.yaml"),r=(0,Uu.parseDocument)(await kt(t,i,{label:"Classic change state"}),{uniqueKeys:!1});if(r.errors.length>0)throw new J(`ERROR: Invalid .comet.yaml: ${r.errors[0].message}`);let s=r.toJS()[n];return s==null?"":typeof s=="object"?JSON.stringify(s):String(s)}async function wy(t,e,n){let i=await vn(t,e.trajectoryRef);i.some(o=>o.type==="recovery_reconciled"&&o.data.kind==="classic-handoff"&&o.data.actionId===n)||await Ct(t,e.trajectoryRef,{sequence:i.length+1,timestamp:new Date().toISOString(),type:"recovery_reconciled",runId:e.runId,data:{kind:"classic-handoff",actionId:n}})}async function yy(t,e,n,i){let r=await fe(t,n,"Classic handoff markdown output");if(r===null)return!1;let o=new Set(r.split(/\r?\n/u));if(!o.has(`- Context hash: ${i}`))return!1;for(let s of await xt(t,e)){let a=await fe(t,s,`Classic handoff source ${s}`);if(a!==null&&!o.has(`- SHA256: ${de(a)}`))return!1}return!0}async function vy(t,e,n,i,r,o,s,a){let[c,l,u]=await Promise.all([ou(e,n.contextRef),ds(e,n.artifactsRef),cu(e,n.checkpointRef)]),[f,d]=await Promise.all([fe(t,r,"Classic handoff JSON output"),fe(t,o,"Classic handoff markdown output")]);return f===null||d===null||c!==d||l.handoff_context!==s||l.handoff_markdown!==a?!1:u?.runId===n.runId&&u.contextHash===(c===null?null:de(c))&&u.artifactsHash===Yu(l)&&i.length===64}var Vu=Lu(async t=>{let e=new Ss,[n,i,r,o]=t,s=t.length===2&&i==="--hash-only",a=i==="design"&&r==="--write"&&(t.length===3||t.length===4&&o==="--full");if(!s&&!a)return{exitCode:64,stderr:"Usage: comet handoff <change-name> design --write [--full] | comet handoff <change-name> --hash-only"};try{uy(n);let c=await es(qu()),l=await Ll(n,c.projectRoot),u=l.directory,f=M(c.projectRoot,u);if(i==="--hash-only"){if(!l.exists)throw new J(oe(`ERROR: change directory not found: ${f}`));for(let Je of["proposal.md","design.md","tasks.md"])if(!await ts(c.projectRoot,`${u}/${Je}`,`Classic handoff source ${Je}`))throw new J(oe(`ERROR: required file missing or empty: ${f}/${Je}`));return e.stdout.push(await Du(c.projectRoot,u,f)),e.toResult(0)}let d=o==="--full"?"full":"compact";if(!l.exists)throw new J(oe(`ERROR: change directory not found: ${f}`));if(!l.stateExists)throw new J(oe(`ERROR: .comet.yaml not found at ${f}/.comet.yaml`));let h=await Mu(c.projectRoot,u,"phase");if(h!=="design"&&h!=="build")throw new J(oe("ERROR: design handoff requires phase: design or build"));for(let Je of["proposal.md","design.md","tasks.md"])if(!await ts(c.projectRoot,`${u}/${Je}`,`Classic handoff source ${Je}`))throw new J(oe(`ERROR: required OpenSpec artifact missing or empty: ${f}/${Je}`));let g=`${u}/.comet/handoff`;await le(c.projectRoot,`${u}/.comet`,{label:"Classic change runtime directory",expected:"directory"}),await le(c.projectRoot,g,{label:"Classic handoff directory",expected:"directory"});let p=await Mu(c.projectRoot,u,"context_compression")||"off",m,w;if(p==="off")m=`${g}/design-context.json`,w=`${g}/design-context.md`;else if(p==="beta")d==="full"&&e.stderr.push(Wu("[HANDOFF] --full is ignored in beta mode; spec files are projected verbatim")),d="beta",m=`${g}/spec-context.json`,w=`${g}/spec-context.md`;else throw new J([oe(`ERROR: invalid context_compression: ${p}`),oe("Valid values: off, beta")].join(`
|
|
162
|
+
`));let y=M(c.projectRoot,m),S=M(c.projectRoot,w),k=await Du(c.projectRoot,u,f),C=`classic-handoff:${k}`,E=await Be(u);if(!E.classic)throw new J(oe("ERROR: design handoff requires Classic state"));let P=E.run?await ps(u,E.run.pendingRef):null,b=P?.id===C&&P.type==="handoff"&&P.ref===k;E.classic.handoffHash&&E.classic.handoffHash!==k&&!b&&e.stderr.push(Wu(`[HANDOFF] refreshing stale design handoff: previous hash ${E.classic.handoffHash}`)),await Ti(c.projectRoot,`${u}/.comet`,"Classic change runtime directory"),await Ti(c.projectRoot,g,"Classic handoff directory");let _=await Tu(u),V=await ps(u,_.run.pendingRef),Ce=V?.id===C&&V.type==="handoff"&&V.ref===k;if(_.run.pending&&_.run.pending!==C)throw new J(oe(`ERROR: another action is pending: ${_.run.pending}`));if(_.classic.handoffHash===k&&_.classic.handoffContext===y&&!_.run.pending&&!V&&await vy(c.projectRoot,u,_.run,k,m,w,y,S)&&await yy(c.projectRoot,u,w,k))return e.envelope=bs({name:n,locale:ks(_.classic.language)}),e.stderr.push(e.envelope.summary),e.stderr.push(Ue(`[HANDOFF] wrote ${y}`)),e.stderr.push(Ue(`[HANDOFF] wrote ${S}`)),e.stderr.push(Ue(`[HANDOFF] handoff_hash=${k}`)),e.toResult(0);let j={id:C,stepId:_.run.currentStep,type:"handoff",ref:k};await su(u,_.run.pendingRef,j);let se={..._.run,pending:C,status:"waiting"};await rt(u,{classic:_.classic,run:se,unknownKeys:(await Be(u)).unknownKeys}),d==="beta"?(await hy(c.projectRoot,u,f,n,k,w),await gy(c.projectRoot,u,f,n,k,m)):(await dy(c.projectRoot,u,f,n,d,k,w),await py(c.projectRoot,u,f,n,d,k,m));let Es=await kt(c.projectRoot,w,{label:"Classic handoff markdown output"});await Vi(u,se.contextRef,Es);let _s={...await ds(u,se.artifactsRef),handoff_context:y,handoff_markdown:S};await Ji(u,se.artifactsRef,_s);let tr={..._.classic,handoffContext:y,handoffHash:k},Ye={...se.currentStep==="full.design.handoff"?await Iu(u,tr,se,{actionId:C,kind:"classic-handoff"}):se,pending:null,status:"running"};(b||Ce)&&await wy(u,Ye,C);let Qu=await vn(u,Ye.trajectoryRef),Xu={runId:Ye.runId,stateVersion:Ye.iteration,trajectoryOffset:Qu.length,contextHash:de(Es),artifactsHash:Yu(_s),createdAt:new Date().toISOString()};return await Gi(u,Ye.checkpointRef,Xu),await rt(u,{classic:tr,run:Ye,unknownKeys:(await Be(u)).unknownKeys}),await au(u,Ye.pendingRef),e.envelope=bs({name:n,locale:ks(tr.language)}),e.stderr.push(e.envelope.summary),e.stderr.push(Ue(`[SET] handoff_context=${m}`)),e.stderr.push(Ue(`[SET] handoff_hash=${k}`)),e.stderr.push(Ue(`[HANDOFF] wrote ${y}`)),e.stderr.push(Ue(`[HANDOFF] wrote ${S}`)),e.stderr.push(Ue(`[HANDOFF] handoff_hash=${k}`)),e.toResult(0)}catch(c){if(c instanceof J){for(let l of c.message.split(`
|
|
163
|
+
`))e.stderr.push(l);return e.toResult(c.exitCode)}throw c}});function Gu(t,e){if(!e.includes("--help")&&!e.includes("-h"))return;let i={state:["comet state <command> [args]","init <change-name> <full|hotfix|tweak> [--isolation <current|branch|worktree>]","get <change-name> <field>","set <change-name> <field> <value>","transition <change-name> <event>","check <change-name> <phase> [--recover]","scale <change-name>","record-check <change-name> <build|verify> --command <text> --exit-code <int> [--cwd <path>]","task-checkoff <file> <task-text>","select <change-name> | rebind <change-name> | next <change-name>","current | clear-selection"],guard:["comet guard <change-name> <open|design|build|verify|archive> [--apply]","Checks only by default; --apply advances the phase after all checks pass."],handoff:["comet handoff <change-name> design --write [--full]","comet handoff <change-name> --hash-only"],archive:["comet archive <change-name> [--dry-run]"],validate:["comet classic validate <change-name>"],workspace:["comet classic workspace prepare <change-name> --isolation <current|branch|worktree> [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]","comet classic workspace resolve <change-name>"]}[t];return i?`Usage: ${i.join(`
|
|
164
|
+
`)}
|
|
165
|
+
|
|
166
|
+
Options: --json (machine-readable output), --help
|
|
167
|
+
Unknown options are rejected; command placeholders must be replaced with actual values.
|
|
168
|
+
`:void 0}function ky(t,e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:t,exitCode:e.exitCode,...e.data===void 0?{}:{data:e.data},...e.envelope===void 0?{}:{summary:e.envelope.summary,...e.envelope.next===void 0?{}:{next:e.envelope.next},...e.envelope.user_message===void 0?{}:{user_message:e.envelope.user_message}},...e.stdout===void 0?{}:{stdout:e.stdout},...e.stderr===void 0?{}:{stderr:e.stderr}})+`
|
|
169
|
+
`,...e.envelope===void 0?{}:{envelope:e.envelope}}}async function zu(t,e,n=process.argv.slice(2)){let i=n.includes("--json"),r=n.filter(a=>a!=="--json"),o;try{let a=Gu(t,r);o=a?{exitCode:0,stdout:a}:await e(r,{json:i})}catch(a){o={exitCode:70,stderr:a instanceof Error?a.message:String(a)}}let s=i?ky(t,o):o;return s.stdout&&process.stdout.write(s.stdout),s.stderr&&process.stderr.write(s.stderr+(s.stderr.endsWith(`
|
|
165
170
|
`)?"":`
|
|
166
|
-
`)),s.exitCode}process.exitCode=await
|
|
171
|
+
`)),s.exitCode}process.exitCode=await zu("handoff",Vu);
|