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,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __cometCreateRequire } from 'module';
|
|
3
|
+
const require = __cometCreateRequire(import.meta.url);
|
|
4
|
+
var pl=Object.create;var so=Object.defineProperty;var hl=Object.getOwnPropertyDescriptor;var gl=Object.getOwnPropertyNames;var wl=Object.getPrototypeOf,yl=Object.prototype.hasOwnProperty;var Lt=(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 vl=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of gl(e))!yl.call(n,i)&&i!==t&&so(n,i,{get:()=>e[i],enumerable:!(r=hl(e,i))||r.enumerable});return n};var er=(n,e,t)=>(t=n!=null?pl(wl(n)):{},vl(e||!n||!n.__esModule?so(t,"default",{value:n,enumerable:!0}):t,n));var _=y(D=>{"use strict";var tr=Symbol.for("yaml.alias"),co=Symbol.for("yaml.document"),Dt=Symbol.for("yaml.map"),lo=Symbol.for("yaml.pair"),nr=Symbol.for("yaml.scalar"),qt=Symbol.for("yaml.seq"),Z=Symbol.for("yaml.node.type"),Sl=n=>!!n&&typeof n=="object"&&n[Z]===tr,Cl=n=>!!n&&typeof n=="object"&&n[Z]===co,El=n=>!!n&&typeof n=="object"&&n[Z]===Dt,_l=n=>!!n&&typeof n=="object"&&n[Z]===lo,uo=n=>!!n&&typeof n=="object"&&n[Z]===nr,xl=n=>!!n&&typeof n=="object"&&n[Z]===qt;function fo(n){if(n&&typeof n=="object")switch(n[Z]){case Dt:case qt:return!0}return!1}function Pl(n){if(n&&typeof n=="object")switch(n[Z]){case tr:case Dt:case nr:case qt:return!0}return!1}var Rl=n=>(uo(n)||fo(n))&&!!n.anchor;D.ALIAS=tr;D.DOC=co;D.MAP=Dt;D.NODE_TYPE=Z;D.PAIR=lo;D.SCALAR=nr;D.SEQ=qt;D.hasAnchor=Rl;D.isAlias=Sl;D.isCollection=fo;D.isDocument=Cl;D.isMap=El;D.isNode=Pl;D.isPair=_l;D.isScalar=uo;D.isSeq=xl});var Ve=y(rr=>{"use strict";var j=_(),$=Symbol("break visit"),mo=Symbol("skip children"),X=Symbol("remove node");function Mt(n,e){let t=po(e);j.isDocument(n)?je(null,n.contents,t,Object.freeze([n]))===X&&(n.contents=null):je(null,n,t,Object.freeze([]))}Mt.BREAK=$;Mt.SKIP=mo;Mt.REMOVE=X;function je(n,e,t,r){let i=ho(n,e,t,r);if(j.isNode(i)||j.isPair(i))return go(n,r,i),je(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=je(o,e.items[o],t,r);if(typeof s=="number")o=s-1;else{if(s===$)return $;s===X&&(e.items.splice(o,1),o-=1)}}}else if(j.isPair(e)){r=Object.freeze(r.concat(e));let o=je("key",e.key,t,r);if(o===$)return $;o===X&&(e.key=null);let s=je("value",e.value,t,r);if(s===$)return $;s===X&&(e.value=null)}}return i}async function Wt(n,e){let t=po(e);j.isDocument(n)?await Le(null,n.contents,t,Object.freeze([n]))===X&&(n.contents=null):await Le(null,n,t,Object.freeze([]))}Wt.BREAK=$;Wt.SKIP=mo;Wt.REMOVE=X;async function Le(n,e,t,r){let i=await ho(n,e,t,r);if(j.isNode(i)||j.isPair(i))return go(n,r,i),Le(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 Le(o,e.items[o],t,r);if(typeof s=="number")o=s-1;else{if(s===$)return $;s===X&&(e.items.splice(o,1),o-=1)}}}else if(j.isPair(e)){r=Object.freeze(r.concat(e));let o=await Le("key",e.key,t,r);if(o===$)return $;o===X&&(e.key=null);let s=await Le("value",e.value,t,r);if(s===$)return $;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 ho(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 go(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`)}}rr.visit=Mt;rr.visitAsync=Wt});var ir=y(yo=>{"use strict";var wo=_(),Nl=Ve(),Al={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Tl=n=>n.replace(/[!,[\]{}]/g,e=>Al[e]),Ge=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+Tl(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&&wo.isNode(e.contents)){let o={};Nl.visit(e.contents,(s,a)=>{wo.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
|
+
`)}};Ge.defaultYaml={explicit:!1,version:"1.2"};Ge.defaultTags={"!!":"tag:yaml.org,2002:"};yo.Directives=Ge});var $t=y(ze=>{"use strict";var vo=_(),Ol=Ve();function Il(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 bo(n){let e=new Set;return Ol.visit(n,{Value(t,r){r.anchor&&e.add(r.anchor)}}),e}function ko(n,e){for(let t=1;;++t){let r=`${n}${t}`;if(!e.has(r))return r}}function jl(n,e){let t=[],r=new Map,i=null;return{onAnchor:o=>{t.push(o),i??(i=bo(n));let s=ko(e,i);return i.add(s),s},setAnchors:()=>{for(let o of t){let s=r.get(o);if(typeof s=="object"&&s.anchor&&(vo.isScalar(s.node)||vo.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}}ze.anchorIsValid=Il;ze.anchorNames=bo;ze.createNodeAnchors=jl;ze.findNewAnchor=ko});var or=y(So=>{"use strict";function Xe(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=Xe(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=Xe(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=Xe(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=Xe(n,r,i,o);s===void 0?delete r[i]:s!==o&&(r[i]=s)}return n.call(e,t,r)}So.applyReviver=Xe});var re=y(Eo=>{"use strict";var Ll=_();function Co(n,e,t){if(Array.isArray(n))return n.map((r,i)=>Co(r,String(i),t));if(n&&typeof n.toJSON=="function"){if(!t||!Ll.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}Eo.toJS=Co});var Ft=y(xo=>{"use strict";var Dl=or(),_o=_(),ql=re(),sr=class{constructor(e){Object.defineProperty(this,_o.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(!_o.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=ql.toJS(this,"",s);if(typeof i=="function")for(let{count:c,res:l}of s.anchors.values())i(l,c);return typeof o=="function"?Dl.applyReviver(o,{"":a},"",a):a}};xo.NodeBase=sr});var Qe=y(Po=>{"use strict";var Ml=$t(),Wl=Ve(),De=_(),$l=Ft(),Fl=re(),ar=class extends $l.NodeBase{constructor(e){super(De.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=[],Wl.visit(e,{Node:(o,s)=>{(De.isAlias(s)||De.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||(Fl.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=Bt(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(Ml.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 Bt(n,e,t){if(De.isAlias(e)){let r=e.resolve(n),i=t&&r&&t.get(r);return i?i.count*i.aliasCount:0}else if(De.isCollection(e)){let r=0;for(let i of e.items){let o=Bt(n,i,t);o>r&&(r=o)}return r}else if(De.isPair(e)){let r=Bt(n,e.key,t),i=Bt(n,e.value,t);return Math.max(r,i)}return 1}Po.Alias=ar});var A=y(cr=>{"use strict";var Bl=_(),Kl=Ft(),Ul=re(),Hl=n=>!n||typeof n!="function"&&typeof n!="object",ie=class extends Kl.NodeBase{constructor(e){super(Bl.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:Ul.toJS(this.value,e,t)}toString(){return String(this.value)}};ie.BLOCK_FOLDED="BLOCK_FOLDED";ie.BLOCK_LITERAL="BLOCK_LITERAL";ie.PLAIN="PLAIN";ie.QUOTE_DOUBLE="QUOTE_DOUBLE";ie.QUOTE_SINGLE="QUOTE_SINGLE";cr.Scalar=ie;cr.isScalarValue=Hl});var Ze=y(No=>{"use strict";var Yl=Qe(),be=_(),Ro=A(),Jl="tag:yaml.org,2002:";function Vl(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 Gl(n,e,t){if(be.isDocument(n)&&(n=n.contents),be.isNode(n))return n;if(be.isPair(n)){let f=t.schema[be.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 Yl.Alias(c.anchor);c={anchor:null,node:null},a.set(n,c)}e?.startsWith("!!")&&(e=Jl+e.slice(2));let l=Vl(n,e,s.tags);if(!l){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let f=new Ro.Scalar(n);return c&&(c.node=f),f}l=n instanceof Map?s[be.MAP]:Symbol.iterator in Object(n)?s[be.SEQ]:s[be.MAP]}o&&(o(l),delete t.onTagObj);let d=l?.createNode?l.createNode(t.schema,n,t):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(t.schema,n,t):new Ro.Scalar(n);return e?d.tag=e:l.default||(d.tag=l.tag),c&&(c.node=d),d}No.createNode=Gl});var Ut=y(Kt=>{"use strict";var zl=Ze(),Q=_(),Xl=Ft();function lr(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 zl.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 Ao=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,ur=class extends Xl.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(Ao(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,lr(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,lr(this.schema,i,t));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};Kt.Collection=ur;Kt.collectionFromPath=lr;Kt.isEmptyPath=Ao});var et=y(Ht=>{"use strict";var Ql=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function fr(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var Zl=(n,e,t)=>n.endsWith(`
|
|
6
|
+
`)?fr(t,e):t.includes(`
|
|
7
|
+
`)?`
|
|
8
|
+
`+fr(t,e):(n.endsWith(" ")?"":" ")+t;Ht.indentComment=fr;Ht.lineComment=Zl;Ht.stringifyComment=Ql});var Oo=y(tt=>{"use strict";var eu="flow",dr="block",Yt="quoted";function tu(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=[],d={},f=i-e.length;typeof r=="number"&&(r>i-Math.max(2,o)?l.push(0):f=i-r);let u,p,g=!1,m=-1,h=-1,w=-1;t===dr&&(m=To(n,m,e.length),m!==-1&&(f=m+c));for(let k;k=n[m+=1];){if(t===Yt&&k==="\\"){switch(h=m,n[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}w=m}if(k===`
|
|
9
|
+
`)t===dr&&(m=To(n,m,e.length)),f=m+e.length+c,u=void 0;else{if(k===" "&&p&&p!==" "&&p!==`
|
|
10
|
+
`&&p!==" "){let S=n[m+1];S&&S!==" "&&S!==`
|
|
11
|
+
`&&S!==" "&&(u=m)}if(m>=f)if(u)l.push(u),f=u+c,u=void 0;else if(t===Yt){for(;p===" "||p===" ";)p=k,k=n[m+=1],g=!0;let S=m>w+1?m-2:h-1;if(d[S])return n;l.push(S),d[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===Yt&&d[S]&&(v+=`${n[S]}\\`),v+=`
|
|
13
|
+
${e}${n.slice(S+1,E)}`)}return v}function To(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}tt.FOLD_BLOCK=dr;tt.FOLD_FLOW=eu;tt.FOLD_QUOTED=Yt;tt.foldFlowLines=tu});var rt=y(Io=>{"use strict";var V=A(),oe=Oo(),Vt=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),Gt=n=>/^(%|---|\.\.\.)/m.test(n);function nu(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 nt(n,e){let t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:r}=e,i=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Gt(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 d=t.substr(c+2,4);switch(d){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:d.substr(0,2)==="00"?s+="\\x"+d.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:oe.foldFlowLines(s,o,oe.FOLD_QUOTED,Vt(e,!1))}function mr(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
|
|
19
|
+
`)||/[ \t]\n|\n[ \t]/.test(n))return nt(n,e);let t=e.indent||(Gt(n)?" ":""),r="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
20
|
+
${t}`)+"'";return e.implicitKey?r:oe.foldFlowLines(r,t,oe.FOLD_FLOW,Vt(e,!1))}function qe(n,e){let{singleQuote:t}=e.options,r;if(t===!1)r=nt;else{let i=n.includes('"'),o=n.includes("'");i&&!o?r=mr:o&&!i?r=nt:r=t?mr:nt}return r(n,e)}var pr;try{pr=new RegExp(`(^|(?<!
|
|
21
|
+
))
|
|
22
|
+
+(?!
|
|
23
|
+
|$)`,"g")}catch{pr=/\n+(?!\n|$)/g}function Jt({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 qe(t,r);let l=r.indent||(r.forceBlockIndent||Gt(t)?" ":""),d=s==="literal"?!0:s==="folded"||e===V.Scalar.BLOCK_FOLDED?!1:e===V.Scalar.BLOCK_LITERAL?!0:!nu(t,c,l.length);if(!t)return d?`|
|
|
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(pr,`$&${l}`));let m=!1,h,w=-1;for(h=0;h<t.length;++h){let E=t[h];if(E===" ")m=!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=(m?l?"2":"1":"")+f;if(n&&(S+=" "+a(n.replace(/ ?[\r\n]+/g," ")),i&&i()),!d){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=Vt(r,!0);s!=="folded"&&e!==V.Scalar.BLOCK_FOLDED&&(N.onOverflow=()=>{C=!0});let b=oe.foldFlowLines(`${v}${E}${p}`,l,oe.FOLD_BLOCK,N);if(!C)return`>${S}
|
|
31
|
+
${l}${b}`}return t=t.replace(/\n+/g,`$&${l}`),`|${S}
|
|
32
|
+
${l}${v}${t}${p}`}function ru(n,e,t,r){let{type:i,value:o}=n,{actualString:s,implicitKey:a,indent:c,indentStep:l,inFlow:d}=e;if(a&&o.includes(`
|
|
33
|
+
`)||d&&/[[\]{},]/.test(o))return qe(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||d||!o.includes(`
|
|
34
|
+
`)?qe(o,e):Jt(n,e,t,r);if(!a&&!d&&i!==V.Scalar.PLAIN&&o.includes(`
|
|
35
|
+
`))return Jt(n,e,t,r);if(Gt(o)){if(c==="")return e.forceBlockIndent=!0,Jt(n,e,t,r);if(a&&c===l)return qe(o,e)}let f=o.replace(/\n+/g,`$&
|
|
36
|
+
${c}`);if(s){let u=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(f),{compat:p,tags:g}=e.doc.schema;if(g.some(u)||p?.some(u))return qe(o,e)}return a?f:oe.foldFlowLines(f,c,oe.FOLD_FLOW,Vt(e,!1))}function iu(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!==V.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value)&&(a=V.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case V.Scalar.BLOCK_FOLDED:case V.Scalar.BLOCK_LITERAL:return i||o?qe(s.value,e):Jt(s,e,t,r);case V.Scalar.QUOTE_DOUBLE:return nt(s.value,e);case V.Scalar.QUOTE_SINGLE:return mr(s.value,e);case V.Scalar.PLAIN:return ru(s,e,t,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:d,defaultStringType:f}=e.options,u=i&&d||f;if(l=c(u),l===null)throw new Error(`Unsupported default string type ${u}`)}return l}Io.stringifyString=iu});var it=y(hr=>{"use strict";var ou=$t(),se=_(),su=et(),au=rt();function cu(n,e){let t=Object.assign({blockQuote:!0,commentString:su.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 lu(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(se.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 uu(n,e,{anchors:t,doc:r}){if(!r.directives)return"";let i=[],o=(se.isScalar(n)||se.isCollection(n))&&n.anchor;o&&ou.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 fu(n,e,t,r){if(se.isPair(n))return n.toString(e,t,r);if(se.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=se.isNode(n)?n:e.doc.createNode(n,{onTagObj:c=>i=c});i??(i=lu(e.doc.schema.tags,o));let s=uu(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):se.isScalar(o)?au.stringifyString(o,e,t,r):o.toString(e,t,r);return s?se.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
|
|
37
|
+
${e.indent}${a}`:a}hr.createStringifyContext=cu;hr.stringify=fu});var qo=y(Do=>{"use strict";var ee=_(),jo=A(),Lo=it(),ot=et();function du({key:n,value:e},t,r,i){let{allNullValues:o,doc:s,indent:a,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:f}}=t,u=ee.isNode(n)&&n.comment||null;if(f){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(ee.isCollection(n)||!ee.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||ee.isCollection(n)||(ee.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,m=!1,h=Lo.stringify(n,t,()=>g=!0,()=>m=!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+=ot.lineComment(h,t.indent,l(u)):m&&i&&i(),h;g&&(u=null),p?(u&&(h+=ot.lineComment(h,t.indent,l(u))),h=`? ${h}
|
|
38
|
+
${a}:`):(h=`${h}:`,u&&(h+=ot.lineComment(h,t.indent,l(u))));let w,v,k;ee.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&&ee.isScalar(e)&&(t.indentAtStart=h.length+1),m=!1,!d&&c.length>=2&&!t.inFlow&&!p&&ee.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let S=!1,E=Lo.stringify(e,t,()=>S=!0,()=>m=!0),C=" ";if(u||w||v){if(C=w?`
|
|
39
|
+
`:"",v){let N=l(v);C+=`
|
|
40
|
+
${ot.indentComment(N,t.indent)}`}E===""&&!t.inFlow?C===`
|
|
41
|
+
`&&k&&(C=`
|
|
42
|
+
|
|
43
|
+
`):C+=`
|
|
44
|
+
${t.indent}`}else if(!p&&ee.isCollection(e)){let N=E[0],b=E.indexOf(`
|
|
45
|
+
`),O=b!==-1,ne=t.inFlow??e.flow??e.items.length===0;if(O||!ne){let Ie=!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)&&(Ie=!0)}Ie||(C=`
|
|
46
|
+
${t.indent}`)}}else(E===""||E[0]===`
|
|
47
|
+
`)&&(C="");return h+=C+E,t.inFlow?S&&r&&r():k&&!S?h+=ot.lineComment(h,t.indent,l(k)):m&&i&&i(),h}Do.stringifyPair=du});var wr=y(gr=>{"use strict";var Mo=Lt("process");function mu(n,...e){n==="debug"&&console.log(...e)}function pu(n,e){(n==="debug"||n==="warn")&&(typeof Mo.emitWarning=="function"?Mo.emitWarning(e):console.warn(e))}gr.debug=mu;gr.warn=pu});var en=y(Zt=>{"use strict";var Qt=_(),Wo=A(),zt="<<",Xt={identify:n=>n===zt||typeof n=="symbol"&&n.description===zt,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Wo.Scalar(Symbol(zt)),{addToJSMap:$o}),stringify:()=>zt},hu=(n,e)=>(Xt.identify(e)||Qt.isScalar(e)&&(!e.type||e.type===Wo.Scalar.PLAIN)&&Xt.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===Xt.tag&&t.default);function $o(n,e,t){let r=Fo(n,t);if(Qt.isSeq(r))for(let i of r.items)yr(n,e,i);else if(Array.isArray(r))for(let i of r)yr(n,e,i);else yr(n,e,r)}function yr(n,e,t){let r=Fo(n,t);if(!Qt.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 Fo(n,e){return n&&Qt.isAlias(e)?e.resolve(n.doc,n):e}Zt.addMergeToJSMap=$o;Zt.isMergeKey=hu;Zt.merge=Xt});var br=y(Uo=>{"use strict";var gu=wr(),Bo=en(),wu=it(),Ko=_(),vr=re();function yu(n,e,{key:t,value:r}){if(Ko.isNode(t)&&t.addToJSMap)t.addToJSMap(n,e,r);else if(Bo.isMergeKey(n,t))Bo.addMergeToJSMap(n,e,r);else{let i=vr.toJS(t,"",n);if(e instanceof Map)e.set(i,vr.toJS(r,i,n));else if(e instanceof Set)e.add(i);else{let o=vu(t,i,n),s=vr.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 vu(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(Ko.isNode(n)&&t?.doc){let r=wu.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)+'..."'),gu.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)}Uo.addPairToJSMap=yu});var ae=y(kr=>{"use strict";var Ho=Ze(),bu=qo(),ku=br(),tn=_();function Su(n,e,t){let r=Ho.createNode(n,void 0,t),i=Ho.createNode(e,void 0,t);return new nn(r,i)}var nn=class n{constructor(e,t=null){Object.defineProperty(this,tn.NODE_TYPE,{value:tn.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return tn.isNode(t)&&(t=t.clone(e)),tn.isNode(r)&&(r=r.clone(e)),new n(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return ku.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?bu.stringifyPair(this,e,t,r):JSON.stringify(this)}};kr.Pair=nn;kr.createPair=Su});var Sr=y(Jo=>{"use strict";var ke=_(),Yo=it(),rn=et();function Cu(n,e,t){return(e.inFlow??n.flow?_u:Eu)(n,e,t)}function Eu({comment:n,items:e},t,{blockItemPrefix:r,flowChars:i,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:l}}=t,d=Object.assign({},t,{indent:o,type:null}),f=!1,u=[];for(let g=0;g<e.length;++g){let m=e[g],h=null;if(ke.isNode(m))!f&&m.spaceBefore&&u.push(""),on(t,u,m.commentBefore,f),m.comment&&(h=m.comment);else if(ke.isPair(m)){let v=ke.isNode(m.key)?m.key:null;v&&(!f&&v.spaceBefore&&u.push(""),on(t,u,v.commentBefore,f))}f=!1;let w=Yo.stringify(m,d,()=>h=null,()=>f=!0);h&&(w+=rn.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 m=u[g];p+=m?`
|
|
48
|
+
${c}${m}`:`
|
|
49
|
+
`}}return n?(p+=`
|
|
50
|
+
`+rn.indentComment(l(n),c),a&&a()):f&&s&&s(),p}function _u({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,d=0,f=[];for(let g=0;g<n.length;++g){let m=n[g],h=null;if(ke.isNode(m))m.spaceBefore&&f.push(""),on(e,f,m.commentBefore,!1),m.comment&&(h=m.comment);else if(ke.isPair(m)){let v=ke.isNode(m.key)?m.key:null;v&&(v.spaceBefore&&f.push(""),on(e,f,v.commentBefore,!1),v.comment&&(l=!0));let k=ke.isNode(m.value)?m.value:null;k?(k.comment&&(h=k.comment),k.commentBefore&&(l=!0)):m.value==null&&v?.comment&&(h=v.comment)}h&&(l=!0);let w=Yo.stringify(m,c,()=>h=null);l||(l=f.length>d||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+=rn.lineComment(w,r,a(h))),f.push(w),d=f.length}let{start:u,end:p}=t;if(f.length===0)return u+p;if(!l){let g=f.reduce((m,h)=>m+h.length+2,2);l=e.options.lineWidth>0&&g>e.options.lineWidth}if(l){let g=u;for(let m of f)g+=m?`
|
|
52
|
+
${o}${i}${m}`:`
|
|
53
|
+
`;return`${g}
|
|
54
|
+
${i}${p}`}else return`${u}${s}${f.join(" ")}${s}${p}`}function on({indent:n,options:{commentString:e}},t,r,i){if(r&&i&&(r=r.replace(/^\n+/,"")),r){let o=rn.indentComment(e(r),n);t.push(o.trimStart())}}Jo.stringifyCollection=Cu});var le=y(Er=>{"use strict";var xu=Sr(),Pu=br(),Ru=Ut(),ce=_(),sn=ae(),Nu=A();function st(n,e){let t=ce.isScalar(e)?e.value:e;for(let r of n)if(ce.isPair(r)&&(r.key===e||r.key===t||ce.isScalar(r.key)&&r.key.value===t))return r}var Cr=class extends Ru.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(ce.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(sn.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;ce.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new sn.Pair(e,e?.value):r=new sn.Pair(e.key,e.value);let i=st(this.items,r.key),o=this.schema?.sortMapEntries;if(i){if(!t)throw new Error(`Key ${r.key} already set`);ce.isScalar(i.value)&&Nu.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=st(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let i=st(this.items,e)?.value;return(!t&&ce.isScalar(i)?i.value:i)??void 0}has(e){return!!st(this.items,e)}set(e,t){this.add(new sn.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)Pu.addPairToJSMap(t,i,o);return i}toString(e,t,r){if(!e)return JSON.stringify(this);for(let i of this.items)if(!ce.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})),xu.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}};Er.YAMLMap=Cr;Er.findPair=st});var Me=y(Go=>{"use strict";var Au=_(),Vo=le(),Tu={collection:"map",default:!0,nodeClass:Vo.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(n,e){return Au.isMap(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>Vo.YAMLMap.from(n,e,t)};Go.map=Tu});var ue=y(zo=>{"use strict";var Ou=Ze(),Iu=Sr(),ju=Ut(),cn=_(),Lu=A(),Du=re(),_r=class extends ju.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(cn.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=an(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let r=an(e);if(typeof r!="number")return;let i=this.items[r];return!t&&cn.isScalar(i)?i.value:i}has(e){let t=an(e);return typeof t=="number"&&t<this.items.length}set(e,t){let r=an(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let i=this.items[r];cn.isScalar(i)&&Lu.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(Du.toJS(o,String(i++),t));return r}toString(e,t,r){return e?Iu.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(Ou.createNode(a,void 0,r))}}return o}};function an(n){let e=cn.isScalar(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}zo.YAMLSeq=_r});var We=y(Qo=>{"use strict";var qu=_(),Xo=ue(),Mu={collection:"seq",default:!0,nodeClass:Xo.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(n,e){return qu.isSeq(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>Xo.YAMLSeq.from(n,e,t)};Qo.seq=Mu});var at=y(Zo=>{"use strict";var Wu=rt(),$u={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),Wu.stringifyString(n,e,t,r)}};Zo.string=$u});var ln=y(ns=>{"use strict";var es=A(),ts={identify:n=>n==null,createNode:()=>new es.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new es.Scalar(null),stringify:({source:n},e)=>typeof n=="string"&&ts.test.test(n)?n:e.options.nullStr};ns.nullTag=ts});var xr=y(is=>{"use strict";var Fu=A(),rs={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new Fu.Scalar(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&rs.test.test(n)){let r=n[0]==="t"||n[0]==="T";if(e===r)return n}return e?t.options.trueStr:t.options.falseStr}};is.boolTag=rs});var $e=y(os=>{"use strict";function Bu({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}os.stringifyNumber=Bu});var Rr=y(un=>{"use strict";var Ku=A(),Pr=$e(),Uu={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:Pr.stringifyNumber},Hu={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():Pr.stringifyNumber(n)}},Yu={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 Ku.Scalar(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:Pr.stringifyNumber};un.float=Yu;un.floatExp=Hu;un.floatNaN=Uu});var Ar=y(dn=>{"use strict";var ss=$e(),fn=n=>typeof n=="bigint"||Number.isInteger(n),Nr=(n,e,t,{intAsBigInt:r})=>r?BigInt(n):parseInt(n.substring(e),t);function as(n,e,t){let{value:r}=n;return fn(r)&&r>=0?t+r.toString(e):ss.stringifyNumber(n)}var Ju={identify:n=>fn(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Nr(n,2,8,t),stringify:n=>as(n,8,"0o")},Vu={identify:fn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Nr(n,0,10,t),stringify:ss.stringifyNumber},Gu={identify:n=>fn(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Nr(n,2,16,t),stringify:n=>as(n,16,"0x")};dn.int=Vu;dn.intHex=Gu;dn.intOct=Ju});var ls=y(cs=>{"use strict";var zu=Me(),Xu=ln(),Qu=We(),Zu=at(),ef=xr(),Tr=Rr(),Or=Ar(),tf=[zu.map,Qu.seq,Zu.string,Xu.nullTag,ef.boolTag,Or.intOct,Or.int,Or.intHex,Tr.floatNaN,Tr.floatExp,Tr.float];cs.schema=tf});var ds=y(fs=>{"use strict";var nf=A(),rf=Me(),of=We();function us(n){return typeof n=="bigint"||Number.isInteger(n)}var mn=({value:n})=>JSON.stringify(n),sf=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:mn},{identify:n=>n==null,createNode:()=>new nf.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:mn},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:mn},{identify:us,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})=>us(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:mn}],af={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},cf=[rf.map,of.seq].concat(sf,af);fs.schema=cf});var jr=y(ms=>{"use strict";var ct=Lt("buffer"),Ir=A(),lf=rt(),uf={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof ct.Buffer=="function")return ct.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 ct.Buffer=="function")a=s instanceof ct.Buffer?s.toString("base64"):ct.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=Ir.Scalar.BLOCK_LITERAL),e!==Ir.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(a.length/c),d=new Array(l);for(let f=0,u=0;f<l;++f,u+=c)d[f]=a.substr(u,c);a=d.join(e===Ir.Scalar.BLOCK_LITERAL?`
|
|
55
|
+
`:" ")}return lf.stringifyString({comment:n,type:e,value:a},r,i,o)}};ms.binary=uf});var gn=y(hn=>{"use strict";var pn=_(),Lr=ae(),ff=A(),df=ue();function ps(n,e){if(pn.isSeq(n))for(let t=0;t<n.items.length;++t){let r=n.items[t];if(!pn.isPair(r)){if(pn.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let i=r.items[0]||new Lr.Pair(new ff.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]=pn.isPair(r)?r:new Lr.Pair(r)}}else e("Expected a sequence for this tag");return n}function hs(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(Lr.createPair(a,c,t))}return i}var mf={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ps,createNode:hs};hn.createPairs=hs;hn.pairs=mf;hn.resolvePairs=ps});var Mr=y(qr=>{"use strict";var gs=_(),Dr=re(),lt=le(),pf=ue(),ws=gn(),Se=class n extends pf.YAMLSeq{constructor(){super(),this.add=lt.YAMLMap.prototype.add.bind(this),this.delete=lt.YAMLMap.prototype.delete.bind(this),this.get=lt.YAMLMap.prototype.get.bind(this),this.has=lt.YAMLMap.prototype.has.bind(this),this.set=lt.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(gs.isPair(i)?(o=Dr.toJS(i.key,"",t),s=Dr.toJS(i.value,o,t)):o=Dr.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=ws.createPairs(e,t,r),o=new this;return o.items=i.items,o}};Se.tag="tag:yaml.org,2002:omap";var hf={collection:"seq",identify:n=>n instanceof Map,nodeClass:Se,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=ws.resolvePairs(n,e),r=[];for(let{key:i}of t.items)gs.isScalar(i)&&(r.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):r.push(i.value));return Object.assign(new Se,t)},createNode:(n,e,t)=>Se.from(n,e,t)};qr.YAMLOMap=Se;qr.omap=hf});var Ss=y(Wr=>{"use strict";var ys=A();function vs({value:n,source:e},t){return e&&(n?bs:ks).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var bs={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 ys.Scalar(!0),stringify:vs},ks={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 ys.Scalar(!1),stringify:vs};Wr.falseTag=ks;Wr.trueTag=bs});var Cs=y(wn=>{"use strict";var gf=A(),$r=$e(),wf={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:$r.stringifyNumber},yf={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():$r.stringifyNumber(n)}},vf={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 gf.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:$r.stringifyNumber};wn.float=vf;wn.floatExp=yf;wn.floatNaN=wf});var _s=y(ft=>{"use strict";var Es=$e(),ut=n=>typeof n=="bigint"||Number.isInteger(n);function yn(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 Fr(n,e,t){let{value:r}=n;if(ut(r)){let i=r.toString(e);return r<0?"-"+t+i.substr(1):t+i}return Es.stringifyNumber(n)}var bf={identify:ut,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>yn(n,2,2,t),stringify:n=>Fr(n,2,"0b")},kf={identify:ut,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>yn(n,1,8,t),stringify:n=>Fr(n,8,"0")},Sf={identify:ut,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>yn(n,0,10,t),stringify:Es.stringifyNumber},Cf={identify:ut,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>yn(n,2,16,t),stringify:n=>Fr(n,16,"0x")};ft.int=Sf;ft.intBin=bf;ft.intHex=Cf;ft.intOct=kf});var Kr=y(Br=>{"use strict";var kn=_(),vn=ae(),bn=le(),Ce=class n extends bn.YAMLMap{constructor(e){super(e),this.tag=n.tag}add(e){let t;kn.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new vn.Pair(e.key,null):t=new vn.Pair(e,null),bn.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=bn.findPair(this.items,e);return!t&&kn.isPair(r)?kn.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=bn.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new vn.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(vn.createPair(s,null,r));return o}};Ce.tag="tag:yaml.org,2002:set";var Ef={collection:"map",identify:n=>n instanceof Set,nodeClass:Ce,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>Ce.from(n,e,t),resolve(n,e){if(kn.isMap(n)){if(n.hasAllNullValues(!0))return Object.assign(new Ce,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};Br.YAMLSet=Ce;Br.set=Ef});var Hr=y(Sn=>{"use strict";var _f=$e();function Ur(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 xs(n){let{value:e}=n,t=s=>s;if(typeof e=="bigint")t=s=>BigInt(s);else if(isNaN(e)||!isFinite(e))return _f.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 xf={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})=>Ur(n,t),stringify:xs},Pf={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=>Ur(n,!1),stringify:xs},Ps={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(Ps.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),d=e[8];if(d&&d!=="Z"){let f=Ur(d,!1);Math.abs(f)<30&&(f*=60),l-=6e4*f}return new Date(l)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Sn.floatTime=Pf;Sn.intTime=xf;Sn.timestamp=Ps});var As=y(Ns=>{"use strict";var Rf=Me(),Nf=ln(),Af=We(),Tf=at(),Of=jr(),Rs=Ss(),Yr=Cs(),Cn=_s(),If=en(),jf=Mr(),Lf=gn(),Df=Kr(),Jr=Hr(),qf=[Rf.map,Af.seq,Tf.string,Nf.nullTag,Rs.trueTag,Rs.falseTag,Cn.intBin,Cn.intOct,Cn.int,Cn.intHex,Yr.floatNaN,Yr.floatExp,Yr.float,Of.binary,If.merge,jf.omap,Lf.pairs,Df.set,Jr.intTime,Jr.floatTime,Jr.timestamp];Ns.schema=qf});var $s=y(zr=>{"use strict";var js=Me(),Mf=ln(),Ls=We(),Wf=at(),$f=xr(),Vr=Rr(),Gr=Ar(),Ff=ls(),Bf=ds(),Ds=jr(),dt=en(),qs=Mr(),Ms=gn(),Ts=As(),Ws=Kr(),En=Hr(),Os=new Map([["core",Ff.schema],["failsafe",[js.map,Ls.seq,Wf.string]],["json",Bf.schema],["yaml11",Ts.schema],["yaml-1.1",Ts.schema]]),Is={binary:Ds.binary,bool:$f.boolTag,float:Vr.float,floatExp:Vr.floatExp,floatNaN:Vr.floatNaN,floatTime:En.floatTime,int:Gr.int,intHex:Gr.intHex,intOct:Gr.intOct,intTime:En.intTime,map:js.map,merge:dt.merge,null:Mf.nullTag,omap:qs.omap,pairs:Ms.pairs,seq:Ls.seq,set:Ws.set,timestamp:En.timestamp},Kf={"tag:yaml.org,2002:binary":Ds.binary,"tag:yaml.org,2002:merge":dt.merge,"tag:yaml.org,2002:omap":qs.omap,"tag:yaml.org,2002:pairs":Ms.pairs,"tag:yaml.org,2002:set":Ws.set,"tag:yaml.org,2002:timestamp":En.timestamp};function Uf(n,e,t){let r=Os.get(e);if(r&&!n)return t&&!r.includes(dt.merge)?r.concat(dt.merge):r.slice();let i=r;if(!i)if(Array.isArray(n))i=[];else{let o=Array.from(Os.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(dt.merge)),i.reduce((o,s)=>{let a=typeof s=="string"?Is[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(Is).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}zr.coreKnownTags=Kf;zr.getTags=Uf});var Zr=y(Fs=>{"use strict";var Xr=_(),Hf=Me(),Yf=We(),Jf=at(),_n=$s(),Vf=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,Qr=class n{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:i,schema:o,sortMapEntries:s,toStringDefaults:a}){this.compat=Array.isArray(e)?_n.getTags(e,"compat"):e?_n.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=i?_n.coreKnownTags:{},this.tags=_n.getTags(t,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,Xr.MAP,{value:Hf.map}),Object.defineProperty(this,Xr.SCALAR,{value:Jf.string}),Object.defineProperty(this,Xr.SEQ,{value:Yf.seq}),this.sortMapEntries=typeof s=="function"?s:s===!0?Vf:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Fs.Schema=Qr});var Ks=y(Bs=>{"use strict";var Gf=_(),ei=it(),mt=et();function zf(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=ei.createStringifyContext(n,e),{commentString:o}=i.options;if(n.commentBefore){t.length!==1&&t.unshift("");let c=o(n.commentBefore);t.unshift(mt.indentComment(c,""))}let s=!1,a=null;if(n.contents){if(Gf.isNode(n.contents)){if(n.contents.spaceBefore&&r&&t.push(""),n.contents.commentBefore){let d=o(n.contents.commentBefore);t.push(mt.indentComment(d,""))}i.forceBlockIndent=!!n.comment,a=n.contents.comment}let c=a?void 0:()=>s=!0,l=ei.stringify(n.contents,i,()=>a=null,c);a&&(l+=mt.lineComment(l,"",o(a))),(l[0]==="|"||l[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${l}`:t.push(l)}else t.push(ei.stringify(n.contents,i));if(n.directives?.docEnd)if(n.comment){let c=o(n.comment);c.includes(`
|
|
58
|
+
`)?(t.push("..."),t.push(mt.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(mt.indentComment(o(c),"")))}return t.join(`
|
|
59
|
+
`)+`
|
|
60
|
+
`}Bs.stringifyDocument=zf});var pt=y(Us=>{"use strict";var Xf=Qe(),Fe=Ut(),H=_(),Qf=ae(),Zf=re(),ed=Zr(),td=Ks(),ti=$t(),nd=or(),rd=Ze(),ni=ir(),ri=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 ni.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){Be(this.contents)&&this.contents.add(e)}addIn(e,t){Be(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=ti.anchorNames(this);e.anchor=!t||r.has(t)?ti.findNewAnchor(t||"a",r):t}return new Xf.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:d}=r??{},{onAnchor:f,setAnchors:u,sourceObjects:p}=ti.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:o??!0,keepUndefined:c??!1,onAnchor:f,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:p},m=rd.createNode(e,d,g);return a&&H.isCollection(m)&&(m.flow=!0),u(),m}createPair(e,t,r={}){let i=this.createNode(e,null,r),o=this.createNode(t,null,r);return new Qf.Pair(i,o)}delete(e){return Be(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Fe.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Be(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 Fe.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 Fe.isEmptyPath(e)?this.contents!==void 0:H.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Fe.collectionFromPath(this.schema,[e],t):Be(this.contents)&&this.contents.set(e,t)}setIn(e,t){Fe.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=Fe.collectionFromPath(this.schema,Array.from(e),t):Be(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 ni.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 ni.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=Zf.toJS(this.contents,t??"",a);if(typeof o=="function")for(let{count:l,res:d}of a.anchors.values())o(d,l);return typeof s=="function"?nd.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 td.stringifyDocument(this,e)}};function Be(n){if(H.isCollection(n))return!0;throw new Error("Expected a YAML collection as document contents")}Us.Document=ri});var wt=y(gt=>{"use strict";var ht=class extends Error{constructor(e,t,r,i){super(),this.name=e,this.code=r,this.message=i,this.pos=t}},ii=class extends ht{constructor(e,t,r){super("YAMLParseError",e,t,r)}},oi=class extends ht{constructor(e,t,r){super("YAMLWarning",e,t,r)}},id=(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
|
+
`}};gt.YAMLError=ht;gt.YAMLParseError=ii;gt.YAMLWarning=oi;gt.prettifyError=id});var yt=y(Hs=>{"use strict";function od(n,{flow:e,indicator:t,next:r,offset:i,onError:o,parentIndent:s,startOnNewline:a}){let c=!1,l=a,d=a,f="",u="",p=!1,g=!1,m=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),m&&(l&&b.type!=="comment"&&b.type!=="newline"&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),b.type){case"space":!e&&(t!=="doc-start"||r?.type!=="flow-collection")&&b.source.includes(" ")&&(m=b),d=!0;break;case"comment":{d||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),d=!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,d=!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,d=!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",d=!1;break;case"comma":if(e){k&&o(b,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=b,l=!1,d=!1;break}default:o(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,d=!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"),m&&(l&&m.indent<=s||r?.type==="block-map"||r?.type==="block-seq")&&o(m,"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}}Hs.resolveProps=od});var xn=y(Ys=>{"use strict";function si(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(si(e.key)||si(e.value))return!0}return!1;default:return!0}}Ys.containsNewline=si});var ai=y(Js=>{"use strict";var sd=xn();function ad(n,e,t){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===n&&(r.source==="]"||r.source==="}")&&sd.containsNewline(e)&&t(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Js.flowIndentCheck=ad});var ci=y(Gs=>{"use strict";var Vs=_();function cd(n,e,t){let{uniqueKeys:r}=n.options;if(r===!1)return!1;let i=typeof r=="function"?r:(o,s)=>o===s||Vs.isScalar(o)&&Vs.isScalar(s)&&o.value===s.value;return e.some(o=>i(o.key,t))}Gs.mapIncludes=cd});var ta=y(ea=>{"use strict";var zs=ae(),ld=le(),Xs=yt(),ud=xn(),Qs=ai(),fd=ci(),Zs="All mapping items must start at the same column";function dd({composeNode:n,composeEmptyNode:e},t,r,i,o){let s=o?.nodeClass??ld.YAMLMap,a=new s(t.schema);t.atRoot&&(t.atRoot=!1);let c=r.offset,l=null;for(let d of r.items){let{start:f,key:u,sep:p,value:g}=d,m=Xs.resolveProps(f,{indicator:"explicit-key-ind",next:u??p?.[0],offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0}),h=!m.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",Zs)),!m.anchor&&!m.tag&&!p){l=m.end,m.comment&&(a.comment?a.comment+=`
|
|
67
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||ud.containsNewline(u))&&i(u??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&i(c,"BAD_INDENT",Zs);t.atKey=!0;let w=m.end,v=u?n(t,u,m,i):e(t,w,f,null,m,i);t.schema.compat&&Qs.flowIndentCheck(r.indent,u,i),t.atKey=!1,fd.mapIncludes(t,a.items,v)&&i(w,"DUPLICATE_KEY","Map keys must be unique");let k=Xs.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&&m.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&&Qs.flowIndentCheck(r.indent,g,i),c=S.range[2];let E=new zs.Pair(v,S);t.options.keepSourceTokens&&(E.srcToken=d),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 zs.Pair(v);t.options.keepSourceTokens&&(S.srcToken=d),a.items.push(S)}}return l&&l<c&&i(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,l??c],a}ea.resolveBlockMap=dd});var ra=y(na=>{"use strict";var md=ue(),pd=yt(),hd=ai();function gd({composeNode:n,composeEmptyNode:e},t,r,i,o){let s=o?.nodeClass??md.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:d,value:f}of r.items){let u=pd.resolveProps(d,{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,d,null,u,i);t.schema.compat&&hd.flowIndentCheck(r.indent,f,i),c=p.range[2],a.items.push(p)}return a.range=[r.offset,c,l??c],a}na.resolveBlockSeq=gd});var Ke=y(ia=>{"use strict";function wd(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 d=c.substring(1)||" ";i?i+=s+d:i=d,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}}ia.resolveEnd=wd});var ca=y(aa=>{"use strict";var yd=_(),vd=ae(),oa=le(),bd=ue(),kd=Ke(),sa=yt(),Sd=xn(),Cd=ci(),li="Block collections are not allowed within flow collections",ui=n=>n&&(n.type==="block-map"||n.type==="block-seq");function Ed({composeNode:n,composeEmptyNode:e},t,r,i,o){let s=r.start.source==="{",a=s?"flow map":"flow sequence",c=o?.nodeClass??(s?oa.YAMLMap:bd.YAMLSeq),l=new c(t.schema);l.flow=!0;let d=t.atRoot;d&&(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=sa.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&&Sd.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];yd.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],ui(E)&&i(N.range,"BLOCK_IN_FLOW",li)}else{t.atKey=!0;let N=C.end,b=k?n(t,k,C,i):e(t,N,v,null,C,i);ui(k)&&i(b.range,"BLOCK_IN_FLOW",li),t.atKey=!1;let O=sa.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 ne=E?n(t,E,O,i):O.found?e(t,O.end,S,null,O,i):null;ne?ui(E)&&i(ne.range,"BLOCK_IN_FLOW",li):O.comment&&(b.comment?b.comment+=`
|
|
71
|
+
`+O.comment:b.comment=O.comment);let Ie=new vd.Pair(b,ne);if(t.options.keepSourceTokens&&(Ie.srcToken=w),s){let I=l;Cd.mapIncludes(t,I.items,b)&&i(N,"DUPLICATE_KEY","Map keys must be unique"),I.items.push(Ie)}else{let I=new oa.YAMLMap(t.schema);I.flow=!0,I.items.push(Ie);let oo=(ne??b).range;I.range=[b.range[0],oo[1],oo[2]],l.items.push(I)}f=ne?ne.range[2]:O.end}}let u=s?"}":"]",[p,...g]=r.end,m=f;if(p?.source===u)m=p.offset+p.source.length;else{let h=a[0].toUpperCase()+a.substring(1),w=d?`${h} must end with a ${u}`:`${h} in block collection must be sufficiently indented and end with a ${u}`;i(f,d?"MISSING_CHAR":"BAD_INDENT",w),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let h=kd.resolveEnd(g,m,t.options.strict,i);h.comment&&(l.comment?l.comment+=`
|
|
72
|
+
`+h.comment:l.comment=h.comment),l.range=[r.offset,m,h.offset]}else l.range=[r.offset,m,m];return l}aa.resolveFlowCollection=Ed});var ua=y(la=>{"use strict";var _d=_(),xd=A(),Pd=le(),Rd=ue(),Nd=ta(),Ad=ra(),Td=ca();function fi(n,e,t,r,i,o){let s=t.type==="block-map"?Nd.resolveBlockMap(n,e,t,r,o):t.type==="block-seq"?Ad.resolveBlockSeq(n,e,t,r,o):Td.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 Od(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===Pd.YAMLMap.tagName&&a==="map"||s===Rd.YAMLSeq.tagName&&a==="seq")return fi(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),fi(n,e,t,i,s)}let l=fi(n,e,t,i,s,c),d=c.resolve?.(l,u=>i(o,"TAG_RESOLVE_FAILED",u),e.options)??l,f=_d.isNode(d)?d:new xd.Scalar(d);return f.range=l.range,f.tag=s,c?.format&&(f.format=c.format),f}la.composeCollection=Od});var mi=y(fa=>{"use strict";var di=A();function Id(n,e,t){let r=e.offset,i=jd(e,n.options.strict,t);if(!i)return{value:"",type:null,comment:"",range:[r,r,r]};let o=i.mode===">"?di.Scalar.BLOCK_FOLDED:di.Scalar.BLOCK_LITERAL,s=e.source?Ld(e.source):[],a=s.length;for(let m=s.length-1;m>=0;--m){let h=s[m][1];if(h===""||h==="\r")a=m;else break}if(a===0){let m=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:m,type:o,comment:i.comment,range:[r,h,h]}}let c=e.indent+i.indent,l=e.offset+i.length,d=0;for(let m=0;m<a;++m){let[h,w]=s[m];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),d=m,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 m=s.length-1;m>=a;--m)s[m][0].length>c&&(a=m+1);let f="",u="",p=!1;for(let m=0;m<d;++m)f+=s[m][0].slice(c)+`
|
|
74
|
+
`;for(let m=d;m<a;++m){let[h,w]=s[m];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===di.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 m=a;m<s.length;++m)f+=`
|
|
84
|
+
`+s[m][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 jd({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,d="",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,d=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 m=p.source;m&&typeof m=="string"&&(f+=m.length)}}}return{mode:o,indent:s,chomp:a,comment:d,length:f}}function Ld(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}fa.resolveBlockScalar=Id});var hi=y(ma=>{"use strict";var pi=A(),Dd=Ke();function qd(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=pi.Scalar.PLAIN,c=Md(o,l);break;case"single-quoted-scalar":a=pi.Scalar.QUOTE_SINGLE,c=Wd(o,l);break;case"double-quoted-scalar":a=pi.Scalar.QUOTE_DOUBLE,c=$d(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 d=r+o.length,f=Dd.resolveEnd(s,d,e,t);return{value:c,type:a,comment:f.comment,range:[r,d,f.offset]}}function Md(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}`),da(n)}function Wd(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),da(n.slice(1,-1)).replace(/''/g,"'")}function da(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 $d(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}=Fd(n,r);t+=o,r=s}else if(i==="\\"){let o=n[++r],s=Bd[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+=Kd(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 Fd(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 Bd={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Kd(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}}ma.resolveFlowScalar=qd});var ga=y(ha=>{"use strict";var Ee=_(),pa=A(),Ud=mi(),Hd=hi();function Yd(n,e,t,r){let{value:i,type:o,comment:s,range:a}=e.type==="block-scalar"?Ud.resolveBlockScalar(n,e,r):Hd.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[Ee.SCALAR]:c?l=Jd(n.schema,i,c,t,r):e.type==="scalar"?l=Vd(n,i,e,r):l=n.schema[Ee.SCALAR];let d;try{let f=l.resolve(i,u=>r(t??e,"TAG_RESOLVE_FAILED",u),n.options);d=Ee.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),d=new pa.Scalar(i)}return d.range=a,d.source=i,o&&(d.type=o),c&&(d.tag=c),l.format&&(d.format=l.format),s&&(d.comment=s),d}function Jd(n,e,t,r,i){if(t==="!")return n[Ee.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[Ee.SCALAR])}function Vd({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[Ee.SCALAR];if(t.compat){let a=t.compat.find(c=>c.default&&c.test?.test(r))??t[Ee.SCALAR];if(s.tag!==a.tag){let c=e.tagString(s.tag),l=e.tagString(a.tag),d=`Value may be parsed as either ${c} or ${l}`;o(i,"TAG_RESOLVE_FAILED",d,!0)}}return s}ha.composeScalar=Yd});var ya=y(wa=>{"use strict";function Gd(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}wa.emptyScalarPosition=Gd});var ka=y(wi=>{"use strict";var zd=Qe(),Xd=_(),Qd=ua(),va=ga(),Zd=Ke(),em=ya(),tm={composeNode:ba,composeEmptyNode:gi};function ba(n,e,t,r){let i=n.atKey,{spaceBefore:o,comment:s,anchor:a,tag:c}=t,l,d=!0;switch(e.type){case"alias":l=nm(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=va.composeScalar(n,e,c,r),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Qd.composeCollection(tm,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),d=!1}}return l??(l=gi(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&&(!Xd.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&&d&&(l.srcToken=e),l}function gi(n,e,t,r,{spaceBefore:i,comment:o,anchor:s,tag:a,end:c},l){let d={type:"scalar",offset:em.emptyScalarPosition(e,t,r),indent:-1,source:""},f=va.composeScalar(n,d,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 nm({options:n},{offset:e,source:t,end:r},i){let o=new zd.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=Zd.resolveEnd(r,s,n.strict,i);return o.range=[e,s,a.offset],a.comment&&(o.comment=a.comment),o}wi.composeEmptyNode=gi;wi.composeNode=ba});var Ea=y(Ca=>{"use strict";var rm=pt(),Sa=ka(),im=Ke(),om=yt();function sm(n,e,{offset:t,start:r,value:i,end:o},s){let a=Object.assign({_directives:e},n),c=new rm.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=om.resolveProps(r,{indicator:"doc-start",next:i??o?.[0],offset:t,onError:s,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!d.hasNewline&&s(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=i?Sa.composeNode(l,i,d,s):Sa.composeEmptyNode(l,d.end,r,null,d,s);let f=c.contents.range[2],u=im.resolveEnd(o,f,!1,s);return u.comment&&(c.comment=u.comment),c.range=[t,f,u.offset],c}Ca.composeDoc=sm});var vi=y(Pa=>{"use strict";var am=Lt("process"),cm=ir(),lm=pt(),vt=wt(),_a=_(),um=Ea(),fm=Ke();function bt(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 xa(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 yi=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,i,o)=>{let s=bt(t);o?this.warnings.push(new vt.YAMLWarning(s,r,i)):this.errors.push(new vt.YAMLParseError(s,r,i))},this.directives=new cm.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:i}=xa(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(_a.isCollection(o)&&!o.flow&&o.items.length>0){let s=o.items[0];_a.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:xa(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(am.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,r,i)=>{let o=bt(e);o[0]+=t,this.onError(o,"BAD_DIRECTIVE",r,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=um.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 vt.YAMLParseError(bt(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 vt.YAMLParseError(bt(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let t=fm.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 vt.YAMLParseError(bt(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 lm.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}}};Pa.Composer=yi});var Aa=y(Pn=>{"use strict";var dm=mi(),mm=hi(),pm=wt(),Ra=rt();function hm(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 pm.YAMLParseError([a,a+1],o,s)};switch(n.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return mm.resolveFlowScalar(n,e,r);case"block-scalar":return dm.resolveBlockScalar({options:{strict:e}},n,r)}}return null}function gm(n,e){let{implicitKey:t=!1,indent:r,inFlow:i=!1,offset:o=-1,type:s="PLAIN"}=e,a=Ra.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
|
+
`),d=a.substring(0,l),f=a.substring(l+1)+`
|
|
112
|
+
`,u=[{type:"block-scalar-header",offset:o,indent:r,source:d}];return Na(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 wm(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=Ra.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">":ym(n,c);break;case'"':bi(n,c,"double-quoted-scalar");break;case"'":bi(n,c,"single-quoted-scalar");break;default:bi(n,c,"scalar")}}function ym(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}];Na(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 Na(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 bi(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})}}}Pn.createScalarToken=gm;Pn.resolveAsScalar=hm;Pn.setScalarValue=wm});var Oa=y(Ta=>{"use strict";var vm=n=>"type"in n?Nn(n):Rn(n);function Nn(n){switch(n.type){case"block-scalar":{let e="";for(let t of n.props)e+=Nn(t);return e+n.source}case"block-map":case"block-seq":{let e="";for(let t of n.items)e+=Rn(t);return e}case"flow-collection":{let e=n.start.source;for(let t of n.items)e+=Rn(t);for(let t of n.end)e+=t.source;return e}case"document":{let e=Rn(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 Rn({start:n,key:e,sep:t,value:r}){let i="";for(let o of n)i+=o.source;if(e&&(i+=Nn(e)),t)for(let o of t)i+=o.source;return r&&(i+=Nn(r)),i}Ta.stringify=vm});var Da=y(La=>{"use strict";var ki=Symbol("break visit"),bm=Symbol("skip children"),Ia=Symbol("remove item");function _e(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),ja(Object.freeze([]),n,e)}_e.BREAK=ki;_e.SKIP=bm;_e.REMOVE=Ia;_e.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};_e.parentCollection=(n,e)=>{let t=_e.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===ki)return ki;a===Ia&&(o.items.splice(s,1),s-=1)}}typeof r=="function"&&i==="key"&&(r=r(e,n))}}return typeof r=="function"?r(e,n):r}La.visit=_e});var An=y(F=>{"use strict";var Si=Aa(),km=Oa(),Sm=Da(),Ci="\uFEFF",Ei="",_i="",xi="",Cm=n=>!!n&&"items"in n,Em=n=>!!n&&(n.type==="scalar"||n.type==="single-quoted-scalar"||n.type==="double-quoted-scalar"||n.type==="block-scalar");function _m(n){switch(n){case Ci:return"<BOM>";case Ei:return"<DOC>";case _i:return"<FLOW_END>";case xi:return"<SCALAR>";default:return JSON.stringify(n)}}function xm(n){switch(n){case Ci:return"byte-order-mark";case Ei:return"doc-mode";case _i:return"flow-error-end";case xi: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=Si.createScalarToken;F.resolveAsScalar=Si.resolveAsScalar;F.setScalarValue=Si.setScalarValue;F.stringify=km.stringify;F.visit=Sm.visit;F.BOM=Ci;F.DOCUMENT=Ei;F.FLOW_END=_i;F.SCALAR=xi;F.isCollection=Cm;F.isScalar=Em;F.prettyToken=_m;F.tokenType=xm});var Ni=y(Ma=>{"use strict";var kt=An();function G(n){switch(n){case void 0:case" ":case`
|
|
120
|
+
`:case"\r":case" ":return!0;default:return!1}}var qa=new Set("0123456789ABCDEFabcdef"),Pm=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Tn=new Set(",[]{}"),Rm=new Set(` ,[]{}
|
|
121
|
+
\r `),Pi=n=>!n||Rm.has(n),Ri=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==="...")&&G(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]===kt.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 kt.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==="...")&&G(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&&!G(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===":")&&G(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(Pi),"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("..."))&&G(i[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield kt.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(Pi),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let s=this.charAt(1);if(this.flowKey||G(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=>G(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 kt.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(G(o)||e&&Tn.has(o))break;t=r}else if(G(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&&Tn.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&&Tn.has(i))break;t=r}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield kt.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(Pi),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(G(r)||t&&Tn.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(;!G(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(Pm.has(t))t=this.buffer[++e];else if(t==="%"&&qa.has(this.buffer[e+1])&&qa.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)}};Ma.Lexer=Ri});var Ti=y(Wa=>{"use strict";var Ai=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}}}};Wa.LineCounter=Ai});var Ii=y(Ua=>{"use strict";var Nm=Lt("process"),$a=An(),Am=Ni();function fe(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function Fa(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 Ka(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 On(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 Ue(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 In(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 Ba(n){if(n.start.type==="flow-seq-start")for(let e of n.items)e.sep&&!e.value&&!fe(e.start,"explicit-key-ind")&&!fe(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Ka(e.value)?e.value.end?In(e.value.end,e.sep):e.value.end=e.sep:In(e.start,e.sep),delete e.sep)}var Oi=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 Am.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,Nm.env.LOG_TOKENS&&console.log("|",$a.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=$a.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"&&Ba(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&&Fa(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":{Fa(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=On(this.peek(2)),r=Ue(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)){In(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(fe(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(Ka(t.key)&&!fe(t.sep,"newline")){let s=Ue(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(fe(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let s=Ue(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]}):fe(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&&!fe(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)){In(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||fe(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=On(r),o=Ue(i);Ba(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=On(e),r=Ue(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=On(e),r=Ue(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())}}};Ua.Parser=Oi});var Ga=y(Ct=>{"use strict";var Ha=vi(),Tm=pt(),St=wt(),Om=wr(),Im=_(),jm=Ti(),Ya=Ii();function Ja(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new jm.LineCounter||null,prettyErrors:e}}function Lm(n,e={}){let{lineCounter:t,prettyErrors:r}=Ja(e),i=new Ya.Parser(t?.addNewLine),o=new Ha.Composer(e),s=Array.from(o.compose(i.parse(n)));if(r&&t)for(let a of s)a.errors.forEach(St.prettifyError(n,t)),a.warnings.forEach(St.prettifyError(n,t));return s.length>0?s:Object.assign([],{empty:!0},o.streamInfo())}function Va(n,e={}){let{lineCounter:t,prettyErrors:r}=Ja(e),i=new Ya.Parser(t?.addNewLine),o=new Ha.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 St.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&t&&(s.errors.forEach(St.prettifyError(n,t)),s.warnings.forEach(St.prettifyError(n,t))),s}function Dm(n,e,t){let r;typeof e=="function"?r=e:t===void 0&&e&&typeof e=="object"&&(t=e);let i=Va(n,t);if(!i)return null;if(i.warnings.forEach(o=>Om.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 qm(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 Im.isDocument(n)&&!r?n.toString(t):new Tm.Document(n,r,t).toString(t)}Ct.parse=Dm;Ct.parseAllDocuments=Lm;Ct.parseDocument=Va;Ct.stringify=qm});var Ln=y(P=>{"use strict";var Mm=vi(),Wm=pt(),$m=Zr(),ji=wt(),Fm=Qe(),de=_(),Bm=ae(),Km=A(),Um=le(),Hm=ue(),Ym=An(),Jm=Ni(),Vm=Ti(),Gm=Ii(),jn=Ga(),za=Ve();P.Composer=Mm.Composer;P.Document=Wm.Document;P.Schema=$m.Schema;P.YAMLError=ji.YAMLError;P.YAMLParseError=ji.YAMLParseError;P.YAMLWarning=ji.YAMLWarning;P.Alias=Fm.Alias;P.isAlias=de.isAlias;P.isCollection=de.isCollection;P.isDocument=de.isDocument;P.isMap=de.isMap;P.isNode=de.isNode;P.isPair=de.isPair;P.isScalar=de.isScalar;P.isSeq=de.isSeq;P.Pair=Bm.Pair;P.Scalar=Km.Scalar;P.YAMLMap=Um.YAMLMap;P.YAMLSeq=Hm.YAMLSeq;P.CST=Ym;P.Lexer=Jm.Lexer;P.LineCounter=Vm.LineCounter;P.Parser=Gm.Parser;P.parse=jn.parse;P.parseAllDocuments=jn.parseAllDocuments;P.parseDocument=jn.parseDocument;P.stringify=jn.stringify;P.visit=za.visit;P.visitAsync=za.visitAsync});import Gn from"node:path";import{AsyncLocalStorage as Gp}from"async_hooks";import{promises as xc}from"fs";import Rt from"path";import{promises as Cc}from"fs";import T from"path";import Kp from"os";import{promises as bl}from"fs";async function ao(n){try{return await bl.access(n),!0}catch(e){if(kl(e))return!1;throw e}}function kl(n){let e=n?.code;return e==="ENOENT"||e==="ENOTDIR"}import me from"path";var Y=er(Ln(),1),xe=Number.MAX_SAFE_INTEGER,Xa=1024,Qa=64,zm=5,Xm=2,Li={learning:!0,retrieval:!0},Za={include:[],max_file_mb:1,max_total_mb:32},Qm={provider:"local"};var ec=36e5,Zm=12e4,tc=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||me.posix.isAbsolute(t)||me.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 Dn(n){let e=ep(n,"native.artifact_root");return e.length===0?".":e.join("/")}function rc(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 he(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||me.posix.isAbsolute(r)||me.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 pe(n,e){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`${e} must be a mapping`);return n}function ic(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 tp(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 nc(n,e,t){let r=tp(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 np(n){if(n===void 0)return;let e=pe(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=pe(e.cleanup,"native.pending_root_move.cleanup"),c=a.kind,l=a.state,d=a.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof d!="string"||!/^[a-f0-9]{64}$/u.test(d))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");s={kind:c,state:l,manifestHash:d}}return{id:t,fromArtifactRoot:Dn(r),toArtifactRoot:Dn(i),stage:o,...s?{cleanup:s}:{}}}function rp(n){if(n===void 0)return;let e=pe(n,"native.finish");if(e.pull_request===void 0)return{};let t=pe(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(me.posix.isAbsolute(r[0])||me.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??Zm;if(!Number.isSafeInteger(i)||i<1||i>tc)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${tc}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:i}}}function ip(n,e={}){let t=pe(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??zm;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?Xm: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=np(t.pending_root_move),d=rp(t.finish);return{artifact_root:Dn(r),language:ic(t.language,"en","native.language"),clarification_mode:i,archive_confirmation:o,max_verify_failures:s,max_parallel_children:a,...c==="revert"?{document_writes:c}:{},...d?{finish:d}:{},...l?{pending_root_move:l}:{}}}function op(n,e){if(!Number.isSafeInteger(n)||Number(n)<1||Number(n)>ec)throw new Error(`${e} must be an integer between 1 and ${ec} milliseconds`);return n}function sp(n){let e=pe(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&&op(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:rc(e.artifact_layout),language:ic(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 ap(n){let t=pe(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)=>he(r,`hook.allow_paths[${i}]`)))]}}function cp(n){if(n===void 0)return{...Li};let e=pe(n,"memory"),t=e.learning??Li.learning,r=e.retrieval??Li.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 Di(n,e){if(n===null||typeof n!="object"||Array.isArray(n))throw new Error(`${e} must be a mapping`);return n}function lp(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")||me.posix.isAbsolute(t)||me.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>Xa)throw new Error(`${e} exceeds ${Xa} 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>Qa)throw new Error(`${e} contains more than ${Qa} wildcard tokens`);return t}function up(n){let e=Di(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)=>lp(i,`knowledge.local.include[${o}]`)))],max_file_mb:nc(e.max_file_mb,Za.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:nc(e.max_total_mb,Za.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 fp(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=Di(n,"knowledge.remote"),t=fp(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 mp(n){if(n===void 0)return{...Qm};let e=Di(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:up(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 oc(n){if(n===void 0)return!0;if(typeof n!="boolean")throw new Error("change_walkthrough must be true or false");return n}function pp(n){let e=n??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function hp(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 d=n.workflows??[n.default_workflow];if(!Array.isArray(d)||d.length===0||d.some(u=>u!=="native"&&u!=="classic"))throw new Error("workflows must contain native and/or classic");let f=[...new Set(d)];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:oc(n.change_walkthrough),...e?{hook:e}:{},memory:t,knowledge:r,...i?{native:i}:{},...o?{classic:o}:{}}}function sc(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 Pe(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=pp(i.ambient_resume),s=oc(i.change_walkthrough),a=i.hook===void 0?void 0:ap(i.hook),c=cp(i.memory),l=mp(i.knowledge),d=i.native===void 0?void 0:ip(i.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),f=i.classic===void 0?void 0:sp(i.classic),u=hp(i,a,c,l,d,f,o,{allowPartialProject:e.allowPartialProject??!1});return{value:i,config:u,ambient_resume:o,change_walkthrough:s,memory:c,knowledge:l,...a?{hook:a}:{},...d?{native:d}:{},...f?{classic:f}:{}}}import{createHash as _p}from"crypto";import{promises as K}from"fs";import R from"path";import{AsyncLocalStorage as bp}from"node:async_hooks";import{constants as we,promises as B}from"fs";import{createHash as gp}from"node:crypto";function ge(n){return n!==0&&n!==0n&&n!=="0"}function ac(n,e){return ge(n.dev)&&ge(e.dev)&&ge(n.ino)&&ge(e.ino)}function Re(n,e){let t=ge(n.dev)&&ge(e.dev);if(t&&n.dev!==e.dev)return!1;let r=ge(n.ino)&&ge(e.ino);return r&&n.ino!==e.ino?!1:t&&r?!0:n.birthtime===e.birthtime}var J=class extends Error{reason;constructor(e,t,r){super(t,r),this.name="RaceSafeReadError",this.reason=e}};function qi(n){return"birthtimeNs"in n&&typeof n.birthtimeNs=="bigint"?n.birthtimeNs:n.birthtimeMs}function qn(n){return"ctimeNs"in n&&typeof n.ctimeNs=="bigint"?n.ctimeNs:n.ctimeMs}function ve(n){return{dev:n.dev,ino:n.ino,birthtime:qi(n)}}function wp(n,e){let t=ve(n),r=ve(e);return ac(t,r)?Re(t,r):Re(t,r)&&qi(n)===qi(e)&&qn(n)===qn(e)&&n.size===e.size}function ye(n,e){let t=r=>"mtimeNs"in r?r.mtimeNs:r.mtimeMs;return wp(n,e)&&n.size===e.size&&n.mode===e.mode&&t(n)===t(e)&&qn(n)===qn(e)}async function Et(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:ve(o)});let a=process.platform==="win32"?we.O_RDONLY:we.O_RDONLY|we.O_NOFOLLOW|we.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,d,f]=await Promise.all([c.stat({bigint:i}),B.lstat(n,{bigint:i}),B.realpath(n)]);if(!l.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!ye(o,l)||!ye(o,d))throw new J("changed",`${r} changed while opening`);await t.verify?.("post-open",{realPath:f,identity:ve(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[m,h,w]=await Promise.all([c.stat({bigint:i}),B.lstat(n,{bigint:i}),B.realpath(n)]);if(!h.isFile()||h.isSymbolicLink()||w!==s||!ye(o,m)||!ye(o,h))throw new J("changed",`${r} changed while reading`);return await t.verify?.("post-read",{realPath:w,identity:ve(m)}),{bytes:Buffer.concat(u,p),stat:m,realPath:w}}finally{await c.close()}}async function cc(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:ve(i)});let s=process.platform==="win32"?we.O_RDONLY:we.O_RDONLY|we.O_NOFOLLOW|we.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,d]=await Promise.all([a.stat({bigint:r}),B.lstat(n,{bigint:r}),B.realpath(n)]);if(!c.isFile()||!l.isFile()||l.isSymbolicLink()||d!==o||!ye(i,c)||!ye(i,l))throw new J("changed",`${t} changed while opening`);await e.verify?.("post-open",{realPath:d,identity:ve(c)}),await e.hooks?.afterOpen?.();let f=gp(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,m]=await Promise.all([a.stat({bigint:r}),B.lstat(n,{bigint:r}),B.realpath(n)]);if(!g.isFile()||g.isSymbolicLink()||m!==o||!ye(i,p)||!ye(i,g))throw new J("changed",`${t} changed while reading`);return await e.verify?.("post-read",{realPath:m,identity:ve(p)}),{digest:f.digest("hex"),stat:p,realPath:m}}finally{await a.close()}}import{AsyncLocalStorage as yp}from"node:async_hooks";var vp=new yp;function lc(){let n=vp.getStore();return n?.active?n:null}function uc(n,e){let t=n;for(let r of e)t+="\0"+(typeof r=="string"?r:JSON.stringify(r));return t}function z(n,e){return(...t)=>{let r=lc();if(r===null)return e(...t);let i=uc(`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 _t(n,e){return(...t)=>{let r=lc();if(r===null)return e(...t);let i=uc(`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}}var kp=new bp;async function Mi(n,e,t={}){let r=R.resolve(n),i=await $i(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,m)=>String(g[0]).localeCompare(String(m[0]),"en"))),d=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 m=await K.realpath(u);if(!He(i,m))throw new Error(`${e} resolves outside the project root`);let h=t.ignoredDirectoryEntries?.(R.relative(r,u).replaceAll("\\","/")||".");return{stat:g,real:m,...h?{ignoreEntry:h,namespace:await l(u,h)}:{}}})(),p=p.catch(g=>{throw o.delete(u),g}),o.set(u,p)),p};await d(r);let f=async u=>{if(s)throw new Error(`${e} read session is already finished`);let p=he(u,e),g=r;for(let m of p.split("/").slice(0,-1))g=R.join(g,m),await d(g);return R.resolve(r,...p.split("/"))};return{observePath:f,async observeDirectory(u){let p=await f(u);return await d(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 cc(p,{bigint:!0,label:`${e} ${u}`,verify:async(g,m)=>{if(!He(i,m.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 m=await f(u);return Et(m,p,{...g,label:`${e} ${u}`,verify:async(h,w)=>{if(!He(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(m)).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,m]of o){let h=await m,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 fc(n){let e=n?.code;return e==="ENOENT"||e==="ENOTDIR"}function He(n,e){let t=R.relative(n,e);return t===""||!R.isAbsolute(t)&&t!==".."&&!t.startsWith(`..${R.sep}`)}var dc=z("protectedChainLstat",n=>K.lstat(n)),mc=z("protectedChainRealpath",n=>K.realpath(n)),Sp=_t("protectedChainInside",He);async function $i(n,e){let t=R.resolve(n),r=await dc(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return mc(t)}async function pc(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 dc(i)}catch(l){if(fc(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 mc(i);if(!Sp(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 hc(n,e,t){let r=he(e,t.label),i=R.resolve(n),o=await $i(i,t.label),s=r.split("/"),a=R.resolve(i,...s);if(!He(i,a))throw new Error(`${t.label} must stay inside the project root`);let c=await pc(i,o,s,t);return{projectRoot:i,target:a,relative:r,exists:c.exists,kind:c.kind}}var Cp=z("protectedInspectPath",(n,e,t)=>hc(n,e,{label:"Protected project path",expected:t}));async function L(n,e,t){if(t.expected===void 0)return hc(n,e,t);try{return await Cp(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 Mn(n,e,t){let r=he(e,t.label),i=R.resolve(n),o=await $i(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(!fc(u))throw u;try{await K.mkdir(a)}catch(p){if(p.code!=="EEXIST")throw p}l=await K.lstat(a)}let d=R.relative(i,a).replaceAll("\\","/");if(l.isSymbolicLink())throw new Error(`${t.label} crosses a symbolic link or junction at ${d}`);if(!l.isDirectory())throw new Error(`${t.label} directory ${d} must be a real directory`);let f=await K.realpath(a);if(!He(o,f))throw new Error(`${t.label} resolves outside the project root`)}return await pc(i,o,s,{label:t.label,expected:"directory"}),a}async function gc(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=Mi(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 Mi(n,r.label),s=await o.read(e,t,r);return await o.finish({allowDirectoryContentChanges:!0}),s}var Wi="Cached protected project read",Ep=z("protectedReadFile",(n,e,t)=>gc(n,e,t,{label:Wi}));async function U(n,e,t,r){if(r.hooks||r.bigint)return gc(n,e,t,r);try{return await Ep(n,e,t)}catch(i){throw i instanceof Error&&i.message.includes(Wi)&&(i.message=i.message.replaceAll(Wi,r.label)),i}}var xt=".comet/config.yaml";function xp(n){let e=n?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Wn(n,e={}){return(await $n(n,e)).document}async function Pp(n){try{return(await U(n,xt,xe,{label:xt})).bytes}catch(e){if(xp(e))return null;throw e}}function Rp(n){return n?{exists:!0,sha256:_p("sha256").update(n).digest("hex")}:{exists:!1,sha256:null}}async function $n(n,e={}){let t=await Pp(n);return{source:t?.toString("utf8")??null,document:t?Pe(t.toString("utf8"),e):null,identity:Rp(t)}}async function Fi(n){return(await Wn(n))?.config??null}import{promises as wc}from"node:fs";var Np=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),Bi=[50,100,200];async function yc(n,e){let t;for(let r=0;r<=Bi.length;r+=1)try{return await n()}catch(i){t=i;let o=i.code;if(r===Bi.length||!Np.has(o??""))throw i;await new Promise(s=>setTimeout(s,Bi[r]))}throw t}async function vc(n,e){await yc(()=>wc.rename(n,e),`rename ${e}`)}async function Ki(n,e){await yc(()=>wc.link(n,e),`link ${e}`)}import{randomUUID as Ap}from"crypto";import{constants as Tp,promises as M}from"fs";import q from"path";async function Ui(n,e){try{return await Ki(n,e),{linked:!0}}catch(t){let r=t.code;if(r!=="ENOTSUP"&&r!=="EOPNOTSUPP")throw t}return await M.copyFile(n,e,Tp.COPYFILE_EXCL),{linked:!1}}function Ye(n,e){let t=q.relative(n,e);return t===""||!q.isAbsolute(t)&&t!==".."&&!t.startsWith(`..${q.sep}`)}function Fn(n){return{dev:n.dev,ino:n.ino,birthtime:n.birthtimeMs}}function Op(n,e){return Re(n,Fn(e))}function Bn(n,e){return Re(Fn(n),Fn(e))}function Ip(n,e){return Bn(n,e)&&n.birthtimeMs===e.birthtimeMs&&n.ctimeMs===e.ctimeMs&&n.mtimeMs===e.mtimeMs&&n.size===e.size}async function Kn(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),...Fn(e)}}async function Ne(n){for(let e of n){let t=await M.lstat(e.path);if(!t.isDirectory()||t.isSymbolicLink()||!Op(e,t)||await M.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function jp(n,e,t){let[r,i]=await Promise.all([M.lstat(n),M.realpath(n),Ne(t)]);if(!r.isFile()||r.isSymbolicLink()||!Bn(r,e)||!Ye(t[0].realPath,i))throw new Error("Contained atomic write temporary file changed after close");return r}async function Lp(n,e){let t=await Dp(n,e);if(t)return t;let r=q.resolve(n),i=q.resolve(e);if(!Ye(r,i))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let o=[await Kn(r)],s=q.relative(r,i).split(q.sep).filter(Boolean),a=r;for(let c of s){await Ne(o),a=q.join(a,c);try{await M.mkdir(a)}catch(d){if(d.code!=="EEXIST")throw d}let l=await Kn(a);if(!Ye(o[0].realPath,l.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${a}`);o.push(l)}return await Ne(o),o}async function Dp(n,e){let t=q.resolve(n),r=q.resolve(e);if(!Ye(t,r))throw new Error(`Contained file parent is outside its managed root: ${e}`);let i=[await Kn(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 Kn(s);if(!Ye(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 Ne(i),i}async function qp(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 Mp(n,e,t){let r=q.dirname(n),i=await Lp(t.containedRoot,r),o=q.join(r,`.${q.basename(n)}.${Ap()}.tmp`),s,a,c;try{await t.beforeTemporaryOpen?.(),s=await M.open(o,"wx"),a=await s.stat();let[l,d]=await Promise.all([M.lstat(o),M.realpath(o)]);if(await Ne(i),!l.isFile()||l.isSymbolicLink()||!Bn(a,l)||!Ye(i[0].realPath,d))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(),!Bn(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 jp(o,c,i),await t.beforeCommit?.(),await Ne(i);let f=await M.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!c||!Ip(f,c))throw new Error("Contained atomic write temporary file changed before commit");t.exclusive?(t.requireAtomicPublication?await Ki(o,n):await Ui(o,n),await M.unlink(o)):await vc(o,n),await qp(r)}catch(l){await s?.close();try{await Ne(i),await M.rm(o,{force:!0})}catch{}throw l}}async function te(n,e,t){await Mp(n,e,t)}var Qw=Number.MAX_SAFE_INTEGER;var Pt=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Ae=class extends Error{constructor(e){super(e instanceof Error?e.message:String(e),{cause:e}),this.name="ClassicProjectConfigError"}},Sc=".comet/config.yaml";function Yi(n){let e=n?.code;return e==="ENOENT"||e==="ENOTDIR"}function Ec(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 Up(n){let e=await Wn(n,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new Pt;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new Pt("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function Hp(n,e){return Ec(n,e??await Up(n))}async function Yp(n){try{return await Cc.lstat(n),!0}catch(e){if(Yi(e))return!1;throw e}}async function Jp(n,e){let t=await Hp(n,e),r=t.artifactLayout==="legacy"?"docs":"legacy",i=Ec(n,r).openSpecRoot,[o,s]=await Promise.all([L(t.projectRoot,Je(t.projectRoot,t.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),Yp(i)]),a=o.exists;return{paths:t,configuredRootExists:a,alternateRoot:i,alternateRootExists:s,dualRoots:a&&s}}async function Vp(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=Je(n.projectRoot,t);await L(n.projectRoot,r,{label:`Classic managed physical path ${r}`,expected:"directory"})}}async function _c(n,e){let t=await Jp(n,e);if(await Vp(t.paths),!t.configuredRootExists){let r=Je(t.paths.projectRoot,t.paths.openSpecRoot),i=Je(t.paths.projectRoot,t.alternateRoot);throw new Pt(`Configured Classic OpenSpec root is missing: ${r} (alternate ${i} is ${t.alternateRootExists?"present":"missing"})`)}return t.paths}async function Te(n){let e=T.resolve(n),t=null;try{(await Cc.lstat(e)).isDirectory()||(e=T.dirname(e))}catch(o){if(!Yi(o))throw o}let r=e,i=T.resolve(Kp.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,Sc,xe,{label:Sc});a=l.toString("utf8")}catch(l){if(!Yi(l))throw l}if(a!==null)try{let l=Pe(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 Ae(l);if(sc(a))throw new Ae(l)}if(o||await ao(T.join(e,".git")))return e;let c=T.dirname(e);if(c===e)return t??T.resolve(n);e=c}}function Je(n,e){return T.relative(T.resolve(n),e).replaceAll("\\","/")}var Un=new Gp;function zp(n,e){let t=Rt.relative(n,e);return t===""||!Rt.isAbsolute(t)&&t!==".."&&!t.startsWith(`..${Rt.sep}`)}async function Xp(n){let e=Rt.resolve(n.invocationCwd??process.cwd()),t=Rt.resolve(n.projectRoot??await Te(e)),[r,i]=await Promise.all([xc.realpath(e),xc.realpath(t)]);if(!zp(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 Qp(n,e){let t=Un.getStore();if(t)return e(t);let r=await Xp(n);return Un.run(r,()=>e(r))}function Pc(){let n=Un.getStore();if(!n)throw new Error("Classic command project context is unavailable");return n.projectRoot}async function Rc(n,e){let t=Un.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 Nc(n){return(e,t)=>Qp(t,()=>n(e,t))}import{promises as Zp}from"node:fs";import Ji from"node:path";var Tc="comet-state.yaml",eh=".comet.yaml",Ac=[Tc,eh],Vi=class extends Error{};async function th(n,e={}){let t=[],r=[];for(let i of Ac)try{let o=await Zp.lstat(Ji.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 Vi(`Classic state files are ambiguous in ${n}: ${Ac.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: ${Ji.join(n,r[0])}`);return Ji.join(n,t[0]??e.defaultFileName??Tc)}var nh=z("classicStateFile",(n,e)=>th(n,e));async function Oe(n,e={}){return nh(n,e)}import{promises as Uc}from"fs";import Vn from"path";import It from"path";import{AsyncLocalStorage as Nh}from"node:async_hooks";var lh=er(Ln(),1);var My=Number.MAX_SAFE_INTEGER;var tv=z("hookWritePolicy",async n=>(await Fi(n))?.hook??{allow_paths:[]});import uh from"node:path";var Hn="comet.selection.v2",Ic=Number.MAX_SAFE_INTEGER;function jc(n){return uh.join(n,".comet","current-change.json")}function fh(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Oc(n){return n===null||typeof n=="string"}function dh(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(!fh(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&&!Oc(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:Hn,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==Hn)throw new Error(`current change selection schema must be ${Hn}`);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(!Oc(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 Lc(n){let e;try{let r=jc(n),{bytes:i}=await Et(r,Ic,{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",...dh(e)}}var sv=z("readCometCurrentSelection",n=>Lc(n));var ab=Number.MAX_SAFE_INTEGER;var Dc=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/u;var Nt=["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"],At=["change_id","run_id","run_checkpoint","application_checkpoint"],fb=new Set([...Nt,...At]);var Fc=er(Ln(),1);import{createHash as Sh,randomUUID as Ch}from"node:crypto";import x from"node:path";import{promises as Wc}from"node:fs";import kh from"node:path";import{createHash as ph}from"node:crypto";import{lstatSync as Tt,readFileSync as hh,realpathSync as qc}from"node:fs";import gh from"node:os";import W from"node:path";function Gi(n){return`${n.dev}:${n.ino}:${n.birthtimeNs}`}function Yn(n){return process.platform==="win32"?qc.native(n):qc(n)}var wh=_t("workspaceIdentity",vh);function yh(n){return wh(n)}function vh(n){let e=Yn(W.resolve(n)),t=Tt(e,{bigint:!0});if(!t.isDirectory())throw new Error(`工作区必须是目录:${n}`);let r=Gi(t),i=(c,l)=>({projectRoot:e,workspaceId:ph("sha256").update(JSON.stringify(["comet.workspace.v2",e,r,c,l])).digest("hex")}),o=W.join(e,".git"),s,a;try{let c=Tt(o);if(c.isSymbolicLink())throw new Error(`工作区 .git 不能是符号链接:${o}`);if(c.isDirectory())s=Yn(o),a=Gi(Tt(s,{bigint:!0}));else if(c.isFile()){let l=/^gitdir: (.+)\r?\n?$/u.exec(hh(o,"utf8"));if(!l)throw new Error(`工作区 .git 文件格式无效:${o}`);s=Yn(W.resolve(e,l[1].trim()));let d=Tt(s,{bigint:!0});if(!d.isDirectory())throw new Error(`工作区 Git 元数据必须是目录:${s}`);a=Gi(d)}else throw new Error(`工作区 .git 类型无效:${o}`)}catch(c){if(c.code!=="ENOENT")throw c;try{Tt(o)}catch(l){if(l.code==="ENOENT")return i(o,null);throw l}throw c}return i(s,a)}function Mc(n){let e=W.dirname(n);if(e===n)return n;try{return W.join(Yn(e),W.basename(n))}catch(t){if(t.code!=="ENOENT")throw t;return W.join(Mc(e),W.basename(n))}}var bh=_t("workspaceRuntimeParent",Mc);function zi(n){let e=yh(n),t=process.env.COMET_DATA_DIR;if(t!==void 0&&(!t.trim()||!W.isAbsolute(t)))throw new Error("COMET_DATA_DIR 必须是非空绝对路径");let r=bh(t??W.join(gh.homedir(),".comet")),i=W.relative(e.projectRoot,r);if(i===""||!W.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${W.sep}`))throw new Error(`用户级 Runtime 数据根不能位于当前工作区内:${r};工作区:${e.projectRoot}`);let o=W.join(r,"workspaces",e.workspaceId);return{...e,dataRoot:r,workspaceRoot:o,runtimeRoot:W.join(o,"runtime")}}function Ot(n){return zi(n).runtimeRoot}async function $c(n){let e=kh.dirname(n);if(e!==n){await $c(e);try{await Wc.mkdir(n,{mode:448})}catch(r){if(r.code!=="EEXIST")throw r}}let t=await Wc.lstat(n);if(!t.isDirectory()||t.isSymbolicLink())throw new Error("Runtime 路径必须是真实目录:"+n)}async function Xi(n){let e=Ot(n);return await $c(e),e}var Eh=new Set(["run-state.json","pending-action.json","trajectory.jsonl","context.md","artifacts.json","checkpoint.json","coordination.json","subagent-progress.md"]);function Jn(n){let e=Sh("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 Bc(n,e){let t=await Oe(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,Fc.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"||!Dc.test(s)))throw new Error("Invalid Classic change_id: expected an immutable UUID");return{source:i,document:o,id:s}}async function _h(n,e){let t=await Oe(e),r=x.relative(n,t).replaceAll("\\","/"),i=()=>Bc(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?Jn(`classic-run:${c}`):Ch();return a.get("archived")===!0||x.basename(x.dirname(e))==="archive"?typeof c=="string"&&c?l:Jn(`classic-archive:${r}`):(a.set("change_id",l),await te(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 xh(n,e,t={}){let r=e??await Te(n),i;try{i=await Bc(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",d=s??(typeof c=="string"&&c?Jn(`classic-run:${c}`):l?Jn(`classic-archive:${a}`):null);if(!d)return n;let f=Ot(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",d):n;let p=await L(f,`classic-changes/${d}`,{label:"Classic read-only Run directory",expected:"directory"});return p.exists||t.includeMissing?p.target:n}async function Ph(n,e){return Rh(n,e)}async function Rh(n,e){let t=e??await Te(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 Oe(n);let i=await Xi(t),o=await _h(t,n),s=x.join(i,"classic-changes",o);return await Mn(i,x.relative(i,s),{label:"Classic local Run directory"}),s}async function Kc(n,e,t={}){let r=Ot(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 Xi(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||!Eh.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 Oe(x.join(n,a))),{label:"Classic local change identity",expected:"file"})).exists)return null;let l=x.join(n,a),d=t.readOnly?await xh(l,n,{includeMissing:!0}):await Ph(l,n);if(!d||t.readOnly&&d===l)return null;let f=x.relative(r,d);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(d,".comet",s[2],s[3]??"")}}var Fb=Number.MAX_SAFE_INTEGER,Bb=new Nh;async function Ah(n,e,t,r=!1){let i=It.resolve(n),o=It.isAbsolute(e)?It.resolve(e):It.resolve(i,e),s=await Kc(i,o,{readOnly:!r});s&&(i=s.root,o=s.target);let a=It.relative(i,o).replaceAll("\\","/");return{root:i,relative:he(a,t),target:o}}async function Qi(n,e,t){let r=await Ah(n,e,t.label,t.migrate);return L(r.root,r.relative,t)}function Th(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 Hc(n){let e=Th(n);if(e)throw new Error(e)}function Oh(n,e){return{label:Je(n,e),directory:e}}async function Zi(n,e,t){let r=Oh(n,e);if(!(await Qi(n,e,{label:t,expected:"directory"})).exists)return{change:r,exists:!1,stateExists:!1};let o=await Qi(n,await Oe(e),{label:`${t} state`,expected:"file"});return{change:r,exists:!0,stateExists:o.exists}}var Ih=/^\d{4}-\d{2}-\d{2}-/u;function jh(n,e){return n.slice(11)===e&&Ih.test(n)}async function Lh(n,e,t){Hc(t);let r=()=>L(n,Vn.relative(n,e),{label:"Classic Archive directory",expected:"directory"}),i=await r();if(!i.exists)return null;let o=async()=>{let c=await Uc.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 Rc(`classic-archive:${JSON.stringify([i.target,t,s])}`,async()=>{let c=await Uc.readdir(i.target);if(await o()!==s)throw new Error("Classic Archive directory changed while inspecting state files");return c.filter(l=>l===t||jh(l,t))});if(!(await r()).exists||await o()!==s)throw new Error("Classic Archive directory changed while inspecting state files");return a}async function Dh(n,e,t,r={}){if(!r.skipExactCompatibility){let s=await Zi(n,Vn.join(e,t),`Classic archived change ${t}`);if(s.exists)return s.change}let i=await Lh(n,e,t),o=[];for(let s of i??[]){if(s===t)continue;let a=await Zi(n,Vn.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 Yc(n,e=process.cwd()){Hc(n);let t=await _c(e),r=await Zi(t.projectRoot,Vn.join(t.changesDir,n),`Classic active change ${n}`);if(r.exists)return r.change;let i=await Dh(t.projectRoot,t.archiveDir,n);return i||r.change}var eo=Nc(async n=>{let[e,t,r]=n,i=n.indexOf("--");if(!["run","rerun"].includes(e)||!t||!["build","verify"].includes(r))throw new Error("Usage: comet check run <change> <build|verify> [--cwd <path>] -- <program> [args...] | comet check rerun <change> <build|verify>");let o=Pc(),s=".",a=i<0?n.length:i;for(let d=3;d<a;d++)if(["--cwd","--timeout-ms","--report"].includes(n[d])){let f=n[d],u=n[++d];if(u===void 0)throw new Error("Missing value for "+f);f==="--cwd"&&(s=u)}else if(!["--local","--incremental"].includes(n[d]))throw new Error("Unknown check option: "+n[d]);if(e==="run"&&(i<3||!n[i+1]))throw new Error("Provide the program and arguments after --");let c=Gn.resolve(o,s),l=Gn.relative(o,c);if(l===".."||l.startsWith(".."+Gn.sep)||Gn.isAbsolute(l))throw new Error("Check cwd must be within the selected project");return await Yc(t,o),{exitCode:0,data:{change:t,scope:r,status:"platform-execution-required",checksExecuted:!1,...i>=0?{platformCommand:{argv:n.slice(i+1),cwd:c}}:{},instruction:"使用 Agent 平台工具执行所选检查,由平台处理超时、取消和进程清理;核对实际结果后,按当前任务提交平台检查报告。Comet 没有执行本条命令,也没有登记通过结果。",commandArgs:["comet","state","next",t,"--json"]},stdout:`请使用 Agent 平台工具执行检查,并提交真实结果;当前命令没有运行检查。
|
|
144
|
+
`}});import{realpathSync as Xh}from"fs";import{pathToFileURL as ll}from"url";var qh=new Set([...At,"archive_confirmation","verify_failures","check_epoch","classic_profile","classic_migration","bound_branch"]),Jc=new Set(Nt.filter(n=>!qh.has(n))),to={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 Vc=["open-complete","design-complete","build-complete","verify-pass","verify-fail","archive-confirm","archive-reopen","archived","preset-escalate"];var Mh=`
|
|
145
|
+
Options: --json (machine-readable output), --compact (requires --json), --help
|
|
146
|
+
精简视图用 outputView.references 的 JSON Pointer 定位重复字段;Request 模板保留完整;没有字节收益时返回原完整协议。去掉 --compact 获取完整协议。
|
|
147
|
+
JSON: one object with command and exitCode; data, stdout, stderr, summary and next are optional.
|
|
148
|
+
Use exitCode for success; do not parse human-readable stdout. Help text is in stdout in JSON mode.
|
|
149
|
+
`;function Gc(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: ${[...Nt,...At].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):",...[...Jc].map(c=>` ${c}${to[c]?`: ${to[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: ${Vc.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(`
|
|
150
|
+
`)}
|
|
151
|
+
${Mh}Command placeholders must be replaced with actual values.
|
|
152
|
+
`:void 0}function zc(n,e){let t=m=>m!==null&&typeof m=="object"&&!Array.isArray(m)?m:{},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,d=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 d=="number"?d: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 Wh}from"node:util";function Xc(n,e={}){return{code:"CLASSIC_COMMAND_FAILED",message:Wh(n instanceof Error?n.message:String(n)),...e}}import{AsyncLocalStorage as el}from"node:async_hooks";var Qc=new el,Zc=new el;async function tl(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)} 秒
|
|
153
|
+
`)}){if(Zc.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 Zc.run(t,n)}finally{clearInterval(i)}}async function nl(n){let e={gitCommands:0,gitDurationMs:0};return{result:await Qc.run([...Qc.getStore()??[],e],n),metrics:e}}import{randomUUID as Jh}from"node:crypto";import{performance as al}from"node:perf_hooks";import{createRequire as $h}from"node:module";var Fh=$h(import.meta.url??__filename),zn;function Xn(n,e){if(!zn){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{zn=Fh("node:sqlite").DatabaseSync}finally{process.emitWarning=t}}return e===void 0?new zn(n):new zn(n,e)}import{promises as Qn}from"node:fs";import no from"node:path";async function Zn(n,e){let t=zi(n),r=no.join(t.workspaceRoot,"observability"),i=t.dataRoot;for(let s of["","workspaces",t.workspaceId,"observability"]){i=no.join(i,s);let a;try{a=await Qn.lstat(i)}catch(c){if(!e||c.code!=="ENOENT")throw c;await Qn.mkdir(i,{recursive:s===""}).catch(l=>{if(l.code!=="EEXIST")throw l}),a=await Qn.lstat(i)}if(!a.isDirectory()||a.isSymbolicLink())throw new Error("Runtime 统计目录必须是普通目录")}let o=no.join(r,"performance.sqlite");for(let s of["","-wal","-shm"])try{let a=await Qn.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 Kh}from"node:async_hooks";import{createHash as Uh,randomUUID as il}from"node:crypto";import ro from"node:path";import{stripVTControlCharacters as Bh}from"node:util";function rl(n,e=process.env){let t=Bh(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 Hh=864e5,Yh=1e4,io=new Kh;function jt(n,e){return rl(n).slice(0,e)}async function ol(n,e){if(!e.length)return;let t=io.getStore();if(t){let i=o=>process.platform==="win32"?ro.resolve(o).toLowerCase():ro.resolve(o);if(i(n)===i(await t.projectRoot())){t.spans.push(...e);return}}let r=Xn(await Zn(n,!0));try{r.exec(`PRAGMA busy_timeout=25; PRAGMA journal_mode=WAL;
|
|
154
|
+
CREATE TABLE IF NOT EXISTS trace_spans (
|
|
155
|
+
id TEXT PRIMARY KEY, trace_id TEXT NOT NULL, workflow TEXT NOT NULL,
|
|
156
|
+
change_name TEXT NOT NULL, run_id TEXT NOT NULL, span_id TEXT NOT NULL,
|
|
157
|
+
parent_span_id TEXT, kind TEXT NOT NULL, name TEXT NOT NULL, status TEXT NOT NULL,
|
|
158
|
+
started_at TEXT, ended_at TEXT, updated_at TEXT NOT NULL,
|
|
159
|
+
revision INTEGER NOT NULL, data TEXT NOT NULL);
|
|
160
|
+
CREATE INDEX IF NOT EXISTS trace_spans_time ON trace_spans(updated_at);
|
|
161
|
+
CREATE INDEX IF NOT EXISTS trace_spans_trace ON trace_spans(trace_id);
|
|
162
|
+
BEGIN IMMEDIATE;`);let i=r.prepare(`INSERT INTO trace_spans VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
|
163
|
+
ON CONFLICT(id) DO UPDATE SET status=CASE WHEN excluded.revision >= trace_spans.revision THEN excluded.status ELSE trace_spans.status END,
|
|
164
|
+
started_at=COALESCE(trace_spans.started_at,excluded.started_at),
|
|
165
|
+
ended_at=CASE WHEN excluded.revision < trace_spans.revision THEN trace_spans.ended_at
|
|
166
|
+
WHEN excluded.status IN ('running','pending','waiting','unknown') THEN NULL
|
|
167
|
+
ELSE COALESCE(trace_spans.ended_at,excluded.ended_at) END, updated_at=MAX(trace_spans.updated_at,excluded.updated_at),
|
|
168
|
+
revision=MAX(trace_spans.revision,excluded.revision),
|
|
169
|
+
data=CASE WHEN excluded.revision >= trace_spans.revision THEN excluded.data ELSE trace_spans.data END
|
|
170
|
+
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:jt(s.name,240),summary:s.summary?jt(s.summary,1e3):void 0,attributes:Object.fromEntries(Object.entries(s.attributes??{}).slice(0,20).map(([d,f])=>[jt(d,80),Array.isArray(f)?f.slice(0,30).map(u=>jt(u,240)):typeof f=="string"?jt(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 d=Object.keys(a.attributes).reverse().find(f=>f!=="truncated");if(d)delete a.attributes[d];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=Uh("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*Hh).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(Yh),r.exec("COMMIT")}finally{r.close()}}async function sl(n,e){let t=io.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=ro.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??il(),spanId:il(),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 ol(await n.projectRoot(),f)}catch{}}let s,a,c=!1;try{s=await io.run(o,e)}catch(f){c=!0,a=f}let l=new Date().toISOString(),d=c?"failed":"succeeded";try{!c&&n.status&&(d=n.status(s))}catch{d="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:d}),!r&&o.spans.length)try{await ol(await n.projectRoot(),o.spans)}catch{}if(c)throw a;return s}var Vh=7*864e5,Gh=1e4;async function zh(n,e){let t=Xn(await Zn(n,!0));try{t.exec(`PRAGMA busy_timeout=25; PRAGMA journal_mode=WAL;
|
|
171
|
+
CREATE TABLE IF NOT EXISTS samples (
|
|
172
|
+
id TEXT PRIMARY KEY, workflow TEXT NOT NULL, kind TEXT NOT NULL, command TEXT NOT NULL,
|
|
173
|
+
occurredAt TEXT NOT NULL, durationMs REAL NOT NULL, exitCode INTEGER NOT NULL,
|
|
174
|
+
gitCommands INTEGER NOT NULL, gitDurationMs REAL NOT NULL);
|
|
175
|
+
CREATE INDEX IF NOT EXISTS samples_time ON samples(occurredAt);
|
|
176
|
+
BEGIN IMMEDIATE;`),t.prepare("DELETE FROM samples WHERE occurredAt < ?").run(new Date(Date.now()-Vh).toISOString()),t.prepare("INSERT INTO samples VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)").run(Jh(),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(Gh),t.exec("COMMIT")}finally{t.close()}}async function cl(n,e){let t=al.now(),r,i,o=!1,s=1,a=!0,{metrics:c}=await sl({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"}},()=>nl(async()=>{try{r=await e()}catch(d){o=!0,i=d}})),l=Math.max(0,al.now()-t);try{if(!a)throw new Error("Runtime result classification unavailable");await zh(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 Qh(n,e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:n,exitCode:e.exitCode,agent:zc(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}})+`
|
|
177
|
+
`,...e.envelope===void 0?{}:{envelope:e.envelope}}}async function ul(n,e,t,r={}){let i=t.indexOf("--"),o=l=>i<0||l<i,s=t.some((l,d)=>o(d)&&l==="--json"),a=t.filter((l,d)=>!o(d)||l!=="--json"),c;try{let l=Gc(n,a),d=()=>e(a,{json:s,invocationCwd:r.invocationCwd??process.cwd(),...r.projectRoot?{projectRoot:r.projectRoot}:{}});c=l?{exitCode:0,stdout:l}:n==="hook-guard"?await d():await tl(()=>cl({projectRoot:()=>r.projectRoot??Te(r.invocationCwd??process.cwd()),workflow:"classic",command:n,errorExitCode:f=>f instanceof Ae?1:70},d))}catch(l){c={exitCode:l instanceof Ae?1:70,stderr:l instanceof Error?l.message:String(l),data:{issues:[Xc(l)]}}}return s?Qh(n,c):c}function fl(n,e){return async(t,r={})=>t[0]!==n?{exitCode:64,stderr:`Expected Classic command: ${n}`}:ul(n,e,t.slice(1),r)}function dl(n){let e=process.argv[1];if(!e)return!1;if(n===ll(e).href)return!0;try{return n===ll(Xh(e)).href}catch{return!1}}async function ml(n,e,t=process.argv.slice(2)){let r=await ul(n,e,t);return r.stdout&&process.stdout.write(r.stdout),r.stderr&&process.stderr.write(r.stderr+(r.stderr.endsWith(`
|
|
178
|
+
`)?"":`
|
|
179
|
+
`)),r.exitCode}var Gk=fl("check",eo);dl(import.meta.url)&&(process.exitCode=await ml("check",eo));export{Gk as runClassicCli};
|