@rpamis/comet 0.4.0-beta.15 → 0.4.0-beta.16
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/assets/manifest.json +1 -1
- package/assets/skills/comet/scripts/comet-archive.mjs +65 -65
- package/assets/skills/comet/scripts/comet-guard.mjs +95 -95
- package/assets/skills/comet/scripts/comet-handoff.mjs +67 -67
- package/assets/skills/comet/scripts/comet-hook-guard.mjs +58 -58
- package/assets/skills/comet/scripts/comet-hook-router.mjs +54 -54
- package/assets/skills/comet/scripts/comet-resume-probe.mjs +60 -60
- package/assets/skills/comet/scripts/comet-runtime.mjs +116 -116
- package/assets/skills/comet/scripts/comet-state.mjs +69 -69
- package/assets/skills/comet/scripts/comet-yaml-validate.mjs +65 -65
- package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +43 -43
- package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +89 -89
- package/dist/app/commands/doctor.d.ts.map +1 -1
- package/dist/app/commands/doctor.js +8 -2
- package/dist/app/commands/doctor.js.map +1 -1
- package/dist/domains/comet-classic/classic-evidence.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-evidence.js +45 -9
- package/dist/domains/comet-classic/classic-evidence.js.map +1 -1
- package/dist/domains/comet-classic/classic-layout-initialization.d.ts +4 -3
- package/dist/domains/comet-classic/classic-layout-initialization.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-layout-initialization.js +13 -9
- package/dist/domains/comet-classic/classic-layout-initialization.js.map +1 -1
- package/dist/domains/comet-classic/classic-layout.d.ts +2 -11
- package/dist/domains/comet-classic/classic-layout.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-layout.js +22 -28
- package/dist/domains/comet-classic/classic-layout.js.map +1 -1
- package/dist/domains/comet-classic/classic-root-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-root-command.js +6 -1
- package/dist/domains/comet-classic/classic-root-command.js.map +1 -1
- package/dist/domains/comet-entry/hook-adapter.d.ts.map +1 -1
- package/dist/domains/comet-entry/hook-adapter.js +4 -0
- package/dist/domains/comet-entry/hook-adapter.js.map +1 -1
- package/dist/domains/dashboard/web/index.html +14 -14
- package/dist/domains/factory/package.d.ts.map +1 -1
- package/dist/domains/factory/package.js +7 -22
- package/dist/domains/factory/package.js.map +1 -1
- package/eval/pyproject.toml +4 -4
- package/package.json +7 -5
|
@@ -1,41 +1,41 @@
|
|
|
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
|
-
`)}};At.defaultYaml={explicit:!1,version:"1.2"};At.defaultTags={"!!":"tag:yaml.org,2002:"};Ho.Directives=At});var Ln=v(jt=>{"use strict";var Go=N(),
|
|
6
|
-
`)?
|
|
4
|
+
var df=Object.create;var gr=Object.defineProperty;var pf=Object.getOwnPropertyDescriptor;var mf=Object.getOwnPropertyNames;var hf=Object.getPrototypeOf,gf=Object.prototype.hasOwnProperty;var jn=(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 G=(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}},wf=(t,e)=>{for(var n in e)gr(t,n,{get:e[n],enumerable:!0})},yf=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of mf(e))!gf.call(t,r)&&r!==n&&gr(t,r,{get:()=>e[r],enumerable:!(i=pf(e,r))||i.enumerable});return t};var Je=(t,e,n)=>(n=t!=null?df(hf(t)):{},yf(e||!t||!t.__esModule?gr(n,"default",{value:t,enumerable:!0}):n,t));var N=v(U=>{"use strict";var wr=Symbol.for("yaml.alias"),Fo=Symbol.for("yaml.document"),Tn=Symbol.for("yaml.map"),Mo=Symbol.for("yaml.pair"),yr=Symbol.for("yaml.scalar"),In=Symbol.for("yaml.seq"),ge=Symbol.for("yaml.node.type"),vf=t=>!!t&&typeof t=="object"&&t[ge]===wr,bf=t=>!!t&&typeof t=="object"&&t[ge]===Fo,kf=t=>!!t&&typeof t=="object"&&t[ge]===Tn,Sf=t=>!!t&&typeof t=="object"&&t[ge]===Mo,Wo=t=>!!t&&typeof t=="object"&&t[ge]===yr,Cf=t=>!!t&&typeof t=="object"&&t[ge]===In;function Bo(t){if(t&&typeof t=="object")switch(t[ge]){case Tn:case In:return!0}return!1}function Ef(t){if(t&&typeof t=="object")switch(t[ge]){case wr:case Tn:case yr:case In:return!0}return!1}var xf=t=>(Wo(t)||Bo(t))&&!!t.anchor;U.ALIAS=wr;U.DOC=Fo;U.MAP=Tn;U.NODE_TYPE=ge;U.PAIR=Mo;U.SCALAR=yr;U.SEQ=In;U.hasAnchor=xf;U.isAlias=vf;U.isCollection=Bo;U.isDocument=bf;U.isMap=kf;U.isNode=Ef;U.isPair=Sf;U.isScalar=Wo;U.isSeq=Cf});var Ot=v(vr=>{"use strict";var B=N(),Z=Symbol("break visit"),Ko=Symbol("skip children"),de=Symbol("remove node");function $n(t,e){let n=Yo(e);B.isDocument(t)?ft(null,t.contents,n,Object.freeze([t]))===de&&(t.contents=null):ft(null,t,n,Object.freeze([]))}$n.BREAK=Z;$n.SKIP=Ko;$n.REMOVE=de;function ft(t,e,n,i){let r=Uo(t,e,n,i);if(B.isNode(r)||B.isPair(r))return Vo(t,i,r),ft(t,r,n,i);if(typeof r!="symbol"){if(B.isCollection(e)){i=Object.freeze(i.concat(e));for(let s=0;s<e.items.length;++s){let o=ft(s,e.items[s],n,i);if(typeof o=="number")s=o-1;else{if(o===Z)return Z;o===de&&(e.items.splice(s,1),s-=1)}}}else if(B.isPair(e)){i=Object.freeze(i.concat(e));let s=ft("key",e.key,n,i);if(s===Z)return Z;s===de&&(e.key=null);let o=ft("value",e.value,n,i);if(o===Z)return Z;o===de&&(e.value=null)}}return r}async function qn(t,e){let n=Yo(e);B.isDocument(t)?await dt(null,t.contents,n,Object.freeze([t]))===de&&(t.contents=null):await dt(null,t,n,Object.freeze([]))}qn.BREAK=Z;qn.SKIP=Ko;qn.REMOVE=de;async function dt(t,e,n,i){let r=await Uo(t,e,n,i);if(B.isNode(r)||B.isPair(r))return Vo(t,i,r),dt(t,r,n,i);if(typeof r!="symbol"){if(B.isCollection(e)){i=Object.freeze(i.concat(e));for(let s=0;s<e.items.length;++s){let o=await dt(s,e.items[s],n,i);if(typeof o=="number")s=o-1;else{if(o===Z)return Z;o===de&&(e.items.splice(s,1),s-=1)}}}else if(B.isPair(e)){i=Object.freeze(i.concat(e));let s=await dt("key",e.key,n,i);if(s===Z)return Z;s===de&&(e.key=null);let o=await dt("value",e.value,n,i);if(o===Z)return Z;o===de&&(e.value=null)}}return r}function Yo(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 Uo(t,e,n,i){if(typeof n=="function")return n(t,e,i);if(B.isMap(e))return n.Map?.(t,e,i);if(B.isSeq(e))return n.Seq?.(t,e,i);if(B.isPair(e))return n.Pair?.(t,e,i);if(B.isScalar(e))return n.Scalar?.(t,e,i);if(B.isAlias(e))return n.Alias?.(t,e,i)}function Vo(t,e,n){let i=e[e.length-1];if(B.isCollection(i))i.items[t]=n;else if(B.isPair(i))t==="key"?i.key=n:i.value=n;else if(B.isDocument(i))i.contents=n;else{let r=B.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}vr.visit=$n;vr.visitAsync=qn});var br=v(Ho=>{"use strict";var Jo=N(),_f=Ot(),Pf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Rf=t=>t.replace(/[!,[\]{}]/g,e=>Pf[e]),At=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[s,o]=i;return this.tags[s]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[s]=i;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{let o=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,o),!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 o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,i,r]=e.match(/^(.*!)([^!]*)$/s);r||n(`The ${e} tag has no suffix`);let s=this.tags[i];if(s)try{return s+decodeURIComponent(r)}catch(o){return n(String(o)),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+Rf(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&&Jo.isNode(e.contents)){let s={};_f.visit(e.contents,(o,a)=>{Jo.isNode(a)&&a.tag&&(s[a.tag]=!0)}),r=Object.keys(s)}else r=[];for(let[s,o]of i)s==="!!"&&o==="tag:yaml.org,2002:"||(!e||r.some(a=>a.startsWith(o)))&&n.push(`%TAG ${s} ${o}`);return n.join(`
|
|
5
|
+
`)}};At.defaultYaml={explicit:!1,version:"1.2"};At.defaultTags={"!!":"tag:yaml.org,2002:"};Ho.Directives=At});var Ln=v(jt=>{"use strict";var Go=N(),Nf=Ot();function Of(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 zo(t){let e=new Set;return Nf.visit(t,{Value(n,i){i.anchor&&e.add(i.anchor)}}),e}function Qo(t,e){for(let n=1;;++n){let i=`${t}${n}`;if(!e.has(i))return i}}function Af(t,e){let n=[],i=new Map,r=null;return{onAnchor:s=>{n.push(s),r??(r=zo(t));let o=Qo(e,r);return r.add(o),o},setAnchors:()=>{for(let s of n){let o=i.get(s);if(typeof o=="object"&&o.anchor&&(Go.isScalar(o.node)||Go.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:i}}jt.anchorIsValid=Of;jt.anchorNames=zo;jt.createNodeAnchors=Af;jt.findNewAnchor=Qo});var kr=v(Xo=>{"use strict";function Tt(t,e,n,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let r=0,s=i.length;r<s;++r){let o=i[r],a=Tt(t,i,String(r),o);a===void 0?delete i[r]:a!==o&&(i[r]=a)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let s=i.get(r),o=Tt(t,i,r,s);o===void 0?i.delete(r):o!==s&&i.set(r,o)}else if(i instanceof Set)for(let r of Array.from(i)){let s=Tt(t,i,r,r);s===void 0?i.delete(r):s!==r&&(i.delete(r),i.add(s))}else for(let[r,s]of Object.entries(i)){let o=Tt(t,i,r,s);o===void 0?delete i[r]:o!==s&&(i[r]=o)}return t.call(e,n,i)}Xo.applyReviver=Tt});var Ee=v(ea=>{"use strict";var jf=N();function Zo(t,e,n){if(Array.isArray(t))return t.map((i,r)=>Zo(i,String(r),n));if(t&&typeof t.toJSON=="function"){if(!n||!jf.hasAnchor(t))return t.toJSON(e,n);let i={aliasCount:0,count:1,res:void 0};n.anchors.set(t,i),n.onCreate=s=>{i.res=s,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}ea.toJS=Zo});var Dn=v(na=>{"use strict";var Tf=kr(),ta=N(),If=Ee(),Sr=class{constructor(e){Object.defineProperty(this,ta.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:s}={}){if(!ta.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},a=If.toJS(this,"",o);if(typeof r=="function")for(let{count:c,res:l}of o.anchors.values())r(l,c);return typeof s=="function"?Tf.applyReviver(s,{"":a},"",a):a}};na.NodeBase=Sr});var It=v(ia=>{"use strict";var $f=Ln(),qf=Ot(),pt=N(),Lf=Dn(),Df=Ee(),Cr=class extends Lf.NodeBase{constructor(e){super(pt.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=[],qf.visit(e,{Node:(s,o)=>{(pt.isAlias(o)||pt.hasAnchor(o))&&i.push(o)}}),n&&(n.aliasResolveCache=i));let r;for(let s of i){if(s===this)break;s.anchor===this.source&&(r=s)}return r}toJSON(e,n){if(!n)return{source:this.source};let{anchors:i,doc:r,maxAliasCount:s}=n,o=this.resolve(r,n);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=i.get(o);if(a||(Df.toJS(o,null,n),a=i.get(o)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(s>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Fn(r,o,i)),a.count*a.aliasCount>s)){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($f.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(e.implicitKey)return`${r} `}return r}};function Fn(t,e,n){if(pt.isAlias(e)){let i=e.resolve(t),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(pt.isCollection(e)){let i=0;for(let r of e.items){let s=Fn(t,r,n);s>i&&(i=s)}return i}else if(pt.isPair(e)){let i=Fn(t,e.key,n),r=Fn(t,e.value,n);return Math.max(i,r)}return 1}ia.Alias=Cr});var q=v(Er=>{"use strict";var Ff=N(),Mf=Dn(),Wf=Ee(),Bf=t=>!t||typeof t!="function"&&typeof t!="object",xe=class extends Mf.NodeBase{constructor(e){super(Ff.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:Wf.toJS(this.value,e,n)}toString(){return String(this.value)}};xe.BLOCK_FOLDED="BLOCK_FOLDED";xe.BLOCK_LITERAL="BLOCK_LITERAL";xe.PLAIN="PLAIN";xe.QUOTE_DOUBLE="QUOTE_DOUBLE";xe.QUOTE_SINGLE="QUOTE_SINGLE";Er.Scalar=xe;Er.isScalarValue=Bf});var $t=v(sa=>{"use strict";var Kf=It(),He=N(),ra=q(),Yf="tag:yaml.org,2002:";function Uf(t,e,n){if(e){let i=n.filter(s=>s.tag===e),r=i.find(s=>!s.format)??i[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return n.find(i=>i.identify?.(t)&&!i.format)}function Vf(t,e,n){if(He.isDocument(t)&&(t=t.contents),He.isNode(t))return t;if(He.isPair(t)){let u=n.schema[He.MAP].createNode?.(n.schema,null,n);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:i,onAnchor:r,onTagObj:s,schema:o,sourceObjects:a}=n,c;if(i&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=r(t)),new Kf.Alias(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=Yf+e.slice(2));let l=Uf(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new ra.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?o[He.MAP]:Symbol.iterator in Object(t)?o[He.SEQ]:o[He.MAP]}s&&(s(l),delete n.onTagObj);let d=l?.createNode?l.createNode(n.schema,t,n):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(n.schema,t,n):new ra.Scalar(t);return e?d.tag=e:l.default||(d.tag=l.tag),c&&(c.node=d),d}sa.createNode=Vf});var Wn=v(Mn=>{"use strict";var Jf=$t(),pe=N(),Hf=Dn();function xr(t,e,n){let i=n;for(let r=e.length-1;r>=0;--r){let s=e[r];if(typeof s=="number"&&Number.isInteger(s)&&s>=0){let o=[];o[s]=i,i=o}else i=new Map([[s,i]])}return Jf.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 oa=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,_r=class extends Hf.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=>pe.isNode(i)||pe.isPair(i)?i.clone(e):i),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(oa(e))this.add(n);else{let[i,...r]=e,s=this.get(i,!0);if(pe.isCollection(s))s.addIn(r,n);else if(s===void 0&&this.schema)this.set(i,xr(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(pe.isCollection(r))return r.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(e,n){let[i,...r]=e,s=this.get(i,!0);return r.length===0?!n&&pe.isScalar(s)?s.value:s:pe.isCollection(s)?s.getIn(r,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!pe.isPair(n))return!1;let i=n.value;return i==null||e&&pe.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 pe.isCollection(r)?r.hasIn(i):!1}setIn(e,n){let[i,...r]=e;if(r.length===0)this.set(i,n);else{let s=this.get(i,!0);if(pe.isCollection(s))s.setIn(r,n);else if(s===void 0&&this.schema)this.set(i,xr(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}};Mn.Collection=_r;Mn.collectionFromPath=xr;Mn.isEmptyPath=oa});var qt=v(Bn=>{"use strict";var Gf=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Pr(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var zf=(t,e,n)=>t.endsWith(`
|
|
6
|
+
`)?Pr(n,e):n.includes(`
|
|
7
7
|
`)?`
|
|
8
|
-
`+
|
|
9
|
-
`)n===
|
|
8
|
+
`+Pr(n,e):(t.endsWith(" ")?"":" ")+n;Bn.indentComment=Pr;Bn.lineComment=zf;Bn.stringifyComment=Gf});var ca=v(Lt=>{"use strict";var Qf="flow",Rr="block",Kn="quoted";function Xf(t,e,n="flow",{indentAtStart:i,lineWidth:r=80,minContentWidth:s=20,onFold:o,onOverflow:a}={}){if(!r||r<0)return t;r<s&&(s=0);let c=Math.max(1+s,1+r-e.length);if(t.length<=c)return t;let l=[],d={},u=r-e.length;typeof i=="number"&&(i>r-Math.max(2,s)?l.push(0):u=r-i);let f,h,w=!1,p=-1,m=-1,g=-1;n===Rr&&(p=aa(t,p,e.length),p!==-1&&(u=p+c));for(let k;k=t[p+=1];){if(n===Kn&&k==="\\"){switch(m=p,t[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}g=p}if(k===`
|
|
9
|
+
`)n===Rr&&(p=aa(t,p,e.length)),u=p+e.length+c,f=void 0;else{if(k===" "&&h&&h!==" "&&h!==`
|
|
10
10
|
`&&h!==" "){let C=t[p+1];C&&C!==" "&&C!==`
|
|
11
|
-
`&&C!==" "&&(
|
|
12
|
-
${e}${t.slice(0,x)}`:(n===Kn&&
|
|
11
|
+
`&&C!==" "&&(f=p)}if(p>=u)if(f)l.push(f),u=f+c,f=void 0;else if(n===Kn){for(;h===" "||h===" ";)h=k,k=t[p+=1],w=!0;let C=p>g+1?p-2:m-1;if(d[C])return t;l.push(C),d[C]=!0,u=C+c,f=void 0}else w=!0}h=k}if(w&&a&&a(),l.length===0)return t;o&&o();let y=t.slice(0,l[0]);for(let k=0;k<l.length;++k){let C=l[k],x=l[k+1]||t.length;C===0?y=`
|
|
12
|
+
${e}${t.slice(0,x)}`:(n===Kn&&d[C]&&(y+=`${t[C]}\\`),y+=`
|
|
13
13
|
${e}${t.slice(C+1,x)}`)}return y}function aa(t,e,n){let i=e,r=e+1,s=t[r];for(;s===" "||s===" ";)if(e<r+n)s=t[++e];else{do s=t[++e];while(s&&s!==`
|
|
14
|
-
`);i=e,r=e+1,s=t[r]}return i}Lt.FOLD_BLOCK=
|
|
15
|
-
`){if(s-o>i)return!0;if(o=s+1,r-o<=i)return!1}return!0}function Dt(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:i}=e,r=e.options.doubleQuotedMinMultiLineLength,s=e.indent||(Vn(t)?" ":""),o="",a=0;for(let c=0,l=n[c];l;l=n[++c])if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(o+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(n[c+1]){case"u":{o+=n.slice(a,c);let
|
|
14
|
+
`);i=e,r=e+1,s=t[r]}return i}Lt.FOLD_BLOCK=Rr;Lt.FOLD_FLOW=Qf;Lt.FOLD_QUOTED=Kn;Lt.foldFlowLines=Xf});var Ft=v(la=>{"use strict";var ae=q(),_e=ca(),Un=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Vn=t=>/^(%|---|\.\.\.)/m.test(t);function Zf(t,e,n){if(!e||e<0)return!1;let i=e-n,r=t.length;if(r<=i)return!1;for(let s=0,o=0;s<r;++s)if(t[s]===`
|
|
15
|
+
`){if(s-o>i)return!0;if(o=s+1,r-o<=i)return!1}return!0}function Dt(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:i}=e,r=e.options.doubleQuotedMinMultiLineLength,s=e.indent||(Vn(t)?" ":""),o="",a=0;for(let c=0,l=n[c];l;l=n[++c])if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(o+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(n[c+1]){case"u":{o+=n.slice(a,c);let d=n.substr(c+2,4);switch(d){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:d.substr(0,2)==="00"?o+="\\x"+d.substr(2):o+=n.substr(c,6)}c+=5,a=c+1}break;case"n":if(i||n[c+2]==='"'||n.length<r)c+=1;else{for(o+=n.slice(a,c)+`
|
|
16
16
|
|
|
17
17
|
`;n[c+2]==="\\"&&n[c+3]==="n"&&n[c+4]!=='"';)o+=`
|
|
18
|
-
`,c+=2;o+=s,n[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+n.slice(a):n,i?o:_e.foldFlowLines(o,s,_e.FOLD_QUOTED,Un(e,!1))}function
|
|
18
|
+
`,c+=2;o+=s,n[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+n.slice(a):n,i?o:_e.foldFlowLines(o,s,_e.FOLD_QUOTED,Un(e,!1))}function Nr(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
19
19
|
`)||/[ \t]\n|\n[ \t]/.test(t))return Dt(t,e);let n=e.indent||(Vn(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
20
|
-
${n}`)+"'";return e.implicitKey?i:_e.foldFlowLines(i,n,_e.FOLD_FLOW,Un(e,!1))}function mt(t,e){let{singleQuote:n}=e.options,i;if(n===!1)i=Dt;else{let r=t.includes('"'),s=t.includes("'");r&&!s?i=
|
|
20
|
+
${n}`)+"'";return e.implicitKey?i:_e.foldFlowLines(i,n,_e.FOLD_FLOW,Un(e,!1))}function mt(t,e){let{singleQuote:n}=e.options,i;if(n===!1)i=Dt;else{let r=t.includes('"'),s=t.includes("'");r&&!s?i=Nr:s&&!r?i=Dt:i=n?Nr:Dt}return i(t,e)}var Or;try{Or=new RegExp(`(^|(?<!
|
|
21
21
|
))
|
|
22
22
|
+(?!
|
|
23
|
-
|$)`,"g")}catch{
|
|
23
|
+
|$)`,"g")}catch{Or=/\n+(?!\n|$)/g}function Yn({comment:t,type:e,value:n},i,r,s){let{blockQuote:o,commentString:a,lineWidth:c}=i.options;if(!o||/\n[\t ]+$/.test(n))return mt(n,i);let l=i.indent||(i.forceBlockIndent||Vn(n)?" ":""),d=o==="literal"?!0:o==="folded"||e===ae.Scalar.BLOCK_FOLDED?!1:e===ae.Scalar.BLOCK_LITERAL?!0:!Zf(n,c,l.length);if(!n)return d?`|
|
|
24
24
|
`:`>
|
|
25
|
-
`;let u,
|
|
26
|
-
`&&x!==" "&&x!==" ")break}let h=n.substring(
|
|
25
|
+
`;let u,f;for(f=n.length;f>0;--f){let x=n[f-1];if(x!==`
|
|
26
|
+
`&&x!==" "&&x!==" ")break}let h=n.substring(f),w=h.indexOf(`
|
|
27
27
|
`);w===-1?u="-":n===h||w!==h.length-1?(u="+",s&&s()):u="",h&&(n=n.slice(0,-h.length),h[h.length-1]===`
|
|
28
|
-
`&&(h=h.slice(0,-1)),h=h.replace(
|
|
29
|
-
`)g=m;else break}let y=n.substring(0,g<m?g+1:m);y&&(n=n.substring(y.length),y=y.replace(/\n+/g,`$&${l}`));let C=(p?l?"2":"1":"")+u;if(t&&(C+=" "+a(t.replace(/ ?[\r\n]+/g," ")),r&&r()),!
|
|
28
|
+
`&&(h=h.slice(0,-1)),h=h.replace(Or,`$&${l}`));let p=!1,m,g=-1;for(m=0;m<n.length;++m){let x=n[m];if(x===" ")p=!0;else if(x===`
|
|
29
|
+
`)g=m;else break}let y=n.substring(0,g<m?g+1:m);y&&(n=n.substring(y.length),y=y.replace(/\n+/g,`$&${l}`));let C=(p?l?"2":"1":"")+u;if(t&&(C+=" "+a(t.replace(/ ?[\r\n]+/g," ")),r&&r()),!d){let x=n.replace(/\n+/g,`
|
|
30
30
|
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),P=!1,j=Un(i,!0);o!=="folded"&&e!==ae.Scalar.BLOCK_FOLDED&&(j.onOverflow=()=>{P=!0});let b=_e.foldFlowLines(`${y}${x}${h}`,l,_e.FOLD_BLOCK,j);if(!P)return`>${C}
|
|
31
31
|
${l}${b}`}return n=n.replace(/\n+/g,`$&${l}`),`|${C}
|
|
32
|
-
${l}${y}${n}${h}`}function
|
|
33
|
-
`)||
|
|
34
|
-
`)?mt(s,e):Yn(t,e,n,i);if(!a&&!
|
|
32
|
+
${l}${y}${n}${h}`}function ed(t,e,n,i){let{type:r,value:s}=t,{actualString:o,implicitKey:a,indent:c,indentStep:l,inFlow:d}=e;if(a&&s.includes(`
|
|
33
|
+
`)||d&&/[[\]{},]/.test(s))return mt(s,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return a||d||!s.includes(`
|
|
34
|
+
`)?mt(s,e):Yn(t,e,n,i);if(!a&&!d&&r!==ae.Scalar.PLAIN&&s.includes(`
|
|
35
35
|
`))return Yn(t,e,n,i);if(Vn(s)){if(c==="")return e.forceBlockIndent=!0,Yn(t,e,n,i);if(a&&c===l)return mt(s,e)}let u=s.replace(/\n+/g,`$&
|
|
36
|
-
${c}`);if(o){let
|
|
37
|
-
${e.indent}${a}`:a}
|
|
38
|
-
${a}:`):(m=`${m}:`,
|
|
36
|
+
${c}`);if(o){let f=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(u),{compat:h,tags:w}=e.doc.schema;if(w.some(f)||h?.some(f))return mt(s,e)}return a?u:_e.foldFlowLines(u,c,_e.FOLD_FLOW,Un(e,!1))}function td(t,e,n,i){let{implicitKey:r,inFlow:s}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==ae.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=ae.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case ae.Scalar.BLOCK_FOLDED:case ae.Scalar.BLOCK_LITERAL:return r||s?mt(o.value,e):Yn(o,e,n,i);case ae.Scalar.QUOTE_DOUBLE:return Dt(o.value,e);case ae.Scalar.QUOTE_SINGLE:return Nr(o.value,e);case ae.Scalar.PLAIN:return ed(o,e,n,i);default:return null}},l=c(a);if(l===null){let{defaultKeyType:d,defaultStringType:u}=e.options,f=r&&d||u;if(l=c(f),l===null)throw new Error(`Unsupported default string type ${f}`)}return l}la.stringifyString=td});var Mt=v(Ar=>{"use strict";var nd=Ln(),Pe=N(),id=qt(),rd=Ft();function sd(t,e){let n=Object.assign({blockQuote:!0,commentString:id.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 od(t,e){if(e.tag){let r=t.filter(s=>s.tag===e.tag);if(r.length>0)return r.find(s=>s.format===e.format)??r[0]}let n,i;if(Pe.isScalar(e)){i=e.value;let r=t.filter(s=>s.identify?.(i));if(r.length>1){let s=r.filter(o=>o.test);s.length>0&&(r=s)}n=r.find(s=>s.format===e.format)??r.find(s=>!s.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 ad(t,e,{anchors:n,doc:i}){if(!i.directives)return"";let r=[],s=(Pe.isScalar(t)||Pe.isCollection(t))&&t.anchor;s&&nd.anchorIsValid(s)&&(n.add(s),r.push(`&${s}`));let o=t.tag??(e.default?null:e.tag);return o&&r.push(i.directives.tagString(o)),r.join(" ")}function cd(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,s=Pe.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>r=c});r??(r=od(e.doc.schema.tags,s));let o=ad(s,r,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof r.stringify=="function"?r.stringify(s,e,n,i):Pe.isScalar(s)?rd.stringifyString(s,e,n,i):s.toString(e,n,i);return o?Pe.isScalar(s)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
37
|
+
${e.indent}${a}`:a}Ar.createStringifyContext=sd;Ar.stringify=cd});var pa=v(da=>{"use strict";var we=N(),ua=q(),fa=Mt(),Wt=qt();function ld({key:t,value:e},n,i,r){let{allNullValues:s,doc:o,indent:a,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:u}}=n,f=we.isNode(t)&&t.comment||null;if(u){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(we.isCollection(t)||!we.isNode(t)&&typeof t=="object"){let j="With simple keys, collection cannot be used as a key value";throw new Error(j)}}let h=!u&&(!t||f&&e==null&&!n.inFlow||we.isCollection(t)||(we.isScalar(t)?t.type===ua.Scalar.BLOCK_FOLDED||t.type===ua.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(u||!s),indent:a+c});let w=!1,p=!1,m=fa.stringify(t,n,()=>w=!0,()=>p=!0);if(!h&&!n.inFlow&&m.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(n.inFlow){if(s||e==null)return w&&i&&i(),m===""?"?":h?`? ${m}`:m}else if(s&&!u||e==null&&h)return m=`? ${m}`,f&&!w?m+=Wt.lineComment(m,n.indent,l(f)):p&&r&&r(),m;w&&(f=null),h?(f&&(m+=Wt.lineComment(m,n.indent,l(f))),m=`? ${m}
|
|
38
|
+
${a}:`):(m=`${m}:`,f&&(m+=Wt.lineComment(m,n.indent,l(f))));let g,y,k;we.isNode(e)?(g=!!e.spaceBefore,y=e.commentBefore,k=e.comment):(g=!1,y=null,k=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!h&&!f&&we.isScalar(e)&&(n.indentAtStart=m.length+1),p=!1,!d&&c.length>=2&&!n.inFlow&&!h&&we.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let C=!1,x=fa.stringify(e,n,()=>C=!0,()=>p=!0),P=" ";if(f||g||y){if(P=g?`
|
|
39
39
|
`:"",y){let j=l(y);P+=`
|
|
40
40
|
${Wt.indentComment(j,n.indent)}`}x===""&&!n.inFlow?P===`
|
|
41
41
|
`&&k&&(P=`
|
|
@@ -44,86 +44,86 @@ ${Wt.indentComment(j,n.indent)}`}x===""&&!n.inFlow?P===`
|
|
|
44
44
|
${n.indent}`}else if(!h&&we.isCollection(e)){let j=x[0],b=x.indexOf(`
|
|
45
45
|
`),M=b!==-1,Ce=n.inFlow??e.flow??e.items.length===0;if(M||!Ce){let ut=!1;if(M&&(j==="&"||j==="!")){let W=x.indexOf(" ");j==="&"&&W!==-1&&W<b&&x[W+1]==="!"&&(W=x.indexOf(" ",W+1)),(W===-1||b<W)&&(ut=!0)}ut||(P=`
|
|
46
46
|
${n.indent}`)}}else(x===""||x[0]===`
|
|
47
|
-
`)&&(P="");return m+=P+x,n.inFlow?C&&i&&i():k&&!C?m+=Wt.lineComment(m,n.indent,l(k)):p&&r&&r(),m}da.stringifyPair=
|
|
47
|
+
`)&&(P="");return m+=P+x,n.inFlow?C&&i&&i():k&&!C?m+=Wt.lineComment(m,n.indent,l(k)):p&&r&&r(),m}da.stringifyPair=ld});var Tr=v(jr=>{"use strict";var ma=jn("process");function ud(t,...e){t==="debug"&&console.log(...e)}function fd(t,e){(t==="debug"||t==="warn")&&(typeof ma.emitWarning=="function"?ma.emitWarning(e):console.warn(e))}jr.debug=ud;jr.warn=fd});var Qn=v(zn=>{"use strict";var Gn=N(),ha=q(),Jn="<<",Hn={identify:t=>t===Jn||typeof t=="symbol"&&t.description===Jn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ha.Scalar(Symbol(Jn)),{addToJSMap:ga}),stringify:()=>Jn},dd=(t,e)=>(Hn.identify(e)||Gn.isScalar(e)&&(!e.type||e.type===ha.Scalar.PLAIN)&&Hn.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===Hn.tag&&n.default);function ga(t,e,n){let i=wa(t,n);if(Gn.isSeq(i))for(let r of i.items)Ir(t,e,r);else if(Array.isArray(i))for(let r of i)Ir(t,e,r);else Ir(t,e,i)}function Ir(t,e,n){let i=wa(t,n);if(!Gn.isMap(i))throw new Error("Merge sources must be maps or map aliases");let r=i.toJSON(null,t,Map);for(let[s,o]of r)e instanceof Map?e.has(s)||e.set(s,o):e instanceof Set?e.add(s):Object.prototype.hasOwnProperty.call(e,s)||Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function wa(t,e){return t&&Gn.isAlias(e)?e.resolve(t.doc,t):e}zn.addMergeToJSMap=ga;zn.isMergeKey=dd;zn.merge=Hn});var qr=v(ba=>{"use strict";var pd=Tr(),ya=Qn(),md=Mt(),va=N(),$r=Ee();function hd(t,e,{key:n,value:i}){if(va.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,i);else if(ya.isMergeKey(t,n))ya.addMergeToJSMap(t,e,i);else{let r=$r.toJS(n,"",t);if(e instanceof Map)e.set(r,$r.toJS(i,r,t));else if(e instanceof Set)e.add(r);else{let s=gd(n,r,t),o=$r.toJS(i,s,t);s in e?Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[s]=o}}return e}function gd(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(va.isNode(t)&&n?.doc){let i=md.createStringifyContext(n.doc,{});i.anchors=new Set;for(let s of n.anchors.keys())i.anchors.add(s.anchor);i.inFlow=!0,i.inStringifyKey=!0;let r=t.toString(i);if(!n.mapKeyWarned){let s=JSON.stringify(r);s.length>40&&(s=s.substring(0,36)+'..."'),pd.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(e)}ba.addPairToJSMap=hd});var Re=v(Lr=>{"use strict";var ka=$t(),wd=pa(),yd=qr(),Xn=N();function vd(t,e,n){let i=ka.createNode(t,void 0,n),r=ka.createNode(e,void 0,n);return new Zn(i,r)}var Zn=class t{constructor(e,n=null){Object.defineProperty(this,Xn.NODE_TYPE,{value:Xn.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:i}=this;return Xn.isNode(n)&&(n=n.clone(e)),Xn.isNode(i)&&(i=i.clone(e)),new t(n,i)}toJSON(e,n){let i=n?.mapAsMap?new Map:{};return yd.addPairToJSMap(n,i,this)}toString(e,n,i){return e?.doc?wd.stringifyPair(this,e,n,i):JSON.stringify(this)}};Lr.Pair=Zn;Lr.createPair=vd});var Dr=v(Ca=>{"use strict";var Ge=N(),Sa=Mt(),ei=qt();function bd(t,e,n){return(e.inFlow??t.flow?Sd:kd)(t,e,n)}function kd({comment:t,items:e},n,{blockItemPrefix:i,flowChars:r,itemIndent:s,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:l}}=n,d=Object.assign({},n,{indent:s,type:null}),u=!1,f=[];for(let w=0;w<e.length;++w){let p=e[w],m=null;if(Ge.isNode(p))!u&&p.spaceBefore&&f.push(""),ti(n,f,p.commentBefore,u),p.comment&&(m=p.comment);else if(Ge.isPair(p)){let y=Ge.isNode(p.key)?p.key:null;y&&(!u&&y.spaceBefore&&f.push(""),ti(n,f,y.commentBefore,u))}u=!1;let g=Sa.stringify(p,d,()=>m=null,()=>u=!0);m&&(g+=ei.lineComment(g,s,l(m))),u&&m&&(u=!1),f.push(i+g)}let h;if(f.length===0)h=r.start+r.end;else{h=f[0];for(let w=1;w<f.length;++w){let p=f[w];h+=p?`
|
|
48
48
|
${c}${p}`:`
|
|
49
49
|
`}}return t?(h+=`
|
|
50
|
-
`+ei.indentComment(l(t),c),a&&a()):u&&o&&o(),h}function
|
|
51
|
-
`)),w<t.length-1?g+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((y,k)=>y+k.length+2,2)+(g.length+2)>e.options.lineWidth)),l&&(g+=",")),m&&(g+=ei.lineComment(g,i,a(m))),u.push(g),
|
|
50
|
+
`+ei.indentComment(l(t),c),a&&a()):u&&o&&o(),h}function Sd({items:t},e,{flowChars:n,itemIndent:i}){let{indent:r,indentStep:s,flowCollectionPadding:o,options:{commentString:a}}=e;i+=s;let c=Object.assign({},e,{indent:i,inFlow:!0,type:null}),l=!1,d=0,u=[];for(let w=0;w<t.length;++w){let p=t[w],m=null;if(Ge.isNode(p))p.spaceBefore&&u.push(""),ti(e,u,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&&u.push(""),ti(e,u,y.commentBefore,!1),y.comment&&(l=!0));let k=Ge.isNode(p.value)?p.value:null;k?(k.comment&&(m=k.comment),k.commentBefore&&(l=!0)):p.value==null&&y?.comment&&(m=y.comment)}m&&(l=!0);let g=Sa.stringify(p,c,()=>m=null);l||(l=u.length>d||g.includes(`
|
|
51
|
+
`)),w<t.length-1?g+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((y,k)=>y+k.length+2,2)+(g.length+2)>e.options.lineWidth)),l&&(g+=",")),m&&(g+=ei.lineComment(g,i,a(m))),u.push(g),d=u.length}let{start:f,end:h}=n;if(u.length===0)return f+h;if(!l){let w=u.reduce((p,m)=>p+m.length+2,2);l=e.options.lineWidth>0&&w>e.options.lineWidth}if(l){let w=f;for(let p of u)w+=p?`
|
|
52
52
|
${s}${r}${p}`:`
|
|
53
53
|
`;return`${w}
|
|
54
|
-
${r}${h}`}else return`${
|
|
55
|
-
`:" ")}return
|
|
54
|
+
${r}${h}`}else return`${f}${o}${u.join(" ")}${o}${h}`}function ti({indent:t,options:{commentString:e}},n,i,r){if(i&&r&&(i=i.replace(/^\n+/,"")),i){let s=ei.indentComment(e(i),t);n.push(s.trimStart())}}Ca.stringifyCollection=bd});var Oe=v(Mr=>{"use strict";var Cd=Dr(),Ed=qr(),xd=Wn(),Ne=N(),ni=Re(),_d=q();function Bt(t,e){let n=Ne.isScalar(e)?e.value:e;for(let i of t)if(Ne.isPair(i)&&(i.key===e||i.key===n||Ne.isScalar(i.key)&&i.key.value===n))return i}var Fr=class extends xd.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Ne.MAP,e),this.items=[]}static from(e,n,i){let{keepUndefined:r,replacer:s}=i,o=new this(e),a=(c,l)=>{if(typeof s=="function")l=s.call(n,c,l);else if(Array.isArray(s)&&!s.includes(c))return;(l!==void 0||r)&&o.items.push(ni.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"&&o.items.sort(e.sortMapEntries),o}add(e,n){let i;Ne.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new ni.Pair(e,e?.value):i=new ni.Pair(e.key,e.value);let r=Bt(this.items,i.key),s=this.schema?.sortMapEntries;if(r){if(!n)throw new Error(`Key ${i.key} already set`);Ne.isScalar(r.value)&&_d.isScalarValue(i.value)?r.value.value=i.value:r.value=i.value}else if(s){let o=this.items.findIndex(a=>s(i,a)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){let n=Bt(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let r=Bt(this.items,e)?.value;return(!n&&Ne.isScalar(r)?r.value:r)??void 0}has(e){return!!Bt(this.items,e)}set(e,n){this.add(new ni.Pair(e,n),!0)}toJSON(e,n,i){let r=i?new i:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(r);for(let s of this.items)Ed.addPairToJSMap(n,r,s);return r}toString(e,n,i){if(!e)return JSON.stringify(this);for(let r of this.items)if(!Ne.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})),Cd.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:n})}};Mr.YAMLMap=Fr;Mr.findPair=Bt});var ht=v(xa=>{"use strict";var Pd=N(),Ea=Oe(),Rd={collection:"map",default:!0,nodeClass:Ea.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Pd.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Ea.YAMLMap.from(t,e,n)};xa.map=Rd});var Ae=v(_a=>{"use strict";var Nd=$t(),Od=Dr(),Ad=Wn(),ri=N(),jd=q(),Td=Ee(),Wr=class extends Ad.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ri.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=ii(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let i=ii(e);if(typeof i!="number")return;let r=this.items[i];return!n&&ri.isScalar(r)?r.value:r}has(e){let n=ii(e);return typeof n=="number"&&n<this.items.length}set(e,n){let i=ii(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let r=this.items[i];ri.isScalar(r)&&jd.isScalarValue(n)?r.value=n:this.items[i]=n}toJSON(e,n){let i=[];n?.onCreate&&n.onCreate(i);let r=0;for(let s of this.items)i.push(Td.toJS(s,String(r++),n));return i}toString(e,n,i){return e?Od.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,s=new this(e);if(n&&Symbol.iterator in Object(n)){let o=0;for(let a of n){if(typeof r=="function"){let c=n instanceof Set?a:String(o++);a=r.call(n,c,a)}s.items.push(Nd.createNode(a,void 0,i))}}return s}};function ii(t){let e=ri.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}_a.YAMLSeq=Wr});var gt=v(Ra=>{"use strict";var Id=N(),Pa=Ae(),$d={collection:"seq",default:!0,nodeClass:Pa.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Id.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Pa.YAMLSeq.from(t,e,n)};Ra.seq=$d});var Kt=v(Na=>{"use strict";var qd=Ft(),Ld={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),qd.stringifyString(t,e,n,i)}};Na.string=Ld});var si=v(ja=>{"use strict";var Oa=q(),Aa={identify:t=>t==null,createNode:()=>new Oa.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Oa.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Aa.test.test(t)?t:e.options.nullStr};ja.nullTag=Aa});var Br=v(Ia=>{"use strict";var Dd=q(),Ta={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Dd.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Ta.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?n.options.trueStr:n.options.falseStr}};Ia.boolTag=Ta});var wt=v($a=>{"use strict";function Fd({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 s=Object.is(i,-0)?"-0":JSON.stringify(i);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let o=s.indexOf(".");o<0&&(o=s.length,s+=".");let a=e-(s.length-o-1);for(;a-- >0;)s+="0"}return s}$a.stringifyNumber=Fd});var Yr=v(oi=>{"use strict";var Md=q(),Kr=wt(),Wd={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:Kr.stringifyNumber},Bd={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():Kr.stringifyNumber(t)}},Kd={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 Md.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Kr.stringifyNumber};oi.float=Kd;oi.floatExp=Bd;oi.floatNaN=Wd});var Vr=v(ci=>{"use strict";var qa=wt(),ai=t=>typeof t=="bigint"||Number.isInteger(t),Ur=(t,e,n,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),n);function La(t,e,n){let{value:i}=t;return ai(i)&&i>=0?n+i.toString(e):qa.stringifyNumber(t)}var Yd={identify:t=>ai(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Ur(t,2,8,n),stringify:t=>La(t,8,"0o")},Ud={identify:ai,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Ur(t,0,10,n),stringify:qa.stringifyNumber},Vd={identify:t=>ai(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Ur(t,2,16,n),stringify:t=>La(t,16,"0x")};ci.int=Ud;ci.intHex=Vd;ci.intOct=Yd});var Fa=v(Da=>{"use strict";var Jd=ht(),Hd=si(),Gd=gt(),zd=Kt(),Qd=Br(),Jr=Yr(),Hr=Vr(),Xd=[Jd.map,Gd.seq,zd.string,Hd.nullTag,Qd.boolTag,Hr.intOct,Hr.int,Hr.intHex,Jr.floatNaN,Jr.floatExp,Jr.float];Da.schema=Xd});var Ba=v(Wa=>{"use strict";var Zd=q(),ep=ht(),tp=gt();function Ma(t){return typeof t=="bigint"||Number.isInteger(t)}var li=({value:t})=>JSON.stringify(t),np=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:li},{identify:t=>t==null,createNode:()=>new Zd.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:li},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:li},{identify:Ma,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})=>Ma(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:li}],ip={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},rp=[ep.map,tp.seq].concat(np,ip);Wa.schema=rp});var zr=v(Ka=>{"use strict";var Yt=jn("buffer"),Gr=q(),sp=Ft(),op={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Yt.Buffer=="function")return Yt.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,s){if(!n)return"";let o=n,a;if(typeof Yt.Buffer=="function")a=o instanceof Yt.Buffer?o.toString("base64"):Yt.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[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=Gr.Scalar.BLOCK_LITERAL),e!==Gr.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(a.length/c),d=new Array(l);for(let u=0,f=0;u<l;++u,f+=c)d[u]=a.substr(f,c);a=d.join(e===Gr.Scalar.BLOCK_LITERAL?`
|
|
55
|
+
`:" ")}return sp.stringifyString({comment:t,type:e,value:a},i,r,s)}};Ka.binary=op});var di=v(fi=>{"use strict";var ui=N(),Qr=Re(),ap=q(),cp=Ae();function Ya(t,e){if(ui.isSeq(t))for(let n=0;n<t.items.length;++n){let i=t.items[n];if(!ui.isPair(i)){if(ui.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let r=i.items[0]||new Qr.Pair(new ap.Scalar(null));if(i.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${i.commentBefore}
|
|
56
56
|
${r.key.commentBefore}`:i.commentBefore),i.comment){let s=r.value??r.key;s.comment=s.comment?`${i.comment}
|
|
57
|
-
${s.comment}`:i.comment}i=r}t.items[n]=ui.isPair(i)?i:new zr.Pair(i)}}else e("Expected a sequence for this tag");return t}function Ua(t,e,n){let{replacer:i}=n,r=new ap.YAMLSeq(t);r.tag="tag:yaml.org,2002:pairs";let s=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof i=="function"&&(o=i.call(e,String(s++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;r.items.push(zr.createPair(a,c,n))}return r}var cp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ya,createNode:Ua};fi.createPairs=Ua;fi.pairs=cp;fi.resolvePairs=Ya});var Zr=v(Xr=>{"use strict";var Va=N(),Qr=Ee(),Ut=Oe(),lp=Ae(),Ja=di(),Ge=class t extends lp.YAMLSeq{constructor(){super(),this.add=Ut.YAMLMap.prototype.add.bind(this),this.delete=Ut.YAMLMap.prototype.delete.bind(this),this.get=Ut.YAMLMap.prototype.get.bind(this),this.has=Ut.YAMLMap.prototype.has.bind(this),this.set=Ut.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 s,o;if(Va.isPair(r)?(s=Qr.toJS(r.key,"",n),o=Qr.toJS(r.value,s,n)):s=Qr.toJS(r,"",n),i.has(s))throw new Error("Ordered maps must not include duplicate keys");i.set(s,o)}return i}static from(e,n,i){let r=Ja.createPairs(e,n,i),s=new this;return s.items=r.items,s}};Ge.tag="tag:yaml.org,2002:omap";var up={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)Va.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)};Xr.YAMLOMap=Ge;Xr.omap=up});var Xa=v(es=>{"use strict";var Ha=q();function Ga({value:t,source:e},n){return e&&(t?za:Qa).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var za={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 Ha.Scalar(!0),stringify:Ga},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 Ha.Scalar(!1),stringify:Ga};es.falseTag=Qa;es.trueTag=za});var Za=v(pi=>{"use strict";var fp=q(),ts=wt(),dp={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:ts.stringifyNumber},pp={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():ts.stringifyNumber(t)}},mp={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 fp.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:ts.stringifyNumber};pi.float=mp;pi.floatExp=pp;pi.floatNaN=dp});var tc=v(Jt=>{"use strict";var ec=wt(),Vt=t=>typeof t=="bigint"||Number.isInteger(t);function mi(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 o=BigInt(t);return r==="-"?BigInt(-1)*o:o}let s=parseInt(t,n);return r==="-"?-1*s:s}function ns(t,e,n){let{value:i}=t;if(Vt(i)){let r=i.toString(e);return i<0?"-"+n+r.substr(1):n+r}return ec.stringifyNumber(t)}var hp={identify:Vt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>mi(t,2,2,n),stringify:t=>ns(t,2,"0b")},gp={identify:Vt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>mi(t,1,8,n),stringify:t=>ns(t,8,"0")},wp={identify:Vt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>mi(t,0,10,n),stringify:ec.stringifyNumber},yp={identify:Vt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>mi(t,2,16,n),stringify:t=>ns(t,16,"0x")};Jt.int=wp;Jt.intBin=hp;Jt.intHex=yp;Jt.intOct=gp});var rs=v(is=>{"use strict";var wi=N(),hi=Re(),gi=Oe(),ze=class t extends gi.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;wi.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new hi.Pair(e.key,null):n=new hi.Pair(e,null),gi.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let i=gi.findPair(this.items,e);return!n&&wi.isPair(i)?wi.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=gi.findPair(this.items,e);i&&!n?this.items.splice(this.items.indexOf(i),1):!i&&n&&this.items.push(new hi.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,s=new this(e);if(n&&Symbol.iterator in Object(n))for(let o of n)typeof r=="function"&&(o=r.call(n,o,o)),s.items.push(hi.createPair(o,null,i));return s}};ze.tag="tag:yaml.org,2002:set";var vp={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(wi.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}};is.YAMLSet=ze;is.set=vp});var os=v(yi=>{"use strict";var bp=wt();function ss(t,e){let n=t[0],i=n==="-"||n==="+"?t.substring(1):t,r=o=>e?BigInt(o):Number(o),s=i.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return n==="-"?r(-1)*s:s}function nc(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return bp.stringifyNumber(t);let i="";e<0&&(i="-",e*=n(-1));let r=n(60),s=[e%r];return e<60?s.unshift(0):(e=(e-s[0])/r,s.unshift(e%r),e>=60&&(e=(e-s[0])/r,s.unshift(e))),i+s.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var kp={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})=>ss(t,n),stringify:nc},Sp={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=>ss(t,!1),stringify:nc},ic={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(ic.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,r,s,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(n,i-1,r,s||0,o||0,a||0,c),f=e[8];if(f&&f!=="Z"){let u=ss(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$/,"")??""};yi.floatTime=Sp;yi.intTime=kp;yi.timestamp=ic});var oc=v(sc=>{"use strict";var Cp=ht(),Ep=si(),xp=gt(),_p=Kt(),Pp=Gr(),rc=Xa(),as=Za(),vi=tc(),Rp=Qn(),Np=Zr(),Op=di(),Ap=rs(),cs=os(),jp=[Cp.map,xp.seq,_p.string,Ep.nullTag,rc.trueTag,rc.falseTag,vi.intBin,vi.intOct,vi.int,vi.intHex,as.floatNaN,as.floatExp,as.float,Pp.binary,Rp.merge,Np.omap,Op.pairs,Ap.set,cs.intTime,cs.floatTime,cs.timestamp];sc.schema=jp});var gc=v(fs=>{"use strict";var uc=ht(),Tp=si(),fc=gt(),Ip=Kt(),$p=Wr(),ls=Kr(),us=Ur(),qp=Fa(),Lp=Ba(),dc=Gr(),Ht=Qn(),pc=Zr(),mc=di(),ac=oc(),hc=rs(),bi=os(),cc=new Map([["core",qp.schema],["failsafe",[uc.map,fc.seq,Ip.string]],["json",Lp.schema],["yaml11",ac.schema],["yaml-1.1",ac.schema]]),lc={binary:dc.binary,bool:$p.boolTag,float:ls.float,floatExp:ls.floatExp,floatNaN:ls.floatNaN,floatTime:bi.floatTime,int:us.int,intHex:us.intHex,intOct:us.intOct,intTime:bi.intTime,map:uc.map,merge:Ht.merge,null:Tp.nullTag,omap:pc.omap,pairs:mc.pairs,seq:fc.seq,set:hc.set,timestamp:bi.timestamp},Dp={"tag:yaml.org,2002:binary":dc.binary,"tag:yaml.org,2002:merge":Ht.merge,"tag:yaml.org,2002:omap":pc.omap,"tag:yaml.org,2002:pairs":mc.pairs,"tag:yaml.org,2002:set":hc.set,"tag:yaml.org,2002:timestamp":bi.timestamp};function Fp(t,e,n){let i=cc.get(e);if(i&&!t)return n&&!i.includes(Ht.merge)?i.concat(Ht.merge):i.slice();let r=i;if(!r)if(Array.isArray(t))r=[];else{let s=Array.from(cc.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${s} or define customTags array`)}if(Array.isArray(t))for(let s of t)r=r.concat(s);else typeof t=="function"&&(r=t(r.slice()));return n&&(r=r.concat(Ht.merge)),r.reduce((s,o)=>{let a=typeof o=="string"?lc[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(lc).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return s.includes(a)||s.push(a),s},[])}fs.coreKnownTags=Dp;fs.getTags=Fp});var ms=v(wc=>{"use strict";var ds=N(),Mp=ht(),Wp=gt(),Bp=Kt(),ki=gc(),Kp=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,ps=class t{constructor({compat:e,customTags:n,merge:i,resolveKnownTags:r,schema:s,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?ki.getTags(e,"compat"):e?ki.getTags(null,e):null,this.name=typeof s=="string"&&s||"core",this.knownTags=r?ki.coreKnownTags:{},this.tags=ki.getTags(n,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,ds.MAP,{value:Mp.map}),Object.defineProperty(this,ds.SCALAR,{value:Bp.string}),Object.defineProperty(this,ds.SEQ,{value:Wp.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Kp:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};wc.Schema=ps});var vc=v(yc=>{"use strict";var Yp=N(),hs=Mt(),Gt=qt();function Up(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=hs.createStringifyContext(t,e),{commentString:s}=r.options;if(t.commentBefore){n.length!==1&&n.unshift("");let c=s(t.commentBefore);n.unshift(Gt.indentComment(c,""))}let o=!1,a=null;if(t.contents){if(Yp.isNode(t.contents)){if(t.contents.spaceBefore&&i&&n.push(""),t.contents.commentBefore){let f=s(t.contents.commentBefore);n.push(Gt.indentComment(f,""))}r.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>o=!0,l=hs.stringify(t.contents,r,()=>a=null,c);a&&(l+=Gt.lineComment(l,"",s(a))),(l[0]==="|"||l[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${l}`:n.push(l)}else n.push(hs.stringify(t.contents,r));if(t.directives?.docEnd)if(t.comment){let c=s(t.comment);c.includes(`
|
|
57
|
+
${s.comment}`:i.comment}i=r}t.items[n]=ui.isPair(i)?i:new Qr.Pair(i)}}else e("Expected a sequence for this tag");return t}function Ua(t,e,n){let{replacer:i}=n,r=new cp.YAMLSeq(t);r.tag="tag:yaml.org,2002:pairs";let s=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof i=="function"&&(o=i.call(e,String(s++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;r.items.push(Qr.createPair(a,c,n))}return r}var lp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ya,createNode:Ua};fi.createPairs=Ua;fi.pairs=lp;fi.resolvePairs=Ya});var es=v(Zr=>{"use strict";var Va=N(),Xr=Ee(),Ut=Oe(),up=Ae(),Ja=di(),ze=class t extends up.YAMLSeq{constructor(){super(),this.add=Ut.YAMLMap.prototype.add.bind(this),this.delete=Ut.YAMLMap.prototype.delete.bind(this),this.get=Ut.YAMLMap.prototype.get.bind(this),this.has=Ut.YAMLMap.prototype.has.bind(this),this.set=Ut.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 s,o;if(Va.isPair(r)?(s=Xr.toJS(r.key,"",n),o=Xr.toJS(r.value,s,n)):s=Xr.toJS(r,"",n),i.has(s))throw new Error("Ordered maps must not include duplicate keys");i.set(s,o)}return i}static from(e,n,i){let r=Ja.createPairs(e,n,i),s=new this;return s.items=r.items,s}};ze.tag="tag:yaml.org,2002:omap";var fp={collection:"seq",identify:t=>t instanceof Map,nodeClass:ze,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)Va.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)};Zr.YAMLOMap=ze;Zr.omap=fp});var Xa=v(ts=>{"use strict";var Ha=q();function Ga({value:t,source:e},n){return e&&(t?za:Qa).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var za={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 Ha.Scalar(!0),stringify:Ga},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 Ha.Scalar(!1),stringify:Ga};ts.falseTag=Qa;ts.trueTag=za});var Za=v(pi=>{"use strict";var dp=q(),ns=wt(),pp={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:ns.stringifyNumber},mp={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():ns.stringifyNumber(t)}},hp={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 dp.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:ns.stringifyNumber};pi.float=hp;pi.floatExp=mp;pi.floatNaN=pp});var tc=v(Jt=>{"use strict";var ec=wt(),Vt=t=>typeof t=="bigint"||Number.isInteger(t);function mi(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 o=BigInt(t);return r==="-"?BigInt(-1)*o:o}let s=parseInt(t,n);return r==="-"?-1*s:s}function is(t,e,n){let{value:i}=t;if(Vt(i)){let r=i.toString(e);return i<0?"-"+n+r.substr(1):n+r}return ec.stringifyNumber(t)}var gp={identify:Vt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>mi(t,2,2,n),stringify:t=>is(t,2,"0b")},wp={identify:Vt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>mi(t,1,8,n),stringify:t=>is(t,8,"0")},yp={identify:Vt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>mi(t,0,10,n),stringify:ec.stringifyNumber},vp={identify:Vt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>mi(t,2,16,n),stringify:t=>is(t,16,"0x")};Jt.int=yp;Jt.intBin=gp;Jt.intHex=vp;Jt.intOct=wp});var ss=v(rs=>{"use strict";var wi=N(),hi=Re(),gi=Oe(),Qe=class t extends gi.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;wi.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new hi.Pair(e.key,null):n=new hi.Pair(e,null),gi.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let i=gi.findPair(this.items,e);return!n&&wi.isPair(i)?wi.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=gi.findPair(this.items,e);i&&!n?this.items.splice(this.items.indexOf(i),1):!i&&n&&this.items.push(new hi.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,s=new this(e);if(n&&Symbol.iterator in Object(n))for(let o of n)typeof r=="function"&&(o=r.call(n,o,o)),s.items.push(hi.createPair(o,null,i));return s}};Qe.tag="tag:yaml.org,2002:set";var bp={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(wi.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}};rs.YAMLSet=Qe;rs.set=bp});var as=v(yi=>{"use strict";var kp=wt();function os(t,e){let n=t[0],i=n==="-"||n==="+"?t.substring(1):t,r=o=>e?BigInt(o):Number(o),s=i.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return n==="-"?r(-1)*s:s}function nc(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return kp.stringifyNumber(t);let i="";e<0&&(i="-",e*=n(-1));let r=n(60),s=[e%r];return e<60?s.unshift(0):(e=(e-s[0])/r,s.unshift(e%r),e>=60&&(e=(e-s[0])/r,s.unshift(e))),i+s.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Sp={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})=>os(t,n),stringify:nc},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=>os(t,!1),stringify:nc},ic={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(ic.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,r,s,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(n,i-1,r,s||0,o||0,a||0,c),d=e[8];if(d&&d!=="Z"){let u=os(d,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};yi.floatTime=Cp;yi.intTime=Sp;yi.timestamp=ic});var oc=v(sc=>{"use strict";var Ep=ht(),xp=si(),_p=gt(),Pp=Kt(),Rp=zr(),rc=Xa(),cs=Za(),vi=tc(),Np=Qn(),Op=es(),Ap=di(),jp=ss(),ls=as(),Tp=[Ep.map,_p.seq,Pp.string,xp.nullTag,rc.trueTag,rc.falseTag,vi.intBin,vi.intOct,vi.int,vi.intHex,cs.floatNaN,cs.floatExp,cs.float,Rp.binary,Np.merge,Op.omap,Ap.pairs,jp.set,ls.intTime,ls.floatTime,ls.timestamp];sc.schema=Tp});var gc=v(ds=>{"use strict";var uc=ht(),Ip=si(),fc=gt(),$p=Kt(),qp=Br(),us=Yr(),fs=Vr(),Lp=Fa(),Dp=Ba(),dc=zr(),Ht=Qn(),pc=es(),mc=di(),ac=oc(),hc=ss(),bi=as(),cc=new Map([["core",Lp.schema],["failsafe",[uc.map,fc.seq,$p.string]],["json",Dp.schema],["yaml11",ac.schema],["yaml-1.1",ac.schema]]),lc={binary:dc.binary,bool:qp.boolTag,float:us.float,floatExp:us.floatExp,floatNaN:us.floatNaN,floatTime:bi.floatTime,int:fs.int,intHex:fs.intHex,intOct:fs.intOct,intTime:bi.intTime,map:uc.map,merge:Ht.merge,null:Ip.nullTag,omap:pc.omap,pairs:mc.pairs,seq:fc.seq,set:hc.set,timestamp:bi.timestamp},Fp={"tag:yaml.org,2002:binary":dc.binary,"tag:yaml.org,2002:merge":Ht.merge,"tag:yaml.org,2002:omap":pc.omap,"tag:yaml.org,2002:pairs":mc.pairs,"tag:yaml.org,2002:set":hc.set,"tag:yaml.org,2002:timestamp":bi.timestamp};function Mp(t,e,n){let i=cc.get(e);if(i&&!t)return n&&!i.includes(Ht.merge)?i.concat(Ht.merge):i.slice();let r=i;if(!r)if(Array.isArray(t))r=[];else{let s=Array.from(cc.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${s} or define customTags array`)}if(Array.isArray(t))for(let s of t)r=r.concat(s);else typeof t=="function"&&(r=t(r.slice()));return n&&(r=r.concat(Ht.merge)),r.reduce((s,o)=>{let a=typeof o=="string"?lc[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(lc).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return s.includes(a)||s.push(a),s},[])}ds.coreKnownTags=Fp;ds.getTags=Mp});var hs=v(wc=>{"use strict";var ps=N(),Wp=ht(),Bp=gt(),Kp=Kt(),ki=gc(),Yp=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,ms=class t{constructor({compat:e,customTags:n,merge:i,resolveKnownTags:r,schema:s,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?ki.getTags(e,"compat"):e?ki.getTags(null,e):null,this.name=typeof s=="string"&&s||"core",this.knownTags=r?ki.coreKnownTags:{},this.tags=ki.getTags(n,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,ps.MAP,{value:Wp.map}),Object.defineProperty(this,ps.SCALAR,{value:Kp.string}),Object.defineProperty(this,ps.SEQ,{value:Bp.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Yp:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};wc.Schema=ms});var vc=v(yc=>{"use strict";var Up=N(),gs=Mt(),Gt=qt();function Vp(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=gs.createStringifyContext(t,e),{commentString:s}=r.options;if(t.commentBefore){n.length!==1&&n.unshift("");let c=s(t.commentBefore);n.unshift(Gt.indentComment(c,""))}let o=!1,a=null;if(t.contents){if(Up.isNode(t.contents)){if(t.contents.spaceBefore&&i&&n.push(""),t.contents.commentBefore){let d=s(t.contents.commentBefore);n.push(Gt.indentComment(d,""))}r.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>o=!0,l=gs.stringify(t.contents,r,()=>a=null,c);a&&(l+=Gt.lineComment(l,"",s(a))),(l[0]==="|"||l[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${l}`:n.push(l)}else n.push(gs.stringify(t.contents,r));if(t.directives?.docEnd)if(t.comment){let c=s(t.comment);c.includes(`
|
|
58
58
|
`)?(n.push("..."),n.push(Gt.indentComment(c,""))):n.push(`... ${c}`)}else n.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||a)&&n[n.length-1]!==""&&n.push(""),n.push(Gt.indentComment(s(c),"")))}return n.join(`
|
|
59
59
|
`)+`
|
|
60
|
-
`}yc.stringifyDocument=
|
|
60
|
+
`}yc.stringifyDocument=Vp});var zt=v(bc=>{"use strict";var Jp=It(),yt=Wn(),re=N(),Hp=Re(),Gp=Ee(),zp=hs(),Qp=vc(),ws=Ln(),Xp=kr(),Zp=$t(),ys=br(),vs=class t{constructor(e,n,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,re.NODE_TYPE,{value:re.DOC});let r=null;typeof n=="function"||Array.isArray(n)?r=n:i===void 0&&n&&(i=n,n=void 0);let s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=s;let{version:o}=s;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new ys.Directives({version:o}),this.setSchema(o,i),this.contents=e===void 0?null:this.createNode(e,r,i)}clone(){let e=Object.create(t.prototype,{[re.NODE_TYPE]:{value:re.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=re.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){vt(this.contents)&&this.contents.add(e)}addIn(e,n){vt(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let i=ws.anchorNames(this);e.anchor=!n||i.has(n)?ws.findNewAnchor(n||"a",i):n}return new Jp.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,g=n.filter(m).map(String);g.length>0&&(n=n.concat(g)),r=n}else i===void 0&&n&&(i=n,n=void 0);let{aliasDuplicateObjects:s,anchorPrefix:o,flow:a,keepUndefined:c,onTagObj:l,tag:d}=i??{},{onAnchor:u,setAnchors:f,sourceObjects:h}=ws.createNodeAnchors(this,o||"a"),w={aliasDuplicateObjects:s??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:r,schema:this.schema,sourceObjects:h},p=Zp.createNode(e,d,w);return a&&re.isCollection(p)&&(p.flow=!0),f(),p}createPair(e,n,i={}){let r=this.createNode(e,null,i),s=this.createNode(n,null,i);return new Hp.Pair(r,s)}delete(e){return vt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return yt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):vt(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return re.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return yt.isEmptyPath(e)?!n&&re.isScalar(this.contents)?this.contents.value:this.contents:re.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return re.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return yt.isEmptyPath(e)?this.contents!==void 0:re.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=yt.collectionFromPath(this.schema,[e],n):vt(this.contents)&&this.contents.set(e,n)}setIn(e,n){yt.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=yt.collectionFromPath(this.schema,Array.from(e),n):vt(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 ys.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 ys.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 zp.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:s,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=Gp.toJS(this.contents,n??"",a);if(typeof s=="function")for(let{count:l,res:d}of a.anchors.values())s(d,l);return typeof o=="function"?Xp.applyReviver(o,{"":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 Qp.stringifyDocument(this,e)}};function vt(t){if(re.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}bc.Document=vs});var Zt=v(Xt=>{"use strict";var Qt=class extends Error{constructor(e,n,i,r){super(),this.name=e,this.code=i,this.message=r,this.pos=n}},bs=class extends Qt{constructor(e,n,i){super("YAMLParseError",e,n,i)}},ks=class extends Qt{constructor(e,n,i){super("YAMLWarning",e,n,i)}},em=(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 s=r-1,o=t.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(s>=60&&o.length>80){let a=Math.min(s-39,o.length-79);o="…"+o.substring(a),s-=a-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,s))){let a=t.substring(e.lineStarts[i-2],e.lineStarts[i-1]);a.length>80&&(a=a.substring(0,79)+`…
|
|
61
61
|
`),o=a+o}if(/[^ ]/.test(o)){let a=1,c=n.linePos[1];c?.line===i&&c.col>r&&(a=Math.max(1,Math.min(c.col-r,80-s)));let l=" ".repeat(s)+"^".repeat(a);n.message+=`:
|
|
62
62
|
|
|
63
63
|
${o}
|
|
64
64
|
${l}
|
|
65
|
-
`}};Xt.YAMLError=Qt;Xt.YAMLParseError=
|
|
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(
|
|
67
|
-
`+p.comment:a.comment=p.comment);continue}(p.newlineAfterProp||
|
|
68
|
-
`+k.comment:y.comment=k.comment);let C=new _c.Pair(y);n.options.keepSourceTokens&&(C.srcToken=
|
|
69
|
-
`+P.comment:l.comment=P.comment),u=P.end;continue}!o&&n.options.strict&&
|
|
70
|
-
`+j:b.comment=j,P.comment=P.comment.substring(j.length+1)}}if(!o&&!C&&!P.found){let j=x?t(n,x,P,r):e(n,P.end,C,null,P,r);l.items.push(j),u=j.range[2],
|
|
71
|
-
`+M.comment:b.comment=M.comment);let ut=new
|
|
72
|
-
`+m.comment:l.comment=m.comment),l.range=[i.offset,p,m.offset]}else l.range=[i.offset,p,p];return l}Lc.resolveFlowCollection=
|
|
73
|
-
`.repeat(Math.max(1,o.length-1)):"",m=i+r.length;return e.source&&(m+=e.source.length),{value:p,type:s,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||g[0]===" "?(
|
|
76
|
-
`:!h&&
|
|
77
|
-
`&&(
|
|
65
|
+
`}};Xt.YAMLError=Qt;Xt.YAMLParseError=bs;Xt.YAMLWarning=ks;Xt.prettifyError=em});var en=v(kc=>{"use strict";function tm(t,{flow:e,indicator:n,next:i,offset:r,onError:s,parentIndent:o,startOnNewline:a}){let c=!1,l=a,d=a,u="",f="",h=!1,w=!1,p=null,m=null,g=null,y=null,k=null,C=null,x=null;for(let b of t)switch(w&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&s(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),w=!1),p&&(l&&b.type!=="comment"&&b.type!=="newline"&&s(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),d=!0;break;case"comment":{d||s(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let M=b.source.substring(1)||" ";u?u+=f+M:u=M,f="",l=!1;break}case"newline":l?u?u+=b.source:(!C||n!=="seq-item-ind")&&(c=!0):f+=b.source,l=!0,h=!0,(m||g)&&(y=b),d=!0;break;case"anchor":m&&s(b,"MULTIPLE_ANCHORS","A node can have at most one anchor"),b.source.endsWith(":")&&s(b.offset+b.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=b,x??(x=b.offset),l=!1,d=!1,w=!0;break;case"tag":{g&&s(b,"MULTIPLE_TAGS","A node can have at most one tag"),g=b,x??(x=b.offset),l=!1,d=!1,w=!0;break}case n:(m||g)&&s(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),C&&s(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${e??"collection"}`),C=b,l=n==="seq-item-ind"||n==="explicit-key-ind",d=!1;break;case"comma":if(e){k&&s(b,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=b,l=!1,d=!1;break}default:s(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,d=!1}let P=t[t.length-1],j=P?P.offset+P.source.length:r;return w&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&s(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(l&&p.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&s(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:C,spaceBefore:c,comment:u,hasNewline:h,anchor:m,tag:g,newlineAfterProp:y,end:j,start:x??j}}kc.resolveProps=tm});var Si=v(Sc=>{"use strict";function Ss(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(Ss(e.key)||Ss(e.value))return!0}return!1;default:return!0}}Sc.containsNewline=Ss});var Cs=v(Cc=>{"use strict";var nm=Si();function im(t,e,n){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&nm.containsNewline(e)&&n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Cc.flowIndentCheck=im});var Es=v(xc=>{"use strict";var Ec=N();function rm(t,e,n){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let r=typeof i=="function"?i:(s,o)=>s===o||Ec.isScalar(s)&&Ec.isScalar(o)&&s.value===o.value;return e.some(s=>r(s.key,n))}xc.mapIncludes=rm});var Ac=v(Oc=>{"use strict";var _c=Re(),sm=Oe(),Pc=en(),om=Si(),Rc=Cs(),am=Es(),Nc="All mapping items must start at the same column";function cm({composeNode:t,composeEmptyNode:e},n,i,r,s){let o=s?.nodeClass??sm.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let c=i.offset,l=null;for(let d of i.items){let{start:u,key:f,sep:h,value:w}=d,p=Pc.resolveProps(u,{indicator:"explicit-key-ind",next:f??h?.[0],offset:c,onError:r,parentIndent:i.indent,startOnNewline:!0}),m=!p.found;if(m){if(f&&(f.type==="block-seq"?r(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==i.indent&&r(c,"BAD_INDENT",Nc)),!p.anchor&&!p.tag&&!h){l=p.end,p.comment&&(a.comment?a.comment+=`
|
|
67
|
+
`+p.comment:a.comment=p.comment);continue}(p.newlineAfterProp||om.containsNewline(f))&&r(f??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==i.indent&&r(c,"BAD_INDENT",Nc);n.atKey=!0;let g=p.end,y=f?t(n,f,p,r):e(n,g,u,null,p,r);n.schema.compat&&Rc.flowIndentCheck(i.indent,f,r),n.atKey=!1,am.mapIncludes(n,a.items,y)&&r(g,"DUPLICATE_KEY","Map keys must be unique");let k=Pc.resolveProps(h??[],{indicator:"map-value-ind",next:w,offset:y.range[2],onError:r,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=k.end,k.found){m&&(w?.type==="block-map"&&!k.hasNewline&&r(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&p.start<k.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 C=w?t(n,w,k,r):e(n,c,h,null,k,r);n.schema.compat&&Rc.flowIndentCheck(i.indent,w,r),c=C.range[2];let x=new _c.Pair(y,C);n.options.keepSourceTokens&&(x.srcToken=d),a.items.push(x)}else{m&&r(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(y.comment?y.comment+=`
|
|
68
|
+
`+k.comment:y.comment=k.comment);let C=new _c.Pair(y);n.options.keepSourceTokens&&(C.srcToken=d),a.items.push(C)}}return l&&l<c&&r(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[i.offset,c,l??c],a}Oc.resolveBlockMap=cm});var Tc=v(jc=>{"use strict";var lm=Ae(),um=en(),fm=Cs();function dm({composeNode:t,composeEmptyNode:e},n,i,r,s){let o=s?.nodeClass??lm.YAMLSeq,a=new o(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let c=i.offset,l=null;for(let{start:d,value:u}of i.items){let f=um.resolveProps(d,{indicator:"seq-item-ind",next:u,offset:c,onError:r,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||u)u?.type==="block-seq"?r(f.end,"BAD_INDENT","All sequence items must start at the same column"):r(c,"MISSING_CHAR","Sequence item without - indicator");else{l=f.end,f.comment&&(a.comment=f.comment);continue}let h=u?t(n,u,f,r):e(n,f.end,d,null,f,r);n.schema.compat&&fm.flowIndentCheck(i.indent,u,r),c=h.range[2],a.items.push(h)}return a.range=[i.offset,c,l??c],a}jc.resolveBlockSeq=dm});var bt=v(Ic=>{"use strict";function pm(t,e,n,i){let r="";if(t){let s=!1,o="";for(let a of t){let{source:c,type:l}=a;switch(l){case"space":s=!0;break;case"comment":{n&&!s&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";r?r+=o+d:r=d,o="";break}case"newline":r&&(o+=c),s=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:r,offset:e}}Ic.resolveEnd=pm});var Dc=v(Lc=>{"use strict";var mm=N(),hm=Re(),$c=Oe(),gm=Ae(),wm=bt(),qc=en(),ym=Si(),vm=Es(),xs="Block collections are not allowed within flow collections",_s=t=>t&&(t.type==="block-map"||t.type==="block-seq");function bm({composeNode:t,composeEmptyNode:e},n,i,r,s){let o=i.start.source==="{",a=o?"flow map":"flow sequence",c=s?.nodeClass??(o?$c.YAMLMap:gm.YAMLSeq),l=new c(n.schema);l.flow=!0;let d=n.atRoot;d&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let u=i.offset+i.start.source.length;for(let m=0;m<i.items.length;++m){let g=i.items[m],{start:y,key:k,sep:C,value:x}=g,P=qc.resolveProps(y,{flow:a,indicator:"explicit-key-ind",next:k??C?.[0],offset:u,onError:r,parentIndent:i.indent,startOnNewline:!1});if(!P.found){if(!P.anchor&&!P.tag&&!C&&!x){m===0&&P.comma?r(P.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):m<i.items.length-1&&r(P.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),P.comment&&(l.comment?l.comment+=`
|
|
69
|
+
`+P.comment:l.comment=P.comment),u=P.end;continue}!o&&n.options.strict&&ym.containsNewline(k)&&r(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)P.comma&&r(P.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(P.comma||r(P.start,"MISSING_CHAR",`Missing , between ${a} items`),P.comment){let j="";e:for(let b of y)switch(b.type){case"comma":case"space":break;case"comment":j=b.source.substring(1);break e;default:break e}if(j){let b=l.items[l.items.length-1];mm.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
|
|
70
|
+
`+j:b.comment=j,P.comment=P.comment.substring(j.length+1)}}if(!o&&!C&&!P.found){let j=x?t(n,x,P,r):e(n,P.end,C,null,P,r);l.items.push(j),u=j.range[2],_s(x)&&r(j.range,"BLOCK_IN_FLOW",xs)}else{n.atKey=!0;let j=P.end,b=k?t(n,k,P,r):e(n,j,y,null,P,r);_s(k)&&r(b.range,"BLOCK_IN_FLOW",xs),n.atKey=!1;let M=qc.resolveProps(C??[],{flow:a,indicator:"map-value-ind",next:x,offset:b.range[2],onError:r,parentIndent:i.indent,startOnNewline:!1});if(M.found){if(!o&&!P.found&&n.options.strict){if(C)for(let W of C){if(W===M.found)break;if(W.type==="newline"){r(W,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}P.start<M.found.offset-1024&&r(M.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else x&&("source"in x&&x.source?.[0]===":"?r(x,"MISSING_CHAR",`Missing space after : in ${a}`):r(M.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let Ce=x?t(n,x,M,r):M.found?e(n,M.end,C,null,M,r):null;Ce?_s(x)&&r(Ce.range,"BLOCK_IN_FLOW",xs):M.comment&&(b.comment?b.comment+=`
|
|
71
|
+
`+M.comment:b.comment=M.comment);let ut=new hm.Pair(b,Ce);if(n.options.keepSourceTokens&&(ut.srcToken=g),o){let W=l;vm.mapIncludes(n,W.items,b)&&r(j,"DUPLICATE_KEY","Map keys must be unique"),W.items.push(ut)}else{let W=new $c.YAMLMap(n.schema);W.flow=!0,W.items.push(ut);let Do=(Ce??b).range;W.range=[b.range[0],Do[1],Do[2]],l.items.push(W)}u=Ce?Ce.range[2]:M.end}}let f=o?"}":"]",[h,...w]=i.end,p=u;if(h?.source===f)p=h.offset+h.source.length;else{let m=a[0].toUpperCase()+a.substring(1),g=d?`${m} must end with a ${f}`:`${m} in block collection must be sufficiently indented and end with a ${f}`;r(u,d?"MISSING_CHAR":"BAD_INDENT",g),h&&h.source.length!==1&&w.unshift(h)}if(w.length>0){let m=wm.resolveEnd(w,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}Lc.resolveFlowCollection=bm});var Mc=v(Fc=>{"use strict";var km=N(),Sm=q(),Cm=Oe(),Em=Ae(),xm=Ac(),_m=Tc(),Pm=Dc();function Ps(t,e,n,i,r,s){let o=n.type==="block-map"?xm.resolveBlockMap(t,e,n,i,s):n.type==="block-seq"?_m.resolveBlockSeq(t,e,n,i,s):Pm.resolveFlowCollection(t,e,n,i,s),a=o.constructor;return r==="!"||r===a.tagName?(o.tag=a.tagName,o):(r&&(o.tag=r),o)}function Rm(t,e,n,i,r){let s=i.tag,o=s?e.directives.tagName(s.source,f=>r(s,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:h}=i,w=f&&s?f.offset>s.offset?f:s:f??s;w&&(!h||h.offset<w.offset)&&r(w,"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(!s||!o||o==="!"||o===Cm.YAMLMap.tagName&&a==="map"||o===Em.YAMLSeq.tagName&&a==="seq")return Ps(t,e,n,r,o);let c=e.schema.tags.find(f=>f.tag===o&&f.collection===a);if(!c){let f=e.schema.knownTags[o];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?r(s,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Ps(t,e,n,r,o)}let l=Ps(t,e,n,r,o,c),d=c.resolve?.(l,f=>r(s,"TAG_RESOLVE_FAILED",f),e.options)??l,u=km.isNode(d)?d:new Sm.Scalar(d);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Fc.composeCollection=Rm});var Ns=v(Wc=>{"use strict";var Rs=q();function Nm(t,e,n){let i=e.offset,r=Om(e,t.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};let s=r.mode===">"?Rs.Scalar.BLOCK_FOLDED:Rs.Scalar.BLOCK_LITERAL,o=e.source?Am(e.source):[],a=o.length;for(let p=o.length-1;p>=0;--p){let m=o[p][1];if(m===""||m==="\r")a=p;else break}if(a===0){let p=r.chomp==="+"&&o.length>0?`
|
|
73
|
+
`.repeat(Math.max(1,o.length-1)):"",m=i+r.length;return e.source&&(m+=e.source.length),{value:p,type:s,comment:r.comment,range:[i,m,m]}}let c=e.indent+r.indent,l=e.offset+r.length,d=0;for(let p=0;p<a;++p){let[m,g]=o[p];if(g===""||g==="\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),d=p,c===0&&!t.atRoot&&n(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+g.length+1}for(let p=o.length-1;p>=a;--p)o[p][0].length>c&&(a=p+1);let u="",f="",h=!1;for(let p=0;p<d;++p)u+=o[p][0].slice(c)+`
|
|
74
|
+
`;for(let p=d;p<a;++p){let[m,g]=o[p];l+=m.length+g.length+1;let y=g[g.length-1]==="\r";if(y&&(g=g.slice(0,-1)),g&&m.length<c){let C=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;n(l-g.length-(y?2:1),"BAD_INDENT",C),m=""}s===Rs.Scalar.BLOCK_LITERAL?(u+=f+m.slice(c)+g,f=`
|
|
75
|
+
`):m.length>c||g[0]===" "?(f===" "?f=`
|
|
76
|
+
`:!h&&f===`
|
|
77
|
+
`&&(f=`
|
|
78
78
|
|
|
79
|
-
`),u+=
|
|
80
|
-
`,h=!0):g===""?
|
|
79
|
+
`),u+=f+m.slice(c)+g,f=`
|
|
80
|
+
`,h=!0):g===""?f===`
|
|
81
81
|
`?u+=`
|
|
82
|
-
`:
|
|
83
|
-
`:(u+=
|
|
82
|
+
`:f=`
|
|
83
|
+
`:(u+=f+g,f=" ",h=!1)}switch(r.chomp){case"-":break;case"+":for(let p=a;p<o.length;++p)u+=`
|
|
84
84
|
`+o[p][0].slice(c);u[u.length-1]!==`
|
|
85
85
|
`&&(u+=`
|
|
86
86
|
`);break;default:u+=`
|
|
87
|
-
`}let w=i+r.length+e.source.length;return{value:u,type:s,comment:r.comment,range:[i,w,w]}}function
|
|
87
|
+
`}let w=i+r.length+e.source.length;return{value:u,type:s,comment:r.comment,range:[i,w,w]}}function Om({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],s=r[0],o=0,a="",c=-1;for(let f=1;f<r.length;++f){let h=r[f];if(!a&&(h==="-"||h==="+"))a=h;else{let w=Number(h);!o&&w?o=w:c===-1&&(c=t+f)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let l=!1,d="",u=r.length;for(let f=1;f<e.length;++f){let h=e[f];switch(h.type){case"space":l=!0;case"newline":u+=h.source.length;break;case"comment":n&&!l&&i(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=h.source.length,d=h.source.substring(1);break;case"error":i(h,"UNEXPECTED_TOKEN",h.message),u+=h.source.length;break;default:{let w=`Unexpected token in block scalar header: ${h.type}`;i(h,"UNEXPECTED_TOKEN",w);let p=h.source;p&&typeof p=="string"&&(u+=p.length)}}}return{mode:s,indent:o,chomp:a,comment:d,length:u}}function Am(t){let e=t.split(/\n( *)/),n=e[0],i=n.match(/^( *)/),s=[i?.[1]?[i[1],n.slice(i[1].length)]:["",n]];for(let o=1;o<e.length;o+=2)s.push([e[o],e[o+1]]);return s}Wc.resolveBlockScalar=Nm});var As=v(Kc=>{"use strict";var Os=q(),jm=bt();function Tm(t,e,n){let{offset:i,type:r,source:s,end:o}=t,a,c,l=(f,h,w)=>n(i+f,h,w);switch(r){case"scalar":a=Os.Scalar.PLAIN,c=Im(s,l);break;case"single-quoted-scalar":a=Os.Scalar.QUOTE_SINGLE,c=$m(s,l);break;case"double-quoted-scalar":a=Os.Scalar.QUOTE_DOUBLE,c=qm(s,l);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[i,i+s.length,i+s.length]}}let d=i+s.length,u=jm.resolveEnd(o,d,e,n);return{value:c,type:a,comment:u.comment,range:[i,d,u.offset]}}function Im(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}`),Bc(t)}function $m(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Bc(t.slice(1,-1)).replace(/''/g,"'")}function Bc(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],s=" ",o=e.lastIndex;for(n.lastIndex=o;i=n.exec(t);)i[1]===""?s===`
|
|
90
90
|
`?r+=s:s=`
|
|
91
|
-
`:(r+=s+i[1],s=" "),o=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(t),r+s+(i?.[1]??"")}function
|
|
91
|
+
`:(r+=s+i[1],s=" "),o=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(t),r+s+(i?.[1]??"")}function qm(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:s,offset:o}=
|
|
93
|
+
`){let{fold:s,offset:o}=Lm(t,i);n+=s,i=o}else if(r==="\\"){let s=t[++i],o=Dm[s];if(o)n+=o;else if(s===`
|
|
94
94
|
`)for(s=t[i+1];s===" "||s===" ";)s=t[++i+1];else if(s==="\r"&&t[i+1]===`
|
|
95
|
-
`)for(s=t[++i+1];s===" "||s===" ";)s=t[++i+1];else if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;n+=
|
|
95
|
+
`)for(s=t[++i+1];s===" "||s===" ";)s=t[++i+1];else if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;n+=Fm(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 s=i,o=t[i+1];for(;o===" "||o===" ";)o=t[++i+1];o!==`
|
|
96
96
|
`&&!(o==="\r"&&t[i+2]===`
|
|
97
|
-
`)&&(n+=i>s?t.slice(s,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>s?t.slice(s,i+1):r)}else n+=r}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function Lm(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 Dm={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Fm(t,e,n,i){let r=t.substr(e,n),o=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=t.substr(e-2,n+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Kc.resolveFlowScalar=Tm});var Vc=v(Uc=>{"use strict";var Xe=N(),Yc=q(),Mm=Ns(),Wm=As();function Bm(t,e,n,i){let{value:r,type:s,comment:o,range:a}=e.type==="block-scalar"?Mm.resolveBlockScalar(t,e,i):Wm.resolveFlowScalar(e,t.options.strict,i),c=n?t.directives.tagName(n.source,u=>i(n,"TAG_RESOLVE_FAILED",u)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Xe.SCALAR]:c?l=Km(t.schema,r,c,n,i):e.type==="scalar"?l=Ym(t,r,e,i):l=t.schema[Xe.SCALAR];let d;try{let u=l.resolve(r,f=>i(n??e,"TAG_RESOLVE_FAILED",f),t.options);d=Xe.isScalar(u)?u:new Yc.Scalar(u)}catch(u){let f=u instanceof Error?u.message:String(u);i(n??e,"TAG_RESOLVE_FAILED",f),d=new Yc.Scalar(r)}return d.range=a,d.source=r,s&&(d.type=s),c&&(d.tag=c),l.format&&(d.format=l.format),o&&(d.comment=o),d}function Km(t,e,n,i,r){if(n==="!")return t[Xe.SCALAR];let s=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(e))return a;let o=t.knownTags[n];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[Xe.SCALAR])}function Ym({atKey:t,directives:e,schema:n},i,r,s){let o=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(o.tag!==a.tag){let c=e.tagString(o.tag),l=e.tagString(a.tag),d=`Value may be parsed as either ${c} or ${l}`;s(r,"TAG_RESOLVE_FAILED",d,!0)}}return o}Uc.composeScalar=Bm});var Hc=v(Jc=>{"use strict";function Um(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}Jc.emptyScalarPosition=Um});var Qc=v(Ts=>{"use strict";var Vm=It(),Jm=N(),Hm=Mc(),Gc=Vc(),Gm=bt(),zm=Hc(),Qm={composeNode:zc,composeEmptyNode:js};function zc(t,e,n,i){let r=t.atKey,{spaceBefore:s,comment:o,anchor:a,tag:c}=n,l,d=!0;switch(e.type){case"alias":l=Xm(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=Gc.composeScalar(t,e,c,i),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Hm.composeCollection(Qm,t,e,n,i),a&&(l.anchor=a.source.substring(1))}catch(u){let f=u instanceof Error?u.message:String(u);i(e,"RESOURCE_EXHAUSTION",f)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",u),d=!1}}return l??(l=js(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&&(!Jm.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"),s&&(l.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?l.comment=o:l.commentBefore=o),t.options.keepSourceTokens&&d&&(l.srcToken=e),l}function js(t,e,n,i,{spaceBefore:r,comment:s,anchor:o,tag:a,end:c},l){let d={type:"scalar",offset:zm.emptyScalarPosition(e,n,i),indent:-1,source:""},u=Gc.composeScalar(t,d,a,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(u.spaceBefore=!0),s&&(u.comment=s,u.range[2]=c),u}function Xm({options:t},{offset:e,source:n,end:i},r){let s=new Vm.Alias(n.substring(1));s.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&r(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+n.length,a=Gm.resolveEnd(i,o,t.strict,r);return s.range=[e,o,a.offset],a.comment&&(s.comment=a.comment),s}Ts.composeEmptyNode=js;Ts.composeNode=zc});var el=v(Zc=>{"use strict";var Zm=zt(),Xc=Qc(),eh=bt(),th=en();function nh(t,e,{offset:n,start:i,value:r,end:s},o){let a=Object.assign({_directives:e},t),c=new Zm.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=th.resolveProps(i,{indicator:"doc-start",next:r??s?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=r?Xc.composeNode(l,r,d,o):Xc.composeEmptyNode(l,d.end,i,null,d,o);let u=c.contents.range[2],f=eh.resolveEnd(s,u,!1,o);return f.comment&&(c.comment=f.comment),c.range=[n,u,f.offset],c}Zc.composeDoc=nh});var $s=v(il=>{"use strict";var ih=jn("process"),rh=br(),sh=zt(),tn=Zt(),tl=N(),oh=el(),ah=bt();function nn(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 nl(t){let e="",n=!1,i=!1;for(let r=0;r<t.length;++r){let s=t[r];switch(s[0]){case"#":e+=(e===""?"":i?`
|
|
103
103
|
|
|
104
104
|
`:`
|
|
105
|
-
`)+(s.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
|
|
105
|
+
`)+(s.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 Is=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,i,r,s)=>{let o=nn(n);s?this.warnings.push(new tn.YAMLWarning(o,i,r)):this.errors.push(new tn.YAMLParseError(o,i,r))},this.directives=new rh.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:i,afterEmptyLine:r}=nl(this.prelude);if(i){let s=e.contents;if(n)e.comment=e.comment?`${e.comment}
|
|
106
106
|
${i}`:i;else if(r||e.directives.docStart||!s)e.commentBefore=i;else if(tl.isCollection(s)&&!s.flow&&s.items.length>0){let o=s.items[0];tl.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${i}
|
|
107
107
|
${a}`:i}else{let o=s.commentBefore;s.commentBefore=o?`${i}
|
|
108
|
-
${o}`:i}}if(n){for(let s=0;s<this.errors.length;++s)e.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)e.warnings.push(this.warnings[s])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:nl(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(
|
|
109
|
-
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new tn.YAMLParseError(nn(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
|
+
${o}`:i}}if(n){for(let s=0;s<this.errors.length;++s)e.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)e.warnings.push(this.warnings[s])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:nl(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(ih.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,i,r)=>{let s=nn(e);s[0]+=n,this.onError(s,"BAD_DIRECTIVE",i,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=oh.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 tn.YAMLParseError(nn(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 tn.YAMLParseError(nn(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let n=ah.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 tn.YAMLParseError(nn(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 sh.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}}};il.Composer=Is});var ol=v(Ci=>{"use strict";var ch=Ns(),lh=As(),uh=Zt(),rl=Ft();function fh(t,e=!0,n){if(t){let i=(r,s,o)=>{let a=typeof r=="number"?r:Array.isArray(r)?r[0]:r.offset;if(n)n(a,s,o);else throw new uh.YAMLParseError([a,a+1],s,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return lh.resolveFlowScalar(t,e,i);case"block-scalar":return ch.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function dh(t,e){let{implicitKey:n=!1,indent:i,inFlow:r=!1,offset:s=-1,type:o="PLAIN"}=e,a=rl.stringifyString({type:o,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
|
-
`,
|
|
113
|
-
`}),{type:"block-scalar",offset:s,indent:i,props:
|
|
111
|
+
`),d=a.substring(0,l),u=a.substring(l+1)+`
|
|
112
|
+
`,f=[{type:"block-scalar-header",offset:s,indent:i,source:d}];return sl(f,c)||f.push({type:"newline",offset:-1,indent:i,source:`
|
|
113
|
+
`}),{type:"block-scalar",offset:s,indent:i,props:f,source:u}}case'"':return{type:"double-quoted-scalar",offset:s,indent:i,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:s,indent:i,source:a,end:c};default:return{type:"scalar",offset:s,indent:i,source:a,end:c}}}function ph(t,e,n={}){let{afterKey:i=!1,implicitKey:r=!1,inFlow:s=!1,type:o}=n,a="indent"in t?t.indent:null;if(i&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=rl.stringifyString({type:o,value:e},{implicitKey:r||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":mh(t,c);break;case'"':qs(t,c,"double-quoted-scalar");break;case"'":qs(t,c,"single-quoted-scalar");break;default:qs(t,c,"scalar")}}function mh(t,e){let n=e.indexOf(`
|
|
114
114
|
`),i=e.substring(0,n),r=e.substring(n+1)+`
|
|
115
115
|
`;if(t.type==="block-scalar"){let s=t.props[0];if(s.type!=="block-scalar-header")throw new Error("Invalid block scalar header");s.source=i,t.source=r}else{let{offset:s}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:s,indent:o,source:i}];sl(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
|
|
116
|
-
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:r})}}function sl(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
|
|
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(s=>s.type==="space"||s.type==="comment"||s.type==="newline"):[];for(let s of Object.keys(t))s!=="type"&&s!=="offset"&&delete t[s];Object.assign(t,{type:n,indent:i,source:e,end:r})}}}Ci.createScalarToken=
|
|
116
|
+
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:r})}}function sl(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 qs(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 s of i)s.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(s=>s.type==="space"||s.type==="comment"||s.type==="newline"):[];for(let s of Object.keys(t))s!=="type"&&s!=="offset"&&delete t[s];Object.assign(t,{type:n,indent:i,source:e,end:r})}}}Ci.createScalarToken=dh;Ci.resolveAsScalar=fh;Ci.setScalarValue=ph});var cl=v(al=>{"use strict";var hh=t=>"type"in t?xi(t):Ei(t);function xi(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=xi(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=Ei(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=Ei(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=Ei(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 Ei({start:t,key:e,sep:n,value:i}){let r="";for(let s of t)r+=s.source;if(e&&(r+=xi(e)),n)for(let s of n)r+=s.source;return i&&(r+=xi(i)),r}al.stringify=hh});var dl=v(fl=>{"use strict";var Ls=Symbol("break visit"),gh=Symbol("skip children"),ll=Symbol("remove item");function Ze(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),ul(Object.freeze([]),t,e)}Ze.BREAK=Ls;Ze.SKIP=gh;Ze.REMOVE=ll;Ze.itemAtPath=(t,e)=>{let n=t;for(let[i,r]of e){let s=n?.[i];if(s&&"items"in s)n=s.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 ul(t,e,n){let i=n(e,t);if(typeof i=="symbol")return i;for(let r of["key","value"]){let s=e[r];if(s&&"items"in s){for(let o=0;o<s.items.length;++o){let a=ul(Object.freeze(t.concat([[r,o]])),s.items[o],n);if(typeof a=="number")o=a-1;else{if(a===Ls)return Ls;a===ll&&(s.items.splice(o,1),o-=1)}}typeof i=="function"&&r==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}fl.visit=Ze});var _i=v(ee=>{"use strict";var Ds=ol(),wh=cl(),yh=dl(),Fs="\uFEFF",Ms="",Ws="",Bs="",vh=t=>!!t&&"items"in t,bh=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function kh(t){switch(t){case Fs:return"<BOM>";case Ms:return"<DOC>";case Ws:return"<FLOW_END>";case Bs:return"<SCALAR>";default:return JSON.stringify(t)}}function Sh(t){switch(t){case Fs:return"byte-order-mark";case Ms:return"doc-mode";case Ws:return"flow-error-end";case Bs: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}ee.createScalarToken=
|
|
120
|
-
`:case"\r":case" ":return!0;default:return!1}}var pl=new Set("0123456789ABCDEFabcdef"),
|
|
121
|
-
\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}ee.createScalarToken=Ds.createScalarToken;ee.resolveAsScalar=Ds.resolveAsScalar;ee.setScalarValue=Ds.setScalarValue;ee.stringify=wh.stringify;ee.visit=yh.visit;ee.BOM=Fs;ee.DOCUMENT=Ms;ee.FLOW_END=Ws;ee.SCALAR=Bs;ee.isCollection=vh;ee.isScalar=bh;ee.prettyToken=kh;ee.tokenType=Sh});var Us=v(ml=>{"use strict";var rn=_i();function ce(t){switch(t){case void 0:case" ":case`
|
|
120
|
+
`:case"\r":case" ":return!0;default:return!1}}var pl=new Set("0123456789ABCDEFabcdef"),Ch=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Pi=new Set(",[]{}"),Eh=new Set(` ,[]{}
|
|
121
|
+
\r `),Ks=t=>!t||Eh.has(t),Ys=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
125
|
`||i>=this.indentNext||!n&&!this.atEnd?e+i:-1}if(n==="-"||n==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&ce(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]===rn.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,i=e.indexOf("#");for(;i!==-1;){let s=e[i-1];if(s===" "||s===" "){n=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let s=e[n-1];if(s===" "||s===" ")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 rn.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==="...")&&ce(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&&!ce(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===":")&&ce(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(
|
|
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]===rn.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,i=e.indexOf("#");for(;i!==-1;){let s=e[i-1];if(s===" "||s===" "){n=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let s=e[n-1];if(s===" "||s===" ")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 rn.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==="...")&&ce(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&&!ce(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===":")&&ce(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(Ks),"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("..."))&&ce(r[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield rn.FLOW_END,yield*this.parseLineStart();let s=0;for(;r[s]===",";)s+=yield*this.pushCount(1),s+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s+=yield*this.pushIndicators(),r[s]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-s),"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(Ks),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ce(o)||o===",")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 s=0;for(;this.buffer[n-1-s]==="\\";)s+=1;if(s%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 s=this.continueScalar(r+1);if(s===-1)break;r=i.indexOf(`
|
|
128
128
|
`,s)}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=>ce(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,i;e:for(let s=this.pos;i=this.buffer[s];++s)switch(i){case" ":n+=1;break;case`
|
|
129
129
|
`:e=s,n=0;break;case"\r":{let o=this.buffer[s+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
@@ -133,40 +133,40 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
133
133
|
`&&s>=this.pos&&s+1+n>a)e=s;else break}while(!0);return yield rn.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 s=this.buffer[i+1];if(ce(s)||e&&Pi.has(s))break;n=i}else if(ce(r)){let s=this.buffer[i+1];if(r==="\r"&&(s===`
|
|
134
134
|
`?(i+=1,r=`
|
|
135
135
|
`,s=this.buffer[i+1]):n=i),s==="#"||e&&Pi.has(s))break;if(r===`
|
|
136
|
-
`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&Pi.has(r))break;n=i}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield rn.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(
|
|
136
|
+
`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&Pi.has(r))break;n=i}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield rn.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(Ks),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,i=this.charAt(1);if(ce(i)||n&&Pi.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(;!ce(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(Ch.has(n))n=this.buffer[++e];else if(n==="%"&&pl.has(this.buffer[e+1])&&pl.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)}};ml.Lexer=
|
|
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)}};ml.Lexer=Ys});var Js=v(hl=>{"use strict";var Vs=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 s=n+i>>1;this.lineStarts[s]<e?n=s+1:i=s}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}}}};hl.LineCounter=Vs});var Gs=v(bl=>{"use strict";var xh=jn("process"),gl=_i(),_h=Us();function je(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function wl(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 vl(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 Ri(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 kt(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 Ni(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 yl(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,vl(e.value)?e.value.end?Ni(e.value.end,e.sep):e.value.end=e.sep:Ni(e.start,e.sep),delete e.sep)}var Hs=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 _h.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,xh.env.LOG_TOKENS&&console.log("|",gl.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=gl.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"&&yl(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&&wl(r.start)===-1&&(n.indent===0||r.start.every(s=>s.type!=="comment"||s.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":{wl(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=Ri(this.peek(2)),i=kt(n),r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];let s={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]=s}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
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)){Ni(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",s=[];if(r&&n.sep&&!n.value){let o=[];for(let a=0;a<n.sep.length;++a){let c=n.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(s=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":r||n.value?(s.push(this.sourceToken),e.items.push({start:s}),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?(s.push(this.sourceToken),e.items.push({start:s,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:s,key:null,sep:[this.sourceToken]}]});else if(vl(n.key)&&!je(n.sep,"newline")){let o=kt(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:o,key:a,sep:c}]})}else s.length>0?n.sep=n.sep.concat(s,this.sourceToken):n.sep.push(this.sourceToken);else if(je(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=kt(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||r?e.items.push({start:s,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 o=this.flowScalar(this.type);r||n.value?(e.items.push({start:s,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.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:s});this.stack.push(o);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)){Ni(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=Ri(i),s=kt(r);yl(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:o}]};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=Ri(e),i=kt(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=Ri(e),i=kt(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())}}};bl.Parser=Js});var xl=v(on=>{"use strict";var kl=Is(),_h=zt(),sn=Zt(),Ph=jr(),Rh=N(),Nh=Vs(),Sl=Hs();function Cl(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Nh.LineCounter||null,prettyErrors:e}}function Oh(t,e={}){let{lineCounter:n,prettyErrors:i}=Cl(e),r=new Sl.Parser(n?.addNewLine),s=new kl.Composer(e),o=Array.from(s.compose(r.parse(t)));if(i&&n)for(let a of o)a.errors.forEach(sn.prettifyError(t,n)),a.warnings.forEach(sn.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},s.streamInfo())}function El(t,e={}){let{lineCounter:n,prettyErrors:i}=Cl(e),r=new Sl.Parser(n?.addNewLine),s=new kl.Composer(e),o=null;for(let a of s.compose(r.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new sn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(o.errors.forEach(sn.prettifyError(t,n)),o.warnings.forEach(sn.prettifyError(t,n))),o}function Ah(t,e,n){let i;typeof e=="function"?i=e:n===void 0&&e&&typeof e=="object"&&(n=e);let r=El(t,n);if(!r)return null;if(r.warnings.forEach(s=>Ph.warn(r.options.logLevel,s)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:i},n))}function jh(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 Rh.isDocument(t)&&!i?t.toString(n):new _h.Document(t,i,n).toString(n)}on.parse=Ah;on.parseAllDocuments=Oh;on.parseDocument=El;on.stringify=jh});var Ie=v(O=>{"use strict";var Th=Is(),Ih=zt(),$h=ms(),Gs=Zt(),qh=It(),Te=N(),Lh=Re(),Dh=q(),Fh=Oe(),Mh=Ae(),Wh=_i(),Bh=Ys(),Kh=Vs(),Yh=Hs(),Oi=xl(),_l=Ot();O.Composer=Th.Composer;O.Document=Ih.Document;O.Schema=$h.Schema;O.YAMLError=Gs.YAMLError;O.YAMLParseError=Gs.YAMLParseError;O.YAMLWarning=Gs.YAMLWarning;O.Alias=qh.Alias;O.isAlias=Te.isAlias;O.isCollection=Te.isCollection;O.isDocument=Te.isDocument;O.isMap=Te.isMap;O.isNode=Te.isNode;O.isPair=Te.isPair;O.isScalar=Te.isScalar;O.isSeq=Te.isSeq;O.Pair=Lh.Pair;O.Scalar=Dh.Scalar;O.YAMLMap=Fh.YAMLMap;O.YAMLSeq=Mh.YAMLSeq;O.CST=Wh;O.Lexer=Bh.Lexer;O.LineCounter=Kh.LineCounter;O.Parser=Yh.Parser;O.parse=Oi.parse;O.parseAllDocuments=Oi.parseAllDocuments;O.parseDocument=Oi.parseDocument;O.stringify=Oi.stringify;O.visit=_l.visit;O.visitAsync=_l.visitAsync});var Ai=G(()=>{"use strict"});function $e(t){return t!==0&&t!==0n&&t!=="0"}function ji(t,e){return $e(t.dev)&&$e(e.dev)&&$e(t.ino)&&$e(e.ino)}function ye(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 Ti=G(()=>{"use strict"});import{randomUUID as Uh}from"crypto";import{constants as Vh,promises as L}from"fs";import V from"path";async function zs(t,e){try{return await L.link(t,e),{linked:!0}}catch(n){let i=n.code;if(i!=="ENOTSUP"&&i!=="EOPNOTSUPP")throw n}return await L.copyFile(t,e,Vh.COPYFILE_EXCL),{linked:!1}}function St(t,e){let n=V.relative(t,e);return n===""||!V.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${V.sep}`)}function $i(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Jh(t,e){return ye(t,$i(e))}function Ii(t,e){let n=$i(t),i=$i(e);return ji(n,i)?ye(n,i):ye(n,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function qi(t){let e=await L.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 L.realpath(t),...$i(e)}}async function qe(t){for(let e of t){let n=await L.lstat(e.path);if(!n.isDirectory()||n.isSymbolicLink()||!Jh(e,n)||await L.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function Hh(t,e){let n=V.resolve(t),i=V.resolve(e);if(!St(n,i))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let r=[await qi(n)],s=V.relative(n,i).split(V.sep).filter(Boolean),o=n;for(let a of s){await qe(r),o=V.join(o,a);try{await L.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await qi(o);if(!St(r[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${o}`);r.push(c)}return await qe(r),r}async function Gh(t,e){let n=V.resolve(t),i=V.resolve(e);if(!St(n,i))throw new Error(`Contained file parent is outside its managed root: ${e}`);let r=[await qi(n)],s=V.relative(n,i).split(V.sep).filter(Boolean),o=n;for(let a of s){o=V.join(o,a);try{let c=await qi(o);if(!St(r[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${o}`);r.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await qe(r),r}async function Pl(t){let e;try{e=await L.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 zh(t,e,n){let i=V.dirname(t),r=await Hh(n.containedRoot,i),s=V.join(i,`.${V.basename(t)}.${Uh()}.tmp`),o,a;try{await n.beforeTemporaryOpen?.(),o=await L.open(s,"wx"),a=await o.stat();let[c,l]=await Promise.all([L.lstat(s),L.realpath(s)]);if(await qe(r),!c.isFile()||c.isSymbolicLink()||!Ii(a,c)||!St(r[0].realPath,l))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await o.writeFile(e,"utf8"):await o.writeFile(e),await o.sync(),!Ii(a,await o.stat()))throw new Error("Contained atomic write temporary file changed while writing");await o.close(),o=void 0,await n.beforeCommit?.(),await qe(r);let f=await L.lstat(s);if(!f.isFile()||f.isSymbolicLink()||!Ii(f,a))throw new Error("Contained atomic write temporary file changed before commit");n.exclusive?(await zs(s,t),await L.unlink(s)):await L.rename(s,t),await Pl(i)}catch(c){await o?.close();try{await qe(r),await L.rm(s,{force:!0})}catch{}throw c}}async function me(t,e,n){await zh(t,e,n)}async function Qs(t,e){let n=V.dirname(t),i=await Gh(e.containedRoot,n);if(!i)return!1;let r,s;try{r=await L.lstat(t),s=await L.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!r.isFile()||r.isSymbolicLink()||!St(i[0].realPath,s))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await qe(i);let[o,a]=await Promise.all([L.lstat(t),L.realpath(t)]);if(!o.isFile()||o.isSymbolicLink()||!Ii(r,o)||a!==s)throw new Error("Contained file removal target changed before removal");return await L.unlink(t),await qe(i),await Pl(n),!0}var Ze=G(()=>{"use strict";Ti()});var Rl=G(()=>{"use strict"});var Xs=G(()=>{"use strict";Ai()});var Nl=G(()=>{"use strict";Ai();Xs()});import Li from"path";function ig(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||Li.posix.isAbsolute(n)||Li.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 an(t){let e=ig(t,"native.artifact_root");return e.length===0?".":e.join("/")}function jl(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 et(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||Li.posix.isAbsolute(i)||Li.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(s=>s===".."))throw new Error(`${e} must stay inside its declared path base`);if(r.some(s=>s===""||s==="."))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 cn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Tl(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 Il(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>eo)throw new Error(`${e} exceeds ${eo} 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>to)throw new Error(`${e} contains more than ${to} wildcard tokens`);return t}function Ol(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=>Il(i,e)))].sort((i,r)=>i.localeCompare(r,"en"))}function Zs(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 rg(t){if(t===void 0)return{...se,include:[...se.include],exclude:[...se.exclude]};let e=cn(t,"native.snapshot");return{include:Ol(e.include,"native.snapshot.include",se.include),exclude:Ol(e.exclude,"native.snapshot.exclude",se.exclude),max_files:Zs(e.max_files,se.max_files,"native.snapshot.max_files"),max_total_bytes:Zs(e.max_total_bytes,se.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Zs(e.max_duration_ms,se.max_duration_ms,"native.snapshot.max_duration_ms")}}function sg(t){if(t===void 0)return;let e=cn(t,"native.pending_root_move"),n=e.id,i=e.from_artifact_root,r=e.to_artifact_root,s=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(s!=="copying"&&s!=="ready"&&s!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(e.cleanup!==void 0){let a=cn(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");o={kind:c,state:l,manifestHash:f}}return{id:n,fromArtifactRoot:an(i),toArtifactRoot:an(r),stage:s,...o?{cleanup:o}:{}}}function og(t,e={}){let n=cn(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??"sequential";if(r!=="sequential"&&r!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let s=n.archive_confirmation??"automatic";if(s!=="automatic"&&s!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=n.max_verify_failures??Al;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let a=sg(n.pending_root_move);return{artifact_root:an(i),language:Tl(n.language,"en","native.language"),clarification_mode:r,archive_confirmation:s,max_verify_failures:o,snapshot:rg(n.snapshot),...a?{pending_root_move:a}:{}}}function ag(t){let e=cn(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:jl(e.artifact_layout),language:Tl(e.language,"zh-CN","classic.language"),context_compression:n,review_mode:i,auto_transition:r}}function cg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function lg(t,e,n,i,r){let s=t.schema!==void 0;if(!(s||t.default_workflow!==void 0||t.workflows!==void 0||!r.allowPartialProject&&t.native!==void 0)||r.allowPartialProject&&!s)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 a=t.workflows??[t.default_workflow];if(!Array.isArray(a)||a.length===0||a.some(l=>l!=="native"&&l!=="classic"))throw new Error("workflows must contain native and/or classic");let c=[...new Set(a)];if(!c.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(c.includes("native")&&!e)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:c,ambient_resume:i,...e?{native:e}:{},...n?{classic:n}:{}}}function Le(t,e={}){let n=(0,no.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,s=cg(r.ambient_resume),o=r.native===void 0?void 0:og(r.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),a=r.classic===void 0?void 0:ag(r.classic),c=lg(r,o,a,s,{allowPartialProject:e.allowPartialProject??!1});return{value:r,config:c,ambient_resume:s,...o?{native:o}:{},...a?{classic:a}:{}}}function io(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:an(t),language:e,clarification_mode:"sequential",archive_confirmation:"automatic",max_verify_failures:Al,snapshot:{...se,include:[...se.include],exclude:[...se.exclude]}}}}var no,Ct,eo,to,Al,ng,se,ve=G(()=>{"use strict";no=Ve(Ie(),1),Ct=64*1024,eo=1024,to=64,Al=5,ng=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],se={include:["**/*"],exclude:[...ng],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4}});import{constants as Di,promises as tt}from"fs";function ro(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function $l(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function ln(t){return{dev:t.dev,ino:t.ino,birthtime:ro(t)}}function Fi(t,e){let n=ln(t),i=ln(e);return ji(n,i)?ye(n,i):ye(n,i)&&ro(t)===ro(e)&&$l(t)===$l(e)&&t.size===e.size}async function ql(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,s=await tt.lstat(t,{bigint:r});if(!s.isFile()||s.isSymbolicLink())throw new De("not-regular-file",`${i} must be a regular file`);if(BigInt(s.size)>BigInt(e))throw new De("too-large",`${i} exceeds ${e} bytes`);let o=await tt.realpath(t);await n.verify?.("pre-open",{realPath:o,identity:ln(s)});let a=process.platform==="win32"?Di.O_RDONLY:Di.O_RDONLY|Di.O_NOFOLLOW|Di.O_NONBLOCK,c;try{c=await tt.open(t,a)}catch(l){throw l.code==="ELOOP"?new De("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,f,u]=await Promise.all([c.stat({bigint:r}),tt.lstat(t,{bigint:r}),tt.realpath(t)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||u!==o||!Fi(s,l)||!Fi(s,f))throw new De("changed",`${i} changed while opening`);await n.verify?.("post-open",{realPath:u,identity:ln(l)}),await n.hooks?.afterOpen?.();let d=[],h=0,w=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let y=e+1-h,{bytesRead:k}=await c.read(w,0,Math.min(w.length,y),null);if(k===0)break;if(h+=k,h>e)throw new De("too-large",`${i} exceeds ${e} bytes`);d.push(Buffer.from(w.subarray(0,k)))}await n.hooks?.beforeFinalCheck?.();let[p,m,g]=await Promise.all([c.stat({bigint:r}),tt.lstat(t,{bigint:r}),tt.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||g!==o||!Fi(s,p)||!Fi(s,m))throw new De("changed",`${i} changed while reading`);return await n.verify?.("post-read",{realPath:g,identity:ln(p)}),{bytes:Buffer.concat(d,h),stat:p,realPath:g}}finally{await c.close()}}var De,Ll=G(()=>{"use strict";Ti();De=class extends Error{reason;constructor(e,n,i){super(n,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Mi}from"fs";import Fe from"path";function ug(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function so(t,e){let n=Fe.relative(t,e);return n===""||!Fe.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${Fe.sep}`)}async function Dl(t,e){let n=Fe.resolve(t),i=await Mi.lstat(n);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Mi.realpath(n)}async function Fl(t,e,n,i){let r=t;for(let s=0;s<n.length;s++){r=Fe.join(r,n[s]);let o;try{o=await Mi.lstat(r)}catch(f){if(ug(f))return{exists:!1,kind:"missing"};throw f}let a=Fe.relative(t,r).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${a}`);let c=s===n.length-1;if(!c&&!o.isDirectory())throw new Error(`${i.label} ancestor ${a} must be a real directory`);if(c&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let l=await Mi.realpath(r);if(!so(e,l))throw new Error(`${i.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function D(t,e,n){let i=et(e,n.label),r=Fe.resolve(t),s=await Dl(r,n.label),o=i.split("/"),a=Fe.resolve(r,...o);if(!so(r,a))throw new Error(`${n.label} must stay inside the project root`);let c=await Fl(r,s,o,n);return{projectRoot:r,target:a,relative:i,exists:c.exists,kind:c.kind}}async function Wi(t,e,n){return(await D(t,e,{...n,expected:"file"})).exists}async function J(t,e,n,i){let r=await D(t,e,{label:i.label,expected:"file"});if(!r.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let s=await Dl(r.projectRoot,i.label);return ql(r.target,n,{...i,verify:async(o,a)=>{if(!so(s,a.realPath))throw new Error(`${i.label} resolves outside the project root`);await Fl(r.projectRoot,s,r.relative.split("/"),{label:i.label,expected:"file"})}})}var le=G(()=>{"use strict";Ll();ve()});function fg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function dg(t){let e=(0,Wl.parseDocument)(t,{uniqueKeys:!0});if(e.errors.length>0)throw new Error(`Invalid global Comet config: ${e.errors[0].message}`);let n=e.toJS();if(n==null)return{};if(typeof n!="object"||Array.isArray(n))throw new Error("Invalid global Comet config: root must be a mapping");return n}function Kl(t){if(t.native?.pending_root_move)throw new Error("Global Comet config cannot contain native.pending_root_move");let e=t.native?(({pending_root_move:n,...i})=>i)(t.native):void 0;return{...t,schema:"comet.global.v1",...e?{native:e}:{}}}function pg(t){let e=Le(JSON.stringify({...t,schema:"comet.project.v1"})).config;if(!e)throw new Error("Invalid global Comet config: workflow template is incomplete");return Kl(e)}function mg(t){let e=Le(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e.native&&!e.classic)return null;let n=e.native?"native":"classic",i=e.native?.language??e.classic?.language??"en",r=io(e.native?.artifact_root??"docs",i);return{schema:"comet.global.v1",default_workflow:n,workflows:[n],ambient_resume:e.ambient_resume,...e.native?{native:{...r.native,...e.native}}:{},...e.classic?{classic:e.classic}:{}}}function Yl(t){let e=dg(t);if(Object.keys(e).length===0)return null;if(e.schema===void 0)return mg(t);if(e.schema!=="comet.global.v1")throw new Error("Unsupported Comet global schema");return pg(e)}async function ao(t){try{let e=await J(t,Bl,Ct,{label:"global Comet config"});return Yl(e.bytes.toString("utf8"))}catch(e){if(fg(e))return null;throw e}}var Wl,Bl,co=G(()=>{"use strict";Wl=Ve(Ie(),1);Ze();ve();le();Bl=".comet/config.yaml"});import{createHash as hg}from"crypto";function gg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Me(t,e={}){return(await Bi(t,e)).document}async function wg(t){try{return(await J(t,un,Ct,{label:un})).bytes}catch(e){if(gg(e))return null;throw e}}function yg(t){return t?{exists:!0,sha256:hg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Bi(t,e={}){let n=await wg(t);return{document:n?Le(n.toString("utf8"),e):null,identity:yg(n)}}var un,nt=G(()=>{"use strict";ve();le();un=".comet/config.yaml"});var Nk,lo=G(()=>{"use strict";Ze();nt();le();Nk=16*1024});var uo=G(()=>{"use strict";Ze();ve();nt();le();lo()});var Vl=G(()=>{"use strict";Ai();Ze();Rl();Nl();ve();co();le();nt();uo();lo();Xs()});import{TextDecoder as Eg}from"util";function Jl(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function xg(t,e){try{return new Eg("utf-8",{fatal:!0}).decode(t.bytes)}catch(n){throw new Error(`${e} is not valid UTF-8`,{cause:n})}}async function fo(t,e,n,i,r={}){try{let s=await J(t,e,n,{label:i,hooks:r.hooks});return{result:s,text:xg(s,i)}}catch(s){let o=s.code;if(o==="ENOENT"||o==="ENOTDIR")return null;throw s}}async function fn(t,e,n,i,r={}){return(await fo(t,e,n,i,r))?.text??null}async function it(t,e,n,i,r,s={}){if(Buffer.byteLength(n,"utf8")>i)throw new Error(`${r} exceeds ${i} bytes`);let o=await fo(t,e,i,r),a=await D(t,e,{label:r,expected:"file"});await me(a.target,n,{containedRoot:a.projectRoot,beforeCommit:async()=>{await s.beforeCommit?.();let c=await fo(t,e,i,r);if(!(!o&&!c)){if(!o||!c)throw new Error(`${r} changed before commit`);if(o.result.realPath!==c.result.realPath||!ye(Jl(o.result.stat),Jl(c.result.stat))||o.text!==c.text)throw new Error(`${r} changed before commit`)}}})}async function Ki(t,e,n,i,r,s={}){let o=await fn(t,e,i,r);await it(t,e,`${o??""}${n}`,i,r,s)}async function po(t,e,n,i={}){let r=await D(t,e,{label:n,expected:"file"});return r.exists?Qs(r.target,{containedRoot:r.projectRoot,beforeRemove:i.beforeRemove}):!1}var Yi=G(()=>{"use strict";Vl();Ti()});var au={};gf(au,{RUN_STATE_FILE:()=>Zi,applyRunStateToDocument:()=>yo,readRunState:()=>vo,removeRunState:()=>bo,runStateFromDocument:()=>Xi,writeRunState:()=>er});import Zg from"path";function En(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 Cn(t,e){let n=En(t,e);if(Zg.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 ew(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 Xi(t){if(!t.run_id)return null;let e=En(t,"run_id"),n=En(t,"skill"),i=En(t,"skill_version"),r=En(t,"skill_hash"),s=Cn(t,"pending_ref"),o=Cn(t,"trajectory_ref"),a=Cn(t,"context_ref"),c=Cn(t,"artifacts_ref"),l=Cn(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:su(t,"current_step"),iteration:f,pending:su(t,"pending"),pendingRef:s,trajectoryRef:o,contextRef:a,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:ew(t)}}function yo(t,e){e?t.run_id=e.runId:delete t.run_id}function tw(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 nw(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 Xi(e)}async function vo(t,e={}){let n=await fn(t,Zi,ou,"Run state",e);if(n===null)return null;let i=JSON.parse(n);return nw(i)}async function er(t,e,n={}){await it(t,Zi,JSON.stringify(tw(e),null,2),ou,"Run state",n)}async function bo(t,e={}){await po(t,Zi,"Run state",e)}var su,Zi,ou,tr=G(()=>{"use strict";Yi();su=(t,e)=>{let n=t[e];return n==null?null:String(n)};Zi=".comet/run-state.json",ou=256*1024});var sf=Ve(Ie(),1);import{spawnSync as $y}from"child_process";import{createHash as rf}from"crypto";import{promises as qy}from"fs";import T from"path";import Ji from"path";Yi();import Ui from"path";var dn={trajectory:8*1024*1024,artifacts:1024*1024,context:1024*1024,pendingAction:256*1024,checkpoint:256*1024};function pn(t,e){if(Ui.isAbsolute(e))throw new Error("Run path must stay inside the change directory");let n=Ui.resolve(t),i=Ui.resolve(n,e);if(i!==n&&!i.startsWith(n+Ui.sep))throw new Error("Run path must stay inside the change directory")}async function mn(t,e,n,i={}){pn(t,e),await Ki(t,e,`${JSON.stringify(n)}
|
|
143
|
-
`,dn.trajectory,"Run trajectory",i)}async function Vi(t,e,n={}){pn(t,e);let i=await fn(t,e,dn.trajectory,"Run trajectory",n);return i===null?[]:i.split(/\r?\n/).map((r,s)=>({line:r,number:s+1})).filter(({line:r})=>r.length>0).map(({line:r,number:s})=>{try{return JSON.parse(r)}catch(o){throw new Error(`Invalid Trajectory event at line ${s}`,{cause:o})}})}async function Hl(t,e,n,i={}){pn(t,e),await
|
|
144
|
-
`,dn.artifacts,"Run artifacts",i)}async function Gl(t,e,n,i={}){pn(t,e),await
|
|
145
|
-
`,dn.checkpoint,"Run checkpoint",i)}function
|
|
146
|
-
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function wo(t){let e=vn(t);if(e)throw new Error(e)}function Fg(t,e){return{label:z(t,e),directory:e}}async function go(t,e,n){let i=Fg(t,e);if(!(await We(t,e,{label:n,expected:"directory"})).exists)return{change:i,exists:!1,stateExists:!1};let s=await We(t,Gi.join(e,".comet.yaml"),{label:`${n} state`,expected:"file"});return{change:i,exists:!0,stateExists:s.exists}}function Mg(t,e){let n=e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`^\\d{4}-\\d{2}-\\d{2}-${n}$`,"u").test(t)}async function Wg(t,e,n,i={}){if(!i.skipExactCompatibility){let o=await go(t,Gi.join(e,n),`Classic archived change ${n}`);if(o.exists)return o.change}if(!(await We(t,e,{label:"Classic archive directory",expected:"directory"})).exists)return null;let s=[];for(let o of await Dg.readdir(e,{withFileTypes:!0})){if(!Mg(o.name,n))continue;let a=await go(t,Gi.join(e,o.name),`Classic archived change ${o.name}`);a.exists&&a.stateExists&&s.push(a.change)}return s.sort((o,a)=>a.directory.localeCompare(o.directory))[0]??null}async function zi(t,e=process.cwd()){wo(t);let n=await rt(e),i=await go(n.projectRoot,Gi.join(n.changesDir,t),`Classic active change ${t}`);if(i.exists)return i.change;let r=await Wg(n.projectRoot,n.archiveDir,t);return r||i.change}function Bg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function iu(t,e,n,i){let r=et(n,"Classic handoff artifact pointer");if((await D(t,r,{label:"Classic handoff artifact",expected:"file"})).exists)return null;let o=await rt(t),a=`${z(t,o.changesDir)}/`,l=(o.artifactLayout==="docs"?[a,"openspec/changes/"]:[a]).find(y=>r.startsWith(y));if(!l)return null;let f=r.slice(l.length).split("/");if(f.length<4||f[1]!==".comet"||f.slice(2).some(y=>y.length===0))return null;let u=f[0];wo(u);let d=f.slice(2),h=bn.resolve(e);if(bn.dirname(h)!==bn.resolve(o.archiveDir))return null;let w=bn.basename(h),p=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(w);if(w!==u&&p?.[1]!==u)return null;await D(t,z(t,h),{label:"Classic archived change directory",expected:"directory"});let m=bn.join(h,".comet",...d),g=z(t,m);try{return await J(t,g,i,{label:"Historical Classic archived handoff artifact"}),g}catch(y){if(Bg(y))return null;throw y}}le();var ru=2*1024*1024;function kn(t,e){return be.relative(t,e).split(be.sep).join("/")}async function Sn(t,e,n){if(!n)return{code:e,satisfied:!1};let i=n.replaceAll("\\","/");try{let r=await Wi(t,i,{label:`${e} artifact`});return{code:e,satisfied:r,source:i,...r?{resolvedSource:i}:{}}}catch(r){return{code:e,satisfied:!1,source:i,detail:`unsafe artifact pointer outside the project or through a special path: ${r instanceof Error?r.message:String(r)}`}}}async function Yg(t,e,n){try{await rt(t)}catch(r){return{code:"design.handoff",satisfied:!1,...n?{source:n.replaceAll("\\","/")}:{},detail:`Classic layout is unsafe or unavailable for handoff evidence: ${r instanceof Error?r.message:String(r)}`}}let i=await Sn(t,"design.handoff",n);if(!n||i.satisfied||i.detail)return i;try{let r=await iu(t,e,n,ru);return r?{...i,satisfied:!0,resolvedSource:r,detail:`resolved historical legacy pointer from archived change: ${r}`}:i}catch(r){return{...i,satisfied:!1,detail:`unsafe archived handoff fallback: ${r instanceof Error?r.message:String(r)}`}}}async function Qi(t,e,n){return Sn(t,e,kn(t,n))}async function Ug(t,e){let n=be.join(e,"specs"),i;try{let o=kn(t,n);if(!(await D(t,o,{label:"OpenSpec delta-spec directory",expected:"directory"})).exists)return{code:"openspec.delta-spec",satisfied:!1};i=await Kg.readdir(n)}catch(o){return o.code==="ENOENT"?{code:"openspec.delta-spec",satisfied:!1}:{code:"openspec.delta-spec",satisfied:!1,detail:`unsafe delta-spec path: ${o instanceof Error?o.message:String(o)}`}}let r=i.map(o=>be.join(n,o,"spec.md")),s=(await Promise.all(r.map(async o=>{try{return await Wi(t,kn(t,o),{label:"OpenSpec delta spec"})?o:null}catch{return null}}))).filter(o=>o!==null);return{code:"openspec.delta-spec",satisfied:s.length>0,source:s[0]?kn(t,s[0]):void 0,detail:`${s.length} delta spec${s.length===1?"":"s"}`}}async function Vg(t,e){let n,i=kn(t,e);try{n=(await J(t,i,ru,{label:"Classic tasks artifact"})).bytes.toString("utf8")}catch(o){return o.code==="ENOENT"?{code:"build.tasks-complete",satisfied:!1}:{code:"build.tasks-complete",satisfied:!1,source:i,detail:`unsafe tasks artifact: ${o instanceof Error?o.message:String(o)}`}}let r=[...n.matchAll(/^\s*[-*]\s+\[([ xX])\]\s+/gmu)],s=r.filter(o=>o[1].toLowerCase()==="x").length;return{code:"build.tasks-complete",satisfied:r.length>0&&s===r.length,source:i,detail:`${s} of ${r.length} tasks complete`}}function ot(t,e){return t.some(n=>n.code===e&&n.satisfied)}async function Be(t,e){let n=await st(t),i=e.classic,r=be.join(t,"proposal.md"),s=be.join(t,"design.md"),o=be.join(t,"tasks.md"),a=e.run?be.resolve(t,e.run.checkpointRef):be.join(t,".comet","checkpoint.json"),c=await Promise.all([Qi(n,"openspec.proposal",r),Qi(n,"openspec.design",s),Qi(n,"openspec.tasks",o),Ug(n,t),Sn(n,"design.document",i?.designDoc??null),Sn(n,"build.plan",i?.plan??null),Vg(n,o),Sn(n,"verification.report",i?.verificationReport??null),Yg(n,t,i?.handoffContext??null),Qi(n,"run.checkpoint",a)]),l=c.find(f=>f.code==="design.handoff");return l&&!i?.handoffHash&&(l.satisfied=!1,l.detail="handoff hash is missing"),c.push({code:"archive.confirmed",satisfied:i?.archiveConfirmation==="confirmed"}),c}import{promises as qu}from"fs";import ie from"path";import{fileURLToPath as Lu}from"url";import{createHash as Hw,randomUUID as Gw}from"crypto";import{promises as Ro}from"fs";import ke from"path";function Jg(t){return t.classicProfile??t.workflow}function Hg(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 Gg(t){return t.buildMode==="direct"&&t.tddMode==="direct"&&t.isolation!==null&&t.verifyMode==="light"}function zg(t,e,n){if(e.verifyResult==="fail")return t==="full"?"full.build.fix":`${t}.build.execute`;if(t==="full"){if(!ot(n,"build.plan"))return"full.build.plan";if(e.buildPause==="plan-ready")return"full.build.plan-ready";if(!Hg(e))return"full.build.configure"}else if(!Gg(e))throw new Error(`${t} build configuration is incomplete`);return ot(n,"build.tasks-complete")?`${t}.build.complete`:`${t}.build.execute`}function Qg(t,e,n){return e.verifyResult!=="pass"||!ot(n,"verification.report")?`${t}.verify.run`:`${t}.verify.branch`}function Xg(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 Et(t,e){let n=Jg(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 ot(e,"design.handoff")?"full.design.document":"full.design.handoff";case"build":return zg(n,t,e);case"verify":return Qg(n,t,e);case"archive":return Xg(n,t)}}var rr=Ve(Ie(),1);Ze();le();import ir from"path";tr();var cu=["full","hotfix","tweak"],at=1,iw=["open","design","build","verify","archive"],rw=["en","zh-CN"],sw=["off","beta"],ow=["subagent-driven-development","executing-plans","direct"],aw=["plan-ready"],cw=["confirmed"],lw=["tdd","direct"],uw=["off","standard","thorough"],fw=["current","branch","worktree"],dw=["light","full"],pw=["pending","pass","fail"],mw=["pending","handled"],hw=["pending","confirmed"],_t=["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"],So=["run_id"],gw=new Set([..._t,...So]),ww=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function lu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function xt(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 Q(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 ko(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 yw(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 nr(t,e){let n=xt(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 vw(t,e){let n=xt(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 bw(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==at)throw new Error(`Invalid Classic state: classic_migration must be ${at}`);return e}function kw(t){if(!_t.some(n=>lu(t,n)))return null;for(let n of ww)if(!lu(t,n))return null;return{workflow:Q(t,"workflow",cu,!1),language:Q(t,"language",rw),phase:Q(t,"phase",iw,!1),contextCompression:Q(t,"context_compression",sw),buildMode:Q(t,"build_mode",ow),buildPause:Q(t,"build_pause",aw),subagentDispatch:Q(t,"subagent_dispatch",cw),tddMode:Q(t,"tdd_mode",lw),reviewMode:Q(t,"review_mode",uw),isolation:Q(t,"isolation",fw),boundBranch:xt(t,"bound_branch"),verifyMode:Q(t,"verify_mode",dw),autoTransition:ko(t,"auto_transition"),baseRef:xt(t,"base_ref"),designDoc:nr(t,"design_doc"),plan:nr(t,"plan"),verifyResult:Q(t,"verify_result",pw,!1),verifyFailures:yw(t,"verify_failures"),verificationReport:nr(t,"verification_report"),branchStatus:Q(t,"branch_status",mw),createdAt:xt(t,"created_at"),verifiedAt:xt(t,"verified_at"),archiveConfirmation:Q(t,"archive_confirmation",hw),archived:ko(t,"archived",!1),directOverride:ko(t,"direct_override"),handoffContext:nr(t,"handoff_context"),handoffHash:vw(t,"handoff_hash"),classicProfile:Q(t,"classic_profile",cu),classicMigration:bw(t)}}function Co(t,e){let n=e??null;if(n===null&&e===void 0&&t.run_id&&t.skill)try{n=Xi(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:kw(t),run:n,unknownKeys:Object.keys(t).filter(i=>!gw.has(i))}}function uu(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}}tr();var Sw=2*1024*1024;function xn(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 fu(t,e,n){t.get(e)!==n&&t.set(e,n)}function Cw(t,e){if(e.classic)for(let[n,i]of Object.entries(uu(e.classic)))fu(t,n,i);else for(let n of _t)t.delete(n);yo(t.toJS(),e.run),e.run?fu(t,"run_id",e.run.runId):t.delete("run_id")}function Ew(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 xw(t){let e=!1;for(let n of["build_command","verify_command"])t.has(n)&&(t.delete(n),e=!0);return e}async function du(t){let e;try{e=(await J(ir.dirname(t),ir.basename(t),Sw,{label:"Classic state document"})).bytes.toString("utf8")}catch(i){if(i.code!=="ENOENT")throw i;return new rr.Document({})}let n=(0,rr.parseDocument)(e);if(n.errors.length>0)throw new Error(`Invalid Classic state document: ${n.errors[0].message}`);return xn(n),n}async function Ke(t,e={}){let n=e.migrate!==!1,i=ir.join(t,".comet.yaml"),r=await du(i),s=xn(r),o=xw(r);o&&(s=xn(r));let a=await vo(t);if(!a&&s.run_id&&s.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(tr(),au));a=c(s),a&&n&&(await er(t,a),Ew(r),o=!0)}return o&&n&&await me(i,r.toString(),{containedRoot:t}),Co(xn(r),a)}async function sr(t,e,n={}){let i=ir.join(t,".comet.yaml"),r=await du(i);Cw(r,{...e,unknownKeys:e.unknownKeys??[]}),Co(xn(r),e.run??null),await me(i,r.toString(),{containedRoot:t,beforeCommit:n.beforeCommit}),e.run?await er(t,e.run):await bo(t)}function pu(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:{}}}import{createHash as Pu,randomUUID as Kw}from"crypto";import{promises as K}from"fs";import F from"path";var gu=Ve(Ie(),1);import{promises as Eo}from"fs";import oe from"path";var _w=["invoke_skill","call_tool","handoff","ask_user","checkpoint"],Pw=["deterministic","adaptive"],Rw=["function","mcp","script","agent"],Nw=["none","read","write","external"],Ow=["progress","step","completion"],Aw=["artifact_exists","state_equals"];function ct(t,e,n){return new Error(`${t}: ${e} ${n}`)}function ne(t,e,n="document"){if(t===null||typeof t!="object"||Array.isArray(t))throw ct(e,n,"must be an object")}function Ye(t,e,n){if(!Array.isArray(t))throw ct(e,n,"must be an array")}function X(t,e,n){if(typeof t!="string")throw ct(e,n,"must be a string")}function ue(t,e,n,i){e in t&&X(t[e],n,`${i}.${e}`)}function wu(t,e,n,i){if(e in t&&typeof t[e]!="boolean")throw ct(n,`${i}.${e}`,"must be a boolean")}function Ue(t,e,n,i){if(typeof t!="string"||!e.includes(t))throw ct(n,i,`must be one of ${e.join(", ")}`)}function or(t,e,n){Ye(t,e,n),t.forEach((i,r)=>{X(i,e,`${n}[${r}]`)})}function mu(t,e,n){ne(t,e,n),X(t.name,e,`${n}.name`),X(t.description,e,`${n}.description`),wu(t,"required",e,n)}function jw(t,e,n){ne(t,e,n),X(t.id,e,`${n}.id`),ue(t,"source",e,n),ue(t,"version",e,n)}function Tw(t,e,n){ne(t,e,n),X(t.id,e,`${n}.id`),X(t.role,e,`${n}.role`),ue(t,"instructions",e,n)}function Iw(t,e,n){ne(t,e,n),X(t.id,e,`${n}.id`),Ue(t.kind,Rw,e,`${n}.kind`),X(t.source,e,`${n}.source`),Ue(t.sideEffect,Nw,e,`${n}.sideEffect`),wu(t,"requiresConfirmation",e,n)}function $w(t,e,n){ne(t,e,n),Ue(t.type,_w,e,`${n}.type`),ue(t,"ref",e,n),ue(t,"prompt",e,n),ue(t,"question",e,n),"options"in t&&or(t.options,e,`${n}.options`)}function qw(t,e,n){ne(t,e,n),X(t.id,e,`${n}.id`),$w(t.action,e,`${n}.action`),ue(t,"next",e,n),"completionEvals"in t&&or(t.completionEvals,e,`${n}.completionEvals`)}function Lw(t,e){let n="goal";ne(t,e,n),X(t.statement,e,`${n}.statement`),Ye(t.inputs,e,`${n}.inputs`),t.inputs.forEach((i,r)=>{mu(i,e,`${n}.inputs[${r}]`)}),Ye(t.outputs,e,`${n}.outputs`),t.outputs.forEach((i,r)=>{mu(i,e,`${n}.outputs[${r}]`)}),or(t.success,e,`${n}.success`)}function Dw(t,e){let n="orchestration";ne(t,e,n),Ue(t.mode,Pw,e,`${n}.mode`),ue(t,"entry",e,n),"steps"in t&&(Ye(t.steps,e,`${n}.steps`),t.steps.forEach((i,r)=>{qw(i,e,`${n}.steps[${r}]`)}))}function yu(t,e){return ne(t,e),Ue(t.apiVersion,["comet/v1alpha1"],e,"apiVersion"),Ue(t.kind,["Skill"],e,"kind"),ne(t.metadata,e,"metadata"),X(t.metadata.name,e,"metadata.name"),X(t.metadata.version,e,"metadata.version"),X(t.metadata.description,e,"metadata.description"),Lw(t.goal,e),Dw(t.orchestration,e),Ye(t.skills,e,"skills"),t.skills.forEach((n,i)=>{jw(n,e,`skills[${i}]`)}),Ye(t.agents,e,"agents"),t.agents.forEach((n,i)=>{Tw(n,e,`agents[${i}]`)}),Ye(t.tools,e,"tools"),t.tools.forEach((n,i)=>{Iw(n,e,`tools[${i}]`)}),t}function vu(t,e){ne(t,e);for(let n of["allowedSkills","allowedAgents","allowedTools","confirmationRequiredFor"])n in t&&or(t[n],e,n);for(let n of["maxIterations","maxRetriesPerAction"])if(n in t&&(typeof t[n]!="number"||!Number.isFinite(t[n])))throw ct(e,n,"must be a finite number");return t}function Fw(t,e){return ne(t,e),"runtime"in t&&bu(t.runtime,e,"runtime"),t}function bu(t,e,n){return Ye(t,e,n),t.forEach((i,r)=>{let s=`${n}[${r}]`;ne(i,e,s),X(i.id,e,`${s}.id`),Ue(i.scope,Ow,e,`${s}.scope`),Ue(i.type,Aw,e,`${s}.type`),ue(i,"artifact",e,s),ue(i,"field",e,s),ue(i,"equals",e,s)}),t}async function xo(t){let e=await Eo.readFile(t,"utf8");try{return(0,gu.parse)(e)}catch(n){let i=n instanceof Error?n.message:String(n);throw ct(t,"document",i)}}async function Mw(t){try{return await xo(t)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function hu(t){try{return await Eo.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Ww(t){let e=oe.join(t,"checks.yaml"),n=oe.join(t,"evals.yaml"),[i,r]=await Promise.all([hu(e),hu(n)]);if(r)throw new Error(`${n}: evals.yaml is no longer supported; use checks.yaml`);return i?{document:Fw(await xo(e),e)}:{document:null}}async function ku(t){let e=oe.resolve(t.root),n=oe.resolve(t.controlRoot);t.requireSkillMarkdown&&await Eo.access(oe.join(e,"SKILL.md"));let i=oe.join(n,"skill.yaml"),r=oe.join(n,"guardrails.yaml"),s=yu(await xo(i),i),o=await Mw(r),a=o===null?null:vu(o,r),c=await Ww(n),l={allowedSkills:s.skills.map(f=>f.id),allowedAgents:s.agents.map(f=>f.id),allowedTools:s.tools.map(f=>f.id),maxIterations:50,maxRetriesPerAction:3,confirmationRequiredFor:s.tools.filter(f=>f.requiresConfirmation).map(f=>f.id)};return{root:e,packageKind:t.packageKind==="runtime"?"runtime":void 0,definition:s,guardrails:{...l,...a},evals:c.document?.runtime??[]}}async function Su(t){let e=oe.resolve(t);return ku({root:e,controlRoot:oe.join(e,"comet"),packageKind:"skill",requireSkillMarkdown:!0})}async function Cu(t){let e=oe.resolve(t);return ku({root:e,controlRoot:e,packageKind:"runtime",requireSkillMarkdown:!1})}function Eu(t,e,n=oe.join(e,"package.json")){ne(t,n);let i=t.packageKind==="runtime"?"runtime":void 0,r=yu(t.definition,n),s=vu(t.guardrails,n),o=bu(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:oe.resolve(e),packageKind:i,definition:r,guardrails:{...a,...s},evals:o}}import xu from"path";function Bw(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 _u(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 s=n.orchestration.steps??[];if(n.orchestration.mode==="adaptive")(n.orchestration.entry||s.length>0)&&e.push("adaptive orchestration must not define entry or steps");else{let o=new Set;for(let a of s)o.has(a.id)&&e.push(`duplicate step id: ${a.id}`),o.add(a.id),Bw(a.action,t,e,a.id);(!n.orchestration.entry||!o.has(n.orchestration.entry))&&e.push(`orchestration.entry references unknown step: ${n.orchestration.entry??"(missing)"}`);for(let a of s){a.next&&!o.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 o of n.tools){if(o.kind!=="script")continue;let a=xu.posix.normalize(o.source.replaceAll("\\","/"));(xu.isAbsolute(o.source)||a===".."||a.startsWith("../"))&&e.push(`script tool ${o.id} must reference a relative path inside the Skill package`)}for(let o of i.allowedSkills)n.skills.some(a=>a.id===o)||e.push(`guardrails allow undeclared skill: ${o}`);for(let o of i.allowedAgents)n.agents.some(a=>a.id===o)||e.push(`guardrails allow undeclared agent: ${o}`);for(let o of i.allowedTools)n.tools.some(a=>a.id===o)||e.push(`guardrails allow undeclared tool: ${o}`);return e}function ar(t){return Array.isArray(t)?t.map(ar):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,ar(n)])):t}function Yw(t){return ar({...t.packageKind==="runtime"?{packageKind:"runtime"}:{},definition:t.definition,guardrails:t.guardrails,evals:t.evals})}function Uw(t){return F.posix.normalize(t.replaceAll("\\","/"))}function Pt(t,e,n){let i=F.relative(t,e);if(!(i===""||!F.isAbsolute(i)&&!i.startsWith(`..${F.sep}`)))throw new Error(`${n} resolves outside the Skill package`)}async function Ru(t,e,n){let i=Uw(e);if(F.posix.isAbsolute(i)||i===".."||i.startsWith("../"))throw new Error(`${n} resolves outside the Skill package`);let r=F.resolve(t,...i.split("/"));Pt(t,r,n);let s;try{s=await K.realpath(r)}catch(o){throw o.code==="ENOENT"?new Error(`${n} does not exist: ${e}`,{cause:o}):o}if(Pt(t,s,n),!(await K.stat(s)).isFile())throw new Error(`${n} is not a file: ${e}`);return{path:i,content:await K.readFile(s)}}async function Vw(t){let e=await K.realpath(t.root),n=t.packageKind==="runtime"?[]:[await Ru(e,"SKILL.md","SKILL.md")];for(let i of t.definition.tools)i.kind==="script"&&n.push(await Ru(e,i.source,`Script tool ${i.id}`));return n.sort((i,r)=>i.path.localeCompare(r.path))}function Jw(t,e){let n=e.map(i=>({path:i.path,sha256:Pu("sha256").update(i.content).digest("hex")}));return Pu("sha256").update(JSON.stringify(ar({package:t,files:n}))).digest("hex")}function Au(t){return JSON.stringify(t,null,2)+`
|
|
147
|
-
`}async function
|
|
148
|
-
`),await K.rename(s,r)}catch(o){if(await
|
|
149
|
-
`));let l=await cr(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 Tu(t){try{return await Ro.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Iu(t){return Hw("sha256").update(t).digest("hex")}function zw(t){return Iu(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}function Qw(t){return t.replaceAll(".","_").replaceAll("-","_")}async function Xw(t,e){let n=await st(t),i=Object.fromEntries(e.filter(o=>o.satisfied&&o.source).map(o=>[Qw(o.code),o.source])),r=ke.join(t,"subagent-progress.md");await Tu(r)&&(i.subagent_progress=ke.relative(n,r).split(ke.sep).join("/"));let s=e.find(o=>o.code==="design.handoff"&&o.satisfied);return s?.source&&(i.handoff_context=s.source),i}function Zw(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:at,profile:e,source:"pre-migration"}}]}async function ey(t){await Promise.all(t.map(e=>Ro.rm(e,{recursive:!0,force:!0})))}async function $u(t,e){let n=await Ke(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!==at)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 cr(e.skillPackage)!==n.run.skillHash)return await Po(t,n.run.skillHash),{classic:i,run:n.run,evidence:await Be(t,n),migrated:!1,snapshotDir:ke.join(t,".comet","skill-snapshots",n.run.skillHash)};let d=await _o(e.skillPackage,t);return{classic:i,run:n.run,evidence:await Be(t,n),migrated:!1,snapshotDir:d.snapshotDir}}let s=await Be(t,n),o=Et(i,s);if(!e.skillPackage.definition.orchestration.steps?.some(u=>u.id===o))throw new Error(`Classic Skill package does not define resolved step: ${o}`);let a=await cr(e.skillPackage),c=ke.join(t,".comet","skill-snapshots",a),l=await Tu(c),f=[];try{let u=await _o(e.skillPackage,t),d=pu(e.skillPackage,e.runId?.()??Gw(),u.hash);d.currentStep=o,o==="completed"&&(d.status="completed");let h={...i,classicProfile:r,classicMigration:at},w=await Xw(t,s),p=await st(t),m=s.find(C=>C.code==="design.handoff"&&C.satisfied),g=null;m?.source&&(g=await te(p,m.resolvedSource??m.source,{label:"Classic migration handoff context",hooks:e.handoffReadHooks}),await Gl(t,d.contextRef,g),f.push(ke.resolve(t,d.contextRef))),await Hl(t,d.artifactsRef,w),f.push(ke.resolve(t,d.artifactsRef));let y=(e.now?.()??new Date).toISOString(),k={runId:d.runId,stateVersion:1,trajectoryOffset:2,contextHash:g===null?null:Iu(g),artifactsHash:zw(w),createdAt:y};await zl(t,d.checkpointRef,k),f.push(ke.resolve(t,d.checkpointRef)),f.push(ke.resolve(t,d.trajectoryRef));for(let C of Zw(d,r,y))await mn(t,d.trajectoryRef,C);return await sr(t,{classic:h,run:d,unknownKeys:n.unknownKeys}),{classic:h,run:d,evidence:s,migrated:!0,snapshotDir:u.snapshotDir}}catch(u){throw await ey(f),l||await Ro.rm(c,{recursive:!0,force:!0}),u}}async function ty(t){try{return(await qu.stat(t)).isDirectory()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function lr(t){try{return(await qu.stat(t)).isFile()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function ny(t){return await ty(t)?await lr(ie.join(t,"skill.yaml"))?!0:await lr(ie.join(t,"SKILL.md"))&&await lr(ie.join(t,"comet","skill.yaml")):!1}function iy(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 ry(){let t=ie.dirname(Lu(import.meta.url)),e=[process.env.COMET_RUNTIME_CLASSIC_ROOT,ie.resolve(t,"..","runtime","classic"),ie.resolve(t,"..","..","comet","runtime","classic"),ie.resolve(t,"..","..","assets","skills","comet","runtime","classic"),ie.resolve("assets","skills","comet","runtime","classic"),process.env.COMET_CLASSIC_SKILL_ROOT,ie.resolve(t,"..","..","comet-classic"),ie.resolve(t,"..","..","assets","skills","comet-classic"),ie.resolve("assets","skills","comet-classic")].filter(n=>!!n);for(let n of e)if(await ny(n))return n;return null}async function sy(t){return await lr(ie.join(t,"skill.yaml"))?Cu(t):Su(t)}async function ur(t){let e=await ry();return $u(t,{skillPackage:e?await sy(e):iy(ie.dirname(Lu(import.meta.url)))})}async function Du(t){let e=await Ke(t),n=Array.from(new Set(e.unknownKeys)).sort();if(n.length>0)throw new Error(`Invalid Classic state: unknown field(s): ${n.join(", ")}`);return ur(t)}async function Fu(t,e,n,i){let r=await Ke(t);if(!r.classic||!r.run)throw new Error("Classic transition requires synchronized Classic and Run projections");let s=await Be(t,{classic:e,run:n,unknownKeys:r.unknownKeys}),o=Et(e,s),a={...n,currentStep:o,iteration:n.iteration+1,status:o==="completed"?"completed":"running"};await sr(t,{classic:e,run:a,unknownKeys:r.unknownKeys});let c=await Vi(t,a.trajectoryRef);return await mn(t,a.trajectoryRef,{sequence:c.length+1,timestamp:new Date().toISOString(),type:"state_transitioned",runId:a.runId,data:{kind:"classic",fromStep:n.currentStep,toStep:o,...i}}),a}var Mu={"full.open":["openspec.proposal","openspec.tasks"],"full.design.handoff":["openspec.proposal","openspec.design","openspec.tasks"],"full.design.document":["design.handoff"],"full.build.plan":["openspec.tasks"],"full.build.plan-ready":["build.plan"],"full.build.configure":["build.plan"],"full.build.execute":["build.plan"],"full.build.complete":["build.tasks-complete"],"full.verify.run":["build.tasks-complete"],"full.verify.branch":["verification.report"],"full.archive.confirm":["verification.report"],"full.archive.execute":["archive.confirmed"]};function oy(t){return Mu[t]?Mu[t]:t.endsWith(".open")?["openspec.proposal","openspec.tasks"]:t.endsWith(".build.execute")?[]:t.endsWith(".build.complete")?["build.tasks-complete"]:t.endsWith(".verify.run")?["build.tasks-complete"]:t.endsWith(".verify.branch")?["verification.report"]:t.endsWith(".archive.confirm")?["verification.report"]:t.endsWith(".archive.execute")?["archive.confirmed"]:[]}function Wu(t,e){let n=oy(t),i=n.filter(r=>!ot(e,r));return{stepId:t,passed:i.length===0,requiredEvidence:n,missingEvidence:i}}function ay(t){switch(t){case"open":return"/comet-open";case"design":return"/comet-design";case"build":return"/comet-build";case"verify":return"/comet-verify";case"archive":return"/comet-archive";default:return null}}async function Bu(t,e){try{let n=await Du(t),i=await Be(t,{classic:n.classic,run:n.run,unknownKeys:[]}),r=Et(n.classic,i);return{name:e,valid:!0,workflow:n.classic.workflow,phase:n.classic.phase,currentStep:r,nextCommand:ay(n.classic.phase),runtimeMode:"engine-projection",runtimeEval:Wu(r,i),evidence:i}}catch(n){return{name:e,valid:!1,workflow:"unknown",phase:"invalid",currentStep:null,nextCommand:null,runtimeMode:"invalid",runtimeEval:null,evidence:[],error:n instanceof Error?n.message:String(n)}}}Yi();import cy from"path";var ly=cy.join(".comet","state-events.jsonl"),uy=8*1024*1024;async function Ku(t,e){let n={schemaVersion:1,timestamp:new Date().toISOString(),...e};return await Ki(t,ly,`${JSON.stringify(n)}
|
|
150
|
-
`,uy,"Classic state event log"),n}var fy={"open-complete":{event:"open-complete",from:"open",guardRefs:["open-artifacts-present"]},"design-complete":{event:"design-complete",from:"design",guardRefs:["design-evidence-present"]},"build-complete":{event:"build-complete",from:"build",guardRefs:["build-decisions-selected"]},"verify-pass":{event:"verify-pass",from:"verify",guardRefs:["verification-report-present"]},"verify-fail":{event:"verify-fail",from:"verify",guardRefs:["verification-failed"]},"archive-confirm":{event:"archive-confirm",from:"archive",guardRefs:["archive-final-confirmation"]},"archive-reopen":{event:"archive-reopen",from:"archive",guardRefs:["archive-not-finalized"]},archived:{event:"archived",from:"archive",guardRefs:["verify-result-pass","archive-confirmed"]},"preset-escalate":{event:"preset-escalate",from:"build",guardRefs:["preset-workflow"]}},
|
|
151
|
-
`)};throw m}let w=(0,Nn.parseDocument)(h);if(w.errors.length>0||!(0,Nn.isMap)(w.contents)){for(let m of w.errors)u(m.message);return(0,Nn.isMap)(w.contents)||u("document root must be a mapping"),c.push("",lt(Pn,`${l} error(s), ${
|
|
152
|
-
`)}}let p=w.toJS();for(let m of vy)Object.prototype.hasOwnProperty.call(p,m)||u(`missing required field '${m}'`);for(let[m,g]of Object.entries(by)){if(!Object.prototype.hasOwnProperty.call(p,m))continue;let y=Rn(p[m]);if(!y){m==="auto_transition"&&u(`${m}='' is not valid. Expected: ${g.join(" ")}`);continue}g.includes(y)||u(`${m}='${y}' is not valid. Expected: ${g.join(" ")}`)}if(Object.prototype.hasOwnProperty.call(p,"bound_branch")){let m=p.bound_branch;m!==null&&typeof m!="string"&&u(`bound_branch='${Rn(m)}' is not a string or null`)}if(Object.prototype.hasOwnProperty.call(p,"verify_failures")){let m=p.verify_failures;(typeof m!="number"||!Number.isInteger(m)||m<0)&&u(`verify_failures='${Rn(m)}' is not a non-negative integer`)}for(let m of["design_doc","plan","handoff_context","verification_report"]){let g=Rn(p[m]);if(g){if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(g)||g.split(/[\\/]/u).includes("..")){u(`${m}='${g}' must be a relative repository path`);continue}try{await yn(r,
|
|
153
|
-
`)}):(c.push(lt(gy,`0 errors, ${
|
|
154
|
-
`)})});
|
|
155
|
-
Next: ask the user to confirm — switch back to '${e}', or run \`comet state rebind ${t}\` after explicit confirmation.`}function
|
|
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=Ri(e),i=kt(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=Ri(e),i=kt(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())}}};bl.Parser=Hs});var xl=v(on=>{"use strict";var kl=$s(),Ph=zt(),sn=Zt(),Rh=Tr(),Nh=N(),Oh=Js(),Sl=Gs();function Cl(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Oh.LineCounter||null,prettyErrors:e}}function Ah(t,e={}){let{lineCounter:n,prettyErrors:i}=Cl(e),r=new Sl.Parser(n?.addNewLine),s=new kl.Composer(e),o=Array.from(s.compose(r.parse(t)));if(i&&n)for(let a of o)a.errors.forEach(sn.prettifyError(t,n)),a.warnings.forEach(sn.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},s.streamInfo())}function El(t,e={}){let{lineCounter:n,prettyErrors:i}=Cl(e),r=new Sl.Parser(n?.addNewLine),s=new kl.Composer(e),o=null;for(let a of s.compose(r.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new sn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(o.errors.forEach(sn.prettifyError(t,n)),o.warnings.forEach(sn.prettifyError(t,n))),o}function jh(t,e,n){let i;typeof e=="function"?i=e:n===void 0&&e&&typeof e=="object"&&(n=e);let r=El(t,n);if(!r)return null;if(r.warnings.forEach(s=>Rh.warn(r.options.logLevel,s)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:i},n))}function Th(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 Nh.isDocument(t)&&!i?t.toString(n):new Ph.Document(t,i,n).toString(n)}on.parse=jh;on.parseAllDocuments=Ah;on.parseDocument=El;on.stringify=Th});var Ie=v(O=>{"use strict";var Ih=$s(),$h=zt(),qh=hs(),zs=Zt(),Lh=It(),Te=N(),Dh=Re(),Fh=q(),Mh=Oe(),Wh=Ae(),Bh=_i(),Kh=Us(),Yh=Js(),Uh=Gs(),Oi=xl(),_l=Ot();O.Composer=Ih.Composer;O.Document=$h.Document;O.Schema=qh.Schema;O.YAMLError=zs.YAMLError;O.YAMLParseError=zs.YAMLParseError;O.YAMLWarning=zs.YAMLWarning;O.Alias=Lh.Alias;O.isAlias=Te.isAlias;O.isCollection=Te.isCollection;O.isDocument=Te.isDocument;O.isMap=Te.isMap;O.isNode=Te.isNode;O.isPair=Te.isPair;O.isScalar=Te.isScalar;O.isSeq=Te.isSeq;O.Pair=Dh.Pair;O.Scalar=Fh.Scalar;O.YAMLMap=Mh.YAMLMap;O.YAMLSeq=Wh.YAMLSeq;O.CST=Bh;O.Lexer=Kh.Lexer;O.LineCounter=Yh.LineCounter;O.Parser=Uh.Parser;O.parse=Oi.parse;O.parseAllDocuments=Oi.parseAllDocuments;O.parseDocument=Oi.parseDocument;O.stringify=Oi.stringify;O.visit=_l.visit;O.visitAsync=_l.visitAsync});var Ai=G(()=>{"use strict"});function $e(t){return t!==0&&t!==0n&&t!=="0"}function ji(t,e){return $e(t.dev)&&$e(e.dev)&&$e(t.ino)&&$e(e.ino)}function ye(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 Ti=G(()=>{"use strict"});import{randomUUID as Vh}from"crypto";import{constants as Jh,promises as L}from"fs";import V from"path";async function Qs(t,e){try{return await L.link(t,e),{linked:!0}}catch(n){let i=n.code;if(i!=="ENOTSUP"&&i!=="EOPNOTSUPP")throw n}return await L.copyFile(t,e,Jh.COPYFILE_EXCL),{linked:!1}}function St(t,e){let n=V.relative(t,e);return n===""||!V.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${V.sep}`)}function $i(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Hh(t,e){return ye(t,$i(e))}function Ii(t,e){let n=$i(t),i=$i(e);return ji(n,i)?ye(n,i):ye(n,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function qi(t){let e=await L.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 L.realpath(t),...$i(e)}}async function qe(t){for(let e of t){let n=await L.lstat(e.path);if(!n.isDirectory()||n.isSymbolicLink()||!Hh(e,n)||await L.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function Gh(t,e){let n=V.resolve(t),i=V.resolve(e);if(!St(n,i))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let r=[await qi(n)],s=V.relative(n,i).split(V.sep).filter(Boolean),o=n;for(let a of s){await qe(r),o=V.join(o,a);try{await L.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await qi(o);if(!St(r[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${o}`);r.push(c)}return await qe(r),r}async function zh(t,e){let n=V.resolve(t),i=V.resolve(e);if(!St(n,i))throw new Error(`Contained file parent is outside its managed root: ${e}`);let r=[await qi(n)],s=V.relative(n,i).split(V.sep).filter(Boolean),o=n;for(let a of s){o=V.join(o,a);try{let c=await qi(o);if(!St(r[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${o}`);r.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await qe(r),r}async function Pl(t){let e;try{e=await L.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 Qh(t,e,n){let i=V.dirname(t),r=await Gh(n.containedRoot,i),s=V.join(i,`.${V.basename(t)}.${Vh()}.tmp`),o,a;try{await n.beforeTemporaryOpen?.(),o=await L.open(s,"wx"),a=await o.stat();let[c,l]=await Promise.all([L.lstat(s),L.realpath(s)]);if(await qe(r),!c.isFile()||c.isSymbolicLink()||!Ii(a,c)||!St(r[0].realPath,l))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await o.writeFile(e,"utf8"):await o.writeFile(e),await o.sync(),!Ii(a,await o.stat()))throw new Error("Contained atomic write temporary file changed while writing");await o.close(),o=void 0,await n.beforeCommit?.(),await qe(r);let d=await L.lstat(s);if(!d.isFile()||d.isSymbolicLink()||!Ii(d,a))throw new Error("Contained atomic write temporary file changed before commit");n.exclusive?(await Qs(s,t),await L.unlink(s)):await L.rename(s,t),await Pl(i)}catch(c){await o?.close();try{await qe(r),await L.rm(s,{force:!0})}catch{}throw c}}async function me(t,e,n){await Qh(t,e,n)}async function Xs(t,e){let n=V.dirname(t),i=await zh(e.containedRoot,n);if(!i)return!1;let r,s;try{r=await L.lstat(t),s=await L.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!r.isFile()||r.isSymbolicLink()||!St(i[0].realPath,s))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await qe(i);let[o,a]=await Promise.all([L.lstat(t),L.realpath(t)]);if(!o.isFile()||o.isSymbolicLink()||!Ii(r,o)||a!==s)throw new Error("Contained file removal target changed before removal");return await L.unlink(t),await qe(i),await Pl(n),!0}var et=G(()=>{"use strict";Ti()});var Rl=G(()=>{"use strict"});var Zs=G(()=>{"use strict";Ai()});var Nl=G(()=>{"use strict";Ai();Zs()});import Li from"path";function rg(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let n=t.trim();if(n.length===0||Li.posix.isAbsolute(n)||Li.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 an(t){let e=rg(t,"native.artifact_root");return e.length===0?".":e.join("/")}function jl(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 tt(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||Li.posix.isAbsolute(i)||Li.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(s=>s===".."))throw new Error(`${e} must stay inside its declared path base`);if(r.some(s=>s===""||s==="."))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 cn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Tl(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 Il(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>to)throw new Error(`${e} exceeds ${to} 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>no)throw new Error(`${e} contains more than ${no} wildcard tokens`);return t}function Ol(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=>Il(i,e)))].sort((i,r)=>i.localeCompare(r,"en"))}function eo(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 sg(t){if(t===void 0)return{...se,include:[...se.include],exclude:[...se.exclude]};let e=cn(t,"native.snapshot");return{include:Ol(e.include,"native.snapshot.include",se.include),exclude:Ol(e.exclude,"native.snapshot.exclude",se.exclude),max_files:eo(e.max_files,se.max_files,"native.snapshot.max_files"),max_total_bytes:eo(e.max_total_bytes,se.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:eo(e.max_duration_ms,se.max_duration_ms,"native.snapshot.max_duration_ms")}}function og(t){if(t===void 0)return;let e=cn(t,"native.pending_root_move"),n=e.id,i=e.from_artifact_root,r=e.to_artifact_root,s=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(s!=="copying"&&s!=="ready"&&s!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(e.cleanup!==void 0){let a=cn(e.cleanup,"native.pending_root_move.cleanup"),c=a.kind,l=a.state,d=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 d!="string"||!/^[a-f0-9]{64}$/u.test(d))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:d}}return{id:n,fromArtifactRoot:an(i),toArtifactRoot:an(r),stage:s,...o?{cleanup:o}:{}}}function ag(t,e={}){let n=cn(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??"sequential";if(r!=="sequential"&&r!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let s=n.archive_confirmation??"automatic";if(s!=="automatic"&&s!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=n.max_verify_failures??Al;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let a=og(n.pending_root_move);return{artifact_root:an(i),language:Tl(n.language,"en","native.language"),clarification_mode:r,archive_confirmation:s,max_verify_failures:o,snapshot:sg(n.snapshot),...a?{pending_root_move:a}:{}}}function cg(t){let e=cn(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:jl(e.artifact_layout),language:Tl(e.language,"zh-CN","classic.language"),context_compression:n,review_mode:i,auto_transition:r}}function lg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function ug(t,e,n,i,r){let s=t.schema!==void 0;if(!(s||t.default_workflow!==void 0||t.workflows!==void 0||!r.allowPartialProject&&t.native!==void 0)||r.allowPartialProject&&!s)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 a=t.workflows??[t.default_workflow];if(!Array.isArray(a)||a.length===0||a.some(l=>l!=="native"&&l!=="classic"))throw new Error("workflows must contain native and/or classic");let c=[...new Set(a)];if(!c.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(c.includes("native")&&!e)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:c,ambient_resume:i,...e?{native:e}:{},...n?{classic:n}:{}}}function Le(t,e={}){let n=(0,io.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,s=lg(r.ambient_resume),o=r.native===void 0?void 0:ag(r.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),a=r.classic===void 0?void 0:cg(r.classic),c=ug(r,o,a,s,{allowPartialProject:e.allowPartialProject??!1});return{value:r,config:c,ambient_resume:s,...o?{native:o}:{},...a?{classic:a}:{}}}function ro(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:an(t),language:e,clarification_mode:"sequential",archive_confirmation:"automatic",max_verify_failures:Al,snapshot:{...se,include:[...se.include],exclude:[...se.exclude]}}}}var io,Ct,to,no,Al,ig,se,ve=G(()=>{"use strict";io=Je(Ie(),1),Ct=64*1024,to=1024,no=64,Al=5,ig=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],se={include:["**/*"],exclude:[...ig],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4}});import{constants as Di,promises as nt}from"fs";function so(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function $l(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function ln(t){return{dev:t.dev,ino:t.ino,birthtime:so(t)}}function Fi(t,e){let n=ln(t),i=ln(e);return ji(n,i)?ye(n,i):ye(n,i)&&so(t)===so(e)&&$l(t)===$l(e)&&t.size===e.size}async function ql(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,s=await nt.lstat(t,{bigint:r});if(!s.isFile()||s.isSymbolicLink())throw new De("not-regular-file",`${i} must be a regular file`);if(BigInt(s.size)>BigInt(e))throw new De("too-large",`${i} exceeds ${e} bytes`);let o=await nt.realpath(t);await n.verify?.("pre-open",{realPath:o,identity:ln(s)});let a=process.platform==="win32"?Di.O_RDONLY:Di.O_RDONLY|Di.O_NOFOLLOW|Di.O_NONBLOCK,c;try{c=await nt.open(t,a)}catch(l){throw l.code==="ELOOP"?new De("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,d,u]=await Promise.all([c.stat({bigint:r}),nt.lstat(t,{bigint:r}),nt.realpath(t)]);if(!l.isFile()||!d.isFile()||d.isSymbolicLink()||u!==o||!Fi(s,l)||!Fi(s,d))throw new De("changed",`${i} changed while opening`);await n.verify?.("post-open",{realPath:u,identity:ln(l)}),await n.hooks?.afterOpen?.();let f=[],h=0,w=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let y=e+1-h,{bytesRead:k}=await c.read(w,0,Math.min(w.length,y),null);if(k===0)break;if(h+=k,h>e)throw new De("too-large",`${i} exceeds ${e} bytes`);f.push(Buffer.from(w.subarray(0,k)))}await n.hooks?.beforeFinalCheck?.();let[p,m,g]=await Promise.all([c.stat({bigint:r}),nt.lstat(t,{bigint:r}),nt.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||g!==o||!Fi(s,p)||!Fi(s,m))throw new De("changed",`${i} changed while reading`);return await n.verify?.("post-read",{realPath:g,identity:ln(p)}),{bytes:Buffer.concat(f,h),stat:p,realPath:g}}finally{await c.close()}}var De,Ll=G(()=>{"use strict";Ti();De=class extends Error{reason;constructor(e,n,i){super(n,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Mi}from"fs";import Fe from"path";function fg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function oo(t,e){let n=Fe.relative(t,e);return n===""||!Fe.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${Fe.sep}`)}async function Dl(t,e){let n=Fe.resolve(t),i=await Mi.lstat(n);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Mi.realpath(n)}async function Fl(t,e,n,i){let r=t;for(let s=0;s<n.length;s++){r=Fe.join(r,n[s]);let o;try{o=await Mi.lstat(r)}catch(d){if(fg(d))return{exists:!1,kind:"missing"};throw d}let a=Fe.relative(t,r).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${a}`);let c=s===n.length-1;if(!c&&!o.isDirectory())throw new Error(`${i.label} ancestor ${a} must be a real directory`);if(c&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let l=await Mi.realpath(r);if(!oo(e,l))throw new Error(`${i.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function D(t,e,n){let i=tt(e,n.label),r=Fe.resolve(t),s=await Dl(r,n.label),o=i.split("/"),a=Fe.resolve(r,...o);if(!oo(r,a))throw new Error(`${n.label} must stay inside the project root`);let c=await Fl(r,s,o,n);return{projectRoot:r,target:a,relative:i,exists:c.exists,kind:c.kind}}async function Wi(t,e,n){return(await D(t,e,{...n,expected:"file"})).exists}async function J(t,e,n,i){let r=await D(t,e,{label:i.label,expected:"file"});if(!r.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let s=await Dl(r.projectRoot,i.label);return ql(r.target,n,{...i,verify:async(o,a)=>{if(!oo(s,a.realPath))throw new Error(`${i.label} resolves outside the project root`);await Fl(r.projectRoot,s,r.relative.split("/"),{label:i.label,expected:"file"})}})}var le=G(()=>{"use strict";Ll();ve()});function dg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function pg(t){let e=(0,Wl.parseDocument)(t,{uniqueKeys:!0});if(e.errors.length>0)throw new Error(`Invalid global Comet config: ${e.errors[0].message}`);let n=e.toJS();if(n==null)return{};if(typeof n!="object"||Array.isArray(n))throw new Error("Invalid global Comet config: root must be a mapping");return n}function Kl(t){if(t.native?.pending_root_move)throw new Error("Global Comet config cannot contain native.pending_root_move");let e=t.native?(({pending_root_move:n,...i})=>i)(t.native):void 0;return{...t,schema:"comet.global.v1",...e?{native:e}:{}}}function mg(t){let e=Le(JSON.stringify({...t,schema:"comet.project.v1"})).config;if(!e)throw new Error("Invalid global Comet config: workflow template is incomplete");return Kl(e)}function hg(t){let e=Le(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e.native&&!e.classic)return null;let n=e.native?"native":"classic",i=e.native?.language??e.classic?.language??"en",r=ro(e.native?.artifact_root??"docs",i);return{schema:"comet.global.v1",default_workflow:n,workflows:[n],ambient_resume:e.ambient_resume,...e.native?{native:{...r.native,...e.native}}:{},...e.classic?{classic:e.classic}:{}}}function Yl(t){let e=pg(t);if(Object.keys(e).length===0)return null;if(e.schema===void 0)return hg(t);if(e.schema!=="comet.global.v1")throw new Error("Unsupported Comet global schema");return mg(e)}async function co(t){try{let e=await J(t,Bl,Ct,{label:"global Comet config"});return Yl(e.bytes.toString("utf8"))}catch(e){if(dg(e))return null;throw e}}var Wl,Bl,lo=G(()=>{"use strict";Wl=Je(Ie(),1);et();ve();le();Bl=".comet/config.yaml"});import{createHash as gg}from"crypto";function wg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Me(t,e={}){return(await Bi(t,e)).document}async function yg(t){try{return(await J(t,un,Ct,{label:un})).bytes}catch(e){if(wg(e))return null;throw e}}function vg(t){return t?{exists:!0,sha256:gg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Bi(t,e={}){let n=await yg(t);return{document:n?Le(n.toString("utf8"),e):null,identity:vg(n)}}var un,it=G(()=>{"use strict";ve();le();un=".comet/config.yaml"});var Nk,uo=G(()=>{"use strict";et();it();le();Nk=16*1024});var fo=G(()=>{"use strict";et();ve();it();le();uo()});var Vl=G(()=>{"use strict";Ai();et();Rl();Nl();ve();lo();le();it();fo();uo();Zs()});import{TextDecoder as xg}from"util";function Jl(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function _g(t,e){try{return new xg("utf-8",{fatal:!0}).decode(t.bytes)}catch(n){throw new Error(`${e} is not valid UTF-8`,{cause:n})}}async function po(t,e,n,i,r={}){try{let s=await J(t,e,n,{label:i,hooks:r.hooks});return{result:s,text:_g(s,i)}}catch(s){let o=s.code;if(o==="ENOENT"||o==="ENOTDIR")return null;throw s}}async function fn(t,e,n,i,r={}){return(await po(t,e,n,i,r))?.text??null}async function rt(t,e,n,i,r,s={}){if(Buffer.byteLength(n,"utf8")>i)throw new Error(`${r} exceeds ${i} bytes`);let o=await po(t,e,i,r),a=await D(t,e,{label:r,expected:"file"});await me(a.target,n,{containedRoot:a.projectRoot,beforeCommit:async()=>{await s.beforeCommit?.();let c=await po(t,e,i,r);if(!(!o&&!c)){if(!o||!c)throw new Error(`${r} changed before commit`);if(o.result.realPath!==c.result.realPath||!ye(Jl(o.result.stat),Jl(c.result.stat))||o.text!==c.text)throw new Error(`${r} changed before commit`)}}})}async function Ki(t,e,n,i,r,s={}){let o=await fn(t,e,i,r);await rt(t,e,`${o??""}${n}`,i,r,s)}async function mo(t,e,n,i={}){let r=await D(t,e,{label:n,expected:"file"});return r.exists?Xs(r.target,{containedRoot:r.projectRoot,beforeRemove:i.beforeRemove}):!1}var Yi=G(()=>{"use strict";Vl();Ti()});var cu={};wf(cu,{RUN_STATE_FILE:()=>er,applyRunStateToDocument:()=>yo,readRunState:()=>vo,removeRunState:()=>bo,runStateFromDocument:()=>Zi,writeRunState:()=>tr});import Zg from"path";function En(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 Cn(t,e){let n=En(t,e);if(Zg.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 ew(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 Zi(t){if(!t.run_id)return null;let e=En(t,"run_id"),n=En(t,"skill"),i=En(t,"skill_version"),r=En(t,"skill_hash"),s=Cn(t,"pending_ref"),o=Cn(t,"trajectory_ref"),a=Cn(t,"context_ref"),c=Cn(t,"artifacts_ref"),l=Cn(t,"checkpoint_ref"),d=Number(t.iteration);if(!Number.isInteger(d)||d<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:ou(t,"current_step"),iteration:d,pending:ou(t,"pending"),pendingRef:s,trajectoryRef:o,contextRef:a,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:ew(t)}}function yo(t,e){e?t.run_id=e.runId:delete t.run_id}function tw(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 nw(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 Zi(e)}async function vo(t,e={}){let n=await fn(t,er,au,"Run state",e);if(n===null)return null;let i=JSON.parse(n);return nw(i)}async function tr(t,e,n={}){await rt(t,er,JSON.stringify(tw(e),null,2),au,"Run state",n)}async function bo(t,e={}){await mo(t,er,"Run state",e)}var ou,er,au,nr=G(()=>{"use strict";Yi();ou=(t,e)=>{let n=t[e];return n==null?null:String(n)};er=".comet/run-state.json",au=256*1024});var of=Je(Ie(),1);import{spawnSync as $y}from"child_process";import{createHash as sf}from"crypto";import{promises as qy}from"fs";import T from"path";import Ji from"path";Yi();import Ui from"path";var dn={trajectory:8*1024*1024,artifacts:1024*1024,context:1024*1024,pendingAction:256*1024,checkpoint:256*1024};function pn(t,e){if(Ui.isAbsolute(e))throw new Error("Run path must stay inside the change directory");let n=Ui.resolve(t),i=Ui.resolve(n,e);if(i!==n&&!i.startsWith(n+Ui.sep))throw new Error("Run path must stay inside the change directory")}async function mn(t,e,n,i={}){pn(t,e),await Ki(t,e,`${JSON.stringify(n)}
|
|
143
|
+
`,dn.trajectory,"Run trajectory",i)}async function Vi(t,e,n={}){pn(t,e);let i=await fn(t,e,dn.trajectory,"Run trajectory",n);return i===null?[]:i.split(/\r?\n/).map((r,s)=>({line:r,number:s+1})).filter(({line:r})=>r.length>0).map(({line:r,number:s})=>{try{return JSON.parse(r)}catch(o){throw new Error(`Invalid Trajectory event at line ${s}`,{cause:o})}})}async function Hl(t,e,n,i={}){pn(t,e),await rt(t,e,JSON.stringify(n,null,2)+`
|
|
144
|
+
`,dn.artifacts,"Run artifacts",i)}async function Gl(t,e,n,i={}){pn(t,e),await rt(t,e,n,dn.context,"Run context",i)}async function zl(t,e,n,i={}){pn(t,e),await rt(t,e,JSON.stringify(n,null,2)+`
|
|
145
|
+
`,dn.checkpoint,"Run checkpoint",i)}function Pg(t){if(t!=="build"&&t!=="verify")throw new Error(`Invalid command check scope: '${String(t)}'`)}function Rg(t,e="."){if(e.trim().length===0)throw new Error("Command check cwd cannot be blank");let n=Ji.resolve(t),i=Ji.resolve(n,e);if(i!==n&&!i.startsWith(n+Ji.sep))throw new Error(`Command check cwd must resolve within the project root: '${e}'`);return Ji.relative(n,i).replaceAll("\\","/")||"."}function Ng(t,e){if(e.type!=="command_check_recorded")return null;let n=e.data;if(typeof n!="object"||n===null||Array.isArray(n))return null;let{scope:i,command:r,exitCode:s,cwd:o}=n;if(i!=="build"&&i!=="verify"||typeof r!="string"||r.trim().length===0||!Number.isInteger(s)||typeof o!="string")return null;let a;try{a=Rg(t,o)}catch{return null}return{sequence:e.sequence,timestamp:e.timestamp,runId:e.runId,scope:i,command:r,exitCode:s,cwd:a}}async function Ql(t,e,n,i){Pg(i);let r=await Vi(e,n.trajectoryRef);for(let s=r.length-1;s>=0;s-=1){let o=r[s];if(o.runId!==n.runId)continue;let a=Ng(t,o);if(a?.scope===i)return a}return null}import{promises as Kg}from"fs";import be from"path";import{promises as Zl}from"fs";import $ from"path";import{promises as Og}from"fs";async function hn(t){try{return await Og.access(t),!0}catch(e){if(Ag(e))return!1;throw e}}function Ag(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}ve();it();fo();le();var gn=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Xl=".comet/config.yaml";function eu(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function tu(t){await D(t,Xl,{label:Xl,expected:"file"})}function Hi(t,e){let n=$.resolve(t),i=e==="docs"?$.join(n,"docs"):n,r=$.join(i,"openspec"),s=$.join(n,"docs","superpowers");return{projectRoot:n,artifactLayout:e,openSpecBase:i,openSpecRoot:r,changesDir:$.join(r,"changes"),archiveDir:$.join(r,"changes","archive"),specsDir:$.join(r,"specs"),superpowersRoot:s,superpowersSpecsDir:$.join(s,"specs"),superpowersPlansDir:$.join(s,"plans"),superpowersReportsDir:$.join(s,"reports")}}async function jg(t){await tu(t);let e=await Me(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new gn;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new gn("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function Tg(t,e){return Hi(t,e??await jg(t))}async function Ig(t){try{return await Zl.lstat(t),!0}catch(e){if(eu(e))return!1;throw e}}async function $g(t,e){let n=await Tg(t,e),i=n.artifactLayout==="legacy"?"docs":"legacy",r=Hi(t,i).openSpecRoot,[s,o]=await Promise.all([D(n.projectRoot,z(n.projectRoot,n.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),Ig(r)]),a=s.exists;return{paths:n,configuredRootExists:a,alternateRoot:r,alternateRootExists:o,dualRoots:a&&o}}async function qg(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=z(t.projectRoot,n);await D(t.projectRoot,i,{label:`Classic managed physical path ${i}`,expected:"directory"})}}async function We(t,e){let n=await $g(t,e);if(await qg(n.paths),!n.configuredRootExists){let i=z(n.paths.projectRoot,n.paths.openSpecRoot),r=z(n.paths.projectRoot,n.alternateRoot);throw new gn(`Configured Classic OpenSpec root is missing: ${i} (alternate ${r} is ${n.alternateRootExists?"present":"missing"})`)}return n.paths}async function ho(t,e){let n=$.join($.resolve(t),".comet","classic-root-move.json");if(await hn(n))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let i=await We(t,e);if(!await hn(i.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${z(i.projectRoot,i.openSpecRoot)}`);return i}async function st(t){let e=$.resolve(t),n=null;try{(await Zl.lstat(e)).isDirectory()||(e=$.dirname(e))}catch(i){if(!eu(i))throw i}for(;;){$.basename(e)==="openspec"&&(n=$.dirname(e));let i=$.join(e,".comet","config.yaml"),r=!1;if(await hn(i))try{await tu(e);let o=(await Me(e))?.value;r=!!o&&typeof o=="object"&&!Array.isArray(o)&&(o.schema==="comet.project.v1"||o.default_workflow!==void 0||o.native!==void 0)}catch{}if(r||await hn($.join(e,".git")))return e;let s=$.dirname(e);if(s===e)return n??$.resolve(t);e=s}}function z(t,e){return $.relative($.resolve(t),e).replaceAll("\\","/")}le();ve();import bn from"path";import{promises as Dg}from"fs";import zi from"path";et();ve();le();import wn from"path";var Lg=2*1024*1024;function nu(t,e,n){let i=wn.resolve(t),r=wn.isAbsolute(e)?wn.resolve(e):wn.resolve(i,e),s=wn.relative(i,r).replaceAll("\\","/");return{root:i,relative:tt(s,n),target:r}}async function Be(t,e,n){let i=nu(t,e,n.label);return D(i.root,i.relative,n)}async function yn(t,e,n){return(await Be(t,e,{label:n.label,expected:n.expected??"any"})).exists}async function iu(t,e,n,i){return await yn(t,e,{label:n,expected:"file"})?(await Gi(t,e,{label:n,hooks:i})).byteLength>0:!1}async function te(t,e,n){return(await Gi(t,e,n)).toString("utf8")}async function Gi(t,e,n){let i=nu(t,e,n.label);return(await J(i.root,i.relative,n.maxBytes??Lg,{label:n.label,hooks:n.hooks})).bytes}function vn(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}'
|
|
146
|
+
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function wo(t){let e=vn(t);if(e)throw new Error(e)}function Fg(t,e){return{label:z(t,e),directory:e}}async function go(t,e,n){let i=Fg(t,e);if(!(await Be(t,e,{label:n,expected:"directory"})).exists)return{change:i,exists:!1,stateExists:!1};let s=await Be(t,zi.join(e,".comet.yaml"),{label:`${n} state`,expected:"file"});return{change:i,exists:!0,stateExists:s.exists}}function Mg(t,e){let n=e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`^\\d{4}-\\d{2}-\\d{2}-${n}$`,"u").test(t)}async function Wg(t,e,n,i={}){if(!i.skipExactCompatibility){let o=await go(t,zi.join(e,n),`Classic archived change ${n}`);if(o.exists)return o.change}if(!(await Be(t,e,{label:"Classic archive directory",expected:"directory"})).exists)return null;let s=[];for(let o of await Dg.readdir(e,{withFileTypes:!0})){if(!Mg(o.name,n))continue;let a=await go(t,zi.join(e,o.name),`Classic archived change ${o.name}`);a.exists&&a.stateExists&&s.push(a.change)}return s.sort((o,a)=>a.directory.localeCompare(o.directory))[0]??null}async function Qi(t,e=process.cwd()){wo(t);let n=await We(e),i=await go(n.projectRoot,zi.join(n.changesDir,t),`Classic active change ${t}`);if(i.exists)return i.change;let r=await Wg(n.projectRoot,n.archiveDir,t);return r||i.change}function Bg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function ru(t,e,n,i){let r=tt(n,"Classic handoff artifact pointer");if((await D(t,r,{label:"Classic handoff artifact",expected:"file"})).exists)return null;let o=await We(t),a=`${z(t,o.changesDir)}/`,l=(o.artifactLayout==="docs"?[a,"openspec/changes/"]:[a]).find(y=>r.startsWith(y));if(!l)return null;let d=r.slice(l.length).split("/");if(d.length<4||d[1]!==".comet"||d.slice(2).some(y=>y.length===0))return null;let u=d[0];wo(u);let f=d.slice(2),h=bn.resolve(e);if(bn.dirname(h)!==bn.resolve(o.archiveDir))return null;let w=bn.basename(h),p=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(w);if(w!==u&&p?.[1]!==u)return null;await D(t,z(t,h),{label:"Classic archived change directory",expected:"directory"});let m=bn.join(h,".comet",...f),g=z(t,m);try{return await J(t,g,i,{label:"Historical Classic archived handoff artifact"}),g}catch(y){if(Bg(y))return null;throw y}}le();var su=2*1024*1024;function kn(t,e){return be.relative(t,e).split(be.sep).join("/")}async function Sn(t,e,n,i,r){if(!n)return{code:e,satisfied:!1};let s=n.replaceAll("\\","/");if(r)return{code:e,satisfied:!1,source:s,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=z(t,Hi(t,a).openSpecRoot);if((s===c||s.startsWith(`${c}/`))&&(await D(t,s,{label:`${e} artifact`,expected:"file"})).exists)return{code:e,satisfied:!1,source:s,detail:"standalone OpenSpec root is not a Comet artifact root"}}let o=await Wi(t,s,{label:`${e} artifact`});return{code:e,satisfied:o,source:s,...o?{resolvedSource:s}:{}}}catch(o){return{code:e,satisfied:!1,source:s,detail:`unsafe artifact pointer outside the project or through a special path: ${o instanceof Error?o.message:String(o)}`}}}async function Yg(t,e,n,i){try{i??=await We(t)}catch(s){return{code:"design.handoff",satisfied:!1,...n?{source:n.replaceAll("\\","/")}:{},detail:`Classic layout is unsafe or unavailable for handoff evidence: ${s instanceof Error?s.message:String(s)}`}}let r=await Sn(t,"design.handoff",n,i);if(!n||r.satisfied||r.detail)return r;try{let s=await ru(t,e,n,su);return s?{...r,satisfied:!0,resolvedSource:s,detail:`resolved historical legacy pointer from archived change: ${s}`}:r}catch(s){return{...r,satisfied:!1,detail:`unsafe archived handoff fallback: ${s instanceof Error?s.message:String(s)}`}}}async function Xi(t,e,n){return Sn(t,e,kn(t,n))}async function Ug(t,e){let n=be.join(e,"specs"),i;try{let o=kn(t,n);if(!(await D(t,o,{label:"OpenSpec delta-spec directory",expected:"directory"})).exists)return{code:"openspec.delta-spec",satisfied:!1};i=await Kg.readdir(n)}catch(o){return o.code==="ENOENT"?{code:"openspec.delta-spec",satisfied:!1}:{code:"openspec.delta-spec",satisfied:!1,detail:`unsafe delta-spec path: ${o instanceof Error?o.message:String(o)}`}}let r=i.map(o=>be.join(n,o,"spec.md")),s=(await Promise.all(r.map(async o=>{try{return await Wi(t,kn(t,o),{label:"OpenSpec delta spec"})?o:null}catch{return null}}))).filter(o=>o!==null);return{code:"openspec.delta-spec",satisfied:s.length>0,source:s[0]?kn(t,s[0]):void 0,detail:`${s.length} delta spec${s.length===1?"":"s"}`}}async function Vg(t,e){let n,i=kn(t,e);try{n=(await J(t,i,su,{label:"Classic tasks artifact"})).bytes.toString("utf8")}catch(o){return o.code==="ENOENT"?{code:"build.tasks-complete",satisfied:!1}:{code:"build.tasks-complete",satisfied:!1,source:i,detail:`unsafe tasks artifact: ${o instanceof Error?o.message:String(o)}`}}let r=[...n.matchAll(/^\s*[-*]\s+\[([ xX])\]\s+/gmu)],s=r.filter(o=>o[1].toLowerCase()==="x").length;return{code:"build.tasks-complete",satisfied:r.length>0&&s===r.length,source:i,detail:`${s} of ${r.length} tasks complete`}}function ot(t,e){return t.some(n=>n.code===e&&n.satisfied)}async function Ke(t,e){let n=await st(t),i=e.classic,r=be.join(t,"proposal.md"),s=be.join(t,"design.md"),o=be.join(t,"tasks.md"),a=e.run?be.resolve(t,e.run.checkpointRef):be.join(t,".comet","checkpoint.json"),c,l;try{c=await We(n)}catch(f){l=f}let d=await Promise.all([Xi(n,"openspec.proposal",r),Xi(n,"openspec.design",s),Xi(n,"openspec.tasks",o),Ug(n,t),Sn(n,"design.document",i?.designDoc??null,c,l),Sn(n,"build.plan",i?.plan??null,c,l),Vg(n,o),Sn(n,"verification.report",i?.verificationReport??null,c,l),Yg(n,t,i?.handoffContext??null,c),Xi(n,"run.checkpoint",a)]),u=d.find(f=>f.code==="design.handoff");return u&&!i?.handoffHash&&(u.satisfied=!1,u.detail="handoff hash is missing"),d.push({code:"archive.confirmed",satisfied:i?.archiveConfirmation==="confirmed"}),d}import{promises as Lu}from"fs";import ie from"path";import{fileURLToPath as Du}from"url";import{createHash as Hw,randomUUID as Gw}from"crypto";import{promises as Ro}from"fs";import ke from"path";function Jg(t){return t.classicProfile??t.workflow}function Hg(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 Gg(t){return t.buildMode==="direct"&&t.tddMode==="direct"&&t.isolation!==null&&t.verifyMode==="light"}function zg(t,e,n){if(e.verifyResult==="fail")return t==="full"?"full.build.fix":`${t}.build.execute`;if(t==="full"){if(!ot(n,"build.plan"))return"full.build.plan";if(e.buildPause==="plan-ready")return"full.build.plan-ready";if(!Hg(e))return"full.build.configure"}else if(!Gg(e))throw new Error(`${t} build configuration is incomplete`);return ot(n,"build.tasks-complete")?`${t}.build.complete`:`${t}.build.execute`}function Qg(t,e,n){return e.verifyResult!=="pass"||!ot(n,"verification.report")?`${t}.verify.run`:`${t}.verify.branch`}function Xg(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 Et(t,e){let n=Jg(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 ot(e,"design.handoff")?"full.design.document":"full.design.handoff";case"build":return zg(n,t,e);case"verify":return Qg(n,t,e);case"archive":return Xg(n,t)}}var sr=Je(Ie(),1);et();le();import rr from"path";nr();var lu=["full","hotfix","tweak"],at=1,iw=["open","design","build","verify","archive"],rw=["en","zh-CN"],sw=["off","beta"],ow=["subagent-driven-development","executing-plans","direct"],aw=["plan-ready"],cw=["confirmed"],lw=["tdd","direct"],uw=["off","standard","thorough"],fw=["current","branch","worktree"],dw=["light","full"],pw=["pending","pass","fail"],mw=["pending","handled"],hw=["pending","confirmed"],_t=["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"],So=["run_id"],gw=new Set([..._t,...So]),ww=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function uu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function xt(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 Q(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 ko(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 yw(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 ir(t,e){let n=xt(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 vw(t,e){let n=xt(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 bw(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==at)throw new Error(`Invalid Classic state: classic_migration must be ${at}`);return e}function kw(t){if(!_t.some(n=>uu(t,n)))return null;for(let n of ww)if(!uu(t,n))return null;return{workflow:Q(t,"workflow",lu,!1),language:Q(t,"language",rw),phase:Q(t,"phase",iw,!1),contextCompression:Q(t,"context_compression",sw),buildMode:Q(t,"build_mode",ow),buildPause:Q(t,"build_pause",aw),subagentDispatch:Q(t,"subagent_dispatch",cw),tddMode:Q(t,"tdd_mode",lw),reviewMode:Q(t,"review_mode",uw),isolation:Q(t,"isolation",fw),boundBranch:xt(t,"bound_branch"),verifyMode:Q(t,"verify_mode",dw),autoTransition:ko(t,"auto_transition"),baseRef:xt(t,"base_ref"),designDoc:ir(t,"design_doc"),plan:ir(t,"plan"),verifyResult:Q(t,"verify_result",pw,!1),verifyFailures:yw(t,"verify_failures"),verificationReport:ir(t,"verification_report"),branchStatus:Q(t,"branch_status",mw),createdAt:xt(t,"created_at"),verifiedAt:xt(t,"verified_at"),archiveConfirmation:Q(t,"archive_confirmation",hw),archived:ko(t,"archived",!1),directOverride:ko(t,"direct_override"),handoffContext:ir(t,"handoff_context"),handoffHash:vw(t,"handoff_hash"),classicProfile:Q(t,"classic_profile",lu),classicMigration:bw(t)}}function Co(t,e){let n=e??null;if(n===null&&e===void 0&&t.run_id&&t.skill)try{n=Zi(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:kw(t),run:n,unknownKeys:Object.keys(t).filter(i=>!gw.has(i))}}function fu(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}}nr();var Sw=2*1024*1024;function xn(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 du(t,e,n){t.get(e)!==n&&t.set(e,n)}function Cw(t,e){if(e.classic)for(let[n,i]of Object.entries(fu(e.classic)))du(t,n,i);else for(let n of _t)t.delete(n);yo(t.toJS(),e.run),e.run?du(t,"run_id",e.run.runId):t.delete("run_id")}function Ew(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 xw(t){let e=!1;for(let n of["build_command","verify_command"])t.has(n)&&(t.delete(n),e=!0);return e}async function pu(t){let e;try{e=(await J(rr.dirname(t),rr.basename(t),Sw,{label:"Classic state document"})).bytes.toString("utf8")}catch(i){if(i.code!=="ENOENT")throw i;return new sr.Document({})}let n=(0,sr.parseDocument)(e);if(n.errors.length>0)throw new Error(`Invalid Classic state document: ${n.errors[0].message}`);return xn(n),n}async function Ye(t,e={}){let n=e.migrate!==!1,i=rr.join(t,".comet.yaml"),r=await pu(i),s=xn(r),o=xw(r);o&&(s=xn(r));let a=await vo(t);if(!a&&s.run_id&&s.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(nr(),cu));a=c(s),a&&n&&(await tr(t,a),Ew(r),o=!0)}return o&&n&&await me(i,r.toString(),{containedRoot:t}),Co(xn(r),a)}async function or(t,e,n={}){let i=rr.join(t,".comet.yaml"),r=await pu(i);Cw(r,{...e,unknownKeys:e.unknownKeys??[]}),Co(xn(r),e.run??null),await me(i,r.toString(),{containedRoot:t,beforeCommit:n.beforeCommit}),e.run?await tr(t,e.run):await bo(t)}function mu(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:{}}}import{createHash as Ru,randomUUID as Kw}from"crypto";import{promises as K}from"fs";import F from"path";var wu=Je(Ie(),1);import{promises as Eo}from"fs";import oe from"path";var _w=["invoke_skill","call_tool","handoff","ask_user","checkpoint"],Pw=["deterministic","adaptive"],Rw=["function","mcp","script","agent"],Nw=["none","read","write","external"],Ow=["progress","step","completion"],Aw=["artifact_exists","state_equals"];function ct(t,e,n){return new Error(`${t}: ${e} ${n}`)}function ne(t,e,n="document"){if(t===null||typeof t!="object"||Array.isArray(t))throw ct(e,n,"must be an object")}function Ue(t,e,n){if(!Array.isArray(t))throw ct(e,n,"must be an array")}function X(t,e,n){if(typeof t!="string")throw ct(e,n,"must be a string")}function ue(t,e,n,i){e in t&&X(t[e],n,`${i}.${e}`)}function yu(t,e,n,i){if(e in t&&typeof t[e]!="boolean")throw ct(n,`${i}.${e}`,"must be a boolean")}function Ve(t,e,n,i){if(typeof t!="string"||!e.includes(t))throw ct(n,i,`must be one of ${e.join(", ")}`)}function ar(t,e,n){Ue(t,e,n),t.forEach((i,r)=>{X(i,e,`${n}[${r}]`)})}function hu(t,e,n){ne(t,e,n),X(t.name,e,`${n}.name`),X(t.description,e,`${n}.description`),yu(t,"required",e,n)}function jw(t,e,n){ne(t,e,n),X(t.id,e,`${n}.id`),ue(t,"source",e,n),ue(t,"version",e,n)}function Tw(t,e,n){ne(t,e,n),X(t.id,e,`${n}.id`),X(t.role,e,`${n}.role`),ue(t,"instructions",e,n)}function Iw(t,e,n){ne(t,e,n),X(t.id,e,`${n}.id`),Ve(t.kind,Rw,e,`${n}.kind`),X(t.source,e,`${n}.source`),Ve(t.sideEffect,Nw,e,`${n}.sideEffect`),yu(t,"requiresConfirmation",e,n)}function $w(t,e,n){ne(t,e,n),Ve(t.type,_w,e,`${n}.type`),ue(t,"ref",e,n),ue(t,"prompt",e,n),ue(t,"question",e,n),"options"in t&&ar(t.options,e,`${n}.options`)}function qw(t,e,n){ne(t,e,n),X(t.id,e,`${n}.id`),$w(t.action,e,`${n}.action`),ue(t,"next",e,n),"completionEvals"in t&&ar(t.completionEvals,e,`${n}.completionEvals`)}function Lw(t,e){let n="goal";ne(t,e,n),X(t.statement,e,`${n}.statement`),Ue(t.inputs,e,`${n}.inputs`),t.inputs.forEach((i,r)=>{hu(i,e,`${n}.inputs[${r}]`)}),Ue(t.outputs,e,`${n}.outputs`),t.outputs.forEach((i,r)=>{hu(i,e,`${n}.outputs[${r}]`)}),ar(t.success,e,`${n}.success`)}function Dw(t,e){let n="orchestration";ne(t,e,n),Ve(t.mode,Pw,e,`${n}.mode`),ue(t,"entry",e,n),"steps"in t&&(Ue(t.steps,e,`${n}.steps`),t.steps.forEach((i,r)=>{qw(i,e,`${n}.steps[${r}]`)}))}function vu(t,e){return ne(t,e),Ve(t.apiVersion,["comet/v1alpha1"],e,"apiVersion"),Ve(t.kind,["Skill"],e,"kind"),ne(t.metadata,e,"metadata"),X(t.metadata.name,e,"metadata.name"),X(t.metadata.version,e,"metadata.version"),X(t.metadata.description,e,"metadata.description"),Lw(t.goal,e),Dw(t.orchestration,e),Ue(t.skills,e,"skills"),t.skills.forEach((n,i)=>{jw(n,e,`skills[${i}]`)}),Ue(t.agents,e,"agents"),t.agents.forEach((n,i)=>{Tw(n,e,`agents[${i}]`)}),Ue(t.tools,e,"tools"),t.tools.forEach((n,i)=>{Iw(n,e,`tools[${i}]`)}),t}function bu(t,e){ne(t,e);for(let n of["allowedSkills","allowedAgents","allowedTools","confirmationRequiredFor"])n in t&&ar(t[n],e,n);for(let n of["maxIterations","maxRetriesPerAction"])if(n in t&&(typeof t[n]!="number"||!Number.isFinite(t[n])))throw ct(e,n,"must be a finite number");return t}function Fw(t,e){return ne(t,e),"runtime"in t&&ku(t.runtime,e,"runtime"),t}function ku(t,e,n){return Ue(t,e,n),t.forEach((i,r)=>{let s=`${n}[${r}]`;ne(i,e,s),X(i.id,e,`${s}.id`),Ve(i.scope,Ow,e,`${s}.scope`),Ve(i.type,Aw,e,`${s}.type`),ue(i,"artifact",e,s),ue(i,"field",e,s),ue(i,"equals",e,s)}),t}async function xo(t){let e=await Eo.readFile(t,"utf8");try{return(0,wu.parse)(e)}catch(n){let i=n instanceof Error?n.message:String(n);throw ct(t,"document",i)}}async function Mw(t){try{return await xo(t)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function gu(t){try{return await Eo.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Ww(t){let e=oe.join(t,"checks.yaml"),n=oe.join(t,"evals.yaml"),[i,r]=await Promise.all([gu(e),gu(n)]);if(r)throw new Error(`${n}: evals.yaml is no longer supported; use checks.yaml`);return i?{document:Fw(await xo(e),e)}:{document:null}}async function Su(t){let e=oe.resolve(t.root),n=oe.resolve(t.controlRoot);t.requireSkillMarkdown&&await Eo.access(oe.join(e,"SKILL.md"));let i=oe.join(n,"skill.yaml"),r=oe.join(n,"guardrails.yaml"),s=vu(await xo(i),i),o=await Mw(r),a=o===null?null:bu(o,r),c=await Ww(n),l={allowedSkills:s.skills.map(d=>d.id),allowedAgents:s.agents.map(d=>d.id),allowedTools:s.tools.map(d=>d.id),maxIterations:50,maxRetriesPerAction:3,confirmationRequiredFor:s.tools.filter(d=>d.requiresConfirmation).map(d=>d.id)};return{root:e,packageKind:t.packageKind==="runtime"?"runtime":void 0,definition:s,guardrails:{...l,...a},evals:c.document?.runtime??[]}}async function Cu(t){let e=oe.resolve(t);return Su({root:e,controlRoot:oe.join(e,"comet"),packageKind:"skill",requireSkillMarkdown:!0})}async function Eu(t){let e=oe.resolve(t);return Su({root:e,controlRoot:e,packageKind:"runtime",requireSkillMarkdown:!1})}function xu(t,e,n=oe.join(e,"package.json")){ne(t,n);let i=t.packageKind==="runtime"?"runtime":void 0,r=vu(t.definition,n),s=bu(t.guardrails,n),o=ku(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:oe.resolve(e),packageKind:i,definition:r,guardrails:{...a,...s},evals:o}}import _u from"path";function Bw(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 Pu(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 s=n.orchestration.steps??[];if(n.orchestration.mode==="adaptive")(n.orchestration.entry||s.length>0)&&e.push("adaptive orchestration must not define entry or steps");else{let o=new Set;for(let a of s)o.has(a.id)&&e.push(`duplicate step id: ${a.id}`),o.add(a.id),Bw(a.action,t,e,a.id);(!n.orchestration.entry||!o.has(n.orchestration.entry))&&e.push(`orchestration.entry references unknown step: ${n.orchestration.entry??"(missing)"}`);for(let a of s){a.next&&!o.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 o of n.tools){if(o.kind!=="script")continue;let a=_u.posix.normalize(o.source.replaceAll("\\","/"));(_u.isAbsolute(o.source)||a===".."||a.startsWith("../"))&&e.push(`script tool ${o.id} must reference a relative path inside the Skill package`)}for(let o of i.allowedSkills)n.skills.some(a=>a.id===o)||e.push(`guardrails allow undeclared skill: ${o}`);for(let o of i.allowedAgents)n.agents.some(a=>a.id===o)||e.push(`guardrails allow undeclared agent: ${o}`);for(let o of i.allowedTools)n.tools.some(a=>a.id===o)||e.push(`guardrails allow undeclared tool: ${o}`);return e}function cr(t){return Array.isArray(t)?t.map(cr):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,cr(n)])):t}function Yw(t){return cr({...t.packageKind==="runtime"?{packageKind:"runtime"}:{},definition:t.definition,guardrails:t.guardrails,evals:t.evals})}function Uw(t){return F.posix.normalize(t.replaceAll("\\","/"))}function Pt(t,e,n){let i=F.relative(t,e);if(!(i===""||!F.isAbsolute(i)&&!i.startsWith(`..${F.sep}`)))throw new Error(`${n} resolves outside the Skill package`)}async function Nu(t,e,n){let i=Uw(e);if(F.posix.isAbsolute(i)||i===".."||i.startsWith("../"))throw new Error(`${n} resolves outside the Skill package`);let r=F.resolve(t,...i.split("/"));Pt(t,r,n);let s;try{s=await K.realpath(r)}catch(o){throw o.code==="ENOENT"?new Error(`${n} does not exist: ${e}`,{cause:o}):o}if(Pt(t,s,n),!(await K.stat(s)).isFile())throw new Error(`${n} is not a file: ${e}`);return{path:i,content:await K.readFile(s)}}async function Vw(t){let e=await K.realpath(t.root),n=t.packageKind==="runtime"?[]:[await Nu(e,"SKILL.md","SKILL.md")];for(let i of t.definition.tools)i.kind==="script"&&n.push(await Nu(e,i.source,`Script tool ${i.id}`));return n.sort((i,r)=>i.path.localeCompare(r.path))}function Jw(t,e){let n=e.map(i=>({path:i.path,sha256:Ru("sha256").update(i.content).digest("hex")}));return Ru("sha256").update(JSON.stringify(cr({package:t,files:n}))).digest("hex")}function ju(t){return JSON.stringify(t,null,2)+`
|
|
147
|
+
`}async function Tu(t){let e=Yw(t),n=await Vw(t);return{document:e,files:n,hash:Jw(e,n)}}async function lr(t){return(await Tu(t)).hash}async function Ou(t){try{return await K.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Au(t,e){try{if((await K.readFile(F.join(t,"sha256"),"utf8")).trim()!==e.hash)throw new Error("hash mismatch");if(await K.readFile(F.join(t,"package.json"),"utf8")!==ju(e.document))throw new Error("package mismatch");for(let r of e.files)if(!(await K.readFile(F.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 _o(t,e){let n=await Tu(t),i=F.resolve(e,".comet","skill-snapshots"),r=F.join(i,n.hash);if(await K.mkdir(i,{recursive:!0}),await Ou(r))return await Au(r,n),{hash:n.hash,snapshotDir:r};let s=F.join(i,`.tmp-${Kw()}`);Pt(i,s,"Temporary snapshot"),Pt(i,r,"Published snapshot");try{await K.mkdir(s);for(let o of n.files){let a=F.join(s,...o.path.split("/"));Pt(s,a,`Snapshot file ${o.path}`),await K.mkdir(F.dirname(a),{recursive:!0}),await K.writeFile(a,o.content)}await K.writeFile(F.join(s,"package.json"),ju(n.document)),await K.writeFile(F.join(s,"sha256"),n.hash+`
|
|
148
|
+
`),await K.rename(s,r)}catch(o){if(await Ou(r)){try{await Au(r,n)}finally{await K.rm(s,{recursive:!0,force:!0})}return{hash:n.hash,snapshotDir:r}}throw await K.rm(s,{recursive:!0,force:!0}),o}return{hash:n.hash,snapshotDir:r}}async function Po(t,e){if(!/^[a-f0-9]{64}$/u.test(e))throw new Error(`Invalid Skill snapshot hash: ${e}`);let n=F.resolve(t,".comet","skill-snapshots"),i=F.join(n,e);Pt(n,i,"Skill snapshot");try{let r=(await K.readFile(F.join(i,"sha256"),"utf8")).trim();if(r!==e)throw new Error(`stored hash is ${r||"(empty)"}`);let s=F.join(i,"package.json"),o=JSON.parse(await K.readFile(s,"utf8")),a=xu(o,i,s),c=Pu(a);if(c.length>0)throw new Error(c.map(d=>` - ${d}`).join(`
|
|
149
|
+
`));let l=await lr(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 Iu(t){try{return await Ro.access(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}function $u(t){return Hw("sha256").update(t).digest("hex")}function zw(t){return $u(JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[n])=>e.localeCompare(n)))))}function Qw(t){return t.replaceAll(".","_").replaceAll("-","_")}async function Xw(t,e){let n=await st(t),i=Object.fromEntries(e.filter(o=>o.satisfied&&o.source).map(o=>[Qw(o.code),o.source])),r=ke.join(t,"subagent-progress.md");await Iu(r)&&(i.subagent_progress=ke.relative(n,r).split(ke.sep).join("/"));let s=e.find(o=>o.code==="design.handoff"&&o.satisfied);return s?.source&&(i.handoff_context=s.source),i}function Zw(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:at,profile:e,source:"pre-migration"}}]}async function ey(t){await Promise.all(t.map(e=>Ro.rm(e,{recursive:!0,force:!0})))}async function qu(t,e){let n=await Ye(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!==at)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 lr(e.skillPackage)!==n.run.skillHash)return await Po(t,n.run.skillHash),{classic:i,run:n.run,evidence:await Ke(t,n),migrated:!1,snapshotDir:ke.join(t,".comet","skill-snapshots",n.run.skillHash)};let f=await _o(e.skillPackage,t);return{classic:i,run:n.run,evidence:await Ke(t,n),migrated:!1,snapshotDir:f.snapshotDir}}let s=await Ke(t,n),o=Et(i,s);if(!e.skillPackage.definition.orchestration.steps?.some(u=>u.id===o))throw new Error(`Classic Skill package does not define resolved step: ${o}`);let a=await lr(e.skillPackage),c=ke.join(t,".comet","skill-snapshots",a),l=await Iu(c),d=[];try{let u=await _o(e.skillPackage,t),f=mu(e.skillPackage,e.runId?.()??Gw(),u.hash);f.currentStep=o,o==="completed"&&(f.status="completed");let h={...i,classicProfile:r,classicMigration:at},w=await Xw(t,s),p=await st(t),m=s.find(C=>C.code==="design.handoff"&&C.satisfied),g=null;m?.source&&(g=await te(p,m.resolvedSource??m.source,{label:"Classic migration handoff context",hooks:e.handoffReadHooks}),await Gl(t,f.contextRef,g),d.push(ke.resolve(t,f.contextRef))),await Hl(t,f.artifactsRef,w),d.push(ke.resolve(t,f.artifactsRef));let y=(e.now?.()??new Date).toISOString(),k={runId:f.runId,stateVersion:1,trajectoryOffset:2,contextHash:g===null?null:$u(g),artifactsHash:zw(w),createdAt:y};await zl(t,f.checkpointRef,k),d.push(ke.resolve(t,f.checkpointRef)),d.push(ke.resolve(t,f.trajectoryRef));for(let C of Zw(f,r,y))await mn(t,f.trajectoryRef,C);return await or(t,{classic:h,run:f,unknownKeys:n.unknownKeys}),{classic:h,run:f,evidence:s,migrated:!0,snapshotDir:u.snapshotDir}}catch(u){throw await ey(d),l||await Ro.rm(c,{recursive:!0,force:!0}),u}}async function ty(t){try{return(await Lu.stat(t)).isDirectory()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function ur(t){try{return(await Lu.stat(t)).isFile()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function ny(t){return await ty(t)?await ur(ie.join(t,"skill.yaml"))?!0:await ur(ie.join(t,"SKILL.md"))&&await ur(ie.join(t,"comet","skill.yaml")):!1}function iy(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 ry(){let t=ie.dirname(Du(import.meta.url)),e=[process.env.COMET_RUNTIME_CLASSIC_ROOT,ie.resolve(t,"..","runtime","classic"),ie.resolve(t,"..","..","comet","runtime","classic"),ie.resolve(t,"..","..","assets","skills","comet","runtime","classic"),ie.resolve("assets","skills","comet","runtime","classic"),process.env.COMET_CLASSIC_SKILL_ROOT,ie.resolve(t,"..","..","comet-classic"),ie.resolve(t,"..","..","assets","skills","comet-classic"),ie.resolve("assets","skills","comet-classic")].filter(n=>!!n);for(let n of e)if(await ny(n))return n;return null}async function sy(t){return await ur(ie.join(t,"skill.yaml"))?Eu(t):Cu(t)}async function fr(t){let e=await ry();return qu(t,{skillPackage:e?await sy(e):iy(ie.dirname(Du(import.meta.url)))})}async function Fu(t){let e=await Ye(t),n=Array.from(new Set(e.unknownKeys)).sort();if(n.length>0)throw new Error(`Invalid Classic state: unknown field(s): ${n.join(", ")}`);return fr(t)}async function Mu(t,e,n,i){let r=await Ye(t);if(!r.classic||!r.run)throw new Error("Classic transition requires synchronized Classic and Run projections");let s=await Ke(t,{classic:e,run:n,unknownKeys:r.unknownKeys}),o=Et(e,s),a={...n,currentStep:o,iteration:n.iteration+1,status:o==="completed"?"completed":"running"};await or(t,{classic:e,run:a,unknownKeys:r.unknownKeys});let c=await Vi(t,a.trajectoryRef);return await mn(t,a.trajectoryRef,{sequence:c.length+1,timestamp:new Date().toISOString(),type:"state_transitioned",runId:a.runId,data:{kind:"classic",fromStep:n.currentStep,toStep:o,...i}}),a}var Wu={"full.open":["openspec.proposal","openspec.tasks"],"full.design.handoff":["openspec.proposal","openspec.design","openspec.tasks"],"full.design.document":["design.handoff"],"full.build.plan":["openspec.tasks"],"full.build.plan-ready":["build.plan"],"full.build.configure":["build.plan"],"full.build.execute":["build.plan"],"full.build.complete":["build.tasks-complete"],"full.verify.run":["build.tasks-complete"],"full.verify.branch":["verification.report"],"full.archive.confirm":["verification.report"],"full.archive.execute":["archive.confirmed"]};function oy(t){return Wu[t]?Wu[t]:t.endsWith(".open")?["openspec.proposal","openspec.tasks"]:t.endsWith(".build.execute")?[]:t.endsWith(".build.complete")?["build.tasks-complete"]:t.endsWith(".verify.run")?["build.tasks-complete"]:t.endsWith(".verify.branch")?["verification.report"]:t.endsWith(".archive.confirm")?["verification.report"]:t.endsWith(".archive.execute")?["archive.confirmed"]:[]}function Bu(t,e){let n=oy(t),i=n.filter(r=>!ot(e,r));return{stepId:t,passed:i.length===0,requiredEvidence:n,missingEvidence:i}}function ay(t){switch(t){case"open":return"/comet-open";case"design":return"/comet-design";case"build":return"/comet-build";case"verify":return"/comet-verify";case"archive":return"/comet-archive";default:return null}}async function Ku(t,e){try{let n=await Fu(t),i=await Ke(t,{classic:n.classic,run:n.run,unknownKeys:[]}),r=Et(n.classic,i);return{name:e,valid:!0,workflow:n.classic.workflow,phase:n.classic.phase,currentStep:r,nextCommand:ay(n.classic.phase),runtimeMode:"engine-projection",runtimeEval:Bu(r,i),evidence:i}}catch(n){return{name:e,valid:!1,workflow:"unknown",phase:"invalid",currentStep:null,nextCommand:null,runtimeMode:"invalid",runtimeEval:null,evidence:[],error:n instanceof Error?n.message:String(n)}}}Yi();import cy from"path";var ly=cy.join(".comet","state-events.jsonl"),uy=8*1024*1024;async function Yu(t,e){let n={schemaVersion:1,timestamp:new Date().toISOString(),...e};return await Ki(t,ly,`${JSON.stringify(n)}
|
|
150
|
+
`,uy,"Classic state event log"),n}var fy={"open-complete":{event:"open-complete",from:"open",guardRefs:["open-artifacts-present"]},"design-complete":{event:"design-complete",from:"design",guardRefs:["design-evidence-present"]},"build-complete":{event:"build-complete",from:"build",guardRefs:["build-decisions-selected"]},"verify-pass":{event:"verify-pass",from:"verify",guardRefs:["verification-report-present"]},"verify-fail":{event:"verify-fail",from:"verify",guardRefs:["verification-failed"]},"archive-confirm":{event:"archive-confirm",from:"archive",guardRefs:["archive-final-confirmation"]},"archive-reopen":{event:"archive-reopen",from:"archive",guardRefs:["archive-not-finalized"]},archived:{event:"archived",from:"archive",guardRefs:["verify-result-pass","archive-confirmed"]},"preset-escalate":{event:"preset-escalate",from:"build",guardRefs:["preset-workflow"]}},Uu={open:"open-complete",design:"design-complete",build:"build-complete",verify:"verify-pass"};function dy(t){return t.toISOString().slice(0,10)}function R(t,e,n,i){let r=t[n];t[n]=i,r!==i&&e.push({field:n,from:r,to:i})}function Vu(t,e,n={}){let i=fy[e];if(t.phase!==i.from)throw new Error(`Cannot apply ${e}: phase is '${t.phase}', expected '${i.from}'`);let r={...t},s=[],o=n.now??new Date;if(e==="open-complete")R(r,s,"phase",r.workflow==="full"?"design":"build");else if(e==="design-complete")R(r,s,"phase","build");else if(e==="build-complete"){let a=r.verifyResult==="fail";R(r,s,"phase","verify"),R(r,s,"verifyResult","pending"),R(r,s,"branchStatus","pending"),a||R(r,s,"verificationReport",null)}else if(e==="verify-pass")R(r,s,"verifyResult","pass"),R(r,s,"verifyFailures",0),R(r,s,"phase","archive"),R(r,s,"verifiedAt",dy(o)),R(r,s,"archiveConfirmation","pending"),R(r,s,"branchStatus","pending");else if(e==="verify-fail")R(r,s,"verifyResult","fail"),R(r,s,"verifyFailures",r.verifyFailures+1),R(r,s,"phase","build"),R(r,s,"branchStatus","pending");else if(e==="preset-escalate"){if(r.workflow!=="hotfix"&&r.workflow!=="tweak")throw new Error(`Cannot apply ${e}: workflow must be hotfix or tweak, got '${r.workflow}'`);R(r,s,"workflow","full"),R(r,s,"classicProfile","full"),R(r,s,"phase","design"),R(r,s,"designDoc",null),R(r,s,"buildPause",null),R(r,s,"buildMode",null),R(r,s,"subagentDispatch",null),R(r,s,"tddMode",null),R(r,s,"reviewMode",null),R(r,s,"isolation",null),R(r,s,"boundBranch",null),R(r,s,"verifyMode",null),R(r,s,"directOverride",null)}else if(e==="archive-confirm"){if(r.verifyResult!=="pass")throw new Error(`Cannot apply ${e}: verifyResult must be pass`);if(r.archived)throw new Error(`Cannot apply ${e}: already archived`);R(r,s,"archiveConfirmation","confirmed")}else if(e==="archive-reopen"){if(r.archived)throw new Error(`Cannot apply ${e}: already archived`);R(r,s,"verifyResult","pending"),R(r,s,"verifyFailures",0),R(r,s,"phase","verify"),R(r,s,"verifiedAt",null),R(r,s,"archiveConfirmation",null),R(r,s,"branchStatus","pending")}else{if(r.verifyResult!=="pass")throw new Error(`Cannot apply ${e}: verifyResult must be pass`);if(r.archiveConfirmation!=="confirmed")throw new Error(`Cannot apply ${e}: archiveConfirmation must be confirmed`);R(r,s,"archived",!0)}return{classic:r,effects:s,definition:i}}var Nn=Je(Ie(),1);import Hu from"path";import{AsyncLocalStorage as py}from"async_hooks";import{promises as Ju}from"fs";import _n from"path";var dr=new py;function my(t,e){let n=_n.relative(t,e);return n===""||!_n.isAbsolute(n)&&n!==".."&&!n.startsWith(`..${_n.sep}`)}async function hy(t){let e=_n.resolve(t.invocationCwd??process.cwd()),n=_n.resolve(t.projectRoot??await st(e)),[i,r]=await Promise.all([Ju.realpath(e),Ju.realpath(n)]);if(!my(r,i))throw new Error(`Classic command invocation cwd is outside the discovered project: ${e}`);return{invocationCwd:e,projectRoot:n}}async function pr(t,e){let n=dr.getStore();if(n)return e(n);let i=await hy(t);return dr.run(i,()=>e(i))}function I(){let t=dr.getStore();if(!t)throw new Error("Classic command project context is unavailable");return t.projectRoot}function mr(){let t=dr.getStore();if(!t)throw new Error("Classic command invocation context is unavailable");return t.invocationCwd}var gy="\x1B[32m",Pn="\x1B[31m",wy="\x1B[33m",yy="\x1B[0m",vy=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"],by={workflow:["full","hotfix","tweak"],language:["en","zh-CN"],phase:["open","design","build","verify","archive"],context_compression:["off","beta"],build_mode:["subagent-driven-development","executing-plans","direct"],build_pause:["plan-ready"],subagent_dispatch:["confirmed"],tdd_mode:["tdd","direct"],review_mode:["off","standard","thorough"],isolation:["current","branch","worktree"],verify_mode:["light","full"],auto_transition:["true","false"],verify_result:["pending","pass","fail"],branch_status:["pending","handled"],archive_confirmation:["pending","confirmed"],archived:["true","false"],direct_override:["true","false"],classic_profile:["full","hotfix","tweak"],classic_migration:["1"]},ky=new Set([..._t,...So,"classic_profile","classic_migration"]);function lt(t,e){return`${t}${e}${yy}`}function Rn(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}var Gu=async(t,e)=>pr(e,async()=>{let n=t[0],i=vn(n);if(i)return{exitCode:1,stderr:lt(Pn,`ERROR: ${i}`)};let r=I(),{directory:s,label:o}=await Qi(n,r),a=Hu.join(s,".comet.yaml"),c=[`[VALIDATE] ${o}/.comet.yaml`],l=0,d=0,u=m=>{l+=1,c.push(lt(Pn,` FAIL: ${m}`))},f=m=>{d+=1,c.push(lt(wy,` WARN: ${m}`))},h;try{h=await te(r,a,{label:`Classic state ${o}/.comet.yaml`})}catch(m){if(m.code==="ENOENT")return u(".comet.yaml does not exist"),c.push("",lt(Pn,`${l} error(s), ${d} warning(s) — validation FAILED`)),{exitCode:1,stderr:c.join(`
|
|
151
|
+
`)};throw m}let w=(0,Nn.parseDocument)(h);if(w.errors.length>0||!(0,Nn.isMap)(w.contents)){for(let m of w.errors)u(m.message);return(0,Nn.isMap)(w.contents)||u("document root must be a mapping"),c.push("",lt(Pn,`${l} error(s), ${d} warning(s) — validation FAILED`)),{exitCode:1,stderr:c.join(`
|
|
152
|
+
`)}}let p=w.toJS();for(let m of vy)Object.prototype.hasOwnProperty.call(p,m)||u(`missing required field '${m}'`);for(let[m,g]of Object.entries(by)){if(!Object.prototype.hasOwnProperty.call(p,m))continue;let y=Rn(p[m]);if(!y){m==="auto_transition"&&u(`${m}='' is not valid. Expected: ${g.join(" ")}`);continue}g.includes(y)||u(`${m}='${y}' is not valid. Expected: ${g.join(" ")}`)}if(Object.prototype.hasOwnProperty.call(p,"bound_branch")){let m=p.bound_branch;m!==null&&typeof m!="string"&&u(`bound_branch='${Rn(m)}' is not a string or null`)}if(Object.prototype.hasOwnProperty.call(p,"verify_failures")){let m=p.verify_failures;(typeof m!="number"||!Number.isInteger(m)||m<0)&&u(`verify_failures='${Rn(m)}' is not a non-negative integer`)}for(let m of["design_doc","plan","handoff_context","verification_report"]){let g=Rn(p[m]);if(g){if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(g)||g.split(/[\\/]/u).includes("..")){u(`${m}='${g}' must be a relative repository path`);continue}try{await yn(r,Hu.resolve(r,g),{label:`${m} artifact pointer`,expected:"file"})||u(`${m}='${g}' does not exist on disk`)}catch(y){u(`${m}='${g}' is unsafe: ${y instanceof Error?y.message:String(y)}`)}}}for(let m of["handoff_hash"]){let g=Rn(p[m]);g&&!/^[a-f0-9]{64}$/u.test(g)&&u(`${m}='${g}' is not a sha256 hex digest`)}for(let m of Object.keys(p))ky.has(m)||f(`unknown field '${m}' found`);return c.push(""),l>0?(c.push(lt(Pn,`${l} error(s), ${d} warning(s) — validation FAILED`)),{exitCode:1,stderr:c.join(`
|
|
153
|
+
`)}):(c.push(lt(gy,`0 errors, ${d} warning(s) — validation PASSED`)),{exitCode:0,stderr:c.join(`
|
|
154
|
+
`)})});lo();it();import Sy from"os";import hr from"path";function Cy(t={}){let e=t.cwd??process.cwd(),n=t.homeDir??Sy.homedir(),i=[{file:hr.resolve(e,".comet","config.yaml"),source:".comet/config.yaml",scope:"project"},{file:hr.resolve(n,".comet","config.yaml"),source:"~/.comet/config.yaml",scope:"global"}];return i.filter((r,s)=>i.findIndex(o=>o.file===r.file)===s)}async function zu(t,e={}){for(let n of Cy(e)){let i=hr.dirname(hr.dirname(n.file)),r=n.scope==="global"?(await co(i))?.classic:(await Me(i,{allowPartialProject:!0}))?.value.classic;if(!r||typeof r!="object"||Array.isArray(r))continue;let s=r[t];if(s!=null)return{value:String(s),source:n.source}}return null}it();var Oo=Je(Ie(),1);import{execFileSync as Qu}from"child_process";import{randomUUID as _y}from"crypto";import{promises as On}from"fs";import Xu from"path";var Ey=null;function xy(t,e){let n=t;for(let i of e)n+="\0"+(typeof i=="string"?i:JSON.stringify(i));return n}function No(t,e){return(...n)=>{let i=Ey;if(i===null)return e(...n);let r=xy(`sync:${t}`,n),s=i.entries.get(r);if(s)return s.value;let o=e(...n);return i.entries.set(r,{value:o}),o}}function Py(t){try{let e=Qu("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return e&&e!=="HEAD"?e:null}catch{return null}}var Ry=No("liveGitBranch",t=>Py(t));function Ny(t){try{return Qu("git",["rev-parse","--is-inside-work-tree"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()==="true"}catch{return!1}}var Oy=No("isGitWorkTree",t=>Ny(t)),Ay=["current","branch","worktree"];function Zu(t){return Ay.includes(t)}function jy(t){return Zu(t.isolation)?t.boundBranch===null&&t.currentBranch===null&&t.gitWorkTree===!1?{status:"not-applicable"}:t.boundBranch===null?t.currentBranch===null?{status:"unbound-detached"}:{status:"needs-heal",branch:t.currentBranch}:t.currentBranch===t.boundBranch?{status:"ok"}:{status:"drift",boundBranch:t.boundBranch,currentBranch:t.currentBranch}:{status:"not-applicable"}}async function ef(t,e){let n=Xu.join(t,".comet.yaml"),i=(0,Oo.parseDocument)(await On.readFile(n,"utf8"),{uniqueKeys:!1});if(i.errors.length>0)throw new Error(`Invalid .comet.yaml: ${i.errors[0].message}`);let r=i.toJS()??{},s=typeof r.isolation=="string"?r.isolation:null,o=typeof r.bound_branch=="string"&&r.bound_branch!==""?r.bound_branch:null,a=Zu(s),c=Ry(e.cwd),l=a&&o===null&&c===null?Oy(e.cwd):!0,d=jy({isolation:s,boundBranch:o,currentBranch:c,gitWorkTree:l});return d.status==="needs-heal"&&e.heal?(await Ty(t,d.branch),{status:"healed",branch:d.branch,bindingRequired:a,currentBranch:c}):{...d,bindingRequired:a,currentBranch:c}}async function Ty(t,e){let n=Xu.join(t,".comet.yaml"),i=(0,Oo.parseDocument)(await On.readFile(n,"utf8"),{uniqueKeys:!1});i.set("bound_branch",e);let r=`${n}.${_y()}.tmp`;try{await On.writeFile(r,i.toString(),"utf8"),await On.rename(r,n)}catch(s){throw await On.rm(r,{force:!0}),s}}function Iy(t){return t??"detached HEAD"}function tf(t,e,n){return`change '${t}' is bound to branch '${e}', but current branch is '${Iy(n)}'.
|
|
155
|
+
Next: ask the user to confirm — switch back to '${e}', or run \`comet state rebind ${t}\` after explicit confirmation.`}function nf(t){return`change '${t}' uses a branch-bound workspace mode but has no bound branch and HEAD is detached; checkout a branch first before continuing.`}var Ly="\x1B[32m",Dy="\x1B[31m",Fy="\x1B[33m",Io="\x1B[0m",My=["open","design","build","verify","archive"],Wy={open:"=== Guard: open → next ===",design:"=== Guard: design → build ===",build:"=== Guard: build → verify ===",verify:"=== Guard: verify → archive ===",archive:"=== Guard: archive completeness ==="},By={open:" [APPLY] .comet.yaml updated: phase=PLACEHOLDER",design:" [APPLY] .comet.yaml updated: phase=build",build:" [APPLY] .comet.yaml updated: phase=verify, verify_result=pending",verify:" [APPLY] .comet.yaml updated: phase=archive, verify_result=pass"},Ky={branchStatus:"branch_status",phase:"phase",verificationReport:"verification_report",verifiedAt:"verified_at",verifyResult:"verify_result"};function Rt(t){return`${Ly}${t}${Io}`}function Se(t){return`${Dy}${t}${Io}`}function Yy(t){return`${Fy}${t}${Io}`}function Uy(t){return Ky[t]??String(t)}function Vy(t){return t===null?"null":t===void 0?"":typeof t=="object"?JSON.stringify(t):String(t)}var fe=class extends Error{constructor(n,i=1){super(n);this.exitCode=i}exitCode},To=class{stderr=[];diagnostics;toResult(e=0){return{exitCode:e,...this.diagnostics?{stdout:JSON.stringify({diagnostics:this.diagnostics})+`
|
|
156
156
|
`}:{},...this.stderr.length>0?{stderr:this.stderr.join(`
|
|
157
157
|
`)+`
|
|
158
|
-
`}:{}}}};async function Y(t){let e=I();return yn(e,t,{label:`Classic guard path ${T.relative(e,T.resolve(e,t)).replaceAll("\\","/")}`})}async function H(t){let e=I();return
|
|
158
|
+
`}:{}}}};async function Y(t){let e=I();return yn(e,t,{label:`Classic guard path ${T.relative(e,T.resolve(e,t)).replaceAll("\\","/")}`})}async function H(t){let e=I();return iu(e,t,`Classic guard file ${T.relative(e,T.resolve(e,t)).replaceAll("\\","/")}`)}function Jy(t){let e=vn(t);if(e)throw new fe(Se(`ERROR: ${e}`))}async function Hy(t){return(await Qi(t,I())).directory}async function A(t,e){let n=T.join(t,".comet.yaml"),i=(0,of.parseDocument)(await te(I(),n,{label:`Classic state ${t}/.comet.yaml`}),{uniqueKeys:!1});if(i.errors.length>0)throw new fe(`ERROR: Invalid .comet.yaml: ${i.errors[0].message}`);let s=i.toJS()[e];return s==null?"":typeof s=="object"?JSON.stringify(s):String(s)}async function Gy(t,e){let n=await A(e,t);return n&&n!=="null"?n:(await zu(t,{cwd:I()}))?.value??""}async function zy(t){let e=await Gy("language",t);if(!e)return"en";if(e==="en"||e==="zh-CN")return e;throw new Error(`configured language '${e}' is invalid; expected en or zh-CN.`)}function Qy(t){let e=[],n=!1;for(let i of t.split(/\r?\n/u)){if(/^\s*```/u.test(i)){n=!n;continue}n||e.push(i)}return e.join(`
|
|
159
159
|
`)}function Xy(t){return t.match(/[\u4e00-\u9fff]/gu)?.length??0}function Zy(t){return t.match(/[A-Za-z][A-Za-z0-9_-]{2,}/gu)?.length??0}async function he(t,e){let n=await zy(t),i=Qy(await te(I(),e,{label:`Classic language-check artifact ${e}`})),r=Xy(i),s=Zy(i);return n==="zh-CN"&&r<20&&s>=20?S(`configured language is zh-CN, but ${e} appears to be English-dominant (cjk_chars=${r}, english_words=${s}).
|
|
160
160
|
Next: regenerate or rewrite this artifact in Chinese while preserving necessary technical terms.`):n==="en"&&r>20&&r>s?S(`configured language is en, but ${e} appears to be Chinese-dominant (cjk_chars=${r}, english_words=${s}).
|
|
161
|
-
Next: regenerate or rewrite this artifact in English while preserving necessary technical terms.`):_()}async function
|
|
162
|
-
`)).digest("hex")}async function tv(t,e){if(!await Y(t))throw new fe(Se(`FATAL: change directory not found: ${t}`));if(!await Y(T.join(t,".comet.yaml")))throw new fe(Se(`FATAL: .comet.yaml not found in ${t}`));await
|
|
161
|
+
Next: regenerate or rewrite this artifact in English while preserving necessary technical terms.`):_()}async function af(t){return sf("sha256").update(await Gi(I(),t,{label:`Classic handoff source ${t}`})).digest("hex")}async function $o(t){let e=z(I(),t),n=[`${e}/proposal.md`,`${e}/design.md`,`${e}/tasks.md`],i=`${e}/specs`;if(await Y(i)){await Be(I(),i,{label:`Classic delta-spec directory ${i}`,expected:"directory"});for(let r of(await qy.readdir(i)).sort()){let s=`${i}/${r}/spec.md`;await Y(s)&&n.push(s)}}return n}async function ev(t){let e=[];for(let n of await $o(t))await Y(n)&&e.push(`path:${n}`,`sha256:${await af(n)}`);return sf("sha256").update(e.join(`
|
|
162
|
+
`)).digest("hex")}async function tv(t,e){if(!await Y(t))throw new fe(Se(`FATAL: change directory not found: ${t}`));if(!await Y(T.join(t,".comet.yaml")))throw new fe(Se(`FATAL: .comet.yaml not found in ${t}`));await Be(I(),T.join(t,".comet"),{label:`Classic runtime directory for ${e}`,expected:"directory"});let n=await Gu([e],{json:!1});if(n.exitCode!==0)throw n.stderr&&process.stderr.write(n.stderr.endsWith(`
|
|
163
163
|
`)?n.stderr:`${n.stderr}
|
|
164
|
-
`),new fe(Se("FATAL: .comet.yaml schema validation failed"));let i=await
|
|
164
|
+
`),new fe(Se("FATAL: .comet.yaml schema validation failed"));let i=await Ye(t),r=Array.from(new Set(i.unknownKeys)).sort();if(r.length>0)throw new fe(Se(`FATAL: .comet.yaml has unknown field(s): ${r.join(", ")}`))}function nv(t,e){if(e.passed){if(t.stderr.push(Rt(` [PASS] ${e.description}`)),e.detail)for(let n of e.detail.split(`
|
|
165
165
|
`))t.stderr.push(Rt(` ${n}`))}else if(t.stderr.push(Se(` [FAIL] ${e.description}`)),e.detail)for(let n of e.detail.split(`
|
|
166
|
-
`))t.stderr.push(Se(` ${n}`))}function E(t,e){return async()=>{try{let n=await e();return{description:t,passed:n.passed,detail:("detail"in n?n.detail:"")??""}}catch(n){return{description:t,passed:!1,detail:n instanceof Error?n.message:String(n)}}}}function _(t){return{passed:!0,...t?{detail:t}:{}}}function S(t){return{passed:!1,detail:t}}async function Nt(t,e){let n=!1;for(let i of e){let r=await i();nv(t,r),r.passed||(n=!0)}return n}var iv=["package.json with a build script","pom.xml","Cargo.toml"];async function rv(t){try{let e=await Me(I(),{allowPartialProject:!0});return e?Object.prototype.hasOwnProperty.call(e.value,t):!1}catch(e){throw new Error(`.comet/config.yaml is invalid YAML (${e instanceof Error?e.message:String(e)}); cannot check for removed "${t}" field. Fix the config and retry.`,{cause:e})}}function sv(t){return{status:1,output:`${t} has been removed from .comet/config.yaml. Delete this field and run any required ${t==="build_command"?"build":"verification"} command manually before retrying.`}}function ov(t){let e=$y(t,{shell:!0,cwd:
|
|
167
|
-
${
|
|
166
|
+
`))t.stderr.push(Se(` ${n}`))}function E(t,e){return async()=>{try{let n=await e();return{description:t,passed:n.passed,detail:("detail"in n?n.detail:"")??""}}catch(n){return{description:t,passed:!1,detail:n instanceof Error?n.message:String(n)}}}}function _(t){return{passed:!0,...t?{detail:t}:{}}}function S(t){return{passed:!1,detail:t}}async function Nt(t,e){let n=!1;for(let i of e){let r=await i();nv(t,r),r.passed||(n=!0)}return n}var iv=["package.json with a build script","pom.xml","Cargo.toml"];async function rv(t){try{let e=await Me(I(),{allowPartialProject:!0});return e?Object.prototype.hasOwnProperty.call(e.value,t):!1}catch(e){throw new Error(`.comet/config.yaml is invalid YAML (${e instanceof Error?e.message:String(e)}); cannot check for removed "${t}" field. Fix the config and retry.`,{cause:e})}}function sv(t){return{status:1,output:`${t} has been removed from .comet/config.yaml. Delete this field and run any required ${t==="build_command"?"build":"verification"} command manually before retrying.`}}function ov(t){let e=$y(t,{shell:!0,cwd:mr(),encoding:"utf8",timeout:3e5});return{status:e.status??1,output:`${e.stdout??""}${e.stderr??""}`.replace(/\n+$/u,"")}}function An(t){return T.resolve(mr(),t)}async function av(){let t=An("package.json");return await Y(t)&&typeof JSON.parse(await te(I(),t,{label:"package.json"})).scripts?.build=="string"?"npm run build":await Y(An("pom.xml"))?process.platform==="win32"?await Y(An("mvnw.cmd"))?"mvnw.cmd compile -q":"mvn.cmd compile -q":await Y(An("mvnw"))?"./mvnw compile -q":"mvn compile -q":await Y(An("Cargo.toml"))?"cargo build":null}function rf(t){return`Evidence: recorded command-check at ${t.timestamp}; command: ${t.command}; cwd: ${t.cwd}`}function Ao(t,e,n){return`comet state record-check ${t} ${e} --command "${n}" --exit-code 0`}async function cf(t,e,n,i){if(process.env.COMET_SKIP_BUILD==="1")return{status:0,output:"SKIPPED via COMET_SKIP_BUILD=1"};let r=i==="build"?["build_command"]:["verify_command","build_command"];for(let a of r)if(await rv(a))return sv(a);let s=i==="build"?await av():null;if(s)return ov(s);let o=await Ql(I(),t,n,i);return o?o.exitCode!==0?{status:o.exitCode,output:`Latest recorded ${i} check failed with exit code ${o.exitCode}.
|
|
167
|
+
${rf(o)}
|
|
168
168
|
Next: rerun the command successfully, then record it with:
|
|
169
|
-
${Ao(e,i,o.command)}`}:{status:0,output:
|
|
169
|
+
${Ao(e,i,o.command)}`}:{status:0,output:rf(o)}:{status:1,output:i==="build"?`No inferred build command or recorded build check. Detection searched: ${iv.join(", ")}.
|
|
170
170
|
Next: run the required command, then record it with:
|
|
171
171
|
${Ao(e,i,"<command>")}`:`No recorded verify check.
|
|
172
172
|
Next: run the required verification command, then record it with:
|
|
@@ -179,7 +179,7 @@ Next: complete or explicitly remove unfinished tasks, then mark tasks.md with '-
|
|
|
179
179
|
Next: restore the Superpowers plan file or update .comet.yaml plan before leaving build.`);let i=(await te(I(),e,{label:`Classic plan ${e}`})).split(/\r?\n/u).map((r,s)=>({line:r,number:s+1})).filter(r=>/^\s*- \[ \]/u.test(r.line));return i.length>0?S(`Unfinished Superpowers plan tasks:
|
|
180
180
|
${i.map(r=>`${r.number}:${r.line}`).join(`
|
|
181
181
|
`)}
|
|
182
|
-
Next: check off corresponding completed plan tasks, then commit the plan update.`):_()}async function Lo(t,e){let n;try{n=await
|
|
182
|
+
Next: check off corresponding completed plan tasks, then commit the plan update.`):_()}async function Lo(t,e){let n;try{n=await ef(t,{heal:!0,cwd:mr()})}catch(i){throw new fe(`ERROR: ${i instanceof Error?i.message:String(i)}`)}switch(n.status){case"drift":return S(tf(e,n.boundBranch,n.currentBranch));case"unbound-detached":return S(nf(e));case"healed":return _(`bound_branch lazily set to ${n.branch}`);case"needs-heal":case"ok":case"not-applicable":return _();default:{let i=n;throw new Error(`unhandled branch binding status: ${JSON.stringify(i)}`)}}}async function uv(t,e){let n=await A(t,"isolation");return n==="current"||n==="branch"||n==="worktree"?_():S(`isolation must be current, branch, or worktree, got '${n||"null"}'
|
|
183
183
|
Next: choose a valid workspace mode, prepare it when needed, then run:
|
|
184
184
|
comet state set ${e} isolation <current|branch|worktree>`)}async function fv(t,e){let n=await A(t,"build_mode");return["subagent-driven-development","executing-plans","direct"].includes(n)?_():S(`build_mode must be selected before leaving build, got '${n||"null"}'
|
|
185
185
|
Next: ask the user to choose an execution mode, then run:
|
|
@@ -198,11 +198,11 @@ Next: regenerate the design handoff with comet handoff ${e} design --write.`);le
|
|
|
198
198
|
Expected handoff_hash: ${i}
|
|
199
199
|
Actual handoff_hash: ${r}
|
|
200
200
|
Next: run comet handoff ${e} design --write so Superpowers receives the current OpenSpec context.`);let s=`${n.replace(/\.json$/u,"")}.md`;return await H(s)?_():S(`design handoff markdown is missing or empty: ${s}
|
|
201
|
-
Next: regenerate the design handoff with comet handoff ${e} design --write.`)}async function kv(t){let e=await A(t,"handoff_context");if(!e||e==="null")return S("handoff_context is missing from .comet.yaml");let n=`${e.replace(/\.json$/u,"")}.md`;if(!await H(n))return S(`design handoff markdown is missing or empty: ${n}`);let i=await te(I(),n,{label:`Classic handoff markdown ${n}`}),r=new Set(i.split(/\r?\n/u)),s=[];/^Generated-by: comet-handoff\.sh$/mu.test(i)||s.push("handoff markdown is missing Generated-by marker"),/^- Mode: (compact|full|beta)$/mu.test(i)||s.push("handoff markdown is missing Mode marker");for(let o of await $o(t))await Y(o)&&(r.has(`- Source: ${o}`)||s.push(`handoff markdown is missing source reference: ${o}`),r.has(`- SHA256: ${await
|
|
202
|
-
`))}async function
|
|
203
|
-
`))}async function Cv(t,e){let n=await A(e,"workflow"),i=[E("proposal.md exists and non-empty",async()=>await H(T.join(e,"proposal.md"))?_():S("")),E("proposal.md matches configured language",()=>he(e,T.join(e,"proposal.md"))),E("tasks.md exists and non-empty",async()=>await H(T.join(e,"tasks.md"))?_():S("")),E("tasks.md matches configured language",()=>he(e,T.join(e,"tasks.md"))),E("tasks.md has at least one task",async()=>await cv(e)?_():S(""))];return n==="full"&&i.splice(1,0,E("design.md exists and non-empty",async()=>await H(T.join(e,"design.md"))?_():S("")),E("design.md matches configured language",()=>he(e,T.join(e,"design.md")))),Nt(t,i)}async function Ev(t,e,n){let i=await A(e,"design_doc"),r=await A(e,"workflow"),s=[E("proposal.md exists",async()=>await H(T.join(e,"proposal.md"))?_():S("")),E("proposal.md matches configured language",()=>he(e,T.join(e,"proposal.md"))),E("design.md exists",async()=>await H(T.join(e,"design.md"))?_():S("")),E("design.md matches configured language",()=>he(e,T.join(e,"design.md"))),E("tasks.md exists",async()=>await H(T.join(e,"tasks.md"))?_():S("")),E("tasks.md matches configured language",()=>he(e,T.join(e,"tasks.md"))),E("design handoff context exists",()=>bv(e,n)),E("design handoff markdown is traceable",()=>kv(e))];await
|
|
204
|
-
Valid phases: open, design, build, verify, archive`);await ho(I());let o=await Hy(i);await tv(o,i);let a=await
|
|
201
|
+
Next: regenerate the design handoff with comet handoff ${e} design --write.`)}async function kv(t){let e=await A(t,"handoff_context");if(!e||e==="null")return S("handoff_context is missing from .comet.yaml");let n=`${e.replace(/\.json$/u,"")}.md`;if(!await H(n))return S(`design handoff markdown is missing or empty: ${n}`);let i=await te(I(),n,{label:`Classic handoff markdown ${n}`}),r=new Set(i.split(/\r?\n/u)),s=[];/^Generated-by: comet-handoff\.sh$/mu.test(i)||s.push("handoff markdown is missing Generated-by marker"),/^- Mode: (compact|full|beta)$/mu.test(i)||s.push("handoff markdown is missing Mode marker");for(let o of await $o(t))await Y(o)&&(r.has(`- Source: ${o}`)||s.push(`handoff markdown is missing source reference: ${o}`),r.has(`- SHA256: ${await af(o)}`)||s.push(`handoff markdown is missing current sha256 for: ${o}`));return s.length===0?_():S(s.join(`
|
|
202
|
+
`))}async function lf(t){return await A(t,"context_compression")||"off"}async function Sv(t){if(await lf(t)!=="beta")return _();let e=await A(t,"handoff_context");if(!e||e==="null")return S("handoff_context is missing from .comet.yaml");if(!await H(e))return S(`spec-context.json is missing or empty: ${e}`);let n=await te(I(),e,{label:`Classic handoff context ${e}`}),i=[],r;try{r=JSON.parse(n)}catch(a){return S(`spec-context.json invalid JSON: ${a instanceof Error?a.message:String(a)}`)}if(!r||typeof r!="object"||Array.isArray(r))return S("spec-context.json root must be an object");let s=r;typeof s.change!="string"&&i.push("spec-context.json missing 'change' field"),typeof s.phase!="string"&&i.push("spec-context.json missing 'phase' field"),s.mode!=="beta"&&i.push("spec-context.json mode is not beta"),typeof s.context_hash!="string"&&i.push("spec-context.json missing 'context_hash' field"),Array.isArray(s.files)||i.push("spec-context.json missing 'files' field");let o=Array.isArray(s.files)?s.files.filter(a=>!!a&&typeof a=="object"&&!Array.isArray(a)):[];for(let a of await $o(t))await Y(a)&&(o.some(c=>c.path===a&&typeof c.sha256=="string")||i.push(`spec-context.json missing source file reference: ${a}`));return i.length===0?_():S(i.join(`
|
|
203
|
+
`))}async function Cv(t,e){let n=await A(e,"workflow"),i=[E("proposal.md exists and non-empty",async()=>await H(T.join(e,"proposal.md"))?_():S("")),E("proposal.md matches configured language",()=>he(e,T.join(e,"proposal.md"))),E("tasks.md exists and non-empty",async()=>await H(T.join(e,"tasks.md"))?_():S("")),E("tasks.md matches configured language",()=>he(e,T.join(e,"tasks.md"))),E("tasks.md has at least one task",async()=>await cv(e)?_():S(""))];return n==="full"&&i.splice(1,0,E("design.md exists and non-empty",async()=>await H(T.join(e,"design.md"))?_():S("")),E("design.md matches configured language",()=>he(e,T.join(e,"design.md")))),Nt(t,i)}async function Ev(t,e,n){let i=await A(e,"design_doc"),r=await A(e,"workflow"),s=[E("proposal.md exists",async()=>await H(T.join(e,"proposal.md"))?_():S("")),E("proposal.md matches configured language",()=>he(e,T.join(e,"proposal.md"))),E("design.md exists",async()=>await H(T.join(e,"design.md"))?_():S("")),E("design.md matches configured language",()=>he(e,T.join(e,"design.md"))),E("tasks.md exists",async()=>await H(T.join(e,"tasks.md"))?_():S("")),E("tasks.md matches configured language",()=>he(e,T.join(e,"tasks.md"))),E("design handoff context exists",()=>bv(e,n)),E("design handoff markdown is traceable",()=>kv(e))];await lf(e)==="beta"&&s.push(E("beta spec-context.json is structurally valid",()=>Sv(e))),r==="full"&&s.push(E("design_doc is recorded for full workflow",()=>vv(e,n)));let o=await Nt(t,s);return i&&i!=="null"?o=await Nt(t,[E(`Design Doc (${i}) exists`,async()=>await H(i)?_():S("")),E("Design Doc matches configured language",()=>he(e,i)),E("Design Doc frontmatter links current change",async()=>await H(i)&&await jo(i,"comet_change",n)?_():S("")),E("Design Doc declares technical design role",async()=>await H(i)&&await jo(i,"role","technical-design")?_():S("")),E("Design Doc declares OpenSpec as canonical spec",async()=>await H(i)&&await jo(i,"canonical_spec","openspec")?_():S(""))])||o:r!=="full"&&t.stderr.push(Yy(" [WARN] No design_doc recorded in .comet.yaml (optional for hotfix/tweak)")),o}async function xv(t,e,n,i){return Nt(t,[E("bound branch matches workspace mode",()=>Lo(e,n)),E("isolation selected",()=>uv(e,n)),E("build_mode selected",()=>fv(e,n)),E("build_mode allowed for workflow",()=>dv(e)),E("subagent dispatch confirmed",()=>pv(e,n)),E("tdd_mode selected",()=>mv(e,n)),E("review_mode selected",()=>hv(e,n)),E("tasks.md all tasks checked",()=>qo(e)),E("Superpowers plan all tasks checked",()=>lv(e)),E("proposal.md exists",async()=>await H(T.join(e,"proposal.md"))?_():S("")),E("proposal.md matches configured language",()=>he(e,T.join(e,"proposal.md"))),E("Superpowers plan matches configured language",async()=>{let r=await A(e,"plan");return!r||r==="null"||!await Y(r)?_():he(e,r)}),E("Build passes",async()=>{let r=await cf(e,n,i,"build");return r.status===0?_(r.output):S(r.output)})])}async function _v(t,e,n,i){return Nt(t,[E("bound branch matches workspace mode",()=>Lo(e,n)),E("tasks.md all tasks checked",()=>qo(e)),E("Verification passes",async()=>{let r=await cf(e,n,i,"verify");return r.status===0?_(r.output):S(r.output)}),E("verification_report exists",async()=>await gv(e)?_():S("")),E("verification_report matches configured language",async()=>{let r=await A(e,"verification_report");return!r||r==="null"||!await Y(r)?_():he(e,r)})])}async function Pv(t,e,n){return Nt(t,[E("bound branch matches workspace mode",()=>Lo(e,n)),E("archived is true",async()=>await yv(e)?_():S("")),E("proposal.md exists",async()=>await H(T.join(e,"proposal.md"))?_():S("")),E("design.md exists",async()=>await H(T.join(e,"design.md"))?_():S("")),E("tasks.md all tasks checked",()=>qo(e)),E("branch_status=handled",async()=>await wv(e)?_():S(""))])}async function Rv(t,e,n,i){let r=Uu[i];if(!r)return;let s=await fr(n),o=Vu(s.classic,r);await Mu(n,o.classic,s.run,{event:r,phase:i,source:"comet-guard"}),await Yu(n,{change:e,event:r,source:"comet-guard",from:s.classic,to:o.classic,effects:o.effects});for(let l of o.effects)t.stderr.push(Rt(`[SET] ${Uy(l.field)}=${Vy(l.to)}`));t.stderr.push(Rt(`[TRANSITION] ${r}`));let a=By[i],c=i==="open"?a.replace("PLACEHOLDER",o.classic.phase):a;t.stderr.push(Rt(c))}var uf=async(t,e)=>pr(e,async()=>{let n=new To,[i,r,s]=t;try{if(Jy(i),!r||!My.includes(r))throw new fe(`${Se(`Unknown phase: ${r??""}`)}
|
|
204
|
+
Valid phases: open, design, build, verify, archive`);await ho(I());let o=await Hy(i);await tv(o,i);let a=await fr(o),c=await Ku(o,i);e.json&&(n.diagnostics={change:i,phase:r,currentStep:c.currentStep,runtimeEval:c.runtimeEval}),n.stderr.push(Wy[r]);let l;return r==="open"?l=await Cv(n,o):r==="design"?l=await Ev(n,o,i):r==="build"?l=await xv(n,o,i,a.run):r==="verify"?l=await _v(n,o,i,a.run):l=await Pv(n,o,i),l?(n.stderr.push(""),n.stderr.push(Se("BLOCKED — fix failing checks before proceeding to next phase")),n.toResult(1)):(n.stderr.push(""),n.stderr.push(Rt("ALL CHECKS PASSED — ready for next phase")),s==="--apply"&&await Rv(n,i,o,r),n.toResult(0))}catch(o){if(o instanceof fe){for(let a of o.message.split(`
|
|
205
205
|
`))n.stderr.push(a);return n.toResult(o.exitCode)}throw o}});function Nv(t,e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:t,exitCode:e.exitCode,...e.stdout===void 0?{}:{stdout:e.stdout},...e.stderr===void 0?{}:{stderr:e.stderr}})+`
|
|
206
|
-
`}}async function
|
|
206
|
+
`}}async function ff(t,e,n=process.argv.slice(2)){let i=n.includes("--json"),r=n.filter(a=>a!=="--json"),s;try{s=await e(r,{json:i})}catch(a){s={exitCode:70,stderr:a instanceof Error?a.message:String(a)}}let o=i?Nv(t,s):s;return o.stdout&&process.stdout.write(o.stdout),o.stderr&&process.stderr.write(o.stderr+(o.stderr.endsWith(`
|
|
207
207
|
`)?"":`
|
|
208
|
-
`)),o.exitCode}process.exitCode=await
|
|
208
|
+
`)),o.exitCode}process.exitCode=await ff("guard",uf);
|