comet-dsh-plugin 0.0.0-stage → 0.5.3
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 -0
- package/README.en.md +176 -0
- package/README.md +152 -2
- package/client.js +349 -0
- package/cordis.patch.yml +4 -0
- package/icon.png +0 -0
- package/index.js +183 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +57 -4
- package/rules/comet-workflow-guard.md +63 -0
- package/rules/migration-assets.json +218 -0
- package/server/comet-plugin-setup.mjs +192 -0
- package/skills/comet/SKILL.md +37 -0
- package/skills/comet/agents/openai.yaml +3 -0
- package/skills/comet/reference/change-walkthrough.md +77 -0
- package/skills/comet/reference/edit-review.md +26 -0
- package/skills/comet/reference/host-check.md +11 -0
- package/skills/comet/reference/platform-execution.md +34 -0
- package/skills/comet/reference/task-learning.md +39 -0
- package/skills/comet/runtime/classic/checks.yaml +6 -0
- package/skills/comet/runtime/classic/guardrails.yaml +13 -0
- package/skills/comet/runtime/classic/skill.yaml +122 -0
- package/skills/comet/scripts/comet-archive.mjs +310 -0
- package/skills/comet/scripts/comet-check.mjs +179 -0
- package/skills/comet/scripts/comet-entry-runtime.mjs +151 -0
- package/skills/comet/scripts/comet-env.mjs +15 -0
- package/skills/comet/scripts/comet-guard.mjs +335 -0
- package/skills/comet/scripts/comet-handoff.mjs +289 -0
- package/skills/comet/scripts/comet-hook-guard.mjs +294 -0
- package/skills/comet/scripts/comet-hook-router-guard.mjs +628 -0
- package/skills/comet/scripts/comet-hook-router.mjs +17 -0
- package/skills/comet/scripts/comet-intent.mjs +181 -0
- package/skills/comet/scripts/comet-plugin-hook.mjs +213 -0
- package/skills/comet/scripts/comet-resume-probe.mjs +205 -0
- package/skills/comet/scripts/comet-runtime.mjs +571 -0
- package/skills/comet/scripts/comet-state.mjs +381 -0
- package/skills/comet/scripts/comet-yaml-validate.mjs +182 -0
- package/skills/comet-any/SKILL.md +47 -0
- package/skills/comet-any/agents/openai.yaml +5 -0
- package/skills/comet-any/reference/sdk-creation.md +100 -0
- package/skills/comet-archive/SKILL.md +28 -0
- package/skills/comet-archive/agents/openai.yaml +5 -0
- package/skills/comet-archive/reference/compat.md +188 -0
- package/skills/comet-build/SKILL.md +35 -0
- package/skills/comet-build/agents/openai.yaml +5 -0
- package/skills/comet-build/reference/compat.md +191 -0
- package/skills/comet-classic/SKILL.md +98 -0
- package/skills/comet-classic/agents/openai.yaml +3 -0
- package/skills/comet-classic/reference/auto-transition.md +34 -0
- package/skills/comet-classic/reference/classic-layout.md +36 -0
- package/skills/comet-classic/reference/comet-yaml-fields.md +82 -0
- package/skills/comet-classic/reference/context-recovery.md +128 -0
- package/skills/comet-classic/reference/debug-gate.md +30 -0
- package/skills/comet-classic/reference/decision-point.md +109 -0
- package/skills/comet-classic/reference/dirty-worktree.md +59 -0
- package/skills/comet-classic/reference/file-structure.md +32 -0
- package/skills/comet-classic/reference/intent-frame.md +132 -0
- package/skills/comet-classic/reference/scripts.md +144 -0
- package/skills/comet-classic/reference/sdk-methods.md +136 -0
- package/skills/comet-classic/reference/subagent-dispatch.md +75 -0
- package/skills/comet-classic/reference/workspace.md +23 -0
- package/skills/comet-design/SKILL.md +25 -0
- package/skills/comet-design/agents/openai.yaml +5 -0
- package/skills/comet-design/reference/compat.md +191 -0
- package/skills/comet-hotfix/SKILL.md +46 -0
- package/skills/comet-hotfix/agents/openai.yaml +5 -0
- package/skills/comet-hotfix/reference/compat.md +240 -0
- package/skills/comet-memory/SKILL.md +68 -0
- package/skills/comet-memory/agents/openai.yaml +5 -0
- package/skills/comet-native/SKILL.md +139 -0
- package/skills/comet-native/agents/openai.yaml +3 -0
- package/skills/comet-native/reference/artifacts.md +118 -0
- package/skills/comet-native/reference/clarification.md +120 -0
- package/skills/comet-native/reference/commands.md +321 -0
- package/skills/comet-native/reference/edit-review.md +26 -0
- package/skills/comet-native/reference/recovery.md +64 -0
- package/skills/comet-native/reference/workspace.md +70 -0
- package/skills/comet-native/scripts/comet-native-archive.mjs +475 -0
- package/skills/comet-native/scripts/comet-native-cancel.mjs +461 -0
- package/skills/comet-native/scripts/comet-native-doctor.mjs +475 -0
- package/skills/comet-native/scripts/comet-native-hook-guard.mjs +470 -0
- package/skills/comet-native/scripts/comet-native-init.mjs +465 -0
- package/skills/comet-native/scripts/comet-native-new.mjs +478 -0
- package/skills/comet-native/scripts/comet-native-next.mjs +464 -0
- package/skills/comet-native/scripts/comet-native-root.mjs +472 -0
- package/skills/comet-native/scripts/comet-native-runtime.mjs +525 -0
- package/skills/comet-native/scripts/comet-native-select.mjs +468 -0
- package/skills/comet-native/scripts/comet-native-show.mjs +462 -0
- package/skills/comet-native/scripts/comet-native-spec.mjs +468 -0
- package/skills/comet-native/scripts/comet-native-status.mjs +467 -0
- package/skills/comet-native/scripts/comet-native-transfer.mjs +466 -0
- package/skills/comet-open/SKILL.md +265 -0
- package/skills/comet-open/agents/openai.yaml +5 -0
- package/skills/comet-open/reference/batch-changes.md +51 -0
- package/skills/comet-review/SKILL.md +121 -0
- package/skills/comet-review/agents/openai.yaml +5 -0
- package/skills/comet-tweak/SKILL.md +49 -0
- package/skills/comet-tweak/agents/openai.yaml +5 -0
- package/skills/comet-tweak/reference/compat.md +232 -0
- package/skills/comet-verify/SKILL.md +30 -0
- package/skills/comet-verify/agents/openai.yaml +5 -0
- package/skills/comet-verify/reference/compat.md +202 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __cometCreateRequire } from 'module';
|
|
3
|
+
const require = __cometCreateRequire(import.meta.url);
|
|
4
|
+
var vl=Object.create;var mo=Object.defineProperty;var bl=Object.getOwnPropertyDescriptor;var kl=Object.getOwnPropertyNames;var Sl=Object.getPrototypeOf,Cl=Object.prototype.hasOwnProperty;var Wt=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var y=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var El=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kl(e))!Cl.call(n,i)&&i!==t&&mo(n,i,{get:()=>e[i],enumerable:!(r=bl(e,i))||r.enumerable});return n};var Ft=(n,e,t)=>(t=n!=null?vl(Sl(n)):{},El(e||!n||!n.__esModule?mo(t,"default",{value:n,enumerable:!0}):t,n));var _=y(D=>{"use strict";var dr=Symbol.for("yaml.alias"),So=Symbol.for("yaml.document"),Ht=Symbol.for("yaml.map"),Co=Symbol.for("yaml.pair"),mr=Symbol.for("yaml.scalar"),Yt=Symbol.for("yaml.seq"),te=Symbol.for("yaml.node.type"),Yl=n=>!!n&&typeof n=="object"&&n[te]===dr,Jl=n=>!!n&&typeof n=="object"&&n[te]===So,Vl=n=>!!n&&typeof n=="object"&&n[te]===Ht,Gl=n=>!!n&&typeof n=="object"&&n[te]===Co,Eo=n=>!!n&&typeof n=="object"&&n[te]===mr,zl=n=>!!n&&typeof n=="object"&&n[te]===Yt;function _o(n){if(n&&typeof n=="object")switch(n[te]){case Ht:case Yt:return!0}return!1}function Xl(n){if(n&&typeof n=="object")switch(n[te]){case dr:case Ht:case mr:case Yt:return!0}return!1}var Ql=n=>(Eo(n)||_o(n))&&!!n.anchor;D.ALIAS=dr;D.DOC=So;D.MAP=Ht;D.NODE_TYPE=te;D.PAIR=Co;D.SCALAR=mr;D.SEQ=Yt;D.hasAnchor=Ql;D.isAlias=Yl;D.isCollection=_o;D.isDocument=Jl;D.isMap=Vl;D.isNode=Xl;D.isPair=Gl;D.isScalar=Eo;D.isSeq=zl});var Ze=y(pr=>{"use strict";var j=_(),W=Symbol("break visit"),xo=Symbol("skip children"),X=Symbol("remove node");function Jt(n,e){let t=Po(e);j.isDocument(n)?Me(null,n.contents,t,Object.freeze([n]))===X&&(n.contents=null):Me(null,n,t,Object.freeze([]))}Jt.BREAK=W;Jt.SKIP=xo;Jt.REMOVE=X;function Me(n,e,t,r){let i=Ro(n,e,t,r);if(j.isNode(i)||j.isPair(i))return No(n,r,i),Me(n,i,t,r);if(typeof i!="symbol"){if(j.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let s=Me(o,e.items[o],t,r);if(typeof s=="number")o=s-1;else{if(s===W)return W;s===X&&(e.items.splice(o,1),o-=1)}}}else if(j.isPair(e)){r=Object.freeze(r.concat(e));let o=Me("key",e.key,t,r);if(o===W)return W;o===X&&(e.key=null);let s=Me("value",e.value,t,r);if(s===W)return W;s===X&&(e.value=null)}}return i}async function Vt(n,e){let t=Po(e);j.isDocument(n)?await $e(null,n.contents,t,Object.freeze([n]))===X&&(n.contents=null):await $e(null,n,t,Object.freeze([]))}Vt.BREAK=W;Vt.SKIP=xo;Vt.REMOVE=X;async function $e(n,e,t,r){let i=await Ro(n,e,t,r);if(j.isNode(i)||j.isPair(i))return No(n,r,i),$e(n,i,t,r);if(typeof i!="symbol"){if(j.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let s=await $e(o,e.items[o],t,r);if(typeof s=="number")o=s-1;else{if(s===W)return W;s===X&&(e.items.splice(o,1),o-=1)}}}else if(j.isPair(e)){r=Object.freeze(r.concat(e));let o=await $e("key",e.key,t,r);if(o===W)return W;o===X&&(e.key=null);let s=await $e("value",e.value,t,r);if(s===W)return W;s===X&&(e.value=null)}}return i}function Po(n){return typeof n=="object"&&(n.Collection||n.Node||n.Value)?Object.assign({Alias:n.Node,Map:n.Node,Scalar:n.Node,Seq:n.Node},n.Value&&{Map:n.Value,Scalar:n.Value,Seq:n.Value},n.Collection&&{Map:n.Collection,Seq:n.Collection},n):n}function Ro(n,e,t,r){if(typeof t=="function")return t(n,e,r);if(j.isMap(e))return t.Map?.(n,e,r);if(j.isSeq(e))return t.Seq?.(n,e,r);if(j.isPair(e))return t.Pair?.(n,e,r);if(j.isScalar(e))return t.Scalar?.(n,e,r);if(j.isAlias(e))return t.Alias?.(n,e,r)}function No(n,e,t){let r=e[e.length-1];if(j.isCollection(r))r.items[n]=t;else if(j.isPair(r))n==="key"?r.key=t:r.value=t;else if(j.isDocument(r))r.contents=t;else{let i=j.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}pr.visit=Jt;pr.visitAsync=Vt});var hr=y(To=>{"use strict";var Ao=_(),Zl=Ze(),eu={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},tu=n=>n.replace(/[!,[\]{}]/g,e=>eu[e]),et=class n{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},n.defaultYaml,e),this.tags=Object.assign({},n.defaultTags,t)}clone(){let e=new n(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new n(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:n.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},n.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:n.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},n.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[o,s]=r;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[o]=r;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return t(6,`Unsupported YAML version ${o}`,s),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);return s==="!"||s==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),s)}let[,r,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);let o=this.tags[r];if(o)try{return o+decodeURIComponent(i)}catch(s){return t(String(s)),null}return r==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+tu(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),i;if(e&&r.length>0&&Ao.isNode(e.contents)){let o={};Zl.visit(e.contents,(s,a)=>{Ao.isNode(a)&&a.tag&&(o[a.tag]=!0)}),i=Object.keys(o)}else i=[];for(let[o,s]of r)o==="!!"&&s==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(s)))&&t.push(`%TAG ${o} ${s}`);return t.join(`
|
|
5
|
+
`)}};et.defaultYaml={explicit:!1,version:"1.2"};et.defaultTags={"!!":"tag:yaml.org,2002:"};To.Directives=et});var Gt=y(tt=>{"use strict";var Oo=_(),nu=Ze();function ru(n){if(/[\x00-\x19\s,[\]{}]/.test(n)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(n)}`;throw new Error(t)}return!0}function Io(n){let e=new Set;return nu.visit(n,{Value(t,r){r.anchor&&e.add(r.anchor)}}),e}function jo(n,e){for(let t=1;;++t){let r=`${n}${t}`;if(!e.has(r))return r}}function iu(n,e){let t=[],r=new Map,i=null;return{onAnchor:o=>{t.push(o),i??(i=Io(n));let s=jo(e,i);return i.add(s),s},setAnchors:()=>{for(let o of t){let s=r.get(o);if(typeof s=="object"&&s.anchor&&(Oo.isScalar(s.node)||Oo.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:r}}tt.anchorIsValid=ru;tt.anchorNames=Io;tt.createNodeAnchors=iu;tt.findNewAnchor=jo});var gr=y(Lo=>{"use strict";function nt(n,e,t,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let i=0,o=r.length;i<o;++i){let s=r[i],a=nt(n,r,String(i),s);a===void 0?delete r[i]:a!==s&&(r[i]=a)}else if(r instanceof Map)for(let i of Array.from(r.keys())){let o=r.get(i),s=nt(n,r,i,o);s===void 0?r.delete(i):s!==o&&r.set(i,s)}else if(r instanceof Set)for(let i of Array.from(r)){let o=nt(n,r,i,i);o===void 0?r.delete(i):o!==i&&(r.delete(i),r.add(o))}else for(let[i,o]of Object.entries(r)){let s=nt(n,r,i,o);s===void 0?delete r[i]:s!==o&&(r[i]=s)}return n.call(e,t,r)}Lo.applyReviver=nt});var se=y(qo=>{"use strict";var ou=_();function Do(n,e,t){if(Array.isArray(n))return n.map((r,i)=>Do(r,String(i),t));if(n&&typeof n.toJSON=="function"){if(!t||!ou.hasAnchor(n))return n.toJSON(e,t);let r={aliasCount:0,count:1,res:void 0};t.anchors.set(n,r),t.onCreate=o=>{r.res=o,delete t.onCreate};let i=n.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof n=="bigint"&&!t?.keep?Number(n):n}qo.toJS=Do});var zt=y($o=>{"use strict";var su=gr(),Mo=_(),au=se(),wr=class{constructor(e){Object.defineProperty(this,Mo.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:t,maxAliasCount:r,onAnchor:i,reviver:o}={}){if(!Mo.isDocument(e))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=au.toJS(this,"",s);if(typeof i=="function")for(let{count:c,res:l}of s.anchors.values())i(l,c);return typeof o=="function"?su.applyReviver(o,{"":a},"",a):a}};$o.NodeBase=wr});var rt=y(Wo=>{"use strict";var cu=Gt(),lu=Ze(),We=_(),uu=zt(),fu=se(),yr=class extends uu.NodeBase{constructor(e){super(We.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;t?.aliasResolveCache?r=t.aliasResolveCache:(r=[],lu.visit(e,{Node:(o,s)=>{(We.isAlias(s)||We.hasAnchor(s))&&r.push(s)}}),t&&(t.aliasResolveCache=r));let i;for(let o of r){if(o===this)break;o.anchor===this.source&&(i=o)}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:i,maxAliasCount:o}=t,s=this.resolve(i,t);if(!s){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=r.get(s);if(a||(fu.toJS(s,null,t),a=r.get(s)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Xt(i,s,r)),a.count*a.aliasCount>o)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,t,r){let i=`*${this.source}`;if(e){if(cu.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${i} `}return i}};function Xt(n,e,t){if(We.isAlias(e)){let r=e.resolve(n),i=t&&r&&t.get(r);return i?i.count*i.aliasCount:0}else if(We.isCollection(e)){let r=0;for(let i of e.items){let o=Xt(n,i,t);o>r&&(r=o)}return r}else if(We.isPair(e)){let r=Xt(n,e.key,t),i=Xt(n,e.value,t);return Math.max(r,i)}return 1}Wo.Alias=yr});var A=y(vr=>{"use strict";var du=_(),mu=zt(),pu=se(),hu=n=>!n||typeof n!="function"&&typeof n!="object",ae=class extends mu.NodeBase{constructor(e){super(du.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:pu.toJS(this.value,e,t)}toString(){return String(this.value)}};ae.BLOCK_FOLDED="BLOCK_FOLDED";ae.BLOCK_LITERAL="BLOCK_LITERAL";ae.PLAIN="PLAIN";ae.QUOTE_DOUBLE="QUOTE_DOUBLE";ae.QUOTE_SINGLE="QUOTE_SINGLE";vr.Scalar=ae;vr.isScalarValue=hu});var it=y(Bo=>{"use strict";var gu=rt(),Ce=_(),Fo=A(),wu="tag:yaml.org,2002:";function yu(n,e,t){if(e){let r=t.filter(o=>o.tag===e),i=r.find(o=>!o.format)??r[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(r=>r.identify?.(n)&&!r.format)}function vu(n,e,t){if(Ce.isDocument(n)&&(n=n.contents),Ce.isNode(n))return n;if(Ce.isPair(n)){let f=t.schema[Ce.MAP].createNode?.(t.schema,null,t);return f.items.push(n),f}(n instanceof String||n instanceof Number||n instanceof Boolean||typeof BigInt<"u"&&n instanceof BigInt)&&(n=n.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:o,schema:s,sourceObjects:a}=t,c;if(r&&n&&typeof n=="object"){if(c=a.get(n),c)return c.anchor??(c.anchor=i(n)),new gu.Alias(c.anchor);c={anchor:null,node:null},a.set(n,c)}e?.startsWith("!!")&&(e=wu+e.slice(2));let l=yu(n,e,s.tags);if(!l){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let f=new Fo.Scalar(n);return c&&(c.node=f),f}l=n instanceof Map?s[Ce.MAP]:Symbol.iterator in Object(n)?s[Ce.SEQ]:s[Ce.MAP]}o&&(o(l),delete t.onTagObj);let m=l?.createNode?l.createNode(t.schema,n,t):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(t.schema,n,t):new Fo.Scalar(n);return e?m.tag=e:l.default||(m.tag=l.tag),c&&(c.node=m),m}Bo.createNode=vu});var Zt=y(Qt=>{"use strict";var bu=it(),Q=_(),ku=zt();function br(n,e,t){let r=t;for(let i=e.length-1;i>=0;--i){let o=e[i];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=r,r=s}else r=new Map([[o,r]])}return bu.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:n,sourceObjects:new Map})}var Ko=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,kr=class extends ku.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(r=>Q.isNode(r)||Q.isPair(r)?r.clone(e):r),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Ko(e))this.add(t);else{let[r,...i]=e,o=this.get(r,!0);if(Q.isCollection(o))o.addIn(i,t);else if(o===void 0&&this.schema)this.set(r,br(this.schema,i,t));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(Q.isCollection(i))return i.deleteIn(r);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,o=this.get(r,!0);return i.length===0?!t&&Q.isScalar(o)?o.value:o:Q.isCollection(o)?o.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Q.isPair(t))return!1;let r=t.value;return r==null||e&&Q.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return Q.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...i]=e;if(i.length===0)this.set(r,t);else{let o=this.get(r,!0);if(Q.isCollection(o))o.setIn(i,t);else if(o===void 0&&this.schema)this.set(r,br(this.schema,i,t));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};Qt.Collection=kr;Qt.collectionFromPath=br;Qt.isEmptyPath=Ko});var ot=y(en=>{"use strict";var Su=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function Sr(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var Cu=(n,e,t)=>n.endsWith(`
|
|
6
|
+
`)?Sr(t,e):t.includes(`
|
|
7
|
+
`)?`
|
|
8
|
+
`+Sr(t,e):(n.endsWith(" ")?"":" ")+t;en.indentComment=Sr;en.lineComment=Cu;en.stringifyComment=Su});var Ho=y(st=>{"use strict";var Eu="flow",Cr="block",tn="quoted";function _u(n,e,t="flow",{indentAtStart:r,lineWidth:i=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!i||i<0)return n;i<o&&(o=0);let c=Math.max(1+o,1+i-e.length);if(n.length<=c)return n;let l=[],m={},f=i-e.length;typeof r=="number"&&(r>i-Math.max(2,o)?l.push(0):f=i-r);let u,p,g=!1,d=-1,h=-1,w=-1;t===Cr&&(d=Uo(n,d,e.length),d!==-1&&(f=d+c));for(let k;k=n[d+=1];){if(t===tn&&k==="\\"){switch(h=d,n[d+1]){case"x":d+=3;break;case"u":d+=5;break;case"U":d+=9;break;default:d+=1}w=d}if(k===`
|
|
9
|
+
`)t===Cr&&(d=Uo(n,d,e.length)),f=d+e.length+c,u=void 0;else{if(k===" "&&p&&p!==" "&&p!==`
|
|
10
|
+
`&&p!==" "){let S=n[d+1];S&&S!==" "&&S!==`
|
|
11
|
+
`&&S!==" "&&(u=d)}if(d>=f)if(u)l.push(u),f=u+c,u=void 0;else if(t===tn){for(;p===" "||p===" ";)p=k,k=n[d+=1],g=!0;let S=d>w+1?d-2:h-1;if(m[S])return n;l.push(S),m[S]=!0,f=S+c,u=void 0}else g=!0}p=k}if(g&&a&&a(),l.length===0)return n;s&&s();let v=n.slice(0,l[0]);for(let k=0;k<l.length;++k){let S=l[k],E=l[k+1]||n.length;S===0?v=`
|
|
12
|
+
${e}${n.slice(0,E)}`:(t===tn&&m[S]&&(v+=`${n[S]}\\`),v+=`
|
|
13
|
+
${e}${n.slice(S+1,E)}`)}return v}function Uo(n,e,t){let r=e,i=e+1,o=n[i];for(;o===" "||o===" ";)if(e<i+t)o=n[++e];else{do o=n[++e];while(o&&o!==`
|
|
14
|
+
`);r=e,i=e+1,o=n[i]}return r}st.FOLD_BLOCK=Cr;st.FOLD_FLOW=Eu;st.FOLD_QUOTED=tn;st.foldFlowLines=_u});var ct=y(Yo=>{"use strict";var G=A(),ce=Ho(),rn=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),on=n=>/^(%|---|\.\.\.)/m.test(n);function xu(n,e,t){if(!e||e<0)return!1;let r=e-t,i=n.length;if(i<=r)return!1;for(let o=0,s=0;o<i;++o)if(n[o]===`
|
|
15
|
+
`){if(o-s>r)return!0;if(s=o+1,i-s<=r)return!1}return!0}function at(n,e){let t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:r}=e,i=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(on(n)?" ":""),s="",a=0;for(let c=0,l=t[c];l;l=t[++c])if(l===" "&&t[c+1]==="\\"&&t[c+2]==="n"&&(s+=t.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(t[c+1]){case"u":{s+=t.slice(a,c);let m=t.substr(c+2,4);switch(m){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:m.substr(0,2)==="00"?s+="\\x"+m.substr(2):s+=t.substr(c,6)}c+=5,a=c+1}break;case"n":if(r||t[c+2]==='"'||t.length<i)c+=1;else{for(s+=t.slice(a,c)+`
|
|
16
|
+
|
|
17
|
+
`;t[c+2]==="\\"&&t[c+3]==="n"&&t[c+4]!=='"';)s+=`
|
|
18
|
+
`,c+=2;s+=o,t[c+2]===" "&&(s+="\\"),c+=1,a=c+1}break;default:c+=1}return s=a?s+t.slice(a):t,r?s:ce.foldFlowLines(s,o,ce.FOLD_QUOTED,rn(e,!1))}function Er(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
|
|
19
|
+
`)||/[ \t]\n|\n[ \t]/.test(n))return at(n,e);let t=e.indent||(on(n)?" ":""),r="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
20
|
+
${t}`)+"'";return e.implicitKey?r:ce.foldFlowLines(r,t,ce.FOLD_FLOW,rn(e,!1))}function Fe(n,e){let{singleQuote:t}=e.options,r;if(t===!1)r=at;else{let i=n.includes('"'),o=n.includes("'");i&&!o?r=Er:o&&!i?r=at:r=t?Er:at}return r(n,e)}var _r;try{_r=new RegExp(`(^|(?<!
|
|
21
|
+
))
|
|
22
|
+
+(?!
|
|
23
|
+
|$)`,"g")}catch{_r=/\n+(?!\n|$)/g}function nn({comment:n,type:e,value:t},r,i,o){let{blockQuote:s,commentString:a,lineWidth:c}=r.options;if(!s||/\n[\t ]+$/.test(t))return Fe(t,r);let l=r.indent||(r.forceBlockIndent||on(t)?" ":""),m=s==="literal"?!0:s==="folded"||e===G.Scalar.BLOCK_FOLDED?!1:e===G.Scalar.BLOCK_LITERAL?!0:!xu(t,c,l.length);if(!t)return m?`|
|
|
24
|
+
`:`>
|
|
25
|
+
`;let f,u;for(u=t.length;u>0;--u){let E=t[u-1];if(E!==`
|
|
26
|
+
`&&E!==" "&&E!==" ")break}let p=t.substring(u),g=p.indexOf(`
|
|
27
|
+
`);g===-1?f="-":t===p||g!==p.length-1?(f="+",o&&o()):f="",p&&(t=t.slice(0,-p.length),p[p.length-1]===`
|
|
28
|
+
`&&(p=p.slice(0,-1)),p=p.replace(_r,`$&${l}`));let d=!1,h,w=-1;for(h=0;h<t.length;++h){let E=t[h];if(E===" ")d=!0;else if(E===`
|
|
29
|
+
`)w=h;else break}let v=t.substring(0,w<h?w+1:h);v&&(t=t.substring(v.length),v=v.replace(/\n+/g,`$&${l}`));let S=(d?l?"2":"1":"")+f;if(n&&(S+=" "+a(n.replace(/ ?[\r\n]+/g," ")),i&&i()),!m){let E=t.replace(/\n+/g,`
|
|
30
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),C=!1,N=rn(r,!0);s!=="folded"&&e!==G.Scalar.BLOCK_FOLDED&&(N.onOverflow=()=>{C=!0});let b=ce.foldFlowLines(`${v}${E}${p}`,l,ce.FOLD_BLOCK,N);if(!C)return`>${S}
|
|
31
|
+
${l}${b}`}return t=t.replace(/\n+/g,`$&${l}`),`|${S}
|
|
32
|
+
${l}${v}${t}${p}`}function Pu(n,e,t,r){let{type:i,value:o}=n,{actualString:s,implicitKey:a,indent:c,indentStep:l,inFlow:m}=e;if(a&&o.includes(`
|
|
33
|
+
`)||m&&/[[\]{},]/.test(o))return Fe(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||m||!o.includes(`
|
|
34
|
+
`)?Fe(o,e):nn(n,e,t,r);if(!a&&!m&&i!==G.Scalar.PLAIN&&o.includes(`
|
|
35
|
+
`))return nn(n,e,t,r);if(on(o)){if(c==="")return e.forceBlockIndent=!0,nn(n,e,t,r);if(a&&c===l)return Fe(o,e)}let f=o.replace(/\n+/g,`$&
|
|
36
|
+
${c}`);if(s){let u=d=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(f),{compat:p,tags:g}=e.doc.schema;if(g.some(u)||p?.some(u))return Fe(o,e)}return a?f:ce.foldFlowLines(f,c,ce.FOLD_FLOW,rn(e,!1))}function Ru(n,e,t,r){let{implicitKey:i,inFlow:o}=e,s=typeof n.value=="string"?n:Object.assign({},n,{value:String(n.value)}),{type:a}=n;a!==G.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=G.Scalar.QUOTE_DOUBLE);let c=m=>{switch(m){case G.Scalar.BLOCK_FOLDED:case G.Scalar.BLOCK_LITERAL:return i||o?Fe(s.value,e):nn(s,e,t,r);case G.Scalar.QUOTE_DOUBLE:return at(s.value,e);case G.Scalar.QUOTE_SINGLE:return Er(s.value,e);case G.Scalar.PLAIN:return Pu(s,e,t,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:m,defaultStringType:f}=e.options,u=i&&m||f;if(l=c(u),l===null)throw new Error(`Unsupported default string type ${u}`)}return l}Yo.stringifyString=Ru});var lt=y(xr=>{"use strict";var Nu=Gt(),le=_(),Au=ot(),Tu=ct();function Ou(n,e){let t=Object.assign({blockQuote:!0,commentString:Au.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},n.schema.toStringOptions,e),r;switch(t.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:n,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:r,options:t}}function Iu(n,e){if(e.tag){let i=n.filter(o=>o.tag===e.tag);if(i.length>0)return i.find(o=>o.format===e.format)??i[0]}let t,r;if(le.isScalar(e)){r=e.value;let i=n.filter(o=>o.identify?.(r));if(i.length>1){let o=i.filter(s=>s.test);o.length>0&&(i=o)}t=i.find(o=>o.format===e.format)??i.find(o=>!o.format)}else r=e,t=n.find(i=>i.nodeClass&&r instanceof i.nodeClass);if(!t){let i=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${i} value`)}return t}function ju(n,e,{anchors:t,doc:r}){if(!r.directives)return"";let i=[],o=(le.isScalar(n)||le.isCollection(n))&&n.anchor;o&&Nu.anchorIsValid(o)&&(t.add(o),i.push(`&${o}`));let s=n.tag??(e.default?null:e.tag);return s&&i.push(r.directives.tagString(s)),i.join(" ")}function Lu(n,e,t,r){if(le.isPair(n))return n.toString(e,t,r);if(le.isAlias(n)){if(e.doc.directives)return n.toString(e);if(e.resolvedAliases?.has(n))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(n):e.resolvedAliases=new Set([n]),n=n.resolve(e.doc)}let i,o=le.isNode(n)?n:e.doc.createNode(n,{onTagObj:c=>i=c});i??(i=Iu(e.doc.schema.tags,o));let s=ju(o,i,e);s.length>0&&(e.indentAtStart=(e.indentAtStart??0)+s.length+1);let a=typeof i.stringify=="function"?i.stringify(o,e,t,r):le.isScalar(o)?Tu.stringifyString(o,e,t,r):o.toString(e,t,r);return s?le.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
|
|
37
|
+
${e.indent}${a}`:a}xr.createStringifyContext=Ou;xr.stringify=Lu});var zo=y(Go=>{"use strict";var ne=_(),Jo=A(),Vo=lt(),ut=ot();function Du({key:n,value:e},t,r,i){let{allNullValues:o,doc:s,indent:a,indentStep:c,options:{commentString:l,indentSeq:m,simpleKeys:f}}=t,u=ne.isNode(n)&&n.comment||null;if(f){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(ne.isCollection(n)||!ne.isNode(n)&&typeof n=="object"){let N="With simple keys, collection cannot be used as a key value";throw new Error(N)}}let p=!f&&(!n||u&&e==null&&!t.inFlow||ne.isCollection(n)||(ne.isScalar(n)?n.type===Jo.Scalar.BLOCK_FOLDED||n.type===Jo.Scalar.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(f||!o),indent:a+c});let g=!1,d=!1,h=Vo.stringify(n,t,()=>g=!0,()=>d=!0);if(!p&&!t.inFlow&&h.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(t.inFlow){if(o||e==null)return g&&r&&r(),h===""?"?":p?`? ${h}`:h}else if(o&&!f||e==null&&p)return h=`? ${h}`,u&&!g?h+=ut.lineComment(h,t.indent,l(u)):d&&i&&i(),h;g&&(u=null),p?(u&&(h+=ut.lineComment(h,t.indent,l(u))),h=`? ${h}
|
|
38
|
+
${a}:`):(h=`${h}:`,u&&(h+=ut.lineComment(h,t.indent,l(u))));let w,v,k;ne.isNode(e)?(w=!!e.spaceBefore,v=e.commentBefore,k=e.comment):(w=!1,v=null,k=null,e&&typeof e=="object"&&(e=s.createNode(e))),t.implicitKey=!1,!p&&!u&&ne.isScalar(e)&&(t.indentAtStart=h.length+1),d=!1,!m&&c.length>=2&&!t.inFlow&&!p&&ne.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let S=!1,E=Vo.stringify(e,t,()=>S=!0,()=>d=!0),C=" ";if(u||w||v){if(C=w?`
|
|
39
|
+
`:"",v){let N=l(v);C+=`
|
|
40
|
+
${ut.indentComment(N,t.indent)}`}E===""&&!t.inFlow?C===`
|
|
41
|
+
`&&k&&(C=`
|
|
42
|
+
|
|
43
|
+
`):C+=`
|
|
44
|
+
${t.indent}`}else if(!p&&ne.isCollection(e)){let N=E[0],b=E.indexOf(`
|
|
45
|
+
`),O=b!==-1,ie=t.inFlow??e.flow??e.items.length===0;if(O||!ie){let De=!1;if(O&&(N==="&"||N==="!")){let I=E.indexOf(" ");N==="&"&&I!==-1&&I<b&&E[I+1]==="!"&&(I=E.indexOf(" ",I+1)),(I===-1||b<I)&&(De=!0)}De||(C=`
|
|
46
|
+
${t.indent}`)}}else(E===""||E[0]===`
|
|
47
|
+
`)&&(C="");return h+=C+E,t.inFlow?S&&r&&r():k&&!S?h+=ut.lineComment(h,t.indent,l(k)):d&&i&&i(),h}Go.stringifyPair=Du});var Rr=y(Pr=>{"use strict";var Xo=Wt("process");function qu(n,...e){n==="debug"&&console.log(...e)}function Mu(n,e){(n==="debug"||n==="warn")&&(typeof Xo.emitWarning=="function"?Xo.emitWarning(e):console.warn(e))}Pr.debug=qu;Pr.warn=Mu});var un=y(ln=>{"use strict";var cn=_(),Qo=A(),sn="<<",an={identify:n=>n===sn||typeof n=="symbol"&&n.description===sn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Qo.Scalar(Symbol(sn)),{addToJSMap:Zo}),stringify:()=>sn},$u=(n,e)=>(an.identify(e)||cn.isScalar(e)&&(!e.type||e.type===Qo.Scalar.PLAIN)&&an.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===an.tag&&t.default);function Zo(n,e,t){let r=es(n,t);if(cn.isSeq(r))for(let i of r.items)Nr(n,e,i);else if(Array.isArray(r))for(let i of r)Nr(n,e,i);else Nr(n,e,r)}function Nr(n,e,t){let r=es(n,t);if(!cn.isMap(r))throw new Error("Merge sources must be maps or map aliases");let i=r.toJSON(null,n,Map);for(let[o,s]of i)e instanceof Map?e.has(o)||e.set(o,s):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0});return e}function es(n,e){return n&&cn.isAlias(e)?e.resolve(n.doc,n):e}ln.addMergeToJSMap=Zo;ln.isMergeKey=$u;ln.merge=an});var Tr=y(rs=>{"use strict";var Wu=Rr(),ts=un(),Fu=lt(),ns=_(),Ar=se();function Bu(n,e,{key:t,value:r}){if(ns.isNode(t)&&t.addToJSMap)t.addToJSMap(n,e,r);else if(ts.isMergeKey(n,t))ts.addMergeToJSMap(n,e,r);else{let i=Ar.toJS(t,"",n);if(e instanceof Map)e.set(i,Ar.toJS(r,i,n));else if(e instanceof Set)e.add(i);else{let o=Ku(t,i,n),s=Ar.toJS(r,o,n);o in e?Object.defineProperty(e,o,{value:s,writable:!0,enumerable:!0,configurable:!0}):e[o]=s}}return e}function Ku(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(ns.isNode(n)&&t?.doc){let r=Fu.createStringifyContext(t.doc,{});r.anchors=new Set;for(let o of t.anchors.keys())r.anchors.add(o.anchor);r.inFlow=!0,r.inStringifyKey=!0;let i=n.toString(r);if(!t.mapKeyWarned){let o=JSON.stringify(i);o.length>40&&(o=o.substring(0,36)+'..."'),Wu.warn(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return i}return JSON.stringify(e)}rs.addPairToJSMap=Bu});var ue=y(Or=>{"use strict";var is=it(),Uu=zo(),Hu=Tr(),fn=_();function Yu(n,e,t){let r=is.createNode(n,void 0,t),i=is.createNode(e,void 0,t);return new dn(r,i)}var dn=class n{constructor(e,t=null){Object.defineProperty(this,fn.NODE_TYPE,{value:fn.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return fn.isNode(t)&&(t=t.clone(e)),fn.isNode(r)&&(r=r.clone(e)),new n(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return Hu.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?Uu.stringifyPair(this,e,t,r):JSON.stringify(this)}};Or.Pair=dn;Or.createPair=Yu});var Ir=y(ss=>{"use strict";var Ee=_(),os=lt(),mn=ot();function Ju(n,e,t){return(e.inFlow??n.flow?Gu:Vu)(n,e,t)}function Vu({comment:n,items:e},t,{blockItemPrefix:r,flowChars:i,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:l}}=t,m=Object.assign({},t,{indent:o,type:null}),f=!1,u=[];for(let g=0;g<e.length;++g){let d=e[g],h=null;if(Ee.isNode(d))!f&&d.spaceBefore&&u.push(""),pn(t,u,d.commentBefore,f),d.comment&&(h=d.comment);else if(Ee.isPair(d)){let v=Ee.isNode(d.key)?d.key:null;v&&(!f&&v.spaceBefore&&u.push(""),pn(t,u,v.commentBefore,f))}f=!1;let w=os.stringify(d,m,()=>h=null,()=>f=!0);h&&(w+=mn.lineComment(w,o,l(h))),f&&h&&(f=!1),u.push(r+w)}let p;if(u.length===0)p=i.start+i.end;else{p=u[0];for(let g=1;g<u.length;++g){let d=u[g];p+=d?`
|
|
48
|
+
${c}${d}`:`
|
|
49
|
+
`}}return n?(p+=`
|
|
50
|
+
`+mn.indentComment(l(n),c),a&&a()):f&&s&&s(),p}function Gu({items:n},e,{flowChars:t,itemIndent:r}){let{indent:i,indentStep:o,flowCollectionPadding:s,options:{commentString:a}}=e;r+=o;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,m=0,f=[];for(let g=0;g<n.length;++g){let d=n[g],h=null;if(Ee.isNode(d))d.spaceBefore&&f.push(""),pn(e,f,d.commentBefore,!1),d.comment&&(h=d.comment);else if(Ee.isPair(d)){let v=Ee.isNode(d.key)?d.key:null;v&&(v.spaceBefore&&f.push(""),pn(e,f,v.commentBefore,!1),v.comment&&(l=!0));let k=Ee.isNode(d.value)?d.value:null;k?(k.comment&&(h=k.comment),k.commentBefore&&(l=!0)):d.value==null&&v?.comment&&(h=v.comment)}h&&(l=!0);let w=os.stringify(d,c,()=>h=null);l||(l=f.length>m||w.includes(`
|
|
51
|
+
`)),g<n.length-1?w+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=f.reduce((v,k)=>v+k.length+2,2)+(w.length+2)>e.options.lineWidth)),l&&(w+=",")),h&&(w+=mn.lineComment(w,r,a(h))),f.push(w),m=f.length}let{start:u,end:p}=t;if(f.length===0)return u+p;if(!l){let g=f.reduce((d,h)=>d+h.length+2,2);l=e.options.lineWidth>0&&g>e.options.lineWidth}if(l){let g=u;for(let d of f)g+=d?`
|
|
52
|
+
${o}${i}${d}`:`
|
|
53
|
+
`;return`${g}
|
|
54
|
+
${i}${p}`}else return`${u}${s}${f.join(" ")}${s}${p}`}function pn({indent:n,options:{commentString:e}},t,r,i){if(r&&i&&(r=r.replace(/^\n+/,"")),r){let o=mn.indentComment(e(r),n);t.push(o.trimStart())}}ss.stringifyCollection=Ju});var de=y(Lr=>{"use strict";var zu=Ir(),Xu=Tr(),Qu=Zt(),fe=_(),hn=ue(),Zu=A();function ft(n,e){let t=fe.isScalar(e)?e.value:e;for(let r of n)if(fe.isPair(r)&&(r.key===e||r.key===t||fe.isScalar(r.key)&&r.key.value===t))return r}var jr=class extends Qu.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(fe.MAP,e),this.items=[]}static from(e,t,r){let{keepUndefined:i,replacer:o}=r,s=new this(e),a=(c,l)=>{if(typeof o=="function")l=o.call(t,c,l);else if(Array.isArray(o)&&!o.includes(c))return;(l!==void 0||i)&&s.items.push(hn.createPair(c,l,r))};if(t instanceof Map)for(let[c,l]of t)a(c,l);else if(t&&typeof t=="object")for(let c of Object.keys(t))a(c,t[c]);return typeof e.sortMapEntries=="function"&&s.items.sort(e.sortMapEntries),s}add(e,t){let r;fe.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new hn.Pair(e,e?.value):r=new hn.Pair(e.key,e.value);let i=ft(this.items,r.key),o=this.schema?.sortMapEntries;if(i){if(!t)throw new Error(`Key ${r.key} already set`);fe.isScalar(i.value)&&Zu.isScalarValue(r.value)?i.value.value=r.value:i.value=r.value}else if(o){let s=this.items.findIndex(a=>o(r,a)<0);s===-1?this.items.push(r):this.items.splice(s,0,r)}else this.items.push(r)}delete(e){let t=ft(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let i=ft(this.items,e)?.value;return(!t&&fe.isScalar(i)?i.value:i)??void 0}has(e){return!!ft(this.items,e)}set(e,t){this.add(new hn.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let o of this.items)Xu.addPairToJSMap(t,i,o);return i}toString(e,t,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!fe.isPair(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),zu.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}};Lr.YAMLMap=jr;Lr.findPair=ft});var Be=y(cs=>{"use strict";var ef=_(),as=de(),tf={collection:"map",default:!0,nodeClass:as.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(n,e){return ef.isMap(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>as.YAMLMap.from(n,e,t)};cs.map=tf});var me=y(ls=>{"use strict";var nf=it(),rf=Ir(),of=Zt(),wn=_(),sf=A(),af=se(),Dr=class extends of.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(wn.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=gn(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let r=gn(e);if(typeof r!="number")return;let i=this.items[r];return!t&&wn.isScalar(i)?i.value:i}has(e){let t=gn(e);return typeof t=="number"&&t<this.items.length}set(e,t){let r=gn(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let i=this.items[r];wn.isScalar(i)&&sf.isScalarValue(t)?i.value=t:this.items[r]=t}toJSON(e,t){let r=[];t?.onCreate&&t.onCreate(r);let i=0;for(let o of this.items)r.push(af.toJS(o,String(i++),t));return r}toString(e,t,r){return e?rf.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,t,r){let{replacer:i}=r,o=new this(e);if(t&&Symbol.iterator in Object(t)){let s=0;for(let a of t){if(typeof i=="function"){let c=t instanceof Set?a:String(s++);a=i.call(t,c,a)}o.items.push(nf.createNode(a,void 0,r))}}return o}};function gn(n){let e=wn.isScalar(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}ls.YAMLSeq=Dr});var Ke=y(fs=>{"use strict";var cf=_(),us=me(),lf={collection:"seq",default:!0,nodeClass:us.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(n,e){return cf.isSeq(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>us.YAMLSeq.from(n,e,t)};fs.seq=lf});var dt=y(ds=>{"use strict";var uf=ct(),ff={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,e,t,r){return e=Object.assign({actualString:!0},e),uf.stringifyString(n,e,t,r)}};ds.string=ff});var yn=y(hs=>{"use strict";var ms=A(),ps={identify:n=>n==null,createNode:()=>new ms.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ms.Scalar(null),stringify:({source:n},e)=>typeof n=="string"&&ps.test.test(n)?n:e.options.nullStr};hs.nullTag=ps});var qr=y(ws=>{"use strict";var df=A(),gs={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new df.Scalar(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&gs.test.test(n)){let r=n[0]==="t"||n[0]==="T";if(e===r)return n}return e?t.options.trueStr:t.options.falseStr}};ws.boolTag=gs});var Ue=y(ys=>{"use strict";function mf({format:n,minFractionDigits:e,tag:t,value:r}){if(typeof r=="bigint")return String(r);let i=typeof r=="number"?r:Number(r);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let o=Object.is(r,-0)?"-0":JSON.stringify(r);if(!n&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let s=o.indexOf(".");s<0&&(s=o.length,o+=".");let a=e-(o.length-s-1);for(;a-- >0;)o+="0"}return o}ys.stringifyNumber=mf});var $r=y(vn=>{"use strict";var pf=A(),Mr=Ue(),hf={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Mr.stringifyNumber},gf={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n),stringify(n){let e=Number(n.value);return isFinite(e)?e.toExponential():Mr.stringifyNumber(n)}},wf={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(n){let e=new pf.Scalar(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:Mr.stringifyNumber};vn.float=wf;vn.floatExp=gf;vn.floatNaN=hf});var Fr=y(kn=>{"use strict";var vs=Ue(),bn=n=>typeof n=="bigint"||Number.isInteger(n),Wr=(n,e,t,{intAsBigInt:r})=>r?BigInt(n):parseInt(n.substring(e),t);function bs(n,e,t){let{value:r}=n;return bn(r)&&r>=0?t+r.toString(e):vs.stringifyNumber(n)}var yf={identify:n=>bn(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Wr(n,2,8,t),stringify:n=>bs(n,8,"0o")},vf={identify:bn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Wr(n,0,10,t),stringify:vs.stringifyNumber},bf={identify:n=>bn(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Wr(n,2,16,t),stringify:n=>bs(n,16,"0x")};kn.int=vf;kn.intHex=bf;kn.intOct=yf});var Ss=y(ks=>{"use strict";var kf=Be(),Sf=yn(),Cf=Ke(),Ef=dt(),_f=qr(),Br=$r(),Kr=Fr(),xf=[kf.map,Cf.seq,Ef.string,Sf.nullTag,_f.boolTag,Kr.intOct,Kr.int,Kr.intHex,Br.floatNaN,Br.floatExp,Br.float];ks.schema=xf});var _s=y(Es=>{"use strict";var Pf=A(),Rf=Be(),Nf=Ke();function Cs(n){return typeof n=="bigint"||Number.isInteger(n)}var Sn=({value:n})=>JSON.stringify(n),Af=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:Sn},{identify:n=>n==null,createNode:()=>new Pf.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Sn},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:Sn},{identify:Cs,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(n,e,{intAsBigInt:t})=>t?BigInt(n):parseInt(n,10),stringify:({value:n})=>Cs(n)?n.toString():JSON.stringify(n)},{identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:n=>parseFloat(n),stringify:Sn}],Tf={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},Of=[Rf.map,Nf.seq].concat(Af,Tf);Es.schema=Of});var Hr=y(xs=>{"use strict";var mt=Wt("buffer"),Ur=A(),If=ct(),jf={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof mt.Buffer=="function")return mt.Buffer.from(n,"base64");if(typeof atob=="function"){let t=atob(n.replace(/[\n\r]/g,"")),r=new Uint8Array(t.length);for(let i=0;i<t.length;++i)r[i]=t.charCodeAt(i);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),n},stringify({comment:n,type:e,value:t},r,i,o){if(!t)return"";let s=t,a;if(typeof mt.Buffer=="function")a=s instanceof mt.Buffer?s.toString("base64"):mt.Buffer.from(s.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<s.length;++l)c+=String.fromCharCode(s[l]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Ur.Scalar.BLOCK_LITERAL),e!==Ur.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(a.length/c),m=new Array(l);for(let f=0,u=0;f<l;++f,u+=c)m[f]=a.substr(u,c);a=m.join(e===Ur.Scalar.BLOCK_LITERAL?`
|
|
55
|
+
`:" ")}return If.stringifyString({comment:n,type:e,value:a},r,i,o)}};xs.binary=jf});var _n=y(En=>{"use strict";var Cn=_(),Yr=ue(),Lf=A(),Df=me();function Ps(n,e){if(Cn.isSeq(n))for(let t=0;t<n.items.length;++t){let r=n.items[t];if(!Cn.isPair(r)){if(Cn.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let i=r.items[0]||new Yr.Pair(new Lf.Scalar(null));if(r.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${r.commentBefore}
|
|
56
|
+
${i.key.commentBefore}`:r.commentBefore),r.comment){let o=i.value??i.key;o.comment=o.comment?`${r.comment}
|
|
57
|
+
${o.comment}`:r.comment}r=i}n.items[t]=Cn.isPair(r)?r:new Yr.Pair(r)}}else e("Expected a sequence for this tag");return n}function Rs(n,e,t){let{replacer:r}=t,i=new Df.YAMLSeq(n);i.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let s of e){typeof r=="function"&&(s=r.call(e,String(o++),s));let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw new TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let l=Object.keys(s);if(l.length===1)a=l[0],c=s[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;i.items.push(Yr.createPair(a,c,t))}return i}var qf={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ps,createNode:Rs};En.createPairs=Rs;En.pairs=qf;En.resolvePairs=Ps});var Gr=y(Vr=>{"use strict";var Ns=_(),Jr=se(),pt=de(),Mf=me(),As=_n(),_e=class n extends Mf.YAMLSeq{constructor(){super(),this.add=pt.YAMLMap.prototype.add.bind(this),this.delete=pt.YAMLMap.prototype.delete.bind(this),this.get=pt.YAMLMap.prototype.get.bind(this),this.has=pt.YAMLMap.prototype.has.bind(this),this.set=pt.YAMLMap.prototype.set.bind(this),this.tag=n.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;t?.onCreate&&t.onCreate(r);for(let i of this.items){let o,s;if(Ns.isPair(i)?(o=Jr.toJS(i.key,"",t),s=Jr.toJS(i.value,o,t)):o=Jr.toJS(i,"",t),r.has(o))throw new Error("Ordered maps must not include duplicate keys");r.set(o,s)}return r}static from(e,t,r){let i=As.createPairs(e,t,r),o=new this;return o.items=i.items,o}};_e.tag="tag:yaml.org,2002:omap";var $f={collection:"seq",identify:n=>n instanceof Map,nodeClass:_e,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=As.resolvePairs(n,e),r=[];for(let{key:i}of t.items)Ns.isScalar(i)&&(r.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):r.push(i.value));return Object.assign(new _e,t)},createNode:(n,e,t)=>_e.from(n,e,t)};Vr.YAMLOMap=_e;Vr.omap=$f});var Ls=y(zr=>{"use strict";var Ts=A();function Os({value:n,source:e},t){return e&&(n?Is:js).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var Is={identify:n=>n===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ts.Scalar(!0),stringify:Os},js={identify:n=>n===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ts.Scalar(!1),stringify:Os};zr.falseTag=js;zr.trueTag=Is});var Ds=y(xn=>{"use strict";var Wf=A(),Xr=Ue(),Ff={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Xr.stringifyNumber},Bf={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n.replace(/_/g,"")),stringify(n){let e=Number(n.value);return isFinite(e)?e.toExponential():Xr.stringifyNumber(n)}},Kf={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(n){let e=new Wf.Scalar(parseFloat(n.replace(/_/g,""))),t=n.indexOf(".");if(t!==-1){let r=n.substring(t+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:Xr.stringifyNumber};xn.float=Kf;xn.floatExp=Bf;xn.floatNaN=Ff});var Ms=y(gt=>{"use strict";var qs=Ue(),ht=n=>typeof n=="bigint"||Number.isInteger(n);function Pn(n,e,t,{intAsBigInt:r}){let i=n[0];if((i==="-"||i==="+")&&(e+=1),n=n.substring(e).replace(/_/g,""),r){switch(t){case 2:n=`0b${n}`;break;case 8:n=`0o${n}`;break;case 16:n=`0x${n}`;break}let s=BigInt(n);return i==="-"?BigInt(-1)*s:s}let o=parseInt(n,t);return i==="-"?-1*o:o}function Qr(n,e,t){let{value:r}=n;if(ht(r)){let i=r.toString(e);return r<0?"-"+t+i.substr(1):t+i}return qs.stringifyNumber(n)}var Uf={identify:ht,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Pn(n,2,2,t),stringify:n=>Qr(n,2,"0b")},Hf={identify:ht,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Pn(n,1,8,t),stringify:n=>Qr(n,8,"0")},Yf={identify:ht,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Pn(n,0,10,t),stringify:qs.stringifyNumber},Jf={identify:ht,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Pn(n,2,16,t),stringify:n=>Qr(n,16,"0x")};gt.int=Yf;gt.intBin=Uf;gt.intHex=Jf;gt.intOct=Hf});var ei=y(Zr=>{"use strict";var An=_(),Rn=ue(),Nn=de(),xe=class n extends Nn.YAMLMap{constructor(e){super(e),this.tag=n.tag}add(e){let t;An.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Rn.Pair(e.key,null):t=new Rn.Pair(e,null),Nn.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=Nn.findPair(this.items,e);return!t&&An.isPair(r)?An.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=Nn.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new Rn.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);throw new Error("Set items must all have null values")}static from(e,t,r){let{replacer:i}=r,o=new this(e);if(t&&Symbol.iterator in Object(t))for(let s of t)typeof i=="function"&&(s=i.call(t,s,s)),o.items.push(Rn.createPair(s,null,r));return o}};xe.tag="tag:yaml.org,2002:set";var Vf={collection:"map",identify:n=>n instanceof Set,nodeClass:xe,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>xe.from(n,e,t),resolve(n,e){if(An.isMap(n)){if(n.hasAllNullValues(!0))return Object.assign(new xe,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};Zr.YAMLSet=xe;Zr.set=Vf});var ni=y(Tn=>{"use strict";var Gf=Ue();function ti(n,e){let t=n[0],r=t==="-"||t==="+"?n.substring(1):n,i=s=>e?BigInt(s):Number(s),o=r.replace(/_/g,"").split(":").reduce((s,a)=>s*i(60)+i(a),i(0));return t==="-"?i(-1)*o:o}function $s(n){let{value:e}=n,t=s=>s;if(typeof e=="bigint")t=s=>BigInt(s);else if(isNaN(e)||!isFinite(e))return Gf.stringifyNumber(n);let r="";e<0&&(r="-",e*=t(-1));let i=t(60),o=[e%i];return e<60?o.unshift(0):(e=(e-o[0])/i,o.unshift(e%i),e>=60&&(e=(e-o[0])/i,o.unshift(e))),r+o.map(s=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var zf={identify:n=>typeof n=="bigint"||Number.isInteger(n),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(n,e,{intAsBigInt:t})=>ti(n,t),stringify:$s},Xf={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:n=>ti(n,!1),stringify:$s},Ws={identify:n=>n 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(n){let e=n.match(Ws.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,r,i,o,s,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(t,r-1,i,o||0,s||0,a||0,c),m=e[8];if(m&&m!=="Z"){let f=ti(m,!1);Math.abs(f)<30&&(f*=60),l-=6e4*f}return new Date(l)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Tn.floatTime=Xf;Tn.intTime=zf;Tn.timestamp=Ws});var Ks=y(Bs=>{"use strict";var Qf=Be(),Zf=yn(),ed=Ke(),td=dt(),nd=Hr(),Fs=Ls(),ri=Ds(),On=Ms(),rd=un(),id=Gr(),od=_n(),sd=ei(),ii=ni(),ad=[Qf.map,ed.seq,td.string,Zf.nullTag,Fs.trueTag,Fs.falseTag,On.intBin,On.intOct,On.int,On.intHex,ri.floatNaN,ri.floatExp,ri.float,nd.binary,rd.merge,id.omap,od.pairs,sd.set,ii.intTime,ii.floatTime,ii.timestamp];Bs.schema=ad});var Zs=y(ai=>{"use strict";var Js=Be(),cd=yn(),Vs=Ke(),ld=dt(),ud=qr(),oi=$r(),si=Fr(),fd=Ss(),dd=_s(),Gs=Hr(),wt=un(),zs=Gr(),Xs=_n(),Us=Ks(),Qs=ei(),In=ni(),Hs=new Map([["core",fd.schema],["failsafe",[Js.map,Vs.seq,ld.string]],["json",dd.schema],["yaml11",Us.schema],["yaml-1.1",Us.schema]]),Ys={binary:Gs.binary,bool:ud.boolTag,float:oi.float,floatExp:oi.floatExp,floatNaN:oi.floatNaN,floatTime:In.floatTime,int:si.int,intHex:si.intHex,intOct:si.intOct,intTime:In.intTime,map:Js.map,merge:wt.merge,null:cd.nullTag,omap:zs.omap,pairs:Xs.pairs,seq:Vs.seq,set:Qs.set,timestamp:In.timestamp},md={"tag:yaml.org,2002:binary":Gs.binary,"tag:yaml.org,2002:merge":wt.merge,"tag:yaml.org,2002:omap":zs.omap,"tag:yaml.org,2002:pairs":Xs.pairs,"tag:yaml.org,2002:set":Qs.set,"tag:yaml.org,2002:timestamp":In.timestamp};function pd(n,e,t){let r=Hs.get(e);if(r&&!n)return t&&!r.includes(wt.merge)?r.concat(wt.merge):r.slice();let i=r;if(!i)if(Array.isArray(n))i=[];else{let o=Array.from(Hs.keys()).filter(s=>s!=="yaml11").map(s=>JSON.stringify(s)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(n))for(let o of n)i=i.concat(o);else typeof n=="function"&&(i=n(i.slice()));return t&&(i=i.concat(wt.merge)),i.reduce((o,s)=>{let a=typeof s=="string"?Ys[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(Ys).map(m=>JSON.stringify(m)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}ai.coreKnownTags=md;ai.getTags=pd});var ui=y(ea=>{"use strict";var ci=_(),hd=Be(),gd=Ke(),wd=dt(),jn=Zs(),yd=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,li=class n{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(e)?jn.getTags(e,"compat"):e?jn.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?jn.coreKnownTags:{},this.tags=jn.getTags(t,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,ci.MAP,{value:hd.map}),Object.defineProperty(this,ci.SCALAR,{value:wd.string}),Object.defineProperty(this,ci.SEQ,{value:gd.seq}),this.sortMapEntries=typeof s=="function"?s:s===!0?yd:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};ea.Schema=li});var na=y(ta=>{"use strict";var vd=_(),fi=lt(),yt=ot();function bd(n,e){let t=[],r=e.directives===!0;if(e.directives!==!1&&n.directives){let c=n.directives.toString(n);c?(t.push(c),r=!0):n.directives.docStart&&(r=!0)}r&&t.push("---");let i=fi.createStringifyContext(n,e),{commentString:o}=i.options;if(n.commentBefore){t.length!==1&&t.unshift("");let c=o(n.commentBefore);t.unshift(yt.indentComment(c,""))}let s=!1,a=null;if(n.contents){if(vd.isNode(n.contents)){if(n.contents.spaceBefore&&r&&t.push(""),n.contents.commentBefore){let m=o(n.contents.commentBefore);t.push(yt.indentComment(m,""))}i.forceBlockIndent=!!n.comment,a=n.contents.comment}let c=a?void 0:()=>s=!0,l=fi.stringify(n.contents,i,()=>a=null,c);a&&(l+=yt.lineComment(l,"",o(a))),(l[0]==="|"||l[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${l}`:t.push(l)}else t.push(fi.stringify(n.contents,i));if(n.directives?.docEnd)if(n.comment){let c=o(n.comment);c.includes(`
|
|
58
|
+
`)?(t.push("..."),t.push(yt.indentComment(c,""))):t.push(`... ${c}`)}else t.push("...");else{let c=n.comment;c&&s&&(c=c.replace(/^\n+/,"")),c&&((!s||a)&&t[t.length-1]!==""&&t.push(""),t.push(yt.indentComment(o(c),"")))}return t.join(`
|
|
59
|
+
`)+`
|
|
60
|
+
`}ta.stringifyDocument=bd});var vt=y(ra=>{"use strict";var kd=rt(),He=Zt(),H=_(),Sd=ue(),Cd=se(),Ed=ui(),_d=na(),di=Gt(),xd=gr(),Pd=it(),mi=hr(),pi=class n{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,H.NODE_TYPE,{value:H.DOC});let i=null;typeof t=="function"||Array.isArray(t)?i=t:r===void 0&&t&&(r=t,t=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=o;let{version:s}=o;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new mi.Directives({version:s}),this.setSchema(s,r),this.contents=e===void 0?null:this.createNode(e,i,r)}clone(){let e=Object.create(n.prototype,{[H.NODE_TYPE]:{value:H.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=H.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ye(this.contents)&&this.contents.add(e)}addIn(e,t){Ye(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=di.anchorNames(this);e.anchor=!t||r.has(t)?di.findNewAnchor(t||"a",r):t}return new kd.Alias(e.anchor)}createNode(e,t,r){let i;if(typeof t=="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){let h=v=>typeof v=="number"||v instanceof String||v instanceof Number,w=t.filter(h).map(String);w.length>0&&(t=t.concat(w)),i=t}else r===void 0&&t&&(r=t,t=void 0);let{aliasDuplicateObjects:o,anchorPrefix:s,flow:a,keepUndefined:c,onTagObj:l,tag:m}=r??{},{onAnchor:f,setAnchors:u,sourceObjects:p}=di.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:o??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:p},d=Pd.createNode(e,m,g);return a&&H.isCollection(d)&&(d.flow=!0),u(),d}createPair(e,t,r={}){let i=this.createNode(e,null,r),o=this.createNode(t,null,r);return new Sd.Pair(i,o)}delete(e){return Ye(this.contents)?this.contents.delete(e):!1}deleteIn(e){return He.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Ye(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return H.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return He.isEmptyPath(e)?!t&&H.isScalar(this.contents)?this.contents.value:this.contents:H.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return H.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return He.isEmptyPath(e)?this.contents!==void 0:H.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=He.collectionFromPath(this.schema,[e],t):Ye(this.contents)&&this.contents.set(e,t)}setIn(e,t){He.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=He.collectionFromPath(this.schema,Array.from(e),t):Ye(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new mi.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new mi.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let i=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new Ed.Schema(Object.assign(r,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:i,onAnchor:o,reviver:s}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},c=Cd.toJS(this.contents,t??"",a);if(typeof o=="function")for(let{count:l,res:m}of a.anchors.values())o(m,l);return typeof s=="function"?xd.applyReviver(s,{"":c},"",c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return _d.stringifyDocument(this,e)}};function Ye(n){if(H.isCollection(n))return!0;throw new Error("Expected a YAML collection as document contents")}ra.Document=pi});var St=y(kt=>{"use strict";var bt=class extends Error{constructor(e,t,r,i){super(),this.name=e,this.code=r,this.message=i,this.pos=t}},hi=class extends bt{constructor(e,t,r){super("YAMLParseError",e,t,r)}},gi=class extends bt{constructor(e,t,r){super("YAMLWarning",e,t,r)}},Rd=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));let{line:r,col:i}=t.linePos[0];t.message+=` at line ${r}, column ${i}`;let o=i-1,s=n.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(o>=60&&s.length>80){let a=Math.min(o-39,s.length-79);s="…"+s.substring(a),o-=a-1}if(s.length>80&&(s=s.substring(0,79)+"…"),r>1&&/^ *$/.test(s.substring(0,o))){let a=n.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`…
|
|
61
|
+
`),s=a+s}if(/[^ ]/.test(s)){let a=1,c=t.linePos[1];c?.line===r&&c.col>i&&(a=Math.max(1,Math.min(c.col-i,80-o)));let l=" ".repeat(o)+"^".repeat(a);t.message+=`:
|
|
62
|
+
|
|
63
|
+
${s}
|
|
64
|
+
${l}
|
|
65
|
+
`}};kt.YAMLError=bt;kt.YAMLParseError=hi;kt.YAMLWarning=gi;kt.prettifyError=Rd});var Ct=y(ia=>{"use strict";function Nd(n,{flow:e,indicator:t,next:r,offset:i,onError:o,parentIndent:s,startOnNewline:a}){let c=!1,l=a,m=a,f="",u="",p=!1,g=!1,d=null,h=null,w=null,v=null,k=null,S=null,E=null;for(let b of n)switch(g&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&o(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),d&&(l&&b.type!=="comment"&&b.type!=="newline"&&o(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),d=null),b.type){case"space":!e&&(t!=="doc-start"||r?.type!=="flow-collection")&&b.source.includes(" ")&&(d=b),m=!0;break;case"comment":{m||o(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let O=b.source.substring(1)||" ";f?f+=u+O:f=O,u="",l=!1;break}case"newline":l?f?f+=b.source:(!S||t!=="seq-item-ind")&&(c=!0):u+=b.source,l=!0,p=!0,(h||w)&&(v=b),m=!0;break;case"anchor":h&&o(b,"MULTIPLE_ANCHORS","A node can have at most one anchor"),b.source.endsWith(":")&&o(b.offset+b.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=b,E??(E=b.offset),l=!1,m=!1,g=!0;break;case"tag":{w&&o(b,"MULTIPLE_TAGS","A node can have at most one tag"),w=b,E??(E=b.offset),l=!1,m=!1,g=!0;break}case t:(h||w)&&o(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),S&&o(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${e??"collection"}`),S=b,l=t==="seq-item-ind"||t==="explicit-key-ind",m=!1;break;case"comma":if(e){k&&o(b,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=b,l=!1,m=!1;break}default:o(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,m=!1}let C=n[n.length-1],N=C?C.offset+C.source.length:i;return g&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&o(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),d&&(l&&d.indent<=s||r?.type==="block-map"||r?.type==="block-seq")&&o(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:c,comment:f,hasNewline:p,anchor:h,tag:w,newlineAfterProp:v,end:N,start:E??N}}ia.resolveProps=Nd});var Ln=y(oa=>{"use strict";function wi(n){if(!n)return null;switch(n.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(n.source.includes(`
|
|
66
|
+
`))return!0;if(n.end){for(let e of n.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of n.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(wi(e.key)||wi(e.value))return!0}return!1;default:return!0}}oa.containsNewline=wi});var yi=y(sa=>{"use strict";var Ad=Ln();function Td(n,e,t){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===n&&(r.source==="]"||r.source==="}")&&Ad.containsNewline(e)&&t(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}sa.flowIndentCheck=Td});var vi=y(ca=>{"use strict";var aa=_();function Od(n,e,t){let{uniqueKeys:r}=n.options;if(r===!1)return!1;let i=typeof r=="function"?r:(o,s)=>o===s||aa.isScalar(o)&&aa.isScalar(s)&&o.value===s.value;return e.some(o=>i(o.key,t))}ca.mapIncludes=Od});var pa=y(ma=>{"use strict";var la=ue(),Id=de(),ua=Ct(),jd=Ln(),fa=yi(),Ld=vi(),da="All mapping items must start at the same column";function Dd({composeNode:n,composeEmptyNode:e},t,r,i,o){let s=o?.nodeClass??Id.YAMLMap,a=new s(t.schema);t.atRoot&&(t.atRoot=!1);let c=r.offset,l=null;for(let m of r.items){let{start:f,key:u,sep:p,value:g}=m,d=ua.resolveProps(f,{indicator:"explicit-key-ind",next:u??p?.[0],offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0}),h=!d.found;if(h){if(u&&(u.type==="block-seq"?i(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==r.indent&&i(c,"BAD_INDENT",da)),!d.anchor&&!d.tag&&!p){l=d.end,d.comment&&(a.comment?a.comment+=`
|
|
67
|
+
`+d.comment:a.comment=d.comment);continue}(d.newlineAfterProp||jd.containsNewline(u))&&i(u??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else d.found?.indent!==r.indent&&i(c,"BAD_INDENT",da);t.atKey=!0;let w=d.end,v=u?n(t,u,d,i):e(t,w,f,null,d,i);t.schema.compat&&fa.flowIndentCheck(r.indent,u,i),t.atKey=!1,Ld.mapIncludes(t,a.items,v)&&i(w,"DUPLICATE_KEY","Map keys must be unique");let k=ua.resolveProps(p??[],{indicator:"map-value-ind",next:g,offset:v.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(c=k.end,k.found){h&&(g?.type==="block-map"&&!k.hasNewline&&i(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&d.start<k.found.offset-1024&&i(v.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=g?n(t,g,k,i):e(t,c,p,null,k,i);t.schema.compat&&fa.flowIndentCheck(r.indent,g,i),c=S.range[2];let E=new la.Pair(v,S);t.options.keepSourceTokens&&(E.srcToken=m),a.items.push(E)}else{h&&i(v.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(v.comment?v.comment+=`
|
|
68
|
+
`+k.comment:v.comment=k.comment);let S=new la.Pair(v);t.options.keepSourceTokens&&(S.srcToken=m),a.items.push(S)}}return l&&l<c&&i(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,l??c],a}ma.resolveBlockMap=Dd});var ga=y(ha=>{"use strict";var qd=me(),Md=Ct(),$d=yi();function Wd({composeNode:n,composeEmptyNode:e},t,r,i,o){let s=o?.nodeClass??qd.YAMLSeq,a=new s(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let c=r.offset,l=null;for(let{start:m,value:f}of r.items){let u=Md.resolveProps(m,{indicator:"seq-item-ind",next:f,offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||f)f?.type==="block-seq"?i(u.end,"BAD_INDENT","All sequence items must start at the same column"):i(c,"MISSING_CHAR","Sequence item without - indicator");else{l=u.end,u.comment&&(a.comment=u.comment);continue}let p=f?n(t,f,u,i):e(t,u.end,m,null,u,i);t.schema.compat&&$d.flowIndentCheck(r.indent,f,i),c=p.range[2],a.items.push(p)}return a.range=[r.offset,c,l??c],a}ha.resolveBlockSeq=Wd});var Je=y(wa=>{"use strict";function Fd(n,e,t,r){let i="";if(n){let o=!1,s="";for(let a of n){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{t&&!o&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let m=c.substring(1)||" ";i?i+=s+m:i=m,s="";break}case"newline":i&&(s+=c),o=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:i,offset:e}}wa.resolveEnd=Fd});var ka=y(ba=>{"use strict";var Bd=_(),Kd=ue(),ya=de(),Ud=me(),Hd=Je(),va=Ct(),Yd=Ln(),Jd=vi(),bi="Block collections are not allowed within flow collections",ki=n=>n&&(n.type==="block-map"||n.type==="block-seq");function Vd({composeNode:n,composeEmptyNode:e},t,r,i,o){let s=r.start.source==="{",a=s?"flow map":"flow sequence",c=o?.nodeClass??(s?ya.YAMLMap:Ud.YAMLSeq),l=new c(t.schema);l.flow=!0;let m=t.atRoot;m&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let f=r.offset+r.start.source.length;for(let h=0;h<r.items.length;++h){let w=r.items[h],{start:v,key:k,sep:S,value:E}=w,C=va.resolveProps(v,{flow:a,indicator:"explicit-key-ind",next:k??S?.[0],offset:f,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!S&&!E){h===0&&C.comma?i(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):h<r.items.length-1&&i(C.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),C.comment&&(l.comment?l.comment+=`
|
|
69
|
+
`+C.comment:l.comment=C.comment),f=C.end;continue}!s&&t.options.strict&&Yd.containsNewline(k)&&i(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)C.comma&&i(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(C.comma||i(C.start,"MISSING_CHAR",`Missing , between ${a} items`),C.comment){let N="";e:for(let b of v)switch(b.type){case"comma":case"space":break;case"comment":N=b.source.substring(1);break e;default:break e}if(N){let b=l.items[l.items.length-1];Bd.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
|
|
70
|
+
`+N:b.comment=N,C.comment=C.comment.substring(N.length+1)}}if(!s&&!S&&!C.found){let N=E?n(t,E,C,i):e(t,C.end,S,null,C,i);l.items.push(N),f=N.range[2],ki(E)&&i(N.range,"BLOCK_IN_FLOW",bi)}else{t.atKey=!0;let N=C.end,b=k?n(t,k,C,i):e(t,N,v,null,C,i);ki(k)&&i(b.range,"BLOCK_IN_FLOW",bi),t.atKey=!1;let O=va.resolveProps(S??[],{flow:a,indicator:"map-value-ind",next:E,offset:b.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(O.found){if(!s&&!C.found&&t.options.strict){if(S)for(let I of S){if(I===O.found)break;if(I.type==="newline"){i(I,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}C.start<O.found.offset-1024&&i(O.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?i(E,"MISSING_CHAR",`Missing space after : in ${a}`):i(O.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let ie=E?n(t,E,O,i):O.found?e(t,O.end,S,null,O,i):null;ie?ki(E)&&i(ie.range,"BLOCK_IN_FLOW",bi):O.comment&&(b.comment?b.comment+=`
|
|
71
|
+
`+O.comment:b.comment=O.comment);let De=new Kd.Pair(b,ie);if(t.options.keepSourceTokens&&(De.srcToken=w),s){let I=l;Jd.mapIncludes(t,I.items,b)&&i(N,"DUPLICATE_KEY","Map keys must be unique"),I.items.push(De)}else{let I=new ya.YAMLMap(t.schema);I.flow=!0,I.items.push(De);let fo=(ie??b).range;I.range=[b.range[0],fo[1],fo[2]],l.items.push(I)}f=ie?ie.range[2]:O.end}}let u=s?"}":"]",[p,...g]=r.end,d=f;if(p?.source===u)d=p.offset+p.source.length;else{let h=a[0].toUpperCase()+a.substring(1),w=m?`${h} must end with a ${u}`:`${h} in block collection must be sufficiently indented and end with a ${u}`;i(f,m?"MISSING_CHAR":"BAD_INDENT",w),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let h=Hd.resolveEnd(g,d,t.options.strict,i);h.comment&&(l.comment?l.comment+=`
|
|
72
|
+
`+h.comment:l.comment=h.comment),l.range=[r.offset,d,h.offset]}else l.range=[r.offset,d,d];return l}ba.resolveFlowCollection=Vd});var Ca=y(Sa=>{"use strict";var Gd=_(),zd=A(),Xd=de(),Qd=me(),Zd=pa(),em=ga(),tm=ka();function Si(n,e,t,r,i,o){let s=t.type==="block-map"?Zd.resolveBlockMap(n,e,t,r,o):t.type==="block-seq"?em.resolveBlockSeq(n,e,t,r,o):tm.resolveFlowCollection(n,e,t,r,o),a=s.constructor;return i==="!"||i===a.tagName?(s.tag=a.tagName,s):(i&&(s.tag=i),s)}function nm(n,e,t,r,i){let o=r.tag,s=o?e.directives.tagName(o.source,u=>i(o,"TAG_RESOLVE_FAILED",u)):null;if(t.type==="block-seq"){let{anchor:u,newlineAfterProp:p}=r,g=u&&o?u.offset>o.offset?u:o:u??o;g&&(!p||p.offset<g.offset)&&i(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!o||!s||s==="!"||s===Xd.YAMLMap.tagName&&a==="map"||s===Qd.YAMLSeq.tagName&&a==="seq")return Si(n,e,t,i,s);let c=e.schema.tags.find(u=>u.tag===s&&u.collection===a);if(!c){let u=e.schema.knownTags[s];if(u?.collection===a)e.schema.tags.push(Object.assign({},u,{default:!1})),c=u;else return u?i(o,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0):i(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0),Si(n,e,t,i,s)}let l=Si(n,e,t,i,s,c),m=c.resolve?.(l,u=>i(o,"TAG_RESOLVE_FAILED",u),e.options)??l,f=Gd.isNode(m)?m:new zd.Scalar(m);return f.range=l.range,f.tag=s,c?.format&&(f.format=c.format),f}Sa.composeCollection=nm});var Ei=y(Ea=>{"use strict";var Ci=A();function rm(n,e,t){let r=e.offset,i=im(e,n.options.strict,t);if(!i)return{value:"",type:null,comment:"",range:[r,r,r]};let o=i.mode===">"?Ci.Scalar.BLOCK_FOLDED:Ci.Scalar.BLOCK_LITERAL,s=e.source?om(e.source):[],a=s.length;for(let d=s.length-1;d>=0;--d){let h=s[d][1];if(h===""||h==="\r")a=d;else break}if(a===0){let d=i.chomp==="+"&&s.length>0?`
|
|
73
|
+
`.repeat(Math.max(1,s.length-1)):"",h=r+i.length;return e.source&&(h+=e.source.length),{value:d,type:o,comment:i.comment,range:[r,h,h]}}let c=e.indent+i.indent,l=e.offset+i.length,m=0;for(let d=0;d<a;++d){let[h,w]=s[d];if(w===""||w==="\r")i.indent===0&&h.length>c&&(c=h.length);else{h.length<c&&t(l+h.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),i.indent===0&&(c=h.length),m=d,c===0&&!n.atRoot&&t(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=h.length+w.length+1}for(let d=s.length-1;d>=a;--d)s[d][0].length>c&&(a=d+1);let f="",u="",p=!1;for(let d=0;d<m;++d)f+=s[d][0].slice(c)+`
|
|
74
|
+
`;for(let d=m;d<a;++d){let[h,w]=s[d];l+=h.length+w.length+1;let v=w[w.length-1]==="\r";if(v&&(w=w.slice(0,-1)),w&&h.length<c){let S=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;t(l-w.length-(v?2:1),"BAD_INDENT",S),h=""}o===Ci.Scalar.BLOCK_LITERAL?(f+=u+h.slice(c)+w,u=`
|
|
75
|
+
`):h.length>c||w[0]===" "?(u===" "?u=`
|
|
76
|
+
`:!p&&u===`
|
|
77
|
+
`&&(u=`
|
|
78
|
+
|
|
79
|
+
`),f+=u+h.slice(c)+w,u=`
|
|
80
|
+
`,p=!0):w===""?u===`
|
|
81
|
+
`?f+=`
|
|
82
|
+
`:u=`
|
|
83
|
+
`:(f+=u+w,u=" ",p=!1)}switch(i.chomp){case"-":break;case"+":for(let d=a;d<s.length;++d)f+=`
|
|
84
|
+
`+s[d][0].slice(c);f[f.length-1]!==`
|
|
85
|
+
`&&(f+=`
|
|
86
|
+
`);break;default:f+=`
|
|
87
|
+
`}let g=r+i.length+e.source.length;return{value:f,type:o,comment:i.comment,range:[r,g,g]}}function im({offset:n,props:e},t,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=e[0],o=i[0],s=0,a="",c=-1;for(let u=1;u<i.length;++u){let p=i[u];if(!a&&(p==="-"||p==="+"))a=p;else{let g=Number(p);!s&&g?s=g:c===-1&&(c=n+u)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let l=!1,m="",f=i.length;for(let u=1;u<e.length;++u){let p=e[u];switch(p.type){case"space":l=!0;case"newline":f+=p.source.length;break;case"comment":t&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=p.source.length,m=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),f+=p.source.length;break;default:{let g=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",g);let d=p.source;d&&typeof d=="string"&&(f+=d.length)}}}return{mode:o,indent:s,chomp:a,comment:m,length:f}}function om(n){let e=n.split(/\n( *)/),t=e[0],r=t.match(/^( *)/),o=[r?.[1]?[r[1],t.slice(r[1].length)]:["",t]];for(let s=1;s<e.length;s+=2)o.push([e[s],e[s+1]]);return o}Ea.resolveBlockScalar=rm});var xi=y(xa=>{"use strict";var _i=A(),sm=Je();function am(n,e,t){let{offset:r,type:i,source:o,end:s}=n,a,c,l=(u,p,g)=>t(r+u,p,g);switch(i){case"scalar":a=_i.Scalar.PLAIN,c=cm(o,l);break;case"single-quoted-scalar":a=_i.Scalar.QUOTE_SINGLE,c=lm(o,l);break;case"double-quoted-scalar":a=_i.Scalar.QUOTE_DOUBLE,c=um(o,l);break;default:return t(n,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[r,r+o.length,r+o.length]}}let m=r+o.length,f=sm.resolveEnd(s,m,e,t);return{value:c,type:a,comment:f.comment,range:[r,m,f.offset]}}function cm(n,e){let t="";switch(n[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${n[0]}`;break}case"@":case"`":{t=`reserved character ${n[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),_a(n)}function lm(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),_a(n.slice(1,-1)).replace(/''/g,"'")}function _a(n){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
88
|
+
`,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
89
|
+
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(n);if(!r)return n;let i=r[1],o=" ",s=e.lastIndex;for(t.lastIndex=s;r=t.exec(n);)r[1]===""?o===`
|
|
90
|
+
`?i+=o:o=`
|
|
91
|
+
`:(i+=o+r[1],o=" "),s=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=s,r=a.exec(n),i+o+(r?.[1]??"")}function um(n,e){let t="";for(let r=1;r<n.length-1;++r){let i=n[r];if(!(i==="\r"&&n[r+1]===`
|
|
92
|
+
`))if(i===`
|
|
93
|
+
`){let{fold:o,offset:s}=fm(n,r);t+=o,r=s}else if(i==="\\"){let o=n[++r],s=dm[o];if(s)t+=s;else if(o===`
|
|
94
|
+
`)for(o=n[r+1];o===" "||o===" ";)o=n[++r+1];else if(o==="\r"&&n[r+1]===`
|
|
95
|
+
`)for(o=n[++r+1];o===" "||o===" ";)o=n[++r+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;t+=mm(n,r+1,a,e),r+=a}else{let a=n.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(i===" "||i===" "){let o=r,s=n[r+1];for(;s===" "||s===" ";)s=n[++r+1];s!==`
|
|
96
|
+
`&&!(s==="\r"&&n[r+2]===`
|
|
97
|
+
`)&&(t+=r>o?n.slice(o,r+1):i)}else t+=i}return(n[n.length-1]!=='"'||n.length===1)&&e(n.length,"MISSING_CHAR",'Missing closing "quote'),t}function fm(n,e){let t="",r=n[e+1];for(;(r===" "||r===" "||r===`
|
|
98
|
+
`||r==="\r")&&!(r==="\r"&&n[e+2]!==`
|
|
99
|
+
`);)r===`
|
|
100
|
+
`&&(t+=`
|
|
101
|
+
`),e+=1,r=n[e+1];return t||(t=" "),{fold:t,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 mm(n,e,t,r){let i=n.substr(e,t),s=i.length===t&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(s)}catch{let a=n.substr(e-2,t+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}xa.resolveFlowScalar=am});var Na=y(Ra=>{"use strict";var Pe=_(),Pa=A(),pm=Ei(),hm=xi();function gm(n,e,t,r){let{value:i,type:o,comment:s,range:a}=e.type==="block-scalar"?pm.resolveBlockScalar(n,e,r):hm.resolveFlowScalar(e,n.options.strict,r),c=t?n.directives.tagName(t.source,f=>r(t,"TAG_RESOLVE_FAILED",f)):null,l;n.options.stringKeys&&n.atKey?l=n.schema[Pe.SCALAR]:c?l=wm(n.schema,i,c,t,r):e.type==="scalar"?l=ym(n,i,e,r):l=n.schema[Pe.SCALAR];let m;try{let f=l.resolve(i,u=>r(t??e,"TAG_RESOLVE_FAILED",u),n.options);m=Pe.isScalar(f)?f:new Pa.Scalar(f)}catch(f){let u=f instanceof Error?f.message:String(f);r(t??e,"TAG_RESOLVE_FAILED",u),m=new Pa.Scalar(i)}return m.range=a,m.source=i,o&&(m.type=o),c&&(m.tag=c),l.format&&(m.format=l.format),s&&(m.comment=s),m}function wm(n,e,t,r,i){if(t==="!")return n[Pe.SCALAR];let o=[];for(let a of n.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(e))return a;let s=n.knownTags[t];return s&&!s.collection?(n.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),n[Pe.SCALAR])}function ym({atKey:n,directives:e,schema:t},r,i,o){let s=t.tags.find(a=>(a.default===!0||n&&a.default==="key")&&a.test?.test(r))||t[Pe.SCALAR];if(t.compat){let a=t.compat.find(c=>c.default&&c.test?.test(r))??t[Pe.SCALAR];if(s.tag!==a.tag){let c=e.tagString(s.tag),l=e.tagString(a.tag),m=`Value may be parsed as either ${c} or ${l}`;o(i,"TAG_RESOLVE_FAILED",m,!0)}}return s}Ra.composeScalar=gm});var Ta=y(Aa=>{"use strict";function vm(n,e,t){if(e){t??(t=e.length);for(let r=t-1;r>=0;--r){let i=e[r];switch(i.type){case"space":case"comment":case"newline":n-=i.source.length;continue}for(i=e[++r];i?.type==="space";)n+=i.source.length,i=e[++r];break}}return n}Aa.emptyScalarPosition=vm});var ja=y(Ri=>{"use strict";var bm=rt(),km=_(),Sm=Ca(),Oa=Na(),Cm=Je(),Em=Ta(),_m={composeNode:Ia,composeEmptyNode:Pi};function Ia(n,e,t,r){let i=n.atKey,{spaceBefore:o,comment:s,anchor:a,tag:c}=t,l,m=!0;switch(e.type){case"alias":l=xm(n,e,r),(a||c)&&r(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=Oa.composeScalar(n,e,c,r),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Sm.composeCollection(_m,n,e,t,r),a&&(l.anchor=a.source.substring(1))}catch(f){let u=f instanceof Error?f.message:String(f);r(e,"RESOURCE_EXHAUSTION",u)}break;default:{let f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",f),m=!1}}return l??(l=Pi(n,e.offset,void 0,null,t,r)),a&&l.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&n.options.stringKeys&&(!km.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(l.spaceBefore=!0),s&&(e.type==="scalar"&&e.source===""?l.comment=s:l.commentBefore=s),n.options.keepSourceTokens&&m&&(l.srcToken=e),l}function Pi(n,e,t,r,{spaceBefore:i,comment:o,anchor:s,tag:a,end:c},l){let m={type:"scalar",offset:Em.emptyScalarPosition(e,t,r),indent:-1,source:""},f=Oa.composeScalar(n,m,a,l);return s&&(f.anchor=s.source.substring(1),f.anchor===""&&l(s,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(f.spaceBefore=!0),o&&(f.comment=o,f.range[2]=c),f}function xm({options:n},{offset:e,source:t,end:r},i){let o=new bm.Alias(t.substring(1));o.source===""&&i(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&i(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=e+t.length,a=Cm.resolveEnd(r,s,n.strict,i);return o.range=[e,s,a.offset],a.comment&&(o.comment=a.comment),o}Ri.composeEmptyNode=Pi;Ri.composeNode=Ia});var qa=y(Da=>{"use strict";var Pm=vt(),La=ja(),Rm=Je(),Nm=Ct();function Am(n,e,{offset:t,start:r,value:i,end:o},s){let a=Object.assign({_directives:e},n),c=new Pm.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},m=Nm.resolveProps(r,{indicator:"doc-start",next:i??o?.[0],offset:t,onError:s,parentIndent:0,startOnNewline:!0});m.found&&(c.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!m.hasNewline&&s(m.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=i?La.composeNode(l,i,m,s):La.composeEmptyNode(l,m.end,r,null,m,s);let f=c.contents.range[2],u=Rm.resolveEnd(o,f,!1,s);return u.comment&&(c.comment=u.comment),c.range=[t,f,u.offset],c}Da.composeDoc=Am});var Ai=y(Wa=>{"use strict";var Tm=Wt("process"),Om=hr(),Im=vt(),Et=St(),Ma=_(),jm=qa(),Lm=Je();function _t(n){if(typeof n=="number")return[n,n+1];if(Array.isArray(n))return n.length===2?n:[n[0],n[1]];let{offset:e,source:t}=n;return[e,e+(typeof t=="string"?t.length:1)]}function $a(n){let e="",t=!1,r=!1;for(let i=0;i<n.length;++i){let o=n[i];switch(o[0]){case"#":e+=(e===""?"":r?`
|
|
103
|
+
|
|
104
|
+
`:`
|
|
105
|
+
`)+(o.substring(1)||" "),t=!0,r=!1;break;case"%":n[i+1]?.[0]!=="#"&&(i+=1),t=!1;break;default:t||(r=!0),t=!1}}return{comment:e,afterEmptyLine:r}}var Ni=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,i,o)=>{let s=_t(t);o?this.warnings.push(new Et.YAMLWarning(s,r,i)):this.errors.push(new Et.YAMLParseError(s,r,i))},this.directives=new Om.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:i}=$a(this.prelude);if(r){let o=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
106
|
+
${r}`:r;else if(i||e.directives.docStart||!o)e.commentBefore=r;else if(Ma.isCollection(o)&&!o.flow&&o.items.length>0){let s=o.items[0];Ma.isPair(s)&&(s=s.key);let a=s.commentBefore;s.commentBefore=a?`${r}
|
|
107
|
+
${a}`:r}else{let s=o.commentBefore;o.commentBefore=s?`${r}
|
|
108
|
+
${s}`:r}}if(t){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:$a(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let i of e)yield*this.next(i);yield*this.end(t,r)}*next(e){switch(Tm.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,r,i)=>{let o=_t(e);o[0]+=t,this.onError(o,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=jm.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Et.YAMLParseError(_t(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new Et.YAMLParseError(_t(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let t=Lm.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
|
|
109
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Et.YAMLParseError(_t(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),i=new Im.Document(void 0,r);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,t,t],this.decorate(i,!1),yield i}}};Wa.Composer=Ni});var Ka=y(Dn=>{"use strict";var Dm=Ei(),qm=xi(),Mm=St(),Fa=ct();function $m(n,e=!0,t){if(n){let r=(i,o,s)=>{let a=typeof i=="number"?i:Array.isArray(i)?i[0]:i.offset;if(t)t(a,o,s);else throw new Mm.YAMLParseError([a,a+1],o,s)};switch(n.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return qm.resolveFlowScalar(n,e,r);case"block-scalar":return Dm.resolveBlockScalar({options:{strict:e}},n,r)}}return null}function Wm(n,e){let{implicitKey:t=!1,indent:r,inFlow:i=!1,offset:o=-1,type:s="PLAIN"}=e,a=Fa.stringifyString({type:s,value:n},{implicitKey:t,indent:r>0?" ".repeat(r):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
|
|
110
|
+
`}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
|
|
111
|
+
`),m=a.substring(0,l),f=a.substring(l+1)+`
|
|
112
|
+
`,u=[{type:"block-scalar-header",offset:o,indent:r,source:m}];return Ba(u,c)||u.push({type:"newline",offset:-1,indent:r,source:`
|
|
113
|
+
`}),{type:"block-scalar",offset:o,indent:r,props:u,source:f}}case'"':return{type:"double-quoted-scalar",offset:o,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:r,source:a,end:c};default:return{type:"scalar",offset:o,indent:r,source:a,end:c}}}function Fm(n,e,t={}){let{afterKey:r=!1,implicitKey:i=!1,inFlow:o=!1,type:s}=t,a="indent"in n?n.indent:null;if(r&&typeof a=="number"&&(a+=2),!s)switch(n.type){case"single-quoted-scalar":s="QUOTE_SINGLE";break;case"double-quoted-scalar":s="QUOTE_DOUBLE";break;case"block-scalar":{let l=n.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");s=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=Fa.stringifyString({type:s,value:e},{implicitKey:i||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":Bm(n,c);break;case'"':Ti(n,c,"double-quoted-scalar");break;case"'":Ti(n,c,"single-quoted-scalar");break;default:Ti(n,c,"scalar")}}function Bm(n,e){let t=e.indexOf(`
|
|
114
|
+
`),r=e.substring(0,t),i=e.substring(t+1)+`
|
|
115
|
+
`;if(n.type==="block-scalar"){let o=n.props[0];if(o.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o.source=r,n.source=i}else{let{offset:o}=n,s="indent"in n?n.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:s,source:r}];Ba(a,"end"in n?n.end:void 0)||a.push({type:"newline",offset:-1,indent:s,source:`
|
|
116
|
+
`});for(let c of Object.keys(n))c!=="type"&&c!=="offset"&&delete n[c];Object.assign(n,{type:"block-scalar",indent:s,props:a,source:i})}}function Ba(n,e){if(e)for(let t of e)switch(t.type){case"space":case"comment":n.push(t);break;case"newline":return n.push(t),!0}return!1}function Ti(n,e,t){switch(n.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":n.type=t,n.source=e;break;case"block-scalar":{let r=n.props.slice(1),i=e.length;n.props[0].type==="block-scalar-header"&&(i-=n.props[0].source.length);for(let o of r)o.offset+=i;delete n.props,Object.assign(n,{type:t,source:e,end:r});break}case"block-map":case"block-seq":{let i={type:"newline",offset:n.offset+e.length,indent:n.indent,source:`
|
|
117
|
+
`};delete n.items,Object.assign(n,{type:t,source:e,end:[i]});break}default:{let r="indent"in n?n.indent:-1,i="end"in n&&Array.isArray(n.end)?n.end.filter(o=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(n))o!=="type"&&o!=="offset"&&delete n[o];Object.assign(n,{type:t,indent:r,source:e,end:i})}}}Dn.createScalarToken=Wm;Dn.resolveAsScalar=$m;Dn.setScalarValue=Fm});var Ha=y(Ua=>{"use strict";var Km=n=>"type"in n?Mn(n):qn(n);function Mn(n){switch(n.type){case"block-scalar":{let e="";for(let t of n.props)e+=Mn(t);return e+n.source}case"block-map":case"block-seq":{let e="";for(let t of n.items)e+=qn(t);return e}case"flow-collection":{let e=n.start.source;for(let t of n.items)e+=qn(t);for(let t of n.end)e+=t.source;return e}case"document":{let e=qn(n);if(n.end)for(let t of n.end)e+=t.source;return e}default:{let e=n.source;if("end"in n&&n.end)for(let t of n.end)e+=t.source;return e}}}function qn({start:n,key:e,sep:t,value:r}){let i="";for(let o of n)i+=o.source;if(e&&(i+=Mn(e)),t)for(let o of t)i+=o.source;return r&&(i+=Mn(r)),i}Ua.stringify=Km});var Ga=y(Va=>{"use strict";var Oi=Symbol("break visit"),Um=Symbol("skip children"),Ya=Symbol("remove item");function Re(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),Ja(Object.freeze([]),n,e)}Re.BREAK=Oi;Re.SKIP=Um;Re.REMOVE=Ya;Re.itemAtPath=(n,e)=>{let t=n;for(let[r,i]of e){let o=t?.[r];if(o&&"items"in o)t=o.items[i];else return}return t};Re.parentCollection=(n,e)=>{let t=Re.itemAtPath(n,e.slice(0,-1)),r=e[e.length-1][0],i=t?.[r];if(i&&"items"in i)return i;throw new Error("Parent collection not found")};function Ja(n,e,t){let r=t(e,n);if(typeof r=="symbol")return r;for(let i of["key","value"]){let o=e[i];if(o&&"items"in o){for(let s=0;s<o.items.length;++s){let a=Ja(Object.freeze(n.concat([[i,s]])),o.items[s],t);if(typeof a=="number")s=a-1;else{if(a===Oi)return Oi;a===Ya&&(o.items.splice(s,1),s-=1)}}typeof r=="function"&&i==="key"&&(r=r(e,n))}}return typeof r=="function"?r(e,n):r}Va.visit=Re});var $n=y(F=>{"use strict";var Ii=Ka(),Hm=Ha(),Ym=Ga(),ji="\uFEFF",Li="",Di="",qi="",Jm=n=>!!n&&"items"in n,Vm=n=>!!n&&(n.type==="scalar"||n.type==="single-quoted-scalar"||n.type==="double-quoted-scalar"||n.type==="block-scalar");function Gm(n){switch(n){case ji:return"<BOM>";case Li:return"<DOC>";case Di:return"<FLOW_END>";case qi:return"<SCALAR>";default:return JSON.stringify(n)}}function zm(n){switch(n){case ji:return"byte-order-mark";case Li:return"doc-mode";case Di:return"flow-error-end";case qi:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
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(n[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}F.createScalarToken=Ii.createScalarToken;F.resolveAsScalar=Ii.resolveAsScalar;F.setScalarValue=Ii.setScalarValue;F.stringify=Hm.stringify;F.visit=Ym.visit;F.BOM=ji;F.DOCUMENT=Li;F.FLOW_END=Di;F.SCALAR=qi;F.isCollection=Jm;F.isScalar=Vm;F.prettyToken=Gm;F.tokenType=zm});var Wi=y(Xa=>{"use strict";var xt=$n();function z(n){switch(n){case void 0:case" ":case`
|
|
120
|
+
`:case"\r":case" ":return!0;default:return!1}}var za=new Set("0123456789ABCDEFabcdef"),Xm=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Wn=new Set(",[]{}"),Qm=new Set(` ,[]{}
|
|
121
|
+
\r `),Mi=n=>!n||Qm.has(n),$i=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";for(;r&&(t||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
|
|
122
|
+
`?!0:t==="\r"?this.buffer[e+1]===`
|
|
123
|
+
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;for(;t===" ";)t=this.buffer[++r+e];if(t==="\r"){let i=this.buffer[r+e+1];if(i===`
|
|
124
|
+
`||!i&&!this.atEnd)return e+r+1}return t===`
|
|
125
|
+
`||r>=this.indentNext||!t&&!this.atEnd?e+r:-1}if(t==="-"||t==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&z(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]===xt.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,r=e.indexOf("#");for(;r!==-1;){let o=e[r-1];if(o===" "||o===" "){t=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let o=e[t-1];if(o===" "||o===" ")t-=1;else break}let i=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield xt.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 t=this.peek(3);if((t==="---"||t==="...")&&z(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!z(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&z(t)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);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(Mi),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,r=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=r=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let i=this.getLine();if(i===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&i[0]!=="#"||r===0&&(i.startsWith("---")||i.startsWith("..."))&&z(i[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield xt.FLOW_END,yield*this.parseLineStart();let o=0;for(;i[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),i[o]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-o),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Mi),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let s=this.charAt(1);if(this.flowKey||z(s)||s===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let o=0;for(;this.buffer[t-1-o]==="\\";)o+=1;if(o%2===0)break;t=this.buffer.indexOf('"',t+1)}let r=this.buffer.substring(0,t),i=r.indexOf(`
|
|
127
|
+
`,this.pos);if(i!==-1){for(;i!==-1;){let o=this.continueScalar(i+1);if(o===-1)break;i=r.indexOf(`
|
|
128
|
+
`,o)}i!==-1&&(t=i-(r[i-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>z(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,r;e:for(let o=this.pos;r=this.buffer[o];++o)switch(r){case" ":t+=1;break;case`
|
|
129
|
+
`:e=o,t=0;break;case"\r":{let s=this.buffer[o+1];if(!s&&!this.atEnd)return this.setNext("block-scalar");if(s===`
|
|
130
|
+
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(e+1);if(o===-1)break;e=this.buffer.indexOf(`
|
|
131
|
+
`,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let i=e+1;for(r=this.buffer[i];r===" ";)r=this.buffer[++i];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
|
|
132
|
+
`;)r=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let o=e-1,s=this.buffer[o];s==="\r"&&(s=this.buffer[--o]);let a=o;for(;s===" ";)s=this.buffer[--o];if(s===`
|
|
133
|
+
`&&o>=this.pos&&o+1+t>a)e=o;else break}while(!0);return yield xt.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,r=this.pos-1,i;for(;i=this.buffer[++r];)if(i===":"){let o=this.buffer[r+1];if(z(o)||e&&Wn.has(o))break;t=r}else if(z(i)){let o=this.buffer[r+1];if(i==="\r"&&(o===`
|
|
134
|
+
`?(r+=1,i=`
|
|
135
|
+
`,o=this.buffer[r+1]):t=r),o==="#"||e&&Wn.has(o))break;if(i===`
|
|
136
|
+
`){let s=this.continueScalar(r+1);if(s===-1)break;r=Math.max(r,s-2)}}else{if(e&&Wn.has(i))break;t=r}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield xt.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(t&&(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(Mi),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(z(r)||t&&Wn.has(r)){t?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,t=this.buffer[e];for(;!z(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(Xm.has(t))t=this.buffer[++e];else if(t==="%"&&za.has(this.buffer[e+1])&&za.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
137
|
+
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
138
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r===" ");let i=t-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=t),i}*pushUntil(e){let t=this.pos,r=this.buffer[t];for(;!e(r);)r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};Xa.Lexer=$i});var Bi=y(Qa=>{"use strict";var Fi=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,r=this.lineStarts.length;for(;t<r;){let o=t+r>>1;this.lineStarts[o]<e?t=o+1:r=o}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}};Qa.LineCounter=Fi});var Ui=y(rc=>{"use strict";var Zm=Wt("process"),Za=$n(),ep=Wi();function pe(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function ec(n){for(let e=0;e<n.length;++e)switch(n[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function nc(n){switch(n?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Fn(n){switch(n.type){case"document":return n.start;case"block-map":{let e=n.items[n.items.length-1];return e.sep??e.start}case"block-seq":return n.items[n.items.length-1].start;default:return[]}}function Ve(n){if(n.length===0)return[];let e=n.length;e:for(;--e>=0;)switch(n[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;n[++e]?.type==="space";);return n.splice(e,n.length)}function Bn(n,e){if(e.length<1e5)Array.prototype.push.apply(n,e);else for(let t=0;t<e.length;++t)n.push(e[t])}function tc(n){if(n.start.type==="flow-seq-start")for(let e of n.items)e.sep&&!e.value&&!pe(e.start,"explicit-key-ind")&&!pe(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,nc(e.value)?e.value.end?Bn(e.value.end,e.sep):e.value.end=e.sep:Bn(e.start,e.sep),delete e.sep)}var Ki=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 ep.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,t))yield*this.next(r);t||(yield*this.end())}*next(e){if(this.source=e,Zm.env.LOG_TOKENS&&console.log("|",Za.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Za.tokenType(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){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 r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,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 t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let r=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in r?r.indent:0:t.type==="flow-collection"&&r.type==="document"&&(t.indent=0),t.type==="flow-collection"&&tc(t),r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let i=r.items[r.items.length-1];if(i.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{let i=r.items[r.items.length-1];i.value?r.items.push({start:[],value:t}):i.value=t;break}case"flow-collection":{let i=r.items[r.items.length-1];!i||i.value?r.items.push({start:[],key:t,sep:[]}):i.sep?i.value=t:Object.assign(i,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let i=t.items[t.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&ec(i.start)===-1&&(t.indent===0||i.start.every(o=>o.type!=="comment"||o.indent<t.indent))&&(r.type==="document"?r.end=i.start:r.items.push({start:i.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{ec(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 t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=Fn(this.peek(2)),r=Ve(t),i;e.end?(i=e.end,i.push(this.sourceToken),delete e.end):i=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
|
|
139
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
140
|
+
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Bn(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,i=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",o=[];if(i&&t.sep&&!t.value){let s=[];for(let a=0;a<t.sep.length;++a){let c=t.sep[a];switch(c.type){case"newline":s.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(s.length=0);break;default:s.length=0}}s.length>=2&&(o=t.sep.splice(s[1]))}switch(this.type){case"anchor":case"tag":i||t.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):i||t.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(pe(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(nc(t.key)&&!pe(t.sep,"newline")){let s=Ve(t.start),a=t.key,c=t.sep;c.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:a,sep:c}]})}else o.length>0?t.sep=t.sep.concat(o,this.sourceToken):t.sep.push(this.sourceToken);else if(pe(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let s=Ve(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||i?e.items.push({start:o,key:null,sep:[this.sourceToken]}):pe(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);i||t.value?(e.items.push({start:o,key:s,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(s):(Object.assign(t,{key:s,sep:[]}),this.onKeyLine=!0);return}default:{let s=this.startBlockValue(e);if(s){if(s.type==="block-seq"){if(!t.explicitKey&&t.sep&&!pe(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:o});this.stack.push(s);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Bn(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||pe(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:i,sep:[]}):t.sep?this.stack.push(i):Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let i=Fn(r),o=Ve(i);tc(e);let s=e.end.splice(1,e.end.length);s.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
141
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
142
|
+
`,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=Fn(e),r=Ve(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Fn(e),r=Ve(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(r=>r.type==="newline"||r.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())}}};rc.Parser=Ki});var cc=y(Rt=>{"use strict";var ic=Ai(),tp=vt(),Pt=St(),np=Rr(),rp=_(),ip=Bi(),oc=Ui();function sc(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new ip.LineCounter||null,prettyErrors:e}}function op(n,e={}){let{lineCounter:t,prettyErrors:r}=sc(e),i=new oc.Parser(t?.addNewLine),o=new ic.Composer(e),s=Array.from(o.compose(i.parse(n)));if(r&&t)for(let a of s)a.errors.forEach(Pt.prettifyError(n,t)),a.warnings.forEach(Pt.prettifyError(n,t));return s.length>0?s:Object.assign([],{empty:!0},o.streamInfo())}function ac(n,e={}){let{lineCounter:t,prettyErrors:r}=sc(e),i=new oc.Parser(t?.addNewLine),o=new ic.Composer(e),s=null;for(let a of o.compose(i.parse(n),!0,n.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new Pt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&t&&(s.errors.forEach(Pt.prettifyError(n,t)),s.warnings.forEach(Pt.prettifyError(n,t))),s}function sp(n,e,t){let r;typeof e=="function"?r=e:t===void 0&&e&&typeof e=="object"&&(t=e);let i=ac(n,t);if(!i)return null;if(i.warnings.forEach(o=>np.warn(i.options.logLevel,o)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},t))}function ap(n,e,t){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){let i=Math.round(t);t=i<1?void 0:i>8?{indent:8}:{indent:i}}if(n===void 0){let{keepUndefined:i}=t??e??{};if(!i)return}return rp.isDocument(n)&&!r?n.toString(t):new tp.Document(n,r,t).toString(t)}Rt.parse=sp;Rt.parseAllDocuments=op;Rt.parseDocument=ac;Rt.stringify=ap});var Nt=y(P=>{"use strict";var cp=Ai(),lp=vt(),up=ui(),Hi=St(),fp=rt(),he=_(),dp=ue(),mp=A(),pp=de(),hp=me(),gp=$n(),wp=Wi(),yp=Bi(),vp=Ui(),Kn=cc(),lc=Ze();P.Composer=cp.Composer;P.Document=lp.Document;P.Schema=up.Schema;P.YAMLError=Hi.YAMLError;P.YAMLParseError=Hi.YAMLParseError;P.YAMLWarning=Hi.YAMLWarning;P.Alias=fp.Alias;P.isAlias=he.isAlias;P.isCollection=he.isCollection;P.isDocument=he.isDocument;P.isMap=he.isMap;P.isNode=he.isNode;P.isPair=he.isPair;P.isScalar=he.isScalar;P.isSeq=he.isSeq;P.Pair=dp.Pair;P.Scalar=mp.Scalar;P.YAMLMap=pp.YAMLMap;P.YAMLSeq=hp.YAMLSeq;P.CST=gp;P.Lexer=wp.Lexer;P.LineCounter=yp.LineCounter;P.Parser=vp.Parser;P.parse=Kn.parse;P.parseAllDocuments=Kn.parseAllDocuments;P.parseDocument=Kn.parseDocument;P.stringify=Kn.stringify;P.visit=lc.visit;P.visitAsync=lc.visitAsync});import{promises as Pl}from"node:fs";import{AsyncLocalStorage as _l}from"node:async_hooks";var xl=new _l;function po(){let n=xl.getStore();return n?.active?n:null}function ho(n,e){let t=n;for(let r of e)t+="\0"+(typeof r=="string"?r:JSON.stringify(r));return t}function V(n,e){return(...t)=>{let r=po();if(r===null)return e(...t);let i=ho(`async:${n}`,t),o=r.entries.get(i);if(o)return o.value;let s=e(...t).catch(a=>{throw r.entries.get(i)?.value===s&&r.entries.delete(i),a});return r.entries.set(i,{value:s}),s}}function Qe(n,e){return(...t)=>{let r=po();if(r===null)return e(...t);let i=ho(`sync:${n}`,t),o=r.entries.get(i);if(o)return o.value;let s=e(...t);return r.entries.set(i,{value:s}),s}}import ar from"node:path";var wo="comet-state.yaml",Rl=".comet.yaml",go=[wo,Rl],cr=class extends Error{};async function Nl(n,e={}){let t=[],r=[];for(let i of go)try{let o=await Pl.lstat(ar.join(n,i));t.push(i),(!o.isFile()||o.isSymbolicLink())&&r.push(i)}catch(o){if(o.code!=="ENOENT")throw o}if(t.length>1)throw new cr(`Classic state files are ambiguous in ${n}: ${go.join(" and ")} both exist; preserve both files and resolve the conflict before continuing`);if(r.length)throw new Error(`Classic state must be a regular file, not a symlink or directory: ${ar.join(n,r[0])}`);return ar.join(n,t[0]??e.defaultFileName??wo)}var Al=V("classicStateFile",(n,e)=>Nl(n,e));async function Z(n,e={}){return Al(n,e)}import{promises as yo}from"node:fs";var Tl=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),lr=[50,100,200];async function vo(n,e){let t;for(let r=0;r<=lr.length;r+=1)try{return await n()}catch(i){t=i;let o=i.code;if(r===lr.length||!Tl.has(o??""))throw i;await new Promise(s=>setTimeout(s,lr[r]))}throw t}async function bo(n,e){await vo(()=>yo.rename(n,e),`rename ${e}`)}async function ur(n,e){await vo(()=>yo.link(n,e),`link ${e}`)}import{randomUUID as Ol}from"crypto";import{constants as Il,promises as M}from"fs";import q from"path";function oe(n){return n!==0&&n!==0n&&n!=="0"}function ko(n,e){return oe(n.dev)&&oe(e.dev)&&oe(n.ino)&&oe(e.ino)}function ke(n,e){let t=oe(n.dev)&&oe(e.dev);if(t&&n.dev!==e.dev)return!1;let r=oe(n.ino)&&oe(e.ino);return r&&n.ino!==e.ino?!1:t&&r?!0:n.birthtime===e.birthtime}async function fr(n,e){try{return await ur(n,e),{linked:!0}}catch(t){let r=t.code;if(r!=="ENOTSUP"&&r!=="EOPNOTSUPP")throw t}return await M.copyFile(n,e,Il.COPYFILE_EXCL),{linked:!1}}function qe(n,e){let t=q.relative(n,e);return t===""||!q.isAbsolute(t)&&t!==".."&&!t.startsWith(`..${q.sep}`)}function Bt(n){return{dev:n.dev,ino:n.ino,birthtime:n.birthtimeMs}}function jl(n,e){return ke(n,Bt(e))}function Kt(n,e){return ke(Bt(n),Bt(e))}function Ll(n,e){return Kt(n,e)&&n.birthtimeMs===e.birthtimeMs&&n.ctimeMs===e.ctimeMs&&n.mtimeMs===e.mtimeMs&&n.size===e.size}async function Ut(n){let e=await M.lstat(n);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Contained atomic write parent must be a real directory: ${n}`);return{path:n,realPath:await M.realpath(n),...Bt(e)}}async function Se(n){for(let e of n){let t=await M.lstat(e.path);if(!t.isDirectory()||t.isSymbolicLink()||!jl(e,t)||await M.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function Dl(n,e,t){let[r,i]=await Promise.all([M.lstat(n),M.realpath(n),Se(t)]);if(!r.isFile()||r.isSymbolicLink()||!Kt(r,e)||!qe(t[0].realPath,i))throw new Error("Contained atomic write temporary file changed after close");return r}async function ql(n,e){let t=await Ml(n,e);if(t)return t;let r=q.resolve(n),i=q.resolve(e);if(!qe(r,i))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let o=[await Ut(r)],s=q.relative(r,i).split(q.sep).filter(Boolean),a=r;for(let c of s){await Se(o),a=q.join(a,c);try{await M.mkdir(a)}catch(m){if(m.code!=="EEXIST")throw m}let l=await Ut(a);if(!qe(o[0].realPath,l.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${a}`);o.push(l)}return await Se(o),o}async function Ml(n,e){let t=q.resolve(n),r=q.resolve(e);if(!qe(t,r))throw new Error(`Contained file parent is outside its managed root: ${e}`);let i=[await Ut(t)],o=q.relative(t,r).split(q.sep).filter(Boolean),s=t;for(let a of o){s=q.join(s,a);try{let c=await Ut(s);if(!qe(i[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${s}`);i.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await Se(i),i}async function $l(n){let e;try{e=await M.open(n,"r"),await e.sync()}catch(t){let r=t.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw t}finally{await e?.close()}}async function Wl(n,e,t){let r=q.dirname(n),i=await ql(t.containedRoot,r),o=q.join(r,`.${q.basename(n)}.${Ol()}.tmp`),s,a,c;try{await t.beforeTemporaryOpen?.(),s=await M.open(o,"wx"),a=await s.stat();let[l,m]=await Promise.all([M.lstat(o),M.realpath(o)]);if(await Se(i),!l.isFile()||l.isSymbolicLink()||!Kt(a,l)||!qe(i[0].realPath,m))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await s.writeFile(e,"utf8"):await s.writeFile(e),await s.sync(),c=await s.stat(),!Kt(a,c))throw new Error("Contained atomic write temporary file changed while writing");if(await s.close(),s=void 0,await t.afterTemporaryClose?.(),!c)throw new Error("Contained atomic write temporary file was not written");c=await Dl(o,c,i),await t.beforeCommit?.(),await Se(i);let f=await M.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!c||!Ll(f,c))throw new Error("Contained atomic write temporary file changed before commit");t.exclusive?(t.requireAtomicPublication?await ur(o,n):await fr(o,n),await M.unlink(o)):await bo(o,n),await $l(r)}catch(l){await s?.close();try{await Se(i),await M.rm(o,{force:!0})}catch{}throw l}}async function ee(n,e,t){await Wl(n,e,t)}import ge from"path";var Y=Ft(Nt(),1),Ne=Number.MAX_SAFE_INTEGER,uc=1024,fc=64,bp=5,kp=2,Yi={learning:!0,retrieval:!0},dc={include:[],max_file_mb:1,max_total_mb:32},Sp={provider:"local"};var mc=36e5,Cp=12e4,pc=6e5;function Ep(n,e){if(typeof n!="string")throw new Error(`${e} must be a string`);let t=n.trim();if(t.length===0||ge.posix.isAbsolute(t)||ge.win32.isAbsolute(t)||/^(?:~|[\\/])/u.test(t))throw new Error(`${e} must be a project-relative path`);if(t===".")return[];let r=t.replaceAll("\\","/").split("/");if(r.some(i=>i===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(i=>i===""||i==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function Un(n){let e=Ep(n,"native.artifact_root");return e.length===0?".":e.join("/")}function gc(n,e="docs"){let t=n??e;if(t!=="legacy"&&t!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return t}function re(n,e,t=!1){if(typeof n!="string")throw new Error(`${e} must be a string`);let r=n.trim().replaceAll("\\","/");if(r.length===0||ge.posix.isAbsolute(r)||ge.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let i=r.split("/");if(i.some(o=>o===".."))throw new Error(`${e} must stay inside its declared path base`);if(i.some(o=>o===""||o==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!t&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return i.join("/")}function we(n,e){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`${e} must be a mapping`);return n}function wc(n,e,t){let r=n??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${t} must be en or zh-CN`);return r}function _p(n,e,t){let r=n??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${t} must be a positive integer`);return r}function hc(n,e,t){let r=_p(n,e,t);if(r>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${t} is too large to convert to bytes safely`);return r}function xp(n){if(n===void 0)return;let e=we(n,"native.pending_root_move"),t=e.id,r=e.from_artifact_root,i=e.to_artifact_root,o=e.stage;if(typeof t!="string"||!/^[a-f0-9-]{8,}$/u.test(t))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof i!="string")throw new Error("native.pending_root_move roots must be strings");if(o!=="copying"&&o!=="ready"&&o!=="switched")throw new Error("native.pending_root_move.stage is invalid");let s;if(e.cleanup!==void 0){let a=we(e.cleanup,"native.pending_root_move.cleanup"),c=a.kind,l=a.state,m=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 m!="string"||!/^[a-f0-9]{64}$/u.test(m))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");s={kind:c,state:l,manifestHash:m}}return{id:t,fromArtifactRoot:Un(r),toArtifactRoot:Un(i),stage:o,...s?{cleanup:s}:{}}}function Pp(n){if(n===void 0)return;let e=we(n,"native.finish");if(e.pull_request===void 0)return{};let t=we(e.pull_request,"native.finish.pull_request");if(t.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(t.command)||t.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(t.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let r=t.command.map((o,s)=>{if(typeof o!="string"||o.trim().length===0||o.length>4096||/[\0\r\n]/u.test(o))throw new Error(`native.finish.pull_request.command[${s}] must be a non-empty single-line string of at most 4096 characters`);return o});if(ge.posix.isAbsolute(r[0])||ge.win32.isAbsolute(r[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let i=t.timeout_ms??Cp;if(!Number.isSafeInteger(i)||i<1||i>pc)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${pc}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:i}}}function Rp(n,e={}){let t=we(n,"native"),r=t.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let i=t.clarification_mode??"batch";if(i!=="sequential"&&i!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let o=t.archive_confirmation??"automatic";if(o!=="automatic"&&o!=="required")throw new Error("native.archive_confirmation must be automatic or required");let s=t.max_verify_failures??bp;if(!Number.isSafeInteger(s)||s<1)throw new Error("native.max_verify_failures must be a positive integer");let a=t.max_parallel_children===void 0?kp:t.max_parallel_children;if(!Number.isSafeInteger(a)||a<1)throw new Error("native.max_parallel_children must be a positive integer");let c=t.document_writes??"allow";if(c!=="allow"&&c!=="revert")throw new Error("native.document_writes must be allow or revert");let l=xp(t.pending_root_move),m=Pp(t.finish);return{artifact_root:Un(r),language:wc(t.language,"en","native.language"),clarification_mode:i,archive_confirmation:o,max_verify_failures:s,max_parallel_children:a,...c==="revert"?{document_writes:c}:{},...m?{finish:m}:{},...l?{pending_root_move:l}:{}}}function Np(n,e){if(!Number.isSafeInteger(n)||Number(n)<1||Number(n)>mc)throw new Error(`${e} must be an integer between 1 and ${mc} milliseconds`);return n}function Ap(n){let e=we(n,"classic"),t=e.context_compression??"off";if(t!=="off"&&t!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let i=e.auto_transition??!0;if(typeof i!="boolean")throw new Error("classic.auto_transition must be true or false");e.check_timeout_ms!==void 0&&Np(e.check_timeout_ms,"classic.check_timeout_ms");let o=e.document_evidence??"neutral";if(o!=="neutral"&&o!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:gc(e.artifact_layout),language:wc(e.language,"zh-CN","classic.language"),context_compression:t,review_mode:r,auto_transition:i,...o==="strict"?{document_evidence:o}:{},...e.check_timeout_ms!==void 0?{check_timeout_ms:e.check_timeout_ms}:{}}}function Tp(n){let t=we(n,"hook").allow_paths??[];if(!Array.isArray(t))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(t.map((r,i)=>re(r,`hook.allow_paths[${i}]`)))]}}function Op(n){if(n===void 0)return{...Yi};let e=we(n,"memory"),t=e.learning??Yi.learning,r=e.retrieval??Yi.retrieval;if(typeof t!="boolean")throw new Error("memory.learning must be true or false");if(typeof r!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:t,retrieval:r}}function Ji(n,e){if(n===null||typeof n!="object"||Array.isArray(n))throw new Error(`${e} must be a mapping`);return n}function Ip(n,e){if(typeof n!="string")throw new Error(`${e} must be a string`);let t=n.trim();if(t.length===0||t.includes("\\")||t.includes("\0")||ge.posix.isAbsolute(t)||ge.win32.isAbsolute(t)||t.startsWith("~")||t.split("/").some(i=>i===""||i==="."||i===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!t.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(t.length>uc)throw new Error(`${e} exceeds ${uc} characters`);let r=0;for(let i=0;i<t.length;i+=1)t[i]==="?"?r+=1:t[i]==="*"&&(r+=1,t[i+1]==="*"&&(i+=1));if(r>fc)throw new Error(`${e} contains more than ${fc} wildcard tokens`);return t}function jp(n){let e=Ji(n,"knowledge.local"),t=e.include??[];if(!Array.isArray(t))throw new Error("knowledge.local.include must be an array");let r={include:[...new Set(t.map((i,o)=>Ip(i,`knowledge.local.include[${o}]`)))],max_file_mb:hc(e.max_file_mb,dc.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:hc(e.max_total_mb,dc.max_total_mb,"knowledge.local.max_total_mb")};if(r.max_file_mb>r.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return r}function Lp(n){if(typeof n!="string"||n.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(n)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let t=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),r=t==="localhost"||t==="127.0.0.1"||t==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&r))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function Dp(n){let e=Ji(n,"knowledge.remote"),t=Lp(e.endpoint),r=e.token_env;if(r!==void 0&&(typeof r!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(r)))throw new Error("knowledge.remote.token_env must be an environment variable name");let i=e.scope;if(i!==void 0&&(typeof i!="string"||i.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let o=e.timeout_ms??5e3;if(typeof o!="number"||!Number.isSafeInteger(o)||o<100||o>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:t,...r===void 0?{}:{token_env:r},...i===void 0?{}:{scope:i},timeout_ms:o}}function qp(n){if(n===void 0)return{...Sp};let e=Ji(n,"knowledge"),t=e.provider??"local";if(t!=="local"&&t!=="remote")throw new Error("knowledge.provider must be local or remote");let r=e.local===void 0?void 0:jp(e.local);if(t==="local")return{provider:t,...r?{local:r}:{}};let i=e.remote===void 0?void 0:Dp(e.remote);if(i===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:t,...r?{local:r}:{},remote:i}}function yc(n){if(n===void 0)return!0;if(typeof n!="boolean")throw new Error("change_walkthrough must be true or false");return n}function Mp(n){let e=n??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function $p(n,e,t,r,i,o,s,a){let c=n.schema!==void 0;if(!(c||n.default_workflow!==void 0||n.workflows!==void 0||!a.allowPartialProject&&n.native!==void 0)||a.allowPartialProject&&!c)return null;if(n.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(n.default_workflow!=="native"&&n.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let m=n.workflows??[n.default_workflow];if(!Array.isArray(m)||m.length===0||m.some(u=>u!=="native"&&u!=="classic"))throw new Error("workflows must contain native and/or classic");let f=[...new Set(m)];if(!f.includes(n.default_workflow))throw new Error("workflows must include default_workflow");if(f.includes("native")&&!i)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:n.default_workflow,workflows:f,ambient_resume:s,change_walkthrough:yc(n.change_walkthrough),...e?{hook:e}:{},memory:t,knowledge:r,...i?{native:i}:{},...o?{classic:o}:{}}}function vc(n){let e=(0,Y.parseDocument)(n),t=r=>{let i=(0,Y.isAlias)(r)?r.resolve(e):r;return(0,Y.isScalar)(i)?i.value:void 0};return(0,Y.isMap)(e.contents)&&e.contents.items.some(({key:r,value:i})=>t(r)==="schema"&&t(i)==="comet.project.v1")}function Ae(n,e={}){let t=(0,Y.parseDocument)(n,{uniqueKeys:!0});if(t.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${t.errors[0].message}`);let r=t.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0,change_walkthrough:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let i=r,o=Mp(i.ambient_resume),s=yc(i.change_walkthrough),a=i.hook===void 0?void 0:Tp(i.hook),c=Op(i.memory),l=qp(i.knowledge),m=i.native===void 0?void 0:Rp(i.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),f=i.classic===void 0?void 0:Ap(i.classic),u=$p(i,a,c,l,m,f,o,{allowPartialProject:e.allowPartialProject??!1});return{value:i,config:u,ambient_resume:o,change_walkthrough:s,memory:c,knowledge:l,...a?{hook:a}:{},...m?{native:m}:{},...f?{classic:f}:{}}}var Vp=Ft(Nt(),1);import{promises as K}from"fs";import R from"path";import{AsyncLocalStorage as Bp}from"node:async_hooks";import{constants as ye,promises as B}from"fs";import{createHash as Wp}from"node:crypto";var J=class extends Error{reason;constructor(e,t,r){super(t,r),this.name="RaceSafeReadError",this.reason=e}};function Vi(n){return"birthtimeNs"in n&&typeof n.birthtimeNs=="bigint"?n.birthtimeNs:n.birthtimeMs}function Hn(n){return"ctimeNs"in n&&typeof n.ctimeNs=="bigint"?n.ctimeNs:n.ctimeMs}function be(n){return{dev:n.dev,ino:n.ino,birthtime:Vi(n)}}function Fp(n,e){let t=be(n),r=be(e);return ko(t,r)?ke(t,r):ke(t,r)&&Vi(n)===Vi(e)&&Hn(n)===Hn(e)&&n.size===e.size}function ve(n,e){let t=r=>"mtimeNs"in r?r.mtimeNs:r.mtimeMs;return Fp(n,e)&&n.size===e.size&&n.mode===e.mode&&t(n)===t(e)&&Hn(n)===Hn(e)}async function At(n,e,t={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=t.label??"file",i=t.bigint===!0,o=await B.lstat(n,{bigint:i});if(!o.isFile()||o.isSymbolicLink())throw new J("not-regular-file",`${r} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new J("too-large",`${r} exceeds ${e} bytes`);let s=await B.realpath(n);await t.verify?.("pre-open",{realPath:s,identity:be(o)});let a=process.platform==="win32"?ye.O_RDONLY:ye.O_RDONLY|ye.O_NOFOLLOW|ye.O_NONBLOCK,c;try{c=await B.open(n,a)}catch(l){throw l.code==="ELOOP"?new J("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,m,f]=await Promise.all([c.stat({bigint:i}),B.lstat(n,{bigint:i}),B.realpath(n)]);if(!l.isFile()||!m.isFile()||m.isSymbolicLink()||f!==s||!ve(o,l)||!ve(o,m))throw new J("changed",`${r} changed while opening`);await t.verify?.("post-open",{realPath:f,identity:be(l)}),await t.hooks?.afterOpen?.();let u=[],p=0,g=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let v=e+1-p,{bytesRead:k}=await c.read(g,0,Math.min(g.length,v),null);if(k===0)break;if(p+=k,p>e)throw new J("too-large",`${r} exceeds ${e} bytes`);u.push(Buffer.from(g.subarray(0,k)))}await t.hooks?.beforeFinalCheck?.();let[d,h,w]=await Promise.all([c.stat({bigint:i}),B.lstat(n,{bigint:i}),B.realpath(n)]);if(!h.isFile()||h.isSymbolicLink()||w!==s||!ve(o,d)||!ve(o,h))throw new J("changed",`${r} changed while reading`);return await t.verify?.("post-read",{realPath:w,identity:be(d)}),{bytes:Buffer.concat(u,p),stat:d,realPath:w}}finally{await c.close()}}async function bc(n,e={}){let t=e.label??"file",r=e.bigint===!0,i=await B.lstat(n,{bigint:r});if(!i.isFile()||i.isSymbolicLink())throw new J("not-regular-file",`${t} must be a regular file`);let o=await B.realpath(n);await e.verify?.("pre-open",{realPath:o,identity:be(i)});let s=process.platform==="win32"?ye.O_RDONLY:ye.O_RDONLY|ye.O_NOFOLLOW|ye.O_NONBLOCK,a;try{a=await B.open(n,s)}catch(c){throw c.code==="ELOOP"?new J("not-regular-file",`${t} must be a regular file`,{cause:c}):c}try{let[c,l,m]=await Promise.all([a.stat({bigint:r}),B.lstat(n,{bigint:r}),B.realpath(n)]);if(!c.isFile()||!l.isFile()||l.isSymbolicLink()||m!==o||!ve(i,c)||!ve(i,l))throw new J("changed",`${t} changed while opening`);await e.verify?.("post-open",{realPath:m,identity:be(c)}),await e.hooks?.afterOpen?.();let f=Wp(e.algorithm??"sha256"),u=Buffer.allocUnsafe(64*1024);for(;;){let{bytesRead:h}=await a.read(u,0,u.length,null);if(h===0)break;f.update(u.subarray(0,h))}await e.hooks?.beforeFinalCheck?.();let[p,g,d]=await Promise.all([a.stat({bigint:r}),B.lstat(n,{bigint:r}),B.realpath(n)]);if(!g.isFile()||g.isSymbolicLink()||d!==o||!ve(i,p)||!ve(i,g))throw new J("changed",`${t} changed while reading`);return await e.verify?.("post-read",{realPath:d,identity:be(p)}),{digest:f.digest("hex"),stat:p,realPath:d}}finally{await a.close()}}var Kp=new Bp;async function Gi(n,e,t={}){let r=R.resolve(n),i=await Xi(r,e),o=new Map,s=!1,a=u=>[u.dev,u.ino,u.mode,u.birthtimeNs,u.mtimeNs,u.ctimeNs].join(":"),c=u=>[u.dev,u.ino,u.mode,u.birthtimeNs].join(":"),l=async(u,p)=>JSON.stringify((await K.readdir(u,{withFileTypes:!0})).filter(g=>!p(g)).map(g=>[g.name,g.isDirectory(),g.isSymbolicLink()]).sort((g,d)=>String(g[0]).localeCompare(String(d[0]),"en"))),m=u=>{let p=o.get(u);return p||(p=(async()=>{let g=await K.lstat(u,{bigint:!0});if(!g.isDirectory()||g.isSymbolicLink())throw new Error(`${e} crosses a symbolic link, junction or invalid directory at ${R.relative(r,u)||"."}`);let d=await K.realpath(u);if(!Ge(i,d))throw new Error(`${e} resolves outside the project root`);let h=t.ignoredDirectoryEntries?.(R.relative(r,u).replaceAll("\\","/")||".");return{stat:g,real:d,...h?{ignoreEntry:h,namespace:await l(u,h)}:{}}})(),p=p.catch(g=>{throw o.delete(u),g}),o.set(u,p)),p};await m(r);let f=async u=>{if(s)throw new Error(`${e} read session is already finished`);let p=re(u,e),g=r;for(let d of p.split("/").slice(0,-1))g=R.join(g,d),await m(g);return R.resolve(r,...p.split("/"))};return{observePath:f,async observeDirectory(u){let p=await f(u);return await m(p),p},async stat(u){let p=await f(u),g=await K.lstat(p,{bigint:!0});if(!g.isFile()||g.isSymbolicLink())throw new Error(`${e} must be a real file: ${u}`);return{target:p,stat:g}},async hash(u){let p=await f(u);return bc(p,{bigint:!0,label:`${e} ${u}`,verify:async(g,d)=>{if(!Ge(i,d.realPath))throw new Error(`${e} resolves outside the project root`);let h=r,w=[r];for(let v of R.relative(r,R.dirname(p)).split(R.sep).filter(Boolean))h=R.join(h,v),w.push(h);for(let v of w){let k=await o.get(v),S=await K.lstat(v,{bigint:!0});if(!S.isDirectory()||S.isSymbolicLink()||c(S)!==c(k.stat))throw new Error(`${e} directory changed while reading: ${R.relative(r,v)||"."}`)}}})},async read(u,p,g={}){let d=await f(u);return At(d,p,{...g,label:`${e} ${u}`,verify:async(h,w)=>{if(!Ge(i,w.realPath))throw new Error(`${e} resolves outside the project root`);if(t.deferDirectoryChecks)return;let v=r,k=[r];for(let S of R.relative(r,R.dirname(d)).split(R.sep).filter(Boolean))v=R.join(v,S),k.push(v);for(let S of k){let E=await o.get(S),C=await K.lstat(S,{bigint:!0});if(!C.isDirectory()||C.isSymbolicLink()||c(C)!==c(E.stat))throw new Error(`${e} directory changed while reading: ${R.relative(r,S)||"."}`)}}})},async finish(u={}){if(s)throw new Error(`${e} read session is already finished`);s=!0;let p=[];for(let[g,d]of o){let h=await d,w=await K.lstat(g,{bigint:!0});if(!w.isDirectory()||w.isSymbolicLink()||c(h.stat)!==c(w)||!u.allowDirectoryContentChanges&&a(h.stat)!==a(w)&&(!h.ignoreEntry||await l(g,h.ignoreEntry)!==h.namespace)||await K.realpath(g)!==h.real)throw new Error(`${e} directory changed while observing: ${R.relative(r,g)||"."}`);a(h.stat)!==a(w)&&p.push(R.relative(r,g).replaceAll("\\","/")||".")}return{changedDirectories:p}}}}function kc(n){let e=n?.code;return e==="ENOENT"||e==="ENOTDIR"}function Ge(n,e){let t=R.relative(n,e);return t===""||!R.isAbsolute(t)&&t!==".."&&!t.startsWith(`..${R.sep}`)}var Sc=V("protectedChainLstat",n=>K.lstat(n)),Cc=V("protectedChainRealpath",n=>K.realpath(n)),Up=Qe("protectedChainInside",Ge);async function Xi(n,e){let t=R.resolve(n),r=await Sc(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Cc(t)}async function Ec(n,e,t,r){let i=n;for(let o=0;o<t.length;o++){i=R.join(i,t[o]);let s;try{s=await Sc(i)}catch(l){if(kc(l))return{exists:!1,kind:"missing"};throw l}if(s.isSymbolicLink()){let l=R.relative(n,i).replaceAll("\\","/");throw new Error(`${r.label} crosses a symbolic link or junction at ${l}`)}let a=o===t.length-1;if(!a&&!s.isDirectory()){let l=R.relative(n,i).replaceAll("\\","/");throw new Error(`${r.label} ancestor ${l} must be a real directory`)}if(a&&(r.expected==="file"&&!s.isFile()||r.expected==="directory"&&!s.isDirectory()||r.expected==="any"&&!s.isFile()&&!s.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let c=await Cc(i);if(!Up(e,c))throw new Error(`${r.label} resolves outside the project root`);if(a)return{exists:!0,kind:s.isFile()?"file":s.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function _c(n,e,t){let r=re(e,t.label),i=R.resolve(n),o=await Xi(i,t.label),s=r.split("/"),a=R.resolve(i,...s);if(!Ge(i,a))throw new Error(`${t.label} must stay inside the project root`);let c=await Ec(i,o,s,t);return{projectRoot:i,target:a,relative:r,exists:c.exists,kind:c.kind}}var Hp=V("protectedInspectPath",(n,e,t)=>_c(n,e,{label:"Protected project path",expected:t}));async function L(n,e,t){if(t.expected===void 0)return _c(n,e,t);try{return await Hp(n,e,t.expected)}catch(r){throw r instanceof Error&&r.message.includes("Protected project path")&&(r.message=r.message.replaceAll("Protected project path",t.label)),r}}async function Yn(n,e,t){let r=re(e,t.label),i=R.resolve(n),o=await Xi(i,t.label),s=r.split("/"),a=i;for(let c of s){a=R.join(a,c);let l;try{l=await K.lstat(a)}catch(u){if(!kc(u))throw u;try{await K.mkdir(a)}catch(p){if(p.code!=="EEXIST")throw p}l=await K.lstat(a)}let m=R.relative(i,a).replaceAll("\\","/");if(l.isSymbolicLink())throw new Error(`${t.label} crosses a symbolic link or junction at ${m}`);if(!l.isDirectory())throw new Error(`${t.label} directory ${m} must be a real directory`);let f=await K.realpath(a);if(!Ge(o,f))throw new Error(`${t.label} resolves outside the project root`)}return await Ec(i,o,s,{label:t.label,expected:"directory"}),a}async function xc(n,e,t,r){let i=!r.hooks&&!r.bigint?Kp.getStore():void 0;if(i){let a=R.resolve(n),c=i.get(a);return c||(c=Gi(a,r.label,{deferDirectoryChecks:!0}).catch(l=>{throw i.delete(a),l}),i.set(a,c)),(await c).read(e,t,r)}let o=await Gi(n,r.label),s=await o.read(e,t,r);return await o.finish({allowDirectoryContentChanges:!0}),s}var zi="Cached protected project read",Yp=V("protectedReadFile",(n,e,t)=>xc(n,e,t,{label:zi}));async function U(n,e,t,r){if(r.hooks||r.bigint)return xc(n,e,t,r);try{return await Yp(n,e,t)}catch(i){throw i instanceof Error&&i.message.includes(zi)&&(i.message=i.message.replaceAll(zi,r.label)),i}}import{createHash as Gp}from"crypto";var Tt=".comet/config.yaml";function zp(n){let e=n?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Jn(n,e={}){return(await Vn(n,e)).document}async function Xp(n){try{return(await U(n,Tt,Ne,{label:Tt})).bytes}catch(e){if(zp(e))return null;throw e}}function Qp(n){return n?{exists:!0,sha256:Gp("sha256").update(n).digest("hex")}:{exists:!1,sha256:null}}async function Vn(n,e={}){let t=await Xp(n);return{source:t?.toString("utf8")??null,document:t?Ae(t.toString("utf8"),e):null,identity:Qp(t)}}async function Zi(n){return(await Jn(n))?.config??null}var Cy=Number.MAX_SAFE_INTEGER;var jy=Number.MAX_SAFE_INTEGER;var Xy=V("hookWritePolicy",async n=>(await Zi(n))?.hook??{allow_paths:[]});import nh from"node:path";var Gn="comet.selection.v2",Ac=Number.MAX_SAFE_INTEGER;function Tc(n){return nh.join(n,".comet","current-change.json")}function rh(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Nc(n){return n===null||typeof n=="string"}function ih(n){let e;try{e=JSON.parse(n)}catch(t){throw new Error(`current change selection contains invalid JSON: ${t instanceof Error?t.message:String(t)}`,{cause:t})}if(!rh(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!Nc(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:Gn,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==Gn)throw new Error(`current change selection schema must be ${Gn}`);if(e.workflow!=="native"&&e.workflow!=="classic"&&e.workflow!=="application")throw new Error("current change selection workflow must be native, classic or application");if(e.workflow==="application"&&(typeof e.applicationId!="string"||!e.applicationId.trim()||e.branch!==null))throw new Error("application selection requires applicationId and a null branch");if(e.workflow!=="application"&&e.applicationId!==void 0)throw new Error("built-in selection cannot retain another application identity");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!Nc(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function Oc(n){let e;try{let r=Tc(n),{bytes:i}=await At(r,Ac,{label:"current change selection"});e=i.toString("utf8")}catch(r){if(r.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${r instanceof Error?r.message:String(r)}`,{cause:r})}return{status:"selected",...ih(e)}}var nv=V("readCometCurrentSelection",n=>Oc(n));var rb=Number.MAX_SAFE_INTEGER;var zn=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/u;var Te=["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","check_epoch","verification_report","branch_status","created_at","verified_at","archive_confirmation","archived","direct_override","handoff_context","handoff_hash","classic_profile","classic_migration"],Oe=["change_id","run_id","run_checkpoint","application_checkpoint"],ab=new Set([...Te,...Oe]);var Mt=Ft(Nt(),1);import nr from"path";import{AsyncLocalStorage as hh}from"async_hooks";import{promises as Mc}from"fs";import It from"path";import{promises as Lc}from"fs";import T from"path";import lh from"os";import{promises as ah}from"fs";async function Ic(n){try{return await ah.access(n),!0}catch(e){if(ch(e))return!1;throw e}}function ch(n){let e=n?.code;return e==="ENOENT"||e==="ENOTDIR"}var Ot=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Ie=class extends Error{constructor(e){super(e instanceof Error?e.message:String(e),{cause:e}),this.name="ClassicProjectConfigError"}},jc=".comet/config.yaml";function eo(n){let e=n?.code;return e==="ENOENT"||e==="ENOTDIR"}function Dc(n,e){let t=T.resolve(n),r=e==="docs"?T.join(t,"docs"):t,i=T.join(r,"openspec"),o=T.join(t,"docs","superpowers");return{projectRoot:t,artifactLayout:e,openSpecBase:r,openSpecRoot:i,changesDir:T.join(i,"changes"),archiveDir:T.join(i,"changes","archive"),specsDir:T.join(i,"specs"),superpowersRoot:o,superpowersSpecsDir:T.join(o,"specs"),superpowersPlansDir:T.join(o,"plans"),superpowersReportsDir:T.join(o,"reports")}}async function uh(n){let e=await Jn(n,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new Ot;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new Ot("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function fh(n,e){return Dc(n,e??await uh(n))}async function dh(n){try{return await Lc.lstat(n),!0}catch(e){if(eo(e))return!1;throw e}}async function mh(n,e){let t=await fh(n,e),r=t.artifactLayout==="legacy"?"docs":"legacy",i=Dc(n,r).openSpecRoot,[o,s]=await Promise.all([L(t.projectRoot,ze(t.projectRoot,t.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),dh(i)]),a=o.exists;return{paths:t,configuredRootExists:a,alternateRoot:i,alternateRootExists:s,dualRoots:a&&s}}async function ph(n){let e=[n.openSpecRoot,n.changesDir,n.archiveDir,n.specsDir,n.superpowersRoot,n.superpowersSpecsDir,n.superpowersPlansDir,n.superpowersReportsDir];for(let t of e){let r=ze(n.projectRoot,t);await L(n.projectRoot,r,{label:`Classic managed physical path ${r}`,expected:"directory"})}}async function qc(n,e){let t=await mh(n,e);if(await ph(t.paths),!t.configuredRootExists){let r=ze(t.paths.projectRoot,t.paths.openSpecRoot),i=ze(t.paths.projectRoot,t.alternateRoot);throw new Ot(`Configured Classic OpenSpec root is missing: ${r} (alternate ${i} is ${t.alternateRootExists?"present":"missing"})`)}return t.paths}async function je(n){let e=T.resolve(n),t=null;try{(await Lc.lstat(e)).isDirectory()||(e=T.dirname(e))}catch(o){if(!eo(o))throw o}let r=e,i=T.resolve(lh.homedir());for(;;){T.basename(e)==="openspec"&&(t=T.dirname(e));let o=!1,s=e===i&&e!==r,a=null;if(!s)try{let{bytes:l}=await U(e,jc,Ne,{label:jc});a=l.toString("utf8")}catch(l){if(!eo(l))throw l}if(a!==null)try{let l=Ae(a,{allowPartialProject:!0,allowMissingNativeFields:!0}).value;o=!!l&&typeof l=="object"&&!Array.isArray(l)&&(l.schema==="comet.project.v1"||l.default_workflow!==void 0||l.native!==void 0)}catch(l){if(e===r)throw new Ie(l);if(vc(a))throw new Ie(l)}if(o||await Ic(T.join(e,".git")))return e;let c=T.dirname(e);if(c===e)return t??T.resolve(n);e=c}}function ze(n,e){return T.relative(T.resolve(n),e).replaceAll("\\","/")}var Xn=new hh;function gh(n,e){let t=It.relative(n,e);return t===""||!It.isAbsolute(t)&&t!==".."&&!t.startsWith(`..${It.sep}`)}async function wh(n){let e=It.resolve(n.invocationCwd??process.cwd()),t=It.resolve(n.projectRoot??await je(e)),[r,i]=await Promise.all([Mc.realpath(e),Mc.realpath(t)]);if(!gh(i,r))throw new Error(`Classic command invocation cwd is outside the discovered project: ${e}`);return{invocationCwd:e,projectRoot:t,observations:new Map}}async function yh(n,e){let t=Xn.getStore();if(t)return e(t);let r=await wh(n);return Xn.run(r,()=>e(r))}function $c(){let n=Xn.getStore();if(!n)throw new Error("Classic command project context is unavailable");return n.projectRoot}async function Wc(n,e){let t=Xn.getStore();if(!t?.observations)return e();let r=t.observations.get(n);if(r)return r;let i=e();t.observations.set(n,i);try{return await i}catch(o){throw t.observations.delete(n),o}}function Fc(n){return(e,t)=>yh(t,()=>n(e,t))}import{promises as Qc}from"fs";import tr from"path";import Xe from"path";import{AsyncLocalStorage as jh}from"node:async_hooks";var Yc=Ft(Nt(),1);import{createHash as Ph,randomUUID as Rh}from"node:crypto";import x from"node:path";import{promises as Uc}from"node:fs";import xh from"node:path";import{createHash as vh}from"node:crypto";import{lstatSync as jt,readFileSync as bh,realpathSync as Bc}from"node:fs";import kh from"node:os";import $ from"node:path";function to(n){return`${n.dev}:${n.ino}:${n.birthtimeNs}`}function Qn(n){return process.platform==="win32"?Bc.native(n):Bc(n)}var Sh=Qe("workspaceIdentity",Eh);function Ch(n){return Sh(n)}function Eh(n){let e=Qn($.resolve(n)),t=jt(e,{bigint:!0});if(!t.isDirectory())throw new Error(`工作区必须是目录:${n}`);let r=to(t),i=(c,l)=>({projectRoot:e,workspaceId:vh("sha256").update(JSON.stringify(["comet.workspace.v2",e,r,c,l])).digest("hex")}),o=$.join(e,".git"),s,a;try{let c=jt(o);if(c.isSymbolicLink())throw new Error(`工作区 .git 不能是符号链接:${o}`);if(c.isDirectory())s=Qn(o),a=to(jt(s,{bigint:!0}));else if(c.isFile()){let l=/^gitdir: (.+)\r?\n?$/u.exec(bh(o,"utf8"));if(!l)throw new Error(`工作区 .git 文件格式无效:${o}`);s=Qn($.resolve(e,l[1].trim()));let m=jt(s,{bigint:!0});if(!m.isDirectory())throw new Error(`工作区 Git 元数据必须是目录:${s}`);a=to(m)}else throw new Error(`工作区 .git 类型无效:${o}`)}catch(c){if(c.code!=="ENOENT")throw c;try{jt(o)}catch(l){if(l.code==="ENOENT")return i(o,null);throw l}throw c}return i(s,a)}function Kc(n){let e=$.dirname(n);if(e===n)return n;try{return $.join(Qn(e),$.basename(n))}catch(t){if(t.code!=="ENOENT")throw t;return $.join(Kc(e),$.basename(n))}}var _h=Qe("workspaceRuntimeParent",Kc);function no(n){let e=Ch(n),t=process.env.COMET_DATA_DIR;if(t!==void 0&&(!t.trim()||!$.isAbsolute(t)))throw new Error("COMET_DATA_DIR 必须是非空绝对路径");let r=_h(t??$.join(kh.homedir(),".comet")),i=$.relative(e.projectRoot,r);if(i===""||!$.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${$.sep}`))throw new Error(`用户级 Runtime 数据根不能位于当前工作区内:${r};工作区:${e.projectRoot}`);let o=$.join(r,"workspaces",e.workspaceId);return{...e,dataRoot:r,workspaceRoot:o,runtimeRoot:$.join(o,"runtime")}}function Lt(n){return no(n).runtimeRoot}async function Hc(n){let e=xh.dirname(n);if(e!==n){await Hc(e);try{await Uc.mkdir(n,{mode:448})}catch(r){if(r.code!=="EEXIST")throw r}}let t=await Uc.lstat(n);if(!t.isDirectory()||t.isSymbolicLink())throw new Error("Runtime 路径必须是真实目录:"+n)}async function ro(n){let e=Lt(n);return await Hc(e),e}var Nh=new Set(["run-state.json","pending-action.json","trajectory.jsonl","context.md","artifacts.json","checkpoint.json","coordination.json","subagent-progress.md"]);function Zn(n){let e=Ph("sha256").update(n).digest("hex");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20,32)}`}async function Jc(n,e){let t=await Z(e),r=x.relative(n,t).replaceAll("\\","/"),i=null;try{i=(await U(n,r,Number.MAX_SAFE_INTEGER,{label:"Classic change identity"})).bytes.toString("utf8")}catch(a){if(a.code!=="ENOENT")throw a}if(i===null)throw Object.assign(new Error("Classic state file does not exist"),{code:"ENOENT"});let o=(0,Yc.parseDocument)(i,{uniqueKeys:!0});if(o.errors.length)throw new Error(`Invalid Classic state document: ${o.errors[0].message}`);let s=o.get("change_id");if(s!==void 0&&(typeof s!="string"||!zn.test(s)))throw new Error("Invalid Classic change_id: expected an immutable UUID");return{source:i,document:o,id:s}}async function Ah(n,e){let t=await Z(e),r=x.relative(n,t).replaceAll("\\","/"),i=()=>Jc(n,e),o=await i();if(o.id)return o.id;let{source:s,document:a}=o,c=a.get("run_id"),l=typeof c=="string"&&c?Zn(`classic-run:${c}`):Rh();return a.get("archived")===!0||x.basename(x.dirname(e))==="archive"?typeof c=="string"&&c?l:Zn(`classic-archive:${r}`):(a.set("change_id",l),await ee(t,a.toString(),{containedRoot:n,exclusive:s===null,beforeCommit:async()=>{if((await i()).source!==s)throw new Error("Classic state changed while assigning its instance identity")}}),l)}async function Th(n,e,t={}){let r=e??await je(n),i;try{i=await Jc(r,n)}catch(g){if(g.code==="ENOENT")return null;throw g}let{document:o,id:s}=i,a=x.relative(r,n).replaceAll("\\","/"),c=o.get("run_id"),l=o.get("archived")===!0||x.basename(x.dirname(n))==="archive",m=s??(typeof c=="string"&&c?Zn(`classic-run:${c}`):l?Zn(`classic-archive:${a}`):null);if(!m)return n;let f=Lt(r),u=x.parse(f).root;if(!(await L(u,x.relative(u,f).replaceAll("\\","/"),{label:"Classic read-only Runtime root",expected:"directory"})).exists)return t.includeMissing?x.join(f,"classic-changes",m):n;let p=await L(f,`classic-changes/${m}`,{label:"Classic read-only Run directory",expected:"directory"});return p.exists||t.includeMissing?p.target:n}async function Oh(n,e){return Ih(n,e)}async function Ih(n,e){let t=e??await je(n),r=x.relative(t,n).replaceAll("\\","/");if(r&&!(await L(t,r,{label:"Classic change directory",expected:"directory"})).exists)throw Object.assign(new Error("Classic change directory does not exist"),{code:"ENOENT"});await Z(n);let i=await ro(t),o=await Ah(t,n),s=x.join(i,"classic-changes",o);return await Yn(i,x.relative(i,s),{label:"Classic local Run directory"}),s}async function Vc(n,e,t={}){let r=Lt(n),i=x.relative(r,e);if(i===""||!i.startsWith(`..${x.sep}`)&&i!==".."&&!x.isAbsolute(i))return t.readOnly?{root:x.dirname(r),target:e}:(await ro(n),{root:r,target:e});let o=x.relative(x.resolve(n),e).replaceAll("\\","/");if(o.startsWith(".comet/runtime/"))return{root:r,target:x.join(r,o.slice(15))};let s=/^(?:(.*)\/)?\.comet\/([^/]+)(\/.*)?$/u.exec(o);if(!s||!Nh.has(s[2]))return null;if(t.readOnly){let u=x.parse(r).root;if(!(await L(u,x.relative(u,x.join(r,"classic-changes")),{label:"Classic local records",expected:"directory"})).exists)return null}let a=s[1]??"";if(!(await L(n,x.relative(n,await Z(x.join(n,a))),{label:"Classic local change identity",expected:"file"})).exists)return null;let l=x.join(n,a),m=t.readOnly?await Th(l,n,{includeMissing:!0}):await Oh(l,n);if(!m||t.readOnly&&m===l)return null;let f=x.relative(r,m);if(x.isAbsolute(f)||f===".."||f.startsWith(`..${x.sep}`))throw new Error("Classic Runtime workspace changed while resolving a change-local target");return{root:t.readOnly?x.dirname(r):r,target:x.join(m,".comet",s[2],s[3]??"")}}var io=Number.MAX_SAFE_INTEGER,Lh=new jh;async function Dh(n,e){let t=Lh.getStore();if(!t||t.root!==Xe.resolve(n))return null;let r=re(e,"Classic proposal source"),i=t.files.get(r);return i||(i=t.session.read(r,io),t.files.set(r,i)),i}async function Gc(n,e,t,r=!1){let i=Xe.resolve(n),o=Xe.isAbsolute(e)?Xe.resolve(e):Xe.resolve(i,e),s=await Vc(i,o,{readOnly:!r});s&&(i=s.root,o=s.target);let a=Xe.relative(i,o).replaceAll("\\","/");return{root:i,relative:re(a,t),target:o}}async function er(n,e,t){let r=await Gc(n,e,t.label,t.migrate);return L(r.root,r.relative,t)}async function zc(n,e,t){try{return(await er(n,e,{label:t.label,expected:t.expected??"any"})).exists}catch(r){if(r.code==="ENOENT")return!1;throw r}}async function Xc(n,e,t){return(await qh(n,e,t)).toString("utf8")}async function qh(n,e,t){let r=await Gc(n,e,t.label);if(!t.hooks){let i=await Dh(r.root,r.relative);if(i){if(i.bytes.length>(t.maxBytes??io))throw new Error(`${t.label} exceeds the read limit`);return i.bytes}}return(await U(r.root,r.relative,t.maxBytes??io,{label:t.label,hooks:t.hooks})).bytes}function so(n){return n?/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(n)?n.includes("..")?"Change name cannot contain '..' (path traversal not allowed)":null:`Invalid change name: '${n}'
|
|
143
|
+
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function Zc(n){let e=so(n);if(e)throw new Error(e)}function Mh(n,e){return{label:ze(n,e),directory:e}}async function oo(n,e,t){let r=Mh(n,e);if(!(await er(n,e,{label:t,expected:"directory"})).exists)return{change:r,exists:!1,stateExists:!1};let o=await er(n,await Z(e),{label:`${t} state`,expected:"file"});return{change:r,exists:!0,stateExists:o.exists}}var $h=/^\d{4}-\d{2}-\d{2}-/u;function Wh(n,e){return n.slice(11)===e&&$h.test(n)}async function Fh(n,e,t){Zc(t);let r=()=>L(n,tr.relative(n,e),{label:"Classic Archive directory",expected:"directory"}),i=await r();if(!i.exists)return null;let o=async()=>{let c=await Qc.lstat(i.target,{bigint:!0});if(!c.isDirectory()||c.isSymbolicLink())throw new Error("Classic Archive directory must be a real directory");return[c.dev,c.ino,c.mode,c.size,c.mtimeNs,c.ctimeNs].join(":")},s=await o(),a=await Wc(`classic-archive:${JSON.stringify([i.target,t,s])}`,async()=>{let c=await Qc.readdir(i.target);if(await o()!==s)throw new Error("Classic Archive directory changed while inspecting state files");return c.filter(l=>l===t||Wh(l,t))});if(!(await r()).exists||await o()!==s)throw new Error("Classic Archive directory changed while inspecting state files");return a}async function Bh(n,e,t,r={}){if(!r.skipExactCompatibility){let s=await oo(n,tr.join(e,t),`Classic archived change ${t}`);if(s.exists)return s.change}let i=await Fh(n,e,t),o=[];for(let s of i??[]){if(s===t)continue;let a=await oo(n,tr.join(e,s),`Classic archived change ${s}`);a.exists&&a.stateExists&&o.push(a.change)}return o.sort((s,a)=>a.directory.localeCompare(s.directory))[0]??null}async function el(n,e=process.cwd()){Zc(n);let t=await qc(e),r=await oo(t.projectRoot,tr.join(t.changesDir,n),`Classic active change ${n}`);if(r.exists)return r.change;let i=await Bh(t.projectRoot,t.archiveDir,n);return i||r.change}var Kh="\x1B[32m",Dt="\x1B[31m",Uh="\x1B[33m",Hh="\x1B[0m",Yh=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"],Jh={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","autonomous"],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"]},Vh=new Set([...Te,...Oe,"classic_profile","classic_migration"]);function Le(n,e){return`${n}${e}${Hh}`}function qt(n){return n==null?"":typeof n=="object"?JSON.stringify(n):String(n)}var tl=Fc(async n=>{if(n.length!==1)return{exitCode:64,stderr:"Usage: comet classic validate <change-name>"};let e=n[0],t=so(e);if(t)return{exitCode:1,stderr:Le(Dt,`ERROR: ${t}`)};let r=$c(),{directory:i,label:o}=await el(e,r),s=await Z(i),a=[`[VALIDATE] ${o}/${nr.basename(s)}`],c=0,l=0,m=d=>{c+=1,a.push(Le(Dt,` FAIL: ${d}`))},f=d=>{l+=1,a.push(Le(Uh,` WARN: ${d}`))},u;try{u=await Xc(r,s,{label:`Classic state ${o}/${nr.basename(s)}`})}catch(d){if(d.code==="ENOENT")return m(`${nr.basename(s)} does not exist`),a.push("",Le(Dt,`${c} error(s), ${l} warning(s) — validation FAILED`)),{exitCode:1,stderr:a.join(`
|
|
144
|
+
`)};throw d}let p=(0,Mt.parseDocument)(u);if(p.errors.length>0||!(0,Mt.isMap)(p.contents)){for(let d of p.errors)m(d.message);return(0,Mt.isMap)(p.contents)||m("document root must be a mapping"),a.push("",Le(Dt,`${c} error(s), ${l} warning(s) — validation FAILED`)),{exitCode:1,stderr:a.join(`
|
|
145
|
+
`)}}let g=p.toJS();for(let d of Yh)Object.prototype.hasOwnProperty.call(g,d)||m(`missing required field '${d}'`);for(let[d,h]of Object.entries(Jh)){if(!Object.prototype.hasOwnProperty.call(g,d))continue;let w=qt(g[d]);if(!w){d==="auto_transition"&&m(`${d}='' is not valid. Expected: ${h.join(" ")}`);continue}h.includes(w)||m(`${d}='${w}' is not valid. Expected: ${h.join(" ")}`)}if(Object.prototype.hasOwnProperty.call(g,"bound_branch")){let d=g.bound_branch;d!==null&&typeof d!="string"&&m(`bound_branch='${qt(d)}' is not a string or null`)}g.change_id!==void 0&&(typeof g.change_id!="string"||!zn.test(g.change_id))&&m("change_id must be an immutable UUID");for(let d of["verify_failures","check_epoch"]){if(!Object.prototype.hasOwnProperty.call(g,d))continue;let h=g[d];(typeof h!="number"||!Number.isSafeInteger(h)||h<0)&&m(`${d}='${qt(h)}' is not a non-negative safe integer`)}for(let d of["design_doc","plan","handoff_context","verification_report"]){let h=qt(g[d]);if(h){if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(h)||h.split(/[\\/]/u).includes("..")){m(`${d}='${h}' must be a relative repository path`);continue}try{await zc(r,nr.resolve(r,h),{label:`${d} artifact pointer`,expected:"file"})||m(`${d}='${h}' does not exist on disk`)}catch(w){m(`${d}='${h}' is unsafe: ${w instanceof Error?w.message:String(w)}`)}}}for(let d of["handoff_hash"]){let h=qt(g[d]);h&&!/^[a-f0-9]{64}$/u.test(h)&&m(`${d}='${h}' is not a sha256 hex digest`)}for(let d of Object.keys(g))Vh.has(d)||f(`unknown field '${d}' found; guard treats unknown fields as fatal — remove the field or realign it with this Comet version before advancing the phase`);return a.push(""),c>0?(a.push(Le(Dt,`${c} error(s), ${l} warning(s) — validation FAILED`)),{exitCode:1,stderr:a.join(`
|
|
146
|
+
`)}):(a.push(Le(Kh,`0 errors, ${l} warning(s) — validation PASSED`)),{exitCode:0,stderr:a.join(`
|
|
147
|
+
`)})});var Gh=new Set([...Oe,"archive_confirmation","verify_failures","check_epoch","classic_profile","classic_migration","bound_branch"]),nl=new Set(Te.filter(n=>!Gh.has(n))),ao={workflow:["full","hotfix","tweak"],phase:["open","design","build","verify","archive"],context_compression:["off","beta"],build_mode:["subagent-driven-development","executing-plans","direct","autonomous"],build_pause:["null","plan-ready"],subagent_dispatch:["null","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"]};var rl=["open-complete","design-complete","build-complete","verify-pass","verify-fail","archive-confirm","archive-reopen","archived","preset-escalate"];var zh=`
|
|
148
|
+
Options: --json (machine-readable output), --compact (requires --json), --help
|
|
149
|
+
精简视图用 outputView.references 的 JSON Pointer 定位重复字段;Request 模板保留完整;没有字节收益时返回原完整协议。去掉 --compact 获取完整协议。
|
|
150
|
+
JSON: one object with command and exitCode; data, stdout, stderr, summary and next are optional.
|
|
151
|
+
Use exitCode for success; do not parse human-readable stdout. Help text is in stdout in JSON mode.
|
|
152
|
+
`;function il(n,e){let t=e.indexOf("--"),r=t<0?e:e.slice(0,t);if(!r.includes("--help")&&!r.includes("-h"))return;let i={check:["comet check run <change> <build|verify> -- <program> [args...]","comet check rerun <change> <build|verify>","These legacy commands return Agent platform guidance only; they do not execute or replay programs, create a claim, or record a passing result.","Run ordinary development and checks with the Agent platform tools. The platform owns timeout, cancellation and process cleanup.","Submit the actual results with --checks when completing SDK Build/Verify; use comet state record-check for Compat.","The Agent judges which checks apply. User choices, approvals, tasks and acceptance remain required.","Result: data.executed=false, data.nextAction and platform guidance; exitCode=0 means guidance was returned, not that a check passed."],state:["comet state <command> [args]","init <change-name> <full|hotfix|tweak> [--isolation <current|branch|worktree>] [--runtime <compat|sdk>]","state init defaults to sdk in Git roots and compat in non-Git roots for document-only archive; explicit sdk remains available but SDK Archive requires Git.","restore <change-name> --confirmed (recover a copied SDK Run; older states without a checkpoint restart at Open)","get <change-name> <field> [<field> ...]","set <change-name> <field> <value> [<field> <value> ...]","propose-design <change-name> --proposal <text> (SDK full workflow)","revise-design <change-name> --expected-revision <number> (SDK full workflow)","decide-design <change-name> --proposal-hash <sha256> --choice <approved|rejected> (SDK)","complete-design <change-name> --design-doc <repo-relative-ref> [--approval-hash <sha256>]","propose-build <change-name> --file <json> [--confirmed] (SDK full; --confirmed only for choices already explicitly approved)","decide-build <change-name> --proposal-hash <sha256> --choice <approved|rejected>","submit-plan <change-name> --plan <repo-relative-ref> [--pause]","revise-plan <change-name> --expected-revision <number> (SDK full workflow)","continue-build <change-name> --expected-revision <number> (SDK; resume a stopped failed Builder with preserved work)","continue-work <change-name> --expected-revision <number> (SDK; continue a settled failed Skill from preserved work)","continue-plan <change-name> --proposal-hash <sha256>","complete-build <change-name>","propose-escalation <change-name> --reason <text> (SDK hotfix/tweak)","decide-escalation <change-name> --proposal-hash <sha256> --choice <continue|upgrade> (SDK)","propose-archive <change-name> --summary <text> [--remote <name>] [--pr-base <branch>] [--delivery-path <file>]... (SDK)","decide-archive <change-name> --proposal-hash <sha256> --choice <local|push|pr|reverify|later> (SDK)","reopen-verification <change-name> --expected-revision <number> (SDK; before Archive execution)","repair-archive <change-name> --expected-revision <number> (SDK; stopped failure with unchanged Archive inputs)","repair-delivery <change-name> --expected-revision <number> [--checks <checks-json-file>] (SDK; repair delivery after Archive)","decide-delivery-repair <change-name> --proposal-hash <hash> --choice <approved|later>","complete-delivery <change-name> --commit <sha> [--pr-url <url>] (SDK)","transition <change-name> <event>","transition <change-name> verify-fail --reason <text> (SDK)","check <change-name> <phase> [--recover] [--details]","scale <change-name>","artifacts <change-name>","record-check <change-name> <build|verify> --command <text> --exit-code <int> [--cwd <path>]","task-checkoff <file> <task-text>","tasks <change-name> [--assign-ids]","task-complete <change-name> <task-id> --expect <revision>","sync-plan <change-name>","checkpoint <change-name> [--file <json>]","delivery <change-name> [--file <json> | --verify]","select <change-name> [--details] | rebind <change-name> | next <change-name> [--details]","current | clear-selection","","Start with current or next <change-name> to inspect workflow guidance.","Advanced writes: init, set, transition, task-checkoff, select, rebind, clear-selection.","Use comet state <command> --help for details. --recover is for cold recovery, not normal progression.","A copied SDK change with a Run checkpoint in comet-state.yaml (or legacy .comet.yaml) resumes at its saved phase. If the checkpoint is absent, state restore requires confirmation and restarts at Open with fresh approvals and checks.","For SDK Design, propose-design records the exact proposal before asking the user; decide-design accepts only its current hash and may return a rejected proposal to Design. complete-design requires the approved hash and records the Design Doc in the same Run.","For SDK Build, propose-build reads build_mode, tdd_mode, review_mode and subagent_dispatch from a project-relative JSON file; optional direct_override is required for full direct execution. Workspace isolation remains the Open decision.","内置 Build 配置提案已拒绝时,修正 JSON 后用 propose-build --file 重提;保留原 claim 和拒绝记录,禁止 --confirmed,须使用新的 proposalHash 再执行 decide-build。未回传或非配置执行任务仍须核对原执行器。","decide-build resolves only the current proposal. Rejecting it returns to configuration; approving it stores the choices and advances to planning.","submit-plan validates the plan and its tasks.md authority before recording both the Action and evidence in the SDK Run. --pause requires an explicit continue-plan decision before execution.","continue-plan accepts only the current plan-ready proposal and rejects changes to the approved plan or tasks.","After source or plan changes, use the revision-bound revise-design or revise-plan command returned by recovery guidance; old approvals and accepted evidence cannot authorize changed content.","complete-build accepts finished full-workflow tasks and actual platform check reports through --checks before scheduling Verify.","For SDK hotfix/tweak, propose-escalation records why full Design is needed; decide-escalation applies only the current user choice. Upgrading continues the same Run and workspace through full Design.","For SDK Archive, propose-archive binds the current branch and verified change to a user decision; decide-archive accepts only its current proposal hash. A local, push, or PR choice is required before the Archive Guard can perform filesystem archiving.","Repeat --delivery-path for a complete explicit file list when this change includes pre-existing work. The original Archive proposal includes those paths for user approval. Without it, pre-existing dirty paths stay outside automatic delivery selection.","SDK 归档后,修复与归档可分成连续单父提交;从已批准 baseCommit 到交付 HEAD 的每个提交只能包含已验证实现和本次归档产物。complete-delivery 核对整个范围、最终内容和已批准的远端/PR;不执行 commit、push、建 PR 或改写历史。","For compat Design, complete-design registers the reference, refreshes handoff, and applies the guard; interrupted retries retain completed work.","Use data.artifactRefs for state references and task-authority markers; absolute paths are for file operations."],guard:["comet guard <change-name> <open|design|build|verify|archive> [--apply]","SDK-owned full Design: comet guard <change-name> design --design-doc <repo-relative-ref> [--apply --approval-hash <sha256>]","SDK Design preview reads the current proposal, handoff and document without advancing the Run; apply requires the matching user approval hash.","SDK-owned Build: comet guard <change-name> build [--apply --checks <checks-json-file> --session <builder-execution-ref>]","SDK Build preview is read-only; apply validates the actual platform reports and completed tasks before Verify. It does not infer or execute commands.","SDK-owned Verify: comet guard <change-name> verify --report <repo-relative-ref> [--apply --checks <checks-json-file>]","--session records the actual Builder session. Preserve any selected independent review and report the actual verification results.","SDK Verify preview checks the report and pending Run without advancing it; apply submits the report and actual platform checks before Archive. Failed or missing reports do not advance the Run.","SDK-owned Archive: comet guard <change-name> archive [--apply]","SDK Archive preview checks the approved delivery and current Verify evidence; apply runs preflight and OpenSpec Archive once. Commit, push, and PR delivery remain a separate pending SDK Action.","Compat Guard validates phase requirements; --apply advances the phase after all checks pass.","Compat Guard reads the latest Agent check report for this phase and Run; it never executes a detected build.","Preview does not advance the phase. Apply requires the current tasks, user approvals and accepted reports.","Repeated previews preserve the Run and reports. The Agent assesses whether changes require further checks.","Do not poll guard for status. Use comet state next <change-name> for guidance.","On failure follow the reported next action; do not blindly retry side-effecting checks.","","Examples:"," comet guard demo build --apply --json"," comet state next demo --json"],handoff:["comet handoff <change-name> design --write [--full]","References the original source files; --full explicitly generates one readable Markdown view without changing approvals."],archive:["comet archive <change-name> [--dry-run|--recover]","--recover reconciles one moved SDK Archive after the original executor has stopped; it never runs OpenSpec Archive again.","If interrupted specification synchronization has no original result receipt, review recoveryApproval.changes with the user, then use --recover --confirmed --proposal-hash <current-hash>. Changed outputs invalidate that decision; do not self-confirm."],validate:["comet classic validate <change-name>"],workspace:["comet classic workspace prepare <change-name> --isolation <current|branch|worktree> [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]","comet classic workspace resolve <change-name>"]},o={current:["comet state current","Reports the selected Classic change. Does not advance the phase."],next:["comet state next <change-name> [--details] [--continue]","Reports the next workflow action. --continue executes only recorded SDK commands and authorized internal steps, stopping for Agent work, user decisions, failures or unresolved executions.","SDK JSON includes recovery paths, configuration, compact task state and current Run handles. --details expands tasks, checkpoint content and full Run history."],select:["comet state select <change-name> [--details]","Writes the current change selection used by workflow routing.","SDK JSON includes recovery paths, configuration, compact task state and current Run handles. --details expands tasks, checkpoint content and full Run history."],rebind:["comet state rebind <change-name>","Updates the change branch binding to the current Git branch after validation."],"clear-selection":["comet state clear-selection","Clears the current change selection; does not delete change artifacts."],init:["comet state init <change-name> <full|hotfix|tweak> [--isolation <current|branch|worktree>]","Creates Classic workflow state. Follow the Open workflow for required user decisions."],scale:["comet state scale <change-name>","Reports a verification recommendation without changing verify_mode.","JSON: data.recommendation, data.selected and data.metrics. Scale is not a risk assessment.","Preserve an existing selection; record a new decision explicitly with state set when needed."],artifacts:["comet state artifacts <change-name>","Inspects the OpenSpec apply dependency closure, including dependencies of already-complete artifacts.","JSON: data.source, required, skipped, designRequired, files and problems. This does not execute implementation or verification.","Optional design is omitted only when the active schema excludes it from the required closure.","Skipped specs require explicit skip_specs: true, upstream support and no conflicting spec files.","Compat changes without .openspec.yaml retain the existing Classic artifact requirements."],"task-checkoff":["comet state task-checkoff <file> <task-text>","Checks that exactly one matching task is already checked. Does not write the task file or execute the task."],tasks:["comet state tasks <change-name> [--assign-ids]","Reads tasks.md as the task completion authority. Fenced examples are excluded.","--assign-ids persists IDs for legacy/new tasks in Open, Design or Build; existing IDs remain unchanged.","Assign IDs before generating the design handoff and plan. ID assignment changes task requirements.","JSON: data.authority, data.revision, data.needsIds, data.tasks and data.progress.","Each task has id, text, completed and line. Never use line/order as task identity.","Example: comet state tasks demo --assign-ids --json"],"task-complete":["comet state task-complete <change-name> <task-id> --expect <revision>","Records accepted task completion during Build; does not execute or independently verify work.","Use the revision returned by state tasks. Changed requirements reject the write; refresh and reassess the task.","Writes tasks.md under the state lock and synchronizes explicitly ID-mapped legacy plan checkboxes. Retries repair interrupted projection writes.","Reconcile code, checks and review evidence before recording completion; unchecked does not mean unimplemented.","Unmapped legacy items are preserved and reported as mapping-required; never match tasks by position or wording."],"sync-plan":["comet state sync-plan <change-name>","Synchronizes legacy plan checkboxes from tasks.md by explicit comet-task IDs; does not execute or accept work.","Rejects missing or unknown plan IDs. Reconcile extra requirements into tasks.md before mapping.","New plans should reference task IDs without a second completion checklist."],checkpoint:["comet state checkpoint <change-name> [--file <json>]","Reads a structured coordination checkpoint, or records an explicitly bounded work package during Build.","Input: taskIds, revision, stage, sessionId, evidence, unresolved, reviewRounds.","Include schemaVersion: 1. JSON state is .comet/coordination.json, separate from the Engine checkpoint.","Stages: implementing|task-review|checkoff|done|blocked. Evidence is a coordination record, not automatic acceptance.","Runtime checks task IDs and revision and renders subagent-progress.md. Do not maintain its projection manually."],delivery:["comet state delivery <change-name> [--file <json> | --verify]","Reads delivery authorization and observed progress, or records the user-authorized local|push|pr action.","Input: action, targetBranch, optional remote, commit and prUrl. Recording never performs remote writes.","First authorization requires Archive with passing verification before archival. Missing legacy authorization is never inferred.","Resume only authorized unfinished steps; supplied commit or PR text alone does not prove delivery.","compat 的 --verify 只做有界远端/PR 读取。SDK 的 --verify 使用当前 HEAD 转交 complete-delivery 校验并结束已批准的交付;已完成 Run 只核对历史回执和原提交对象,不将后续 HEAD、工作区或远端变化视为旧交付失败;普通读取不访问网络。","SDK 的 --file 仅接受与已批准 action、targetBranch、remote 一致的实际 commit 和可选 prUrl,不创建或覆盖授权。PR 首次交付使用 complete-delivery --commit <sha> --pr-url <url>,或 --file 提交完整记录。"],get:["comet state get <change-name> <field> [<field> ...]","Reads the requested fields from one state snapshot. JSON: data.change and data.fields (string values).","One field preserves the bare stdout value; multiple fields print field=value lines in request order.",`Fields: ${[...Te,...Oe].join(", ")}`,"Example: comet state get demo phase --json","Example: comet state get demo phase workflow build_mode tdd_mode review_mode --json"],set:["comet state set <change-name> <field> <value> [<field> <value> ...]","Advanced: validates all fields, then commits one atomic state update and reconciles Runtime state.","Invalid values or duplicate fields reject the whole update. Do not bypass workflow confirmations.","JSON: data.change and data.updated contain the committed field values.","Writable fields (enum values shown where applicable):",...[...nl].map(c=>` ${c}${ao[c]?`: ${ao[c].join("|")}`:c==="language"?": en|zh-CN":""}`),"Other Runtime-owned fields cannot be set manually. Artifact paths must stay within the project.","Example: comet state set demo verify_mode full","Example: comet state set demo build_mode executing-plans tdd_mode direct review_mode standard --json"],check:["comet state check <change-name> <open|design|build|verify|archive> [--recover] [--details]","Checks phase entry requirements; this is not a build/test execution command.","--recover is for cold recovery after context loss, not normal phase progression.","Recovery reads the original business state, reports and approvals; it does not replay commands or recover processes.","It preserves completed work. The Agent checks current implementation and acceptance, runs necessary checks with platform tools, and submits the actual results.","JSON entry data includes layout, configuration, configurationReadiness, nextAction, compact taskState, planMapping and checks.","--recover includes checkpoint references; --details expands tasks, checkpoint content and full SDK Run history.","Reconcile existing implementation and acceptance before dispatching work; unchecked tasks are not proof of missing implementation.","Read fresh state after changing configuration or advancing phases; do not reuse an earlier entry snapshot.","SDK entry, proposal, decision and completion results include nextAction from that Run revision, with Action, evidence or decision handles. User approval and fresh validation are still required for subsequent writes.","","Examples:"," comet state check demo build --json"," comet state check demo build --recover --json"],"revise-design":["comet state revise-design <change-name> --expected-revision <number>","Reopens SDK full Design from Design, Build, Verify, or Archive before side effects; retains implementation, configuration and decision history. Reconcile running or unknown work first.","Use the current Run revision from state next or state check --recover. A stale revision is rejected.","Then propose-design with the revised design and any agreed Spec Patch, obtain a new explicit user decision, and decide-design with the new proposal hash.","Revision does not approve the new design. Old approval hashes do not authorize changed requirements."],"reopen-verification":["comet state reopen-verification <change-name> --expected-revision <number>","保留当前修改和审计历史,取消未执行的归档或验收工作并重开 Verify;通过后必须重新批准 Archive。","仅支持尚未执行归档、活动目录仍存在且没有 running/unknown Action 的内置 SDK Run。旧 revision 不生效。"],"continue-build":["comet state continue-build <change-name> --expected-revision <number>","Resume a stopped failed Builder, or return Verify or pre-execution Archive to Build on the same SDK Run. Preserve partial work and task completion; invalidate verification and Archive authorization.","Changed full requirements still require revise-design; changed hotfix/tweak scope requires propose-escalation and a new scope decision. Never replay unknown executions."],"continue-work":["comet state continue-work <change-name> --expected-revision <number>","Create successor work for the original failed Skill on the same Run. Preserve completed stages, decisions, partial artifacts and the original failure receipt. Reject running, unknown, stale, or cancelled work."],"repair-archive":["comet state repair-archive <change-name> --expected-revision <number>","Verify that the failed Archive left its original inputs and specifications unchanged and created no archive directory, then reopen Open on the same Run. Correct the inputs and obtain fresh approval and verification. Unknown execution results must be reconciled first."],"repair-delivery":["comet state repair-delivery <change-name> --expected-revision <number> [--checks <checks-json-file>]","归档已完成、交付尚未完成时,在同一 SDK Run 补充检查输出声明并重新检查。保留原归档、业务批准和执行历史,不重放 OpenSpec。","v2:由 Agent 平台完成必要检查,通过 --checks 提交与 Build/Verify 相同格式的报告;保留原批准的路径范围,Runtime 不重跑命令。","旧 v1:在 .comet/check-policy.json 为原 Verify 命令声明 outputs,只排除原批准基线未追踪的生成物。移除这些生成物后沿原命令检查,保持原实现和归档。","随后沿 state next 的原检查请求推进,展示新的交付范围,并取得当前 proposalHash 的明确批准。旧批准不能直接完成本次修复后的交付。"],"decide-delivery-repair":["comet state decide-delivery-repair <change-name> --proposal-hash <hash> --choice <approved|later>","核对补声明的输出、原检查结果和保留的归档,再确认当前交付范围。approved 只恢复当前已核验范围的交付;later 保持等待,不提交或重做归档。"],"revise-plan":["comet state revise-plan <change-name> --expected-revision <number>","Reopens SDK full planning after accepted plan content changes, retaining completed implementation and prior evidence history.","Use the current Run revision from state next or state check --recover. A stale revision is rejected.","Then submit-plan with the revised plan and current task mapping. Use --pause when the user requested a planning pause; continue only with the new plan-ready proposal hash.","Revision does not accept the new plan or bypass task authority, design approval, or Runtime checks.","Changed requirements or task scope require revise-design and a fresh Design approval before resubmitting the plan."],restore:["comet state restore <change-name> --confirmed","Only for a copied SDK change whose state file survived but local Run history did not.","Confirm the original execution process stopped before using this command. A portable checkpoint restores the saved phase and decisions; an older state without one restarts at Open and requires fresh evidence and approvals.","Unknown external actions are not replayed. A branch binding mismatch or archived change is rejected."],"record-check":["comet state record-check <change> <build|verify> --command <text> --exit-code <int> [--cwd <path>]","Records the actual Agent platform result for Compat; does not execute the command.","The latest report belongs to this Run and phase. A failed report cannot advance the phase or borrow an earlier success.","SDK Build/Verify accepts a checks JSON report through --checks; use the command returned by the current Run.","--cwd: relative to project root, defaults to .; must stay inside the project.","","Examples:",' comet state record-check demo verify --command "external test run" --exit-code 1'],transition:["comet state transition <change-name> <event>","SDK: comet state transition <change-name> verify-fail --reason <text>",`Events: ${rl.join(", ")}`,"Advanced: applies a state-machine event and writes workflow state. Required confirmations still apply.","This is not a substitute for the workflow Skill or phase guard. Use state next for the next action."]},s=r.find(c=>!c.startsWith("-")),a=n==="state"&&s&&o[s]||i[n];return a?`Usage: ${a.join(`
|
|
153
|
+
`)}
|
|
154
|
+
${zh}Command placeholders must be replaced with actual values.
|
|
155
|
+
`:void 0}function ol(n,e){let t=d=>d!==null&&typeof d=="object"&&!Array.isArray(d)?d:{},r=t(n),i=t(r.entry),o=t(r.run??i.run??(typeof r.runId=="string"?r:void 0)),s=t(r.state??i.state??r),a=t(r.preparation??r.workspace??i.workspace),c=t(r.continuation??i.continuation??r.nextAction??i.nextAction),l=typeof a.projectRoot=="string"&&a.projectRoot!=="."?a.projectRoot:typeof c.cwd=="string"?c.cwd:typeof r.projectRoot=="string"?r.projectRoot:typeof i.projectRoot=="string"?i.projectRoot:e??null,m=s.stateVersion??s.state_version,f=s.status??o.status,{current:u,...p}=c,g=u===void 0?c:{...p,currentRef:r.continuation!==void 0?"data.continuation.current":"data.entry.continuation.current"};return{phase:typeof s.phase=="string"?s.phase:null,status:typeof f=="string"?f:null,stateVersion:typeof m=="number"?m:null,workspace:{cwd:l},continuation:Object.keys(c).length?{...g,cwd:l}:null,...Object.keys(o).length?{run:{id:typeof o.id=="string"?o.id:typeof o.runId=="string"?o.runId:null,revision:typeof o.revision=="number"?o.revision:null,status:typeof o.status=="string"?o.status:null}}:{}}}import{stripVTControlCharacters as Xh}from"node:util";function sl(n,e={}){return{code:"CLASSIC_COMMAND_FAILED",message:Xh(n instanceof Error?n.message:String(n)),...e}}import{AsyncLocalStorage as ll}from"node:async_hooks";var al=new ll,cl=new ll;async function ul(n,e=t=>{let r=t.completed===void 0?"":`:${t.completed}${t.total===void 0?"":`/${t.total}`} 项`;process.stderr.write(`[Comet] ${t.label}${r},已用 ${Math.floor(t.elapsedMs/1e3)} 秒
|
|
156
|
+
`)}){if(cl.getStore())return n();let t={label:"执行工作流命令"},r=Date.now(),i=setInterval(()=>{try{e({...t,elapsedMs:Date.now()-r})}catch{}},5e3);i.unref?.();try{return await cl.run(t,n)}finally{clearInterval(i)}}async function fl(n){let e={gitCommands:0,gitDurationMs:0};return{result:await al.run([...al.getStore()??[],e],n),metrics:e}}import{randomUUID as og}from"node:crypto";import{performance as gl}from"node:perf_hooks";import{createRequire as Qh}from"node:module";var Zh=Qh(import.meta.url??__filename),rr;function ir(n,e){if(!rr){let t=process.emitWarning;process.emitWarning=((r,...i)=>{String(r instanceof Error?r.message:r).startsWith("SQLite is an experimental feature and might change at any time")||Reflect.apply(t,process,[r,...i])});try{rr=Zh("node:sqlite").DatabaseSync}finally{process.emitWarning=t}}return e===void 0?new rr(n):new rr(n,e)}import{promises as or}from"node:fs";import co from"node:path";async function sr(n,e){let t=no(n),r=co.join(t.workspaceRoot,"observability"),i=t.dataRoot;for(let s of["","workspaces",t.workspaceId,"observability"]){i=co.join(i,s);let a;try{a=await or.lstat(i)}catch(c){if(!e||c.code!=="ENOENT")throw c;await or.mkdir(i,{recursive:s===""}).catch(l=>{if(l.code!=="EEXIST")throw l}),a=await or.lstat(i)}if(!a.isDirectory()||a.isSymbolicLink())throw new Error("Runtime 统计目录必须是普通目录")}let o=co.join(r,"performance.sqlite");for(let s of["","-wal","-shm"])try{let a=await or.lstat(o+s);if(!a.isFile()||a.isSymbolicLink()||a.size>64*1024*1024)throw new Error("Runtime 统计文件无效")}catch(a){if(a.code!=="ENOENT")throw a}return o}import{AsyncLocalStorage as tg}from"node:async_hooks";import{createHash as ng,randomUUID as ml}from"node:crypto";import lo from"node:path";import{stripVTControlCharacters as eg}from"node:util";function dl(n,e=process.env){let t=eg(n).replace(/(Bearer\s+)[^\s"']+/giu,"$1[redacted]").replace(/((?:api[_-]?key|auth[_-]?token|access[_-]?token|_authToken|password|secret)\s*[=:]\s*["']?)[^\s"',}]+/giu,"$1[redacted]").replace(/(https?:\/\/[^\s/:]+:)[^\s@]+@/giu,"$1[redacted]@");for(let[r,i]of Object.entries(e))i&&i.length>=6&&/key|token|password|secret|credential/iu.test(r)&&(t=t.split(i).join("[redacted]"));return t}var rg=864e5,ig=1e4,uo=new tg;function $t(n,e){return dl(n).slice(0,e)}async function pl(n,e){if(!e.length)return;let t=uo.getStore();if(t){let i=o=>process.platform==="win32"?lo.resolve(o).toLowerCase():lo.resolve(o);if(i(n)===i(await t.projectRoot())){t.spans.push(...e);return}}let r=ir(await sr(n,!0));try{r.exec(`PRAGMA busy_timeout=25; PRAGMA journal_mode=WAL;
|
|
157
|
+
CREATE TABLE IF NOT EXISTS trace_spans (
|
|
158
|
+
id TEXT PRIMARY KEY, trace_id TEXT NOT NULL, workflow TEXT NOT NULL,
|
|
159
|
+
change_name TEXT NOT NULL, run_id TEXT NOT NULL, span_id TEXT NOT NULL,
|
|
160
|
+
parent_span_id TEXT, kind TEXT NOT NULL, name TEXT NOT NULL, status TEXT NOT NULL,
|
|
161
|
+
started_at TEXT, ended_at TEXT, updated_at TEXT NOT NULL,
|
|
162
|
+
revision INTEGER NOT NULL, data TEXT NOT NULL);
|
|
163
|
+
CREATE INDEX IF NOT EXISTS trace_spans_time ON trace_spans(updated_at);
|
|
164
|
+
CREATE INDEX IF NOT EXISTS trace_spans_trace ON trace_spans(trace_id);
|
|
165
|
+
BEGIN IMMEDIATE;`);let i=r.prepare(`INSERT INTO trace_spans VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
|
166
|
+
ON CONFLICT(id) DO UPDATE SET status=CASE WHEN excluded.revision >= trace_spans.revision THEN excluded.status ELSE trace_spans.status END,
|
|
167
|
+
started_at=COALESCE(trace_spans.started_at,excluded.started_at),
|
|
168
|
+
ended_at=CASE WHEN excluded.revision < trace_spans.revision THEN trace_spans.ended_at
|
|
169
|
+
WHEN excluded.status IN ('running','pending','waiting','unknown') THEN NULL
|
|
170
|
+
ELSE COALESCE(trace_spans.ended_at,excluded.ended_at) END, updated_at=MAX(trace_spans.updated_at,excluded.updated_at),
|
|
171
|
+
revision=MAX(trace_spans.revision,excluded.revision),
|
|
172
|
+
data=CASE WHEN excluded.revision >= trace_spans.revision THEN excluded.data ELSE trace_spans.data END
|
|
173
|
+
WHERE excluded.revision >= trace_spans.revision OR (trace_spans.started_at IS NULL AND excluded.started_at IS NOT NULL)`),o=e.length>1e3?[...e.filter(s=>s.parentSpanId===null),...e.filter(s=>s.parentSpanId!==null).slice(-999)].slice(0,1e3):e;for(let s of o){if(!s.change||!s.runId||!s.traceId||!s.spanId||s.change.length>240||s.runId.length>240||s.traceId.length>512||s.spanId.length>512||(s.parentSpanId?.length??0)>512)continue;let a={...s,name:$t(s.name,240),summary:s.summary?$t(s.summary,1e3):void 0,attributes:Object.fromEntries(Object.entries(s.attributes??{}).slice(0,20).map(([m,f])=>[$t(m,80),Array.isArray(f)?f.slice(0,30).map(u=>$t(u,240)):typeof f=="string"?$t(f,2e3):f]))};e.length>1e3&&s.parentSpanId===null&&(a.attributes.truncated=!0);let c=JSON.stringify(a);for(;Buffer.byteLength(c,"utf8")>4096;){let m=Object.keys(a.attributes).reverse().find(f=>f!=="truncated");if(m)delete a.attributes[m];else if(a.summary)a.summary=a.summary.slice(0,Math.floor(a.summary.length*.75));else break;c=JSON.stringify(a)}if(Buffer.byteLength(c,"utf8")>4096)continue;let l=ng("sha256").update(JSON.stringify([s.traceId,s.spanId])).digest("hex");i.run(l,s.traceId,s.workflow,s.change,s.runId,s.spanId,s.parentSpanId,s.kind,a.name,s.status,s.startedAt,s.endedAt,s.updatedAt,s.revision,c)}r.prepare("DELETE FROM trace_spans WHERE updated_at < ?").run(new Date(Date.now()-7*rg).toISOString()),r.prepare("DELETE FROM trace_spans WHERE id IN (SELECT id FROM trace_spans ORDER BY updated_at DESC, id DESC LIMIT -1 OFFSET ?)").run(ig),r.exec("COMMIT")}finally{r.close()}}async function hl(n,e){let t=uo.getStore(),r=t?.binding.workflow===n.workflow?t:void 0;if(r)try{let u=(await Promise.all([n.projectRoot(),r.projectRoot()])).map(p=>{let g=lo.resolve(p);return process.platform==="win32"?g.toLowerCase():g});(u[0]!==u[1]||n.runId&&r.binding.runId&&n.runId!==r.binding.runId)&&(r=void 0)}catch{r=void 0}let i=new Date().toISOString(),o={traceId:r?.traceId??ml(),spanId:ml(),binding:r?.binding??{workflow:n.workflow,change:n.change,runId:n.runId},spans:r?.spans??[],startedAt:i,kind:n.kind,name:n.name,projectRoot:n.projectRoot,parent:r};if(o.binding.change&&o.binding.runId){let f=[];for(let u=o;u;u=u.parent)f.push({traceId:u.traceId,spanId:u.spanId,parentSpanId:u.parent?.spanId??null,workflow:o.binding.workflow,change:o.binding.change,runId:o.binding.runId,kind:u.kind,name:u.name,status:"running",startedAt:u.startedAt,endedAt:null,updatedAt:i,revision:0});try{await pl(await n.projectRoot(),f)}catch{}}let s,a,c=!1;try{s=await uo.run(o,e)}catch(f){c=!0,a=f}let l=new Date().toISOString(),m=c?"failed":"succeeded";try{!c&&n.status&&(m=n.status(s))}catch{m="unknown"}if(o.binding.change&&o.binding.runId&&o.spans.push({traceId:o.traceId,spanId:o.spanId,parentSpanId:r?.spanId??null,workflow:o.binding.workflow,change:o.binding.change,runId:o.binding.runId,kind:n.kind,name:n.name,startedAt:i,endedAt:l,updatedAt:l,revision:1,status:m}),!r&&o.spans.length)try{await pl(await n.projectRoot(),o.spans)}catch{}if(c)throw a;return s}var sg=7*864e5,ag=1e4;async function cg(n,e){let t=ir(await sr(n,!0));try{t.exec(`PRAGMA busy_timeout=25; PRAGMA journal_mode=WAL;
|
|
174
|
+
CREATE TABLE IF NOT EXISTS samples (
|
|
175
|
+
id TEXT PRIMARY KEY, workflow TEXT NOT NULL, kind TEXT NOT NULL, command TEXT NOT NULL,
|
|
176
|
+
occurredAt TEXT NOT NULL, durationMs REAL NOT NULL, exitCode INTEGER NOT NULL,
|
|
177
|
+
gitCommands INTEGER NOT NULL, gitDurationMs REAL NOT NULL);
|
|
178
|
+
CREATE INDEX IF NOT EXISTS samples_time ON samples(occurredAt);
|
|
179
|
+
BEGIN IMMEDIATE;`),t.prepare("DELETE FROM samples WHERE occurredAt < ?").run(new Date(Date.now()-sg).toISOString()),t.prepare("INSERT INTO samples VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)").run(og(),e.workflow,e.kind,e.command,e.occurredAt,e.durationMs,e.exitCode,e.gitCommands,e.gitDurationMs),t.prepare("DELETE FROM samples WHERE id IN (SELECT id FROM samples ORDER BY occurredAt DESC, rowid DESC LIMIT -1 OFFSET ?)").run(ag),t.exec("COMMIT")}finally{t.close()}}async function wl(n,e){let t=gl.now(),r,i,o=!1,s=1,a=!0,{metrics:c}=await hl({projectRoot:n.projectRoot,workflow:n.workflow,kind:n.kind??"command",name:n.traceName??n.command,status:()=>{try{s=r?n.exitCode?.(r)??r.exitCode??1:n.errorExitCode?.(i)??1}catch{return a=!1,"unknown"}return s===0?"succeeded":"failed"}},()=>fl(async()=>{try{r=await e()}catch(m){o=!0,i=m}})),l=Math.max(0,gl.now()-t);try{if(!a)throw new Error("Runtime result classification unavailable");await cg(await n.projectRoot(),{workflow:n.workflow,kind:n.kind??"command",command:n.command,occurredAt:new Date().toISOString(),durationMs:l,exitCode:s,...c})}catch{}if(o)throw i;return r}function lg(n,e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:n,exitCode:e.exitCode,agent:ol(e.data),...e.data===void 0?{}:{data:e.data},...e.envelope===void 0?{}:{summary:e.envelope.summary,...e.envelope.next===void 0?{}:{next:e.envelope.next},...e.envelope.user_message===void 0?{}:{user_message:e.envelope.user_message}},...e.stdout===void 0?{}:{stdout:e.stdout},...e.stderr===void 0?{}:{stderr:e.stderr}})+`
|
|
180
|
+
`,...e.envelope===void 0?{}:{envelope:e.envelope}}}async function ug(n,e,t,r={}){let i=t.indexOf("--"),o=l=>i<0||l<i,s=t.some((l,m)=>o(m)&&l==="--json"),a=t.filter((l,m)=>!o(m)||l!=="--json"),c;try{let l=il(n,a),m=()=>e(a,{json:s,invocationCwd:r.invocationCwd??process.cwd(),...r.projectRoot?{projectRoot:r.projectRoot}:{}});c=l?{exitCode:0,stdout:l}:n==="hook-guard"?await m():await ul(()=>wl({projectRoot:()=>r.projectRoot??je(r.invocationCwd??process.cwd()),workflow:"classic",command:n,errorExitCode:f=>f instanceof Ie?1:70},m))}catch(l){c={exitCode:l instanceof Ie?1:70,stderr:l instanceof Error?l.message:String(l),data:{issues:[sl(l)]}}}return s?lg(n,c):c}async function yl(n,e,t=process.argv.slice(2)){let r=await ug(n,e,t);return r.stdout&&process.stdout.write(r.stdout),r.stderr&&process.stderr.write(r.stderr+(r.stderr.endsWith(`
|
|
181
|
+
`)?"":`
|
|
182
|
+
`)),r.exitCode}process.exitCode=await yl("validate",tl);
|