@codehourra/llm-iwiki 0.3.1 → 0.3.2
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/dist/index.js +133 -132
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as EH}from"node:module";var V=(_,$)=>()=>($||_(($={exports:{}}).exports,$),$.exports);var
|
|
3
|
-
`)}}k.defaultYaml={explicit:!1,version:"1.2"};k.defaultTags={"!!":"tag:yaml.org,2002:"};
|
|
2
|
+
import{createRequire as EH}from"node:module";var V=(_,$)=>()=>($||_(($={exports:{}}).exports,$),$.exports);var W$=EH(import.meta.url);var S=V((hH)=>{var G0=Symbol.for("yaml.alias"),tq=Symbol.for("yaml.document"),G$=Symbol.for("yaml.map"),eq=Symbol.for("yaml.pair"),R0=Symbol.for("yaml.scalar"),R$=Symbol.for("yaml.seq"),n=Symbol.for("yaml.node.type"),jH=(_)=>!!_&&typeof _==="object"&&_[n]===G0,bH=(_)=>!!_&&typeof _==="object"&&_[n]===tq,yH=(_)=>!!_&&typeof _==="object"&&_[n]===G$,gH=(_)=>!!_&&typeof _==="object"&&_[n]===eq,_1=(_)=>!!_&&typeof _==="object"&&_[n]===R0,xH=(_)=>!!_&&typeof _==="object"&&_[n]===R$;function $1(_){if(_&&typeof _==="object")switch(_[n]){case G$:case R$:return!0}return!1}function kH(_){if(_&&typeof _==="object")switch(_[n]){case G0:case G$:case R0:case R$:return!0}return!1}var uH=(_)=>(_1(_)||$1(_))&&!!_.anchor;hH.ALIAS=G0;hH.DOC=tq;hH.MAP=G$;hH.NODE_TYPE=n;hH.PAIR=eq;hH.SCALAR=R0;hH.SEQ=R$;hH.hasAnchor=uH;hH.isAlias=jH;hH.isCollection=$1;hH.isDocument=bH;hH.isMap=yH;hH.isNode=kH;hH.isPair=gH;hH.isScalar=_1;hH.isSeq=xH});var y_=V((q2)=>{var b=S(),g=Symbol("break visit"),q1=Symbol("skip children"),p=Symbol("remove node");function Y$(_,$){let q=T1($);if(b.isDocument(_)){if(A_(null,_.contents,q,Object.freeze([_]))===p)_.contents=null}else A_(null,_,q,Object.freeze([]))}Y$.BREAK=g;Y$.SKIP=q1;Y$.REMOVE=p;function A_(_,$,q,T){let O=O1(_,$,q,T);if(b.isNode(O)||b.isPair(O))return H1(_,T,O),A_(_,O,q,T);if(typeof O!=="symbol"){if(b.isCollection($)){T=Object.freeze(T.concat($));for(let H=0;H<$.items.length;++H){let X=A_(H,$.items[H],q,T);if(typeof X==="number")H=X-1;else if(X===g)return g;else if(X===p)$.items.splice(H,1),H-=1}}else if(b.isPair($)){T=Object.freeze(T.concat($));let H=A_("key",$.key,q,T);if(H===g)return g;else if(H===p)$.key=null;let X=A_("value",$.value,q,T);if(X===g)return g;else if(X===p)$.value=null}}return O}async function L$(_,$){let q=T1($);if(b.isDocument(_)){if(await M_(null,_.contents,q,Object.freeze([_]))===p)_.contents=null}else await M_(null,_,q,Object.freeze([]))}L$.BREAK=g;L$.SKIP=q1;L$.REMOVE=p;async function M_(_,$,q,T){let O=await O1(_,$,q,T);if(b.isNode(O)||b.isPair(O))return H1(_,T,O),M_(_,O,q,T);if(typeof O!=="symbol"){if(b.isCollection($)){T=Object.freeze(T.concat($));for(let H=0;H<$.items.length;++H){let X=await M_(H,$.items[H],q,T);if(typeof X==="number")H=X-1;else if(X===g)return g;else if(X===p)$.items.splice(H,1),H-=1}}else if(b.isPair($)){T=Object.freeze(T.concat($));let H=await M_("key",$.key,q,T);if(H===g)return g;else if(H===p)$.key=null;let X=await M_("value",$.value,q,T);if(X===g)return g;else if(X===p)$.value=null}}return O}function T1(_){if(typeof _==="object"&&(_.Collection||_.Node||_.Value))return Object.assign({Alias:_.Node,Map:_.Node,Scalar:_.Node,Seq:_.Node},_.Value&&{Map:_.Value,Scalar:_.Value,Seq:_.Value},_.Collection&&{Map:_.Collection,Seq:_.Collection},_);return _}function O1(_,$,q,T){if(typeof q==="function")return q(_,$,T);if(b.isMap($))return q.Map?.(_,$,T);if(b.isSeq($))return q.Seq?.(_,$,T);if(b.isPair($))return q.Pair?.(_,$,T);if(b.isScalar($))return q.Scalar?.(_,$,T);if(b.isAlias($))return q.Alias?.(_,$,T);return}function H1(_,$,q){let T=$[$.length-1];if(b.isCollection(T))T.items[_]=q;else if(b.isPair(T))if(_==="key")T.key=q;else T.value=q;else if(b.isDocument(T))T.contents=q;else{let O=b.isAlias(T)?"alias":"scalar";throw Error(`Cannot replace node with ${O} parent`)}}q2.visit=Y$;q2.visitAsync=L$});var Y0=V((Z2)=>{var X1=S(),H2=y_(),X2={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},U2=(_)=>_.replace(/[!,[\]{}]/g,($)=>X2[$]);class k{constructor(_,$){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},k.defaultYaml,_),this.tags=Object.assign({},k.defaultTags,$)}clone(){let _=new k(this.yaml,this.tags);return _.docStart=this.docStart,_}atDocument(){let _=new k(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:k.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},k.defaultTags);break}return _}add(_,$){if(this.atNextDocument)this.yaml={explicit:k.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},k.defaultTags),this.atNextDocument=!1;let q=_.trim().split(/[ \t]+/),T=q.shift();switch(T){case"%TAG":{if(q.length!==2){if($(0,"%TAG directive should contain exactly two parts"),q.length<2)return!1}let[O,H]=q;return this.tags[O]=H,!0}case"%YAML":{if(this.yaml.explicit=!0,q.length!==1)return $(0,"%YAML directive should contain exactly one part"),!1;let[O]=q;if(O==="1.1"||O==="1.2")return this.yaml.version=O,!0;else{let H=/^\d+\.\d+$/.test(O);return $(6,`Unsupported YAML version ${O}`,H),!1}}default:return $(0,`Unknown directive ${T}`,!0),!1}}tagName(_,$){if(_==="!")return"!";if(_[0]!=="!")return $(`Not a valid tag: ${_}`),null;if(_[1]==="<"){let H=_.slice(2,-1);if(H==="!"||H==="!!")return $(`Verbatim tags aren't resolved, so ${_} is invalid.`),null;if(_[_.length-1]!==">")$("Verbatim tags must end with a >");return H}let[,q,T]=_.match(/^(.*!)([^!]*)$/s);if(!T)$(`The ${_} tag has no suffix`);let O=this.tags[q];if(O)try{return O+decodeURIComponent(T)}catch(H){return $(String(H)),null}if(q==="!")return _;return $(`Could not resolve tag: ${_}`),null}tagString(_){for(let[$,q]of Object.entries(this.tags))if(_.startsWith(q))return $+U2(_.substring(q.length));return _[0]==="!"?_:`!<${_}>`}toString(_){let $=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],q=Object.entries(this.tags),T;if(_&&q.length>0&&X1.isNode(_.contents)){let O={};H2.visit(_.contents,(H,X)=>{if(X1.isNode(X)&&X.tag)O[X.tag]=!0}),T=Object.keys(O)}else T=[];for(let[O,H]of q){if(O==="!!"&&H==="tag:yaml.org,2002:")continue;if(!_||T.some((X)=>X.startsWith(H)))$.push(`%TAG ${O} ${H}`)}return $.join(`
|
|
3
|
+
`)}}k.defaultYaml={explicit:!1,version:"1.2"};k.defaultTags={"!!":"tag:yaml.org,2002:"};Z2.Directives=k});var V$=V((G2)=>{var U1=S(),z2=y_();function Q2(_){if(/[\x00-\x19\s,[\]{}]/.test(_)){let q=`Anchor must not contain whitespace or control characters: ${JSON.stringify(_)}`;throw Error(q)}return!0}function Z1(_){let $=new Set;return z2.visit(_,{Value(q,T){if(T.anchor)$.add(T.anchor)}}),$}function J1(_,$){for(let q=1;;++q){let T=`${_}${q}`;if(!$.has(T))return T}}function W2(_,$){let q=[],T=new Map,O=null;return{onAnchor:(H)=>{q.push(H),O??(O=Z1(_));let X=J1($,O);return O.add(X),X},setAnchors:()=>{for(let H of q){let X=T.get(H);if(typeof X==="object"&&X.anchor&&(U1.isScalar(X.node)||U1.isCollection(X.node)))X.node.anchor=X.anchor;else{let U=Error("Failed to resolve repeated object (this should not happen)");throw U.source=H,U}}},sourceObjects:T}}G2.anchorIsValid=Q2;G2.anchorNames=Z1;G2.createNodeAnchors=W2;G2.findNewAnchor=J1});var L0=V((B2)=>{function g_(_,$,q,T){if(T&&typeof T==="object")if(Array.isArray(T))for(let O=0,H=T.length;O<H;++O){let X=T[O],U=g_(_,T,String(O),X);if(U===void 0)delete T[O];else if(U!==X)T[O]=U}else if(T instanceof Map)for(let O of Array.from(T.keys())){let H=T.get(O),X=g_(_,T,O,H);if(X===void 0)T.delete(O);else if(X!==H)T.set(O,X)}else if(T instanceof Set)for(let O of Array.from(T)){let H=g_(_,T,O,O);if(H===void 0)T.delete(O);else if(H!==O)T.delete(O),T.add(H)}else for(let[O,H]of Object.entries(T)){let X=g_(_,T,O,H);if(X===void 0)delete T[O];else if(X!==H)T[O]=X}return _.call($,q,T)}B2.applyReviver=g_});var e=V((A2)=>{var D2=S();function z1(_,$,q){if(Array.isArray(_))return _.map((T,O)=>z1(T,String(O),q));if(_&&typeof _.toJSON==="function"){if(!q||!D2.hasAnchor(_))return _.toJSON($,q);let T={aliasCount:0,count:1,res:void 0};q.anchors.set(_,T),q.onCreate=(H)=>{T.res=H,delete q.onCreate};let O=_.toJSON($,q);if(q.onCreate)q.onCreate(O);return O}if(typeof _==="bigint"&&!q?.keep)return Number(_);return _}A2.toJS=z1});var B$=V((S2)=>{var I2=L0(),Q1=S(),F2=e();class W1{constructor(_){Object.defineProperty(this,Q1.NODE_TYPE,{value:_})}clone(){let _=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)_.range=this.range.slice();return _}toJS(_,{mapAsMap:$,maxAliasCount:q,onAnchor:T,reviver:O}={}){if(!Q1.isDocument(_))throw TypeError("A document argument is required");let H={anchors:new Map,doc:_,keep:!0,mapAsMap:$===!0,mapKeyWarned:!1,maxAliasCount:typeof q==="number"?q:100},X=F2.toJS(this,"",H);if(typeof T==="function")for(let{count:U,res:Z}of H.anchors.values())T(Z,U);return typeof O==="function"?I2.applyReviver(O,{"":X},"",X):X}}S2.NodeBase=W1});var x_=V((E2)=>{var N2=V$(),C2=y_(),I_=S(),P2=B$(),f2=e();class G1 extends P2.NodeBase{constructor(_){super(I_.ALIAS);this.source=_,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(_,$){if($?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let q;if($?.aliasResolveCache)q=$.aliasResolveCache;else if(q=[],C2.visit(_,{Node:(O,H)=>{if(I_.isAlias(H)||I_.hasAnchor(H))q.push(H)}}),$)$.aliasResolveCache=q;let T=void 0;for(let O of q){if(O===this)break;if(O.anchor===this.source)T=O}return T}toJSON(_,$){if(!$)return{source:this.source};let{anchors:q,doc:T,maxAliasCount:O}=$,H=this.resolve(T,$);if(!H){let U=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(U)}let X=q.get(H);if(!X)f2.toJS(H,null,$),X=q.get(H);if(X?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(O>=0){if(X.count+=1,X.aliasCount===0)X.aliasCount=w$(T,H,q);if(X.count*X.aliasCount>O)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return X.res}toString(_,$,q){let T=`*${this.source}`;if(_){if(N2.anchorIsValid(this.source),_.options.verifyAliasOrder&&!_.anchors.has(this.source)){let O=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(O)}if(_.implicitKey)return`${T} `}return T}}function w$(_,$,q){if(I_.isAlias($)){let T=$.resolve(_),O=q&&T&&q.get(T);return O?O.count*O.aliasCount:0}else if(I_.isCollection($)){let T=0;for(let O of $.items){let H=w$(_,O,q);if(H>T)T=H}return T}else if(I_.isPair($)){let T=w$(_,$.key,q),O=w$(_,$.value,q);return Math.max(T,O)}return 1}E2.Alias=G1});var f=V((k2)=>{var b2=S(),y2=B$(),g2=e(),x2=(_)=>!_||typeof _!=="function"&&typeof _!=="object";class Q_ extends y2.NodeBase{constructor(_){super(b2.SCALAR);this.value=_}toJSON(_,$){return $?.keep?this.value:g2.toJS(this.value,_,$)}toString(){return String(this.value)}}Q_.BLOCK_FOLDED="BLOCK_FOLDED";Q_.BLOCK_LITERAL="BLOCK_LITERAL";Q_.PLAIN="PLAIN";Q_.QUOTE_DOUBLE="QUOTE_DOUBLE";Q_.QUOTE_SINGLE="QUOTE_SINGLE";k2.Scalar=Q_;k2.isScalarValue=x2});var k_=V((d2)=>{var v2=x_(),W_=S(),R1=f(),m2="tag:yaml.org,2002:";function l2(_,$,q){if($){let T=q.filter((H)=>H.tag===$),O=T.find((H)=>!H.format)??T[0];if(!O)throw Error(`Tag ${$} not found`);return O}return q.find((T)=>T.identify?.(_)&&!T.format)}function p2(_,$,q){if(W_.isDocument(_))_=_.contents;if(W_.isNode(_))return _;if(W_.isPair(_)){let Q=q.schema[W_.MAP].createNode?.(q.schema,null,q);return Q.items.push(_),Q}if(_ instanceof String||_ instanceof Number||_ instanceof Boolean||typeof BigInt<"u"&&_ instanceof BigInt)_=_.valueOf();let{aliasDuplicateObjects:T,onAnchor:O,onTagObj:H,schema:X,sourceObjects:U}=q,Z=void 0;if(T&&_&&typeof _==="object")if(Z=U.get(_),Z)return Z.anchor??(Z.anchor=O(_)),new v2.Alias(Z.anchor);else Z={anchor:null,node:null},U.set(_,Z);if($?.startsWith("!!"))$=m2+$.slice(2);let J=l2(_,$,X.tags);if(!J){if(_&&typeof _.toJSON==="function")_=_.toJSON();if(!_||typeof _!=="object"){let Q=new R1.Scalar(_);if(Z)Z.node=Q;return Q}J=_ instanceof Map?X[W_.MAP]:(Symbol.iterator in Object(_))?X[W_.SEQ]:X[W_.MAP]}if(H)H(J),delete q.onTagObj;let z=J?.createNode?J.createNode(q.schema,_,q):typeof J?.nodeClass?.from==="function"?J.nodeClass.from(q.schema,_,q):new R1.Scalar(_);if($)z.tag=$;else if(!J.default)z.tag=J.tag;if(Z)Z.node=z;return z}d2.createNode=p2});var D$=V((n2)=>{var s2=k_(),d=S(),i2=B$();function V0(_,$,q){let T=q;for(let O=$.length-1;O>=0;--O){let H=$[O];if(typeof H==="number"&&Number.isInteger(H)&&H>=0){let X=[];X[H]=T,T=X}else T=new Map([[H,T]])}return s2.createNode(T,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:_,sourceObjects:new Map})}var Y1=(_)=>_==null||typeof _==="object"&&!!_[Symbol.iterator]().next().done;class L1 extends i2.NodeBase{constructor(_,$){super(_);Object.defineProperty(this,"schema",{value:$,configurable:!0,enumerable:!1,writable:!0})}clone(_){let $=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(_)$.schema=_;if($.items=$.items.map((q)=>d.isNode(q)||d.isPair(q)?q.clone(_):q),this.range)$.range=this.range.slice();return $}addIn(_,$){if(Y1(_))this.add($);else{let[q,...T]=_,O=this.get(q,!0);if(d.isCollection(O))O.addIn(T,$);else if(O===void 0&&this.schema)this.set(q,V0(this.schema,T,$));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${T}`)}}deleteIn(_){let[$,...q]=_;if(q.length===0)return this.delete($);let T=this.get($,!0);if(d.isCollection(T))return T.deleteIn(q);else throw Error(`Expected YAML collection at ${$}. Remaining path: ${q}`)}getIn(_,$){let[q,...T]=_,O=this.get(q,!0);if(T.length===0)return!$&&d.isScalar(O)?O.value:O;else return d.isCollection(O)?O.getIn(T,$):void 0}hasAllNullValues(_){return this.items.every(($)=>{if(!d.isPair($))return!1;let q=$.value;return q==null||_&&d.isScalar(q)&&q.value==null&&!q.commentBefore&&!q.comment&&!q.tag})}hasIn(_){let[$,...q]=_;if(q.length===0)return this.has($);let T=this.get($,!0);return d.isCollection(T)?T.hasIn(q):!1}setIn(_,$){let[q,...T]=_;if(T.length===0)this.set(q,$);else{let O=this.get(q,!0);if(d.isCollection(O))O.setIn(T,$);else if(O===void 0&&this.schema)this.set(q,V0(this.schema,T,$));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${T}`)}}}n2.Collection=L1;n2.collectionFromPath=V0;n2.isEmptyPath=Y1});var u_=V((_9)=>{var t2=(_)=>_.replace(/^(?!$)(?: $)?/gm,"#");function B0(_,$){if(/^\n+$/.test(_))return _.substring(1);return $?_.replace(/^(?! *$)/gm,$):_}var e2=(_,$,q)=>_.endsWith(`
|
|
4
4
|
`)?B0(q,$):q.includes(`
|
|
5
5
|
`)?`
|
|
6
|
-
`+B0(q,$):(_.endsWith(" ")?"":" ")+q;_9.indentComment=B0;_9.lineComment=e2;_9.stringifyComment=t2});var
|
|
7
|
-
`){if(q==="block")
|
|
8
|
-
`&&Y!=="\t"){let M=_[
|
|
9
|
-
`&&M!=="\t")
|
|
6
|
+
`+B0(q,$):(_.endsWith(" ")?"":" ")+q;_9.indentComment=B0;_9.lineComment=e2;_9.stringifyComment=t2});var B1=V((H9)=>{function O9(_,$,q="flow",{indentAtStart:T,lineWidth:O=80,minContentWidth:H=20,onFold:X,onOverflow:U}={}){if(!O||O<0)return _;if(O<H)H=0;let Z=Math.max(1+H,1+O-$.length);if(_.length<=Z)return _;let J=[],z={},Q=O-$.length;if(typeof T==="number")if(T>O-Math.max(2,H))J.push(0);else Q=O-T;let W=void 0,Y=void 0,R=!1,G=-1,L=-1,B=-1;if(q==="block"){if(G=V1(_,G,$.length),G!==-1)Q=G+Z}for(let A;A=_[G+=1];){if(q==="quoted"&&A==="\\"){switch(L=G,_[G+1]){case"x":G+=3;break;case"u":G+=5;break;case"U":G+=9;break;default:G+=1}B=G}if(A===`
|
|
7
|
+
`){if(q==="block")G=V1(_,G,$.length);Q=G+$.length+Z,W=void 0}else{if(A===" "&&Y&&Y!==" "&&Y!==`
|
|
8
|
+
`&&Y!=="\t"){let M=_[G+1];if(M&&M!==" "&&M!==`
|
|
9
|
+
`&&M!=="\t")W=G}if(G>=Q)if(W)J.push(W),Q=W+Z,W=void 0;else if(q==="quoted"){while(Y===" "||Y==="\t")Y=A,A=_[G+=1],R=!0;let M=G>B+1?G-2:L-1;if(z[M])return _;J.push(M),z[M]=!0,Q=M+Z,W=void 0}else R=!0}Y=A}if(R&&U)U();if(J.length===0)return _;if(X)X();let D=_.slice(0,J[0]);for(let A=0;A<J.length;++A){let M=J[A],I=J[A+1]||_.length;if(M===0)D=`
|
|
10
10
|
${$}${_.slice(0,I)}`;else{if(q==="quoted"&&z[M])D+=`${_[M]}\\`;D+=`
|
|
11
|
-
${$}${_.slice(M+1,I)}`}}return D}function
|
|
12
|
-
`);T=$,O=$+1,H=_[O]}return T}H9.FOLD_BLOCK="block";H9.FOLD_FLOW="flow";H9.FOLD_QUOTED="quoted";H9.foldFlowLines=O9});var v_=V((
|
|
13
|
-
`){if(H-X>T)return!0;if(X=H+1,O-X<=T)return!1}return!0}function h_(_,$){let q=JSON.stringify(_);if($.options.doubleQuotedAsJSON)return q;let{implicitKey:T}=$,O=$.options.doubleQuotedMinMultiLineLength,H=$.indent||(I$(_)?" ":""),X="",U=0;for(let
|
|
11
|
+
${$}${_.slice(M+1,I)}`}}return D}function V1(_,$,q){let T=$,O=$+1,H=_[O];while(H===" "||H==="\t")if($<O+q)H=_[++$];else{do H=_[++$];while(H&&H!==`
|
|
12
|
+
`);T=$,O=$+1,H=_[O]}return T}H9.FOLD_BLOCK="block";H9.FOLD_FLOW="flow";H9.FOLD_QUOTED="quoted";H9.foldFlowLines=O9});var v_=V((G9)=>{var v=f(),__=B1(),M$=(_,$)=>({indentAtStart:$?_.indent.length:_.indentAtStart,lineWidth:_.options.lineWidth,minContentWidth:_.options.minContentWidth}),I$=(_)=>/^(%|---|\.\.\.)/m.test(_);function z9(_,$,q){if(!$||$<0)return!1;let T=$-q,O=_.length;if(O<=T)return!1;for(let H=0,X=0;H<O;++H)if(_[H]===`
|
|
13
|
+
`){if(H-X>T)return!0;if(X=H+1,O-X<=T)return!1}return!0}function h_(_,$){let q=JSON.stringify(_);if($.options.doubleQuotedAsJSON)return q;let{implicitKey:T}=$,O=$.options.doubleQuotedMinMultiLineLength,H=$.indent||(I$(_)?" ":""),X="",U=0;for(let Z=0,J=q[Z];J;J=q[++Z]){if(J===" "&&q[Z+1]==="\\"&&q[Z+2]==="n")X+=q.slice(U,Z)+"\\ ",Z+=1,U=Z,J="\\";if(J==="\\")switch(q[Z+1]){case"u":{X+=q.slice(U,Z);let z=q.substr(Z+2,4);switch(z){case"0000":X+="\\0";break;case"0007":X+="\\a";break;case"000b":X+="\\v";break;case"001b":X+="\\e";break;case"0085":X+="\\N";break;case"00a0":X+="\\_";break;case"2028":X+="\\L";break;case"2029":X+="\\P";break;default:if(z.substr(0,2)==="00")X+="\\x"+z.substr(2);else X+=q.substr(Z,6)}Z+=5,U=Z+1}break;case"n":if(T||q[Z+2]==='"'||q.length<O)Z+=1;else{X+=q.slice(U,Z)+`
|
|
14
14
|
|
|
15
|
-
`;while(q[
|
|
16
|
-
`,
|
|
15
|
+
`;while(q[Z+2]==="\\"&&q[Z+3]==="n"&&q[Z+4]!=='"')X+=`
|
|
16
|
+
`,Z+=2;if(X+=H,q[Z+2]===" ")X+="\\";Z+=1,U=Z+1}break;default:Z+=1}}return X=U?X+q.slice(U):q,T?X:__.foldFlowLines(X,H,__.FOLD_QUOTED,M$($,!1))}function w0(_,$){if($.options.singleQuote===!1||$.implicitKey&&_.includes(`
|
|
17
17
|
`)||/[ \t]\n|\n[ \t]/.test(_))return h_(_,$);let q=$.indent||(I$(_)?" ":""),T="'"+_.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
18
18
|
${q}`)+"'";return $.implicitKey?T:__.foldFlowLines(T,q,__.FOLD_FLOW,M$($,!1))}function F_(_,$){let{singleQuote:q}=$.options,T;if(q===!1)T=h_;else{let O=_.includes('"'),H=_.includes("'");if(O&&!H)T=w0;else if(H&&!O)T=h_;else T=q?w0:h_}return T(_,$)}var D0;try{D0=new RegExp(`(^|(?<!
|
|
19
19
|
))
|
|
20
20
|
+(?!
|
|
21
|
-
|$)`,"g")}catch{D0=/\n+(?!\n|$)/g}function A$({comment:_,type:$,value:q},T,O,H){let{blockQuote:X,commentString:U,lineWidth:
|
|
21
|
+
|$)`,"g")}catch{D0=/\n+(?!\n|$)/g}function A$({comment:_,type:$,value:q},T,O,H){let{blockQuote:X,commentString:U,lineWidth:Z}=T.options;if(!X||/\n[\t ]+$/.test(q))return F_(q,T);let J=T.indent||(T.forceBlockIndent||I$(q)?" ":""),z=X==="literal"?!0:X==="folded"||$===v.Scalar.BLOCK_FOLDED?!1:$===v.Scalar.BLOCK_LITERAL?!0:!z9(q,Z,J.length);if(!q)return z?`|
|
|
22
22
|
`:`>
|
|
23
|
-
`;let
|
|
24
|
-
`&&I!=="\t"&&I!==" ")break}let Y=q.substring(
|
|
25
|
-
`);if(R===-1)
|
|
26
|
-
`)Y=Y.slice(0,-1);Y=Y.replace(D0,`$&${
|
|
27
|
-
`)B=L;else break}let D=q.substring(0,B<L?B+1:L);if(D)q=q.substring(D.length),D=D.replace(/\n+/g,`$&${
|
|
28
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${
|
|
29
|
-
${
|
|
30
|
-
${
|
|
23
|
+
`;let Q,W;for(W=q.length;W>0;--W){let I=q[W-1];if(I!==`
|
|
24
|
+
`&&I!=="\t"&&I!==" ")break}let Y=q.substring(W),R=Y.indexOf(`
|
|
25
|
+
`);if(R===-1)Q="-";else if(q===Y||R!==Y.length-1){if(Q="+",H)H()}else Q="";if(Y){if(q=q.slice(0,-Y.length),Y[Y.length-1]===`
|
|
26
|
+
`)Y=Y.slice(0,-1);Y=Y.replace(D0,`$&${J}`)}let G=!1,L,B=-1;for(L=0;L<q.length;++L){let I=q[L];if(I===" ")G=!0;else if(I===`
|
|
27
|
+
`)B=L;else break}let D=q.substring(0,B<L?B+1:L);if(D)q=q.substring(D.length),D=D.replace(/\n+/g,`$&${J}`);let M=(G?J?"2":"1":"")+Q;if(_){if(M+=" "+U(_.replace(/ ?[\r\n]+/g," ")),O)O()}if(!z){let I=q.replace(/\n+/g,`
|
|
28
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${J}`),F=!1,K=M$(T,!0);if(X!=="folded"&&$!==v.Scalar.BLOCK_FOLDED)K.onOverflow=()=>{F=!0};let w=__.foldFlowLines(`${D}${I}${Y}`,J,__.FOLD_BLOCK,K);if(!F)return`>${M}
|
|
29
|
+
${J}${w}`}return q=q.replace(/\n+/g,`$&${J}`),`|${M}
|
|
30
|
+
${J}${D}${q}${Y}`}function Q9(_,$,q,T){let{type:O,value:H}=_,{actualString:X,implicitKey:U,indent:Z,indentStep:J,inFlow:z}=$;if(U&&H.includes(`
|
|
31
31
|
`)||z&&/[[\]{},]/.test(H))return F_(H,$);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(H))return U||z||!H.includes(`
|
|
32
32
|
`)?F_(H,$):A$(_,$,q,T);if(!U&&!z&&O!==v.Scalar.PLAIN&&H.includes(`
|
|
33
|
-
`))return A$(_,$,q,T);if(I$(H)){if(
|
|
34
|
-
${
|
|
35
|
-
${$.indent}${U}`}M9.createStringifyContext=B9;M9.stringify=A9});var
|
|
36
|
-
${U}:`}else if(L=`${L}:`,
|
|
37
|
-
`:"",D){let K=
|
|
33
|
+
`))return A$(_,$,q,T);if(I$(H)){if(Z==="")return $.forceBlockIndent=!0,A$(_,$,q,T);else if(U&&Z===J)return F_(H,$)}let Q=H.replace(/\n+/g,`$&
|
|
34
|
+
${Z}`);if(X){let W=(G)=>G.default&&G.tag!=="tag:yaml.org,2002:str"&&G.test?.test(Q),{compat:Y,tags:R}=$.doc.schema;if(R.some(W)||Y?.some(W))return F_(H,$)}return U?Q:__.foldFlowLines(Q,Z,__.FOLD_FLOW,M$($,!1))}function W9(_,$,q,T){let{implicitKey:O,inFlow:H}=$,X=typeof _.value==="string"?_:Object.assign({},_,{value:String(_.value)}),{type:U}=_;if(U!==v.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(X.value))U=v.Scalar.QUOTE_DOUBLE}let Z=(z)=>{switch(z){case v.Scalar.BLOCK_FOLDED:case v.Scalar.BLOCK_LITERAL:return O||H?F_(X.value,$):A$(X,$,q,T);case v.Scalar.QUOTE_DOUBLE:return h_(X.value,$);case v.Scalar.QUOTE_SINGLE:return w0(X.value,$);case v.Scalar.PLAIN:return Q9(X,$,q,T);default:return null}},J=Z(U);if(J===null){let{defaultKeyType:z,defaultStringType:Q}=$.options,W=O&&z||Q;if(J=Z(W),J===null)throw Error(`Unsupported default string type ${W}`)}return J}G9.stringifyString=W9});var m_=V((M9)=>{var Y9=V$(),$_=S(),L9=u_(),V9=v_();function B9(_,$){let q=Object.assign({blockQuote:!0,commentString:L9.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},_.schema.toStringOptions,$),T;switch(q.collectionStyle){case"block":T=!1;break;case"flow":T=!0;break;default:T=null}return{anchors:new Set,doc:_,flowCollectionPadding:q.flowCollectionPadding?" ":"",indent:"",indentStep:typeof q.indent==="number"?" ".repeat(q.indent):" ",inFlow:T,options:q}}function w9(_,$){if($.tag){let O=_.filter((H)=>H.tag===$.tag);if(O.length>0)return O.find((H)=>H.format===$.format)??O[0]}let q=void 0,T;if($_.isScalar($)){T=$.value;let O=_.filter((H)=>H.identify?.(T));if(O.length>1){let H=O.filter((X)=>X.test);if(H.length>0)O=H}q=O.find((H)=>H.format===$.format)??O.find((H)=>!H.format)}else T=$,q=_.find((O)=>O.nodeClass&&T instanceof O.nodeClass);if(!q){let O=T?.constructor?.name??(T===null?"null":typeof T);throw Error(`Tag not resolved for ${O} value`)}return q}function D9(_,$,{anchors:q,doc:T}){if(!T.directives)return"";let O=[],H=($_.isScalar(_)||$_.isCollection(_))&&_.anchor;if(H&&Y9.anchorIsValid(H))q.add(H),O.push(`&${H}`);let X=_.tag??($.default?null:$.tag);if(X)O.push(T.directives.tagString(X));return O.join(" ")}function A9(_,$,q,T){if($_.isPair(_))return _.toString($,q,T);if($_.isAlias(_)){if($.doc.directives)return _.toString($);if($.resolvedAliases?.has(_))throw TypeError("Cannot stringify circular structure without alias nodes");else{if($.resolvedAliases)$.resolvedAliases.add(_);else $.resolvedAliases=new Set([_]);_=_.resolve($.doc)}}let O=void 0,H=$_.isNode(_)?_:$.doc.createNode(_,{onTagObj:(Z)=>O=Z});O??(O=w9($.doc.schema.tags,H));let X=D9(H,O,$);if(X.length>0)$.indentAtStart=($.indentAtStart??0)+X.length+1;let U=typeof O.stringify==="function"?O.stringify(H,$,q,T):$_.isScalar(H)?V9.stringifyString(H,$,q,T):H.toString($,q,T);if(!X)return U;return $_.isScalar(H)||U[0]==="{"||U[0]==="["?`${X} ${U}`:`${X}
|
|
35
|
+
${$.indent}${U}`}M9.createStringifyContext=B9;M9.stringify=A9});var A1=V((K9)=>{var a=S(),w1=f(),D1=m_(),l_=u_();function S9({key:_,value:$},q,T,O){let{allNullValues:H,doc:X,indent:U,indentStep:Z,options:{commentString:J,indentSeq:z,simpleKeys:Q}}=q,W=a.isNode(_)&&_.comment||null;if(Q){if(W)throw Error("With simple keys, key nodes cannot have comments");if(a.isCollection(_)||!a.isNode(_)&&typeof _==="object")throw Error("With simple keys, collection cannot be used as a key value")}let Y=!Q&&(!_||W&&$==null&&!q.inFlow||a.isCollection(_)||(a.isScalar(_)?_.type===w1.Scalar.BLOCK_FOLDED||_.type===w1.Scalar.BLOCK_LITERAL:typeof _==="object"));q=Object.assign({},q,{allNullValues:!1,implicitKey:!Y&&(Q||!H),indent:U+Z});let R=!1,G=!1,L=D1.stringify(_,q,()=>R=!0,()=>G=!0);if(!Y&&!q.inFlow&&L.length>1024){if(Q)throw Error("With simple keys, single line scalar must not span more than 1024 characters");Y=!0}if(q.inFlow){if(H||$==null){if(R&&T)T();return L===""?"?":Y?`? ${L}`:L}}else if(H&&!Q||$==null&&Y){if(L=`? ${L}`,W&&!R)L+=l_.lineComment(L,q.indent,J(W));else if(G&&O)O();return L}if(R)W=null;if(Y){if(W)L+=l_.lineComment(L,q.indent,J(W));L=`? ${L}
|
|
36
|
+
${U}:`}else if(L=`${L}:`,W)L+=l_.lineComment(L,q.indent,J(W));let B,D,A;if(a.isNode($))B=!!$.spaceBefore,D=$.commentBefore,A=$.comment;else if(B=!1,D=null,A=null,$&&typeof $==="object")$=X.createNode($);if(q.implicitKey=!1,!Y&&!W&&a.isScalar($))q.indentAtStart=L.length+1;if(G=!1,!z&&Z.length>=2&&!q.inFlow&&!Y&&a.isSeq($)&&!$.flow&&!$.tag&&!$.anchor)q.indent=q.indent.substring(2);let M=!1,I=D1.stringify($,q,()=>M=!0,()=>G=!0),F=" ";if(W||B||D){if(F=B?`
|
|
37
|
+
`:"",D){let K=J(D);F+=`
|
|
38
38
|
${l_.indentComment(K,q.indent)}`}if(I===""&&!q.inFlow){if(F===`
|
|
39
39
|
`&&A)F=`
|
|
40
40
|
|
|
@@ -42,47 +42,47 @@ ${l_.indentComment(K,q.indent)}`}if(I===""&&!q.inFlow){if(F===`
|
|
|
42
42
|
${q.indent}`}else if(!Y&&a.isCollection($)){let K=I[0],w=I.indexOf(`
|
|
43
43
|
`),E=w!==-1,t=q.inFlow??$.flow??$.items.length===0;if(E||!t){let D_=!1;if(E&&(K==="&"||K==="!")){let j=I.indexOf(" ");if(K==="&"&&j!==-1&&j<w&&I[j+1]==="!")j=I.indexOf(" ",j+1);if(j===-1||w<j)D_=!0}if(!D_)F=`
|
|
44
44
|
${q.indent}`}}else if(I===""||I[0]===`
|
|
45
|
-
`)F="";if(L+=F+I,q.inFlow){if(M&&T)T()}else if(A&&!M)L+=l_.lineComment(L,q.indent,
|
|
46
|
-
${
|
|
45
|
+
`)F="";if(L+=F+I,q.inFlow){if(M&&T)T()}else if(A&&!M)L+=l_.lineComment(L,q.indent,J(A));else if(G&&O)O();return L}K9.stringifyPair=S9});var A0=V((f9)=>{var M1=W$("process");function C9(_,...$){if(_==="debug")console.log(...$)}function P9(_,$){if(_==="debug"||_==="warn")if(typeof M1.emitWarning==="function")M1.emitWarning($);else console.warn($)}f9.debug=C9;f9.warn=P9});var N$=V((y9)=>{var K$=S(),I1=f(),F$="<<",S$={identify:(_)=>_===F$||typeof _==="symbol"&&_.description===F$,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new I1.Scalar(Symbol(F$)),{addToJSMap:F1}),stringify:()=>F$},b9=(_,$)=>(S$.identify($)||K$.isScalar($)&&(!$.type||$.type===I1.Scalar.PLAIN)&&S$.identify($.value))&&_?.doc.schema.tags.some((q)=>q.tag===S$.tag&&q.default);function F1(_,$,q){let T=S1(_,q);if(K$.isSeq(T))for(let O of T.items)M0(_,$,O);else if(Array.isArray(T))for(let O of T)M0(_,$,O);else M0(_,$,T)}function M0(_,$,q){let T=S1(_,q);if(!K$.isMap(T))throw Error("Merge sources must be maps or map aliases");let O=T.toJSON(null,_,Map);for(let[H,X]of O)if($ instanceof Map){if(!$.has(H))$.set(H,X)}else if($ instanceof Set)$.add(H);else if(!Object.prototype.hasOwnProperty.call($,H))Object.defineProperty($,H,{value:X,writable:!0,enumerable:!0,configurable:!0});return $}function S1(_,$){return _&&K$.isAlias($)?$.resolve(_.doc,_):$}y9.addMergeToJSMap=F1;y9.isMergeKey=b9;y9.merge=S$});var F0=V((l9)=>{var u9=A0(),K1=N$(),h9=m_(),N1=S(),I0=e();function v9(_,$,{key:q,value:T}){if(N1.isNode(q)&&q.addToJSMap)q.addToJSMap(_,$,T);else if(K1.isMergeKey(_,q))K1.addMergeToJSMap(_,$,T);else{let O=I0.toJS(q,"",_);if($ instanceof Map)$.set(O,I0.toJS(T,O,_));else if($ instanceof Set)$.add(O);else{let H=m9(q,O,_),X=I0.toJS(T,H,_);if(H in $)Object.defineProperty($,H,{value:X,writable:!0,enumerable:!0,configurable:!0});else $[H]=X}}return $}function m9(_,$,q){if($===null)return"";if(typeof $!=="object")return String($);if(N1.isNode(_)&&q?.doc){let T=h9.createStringifyContext(q.doc,{});T.anchors=new Set;for(let H of q.anchors.keys())T.anchors.add(H.anchor);T.inFlow=!0,T.inStringifyKey=!0;let O=_.toString(T);if(!q.mapKeyWarned){let H=JSON.stringify(O);if(H.length>40)H=H.substring(0,36)+'..."';u9.warn(q.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${H}. Set mapAsMap: true to use object keys.`),q.mapKeyWarned=!0}return O}return JSON.stringify($)}l9.addPairToJSMap=v9});var q_=V((i9)=>{var C1=k_(),d9=A1(),c9=F0(),C$=S();function s9(_,$,q){let T=C1.createNode(_,void 0,q),O=C1.createNode($,void 0,q);return new P$(T,O)}class P${constructor(_,$=null){Object.defineProperty(this,C$.NODE_TYPE,{value:C$.PAIR}),this.key=_,this.value=$}clone(_){let{key:$,value:q}=this;if(C$.isNode($))$=$.clone(_);if(C$.isNode(q))q=q.clone(_);return new P$($,q)}toJSON(_,$){let q=$?.mapAsMap?new Map:{};return c9.addPairToJSMap($,q,this)}toString(_,$,q){return _?.doc?d9.stringifyPair(this,_,$,q):JSON.stringify(this)}}i9.Pair=P$;i9.createPair=s9});var S0=V((e9)=>{var G_=S(),P1=m_(),f$=u_();function r9(_,$,q){return($.inFlow??_.flow?t9:o9)(_,$,q)}function o9({comment:_,items:$},q,{blockItemPrefix:T,flowChars:O,itemIndent:H,onChompKeep:X,onComment:U}){let{indent:Z,options:{commentString:J}}=q,z=Object.assign({},q,{indent:H,type:null}),Q=!1,W=[];for(let R=0;R<$.length;++R){let G=$[R],L=null;if(G_.isNode(G)){if(!Q&&G.spaceBefore)W.push("");if(E$(q,W,G.commentBefore,Q),G.comment)L=G.comment}else if(G_.isPair(G)){let D=G_.isNode(G.key)?G.key:null;if(D){if(!Q&&D.spaceBefore)W.push("");E$(q,W,D.commentBefore,Q)}}Q=!1;let B=P1.stringify(G,z,()=>L=null,()=>Q=!0);if(L)B+=f$.lineComment(B,H,J(L));if(Q&&L)Q=!1;W.push(T+B)}let Y;if(W.length===0)Y=O.start+O.end;else{Y=W[0];for(let R=1;R<W.length;++R){let G=W[R];Y+=G?`
|
|
46
|
+
${Z}${G}`:`
|
|
47
47
|
`}}if(_){if(Y+=`
|
|
48
|
-
`+f$.indentComment(
|
|
49
|
-
`)),R<_.length-1)B+=",";else if($.options.trailingComma){if($.options.lineWidth>0)
|
|
50
|
-
${H}${O}${
|
|
48
|
+
`+f$.indentComment(J(_),Z),U)U()}else if(Q&&X)X();return Y}function t9({items:_},$,{flowChars:q,itemIndent:T}){let{indent:O,indentStep:H,flowCollectionPadding:X,options:{commentString:U}}=$;T+=H;let Z=Object.assign({},$,{indent:T,inFlow:!0,type:null}),J=!1,z=0,Q=[];for(let R=0;R<_.length;++R){let G=_[R],L=null;if(G_.isNode(G)){if(G.spaceBefore)Q.push("");if(E$($,Q,G.commentBefore,!1),G.comment)L=G.comment}else if(G_.isPair(G)){let D=G_.isNode(G.key)?G.key:null;if(D){if(D.spaceBefore)Q.push("");if(E$($,Q,D.commentBefore,!1),D.comment)J=!0}let A=G_.isNode(G.value)?G.value:null;if(A){if(A.comment)L=A.comment;if(A.commentBefore)J=!0}else if(G.value==null&&D?.comment)L=D.comment}if(L)J=!0;let B=P1.stringify(G,Z,()=>L=null);if(J||(J=Q.length>z||B.includes(`
|
|
49
|
+
`)),R<_.length-1)B+=",";else if($.options.trailingComma){if($.options.lineWidth>0)J||(J=Q.reduce((D,A)=>D+A.length+2,2)+(B.length+2)>$.options.lineWidth);if(J)B+=","}if(L)B+=f$.lineComment(B,T,U(L));Q.push(B),z=Q.length}let{start:W,end:Y}=q;if(Q.length===0)return W+Y;else{if(!J){let R=Q.reduce((G,L)=>G+L.length+2,2);J=$.options.lineWidth>0&&R>$.options.lineWidth}if(J){let R=W;for(let G of Q)R+=G?`
|
|
50
|
+
${H}${O}${G}`:`
|
|
51
51
|
`;return`${R}
|
|
52
|
-
${O}${Y}`}else return`${
|
|
53
|
-
`:" ")}return
|
|
52
|
+
${O}${Y}`}else return`${W}${X}${Q.join(" ")}${X}${Y}`}}function E$({indent:_,options:{commentString:$}},q,T,O){if(T&&O)T=T.replace(/^\n+/,"");if(T){let H=f$.indentComment($(T),_);q.push(H.trimStart())}}e9.stringifyCollection=r9});var O_=V((HX)=>{var $X=S0(),qX=F0(),TX=D$(),T_=S(),j$=q_(),OX=f();function p_(_,$){let q=T_.isScalar($)?$.value:$;for(let T of _)if(T_.isPair(T)){if(T.key===$||T.key===q)return T;if(T_.isScalar(T.key)&&T.key.value===q)return T}return}class f1 extends TX.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(_){super(T_.MAP,_);this.items=[]}static from(_,$,q){let{keepUndefined:T,replacer:O}=q,H=new this(_),X=(U,Z)=>{if(typeof O==="function")Z=O.call($,U,Z);else if(Array.isArray(O)&&!O.includes(U))return;if(Z!==void 0||T)H.items.push(j$.createPair(U,Z,q))};if($ instanceof Map)for(let[U,Z]of $)X(U,Z);else if($&&typeof $==="object")for(let U of Object.keys($))X(U,$[U]);if(typeof _.sortMapEntries==="function")H.items.sort(_.sortMapEntries);return H}add(_,$){let q;if(T_.isPair(_))q=_;else if(!_||typeof _!=="object"||!("key"in _))q=new j$.Pair(_,_?.value);else q=new j$.Pair(_.key,_.value);let T=p_(this.items,q.key),O=this.schema?.sortMapEntries;if(T){if(!$)throw Error(`Key ${q.key} already set`);if(T_.isScalar(T.value)&&OX.isScalarValue(q.value))T.value.value=q.value;else T.value=q.value}else if(O){let H=this.items.findIndex((X)=>O(q,X)<0);if(H===-1)this.items.push(q);else this.items.splice(H,0,q)}else this.items.push(q)}delete(_){let $=p_(this.items,_);if(!$)return!1;return this.items.splice(this.items.indexOf($),1).length>0}get(_,$){let T=p_(this.items,_)?.value;return(!$&&T_.isScalar(T)?T.value:T)??void 0}has(_){return!!p_(this.items,_)}set(_,$){this.add(new j$.Pair(_,$),!0)}toJSON(_,$,q){let T=q?new q:$?.mapAsMap?new Map:{};if($?.onCreate)$.onCreate(T);for(let O of this.items)qX.addPairToJSMap($,T,O);return T}toString(_,$,q){if(!_)return JSON.stringify(this);for(let T of this.items)if(!T_.isPair(T))throw Error(`Map items must all be pairs; found ${JSON.stringify(T)} instead`);if(!_.allNullValues&&this.hasAllNullValues(!1))_=Object.assign({},_,{allNullValues:!0});return $X.stringifyCollection(this,_,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:_.indent||"",onChompKeep:q,onComment:$})}}HX.YAMLMap=f1;HX.findPair=p_});var S_=V((zX)=>{var ZX=S(),E1=O_(),JX={collection:"map",default:!0,nodeClass:E1.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(_,$){if(!ZX.isMap(_))$("Expected a mapping for this tag");return _},createNode:(_,$,q)=>E1.YAMLMap.from(_,$,q)};zX.map=JX});var H_=V((VX)=>{var WX=k_(),GX=S0(),RX=D$(),y$=S(),YX=f(),LX=e();class j1 extends RX.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(_){super(y$.SEQ,_);this.items=[]}add(_){this.items.push(_)}delete(_){let $=b$(_);if(typeof $!=="number")return!1;return this.items.splice($,1).length>0}get(_,$){let q=b$(_);if(typeof q!=="number")return;let T=this.items[q];return!$&&y$.isScalar(T)?T.value:T}has(_){let $=b$(_);return typeof $==="number"&&$<this.items.length}set(_,$){let q=b$(_);if(typeof q!=="number")throw Error(`Expected a valid index, not ${_}.`);let T=this.items[q];if(y$.isScalar(T)&&YX.isScalarValue($))T.value=$;else this.items[q]=$}toJSON(_,$){let q=[];if($?.onCreate)$.onCreate(q);let T=0;for(let O of this.items)q.push(LX.toJS(O,String(T++),$));return q}toString(_,$,q){if(!_)return JSON.stringify(this);return GX.stringifyCollection(this,_,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(_.indent||"")+" ",onChompKeep:q,onComment:$})}static from(_,$,q){let{replacer:T}=q,O=new this(_);if($&&Symbol.iterator in Object($)){let H=0;for(let X of $){if(typeof T==="function"){let U=$ instanceof Set?X:String(H++);X=T.call($,U,X)}O.items.push(WX.createNode(X,void 0,q))}}return O}}function b$(_){let $=y$.isScalar(_)?_.value:_;if($&&typeof $==="string")$=Number($);return typeof $==="number"&&Number.isInteger($)&&$>=0?$:null}VX.YAMLSeq=j1});var K_=V((AX)=>{var wX=S(),b1=H_(),DX={collection:"seq",default:!0,nodeClass:b1.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(_,$){if(!wX.isSeq(_))$("Expected a sequence for this tag");return _},createNode:(_,$,q)=>b1.YAMLSeq.from(_,$,q)};AX.seq=DX});var d_=V((SX)=>{var IX=v_(),FX={identify:(_)=>typeof _==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(_)=>_,stringify(_,$,q,T){return $=Object.assign({actualString:!0},$),IX.stringifyString(_,$,q,T)}};SX.string=FX});var g$=V((NX)=>{var y1=f(),g1={identify:(_)=>_==null,createNode:()=>new y1.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new y1.Scalar(null),stringify:({source:_},$)=>typeof _==="string"&&g1.test.test(_)?_:$.options.nullStr};NX.nullTag=g1});var K0=V((fX)=>{var PX=f(),x1={identify:(_)=>typeof _==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(_)=>new PX.Scalar(_[0]==="t"||_[0]==="T"),stringify({source:_,value:$},q){if(_&&x1.test.test(_)){let T=_[0]==="t"||_[0]==="T";if($===T)return _}return $?q.options.trueStr:q.options.falseStr}};fX.boolTag=x1});var N_=V((bX)=>{function jX({format:_,minFractionDigits:$,tag:q,value:T}){if(typeof T==="bigint")return String(T);let O=typeof T==="number"?T:Number(T);if(!isFinite(O))return isNaN(O)?".nan":O<0?"-.inf":".inf";let H=Object.is(T,-0)?"-0":JSON.stringify(T);if(!_&&$&&(!q||q==="tag:yaml.org,2002:float")&&/^-?\d/.test(H)&&!H.includes("e")){let X=H.indexOf(".");if(X<0)X=H.length,H+=".";let U=$-(H.length-X-1);while(U-- >0)H+="0"}return H}bX.stringifyNumber=jX});var C0=V((hX)=>{var gX=f(),N0=N_(),xX={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(_)=>_.slice(-3).toLowerCase()==="nan"?NaN:_[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:N0.stringifyNumber},kX={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(_)=>parseFloat(_),stringify(_){let $=Number(_.value);return isFinite($)?$.toExponential():N0.stringifyNumber(_)}},uX={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(_){let $=new gX.Scalar(parseFloat(_)),q=_.indexOf(".");if(q!==-1&&_[_.length-1]==="0")$.minFractionDigits=_.length-q-1;return $},stringify:N0.stringifyNumber};hX.float=uX;hX.floatExp=kX;hX.floatNaN=xX});var f0=V((sX)=>{var k1=N_(),x$=(_)=>typeof _==="bigint"||Number.isInteger(_),P0=(_,$,q,{intAsBigInt:T})=>T?BigInt(_):parseInt(_.substring($),q);function u1(_,$,q){let{value:T}=_;if(x$(T)&&T>=0)return q+T.toString($);return k1.stringifyNumber(_)}var pX={identify:(_)=>x$(_)&&_>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(_,$,q)=>P0(_,2,8,q),stringify:(_)=>u1(_,8,"0o")},dX={identify:x$,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(_,$,q)=>P0(_,0,10,q),stringify:k1.stringifyNumber},cX={identify:(_)=>x$(_)&&_>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(_,$,q)=>P0(_,2,16,q),stringify:(_)=>u1(_,16,"0x")};sX.int=dX;sX.intHex=cX;sX.intOct=pX});var h1=V((q4)=>{var rX=S_(),oX=g$(),tX=K_(),eX=d_(),_4=K0(),E0=C0(),j0=f0(),$4=[rX.map,tX.seq,eX.string,oX.nullTag,_4.boolTag,j0.intOct,j0.int,j0.intHex,E0.floatNaN,E0.floatExp,E0.float];q4.schema=$4});var m1=V((z4)=>{var O4=f(),H4=S_(),X4=K_();function v1(_){return typeof _==="bigint"||Number.isInteger(_)}var k$=({value:_})=>JSON.stringify(_),U4=[{identify:(_)=>typeof _==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(_)=>_,stringify:k$},{identify:(_)=>_==null,createNode:()=>new O4.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:k$},{identify:(_)=>typeof _==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(_)=>_==="true",stringify:k$},{identify:v1,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(_,$,{intAsBigInt:q})=>q?BigInt(_):parseInt(_,10),stringify:({value:_})=>v1(_)?_.toString():JSON.stringify(_)},{identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(_)=>parseFloat(_),stringify:k$}],Z4={default:!0,tag:"",test:/^/,resolve(_,$){return $(`Unresolved plain scalar ${JSON.stringify(_)}`),_}},J4=[H4.map,X4.seq].concat(U4,Z4);z4.schema=J4});var y0=V((R4)=>{var c_=W$("buffer"),b0=f(),W4=v_(),G4={identify:(_)=>_ instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(_,$){if(typeof c_.Buffer==="function")return c_.Buffer.from(_,"base64");else if(typeof atob==="function"){let q=atob(_.replace(/[\n\r]/g,"")),T=new Uint8Array(q.length);for(let O=0;O<q.length;++O)T[O]=q.charCodeAt(O);return T}else return $("This environment does not support reading binary tags; either Buffer or atob is required"),_},stringify({comment:_,type:$,value:q},T,O,H){if(!q)return"";let X=q,U;if(typeof c_.Buffer==="function")U=X instanceof c_.Buffer?X.toString("base64"):c_.Buffer.from(X.buffer).toString("base64");else if(typeof btoa==="function"){let Z="";for(let J=0;J<X.length;++J)Z+=String.fromCharCode(X[J]);U=btoa(Z)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if($??($=b0.Scalar.BLOCK_LITERAL),$!==b0.Scalar.QUOTE_DOUBLE){let Z=Math.max(T.options.lineWidth-T.indent.length,T.options.minContentWidth),J=Math.ceil(U.length/Z),z=Array(J);for(let Q=0,W=0;Q<J;++Q,W+=Z)z[Q]=U.substr(W,Z);U=z.join($===b0.Scalar.BLOCK_LITERAL?`
|
|
53
|
+
`:" ")}return W4.stringifyString({comment:_,type:$,value:U},T,O,H)}};R4.binary=G4});var h$=V((w4)=>{var u$=S(),g0=q_(),L4=f(),V4=H_();function l1(_,$){if(u$.isSeq(_))for(let q=0;q<_.items.length;++q){let T=_.items[q];if(u$.isPair(T))continue;else if(u$.isMap(T)){if(T.items.length>1)$("Each pair must have its own sequence indicator");let O=T.items[0]||new g0.Pair(new L4.Scalar(null));if(T.commentBefore)O.key.commentBefore=O.key.commentBefore?`${T.commentBefore}
|
|
54
54
|
${O.key.commentBefore}`:T.commentBefore;if(T.comment){let H=O.value??O.key;H.comment=H.comment?`${T.comment}
|
|
55
|
-
${H.comment}`:T.comment}T=O}_.items[q]=u$.isPair(T)?T:new y0.Pair(T)}else $("Expected a sequence for this tag");return _}function lT(_,$,q){let{replacer:T}=q,O=new V4.YAMLSeq(_);O.tag="tag:yaml.org,2002:pairs";let H=0;if($&&Symbol.iterator in Object($))for(let X of $){if(typeof T==="function")X=T.call($,String(H++),X);let U,J;if(Array.isArray(X))if(X.length===2)U=X[0],J=X[1];else throw TypeError(`Expected [key, value] tuple: ${X}`);else if(X&&X instanceof Object){let Z=Object.keys(X);if(Z.length===1)U=Z[0],J=X[U];else throw TypeError(`Expected tuple with one key, not ${Z.length} keys`)}else U=X;O.items.push(y0.createPair(U,J,q))}return O}var B4={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:mT,createNode:lT};w4.createPairs=lT;w4.pairs=B4;w4.resolvePairs=mT});var k0=V((S4)=>{var pT=S(),x0=e(),s_=O_(),I4=H_(),dT=h$();class R_ extends I4.YAMLSeq{constructor(){super();this.add=s_.YAMLMap.prototype.add.bind(this),this.delete=s_.YAMLMap.prototype.delete.bind(this),this.get=s_.YAMLMap.prototype.get.bind(this),this.has=s_.YAMLMap.prototype.has.bind(this),this.set=s_.YAMLMap.prototype.set.bind(this),this.tag=R_.tag}toJSON(_,$){if(!$)return super.toJSON(_);let q=new Map;if($?.onCreate)$.onCreate(q);for(let T of this.items){let O,H;if(pT.isPair(T))O=x0.toJS(T.key,"",$),H=x0.toJS(T.value,O,$);else O=x0.toJS(T,"",$);if(q.has(O))throw Error("Ordered maps must not include duplicate keys");q.set(O,H)}return q}static from(_,$,q){let T=dT.createPairs(_,$,q),O=new this;return O.items=T.items,O}}R_.tag="tag:yaml.org,2002:omap";var F4={collection:"seq",identify:(_)=>_ instanceof Map,nodeClass:R_,default:!1,tag:"tag:yaml.org,2002:omap",resolve(_,$){let q=dT.resolvePairs(_,$),T=[];for(let{key:O}of q.items)if(pT.isScalar(O))if(T.includes(O.value))$(`Ordered maps must not include duplicate keys: ${O.value}`);else T.push(O.value);return Object.assign(new R_,q)},createNode:(_,$,q)=>R_.from(_,$,q)};S4.YAMLOMap=R_;S4.omap=F4});var aT=V((C4)=>{var cT=f();function sT({value:_,source:$},q){if($&&(_?iT:nT).test.test($))return $;return _?q.options.trueStr:q.options.falseStr}var iT={identify:(_)=>_===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new cT.Scalar(!0),stringify:sT},nT={identify:(_)=>_===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new cT.Scalar(!1),stringify:sT};C4.falseTag=nT;C4.trueTag=iT});var rT=V((y4)=>{var E4=f(),u0=N_(),j4={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(_)=>_.slice(-3).toLowerCase()==="nan"?NaN:_[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:u0.stringifyNumber},b4={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(_)=>parseFloat(_.replace(/_/g,"")),stringify(_){let $=Number(_.value);return isFinite($)?$.toExponential():u0.stringifyNumber(_)}},g4={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(_){let $=new E4.Scalar(parseFloat(_.replace(/_/g,""))),q=_.indexOf(".");if(q!==-1){let T=_.substring(q+1).replace(/_/g,"");if(T[T.length-1]==="0")$.minFractionDigits=T.length}return $},stringify:u0.stringifyNumber};y4.float=g4;y4.floatExp=b4;y4.floatNaN=j4});var tT=V((p4)=>{var oT=N_(),i_=(_)=>typeof _==="bigint"||Number.isInteger(_);function v$(_,$,q,{intAsBigInt:T}){let O=_[0];if(O==="-"||O==="+")$+=1;if(_=_.substring($).replace(/_/g,""),T){switch(q){case 2:_=`0b${_}`;break;case 8:_=`0o${_}`;break;case 16:_=`0x${_}`;break}let X=BigInt(_);return O==="-"?BigInt(-1)*X:X}let H=parseInt(_,q);return O==="-"?-1*H:H}function h0(_,$,q){let{value:T}=_;if(i_(T)){let O=T.toString($);return T<0?"-"+q+O.substr(1):q+O}return oT.stringifyNumber(_)}var h4={identify:i_,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(_,$,q)=>v$(_,2,2,q),stringify:(_)=>h0(_,2,"0b")},v4={identify:i_,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(_,$,q)=>v$(_,1,8,q),stringify:(_)=>h0(_,8,"0")},m4={identify:i_,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(_,$,q)=>v$(_,0,10,q),stringify:oT.stringifyNumber},l4={identify:i_,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(_,$,q)=>v$(_,2,16,q),stringify:(_)=>h0(_,16,"0x")};p4.int=m4;p4.intBin=h4;p4.intHex=l4;p4.intOct=v4});var v0=V((a4)=>{var p$=S(),m$=q_(),l$=O_();class Y_ extends l$.YAMLMap{constructor(_){super(_);this.tag=Y_.tag}add(_){let $;if(p$.isPair(_))$=_;else if(_&&typeof _==="object"&&"key"in _&&"value"in _&&_.value===null)$=new m$.Pair(_.key,null);else $=new m$.Pair(_,null);if(!l$.findPair(this.items,$.key))this.items.push($)}get(_,$){let q=l$.findPair(this.items,_);return!$&&p$.isPair(q)?p$.isScalar(q.key)?q.key.value:q.key:q}set(_,$){if(typeof $!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof $}`);let q=l$.findPair(this.items,_);if(q&&!$)this.items.splice(this.items.indexOf(q),1);else if(!q&&$)this.items.push(new m$.Pair(_))}toJSON(_,$){return super.toJSON(_,$,Set)}toString(_,$,q){if(!_)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},_,{allNullValues:!0}),$,q);else throw Error("Set items must all have null values")}static from(_,$,q){let{replacer:T}=q,O=new this(_);if($&&Symbol.iterator in Object($))for(let H of $){if(typeof T==="function")H=T.call($,H,H);O.items.push(m$.createPair(H,null,q))}return O}}Y_.tag="tag:yaml.org,2002:set";var n4={collection:"map",identify:(_)=>_ instanceof Set,nodeClass:Y_,default:!1,tag:"tag:yaml.org,2002:set",createNode:(_,$,q)=>Y_.from(_,$,q),resolve(_,$){if(p$.isMap(_))if(_.hasAllNullValues(!0))return Object.assign(new Y_,_);else $("Set items must all have null values");else $("Expected a mapping for this tag");return _}};a4.YAMLSet=Y_;a4.set=n4});var l0=V(($8)=>{var t4=N_();function m0(_,$){let q=_[0],T=q==="-"||q==="+"?_.substring(1):_,O=(X)=>$?BigInt(X):Number(X),H=T.replace(/_/g,"").split(":").reduce((X,U)=>X*O(60)+O(U),O(0));return q==="-"?O(-1)*H:H}function eT(_){let{value:$}=_,q=(X)=>X;if(typeof $==="bigint")q=(X)=>BigInt(X);else if(isNaN($)||!isFinite($))return t4.stringifyNumber(_);let T="";if($<0)T="-",$*=q(-1);let O=q(60),H=[$%O];if($<60)H.unshift(0);else if($=($-H[0])/O,H.unshift($%O),$>=60)$=($-H[0])/O,H.unshift($);return T+H.map((X)=>String(X).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var e4={identify:(_)=>typeof _==="bigint"||Number.isInteger(_),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(_,$,{intAsBigInt:q})=>m0(_,q),stringify:eT},_8={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(_)=>m0(_,!1),stringify:eT},_1={identify:(_)=>_ 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(_){let $=_.match(_1.test);if(!$)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,q,T,O,H,X,U]=$.map(Number),J=$[7]?Number(($[7]+"00").substr(1,3)):0,Z=Date.UTC(q,T-1,O,H||0,X||0,U||0,J),z=$[8];if(z&&z!=="Z"){let G=m0(z,!1);if(Math.abs(G)<30)G*=60;Z-=60000*G}return new Date(Z)},stringify:({value:_})=>_?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};$8.floatTime=_8;$8.intTime=e4;$8.timestamp=_1});var q1=V((Y8)=>{var H8=S_(),X8=y$(),U8=K_(),J8=d_(),Z8=g0(),$1=aT(),p0=rT(),d$=tT(),z8=N$(),G8=k0(),Q8=h$(),W8=v0(),d0=l0(),R8=[H8.map,U8.seq,J8.string,X8.nullTag,$1.trueTag,$1.falseTag,d$.intBin,d$.intOct,d$.int,d$.intHex,p0.floatNaN,p0.floatExp,p0.float,Z8.binary,z8.merge,G8.omap,Q8.pairs,W8.set,d0.intTime,d0.floatTime,d0.timestamp];Y8.schema=R8});var Q1=V((F8)=>{var X1=S_(),V8=y$(),U1=K_(),B8=d_(),w8=K0(),c0=C0(),s0=f0(),D8=uT(),A8=vT(),J1=g0(),n_=N$(),Z1=k0(),z1=h$(),T1=q1(),G1=v0(),c$=l0(),O1=new Map([["core",D8.schema],["failsafe",[X1.map,U1.seq,B8.string]],["json",A8.schema],["yaml11",T1.schema],["yaml-1.1",T1.schema]]),H1={binary:J1.binary,bool:w8.boolTag,float:c0.float,floatExp:c0.floatExp,floatNaN:c0.floatNaN,floatTime:c$.floatTime,int:s0.int,intHex:s0.intHex,intOct:s0.intOct,intTime:c$.intTime,map:X1.map,merge:n_.merge,null:V8.nullTag,omap:Z1.omap,pairs:z1.pairs,seq:U1.seq,set:G1.set,timestamp:c$.timestamp},M8={"tag:yaml.org,2002:binary":J1.binary,"tag:yaml.org,2002:merge":n_.merge,"tag:yaml.org,2002:omap":Z1.omap,"tag:yaml.org,2002:pairs":z1.pairs,"tag:yaml.org,2002:set":G1.set,"tag:yaml.org,2002:timestamp":c$.timestamp};function I8(_,$,q){let T=O1.get($);if(T&&!_)return q&&!T.includes(n_.merge)?T.concat(n_.merge):T.slice();let O=T;if(!O)if(Array.isArray(_))O=[];else{let H=Array.from(O1.keys()).filter((X)=>X!=="yaml11").map((X)=>JSON.stringify(X)).join(", ");throw Error(`Unknown schema "${$}"; use one of ${H} or define customTags array`)}if(Array.isArray(_))for(let H of _)O=O.concat(H);else if(typeof _==="function")O=_(O.slice());if(q)O=O.concat(n_.merge);return O.reduce((H,X)=>{let U=typeof X==="string"?H1[X]:X;if(!U){let J=JSON.stringify(X),Z=Object.keys(H1).map((z)=>JSON.stringify(z)).join(", ");throw Error(`Unknown custom tag ${J}; use one of ${Z}`)}if(!H.includes(U))H.push(U);return H},[])}F8.coreKnownTags=M8;F8.getTags=I8});var a0=V((E8)=>{var i0=S(),N8=S_(),C8=K_(),P8=d_(),s$=Q1(),f8=(_,$)=>_.key<$.key?-1:_.key>$.key?1:0;class n0{constructor({compat:_,customTags:$,merge:q,resolveKnownTags:T,schema:O,sortMapEntries:H,toStringDefaults:X}){this.compat=Array.isArray(_)?s$.getTags(_,"compat"):_?s$.getTags(null,_):null,this.name=typeof O==="string"&&O||"core",this.knownTags=T?s$.coreKnownTags:{},this.tags=s$.getTags($,this.name,q),this.toStringOptions=X??null,Object.defineProperty(this,i0.MAP,{value:N8.map}),Object.defineProperty(this,i0.SCALAR,{value:P8.string}),Object.defineProperty(this,i0.SEQ,{value:C8.seq}),this.sortMapEntries=typeof H==="function"?H:H===!0?f8:null}clone(){let _=Object.create(n0.prototype,Object.getOwnPropertyDescriptors(this));return _.tags=this.tags.slice(),_}}E8.Schema=n0});var W1=V((y8)=>{var b8=S(),r0=m_(),a_=u_();function g8(_,$){let q=[],T=$.directives===!0;if($.directives!==!1&&_.directives){let J=_.directives.toString(_);if(J)q.push(J),T=!0;else if(_.directives.docStart)T=!0}if(T)q.push("---");let O=r0.createStringifyContext(_,$),{commentString:H}=O.options;if(_.commentBefore){if(q.length!==1)q.unshift("");let J=H(_.commentBefore);q.unshift(a_.indentComment(J,""))}let X=!1,U=null;if(_.contents){if(b8.isNode(_.contents)){if(_.contents.spaceBefore&&T)q.push("");if(_.contents.commentBefore){let z=H(_.contents.commentBefore);q.push(a_.indentComment(z,""))}O.forceBlockIndent=!!_.comment,U=_.contents.comment}let J=U?void 0:()=>X=!0,Z=r0.stringify(_.contents,O,()=>U=null,J);if(U)Z+=a_.lineComment(Z,"",H(U));if((Z[0]==="|"||Z[0]===">")&&q[q.length-1]==="---")q[q.length-1]=`--- ${Z}`;else q.push(Z)}else q.push(r0.stringify(_.contents,O));if(_.directives?.docEnd)if(_.comment){let J=H(_.comment);if(J.includes(`
|
|
56
|
-
`))q.push("..."),q.push(a_.indentComment(
|
|
55
|
+
${H.comment}`:T.comment}T=O}_.items[q]=u$.isPair(T)?T:new g0.Pair(T)}else $("Expected a sequence for this tag");return _}function p1(_,$,q){let{replacer:T}=q,O=new V4.YAMLSeq(_);O.tag="tag:yaml.org,2002:pairs";let H=0;if($&&Symbol.iterator in Object($))for(let X of $){if(typeof T==="function")X=T.call($,String(H++),X);let U,Z;if(Array.isArray(X))if(X.length===2)U=X[0],Z=X[1];else throw TypeError(`Expected [key, value] tuple: ${X}`);else if(X&&X instanceof Object){let J=Object.keys(X);if(J.length===1)U=J[0],Z=X[U];else throw TypeError(`Expected tuple with one key, not ${J.length} keys`)}else U=X;O.items.push(g0.createPair(U,Z,q))}return O}var B4={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:l1,createNode:p1};w4.createPairs=p1;w4.pairs=B4;w4.resolvePairs=l1});var k0=V((S4)=>{var d1=S(),x0=e(),s_=O_(),I4=H_(),c1=h$();class R_ extends I4.YAMLSeq{constructor(){super();this.add=s_.YAMLMap.prototype.add.bind(this),this.delete=s_.YAMLMap.prototype.delete.bind(this),this.get=s_.YAMLMap.prototype.get.bind(this),this.has=s_.YAMLMap.prototype.has.bind(this),this.set=s_.YAMLMap.prototype.set.bind(this),this.tag=R_.tag}toJSON(_,$){if(!$)return super.toJSON(_);let q=new Map;if($?.onCreate)$.onCreate(q);for(let T of this.items){let O,H;if(d1.isPair(T))O=x0.toJS(T.key,"",$),H=x0.toJS(T.value,O,$);else O=x0.toJS(T,"",$);if(q.has(O))throw Error("Ordered maps must not include duplicate keys");q.set(O,H)}return q}static from(_,$,q){let T=c1.createPairs(_,$,q),O=new this;return O.items=T.items,O}}R_.tag="tag:yaml.org,2002:omap";var F4={collection:"seq",identify:(_)=>_ instanceof Map,nodeClass:R_,default:!1,tag:"tag:yaml.org,2002:omap",resolve(_,$){let q=c1.resolvePairs(_,$),T=[];for(let{key:O}of q.items)if(d1.isScalar(O))if(T.includes(O.value))$(`Ordered maps must not include duplicate keys: ${O.value}`);else T.push(O.value);return Object.assign(new R_,q)},createNode:(_,$,q)=>R_.from(_,$,q)};S4.YAMLOMap=R_;S4.omap=F4});var r1=V((C4)=>{var s1=f();function i1({value:_,source:$},q){if($&&(_?n1:a1).test.test($))return $;return _?q.options.trueStr:q.options.falseStr}var n1={identify:(_)=>_===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new s1.Scalar(!0),stringify:i1},a1={identify:(_)=>_===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new s1.Scalar(!1),stringify:i1};C4.falseTag=a1;C4.trueTag=n1});var o1=V((g4)=>{var E4=f(),u0=N_(),j4={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(_)=>_.slice(-3).toLowerCase()==="nan"?NaN:_[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:u0.stringifyNumber},b4={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(_)=>parseFloat(_.replace(/_/g,"")),stringify(_){let $=Number(_.value);return isFinite($)?$.toExponential():u0.stringifyNumber(_)}},y4={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(_){let $=new E4.Scalar(parseFloat(_.replace(/_/g,""))),q=_.indexOf(".");if(q!==-1){let T=_.substring(q+1).replace(/_/g,"");if(T[T.length-1]==="0")$.minFractionDigits=T.length}return $},stringify:u0.stringifyNumber};g4.float=y4;g4.floatExp=b4;g4.floatNaN=j4});var e1=V((p4)=>{var t1=N_(),i_=(_)=>typeof _==="bigint"||Number.isInteger(_);function v$(_,$,q,{intAsBigInt:T}){let O=_[0];if(O==="-"||O==="+")$+=1;if(_=_.substring($).replace(/_/g,""),T){switch(q){case 2:_=`0b${_}`;break;case 8:_=`0o${_}`;break;case 16:_=`0x${_}`;break}let X=BigInt(_);return O==="-"?BigInt(-1)*X:X}let H=parseInt(_,q);return O==="-"?-1*H:H}function h0(_,$,q){let{value:T}=_;if(i_(T)){let O=T.toString($);return T<0?"-"+q+O.substr(1):q+O}return t1.stringifyNumber(_)}var h4={identify:i_,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(_,$,q)=>v$(_,2,2,q),stringify:(_)=>h0(_,2,"0b")},v4={identify:i_,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(_,$,q)=>v$(_,1,8,q),stringify:(_)=>h0(_,8,"0")},m4={identify:i_,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(_,$,q)=>v$(_,0,10,q),stringify:t1.stringifyNumber},l4={identify:i_,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(_,$,q)=>v$(_,2,16,q),stringify:(_)=>h0(_,16,"0x")};p4.int=m4;p4.intBin=h4;p4.intHex=l4;p4.intOct=v4});var v0=V((a4)=>{var p$=S(),m$=q_(),l$=O_();class Y_ extends l$.YAMLMap{constructor(_){super(_);this.tag=Y_.tag}add(_){let $;if(p$.isPair(_))$=_;else if(_&&typeof _==="object"&&"key"in _&&"value"in _&&_.value===null)$=new m$.Pair(_.key,null);else $=new m$.Pair(_,null);if(!l$.findPair(this.items,$.key))this.items.push($)}get(_,$){let q=l$.findPair(this.items,_);return!$&&p$.isPair(q)?p$.isScalar(q.key)?q.key.value:q.key:q}set(_,$){if(typeof $!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof $}`);let q=l$.findPair(this.items,_);if(q&&!$)this.items.splice(this.items.indexOf(q),1);else if(!q&&$)this.items.push(new m$.Pair(_))}toJSON(_,$){return super.toJSON(_,$,Set)}toString(_,$,q){if(!_)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},_,{allNullValues:!0}),$,q);else throw Error("Set items must all have null values")}static from(_,$,q){let{replacer:T}=q,O=new this(_);if($&&Symbol.iterator in Object($))for(let H of $){if(typeof T==="function")H=T.call($,H,H);O.items.push(m$.createPair(H,null,q))}return O}}Y_.tag="tag:yaml.org,2002:set";var n4={collection:"map",identify:(_)=>_ instanceof Set,nodeClass:Y_,default:!1,tag:"tag:yaml.org,2002:set",createNode:(_,$,q)=>Y_.from(_,$,q),resolve(_,$){if(p$.isMap(_))if(_.hasAllNullValues(!0))return Object.assign(new Y_,_);else $("Set items must all have null values");else $("Expected a mapping for this tag");return _}};a4.YAMLSet=Y_;a4.set=n4});var l0=V(($8)=>{var t4=N_();function m0(_,$){let q=_[0],T=q==="-"||q==="+"?_.substring(1):_,O=(X)=>$?BigInt(X):Number(X),H=T.replace(/_/g,"").split(":").reduce((X,U)=>X*O(60)+O(U),O(0));return q==="-"?O(-1)*H:H}function _T(_){let{value:$}=_,q=(X)=>X;if(typeof $==="bigint")q=(X)=>BigInt(X);else if(isNaN($)||!isFinite($))return t4.stringifyNumber(_);let T="";if($<0)T="-",$*=q(-1);let O=q(60),H=[$%O];if($<60)H.unshift(0);else if($=($-H[0])/O,H.unshift($%O),$>=60)$=($-H[0])/O,H.unshift($);return T+H.map((X)=>String(X).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var e4={identify:(_)=>typeof _==="bigint"||Number.isInteger(_),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(_,$,{intAsBigInt:q})=>m0(_,q),stringify:_T},_8={identify:(_)=>typeof _==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(_)=>m0(_,!1),stringify:_T},$T={identify:(_)=>_ 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(_){let $=_.match($T.test);if(!$)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,q,T,O,H,X,U]=$.map(Number),Z=$[7]?Number(($[7]+"00").substr(1,3)):0,J=Date.UTC(q,T-1,O,H||0,X||0,U||0,Z),z=$[8];if(z&&z!=="Z"){let Q=m0(z,!1);if(Math.abs(Q)<30)Q*=60;J-=60000*Q}return new Date(J)},stringify:({value:_})=>_?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};$8.floatTime=_8;$8.intTime=e4;$8.timestamp=$T});var TT=V((Y8)=>{var H8=S_(),X8=g$(),U8=K_(),Z8=d_(),J8=y0(),qT=r1(),p0=o1(),d$=e1(),z8=N$(),Q8=k0(),W8=h$(),G8=v0(),d0=l0(),R8=[H8.map,U8.seq,Z8.string,X8.nullTag,qT.trueTag,qT.falseTag,d$.intBin,d$.intOct,d$.int,d$.intHex,p0.floatNaN,p0.floatExp,p0.float,J8.binary,z8.merge,Q8.omap,W8.pairs,G8.set,d0.intTime,d0.floatTime,d0.timestamp];Y8.schema=R8});var GT=V((F8)=>{var UT=S_(),V8=g$(),ZT=K_(),B8=d_(),w8=K0(),c0=C0(),s0=f0(),D8=h1(),A8=m1(),JT=y0(),n_=N$(),zT=k0(),QT=h$(),OT=TT(),WT=v0(),c$=l0(),HT=new Map([["core",D8.schema],["failsafe",[UT.map,ZT.seq,B8.string]],["json",A8.schema],["yaml11",OT.schema],["yaml-1.1",OT.schema]]),XT={binary:JT.binary,bool:w8.boolTag,float:c0.float,floatExp:c0.floatExp,floatNaN:c0.floatNaN,floatTime:c$.floatTime,int:s0.int,intHex:s0.intHex,intOct:s0.intOct,intTime:c$.intTime,map:UT.map,merge:n_.merge,null:V8.nullTag,omap:zT.omap,pairs:QT.pairs,seq:ZT.seq,set:WT.set,timestamp:c$.timestamp},M8={"tag:yaml.org,2002:binary":JT.binary,"tag:yaml.org,2002:merge":n_.merge,"tag:yaml.org,2002:omap":zT.omap,"tag:yaml.org,2002:pairs":QT.pairs,"tag:yaml.org,2002:set":WT.set,"tag:yaml.org,2002:timestamp":c$.timestamp};function I8(_,$,q){let T=HT.get($);if(T&&!_)return q&&!T.includes(n_.merge)?T.concat(n_.merge):T.slice();let O=T;if(!O)if(Array.isArray(_))O=[];else{let H=Array.from(HT.keys()).filter((X)=>X!=="yaml11").map((X)=>JSON.stringify(X)).join(", ");throw Error(`Unknown schema "${$}"; use one of ${H} or define customTags array`)}if(Array.isArray(_))for(let H of _)O=O.concat(H);else if(typeof _==="function")O=_(O.slice());if(q)O=O.concat(n_.merge);return O.reduce((H,X)=>{let U=typeof X==="string"?XT[X]:X;if(!U){let Z=JSON.stringify(X),J=Object.keys(XT).map((z)=>JSON.stringify(z)).join(", ");throw Error(`Unknown custom tag ${Z}; use one of ${J}`)}if(!H.includes(U))H.push(U);return H},[])}F8.coreKnownTags=M8;F8.getTags=I8});var a0=V((E8)=>{var i0=S(),N8=S_(),C8=K_(),P8=d_(),s$=GT(),f8=(_,$)=>_.key<$.key?-1:_.key>$.key?1:0;class n0{constructor({compat:_,customTags:$,merge:q,resolveKnownTags:T,schema:O,sortMapEntries:H,toStringDefaults:X}){this.compat=Array.isArray(_)?s$.getTags(_,"compat"):_?s$.getTags(null,_):null,this.name=typeof O==="string"&&O||"core",this.knownTags=T?s$.coreKnownTags:{},this.tags=s$.getTags($,this.name,q),this.toStringOptions=X??null,Object.defineProperty(this,i0.MAP,{value:N8.map}),Object.defineProperty(this,i0.SCALAR,{value:P8.string}),Object.defineProperty(this,i0.SEQ,{value:C8.seq}),this.sortMapEntries=typeof H==="function"?H:H===!0?f8:null}clone(){let _=Object.create(n0.prototype,Object.getOwnPropertyDescriptors(this));return _.tags=this.tags.slice(),_}}E8.Schema=n0});var RT=V((g8)=>{var b8=S(),r0=m_(),a_=u_();function y8(_,$){let q=[],T=$.directives===!0;if($.directives!==!1&&_.directives){let Z=_.directives.toString(_);if(Z)q.push(Z),T=!0;else if(_.directives.docStart)T=!0}if(T)q.push("---");let O=r0.createStringifyContext(_,$),{commentString:H}=O.options;if(_.commentBefore){if(q.length!==1)q.unshift("");let Z=H(_.commentBefore);q.unshift(a_.indentComment(Z,""))}let X=!1,U=null;if(_.contents){if(b8.isNode(_.contents)){if(_.contents.spaceBefore&&T)q.push("");if(_.contents.commentBefore){let z=H(_.contents.commentBefore);q.push(a_.indentComment(z,""))}O.forceBlockIndent=!!_.comment,U=_.contents.comment}let Z=U?void 0:()=>X=!0,J=r0.stringify(_.contents,O,()=>U=null,Z);if(U)J+=a_.lineComment(J,"",H(U));if((J[0]==="|"||J[0]===">")&&q[q.length-1]==="---")q[q.length-1]=`--- ${J}`;else q.push(J)}else q.push(r0.stringify(_.contents,O));if(_.directives?.docEnd)if(_.comment){let Z=H(_.comment);if(Z.includes(`
|
|
56
|
+
`))q.push("..."),q.push(a_.indentComment(Z,""));else q.push(`... ${Z}`)}else q.push("...");else{let Z=_.comment;if(Z&&X)Z=Z.replace(/^\n+/,"");if(Z){if((!X||U)&&q[q.length-1]!=="")q.push("");q.push(a_.indentComment(H(Z),""))}}return q.join(`
|
|
57
57
|
`)+`
|
|
58
|
-
`}
|
|
59
|
-
`;X=U+X}if(/[^ ]/.test(X)){let U=1,
|
|
58
|
+
`}g8.stringifyDocument=y8});var r_=V((d8)=>{var k8=x_(),C_=D$(),u=S(),u8=q_(),h8=e(),v8=a0(),m8=RT(),o0=V$(),l8=L0(),p8=k_(),t0=Y0();class e0{constructor(_,$,q){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,u.NODE_TYPE,{value:u.DOC});let T=null;if(typeof $==="function"||Array.isArray($))T=$;else if(q===void 0&&$)q=$,$=void 0;let O=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},q);this.options=O;let{version:H}=O;if(q?._directives){if(this.directives=q._directives.atDocument(),this.directives.yaml.explicit)H=this.directives.yaml.version}else this.directives=new t0.Directives({version:H});this.setSchema(H,q),this.contents=_===void 0?null:this.createNode(_,T,q)}clone(){let _=Object.create(e0.prototype,{[u.NODE_TYPE]:{value:u.DOC}});if(_.commentBefore=this.commentBefore,_.comment=this.comment,_.errors=this.errors.slice(),_.warnings=this.warnings.slice(),_.options=Object.assign({},this.options),this.directives)_.directives=this.directives.clone();if(_.schema=this.schema.clone(),_.contents=u.isNode(this.contents)?this.contents.clone(_.schema):this.contents,this.range)_.range=this.range.slice();return _}add(_){if(P_(this.contents))this.contents.add(_)}addIn(_,$){if(P_(this.contents))this.contents.addIn(_,$)}createAlias(_,$){if(!_.anchor){let q=o0.anchorNames(this);_.anchor=!$||q.has($)?o0.findNewAnchor($||"a",q):$}return new k8.Alias(_.anchor)}createNode(_,$,q){let T=void 0;if(typeof $==="function")_=$.call({"":_},"",_),T=$;else if(Array.isArray($)){let G=(B)=>typeof B==="number"||B instanceof String||B instanceof Number,L=$.filter(G).map(String);if(L.length>0)$=$.concat(L);T=$}else if(q===void 0&&$)q=$,$=void 0;let{aliasDuplicateObjects:O,anchorPrefix:H,flow:X,keepUndefined:U,onTagObj:Z,tag:J}=q??{},{onAnchor:z,setAnchors:Q,sourceObjects:W}=o0.createNodeAnchors(this,H||"a"),Y={aliasDuplicateObjects:O??!0,keepUndefined:U??!1,onAnchor:z,onTagObj:Z,replacer:T,schema:this.schema,sourceObjects:W},R=p8.createNode(_,J,Y);if(X&&u.isCollection(R))R.flow=!0;return Q(),R}createPair(_,$,q={}){let T=this.createNode(_,null,q),O=this.createNode($,null,q);return new u8.Pair(T,O)}delete(_){return P_(this.contents)?this.contents.delete(_):!1}deleteIn(_){if(C_.isEmptyPath(_)){if(this.contents==null)return!1;return this.contents=null,!0}return P_(this.contents)?this.contents.deleteIn(_):!1}get(_,$){return u.isCollection(this.contents)?this.contents.get(_,$):void 0}getIn(_,$){if(C_.isEmptyPath(_))return!$&&u.isScalar(this.contents)?this.contents.value:this.contents;return u.isCollection(this.contents)?this.contents.getIn(_,$):void 0}has(_){return u.isCollection(this.contents)?this.contents.has(_):!1}hasIn(_){if(C_.isEmptyPath(_))return this.contents!==void 0;return u.isCollection(this.contents)?this.contents.hasIn(_):!1}set(_,$){if(this.contents==null)this.contents=C_.collectionFromPath(this.schema,[_],$);else if(P_(this.contents))this.contents.set(_,$)}setIn(_,$){if(C_.isEmptyPath(_))this.contents=$;else if(this.contents==null)this.contents=C_.collectionFromPath(this.schema,Array.from(_),$);else if(P_(this.contents))this.contents.setIn(_,$)}setSchema(_,$={}){if(typeof _==="number")_=String(_);let q;switch(_){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new t0.Directives({version:"1.1"});q={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=_;else this.directives=new t0.Directives({version:_});q={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;q=null;break;default:{let T=JSON.stringify(_);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${T}`)}}if($.schema instanceof Object)this.schema=$.schema;else if(q)this.schema=new v8.Schema(Object.assign(q,$));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:_,jsonArg:$,mapAsMap:q,maxAliasCount:T,onAnchor:O,reviver:H}={}){let X={anchors:new Map,doc:this,keep:!_,mapAsMap:q===!0,mapKeyWarned:!1,maxAliasCount:typeof T==="number"?T:100},U=h8.toJS(this.contents,$??"",X);if(typeof O==="function")for(let{count:Z,res:J}of X.anchors.values())O(J,Z);return typeof H==="function"?l8.applyReviver(H,{"":U},"",U):U}toJSON(_,$){return this.toJS({json:!0,jsonArg:_,mapAsMap:!1,onAnchor:$})}toString(_={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in _&&(!Number.isInteger(_.indent)||Number(_.indent)<=0)){let $=JSON.stringify(_.indent);throw Error(`"indent" option must be a positive integer, not ${$}`)}return m8.stringifyDocument(this,_)}}function P_(_){if(u.isCollection(_))return!0;throw Error("Expected a YAML collection as document contents")}d8.Document=e0});var o_=V((i8)=>{class i$ extends Error{constructor(_,$,q,T){super();this.name=_,this.code=q,this.message=T,this.pos=$}}class YT extends i${constructor(_,$,q){super("YAMLParseError",_,$,q)}}class LT extends i${constructor(_,$,q){super("YAMLWarning",_,$,q)}}var s8=(_,$)=>(q)=>{if(q.pos[0]===-1)return;q.linePos=q.pos.map((U)=>$.linePos(U));let{line:T,col:O}=q.linePos[0];q.message+=` at line ${T}, column ${O}`;let H=O-1,X=_.substring($.lineStarts[T-1],$.lineStarts[T]).replace(/[\n\r]+$/,"");if(H>=60&&X.length>80){let U=Math.min(H-39,X.length-79);X="…"+X.substring(U),H-=U-1}if(X.length>80)X=X.substring(0,79)+"…";if(T>1&&/^ *$/.test(X.substring(0,H))){let U=_.substring($.lineStarts[T-2],$.lineStarts[T-1]);if(U.length>80)U=U.substring(0,79)+`…
|
|
59
|
+
`;X=U+X}if(/[^ ]/.test(X)){let U=1,Z=q.linePos[1];if(Z?.line===T&&Z.col>O)U=Math.max(1,Math.min(Z.col-O,80-H));let J=" ".repeat(H)+"^".repeat(U);q.message+=`:
|
|
60
60
|
|
|
61
61
|
${X}
|
|
62
|
-
${
|
|
63
|
-
`}};i8.YAMLError=i$;i8.YAMLParseError=
|
|
64
|
-
`))return!0;if(_.end){for(let $ of _.end)if($.type==="newline")return!0}return!1;case"flow-collection":for(let $ of _.items){for(let q of $.start)if(q.type==="newline")return!0;if($.sep){for(let q of $.sep)if(q.type==="newline")return!0}if(_q($.key)||_q($.value))return!0}return!1;default:return!0}}$6.containsNewline=_q});var $q=V((H6)=>{var T6=n$();function O6(_,$,q){if($?.type==="flow-collection"){let T=$.end[0];if(T.indent===_&&(T.source==="]"||T.source==="}")&&T6.containsNewline($))q(T,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}H6.flowIndentCheck=O6});var qq=V((
|
|
65
|
-
`+
|
|
66
|
-
`+A.comment;else D.comment=A.comment;let M=new
|
|
67
|
-
`+F.comment;else
|
|
68
|
-
`+K;else w.comment=K;F.comment=F.comment.substring(K.length+1)}}}if(!X&&!M&&!F.found){let K=I?_(q,I,F,O):$(q,F.end,M,null,F,O);if(
|
|
69
|
-
`+E.comment;else w.comment=E.comment;let D_=new K6.Pair(w,t);if(q.options.keepSourceTokens)D_.srcToken=B;if(X){let j=
|
|
70
|
-
`+L.comment;else
|
|
71
|
-
`.repeat(Math.max(1,X.length-1)):"",L=T+O.length;if($.source)L+=$.source.length;return{value:
|
|
72
|
-
`;for(let
|
|
73
|
-
`;else if(L.length>
|
|
74
|
-
`;else if(!Y&&
|
|
75
|
-
`)
|
|
76
|
-
|
|
77
|
-
`;
|
|
78
|
-
`,Y=!0}else if(B==="")if(
|
|
79
|
-
`)
|
|
80
|
-
`;else
|
|
81
|
-
`;else
|
|
82
|
-
`+X[
|
|
83
|
-
`)
|
|
84
|
-
`;break;default:
|
|
85
|
-
`}let R=T+O.length+$.source.length;return{value:
|
|
62
|
+
${J}
|
|
63
|
+
`}};i8.YAMLError=i$;i8.YAMLParseError=YT;i8.YAMLWarning=LT;i8.prettifyError=s8});var t_=V((e8)=>{function t8(_,{flow:$,indicator:q,next:T,offset:O,onError:H,parentIndent:X,startOnNewline:U}){let Z=!1,J=U,z=U,Q="",W="",Y=!1,R=!1,G=null,L=null,B=null,D=null,A=null,M=null,I=null;for(let w of _){if(R){if(w.type!=="space"&&w.type!=="newline"&&w.type!=="comma")H(w.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");R=!1}if(G){if(J&&w.type!=="comment"&&w.type!=="newline")H(G,"TAB_AS_INDENT","Tabs are not allowed as indentation");G=null}switch(w.type){case"space":if(!$&&(q!=="doc-start"||T?.type!=="flow-collection")&&w.source.includes("\t"))G=w;z=!0;break;case"comment":{if(!z)H(w,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let E=w.source.substring(1)||" ";if(!Q)Q=E;else Q+=W+E;W="",J=!1;break}case"newline":if(J){if(Q)Q+=w.source;else if(!M||q!=="seq-item-ind")Z=!0}else W+=w.source;if(J=!0,Y=!0,L||B)D=w;z=!0;break;case"anchor":if(L)H(w,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(w.source.endsWith(":"))H(w.offset+w.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);L=w,I??(I=w.offset),J=!1,z=!1,R=!0;break;case"tag":{if(B)H(w,"MULTIPLE_TAGS","A node can have at most one tag");B=w,I??(I=w.offset),J=!1,z=!1,R=!0;break}case q:if(L||B)H(w,"BAD_PROP_ORDER",`Anchors and tags must be after the ${w.source} indicator`);if(M)H(w,"UNEXPECTED_TOKEN",`Unexpected ${w.source} in ${$??"collection"}`);M=w,J=q==="seq-item-ind"||q==="explicit-key-ind",z=!1;break;case"comma":if($){if(A)H(w,"UNEXPECTED_TOKEN",`Unexpected , in ${$}`);A=w,J=!1,z=!1;break}default:H(w,"UNEXPECTED_TOKEN",`Unexpected ${w.type} token`),J=!1,z=!1}}let F=_[_.length-1],K=F?F.offset+F.source.length:O;if(R&&T&&T.type!=="space"&&T.type!=="newline"&&T.type!=="comma"&&(T.type!=="scalar"||T.source!==""))H(T.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(G&&(J&&G.indent<=X||T?.type==="block-map"||T?.type==="block-seq"))H(G,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:A,found:M,spaceBefore:Z,comment:Q,hasNewline:Y,anchor:L,tag:B,newlineAfterProp:D,end:K,start:I??K}}e8.resolveProps=t8});var n$=V(($6)=>{function _q(_){if(!_)return null;switch(_.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(_.source.includes(`
|
|
64
|
+
`))return!0;if(_.end){for(let $ of _.end)if($.type==="newline")return!0}return!1;case"flow-collection":for(let $ of _.items){for(let q of $.start)if(q.type==="newline")return!0;if($.sep){for(let q of $.sep)if(q.type==="newline")return!0}if(_q($.key)||_q($.value))return!0}return!1;default:return!0}}$6.containsNewline=_q});var $q=V((H6)=>{var T6=n$();function O6(_,$,q){if($?.type==="flow-collection"){let T=$.end[0];if(T.indent===_&&(T.source==="]"||T.source==="}")&&T6.containsNewline($))q(T,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}H6.flowIndentCheck=O6});var qq=V((Z6)=>{var VT=S();function U6(_,$,q){let{uniqueKeys:T}=_.options;if(T===!1)return!1;let O=typeof T==="function"?T:(H,X)=>H===X||VT.isScalar(H)&&VT.isScalar(X)&&H.value===X.value;return $.some((H)=>O(H.key,q))}Z6.mapIncludes=U6});var MT=V((R6)=>{var BT=q_(),z6=O_(),wT=t_(),Q6=n$(),DT=$q(),W6=qq(),AT="All mapping items must start at the same column";function G6({composeNode:_,composeEmptyNode:$},q,T,O,H){let U=new(H?.nodeClass??z6.YAMLMap)(q.schema);if(q.atRoot)q.atRoot=!1;let Z=T.offset,J=null;for(let z of T.items){let{start:Q,key:W,sep:Y,value:R}=z,G=wT.resolveProps(Q,{indicator:"explicit-key-ind",next:W??Y?.[0],offset:Z,onError:O,parentIndent:T.indent,startOnNewline:!0}),L=!G.found;if(L){if(W){if(W.type==="block-seq")O(Z,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in W&&W.indent!==T.indent)O(Z,"BAD_INDENT",AT)}if(!G.anchor&&!G.tag&&!Y){if(J=G.end,G.comment)if(U.comment)U.comment+=`
|
|
65
|
+
`+G.comment;else U.comment=G.comment;continue}if(G.newlineAfterProp||Q6.containsNewline(W))O(W??Q[Q.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(G.found?.indent!==T.indent)O(Z,"BAD_INDENT",AT);q.atKey=!0;let B=G.end,D=W?_(q,W,G,O):$(q,B,Q,null,G,O);if(q.schema.compat)DT.flowIndentCheck(T.indent,W,O);if(q.atKey=!1,W6.mapIncludes(q,U.items,D))O(B,"DUPLICATE_KEY","Map keys must be unique");let A=wT.resolveProps(Y??[],{indicator:"map-value-ind",next:R,offset:D.range[2],onError:O,parentIndent:T.indent,startOnNewline:!W||W.type==="block-scalar"});if(Z=A.end,A.found){if(L){if(R?.type==="block-map"&&!A.hasNewline)O(Z,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(q.options.strict&&G.start<A.found.offset-1024)O(D.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let M=R?_(q,R,A,O):$(q,Z,Y,null,A,O);if(q.schema.compat)DT.flowIndentCheck(T.indent,R,O);Z=M.range[2];let I=new BT.Pair(D,M);if(q.options.keepSourceTokens)I.srcToken=z;U.items.push(I)}else{if(L)O(D.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(A.comment)if(D.comment)D.comment+=`
|
|
66
|
+
`+A.comment;else D.comment=A.comment;let M=new BT.Pair(D);if(q.options.keepSourceTokens)M.srcToken=z;U.items.push(M)}}if(J&&J<Z)O(J,"IMPOSSIBLE","Map comment with trailing content");return U.range=[T.offset,Z,J??Z],U}R6.resolveBlockMap=G6});var IT=V((D6)=>{var L6=H_(),V6=t_(),B6=$q();function w6({composeNode:_,composeEmptyNode:$},q,T,O,H){let U=new(H?.nodeClass??L6.YAMLSeq)(q.schema);if(q.atRoot)q.atRoot=!1;if(q.atKey)q.atKey=!1;let Z=T.offset,J=null;for(let{start:z,value:Q}of T.items){let W=V6.resolveProps(z,{indicator:"seq-item-ind",next:Q,offset:Z,onError:O,parentIndent:T.indent,startOnNewline:!0});if(!W.found)if(W.anchor||W.tag||Q)if(Q?.type==="block-seq")O(W.end,"BAD_INDENT","All sequence items must start at the same column");else O(Z,"MISSING_CHAR","Sequence item without - indicator");else{if(J=W.end,W.comment)U.comment=W.comment;continue}let Y=Q?_(q,Q,W,O):$(q,W.end,z,null,W,O);if(q.schema.compat)B6.flowIndentCheck(T.indent,Q,O);Z=Y.range[2],U.items.push(Y)}return U.range=[T.offset,Z,J??Z],U}D6.resolveBlockSeq=w6});var f_=V((I6)=>{function M6(_,$,q,T){let O="";if(_){let H=!1,X="";for(let U of _){let{source:Z,type:J}=U;switch(J){case"space":H=!0;break;case"comment":{if(q&&!H)T(U,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let z=Z.substring(1)||" ";if(!O)O=z;else O+=X+z;X="";break}case"newline":if(O)X+=Z;H=!0;break;default:T(U,"UNEXPECTED_TOKEN",`Unexpected ${J} at node end`)}$+=Z.length}}return{comment:O,offset:$}}I6.resolveEnd=M6});var KT=V((j6)=>{var S6=S(),K6=q_(),FT=O_(),N6=H_(),C6=f_(),ST=t_(),P6=n$(),f6=qq(),Tq="Block collections are not allowed within flow collections",Oq=(_)=>_&&(_.type==="block-map"||_.type==="block-seq");function E6({composeNode:_,composeEmptyNode:$},q,T,O,H){let X=T.start.source==="{",U=X?"flow map":"flow sequence",J=new(H?.nodeClass??(X?FT.YAMLMap:N6.YAMLSeq))(q.schema);J.flow=!0;let z=q.atRoot;if(z)q.atRoot=!1;if(q.atKey)q.atKey=!1;let Q=T.offset+T.start.source.length;for(let L=0;L<T.items.length;++L){let B=T.items[L],{start:D,key:A,sep:M,value:I}=B,F=ST.resolveProps(D,{flow:U,indicator:"explicit-key-ind",next:A??M?.[0],offset:Q,onError:O,parentIndent:T.indent,startOnNewline:!1});if(!F.found){if(!F.anchor&&!F.tag&&!M&&!I){if(L===0&&F.comma)O(F.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${U}`);else if(L<T.items.length-1)O(F.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${U}`);if(F.comment)if(J.comment)J.comment+=`
|
|
67
|
+
`+F.comment;else J.comment=F.comment;Q=F.end;continue}if(!X&&q.options.strict&&P6.containsNewline(A))O(A,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(L===0){if(F.comma)O(F.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${U}`)}else{if(!F.comma)O(F.start,"MISSING_CHAR",`Missing , between ${U} items`);if(F.comment){let K="";_:for(let w of D)switch(w.type){case"comma":case"space":break;case"comment":K=w.source.substring(1);break _;default:break _}if(K){let w=J.items[J.items.length-1];if(S6.isPair(w))w=w.value??w.key;if(w.comment)w.comment+=`
|
|
68
|
+
`+K;else w.comment=K;F.comment=F.comment.substring(K.length+1)}}}if(!X&&!M&&!F.found){let K=I?_(q,I,F,O):$(q,F.end,M,null,F,O);if(J.items.push(K),Q=K.range[2],Oq(I))O(K.range,"BLOCK_IN_FLOW",Tq)}else{q.atKey=!0;let K=F.end,w=A?_(q,A,F,O):$(q,K,D,null,F,O);if(Oq(A))O(w.range,"BLOCK_IN_FLOW",Tq);q.atKey=!1;let E=ST.resolveProps(M??[],{flow:U,indicator:"map-value-ind",next:I,offset:w.range[2],onError:O,parentIndent:T.indent,startOnNewline:!1});if(E.found){if(!X&&!F.found&&q.options.strict){if(M)for(let j of M){if(j===E.found)break;if(j.type==="newline"){O(j,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(F.start<E.found.offset-1024)O(E.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(I)if("source"in I&&I.source?.[0]===":")O(I,"MISSING_CHAR",`Missing space after : in ${U}`);else O(E.start,"MISSING_CHAR",`Missing , or : between ${U} items`);let t=I?_(q,I,E,O):E.found?$(q,E.end,M,null,E,O):null;if(t){if(Oq(I))O(t.range,"BLOCK_IN_FLOW",Tq)}else if(E.comment)if(w.comment)w.comment+=`
|
|
69
|
+
`+E.comment;else w.comment=E.comment;let D_=new K6.Pair(w,t);if(q.options.keepSourceTokens)D_.srcToken=B;if(X){let j=J;if(f6.mapIncludes(q,j.items,w))O(K,"DUPLICATE_KEY","Map keys must be unique");j.items.push(D_)}else{let j=new FT.YAMLMap(q.schema);j.flow=!0,j.items.push(D_);let oq=(t??w).range;j.range=[w.range[0],oq[1],oq[2]],J.items.push(j)}Q=t?t.range[2]:E.end}}let W=X?"}":"]",[Y,...R]=T.end,G=Q;if(Y?.source===W)G=Y.offset+Y.source.length;else{let L=U[0].toUpperCase()+U.substring(1),B=z?`${L} must end with a ${W}`:`${L} in block collection must be sufficiently indented and end with a ${W}`;if(O(Q,z?"MISSING_CHAR":"BAD_INDENT",B),Y&&Y.source.length!==1)R.unshift(Y)}if(R.length>0){let L=C6.resolveEnd(R,G,q.options.strict,O);if(L.comment)if(J.comment)J.comment+=`
|
|
70
|
+
`+L.comment;else J.comment=L.comment;J.range=[T.offset,G,L.offset]}else J.range=[T.offset,G,G];return J}j6.resolveFlowCollection=E6});var NT=V((l6)=>{var y6=S(),g6=f(),x6=O_(),k6=H_(),u6=MT(),h6=IT(),v6=KT();function Hq(_,$,q,T,O,H){let X=q.type==="block-map"?u6.resolveBlockMap(_,$,q,T,H):q.type==="block-seq"?h6.resolveBlockSeq(_,$,q,T,H):v6.resolveFlowCollection(_,$,q,T,H),U=X.constructor;if(O==="!"||O===U.tagName)return X.tag=U.tagName,X;if(O)X.tag=O;return X}function m6(_,$,q,T,O){let H=T.tag,X=!H?null:$.directives.tagName(H.source,(W)=>O(H,"TAG_RESOLVE_FAILED",W));if(q.type==="block-seq"){let{anchor:W,newlineAfterProp:Y}=T,R=W&&H?W.offset>H.offset?W:H:W??H;if(R&&(!Y||Y.offset<R.offset))O(R,"MISSING_CHAR","Missing newline after block sequence props")}let U=q.type==="block-map"?"map":q.type==="block-seq"?"seq":q.start.source==="{"?"map":"seq";if(!H||!X||X==="!"||X===x6.YAMLMap.tagName&&U==="map"||X===k6.YAMLSeq.tagName&&U==="seq")return Hq(_,$,q,O,X);let Z=$.schema.tags.find((W)=>W.tag===X&&W.collection===U);if(!Z){let W=$.schema.knownTags[X];if(W?.collection===U)$.schema.tags.push(Object.assign({},W,{default:!1})),Z=W;else{if(W)O(H,"BAD_COLLECTION_TYPE",`${W.tag} used for ${U} collection, but expects ${W.collection??"scalar"}`,!0);else O(H,"TAG_RESOLVE_FAILED",`Unresolved tag: ${X}`,!0);return Hq(_,$,q,O,X)}}let J=Hq(_,$,q,O,X,Z),z=Z.resolve?.(J,(W)=>O(H,"TAG_RESOLVE_FAILED",W),$.options)??J,Q=y6.isNode(z)?z:new g6.Scalar(z);if(Q.range=J.range,Q.tag=X,Z?.format)Q.format=Z.format;return Q}l6.composeCollection=m6});var Uq=V((i6)=>{var Xq=f();function d6(_,$,q){let T=$.offset,O=c6($,_.options.strict,q);if(!O)return{value:"",type:null,comment:"",range:[T,T,T]};let H=O.mode===">"?Xq.Scalar.BLOCK_FOLDED:Xq.Scalar.BLOCK_LITERAL,X=$.source?s6($.source):[],U=X.length;for(let G=X.length-1;G>=0;--G){let L=X[G][1];if(L===""||L==="\r")U=G;else break}if(U===0){let G=O.chomp==="+"&&X.length>0?`
|
|
71
|
+
`.repeat(Math.max(1,X.length-1)):"",L=T+O.length;if($.source)L+=$.source.length;return{value:G,type:H,comment:O.comment,range:[T,L,L]}}let Z=$.indent+O.indent,J=$.offset+O.length,z=0;for(let G=0;G<U;++G){let[L,B]=X[G];if(B===""||B==="\r"){if(O.indent===0&&L.length>Z)Z=L.length}else{if(L.length<Z)q(J+L.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(O.indent===0)Z=L.length;if(z=G,Z===0&&!_.atRoot)q(J,"BAD_INDENT","Block scalar values in collections must be indented");break}J+=L.length+B.length+1}for(let G=X.length-1;G>=U;--G)if(X[G][0].length>Z)U=G+1;let Q="",W="",Y=!1;for(let G=0;G<z;++G)Q+=X[G][0].slice(Z)+`
|
|
72
|
+
`;for(let G=z;G<U;++G){let[L,B]=X[G];J+=L.length+B.length+1;let D=B[B.length-1]==="\r";if(D)B=B.slice(0,-1);if(B&&L.length<Z){let M=`Block scalar lines must not be less indented than their ${O.indent?"explicit indentation indicator":"first line"}`;q(J-B.length-(D?2:1),"BAD_INDENT",M),L=""}if(H===Xq.Scalar.BLOCK_LITERAL)Q+=W+L.slice(Z)+B,W=`
|
|
73
|
+
`;else if(L.length>Z||B[0]==="\t"){if(W===" ")W=`
|
|
74
|
+
`;else if(!Y&&W===`
|
|
75
|
+
`)W=`
|
|
76
|
+
|
|
77
|
+
`;Q+=W+L.slice(Z)+B,W=`
|
|
78
|
+
`,Y=!0}else if(B==="")if(W===`
|
|
79
|
+
`)Q+=`
|
|
80
|
+
`;else W=`
|
|
81
|
+
`;else Q+=W+B,W=" ",Y=!1}switch(O.chomp){case"-":break;case"+":for(let G=U;G<X.length;++G)Q+=`
|
|
82
|
+
`+X[G][0].slice(Z);if(Q[Q.length-1]!==`
|
|
83
|
+
`)Q+=`
|
|
84
|
+
`;break;default:Q+=`
|
|
85
|
+
`}let R=T+O.length+$.source.length;return{value:Q,type:H,comment:O.comment,range:[T,R,R]}}function c6({offset:_,props:$},q,T){if($[0].type!=="block-scalar-header")return T($[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:O}=$[0],H=O[0],X=0,U="",Z=-1;for(let W=1;W<O.length;++W){let Y=O[W];if(!U&&(Y==="-"||Y==="+"))U=Y;else{let R=Number(Y);if(!X&&R)X=R;else if(Z===-1)Z=_+W}}if(Z!==-1)T(Z,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${O}`);let J=!1,z="",Q=O.length;for(let W=1;W<$.length;++W){let Y=$[W];switch(Y.type){case"space":J=!0;case"newline":Q+=Y.source.length;break;case"comment":if(q&&!J)T(Y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");Q+=Y.source.length,z=Y.source.substring(1);break;case"error":T(Y,"UNEXPECTED_TOKEN",Y.message),Q+=Y.source.length;break;default:{let R=`Unexpected token in block scalar header: ${Y.type}`;T(Y,"UNEXPECTED_TOKEN",R);let G=Y.source;if(G&&typeof G==="string")Q+=G.length}}}return{mode:H,indent:X,chomp:U,comment:z,length:Q}}function s6(_){let $=_.split(/\n( *)/),q=$[0],T=q.match(/^( *)/),H=[T?.[1]?[T[1],q.slice(T[1].length)]:["",q]];for(let X=1;X<$.length;X+=2)H.push([$[X],$[X+1]]);return H}i6.resolveBlockScalar=d6});var Jq=V((TU)=>{var Zq=f(),a6=f_();function r6(_,$,q){let{offset:T,type:O,source:H,end:X}=_,U,Z,J=(W,Y,R)=>q(T+W,Y,R);switch(O){case"scalar":U=Zq.Scalar.PLAIN,Z=o6(H,J);break;case"single-quoted-scalar":U=Zq.Scalar.QUOTE_SINGLE,Z=t6(H,J);break;case"double-quoted-scalar":U=Zq.Scalar.QUOTE_DOUBLE,Z=e6(H,J);break;default:return q(_,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${O}`),{value:"",type:null,comment:"",range:[T,T+H.length,T+H.length]}}let z=T+H.length,Q=a6.resolveEnd(X,z,$,q);return{value:Z,type:U,comment:Q.comment,range:[T,z,Q.offset]}}function o6(_,$){let q="";switch(_[0]){case"\t":q="a tab character";break;case",":q="flow indicator character ,";break;case"%":q="directive indicator character %";break;case"|":case">":{q=`block scalar indicator ${_[0]}`;break}case"@":case"`":{q=`reserved character ${_[0]}`;break}}if(q)$(0,"BAD_SCALAR_START",`Plain value cannot start with ${q}`);return CT(_)}function t6(_,$){if(_[_.length-1]!=="'"||_.length===1)$(_.length,"MISSING_CHAR","Missing closing 'quote");return CT(_.slice(1,-1)).replace(/''/g,"'")}function CT(_){let $,q;try{$=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
86
86
|
`,"sy"),q=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
87
87
|
`,"sy")}catch{$=/(.*?)[ \t]*\r?\n/sy,q=/[ \t]*(.*?)[ \t]*\r?\n/sy}let T=$.exec(_);if(!T)return _;let O=T[1],H=" ",X=$.lastIndex;q.lastIndex=X;while(T=q.exec(_)){if(T[1]==="")if(H===`
|
|
88
88
|
`)O+=H;else H=`
|
|
@@ -97,26 +97,26 @@ ${Z}
|
|
|
97
97
|
`)break;if(T===`
|
|
98
98
|
`)q+=`
|
|
99
99
|
`;$+=1,T=_[$+1]}if(!q)q=" ";return{fold:q,offset:$}}var $U={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
100
|
-
`,r:"\r",t:"\t",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function qU(_,$,q,T){let O=_.substr($,q),X=O.length===q&&/^[0-9a-fA-F]+$/.test(O)?parseInt(O,16):NaN;try{return String.fromCodePoint(X)}catch{let U=_.substr($-2,q+2);return T($-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${U}`),U}}TU.resolveFlowScalar=r6});var
|
|
100
|
+
`,r:"\r",t:"\t",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function qU(_,$,q,T){let O=_.substr($,q),X=O.length===q&&/^[0-9a-fA-F]+$/.test(O)?parseInt(O,16):NaN;try{return String.fromCodePoint(X)}catch{let U=_.substr($-2,q+2);return T($-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${U}`),U}}TU.resolveFlowScalar=r6});var fT=V((zU)=>{var L_=S(),PT=f(),HU=Uq(),XU=Jq();function UU(_,$,q,T){let{value:O,type:H,comment:X,range:U}=$.type==="block-scalar"?HU.resolveBlockScalar(_,$,T):XU.resolveFlowScalar($,_.options.strict,T),Z=q?_.directives.tagName(q.source,(Q)=>T(q,"TAG_RESOLVE_FAILED",Q)):null,J;if(_.options.stringKeys&&_.atKey)J=_.schema[L_.SCALAR];else if(Z)J=ZU(_.schema,O,Z,q,T);else if($.type==="scalar")J=JU(_,O,$,T);else J=_.schema[L_.SCALAR];let z;try{let Q=J.resolve(O,(W)=>T(q??$,"TAG_RESOLVE_FAILED",W),_.options);z=L_.isScalar(Q)?Q:new PT.Scalar(Q)}catch(Q){let W=Q instanceof Error?Q.message:String(Q);T(q??$,"TAG_RESOLVE_FAILED",W),z=new PT.Scalar(O)}if(z.range=U,z.source=O,H)z.type=H;if(Z)z.tag=Z;if(J.format)z.format=J.format;if(X)z.comment=X;return z}function ZU(_,$,q,T,O){if(q==="!")return _[L_.SCALAR];let H=[];for(let U of _.tags)if(!U.collection&&U.tag===q)if(U.default&&U.test)H.push(U);else return U;for(let U of H)if(U.test?.test($))return U;let X=_.knownTags[q];if(X&&!X.collection)return _.tags.push(Object.assign({},X,{default:!1,test:void 0})),X;return O(T,"TAG_RESOLVE_FAILED",`Unresolved tag: ${q}`,q!=="tag:yaml.org,2002:str"),_[L_.SCALAR]}function JU({atKey:_,directives:$,schema:q},T,O,H){let X=q.tags.find((U)=>(U.default===!0||_&&U.default==="key")&&U.test?.test(T))||q[L_.SCALAR];if(q.compat){let U=q.compat.find((Z)=>Z.default&&Z.test?.test(T))??q[L_.SCALAR];if(X.tag!==U.tag){let Z=$.tagString(X.tag),J=$.tagString(U.tag),z=`Value may be parsed as either ${Z} or ${J}`;H(O,"TAG_RESOLVE_FAILED",z,!0)}}return X}zU.composeScalar=UU});var ET=V((GU)=>{function WU(_,$,q){if($){q??(q=$.length);for(let T=q-1;T>=0;--T){let O=$[T];switch(O.type){case"space":case"comment":case"newline":_-=O.source.length;continue}O=$[++T];while(O?.type==="space")_+=O.source.length,O=$[++T];break}}return _}GU.emptyScalarPosition=WU});var yT=V((MU)=>{var YU=x_(),LU=S(),VU=NT(),jT=fT(),BU=f_(),wU=ET(),DU={composeNode:bT,composeEmptyNode:zq};function bT(_,$,q,T){let O=_.atKey,{spaceBefore:H,comment:X,anchor:U,tag:Z}=q,J,z=!0;switch($.type){case"alias":if(J=AU(_,$,T),U||Z)T($,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(J=jT.composeScalar(_,$,Z,T),U)J.anchor=U.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(J=VU.composeCollection(DU,_,$,q,T),U)J.anchor=U.source.substring(1)}catch(Q){let W=Q instanceof Error?Q.message:String(Q);T($,"RESOURCE_EXHAUSTION",W)}break;default:{let Q=$.type==="error"?$.message:`Unsupported token (type: ${$.type})`;T($,"UNEXPECTED_TOKEN",Q),z=!1}}if(J??(J=zq(_,$.offset,void 0,null,q,T)),U&&J.anchor==="")T(U,"BAD_ALIAS","Anchor cannot be an empty string");if(O&&_.options.stringKeys&&(!LU.isScalar(J)||typeof J.value!=="string"||J.tag&&J.tag!=="tag:yaml.org,2002:str"))T(Z??$,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(H)J.spaceBefore=!0;if(X)if($.type==="scalar"&&$.source==="")J.comment=X;else J.commentBefore=X;if(_.options.keepSourceTokens&&z)J.srcToken=$;return J}function zq(_,$,q,T,{spaceBefore:O,comment:H,anchor:X,tag:U,end:Z},J){let z={type:"scalar",offset:wU.emptyScalarPosition($,q,T),indent:-1,source:""},Q=jT.composeScalar(_,z,U,J);if(X){if(Q.anchor=X.source.substring(1),Q.anchor==="")J(X,"BAD_ALIAS","Anchor cannot be an empty string")}if(O)Q.spaceBefore=!0;if(H)Q.comment=H,Q.range[2]=Z;return Q}function AU({options:_},{offset:$,source:q,end:T},O){let H=new YU.Alias(q.substring(1));if(H.source==="")O($,"BAD_ALIAS","Alias cannot be an empty string");if(H.source.endsWith(":"))O($+q.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let X=$+q.length,U=BU.resolveEnd(T,X,_.strict,O);if(H.range=[$,X,U.offset],U.comment)H.comment=U.comment;return H}MU.composeEmptyNode=zq;MU.composeNode=bT});var xT=V((PU)=>{var SU=r_(),gT=yT(),KU=f_(),NU=t_();function CU(_,$,{offset:q,start:T,value:O,end:H},X){let U=Object.assign({_directives:$},_),Z=new SU.Document(void 0,U),J={atKey:!1,atRoot:!0,directives:Z.directives,options:Z.options,schema:Z.schema},z=NU.resolveProps(T,{indicator:"doc-start",next:O??H?.[0],offset:q,onError:X,parentIndent:0,startOnNewline:!0});if(z.found){if(Z.directives.docStart=!0,O&&(O.type==="block-map"||O.type==="block-seq")&&!z.hasNewline)X(z.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}Z.contents=O?gT.composeNode(J,O,z,X):gT.composeEmptyNode(J,z.end,T,null,z,X);let Q=Z.contents.range[2],W=KU.resolveEnd(H,Q,!1,X);if(W.comment)Z.comment=W.comment;return Z.range=[q,Q,W.offset],Z}PU.composeDoc=CU});var Qq=V((xU)=>{var EU=W$("process"),jU=Y0(),bU=r_(),e_=o_(),kT=S(),yU=xT(),gU=f_();function _$(_){if(typeof _==="number")return[_,_+1];if(Array.isArray(_))return _.length===2?_:[_[0],_[1]];let{offset:$,source:q}=_;return[$,$+(typeof q==="string"?q.length:1)]}function uT(_){let $="",q=!1,T=!1;for(let O=0;O<_.length;++O){let H=_[O];switch(H[0]){case"#":$+=($===""?"":T?`
|
|
101
101
|
|
|
102
102
|
`:`
|
|
103
|
-
`)+(H.substring(1)||" "),q=!0,T=!1;break;case"%":if(_[O+1]?.[0]!=="#")O+=1;q=!1;break;default:if(!q)T=!0;q=!1}}return{comment:$,afterEmptyLine:T}}class
|
|
104
|
-
${q}`:q;else if(T||_.directives.docStart||!O)_.commentBefore=q;else if(
|
|
103
|
+
`)+(H.substring(1)||" "),q=!0,T=!1;break;case"%":if(_[O+1]?.[0]!=="#")O+=1;q=!1;break;default:if(!q)T=!0;q=!1}}return{comment:$,afterEmptyLine:T}}class hT{constructor(_={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=($,q,T,O)=>{let H=_$($);if(O)this.warnings.push(new e_.YAMLWarning(H,q,T));else this.errors.push(new e_.YAMLParseError(H,q,T))},this.directives=new jU.Directives({version:_.version||"1.2"}),this.options=_}decorate(_,$){let{comment:q,afterEmptyLine:T}=uT(this.prelude);if(q){let O=_.contents;if($)_.comment=_.comment?`${_.comment}
|
|
104
|
+
${q}`:q;else if(T||_.directives.docStart||!O)_.commentBefore=q;else if(kT.isCollection(O)&&!O.flow&&O.items.length>0){let H=O.items[0];if(kT.isPair(H))H=H.key;let X=H.commentBefore;H.commentBefore=X?`${q}
|
|
105
105
|
${X}`:q}else{let H=O.commentBefore;O.commentBefore=H?`${q}
|
|
106
|
-
${H}`:q}}if($){for(let O=0;O<this.errors.length;++O)_.errors.push(this.errors[O]);for(let O=0;O<this.warnings.length;++O)_.warnings.push(this.warnings[O])}else _.errors=this.errors,_.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
107
|
-
${$.comment}`:$.comment}this.doc.range[2]=$.offset;break}default:this.errors.push(new e_.YAMLParseError(_$(_),"UNEXPECTED_TOKEN",`Unsupported token ${_.type}`))}}*end(_=!1,$=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(_){let q=Object.assign({_directives:this.directives},this.options),T=new bU.Document(void 0,q);if(this.atDirectives)this.onError($,"MISSING_CHAR","Missing directives-end indicator line");T.range=[0,$,$],this.decorate(T,!1),yield T}}}xU.Composer=
|
|
108
|
-
`}];switch(U[0]){case"|":case">":{let
|
|
109
|
-
`),z=U.substring(0,
|
|
110
|
-
`,
|
|
111
|
-
`});return{type:"block-scalar",offset:H,indent:T,props:
|
|
106
|
+
${H}`:q}}if($){for(let O=0;O<this.errors.length;++O)_.errors.push(this.errors[O]);for(let O=0;O<this.warnings.length;++O)_.warnings.push(this.warnings[O])}else _.errors=this.errors,_.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:uT(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(_,$=!1,q=-1){for(let T of _)yield*this.next(T);yield*this.end($,q)}*next(_){if(EU.env.LOG_STREAM)console.dir(_,{depth:null});switch(_.type){case"directive":this.directives.add(_.source,($,q,T)=>{let O=_$(_);O[0]+=$,this.onError(O,"BAD_DIRECTIVE",q,T)}),this.prelude.push(_.source),this.atDirectives=!0;break;case"document":{let $=yU.composeDoc(this.options,this.directives,_,this.onError);if(this.atDirectives&&!$.directives.docStart)this.onError(_,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate($,!1),this.doc)yield this.doc;this.doc=$,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(_.source);break;case"error":{let $=_.source?`${_.message}: ${JSON.stringify(_.source)}`:_.message,q=new e_.YAMLParseError(_$(_),"UNEXPECTED_TOKEN",$);if(this.atDirectives||!this.doc)this.errors.push(q);else this.doc.errors.push(q);break}case"doc-end":{if(!this.doc){this.errors.push(new e_.YAMLParseError(_$(_),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let $=gU.resolveEnd(_.end,_.offset+_.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),$.comment){let q=this.doc.comment;this.doc.comment=q?`${q}
|
|
107
|
+
${$.comment}`:$.comment}this.doc.range[2]=$.offset;break}default:this.errors.push(new e_.YAMLParseError(_$(_),"UNEXPECTED_TOKEN",`Unsupported token ${_.type}`))}}*end(_=!1,$=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(_){let q=Object.assign({_directives:this.directives},this.options),T=new bU.Document(void 0,q);if(this.atDirectives)this.onError($,"MISSING_CHAR","Missing directives-end indicator line");T.range=[0,$,$],this.decorate(T,!1),yield T}}}xU.Composer=hT});var lT=V((cU)=>{var uU=Uq(),hU=Jq(),vU=o_(),vT=v_();function mU(_,$=!0,q){if(_){let T=(O,H,X)=>{let U=typeof O==="number"?O:Array.isArray(O)?O[0]:O.offset;if(q)q(U,H,X);else throw new vU.YAMLParseError([U,U+1],H,X)};switch(_.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return hU.resolveFlowScalar(_,$,T);case"block-scalar":return uU.resolveBlockScalar({options:{strict:$}},_,T)}}return null}function lU(_,$){let{implicitKey:q=!1,indent:T,inFlow:O=!1,offset:H=-1,type:X="PLAIN"}=$,U=vT.stringifyString({type:X,value:_},{implicitKey:q,indent:T>0?" ".repeat(T):"",inFlow:O,options:{blockQuote:!0,lineWidth:-1}}),Z=$.end??[{type:"newline",offset:-1,indent:T,source:`
|
|
108
|
+
`}];switch(U[0]){case"|":case">":{let J=U.indexOf(`
|
|
109
|
+
`),z=U.substring(0,J),Q=U.substring(J+1)+`
|
|
110
|
+
`,W=[{type:"block-scalar-header",offset:H,indent:T,source:z}];if(!mT(W,Z))W.push({type:"newline",offset:-1,indent:T,source:`
|
|
111
|
+
`});return{type:"block-scalar",offset:H,indent:T,props:W,source:Q}}case'"':return{type:"double-quoted-scalar",offset:H,indent:T,source:U,end:Z};case"'":return{type:"single-quoted-scalar",offset:H,indent:T,source:U,end:Z};default:return{type:"scalar",offset:H,indent:T,source:U,end:Z}}}function pU(_,$,q={}){let{afterKey:T=!1,implicitKey:O=!1,inFlow:H=!1,type:X}=q,U="indent"in _?_.indent:null;if(T&&typeof U==="number")U+=2;if(!X)switch(_.type){case"single-quoted-scalar":X="QUOTE_SINGLE";break;case"double-quoted-scalar":X="QUOTE_DOUBLE";break;case"block-scalar":{let J=_.props[0];if(J.type!=="block-scalar-header")throw Error("Invalid block scalar header");X=J.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:X="PLAIN"}let Z=vT.stringifyString({type:X,value:$},{implicitKey:O||U===null,indent:U!==null&&U>0?" ".repeat(U):"",inFlow:H,options:{blockQuote:!0,lineWidth:-1}});switch(Z[0]){case"|":case">":dU(_,Z);break;case'"':Wq(_,Z,"double-quoted-scalar");break;case"'":Wq(_,Z,"single-quoted-scalar");break;default:Wq(_,Z,"scalar")}}function dU(_,$){let q=$.indexOf(`
|
|
112
112
|
`),T=$.substring(0,q),O=$.substring(q+1)+`
|
|
113
|
-
`;if(_.type==="block-scalar"){let H=_.props[0];if(H.type!=="block-scalar-header")throw Error("Invalid block scalar header");H.source=T,_.source=O}else{let{offset:H}=_,X="indent"in _?_.indent:-1,U=[{type:"block-scalar-header",offset:H,indent:X,source:T}];if(!
|
|
114
|
-
`});for(let
|
|
115
|
-
`};delete _.items,Object.assign(_,{type:q,source:$,end:[O]});break}default:{let T="indent"in _?_.indent:-1,O="end"in _&&Array.isArray(_.end)?_.end.filter((H)=>H.type==="space"||H.type==="comment"||H.type==="newline"):[];for(let H of Object.keys(_))if(H!=="type"&&H!=="offset")delete _[H];Object.assign(_,{type:q,indent:T,source:$,end:O})}}}cU.createScalarToken=lU;cU.resolveAsScalar=mU;cU.setScalarValue=pU});var
|
|
113
|
+
`;if(_.type==="block-scalar"){let H=_.props[0];if(H.type!=="block-scalar-header")throw Error("Invalid block scalar header");H.source=T,_.source=O}else{let{offset:H}=_,X="indent"in _?_.indent:-1,U=[{type:"block-scalar-header",offset:H,indent:X,source:T}];if(!mT(U,"end"in _?_.end:void 0))U.push({type:"newline",offset:-1,indent:X,source:`
|
|
114
|
+
`});for(let Z of Object.keys(_))if(Z!=="type"&&Z!=="offset")delete _[Z];Object.assign(_,{type:"block-scalar",indent:X,props:U,source:O})}}function mT(_,$){if($)for(let q of $)switch(q.type){case"space":case"comment":_.push(q);break;case"newline":return _.push(q),!0}return!1}function Wq(_,$,q){switch(_.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":_.type=q,_.source=$;break;case"block-scalar":{let T=_.props.slice(1),O=$.length;if(_.props[0].type==="block-scalar-header")O-=_.props[0].source.length;for(let H of T)H.offset+=O;delete _.props,Object.assign(_,{type:q,source:$,end:T});break}case"block-map":case"block-seq":{let O={type:"newline",offset:_.offset+$.length,indent:_.indent,source:`
|
|
115
|
+
`};delete _.items,Object.assign(_,{type:q,source:$,end:[O]});break}default:{let T="indent"in _?_.indent:-1,O="end"in _&&Array.isArray(_.end)?_.end.filter((H)=>H.type==="space"||H.type==="comment"||H.type==="newline"):[];for(let H of Object.keys(_))if(H!=="type"&&H!=="offset")delete _[H];Object.assign(_,{type:q,indent:T,source:$,end:O})}}}cU.createScalarToken=lU;cU.resolveAsScalar=mU;cU.setScalarValue=pU});var pT=V((rU)=>{var aU=(_)=>("type"in _)?r$(_):a$(_);function r$(_){switch(_.type){case"block-scalar":{let $="";for(let q of _.props)$+=r$(q);return $+_.source}case"block-map":case"block-seq":{let $="";for(let q of _.items)$+=a$(q);return $}case"flow-collection":{let $=_.start.source;for(let q of _.items)$+=a$(q);for(let q of _.end)$+=q.source;return $}case"document":{let $=a$(_);if(_.end)for(let q of _.end)$+=q.source;return $}default:{let $=_.source;if("end"in _&&_.end)for(let q of _.end)$+=q.source;return $}}}function a$({start:_,key:$,sep:q,value:T}){let O="";for(let H of _)O+=H.source;if($)O+=r$($);if(q)for(let H of q)O+=H.source;if(T)O+=r$(T);return O}rU.stringify=aU});var sT=V((eU)=>{var Gq=Symbol("break visit"),tU=Symbol("skip children"),dT=Symbol("remove item");function V_(_,$){if("type"in _&&_.type==="document")_={start:_.start,value:_.value};cT(Object.freeze([]),_,$)}V_.BREAK=Gq;V_.SKIP=tU;V_.REMOVE=dT;V_.itemAtPath=(_,$)=>{let q=_;for(let[T,O]of $){let H=q?.[T];if(H&&"items"in H)q=H.items[O];else return}return q};V_.parentCollection=(_,$)=>{let q=V_.itemAtPath(_,$.slice(0,-1)),T=$[$.length-1][0],O=q?.[T];if(O&&"items"in O)return O;throw Error("Parent collection not found")};function cT(_,$,q){let T=q($,_);if(typeof T==="symbol")return T;for(let O of["key","value"]){let H=$[O];if(H&&"items"in H){for(let X=0;X<H.items.length;++X){let U=cT(Object.freeze(_.concat([[O,X]])),H.items[X],q);if(typeof U==="number")X=U-1;else if(U===Gq)return Gq;else if(U===dT)H.items.splice(X,1),X-=1}if(typeof T==="function"&&O==="key")T=T($,_)}}return typeof T==="function"?T($,_):T}eU.visit=V_});var o$=V((U7)=>{var Rq=lT(),$7=pT(),q7=sT(),Yq="\uFEFF",Lq="\x02",Vq="\x18",Bq="\x1F",T7=(_)=>!!_&&("items"in _),O7=(_)=>!!_&&(_.type==="scalar"||_.type==="single-quoted-scalar"||_.type==="double-quoted-scalar"||_.type==="block-scalar");function H7(_){switch(_){case Yq:return"<BOM>";case Lq:return"<DOC>";case Vq:return"<FLOW_END>";case Bq:return"<SCALAR>";default:return JSON.stringify(_)}}function X7(_){switch(_){case Yq:return"byte-order-mark";case Lq:return"doc-mode";case Vq:return"flow-error-end";case Bq:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
116
116
|
`:case`\r
|
|
117
|
-
`: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(_[0]){case" ":case"\t":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}
|
|
118
|
-
`:case"\r":case"\t":return!0;default:return!1}}var
|
|
119
|
-
\r `),wq=(_)=>!_||
|
|
117
|
+
`: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(_[0]){case" ":case"\t":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}U7.createScalarToken=Rq.createScalarToken;U7.resolveAsScalar=Rq.resolveAsScalar;U7.setScalarValue=Rq.setScalarValue;U7.stringify=$7.stringify;U7.visit=q7.visit;U7.BOM=Yq;U7.DOCUMENT=Lq;U7.FLOW_END=Vq;U7.SCALAR=Bq;U7.isCollection=T7;U7.isScalar=O7;U7.prettyToken=H7;U7.tokenType=X7});var Dq=V((I7)=>{var $$=o$();function m(_){switch(_){case void 0:case" ":case`
|
|
118
|
+
`:case"\r":case"\t":return!0;default:return!1}}var iT=new Set("0123456789ABCDEFabcdef"),A7=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),t$=new Set(",[]{}"),M7=new Set(` ,[]{}
|
|
119
|
+
\r `),wq=(_)=>!_||M7.has(_);class nT{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(_,$=!1){if(_){if(typeof _!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+_:_,this.lineEndPos=null}this.atEnd=!$;let q=this.next??"stream";while(q&&($||this.hasChars(1)))q=yield*this.parseNext(q)}atLineEnd(){let _=this.pos,$=this.buffer[_];while($===" "||$==="\t")$=this.buffer[++_];if(!$||$==="#"||$===`
|
|
120
120
|
`)return!0;if($==="\r")return this.buffer[_+1]===`
|
|
121
121
|
`;return!1}charAt(_){return this.buffer[this.pos+_]}continueScalar(_){let $=this.buffer[_];if(this.indentNext>0){let q=0;while($===" ")$=this.buffer[++q+_];if($==="\r"){let T=this.buffer[q+_+1];if(T===`
|
|
122
122
|
`||!T&&!this.atEnd)return _+q+1}return $===`
|
|
@@ -131,17 +131,17 @@ ${$.comment}`:$.comment}this.doc.range[2]=$.offset;break}default:this.errors.pus
|
|
|
131
131
|
`&&O>=this.pos&&O+1+$>X)_=O;else break}while(!0);return yield $$.SCALAR,yield*this.pushToIndex(_+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let _=this.flowLevel>0,$=this.pos-1,q=this.pos-1,T;while(T=this.buffer[++q])if(T===":"){let O=this.buffer[q+1];if(m(O)||_&&t$.has(O))break;$=q}else if(m(T)){let O=this.buffer[q+1];if(T==="\r")if(O===`
|
|
132
132
|
`)q+=1,T=`
|
|
133
133
|
`,O=this.buffer[q+1];else $=q;if(O==="#"||_&&t$.has(O))break;if(T===`
|
|
134
|
-
`){let H=this.continueScalar(q+1);if(H===-1)break;q=Math.max(q,H-2)}}else{if(_&&t$.has(T))break;$=q}if(!T&&!this.atEnd)return this.setNext("plain-scalar");return yield $$.SCALAR,yield*this.pushToIndex($+1,!0),_?"flow":"doc"}*pushCount(_){if(_>0)return yield this.buffer.substr(this.pos,_),this.pos+=_,_;return 0}*pushToIndex(_,$){let q=this.buffer.slice(this.pos,_);if(q)return yield q,this.pos+=q.length,q.length;else if($)yield"";return 0}*pushIndicators(){let _=0;_:while(!0){switch(this.charAt(0)){case"!":_+=yield*this.pushTag(),_+=yield*this.pushSpaces(!0);continue _;case"&":_+=yield*this.pushUntil(wq),_+=yield*this.pushSpaces(!0);continue _;case"-":case"?":case":":{let $=this.flowLevel>0,q=this.charAt(1);if(m(q)||$&&t$.has(q)){if(!$)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;_+=yield*this.pushCount(1),_+=yield*this.pushSpaces(!0);continue _}}}break _}return _}*pushTag(){if(this.charAt(1)==="<"){let _=this.pos+2,$=this.buffer[_];while(!m($)&&$!==">")$=this.buffer[++_];return yield*this.pushToIndex($===">"?_+1:_,!1)}else{let _=this.pos+1,$=this.buffer[_];while($)if(
|
|
134
|
+
`){let H=this.continueScalar(q+1);if(H===-1)break;q=Math.max(q,H-2)}}else{if(_&&t$.has(T))break;$=q}if(!T&&!this.atEnd)return this.setNext("plain-scalar");return yield $$.SCALAR,yield*this.pushToIndex($+1,!0),_?"flow":"doc"}*pushCount(_){if(_>0)return yield this.buffer.substr(this.pos,_),this.pos+=_,_;return 0}*pushToIndex(_,$){let q=this.buffer.slice(this.pos,_);if(q)return yield q,this.pos+=q.length,q.length;else if($)yield"";return 0}*pushIndicators(){let _=0;_:while(!0){switch(this.charAt(0)){case"!":_+=yield*this.pushTag(),_+=yield*this.pushSpaces(!0);continue _;case"&":_+=yield*this.pushUntil(wq),_+=yield*this.pushSpaces(!0);continue _;case"-":case"?":case":":{let $=this.flowLevel>0,q=this.charAt(1);if(m(q)||$&&t$.has(q)){if(!$)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;_+=yield*this.pushCount(1),_+=yield*this.pushSpaces(!0);continue _}}}break _}return _}*pushTag(){if(this.charAt(1)==="<"){let _=this.pos+2,$=this.buffer[_];while(!m($)&&$!==">")$=this.buffer[++_];return yield*this.pushToIndex($===">"?_+1:_,!1)}else{let _=this.pos+1,$=this.buffer[_];while($)if(A7.has($))$=this.buffer[++_];else if($==="%"&&iT.has(this.buffer[_+1])&&iT.has(this.buffer[_+2]))$=this.buffer[_+=3];else break;return yield*this.pushToIndex(_,!1)}}*pushNewline(){let _=this.buffer[this.pos];if(_===`
|
|
135
135
|
`)return yield*this.pushCount(1);else if(_==="\r"&&this.charAt(1)===`
|
|
136
|
-
`)return yield*this.pushCount(2);else return 0}*pushSpaces(_){let $=this.pos-1,q;do q=this.buffer[++$];while(q===" "||_&&q==="\t");let T=$-this.pos;if(T>0)yield this.buffer.substr(this.pos,T),this.pos=$;return T}*pushUntil(_){let $=this.pos,q=this.buffer[$];while(!_(q))q=this.buffer[++$];return yield*this.pushToIndex($,!1)}}
|
|
136
|
+
`)return yield*this.pushCount(2);else return 0}*pushSpaces(_){let $=this.pos-1,q;do q=this.buffer[++$];while(q===" "||_&&q==="\t");let T=$-this.pos;if(T>0)yield this.buffer.substr(this.pos,T),this.pos=$;return T}*pushUntil(_){let $=this.pos,q=this.buffer[$];while(!_(q))q=this.buffer[++$];return yield*this.pushToIndex($,!1)}}I7.Lexer=nT});var Aq=V((S7)=>{class aT{constructor(){this.lineStarts=[],this.addNewLine=(_)=>this.lineStarts.push(_),this.linePos=(_)=>{let $=0,q=this.lineStarts.length;while($<q){let O=$+q>>1;if(this.lineStarts[O]<_)$=O+1;else q=O}if(this.lineStarts[$]===_)return{line:$+1,col:1};if($===0)return{line:0,col:_};let T=this.lineStarts[$-1];return{line:$,col:_-T+1}}}}S7.LineCounter=aT});var Mq=V((P7)=>{var N7=W$("process"),rT=o$(),C7=Dq();function X_(_,$){for(let q=0;q<_.length;++q)if(_[q].type===$)return!0;return!1}function oT(_){for(let $=0;$<_.length;++$)switch(_[$].type){case"space":case"comment":case"newline":break;default:return $}return-1}function eT(_){switch(_?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function e$(_){switch(_.type){case"document":return _.start;case"block-map":{let $=_.items[_.items.length-1];return $.sep??$.start}case"block-seq":return _.items[_.items.length-1].start;default:return[]}}function E_(_){if(_.length===0)return[];let $=_.length;_:while(--$>=0)switch(_[$].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break _}while(_[++$]?.type==="space");return _.splice($,_.length)}function _0(_,$){if($.length<1e5)Array.prototype.push.apply(_,$);else for(let q=0;q<$.length;++q)_.push($[q])}function tT(_){if(_.start.type==="flow-seq-start"){for(let $ of _.items)if($.sep&&!$.value&&!X_($.start,"explicit-key-ind")&&!X_($.sep,"map-value-ind")){if($.key)$.value=$.key;if(delete $.key,eT($.value))if($.value.end)_0($.value.end,$.sep);else $.value.end=$.sep;else _0($.start,$.sep);delete $.sep}}}class _O{constructor(_){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new C7.Lexer,this.onNewLine=_}*parse(_,$=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let q of this.lexer.lex(_,$))yield*this.next(q);if(!$)yield*this.end()}*next(_){if(this.source=_,N7.env.LOG_TOKENS)console.log("|",rT.prettyToken(_));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=_.length;return}let $=rT.tokenType(_);if(!$){let q=`Not a YAML token: ${_}`;yield*this.pop({type:"error",offset:this.offset,message:q,source:_}),this.offset+=_.length}else if($==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=$,yield*this.step(),$){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+_.length);break;case"space":if(this.atNewLine&&_[0]===" ")this.indent+=_.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=_.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=_.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let _=this.peek(1);if(this.type==="doc-end"&&_?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!_)return yield*this.stream();switch(_.type){case"document":return yield*this.document(_);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(_);case"block-scalar":return yield*this.blockScalar(_);case"block-map":return yield*this.blockMap(_);case"block-seq":return yield*this.blockSequence(_);case"flow-collection":return yield*this.flowCollection(_);case"doc-end":return yield*this.documentEnd(_)}yield*this.pop()}peek(_){return this.stack[this.stack.length-_]}*pop(_){let $=_??this.stack.pop();if(!$)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield $;else{let q=this.peek(1);if($.type==="block-scalar")$.indent="indent"in q?q.indent:0;else if($.type==="flow-collection"&&q.type==="document")$.indent=0;if($.type==="flow-collection")tT($);switch(q.type){case"document":q.value=$;break;case"block-scalar":q.props.push($);break;case"block-map":{let T=q.items[q.items.length-1];if(T.value){q.items.push({start:[],key:$,sep:[]}),this.onKeyLine=!0;return}else if(T.sep)T.value=$;else{Object.assign(T,{key:$,sep:[]}),this.onKeyLine=!T.explicitKey;return}break}case"block-seq":{let T=q.items[q.items.length-1];if(T.value)q.items.push({start:[],value:$});else T.value=$;break}case"flow-collection":{let T=q.items[q.items.length-1];if(!T||T.value)q.items.push({start:[],key:$,sep:[]});else if(T.sep)T.value=$;else Object.assign(T,{key:$,sep:[]});return}default:yield*this.pop(),yield*this.pop($)}if((q.type==="document"||q.type==="block-map"||q.type==="block-seq")&&($.type==="block-map"||$.type==="block-seq")){let T=$.items[$.items.length-1];if(T&&!T.sep&&!T.value&&T.start.length>0&&oT(T.start)===-1&&($.indent===0||T.start.every((O)=>O.type!=="comment"||O.indent<$.indent))){if(q.type==="document")q.end=T.start;else q.items.push({start:T.start});$.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 _={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")_.start.push(this.sourceToken);this.stack.push(_);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(_){if(_.value)return yield*this.lineEnd(_);switch(this.type){case"doc-start":{if(oT(_.start)!==-1)yield*this.pop(),yield*this.step();else _.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":_.start.push(this.sourceToken);return}let $=this.startBlockValue(_);if($)this.stack.push($);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(_){if(this.type==="map-value-ind"){let $=e$(this.peek(2)),q=E_($),T;if(_.end)T=_.end,T.push(this.sourceToken),delete _.end;else T=[this.sourceToken];let O={type:"block-map",offset:_.offset,indent:_.indent,items:[{start:q,key:_,sep:T}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=O}else yield*this.lineEnd(_)}*blockScalar(_){switch(this.type){case"space":case"comment":case"newline":_.props.push(this.sourceToken);return;case"scalar":if(_.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let $=this.source.indexOf(`
|
|
137
137
|
`)+1;while($!==0)this.onNewLine(this.offset+$),$=this.source.indexOf(`
|
|
138
|
-
`,$)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(_){let $=_.items[_.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,$.value){let q="end"in $.value?$.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else _.items.push({start:[this.sourceToken]})}else if($.sep)$.sep.push(this.sourceToken);else $.start.push(this.sourceToken);return;case"space":case"comment":if($.value)_.items.push({start:[this.sourceToken]});else if($.sep)$.sep.push(this.sourceToken);else{if(this.atIndentedComment($.start,_.indent)){let T=_.items[_.items.length-2]?.value?.end;if(Array.isArray(T)){_0(T,$.start),T.push(this.sourceToken),_.items.pop();return}}$.start.push(this.sourceToken)}return}if(this.indent>=_.indent){let q=!this.onKeyLine&&this.indent===_.indent,T=q&&($.sep||$.explicitKey)&&this.type!=="seq-item-ind",O=[];if(T&&$.sep&&!$.value){let H=[];for(let X=0;X<$.sep.length;++X){let U=$.sep[X];switch(U.type){case"newline":H.push(X);break;case"space":break;case"comment":if(U.indent>_.indent)H.length=0;break;default:H.length=0}}if(H.length>=2)O=$.sep.splice(H[1])}switch(this.type){case"anchor":case"tag":if(T||$.value)O.push(this.sourceToken),_.items.push({start:O}),this.onKeyLine=!0;else if($.sep)$.sep.push(this.sourceToken);else $.start.push(this.sourceToken);return;case"explicit-key-ind":if(!$.sep&&!$.explicitKey)$.start.push(this.sourceToken),$.explicitKey=!0;else if(T||$.value)O.push(this.sourceToken),_.items.push({start:O,explicitKey:!0});else 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($.explicitKey)if(!$.sep)if(X_($.start,"newline"))Object.assign($,{key:null,sep:[this.sourceToken]});else{let H=E_($.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:H,key:null,sep:[this.sourceToken]}]})}else if($.value)_.items.push({start:[],key:null,sep:[this.sourceToken]});else if(X_($.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(
|
|
138
|
+
`,$)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(_){let $=_.items[_.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,$.value){let q="end"in $.value?$.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else _.items.push({start:[this.sourceToken]})}else if($.sep)$.sep.push(this.sourceToken);else $.start.push(this.sourceToken);return;case"space":case"comment":if($.value)_.items.push({start:[this.sourceToken]});else if($.sep)$.sep.push(this.sourceToken);else{if(this.atIndentedComment($.start,_.indent)){let T=_.items[_.items.length-2]?.value?.end;if(Array.isArray(T)){_0(T,$.start),T.push(this.sourceToken),_.items.pop();return}}$.start.push(this.sourceToken)}return}if(this.indent>=_.indent){let q=!this.onKeyLine&&this.indent===_.indent,T=q&&($.sep||$.explicitKey)&&this.type!=="seq-item-ind",O=[];if(T&&$.sep&&!$.value){let H=[];for(let X=0;X<$.sep.length;++X){let U=$.sep[X];switch(U.type){case"newline":H.push(X);break;case"space":break;case"comment":if(U.indent>_.indent)H.length=0;break;default:H.length=0}}if(H.length>=2)O=$.sep.splice(H[1])}switch(this.type){case"anchor":case"tag":if(T||$.value)O.push(this.sourceToken),_.items.push({start:O}),this.onKeyLine=!0;else if($.sep)$.sep.push(this.sourceToken);else $.start.push(this.sourceToken);return;case"explicit-key-ind":if(!$.sep&&!$.explicitKey)$.start.push(this.sourceToken),$.explicitKey=!0;else if(T||$.value)O.push(this.sourceToken),_.items.push({start:O,explicitKey:!0});else 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($.explicitKey)if(!$.sep)if(X_($.start,"newline"))Object.assign($,{key:null,sep:[this.sourceToken]});else{let H=E_($.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:H,key:null,sep:[this.sourceToken]}]})}else if($.value)_.items.push({start:[],key:null,sep:[this.sourceToken]});else if(X_($.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(eT($.key)&&!X_($.sep,"newline")){let H=E_($.start),X=$.key,U=$.sep;U.push(this.sourceToken),delete $.key,delete $.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:H,key:X,sep:U}]})}else if(O.length>0)$.sep=$.sep.concat(O,this.sourceToken);else $.sep.push(this.sourceToken);else if(!$.sep)Object.assign($,{key:null,sep:[this.sourceToken]});else if($.value||T)_.items.push({start:O,key:null,sep:[this.sourceToken]});else if(X_($.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else $.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let H=this.flowScalar(this.type);if(T||$.value)_.items.push({start:O,key:H,sep:[]}),this.onKeyLine=!0;else if($.sep)this.stack.push(H);else Object.assign($,{key:H,sep:[]}),this.onKeyLine=!0;return}default:{let H=this.startBlockValue(_);if(H){if(H.type==="block-seq"){if(!$.explicitKey&&$.sep&&!X_($.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 if(q)_.items.push({start:O});this.stack.push(H);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(_){let $=_.items[_.items.length-1];switch(this.type){case"newline":if($.value){let q="end"in $.value?$.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else _.items.push({start:[this.sourceToken]})}else $.start.push(this.sourceToken);return;case"space":case"comment":if($.value)_.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment($.start,_.indent)){let T=_.items[_.items.length-2]?.value?.end;if(Array.isArray(T)){_0(T,$.start),T.push(this.sourceToken),_.items.pop();return}}$.start.push(this.sourceToken)}return;case"anchor":case"tag":if($.value||this.indent<=_.indent)break;$.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==_.indent)break;if($.value||X_($.start,"seq-item-ind"))_.items.push({start:[this.sourceToken]});else $.start.push(this.sourceToken);return}if(this.indent>_.indent){let q=this.startBlockValue(_);if(q){this.stack.push(q);return}}yield*this.pop(),yield*this.step()}*flowCollection(_){let $=_.items[_.items.length-1];if(this.type==="flow-error-end"){let q;do yield*this.pop(),q=this.peek(1);while(q?.type==="flow-collection")}else if(_.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!$||$.sep)_.items.push({start:[this.sourceToken]});else $.start.push(this.sourceToken);return;case"map-value-ind":if(!$||$.value)_.items.push({start:[],key:null,sep:[this.sourceToken]});else if($.sep)$.sep.push(this.sourceToken);else Object.assign($,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!$||$.value)_.items.push({start:[this.sourceToken]});else if($.sep)$.sep.push(this.sourceToken);else $.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let T=this.flowScalar(this.type);if(!$||$.value)_.items.push({start:[],key:T,sep:[]});else if($.sep)this.stack.push(T);else Object.assign($,{key:T,sep:[]});return}case"flow-map-end":case"flow-seq-end":_.end.push(this.sourceToken);return}let q=this.startBlockValue(_);if(q)this.stack.push(q);else yield*this.pop(),yield*this.step()}else{let q=this.peek(2);if(q.type==="block-map"&&(this.type==="map-value-ind"&&q.indent===_.indent||this.type==="newline"&&!q.items[q.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&q.type!=="flow-collection"){let T=e$(q),O=E_(T);tT(_);let H=_.end.splice(1,_.end.length);H.push(this.sourceToken);let X={type:"block-map",offset:_.offset,indent:_.indent,items:[{start:O,key:_,sep:H}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=X}else yield*this.lineEnd(_)}}flowScalar(_){if(this.onNewLine){let $=this.source.indexOf(`
|
|
139
139
|
`)+1;while($!==0)this.onNewLine(this.offset+$),$=this.source.indexOf(`
|
|
140
|
-
`,$)+1}return{type:_,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(_){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 $=e$(_),q=E_($);return q.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let $=e$(_),q=E_($);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(_,$){if(this.type!=="comment")return!1;if(this.indent<=$)return!1;return _.every((q)=>q.type==="newline"||q.type==="space")}*documentEnd(_){if(this.type!=="doc-mode"){if(_.end)_.end.push(this.sourceToken);else _.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(_){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;case"space":case"comment":default:if(_.end)_.end.push(this.sourceToken);else _.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}
|
|
141
|
-
`)){let T=q.trim();if(T===""||T.startsWith("#")||T.startsWith("["))continue;let O=T.match(/^([\w.]+)\s*=\s*(.*)$/);if(!O)continue;let H=O[1],X=O[2].trim();if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'"))X=X.slice(1,-1);$[H]=X}return $}function O0(_){if(!
|
|
142
|
-
`),X=`${T} = "${q}"`,U=!1,
|
|
140
|
+
`,$)+1}return{type:_,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(_){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 $=e$(_),q=E_($);return q.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let $=e$(_),q=E_($);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(_,$){if(this.type!=="comment")return!1;if(this.indent<=$)return!1;return _.every((q)=>q.type==="newline"||q.type==="space")}*documentEnd(_){if(this.type!=="doc-mode"){if(_.end)_.end.push(this.sourceToken);else _.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(_){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;case"space":case"comment":default:if(_.end)_.end.push(this.sourceToken);else _.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}P7.Parser=_O});var HO=V((u7)=>{var $O=Qq(),E7=r_(),q$=o_(),j7=A0(),b7=S(),y7=Aq(),qO=Mq();function TO(_){let $=_.prettyErrors!==!1;return{lineCounter:_.lineCounter||$&&new y7.LineCounter||null,prettyErrors:$}}function g7(_,$={}){let{lineCounter:q,prettyErrors:T}=TO($),O=new qO.Parser(q?.addNewLine),H=new $O.Composer($),X=Array.from(H.compose(O.parse(_)));if(T&&q)for(let U of X)U.errors.forEach(q$.prettifyError(_,q)),U.warnings.forEach(q$.prettifyError(_,q));if(X.length>0)return X;return Object.assign([],{empty:!0},H.streamInfo())}function OO(_,$={}){let{lineCounter:q,prettyErrors:T}=TO($),O=new qO.Parser(q?.addNewLine),H=new $O.Composer($),X=null;for(let U of H.compose(O.parse(_),!0,_.length))if(!X)X=U;else if(X.options.logLevel!=="silent"){X.errors.push(new q$.YAMLParseError(U.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(T&&q)X.errors.forEach(q$.prettifyError(_,q)),X.warnings.forEach(q$.prettifyError(_,q));return X}function x7(_,$,q){let T=void 0;if(typeof $==="function")T=$;else if(q===void 0&&$&&typeof $==="object")q=$;let O=OO(_,q);if(!O)return null;if(O.warnings.forEach((H)=>j7.warn(O.options.logLevel,H)),O.errors.length>0)if(O.options.logLevel!=="silent")throw O.errors[0];else O.errors=[];return O.toJS(Object.assign({reviver:T},q))}function k7(_,$,q){let T=null;if(typeof $==="function"||Array.isArray($))T=$;else if(q===void 0&&$)q=$;if(typeof q==="string")q=q.length;if(typeof q==="number"){let O=Math.round(q);q=O<1?void 0:O>8?{indent:8}:{indent:O}}if(_===void 0){let{keepUndefined:O}=q??$??{};if(!O)return}if(b7.isDocument(_)&&!T)return _.toString(q);return new E7.Document(_,T,q).toString(q)}u7.parse=x7;u7.parseAllDocuments=g7;u7.parseDocument=OO;u7.stringify=k7});import{existsSync as nq,mkdirSync as W0,readFileSync as rq,writeFileSync as aq}from"node:fs";import{dirname as KH,isAbsolute as _3,join as NH,resolve as $3}from"node:path";var p7=Qq(),d7=r_(),c7=a0(),Iq=o_(),s7=x_(),U_=S(),i7=q_(),n7=f(),a7=O_(),r7=H_(),KJ=o$(),o7=Dq(),t7=Aq(),e7=Mq(),$0=HO(),XO=y_();var _Z=p7.Composer,$Z=d7.Document,qZ=c7.Schema,TZ=Iq.YAMLError,OZ=Iq.YAMLParseError,HZ=Iq.YAMLWarning,XZ=s7.Alias,UZ=U_.isAlias,ZZ=U_.isCollection,JZ=U_.isDocument,zZ=U_.isMap,QZ=U_.isNode,WZ=U_.isPair,GZ=U_.isScalar,RZ=U_.isSeq,YZ=i7.Pair,LZ=n7.Scalar,VZ=a7.YAMLMap,BZ=r7.YAMLSeq;var wZ=o7.Lexer,DZ=t7.LineCounter,AZ=e7.Parser,q0=$0.parse,MZ=$0.parseAllDocuments,IZ=$0.parseDocument,Fq=$0.stringify,FZ=XO.visit,SZ=XO.visitAsync;var KZ=new Set(["none","low","medium","high"]),NZ=new Set(["low","medium","high"]);function T0(_,$){if(!_||typeof _!=="object"||Array.isArray(_))throw Error(`${$} must be an object`);return _}var CZ=/<[^>\n]*[\s\u4e00-\u9fff…][^>\n]*>|(空)|\(空\)|占位符|proj_xxxx|cc_xxxxxxxx/;function PZ(_,$){if(CZ.test(_))throw Error(`${$} still contains a placeholder; replace it with real content`)}function r(_,$,q=$){let T=_[$];if(typeof T!=="string"||T.trim()==="")throw Error(`Missing required string: ${q}`);return PZ(T,q),T}function UO(_,$){let q=_[$];if(typeof q!=="string"||q.trim()==="")return null;return q}function fZ(_,$,q){let T=_[$];if(T==null)return[];if(!Array.isArray(T)||T.some((O)=>typeof O!=="string"))throw Error(`${q} must be a string array`);return T}function ZO(_){if(!("confidence"in _))return null;let $=_.confidence;if(typeof $!=="string"||!NZ.has($))throw Error(`Invalid confidence: ${String($)}`);return $}function JO(_){let $=T0(q0(_),"summaries.yaml"),q=r($,"project_id");if(!Array.isArray($.summaries))throw Error("summaries must be an array");return{projectId:q,summaries:$.summaries.map((T,O)=>{let H=`summaries[${O}]`,X=T0(T,`summaries[${O}]`),U=r(X,"value",`${H}.value`);if(!KZ.has(U))throw Error(`Invalid summary value: ${U}`);return ZO(X),{sessionId:r(X,"session_id",`${H}.session_id`),title:r(X,"title",`${H}.title`),value:U,summaryMarkdown:r(X,"summary_markdown",`${H}.summary_markdown`),metadata:X}})}}function zO(_){let $=T0(q0(_),"experiences.yaml"),q=r($,"project_id");if(!Array.isArray($.experiences))throw Error("experiences must be an array");return{projectId:q,experiences:$.experiences.map((T,O)=>{let H=`experiences[${O}]`,X=T0(T,H),U=X.source_sessions;if(!Array.isArray(U)||U.some((J)=>typeof J!=="string"))throw Error(`experiences[${O}].source_sessions must be a string array`);let Z=ZO(X);return{title:r(X,"title",`${H}.title`),slug:typeof X.slug==="string"?X.slug:null,summary:r(X,"summary",`${H}.summary`),bodyMarkdown:r(X,"body_markdown",`${H}.body_markdown`),sourceSessions:U,confidence:Z,topic:UO(X,"topic"),techStack:fZ(X,"tech_stack",`${H}.tech_stack`),problemType:UO(X,"problem_type"),metadata:X}})}}import{existsSync as QO,readFileSync as WO,writeFileSync as EZ}from"node:fs";var jZ={"obsidian.vault":"obsidian_vault",obsidian_vault:"obsidian_vault"};function bZ(_){let $={};for(let q of _.split(`
|
|
141
|
+
`)){let T=q.trim();if(T===""||T.startsWith("#")||T.startsWith("["))continue;let O=T.match(/^([\w.]+)\s*=\s*(.*)$/);if(!O)continue;let H=O[1],X=O[2].trim();if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'"))X=X.slice(1,-1);$[H]=X}return $}function O0(_){if(!QO(_))return{obsidianVault:null};let q=bZ(WO(_,"utf8")).obsidian_vault;return{obsidianVault:q&&q.trim()!==""?q:null}}function GO(_,$,q){let T=jZ[$];if(!T)throw Error(`Unknown config key: ${$}. Supported: obsidian.vault`);let H=(QO(_)?WO(_,"utf8"):"").split(`
|
|
142
|
+
`),X=`${T} = "${q}"`,U=!1,Z=H.map((J)=>{if(J.trim().startsWith(`${T} `)||J.trim().startsWith(`${T}=`))return U=!0,X;return J});if(!U)Z.push(X);return EZ(_,`${Z.filter((J,z)=>!(J===""&&z===Z.length-1)).join(`
|
|
143
143
|
`)}
|
|
144
|
-
`),T}import{mkdirSync as
|
|
144
|
+
`),T}import{mkdirSync as yZ}from"node:fs";import{createRequire as gZ}from"node:module";import{dirname as xZ}from"node:path";var RO=gZ(import.meta.url),YO=typeof globalThis.Bun<"u";function LO(_,$){let q=$?{readonly:!0}:void 0;if(YO){let{Database:H}=RO("bun:sqlite");return new H(_,q)}return new(RO("better-sqlite3"))(_,q)}function kZ(_){return typeof _==="object"&&_!==null&&!Array.isArray(_)&&!Buffer.isBuffer(_)}function Sq(_){if(_.length!==1||!kZ(_[0]))return _;if(YO)return _;let $={};for(let[q,T]of Object.entries(_[0]))$[q.replace(/^[$@:]/,"")]=T;return[$]}class VO{statement;constructor(_){this.statement=_}get(..._){return this.statement.get(...Sq(_))??null}all(..._){return this.statement.all(...Sq(_))}run(..._){return this.statement.run(...Sq(_))}}class Kq{raw;constructor(_){this.raw=_}query(_){return new VO(this.raw.prepare(_))}exec(_){this.raw.exec(_)}transaction(_){return this.raw.transaction(_)}close(){this.raw.close()}}function C(_){return yZ(xZ(_),{recursive:!0}),new Kq(LO(_,!1))}function BO(_){try{return new Kq(LO(_,!0))}catch{return null}}function T$(_,$,q,T){if(_.query(`PRAGMA table_info(${$})`).all().some((H)=>H.name===q))return;_.exec(`ALTER TABLE ${$} ADD COLUMN ${q} ${T}`)}function P(_){_.exec(`
|
|
145
145
|
PRAGMA journal_mode = WAL;
|
|
146
146
|
|
|
147
147
|
CREATE TABLE IF NOT EXISTS projects (
|
|
@@ -279,18 +279,18 @@ ${$.comment}`:$.comment}this.doc.range[2]=$.offset;break}default:this.errors.pus
|
|
|
279
279
|
conflict_status TEXT NOT NULL,
|
|
280
280
|
UNIQUE(note_type, entity_id)
|
|
281
281
|
);
|
|
282
|
-
`),T$(_,"experience_candidates","proposed_summary","TEXT"),T$(_,"experience_candidates","tech_stack_json","TEXT"),T$(_,"experience_candidates","problem_type","TEXT"),T$(_,"experience_candidates","topic","TEXT"),T$(_,"experiences","topic","TEXT")}import{createHash as
|
|
282
|
+
`),T$(_,"experience_candidates","proposed_summary","TEXT"),T$(_,"experience_candidates","tech_stack_json","TEXT"),T$(_,"experience_candidates","problem_type","TEXT"),T$(_,"experience_candidates","topic","TEXT"),T$(_,"experiences","topic","TEXT")}import{createHash as uZ}from"node:crypto";function h(_){return uZ("sha1").update(_).digest("hex").slice(0,16)}import{spawnSync as hZ}from"node:child_process";import{existsSync as DO}from"node:fs";import{basename as vZ,resolve as Cq}from"node:path";function mZ(_){return _.trim().replace(/\/+$/,"").replace(/^ssh:\/\/git@([^/]+)\//,"$1/").replace(/^git@([^:]+):/,"$1/").replace(/^https?:\/\//,"").replace(/\.git$/,"")}function X0(_){return _.normalize("NFKD").replace(/[^\w\s./-]/g,"").trim().toLowerCase().replace(/[\s._/]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"project"}function wO(_,$){let q=hZ("git",$,{cwd:_,encoding:"utf8"});if(q.status!==0)return null;return q.stdout.trim()||null}function Pq(_){let $=wO(_,["rev-parse","--show-toplevel"]),q=wO(_,["config","--get","remote.origin.url"]),T=q?mZ(q):null,O=T??vZ($??_),H=X0(O);return{id:`proj_${h(T??$??_)}`,canonicalName:O,slug:H,canonicalRepoUrl:T,identitySource:T?"git_remote":"path"}}function Nq(_,$,q,T){let O=`alias_${h(`${q}\x00${T}`)}`;_.query(`
|
|
283
283
|
INSERT INTO project_aliases (id, project_id, alias_type, alias_value)
|
|
284
284
|
VALUES ($id, $projectId, $aliasType, $aliasValue)
|
|
285
285
|
ON CONFLICT(id) DO UPDATE SET project_id = excluded.project_id
|
|
286
|
-
`).run({$id:O,$projectId:$,$aliasType:q,$aliasValue:T})}function
|
|
286
|
+
`).run({$id:O,$projectId:$,$aliasType:q,$aliasValue:T})}function lZ(_,$,q){if(Nq(_,$.id,"path",q),Nq(_,$.id,"slug",$.slug),$.canonicalRepoUrl)Nq(_,$.id,"repo",$.canonicalRepoUrl);let T=new Date().toISOString(),O=`chk_${h(q)}`;_.query(`
|
|
287
287
|
INSERT INTO project_checkouts (id, project_id, local_path, git_root, remote_url, canonical_remote_url, current_branch, first_seen_at, last_seen_at)
|
|
288
288
|
VALUES ($id, $projectId, $localPath, NULL, NULL, $canonicalRepoUrl, NULL, $now, $now)
|
|
289
289
|
ON CONFLICT(id) DO UPDATE SET
|
|
290
290
|
project_id = excluded.project_id,
|
|
291
291
|
canonical_remote_url = excluded.canonical_remote_url,
|
|
292
292
|
last_seen_at = excluded.last_seen_at
|
|
293
|
-
`).run({$id:O,$projectId:$.id,$localPath:q,$canonicalRepoUrl:$.canonicalRepoUrl,$now:T})}function
|
|
293
|
+
`).run({$id:O,$projectId:$.id,$localPath:q,$canonicalRepoUrl:$.canonicalRepoUrl,$now:T})}function AO(_,$,q){let T=new Date().toISOString();if(_.query(`
|
|
294
294
|
INSERT INTO projects (id, canonical_name, display_name, slug, canonical_repo_url, provider, identity_source, created_at, updated_at)
|
|
295
295
|
VALUES ($id, $canonicalName, NULL, $slug, $canonicalRepoUrl, NULL, $identitySource, $now, $now)
|
|
296
296
|
ON CONFLICT(id) DO UPDATE SET
|
|
@@ -299,7 +299,7 @@ ${$.comment}`:$.comment}this.doc.range[2]=$.offset;break}default:this.errors.pus
|
|
|
299
299
|
canonical_repo_url = excluded.canonical_repo_url,
|
|
300
300
|
identity_source = excluded.identity_source,
|
|
301
301
|
updated_at = excluded.updated_at
|
|
302
|
-
`).run({$id:$.id,$canonicalName:$.canonicalName,$slug:$.slug,$canonicalRepoUrl:$.canonicalRepoUrl,$identitySource:$.identitySource,$now:T}),q)
|
|
302
|
+
`).run({$id:$.id,$canonicalName:$.canonicalName,$slug:$.slug,$canonicalRepoUrl:$.canonicalRepoUrl,$identitySource:$.identitySource,$now:T}),q)lZ(_,$,q);return Z_(_,$.id)}function fq(_,$){let q=Cq($);if(!DO(q))throw Error(`Path does not exist: ${q}`);return AO(_,Pq(q),q)}function MO(_,$){let q=Cq($);return AO(_,Pq(q),q)}class O$ extends Error{ref;candidates;constructor(_,$){super($.length===0?`No project matched: ${_}`:`Ambiguous project reference: ${_} (${$.length} candidates)`);this.ref=_;this.candidates=$;this.name="ProjectResolutionError"}}function pZ(_,$,q){let T=J_(_),O=new Map(T.map((z)=>[z.id,z])),H=new Map,X=(z)=>{if(z)H.set(z.id,z)};if($.startsWith("proj_"))return X(O.get($)),[...H.values()];let U=Cq(q,$);if(DO(U)){let z=Pq(U);if(X(O.get(z.id)),z.canonicalRepoUrl){for(let W of T)if(W.canonicalRepoUrl===z.canonicalRepoUrl)X(W)}let Q=_.query("SELECT project_id FROM project_aliases WHERE alias_type = ? AND alias_value = ?").all("path",U);for(let W of Q)X(O.get(W.project_id));if(H.size>0)return H0([...H.values()])}let Z=$.trim().toLowerCase(),J=X0($);for(let z of T){let Q=[z.slug,z.canonicalName,z.displayName??""];if(z.slug===J)X(z);else if(Q.some((W)=>W.toLowerCase().includes(Z)))X(z)}return H0([...H.values()])}function H0(_){return[..._].sort(($,q)=>q.sessionCount-$.sessionCount||$.canonicalName.localeCompare(q.canonicalName))}function c(_,$,q){let T=pZ(_,$,q);if(T.length===0)throw new O$($,T);if(T.length===1)return Z_(_,T[0].id);let[O,H]=T;if(O&&H&&O.sessionCount===H.sessionCount)throw new O$($,T);return Z_(_,O.id)}function Eq(_,$,q){if($===q)throw Error("Cannot merge a project into itself");Z_(_,$),Z_(_,q);let T=0;return _.transaction(()=>{T=_.query("UPDATE sessions SET project_id = ? WHERE project_id = ?").run(q,$).changes,_.query("UPDATE session_summaries SET project_id = ? WHERE project_id = ?").run(q,$),_.query("UPDATE experience_candidates SET project_id = ? WHERE project_id = ?").run(q,$),_.query("UPDATE experiences SET project_id = ? WHERE project_id = ?").run(q,$),_.query("UPDATE project_aliases SET project_id = ? WHERE project_id = ?").run(q,$),_.query("UPDATE project_checkouts SET project_id = ? WHERE project_id = ?").run(q,$),_.query("UPDATE obsidian_notes SET entity_id = ? WHERE note_type = 'project-summary' AND entity_id = ?").run(q,$),_.query("DELETE FROM projects WHERE id = ?").run($)})(),{fromId:$,intoId:q,movedSessions:T}}function IO(_){let $=H0(J_(_)),q=new Map;for(let O of $){let H=O.canonicalRepoUrl?`repo:${O.canonicalRepoUrl}`:`slug:${O.slug}`,X=q.get(H)??[];X.push(O),q.set(H,X)}let T=[];for(let O of q.values()){if(O.length<2)continue;let H=H0(O),X=H[0];for(let U of H.slice(1))T.push(Eq(_,U.id,X.id))}return{merges:T}}function jq(_,$,q){let T=new Date().toISOString();if(_.query("UPDATE projects SET display_name = $displayName, updated_at = $now WHERE id = $projectId").run({$displayName:q,$projectId:$,$now:T}).changes===0)throw Error(`Project not found: ${$}`);return Z_(_,$)}function J_(_){return _.query(`
|
|
303
303
|
SELECT
|
|
304
304
|
p.id,
|
|
305
305
|
p.canonical_name,
|
|
@@ -313,7 +313,7 @@ ${$.comment}`:$.comment}this.doc.range[2]=$.offset;break}default:this.errors.pus
|
|
|
313
313
|
LEFT JOIN sessions s ON s.project_id = p.id
|
|
314
314
|
GROUP BY p.id
|
|
315
315
|
ORDER BY session_count DESC, p.canonical_name ASC
|
|
316
|
-
`).all().map((q)=>({id:q.id,canonicalName:q.canonical_name,displayName:q.display_name,slug:q.slug,canonicalRepoUrl:q.canonical_repo_url,identitySource:q.identity_source,sessionCount:q.session_count,lastSeenAt:q.last_seen_at}))}function
|
|
316
|
+
`).all().map((q)=>({id:q.id,canonicalName:q.canonical_name,displayName:q.display_name,slug:q.slug,canonicalRepoUrl:q.canonical_repo_url,identitySource:q.identity_source,sessionCount:q.session_count,lastSeenAt:q.last_seen_at}))}function Z_(_,$){let q=_.query("SELECT * FROM projects WHERE id = ?").get($);if(!q)throw Error(`Project not found: ${$}`);return{id:q.id,canonicalName:q.canonical_name,displayName:q.display_name,slug:q.slug,canonicalRepoUrl:q.canonical_repo_url,identitySource:q.identity_source}}var dZ=`## 输出格式(务必遵守)
|
|
317
317
|
|
|
318
318
|
本文件(\`experiences-task.md\`)是任务说明,请勿修改它。
|
|
319
319
|
请**另外新建**一个纯 YAML 文件 \`.llm-iwiki/exchange/experiences.yaml\`,然后运行:
|
|
@@ -349,18 +349,18 @@ experiences:
|
|
|
349
349
|
topic: backend # 可选,跨项目主题
|
|
350
350
|
tech_stack: [go, kratos] # 可选
|
|
351
351
|
problem_type: 登录态 # 可选
|
|
352
|
-
\`\`\``;function
|
|
352
|
+
\`\`\``;function cZ(_,$,q,T){let O=q==="changed-summaries"?"AND value IN ('medium', 'high')":"",H=T?"AND updated_at >= ?":"",X=T?[$,T]:[$];return _.query(`
|
|
353
353
|
SELECT session_id, title, value, summary_markdown
|
|
354
354
|
FROM session_summaries
|
|
355
355
|
WHERE project_id = ? ${O} ${H}
|
|
356
356
|
ORDER BY updated_at DESC
|
|
357
|
-
`).all(...X)}function
|
|
358
|
-
`));return{markdown:["# Experiences Task","",`project_id: ${$}`,`scope: ${q}`,`summaries: ${H.length}`,"",
|
|
357
|
+
`).all(...X)}function FO(_,$,q,T=null){let H=cZ(_,$,q,T).map((U)=>[`### ${U.session_id} — ${U.title}`,`- value: ${U.value}`,"",U.summary_markdown].join(`
|
|
358
|
+
`));return{markdown:["# Experiences Task","",`project_id: ${$}`,`scope: ${q}`,`summaries: ${H.length}`,"",dZ,"","---","",H.join(`
|
|
359
359
|
|
|
360
360
|
---
|
|
361
361
|
|
|
362
362
|
`),""].join(`
|
|
363
|
-
`),summaryCount:H.length}}function
|
|
363
|
+
`),summaryCount:H.length}}function SO(_){return h(_)}function KO(_,$){let q=new Date().toISOString(),T=0;return _.transaction(()=>{for(let H of $.experiences){let X=H.slug&&H.slug.trim()!==""?H.slug:X0(H.title),U=`cand_${SO(`${$.projectId}\x00${X}`)}`;_.query(`
|
|
364
364
|
INSERT INTO experience_candidates (
|
|
365
365
|
id, project_id, proposed_title, proposed_slug, proposed_summary, proposed_body_markdown,
|
|
366
366
|
source_sessions_json, confidence, tech_stack_json, problem_type, topic, status, created_at
|
|
@@ -377,7 +377,7 @@ experiences:
|
|
|
377
377
|
tech_stack_json = excluded.tech_stack_json,
|
|
378
378
|
problem_type = excluded.problem_type,
|
|
379
379
|
topic = excluded.topic
|
|
380
|
-
`).run({$id:U,$projectId:$.projectId,$title:H.title,$slug:X,$summary:H.summary,$body:H.bodyMarkdown,$sources:JSON.stringify(H.sourceSessions),$confidence:H.confidence,$techStack:H.techStack.length>0?JSON.stringify(H.techStack):null,$problemType:H.problemType,$topic:H.topic,$now:q}),T+=1}})(),{written:T}}function
|
|
380
|
+
`).run({$id:U,$projectId:$.projectId,$title:H.title,$slug:X,$summary:H.summary,$body:H.bodyMarkdown,$sources:JSON.stringify(H.sourceSessions),$confidence:H.confidence,$techStack:H.techStack.length>0?JSON.stringify(H.techStack):null,$problemType:H.problemType,$topic:H.topic,$now:q}),T+=1}})(),{written:T}}function NO(_,$){if($)return _.query("SELECT id, project_id, proposed_title, proposed_slug, confidence, status, source_sessions_json, created_at FROM experience_candidates WHERE project_id = ? ORDER BY created_at DESC").all($);return _.query("SELECT id, project_id, proposed_title, proposed_slug, confidence, status, source_sessions_json, created_at FROM experience_candidates ORDER BY created_at DESC").all()}function CO(_,$){let q=_.query("SELECT project_id, proposed_title, proposed_slug, proposed_summary, proposed_body_markdown, confidence, tech_stack_json, problem_type, topic, source_sessions_json FROM experience_candidates WHERE id = ?").get($);if(!q)throw Error(`Experience candidate not found: ${$}`);let T=[];try{let U=JSON.parse(q.source_sessions_json);if(Array.isArray(U))T=U.filter((Z)=>typeof Z==="string")}catch{T=[]}let O=new Date().toISOString(),H=`exp_${SO(`${q.project_id}\x00${q.proposed_slug}`)}`;return _.transaction(()=>{_.query(`
|
|
381
381
|
INSERT INTO experiences (
|
|
382
382
|
id, project_id, title, slug, summary, body_markdown, confidence, tech_stack_json, problem_type, topic, status, created_at, updated_at
|
|
383
383
|
) VALUES ($id, $projectId, $title, $slug, $summary, $body, $confidence, $techStack, $problemType, $topic, 'accepted', $now, $now)
|
|
@@ -391,14 +391,14 @@ experiences:
|
|
|
391
391
|
topic = excluded.topic,
|
|
392
392
|
status = 'accepted',
|
|
393
393
|
updated_at = excluded.updated_at
|
|
394
|
-
`).run({$id:H,$projectId:q.project_id,$title:q.proposed_title,$slug:q.proposed_slug,$summary:q.proposed_summary,$body:q.proposed_body_markdown,$confidence:q.confidence,$techStack:q.tech_stack_json,$problemType:q.problem_type,$topic:q.topic,$now:O});let
|
|
394
|
+
`).run({$id:H,$projectId:q.project_id,$title:q.proposed_title,$slug:q.proposed_slug,$summary:q.proposed_summary,$body:q.proposed_body_markdown,$confidence:q.confidence,$techStack:q.tech_stack_json,$problemType:q.problem_type,$topic:q.topic,$now:O});let Z=_.query("SELECT id FROM experiences WHERE project_id = ? AND slug = ?").get(q.project_id,q.proposed_slug)?.id??H;for(let J of T)_.query(`
|
|
395
395
|
INSERT INTO session_experience_links (session_id, experience_id, relation)
|
|
396
396
|
VALUES (?, ?, 'source')
|
|
397
397
|
ON CONFLICT(session_id, experience_id) DO NOTHING
|
|
398
|
-
`).run(Z
|
|
399
|
-
`)}function gO(_){let $=_.indexOf(
|
|
398
|
+
`).run(J,Z);_.query("UPDATE experience_candidates SET status = 'accepted' WHERE id = ?").run($)})(),{experienceId:H,slug:q.proposed_slug,linkedSessions:T.length}}function PO(_,$){if(_.query("UPDATE experience_candidates SET status = 'rejected' WHERE id = ?").run($).changes===0)throw Error(`Experience candidate not found: ${$}`)}import{existsSync as J0,mkdirSync as jO,readFileSync as bO,renameSync as sZ,writeFileSync as fO}from"node:fs";import{dirname as bq,join as o}from"node:path";var Z0="<!-- aiwiki:managed:start -->",yO="<!-- aiwiki:managed:end -->";function z0(_){return h(_)}function U$(_){let $=_.replace(/[\\/:*?"<>|]/g," ").replace(/\s+/g," ").trim().slice(0,80);return $===""?"untitled":$}function iZ(_){let $=Fq(_.frontmatter).trimEnd(),q=_.userSectionHeading??"## 我的补充";return["---",$,"---","",`# ${_.title}`,"",Z0,_.managedBody.trim(),yO,"",q,"",""].join(`
|
|
399
|
+
`)}function gO(_){let $=_.indexOf(Z0),q=_.indexOf(yO);if($===-1||q===-1||q<$)return null;return{before:_.slice(0,$+Z0.length),managed:_.slice($+Z0.length,q).trim(),after:_.slice(q)}}function nZ(_,$){return`${_.before}
|
|
400
400
|
${$.trim()}
|
|
401
|
-
${_.after}`}function
|
|
401
|
+
${_.after}`}function aZ(_,$,q){return _.query("SELECT managed_hash, file_path FROM obsidian_notes WHERE note_type = ? AND entity_id = ?").get($,q)}function U0(_,$,q,T,O,H){_.query(`
|
|
402
402
|
INSERT INTO obsidian_notes (id, note_type, entity_id, file_path, managed_hash, frontmatter_hash, last_exported_at, conflict_status)
|
|
403
403
|
VALUES ($id, $noteType, $entityId, $filePath, $managedHash, NULL, $now, $conflictStatus)
|
|
404
404
|
ON CONFLICT(note_type, entity_id) DO UPDATE SET
|
|
@@ -406,43 +406,43 @@ ${_.after}`}function a7(_,$,q){return _.query("SELECT managed_hash, file_path FR
|
|
|
406
406
|
managed_hash = excluded.managed_hash,
|
|
407
407
|
last_exported_at = excluded.last_exported_at,
|
|
408
408
|
conflict_status = excluded.conflict_status
|
|
409
|
-
`).run({$id:`note_${z0(`${$.noteType}\x00${$.entityId}`)}`,$noteType:$.noteType,$entityId:$.entityId,$filePath:q,$managedHash:T,$conflictStatus:O,$now:H})}function H$(_,$,q,T,O){let H=o($,q.relPath),X=z0(q.managedBody.trim());if(!
|
|
410
|
-
`)[0]}`:"";X.push(`- ${B_(U.slug||U.title)}${
|
|
411
|
-
`)}function
|
|
409
|
+
`).run({$id:`note_${z0(`${$.noteType}\x00${$.entityId}`)}`,$noteType:$.noteType,$entityId:$.entityId,$filePath:q,$managedHash:T,$conflictStatus:O,$now:H})}function H$(_,$,q,T,O){let H=o($,q.relPath),X=z0(q.managedBody.trim());if(!J0(H))return jO(bq(H),{recursive:!0}),fO(H,iZ(q)),U0(_,q,H,X,"clean",O),"created";let U=bO(H,"utf8"),Z=gO(U);if(!Z)return U0(_,q,H,X,"no_managed_block",O),"conflict";let J=z0(Z.managed),z=aZ(_,q.noteType,q.entityId),Q=!z||z.managed_hash!==J;if(Q&&!T.force)return U0(_,q,H,z?.managed_hash??J,"managed_conflict",O),"conflict";return fO(H,nZ(Z,q.managedBody)),U0(_,q,H,X,"clean",O),Q?"forced":"updated"}var X$="LLM-iWiki";function xO(_){return U$(_.slug||_.displayName||_.canonicalName)}function B_(_){return`[[${_.replace(/[[\]|]/g," ").trim()}]]`}function kO(_){if(!_)return[];try{let $=JSON.parse(_);return Array.isArray($)?$.filter((q)=>typeof q==="string"):[]}catch{return[]}}function rZ(_,$,q){let T=[...new Set(q.flatMap((U)=>kO(U.tech_stack_json)))],O=[...new Set(q.map((U)=>U.topic).filter((U)=>!!U))],H=[...$].filter((U)=>U.updated_at).sort((U,Z)=>(U.updated_at??"").localeCompare(Z.updated_at??"")).map((U)=>`| ${(U.updated_at??"").slice(0,10)} | ${U.title} |`),X=[];if(X.push("## 概览"),X.push(""),X.push(`- 标识:\`${_.canonicalName}\``),_.canonicalRepoUrl)X.push(`- 仓库:${_.canonicalRepoUrl}`);if(X.push(`- 会话总结:${$.length} 条`),X.push(`- 沉淀经验:${q.length} 条`),T.length>0)X.push(`- 技术栈:${T.join(" / ")}`);if(O.length>0)X.push(`- 主题:${O.map((U)=>B_(`Topic - ${U}`)).join(" ")}`);if(X.push(""),X.push("## 相关经验"),X.push(""),q.length===0)X.push("_暂无已采纳经验。_");else for(let U of q){let Z=U.summary?` — ${U.summary.trim().split(`
|
|
410
|
+
`)[0]}`:"";X.push(`- ${B_(U.slug||U.title)}${Z}`)}if(X.push(""),X.push("## 演进时间线"),X.push(""),H.length===0)X.push("_暂无会话总结。_");else X.push("| 日期 | 里程碑 |"),X.push("| --- | --- |"),X.push(...H);return X.join(`
|
|
411
|
+
`)}function yq(_,$,q,T){let O=new Date().toISOString(),H={created:0,updated:0,forced:0,conflicts:[]},X=xO(q),U=o(X$,"Projects",X),Z=q.displayName??q.canonicalName,J=(R,G)=>{if(R==="created")H.created+=1;else if(R==="updated")H.updated+=1;else if(R==="forced")H.forced+=1;else H.conflicts.push(G)},z=_.query(`
|
|
412
412
|
SELECT id, session_id, title, value, summary_markdown, updated_at
|
|
413
413
|
FROM session_summaries WHERE project_id = ? ORDER BY updated_at DESC
|
|
414
|
-
`).all(q.id);for(let R of z){let
|
|
414
|
+
`).all(q.id);for(let R of z){let G=o(U,"sessions",`${U$(R.title)}.md`),L={noteType:"session-summary",entityId:R.id,relPath:G,title:R.title,managedBody:R.summary_markdown,frontmatter:{type:"session-summary",aiwiki_id:R.id,aiwiki_project_id:q.id,project:Z,session_id:R.session_id,value:R.value,updated_at:R.updated_at??O}};J(H$(_,$,L,T,O),G)}let Q=_.query(`
|
|
415
415
|
SELECT id, title, slug, summary, body_markdown, confidence, topic, tech_stack_json, status, updated_at
|
|
416
416
|
FROM experiences WHERE project_id = ? AND status = 'accepted' ORDER BY updated_at DESC
|
|
417
|
-
`).all(q.id);for(let R of
|
|
418
|
-
`),A={noteType:"experience",entityId:R.id,relPath:
|
|
417
|
+
`).all(q.id);for(let R of Q){let G=o(U,"experiences",`${U$(R.slug||R.title)}.md`),L=_.query("SELECT session_id FROM session_experience_links WHERE experience_id = ?").all(R.id).map((M)=>M.session_id),B=kO(R.tech_stack_json),D=[R.summary?`> ${R.summary.trim().replace(/\n+/g," ")}`:null,R.summary?"":null,`- 所属项目:${B_(q.slug||Z)}`,R.topic?`- 主题:${B_(`Topic - ${R.topic}`)}`:null,B.length>0?`- 技术栈:${B.join(" / ")}`:null,"",R.body_markdown.trim()].filter((M)=>M!=null).join(`
|
|
418
|
+
`),A={noteType:"experience",entityId:R.id,relPath:G,title:R.title,managedBody:D,frontmatter:{type:"experience",aiwiki_id:R.id,aiwiki_project_id:q.id,project:Z,slug:R.slug,topic:R.topic,tech_stack:B,confidence:R.confidence,status:R.status,source_sessions:L,updated_at:R.updated_at}};J(H$(_,$,A,T,O),G)}let W=o(U,"Project Summary.md"),Y={noteType:"project-summary",entityId:q.id,relPath:W,title:Z,managedBody:rZ(q,z,Q),frontmatter:{type:"project-summary",aiwiki_project_id:q.id,project:Z,slug:q.slug,canonical_repo_url:q.canonicalRepoUrl,updated_at:O}};return J(H$(_,$,Y,T,O),W),H}function EO(_,$){_.created+=$.created,_.updated+=$.updated,_.forced+=$.forced,_.conflicts.push(...$.conflicts)}function gq(_,$,q){let T=new Date().toISOString(),O={created:0,updated:0,forced:0,conflicts:[]},H=(z,Q)=>{if(z==="created")O.created+=1;else if(z==="updated")O.updated+=1;else if(z==="forced")O.forced+=1;else O.conflicts.push(Q)},X=J_(_).filter((z)=>z.sessionCount>0||uO(_,z.id)),U=_.query(`
|
|
419
419
|
SELECT e.title, e.slug, e.summary, e.topic, p.slug AS project_slug,
|
|
420
420
|
COALESCE(p.display_name, p.canonical_name) AS project_name
|
|
421
421
|
FROM experiences e
|
|
422
422
|
JOIN projects p ON p.id = e.project_id
|
|
423
423
|
WHERE e.status = 'accepted' AND e.topic IS NOT NULL AND e.topic != ''
|
|
424
424
|
ORDER BY e.topic ASC, e.updated_at DESC
|
|
425
|
-
`).all(),
|
|
426
|
-
`),frontmatter:{type:"index",updated_at:T},userSectionHeading:"## 备注"},q,T),o(X$,"README.md"));for(let[z,
|
|
427
|
-
`)[0]}`:"";return`- ${B_(R.slug||R.title)}${
|
|
428
|
-
`),Y=o(X$,"Topics",`Topic - ${U$(z)}.md`);H(H$(_,$,{noteType:"topic",entityId:z,relPath:Y,title:`Topic - ${z}`,managedBody:
|
|
425
|
+
`).all(),Z=new Map;for(let z of U){let Q=Z.get(z.topic)??[];Q.push(z),Z.set(z.topic,Q)}let J=[];if(J.push("## 项目"),J.push(""),X.length===0)J.push("_暂无项目。运行 `llm-iwiki obsidian export` 导出。_");else for(let z of X){let Q=z.displayName??z.canonicalName,W=U$(z.slug||Q);J.push(`- [${Q}](Projects/${encodeURIComponent(W)}/Project%20Summary.md) — 总结 ${z.sessionCount} 会话`)}if(J.push(""),J.push("## 主题"),J.push(""),Z.size===0)J.push("_暂无主题分类。在经验 YAML 中填写 `topic` 即可聚合。_");else for(let z of[...Z.keys()].sort())J.push(`- ${B_(`Topic - ${z}`)}(${Z.get(z).length} 条经验)`);H(H$(_,$,{noteType:"index",entityId:"root",relPath:o(X$,"README.md"),title:"LLM-iWiki 知识库",managedBody:J.join(`
|
|
426
|
+
`),frontmatter:{type:"index",updated_at:T},userSectionHeading:"## 备注"},q,T),o(X$,"README.md"));for(let[z,Q]of Z){let W=Q.map((R)=>{let G=R.summary?` — ${R.summary.trim().split(`
|
|
427
|
+
`)[0]}`:"";return`- ${B_(R.slug||R.title)}${G}(${B_(R.project_slug||R.project_name)})`}).join(`
|
|
428
|
+
`),Y=o(X$,"Topics",`Topic - ${U$(z)}.md`);H(H$(_,$,{noteType:"topic",entityId:z,relPath:Y,title:`Topic - ${z}`,managedBody:W,frontmatter:{type:"topic",topic:z,updated_at:T}},q,T),Y)}return O}function uO(_,$){return(_.query("SELECT COUNT(*) AS n FROM obsidian_notes WHERE note_type = 'project-summary' AND entity_id = ?").get($)?.n??0)>0}function hO(_,$,q){let T={created:0,updated:0,forced:0,conflicts:[]};for(let O of J_(_)){if(O.sessionCount===0&&!uO(_,O.id))continue;EO(T,yq(_,$,Z_(_,O.id),q))}return EO(T,gq(_,$,q)),T}function vO(_,$,q){let T=o($,X$,"Projects",xO(q)),O=_.query("SELECT file_path FROM obsidian_notes WHERE note_type = 'project-summary' AND entity_id = ?").get(q.id),H=[],X=0;if(O){let U=bq(O.file_path);if(J0(U)&&U!==T){if(jO(bq(T),{recursive:!0}),J0(T))throw Error(`Target already exists: ${T}`);sZ(U,T),H.push(U),X+=1;let Z=_.query("SELECT id, file_path FROM obsidian_notes").all();for(let J of Z)if(J.file_path.startsWith(U)){let z=J.file_path.replace(U,T);_.query("UPDATE obsidian_notes SET file_path = ? WHERE id = ?").run(z,J.id)}}}return{moved:X,fromDirs:H}}function mO(_){let $=_.query("SELECT note_type, entity_id, file_path, managed_hash FROM obsidian_notes ORDER BY file_path ASC").all(),q=[],T=0;for(let O of $){let H;if(!J0(O.file_path))H="missing";else{let X=gO(bO(O.file_path,"utf8"));if(!X)H="no_managed_block";else if(O.managed_hash&&z0(X.managed)===O.managed_hash)H="clean";else H="drift"}if(H==="clean")T+=1;else q.push({noteType:O.note_type,entityId:O.entity_id,filePath:O.file_path,status:H})}return{total:$.length,clean:T,entries:q}}import{homedir as oZ}from"node:os";import{join as xq,resolve as tZ}from"node:path";function N(_=oZ()){let $=xq(_,".llm-iwiki");return{homeDir:_,configDir:$,configFile:xq($,"config.toml"),databaseFile:xq($,"llm-iwiki.db")}}function kq(_){return tZ(_,".llm-iwiki","exchange")}function lO(_,$,q=80){let T=_.replace(/\s+/g," ").trim(),O=T.toLowerCase().indexOf($.toLowerCase());if(O===-1)return T.slice(0,q);let H=Math.max(0,O-q/4),X=T.slice(H,H+q);return`${H>0?"…":""}${X}${H+q<T.length?"…":""}`}function pO(_,$,q,T,O=20){let H=`%${q.replace(/[%_]/g,(U)=>`\\${U}`)}%`;if($==="experiences")return _.query(`
|
|
429
429
|
SELECT id, title, summary, body_markdown, project_id
|
|
430
430
|
FROM experiences
|
|
431
431
|
WHERE status = 'accepted'
|
|
432
432
|
AND (title LIKE ? ESCAPE '\\' OR COALESCE(summary, '') LIKE ? ESCAPE '\\' OR body_markdown LIKE ? ESCAPE '\\')
|
|
433
433
|
ORDER BY updated_at DESC
|
|
434
|
-
`).all(H,H,H).filter((
|
|
434
|
+
`).all(H,H,H).filter((Z)=>!T||Z.project_id===T).slice(0,O).map((Z)=>({id:Z.id,title:Z.title,snippet:lO(Z.summary??Z.body_markdown,q),projectId:Z.project_id}));return _.query(`
|
|
435
435
|
SELECT id, title, summary_markdown, project_id
|
|
436
436
|
FROM session_summaries
|
|
437
437
|
WHERE title LIKE ? ESCAPE '\\' OR summary_markdown LIKE ? ESCAPE '\\'
|
|
438
438
|
ORDER BY updated_at DESC
|
|
439
|
-
`).all(H,H).filter((U)=>!T||U.project_id===T).slice(0,O).map((U)=>({id:U.id,title:U.title,snippet:
|
|
439
|
+
`).all(H,H).filter((U)=>!T||U.project_id===T).slice(0,O).map((U)=>({id:U.id,title:U.title,snippet:lO(U.summary_markdown,q),projectId:U.project_id}))}var eZ={maxPerMessage:1200,maxMessages:60};function _5(_){return _.replace(/[ \t]+\n/g,`
|
|
440
440
|
`).replace(/\n{3,}/g,`
|
|
441
441
|
|
|
442
|
-
`).trim()}function $
|
|
443
|
-
…[truncated ${q.length-$} chars]`}function
|
|
442
|
+
`).trim()}function $5(_,$){let q=_5(_);if(q.length<=$)return q;return`${q.slice(0,$)}
|
|
443
|
+
…[truncated ${q.length-$} chars]`}function Z$(_,$={}){let q={...eZ,...$},T=_.filter((U)=>U.content.trim()!==""),O=T,H="";if(T.length>q.maxMessages){let U=Math.ceil(q.maxMessages*0.6),Z=q.maxMessages-U;O=[...T.slice(0,U),...T.slice(T.length-Z)],H=`
|
|
444
444
|
…[omitted ${T.length-q.maxMessages} middle messages]
|
|
445
|
-
`}let X=[];return O.forEach((U,
|
|
445
|
+
`}let X=[];return O.forEach((U,Z)=>{if(H&&Z===Math.ceil(q.maxMessages*0.6))X.push(H);let J=U.role==="user"?"User":U.role==="assistant"?"Assistant":U.role;X.push(`**${J}:** ${$5(U.content,q.maxPerMessage)}`)}),X.join(`
|
|
446
446
|
|
|
447
447
|
`)}function uq(_){return{id:_.id,sourceId:_.source_id,sourceSessionId:_.source_session_id,title:_.title,messageCount:_.message_count,status:_.status,rawProjectPath:_.raw_project_path,updatedAt:_.updated_at,lastSeenAt:_.last_seen_at}}function hq(_,$,q=100){return _.query(`
|
|
448
448
|
SELECT id, source_id, source_session_id, title, message_count, status, raw_project_path, updated_at, last_seen_at
|
|
@@ -450,22 +450,22 @@ ${_.after}`}function a7(_,$,q){return _.query("SELECT managed_hash, file_path FR
|
|
|
450
450
|
WHERE project_id = ?
|
|
451
451
|
ORDER BY COALESCE(updated_at, last_seen_at) DESC
|
|
452
452
|
LIMIT ?
|
|
453
|
-
`).all($,q).map(uq)}function vq(_,$){return _.query("SELECT role, content FROM messages WHERE session_id = ? ORDER BY seq_order ASC").all($)}function
|
|
453
|
+
`).all($,q).map(uq)}function vq(_,$){return _.query("SELECT role, content FROM messages WHERE session_id = ? ORDER BY seq_order ASC").all($)}function dO(_,$,q={}){let T=q5(_,$);if(!T)throw Error(`Session not found: ${$}`);let O=vq(_,$),H=q.full?Z$(O,{maxPerMessage:1e6,maxMessages:1e6}):Z$(O);return{session:T,transcript:H,messageCount:O.length}}function q5(_,$){let q=_.query(`
|
|
454
454
|
SELECT id, source_id, source_session_id, title, message_count, status, raw_project_path, updated_at, last_seen_at
|
|
455
455
|
FROM sessions
|
|
456
456
|
WHERE id = ?
|
|
457
|
-
`).get($);return q?uq(q):null}function
|
|
457
|
+
`).get($);return q?uq(q):null}function cO(_,$,q){let T=q==="changed"?"AND status IN ('new', 'changed')":"";return _.query(`
|
|
458
458
|
SELECT id, source_id, source_session_id, title, message_count, status, raw_project_path, updated_at, last_seen_at
|
|
459
459
|
FROM sessions
|
|
460
460
|
WHERE project_id = ? ${T}
|
|
461
461
|
ORDER BY COALESCE(updated_at, last_seen_at) DESC
|
|
462
|
-
`).all($).map(uq)}function
|
|
462
|
+
`).all($).map(uq)}function sO(_,$){return{sources:_.query(`
|
|
463
463
|
SELECT source_id, COUNT(*) AS session_count
|
|
464
464
|
FROM sessions
|
|
465
465
|
WHERE project_id = ?
|
|
466
466
|
GROUP BY source_id
|
|
467
467
|
ORDER BY session_count DESC
|
|
468
|
-
`).all($).map((T)=>({source:T.source_id,sessionCount:T.session_count})),sessions:hq(_,$)}}import{existsSync as
|
|
468
|
+
`).all($).map((T)=>({source:T.source_id,sessionCount:T.session_count})),sessions:hq(_,$)}}import{existsSync as T5,mkdirSync as O5,writeFileSync as iO}from"node:fs";import{dirname as H5,join as mq}from"node:path";var lq=["codex","claude-code","cursor"],pq=mq(".agents","skills"),nO={codex:"Codex","claude-code":"Claude Code",cursor:"Cursor"},aO=[{directory:"aiwiki-knowledge",content:`---
|
|
469
469
|
name: aiwiki-knowledge
|
|
470
470
|
description: 用 llm-iwiki 把当前项目跨 AI 工具的会话沉淀成知识库——采集会话、生成总结与经验、导出到 Obsidian。当用户提到"沉淀/总结这次工作""存进知识库""项目复盘""跑一下 llm-iwiki"或想把会话经验归档时使用。
|
|
471
471
|
---
|
|
@@ -588,11 +588,11 @@ experiences:
|
|
|
588
588
|
tech_stack: [go, kratos]
|
|
589
589
|
problem_type: 登录态
|
|
590
590
|
\`\`\`
|
|
591
|
-
`}];function
|
|
591
|
+
`}];function X5(_,$){if(!$)return _;return`${_}
|
|
592
592
|
## 适配工具
|
|
593
593
|
|
|
594
|
-
本 skill 为 ${
|
|
595
|
-
`}function
|
|
594
|
+
本 skill 为 ${nO[$]} 初始化。
|
|
595
|
+
`}function U5(_){return _ instanceof Error&&"code"in _&&_.code==="EEXIST"}function rO(){return lq.map((_)=>({id:_,name:nO[_]}))}function oO(){return aO.map((_)=>({directory:_.directory,relPath:mq(pq,_.directory,"SKILL.md")}))}function tO(_){let $=[],q=[];for(let T of aO){let O=mq(_.cwd,".agents","skills",T.directory,"SKILL.md");if(T5(O)&&!_.force){q.push(O);continue}if($.push(O),_.dryRun)continue;O5(H5(O),{recursive:!0});let H=X5(T.content,_.target);if(_.force){iO(O,H);continue}try{iO(O,H,{flag:"wx"})}catch(X){if(!U5(X))throw X;$.pop(),q.push(O)}}return{written:$,skipped:q}}var Z5=`## 输出格式(务必遵守)
|
|
596
596
|
|
|
597
597
|
本文件(\`summaries-task.md\`)是任务说明,请勿修改它。
|
|
598
598
|
请**另外新建**一个纯 YAML 文件 \`.llm-iwiki/exchange/summaries.yaml\`,然后运行:
|
|
@@ -620,13 +620,13 @@ summaries:
|
|
|
620
620
|
做了哪些选择、为什么。
|
|
621
621
|
## 结论
|
|
622
622
|
最终结果与后续动作。
|
|
623
|
-
\`\`\``;function
|
|
624
|
-
`))}return{markdown:["# Summaries Task","",`project_id: ${$}`,`scope: ${q}`,`sessions: ${O.length}`,"",
|
|
623
|
+
\`\`\``;function eO(_,$,q){let T=cO(_,$,q),O=[];for(let X of T){let U=vq(_,X.id);if(U.length===0)continue;let Z=Z$(U);O.push([`### ${X.id}`,`- source: ${X.sourceId}`,`- title: ${X.title??"(无标题)"}`,`- messages: ${X.messageCount}`,"",Z].join(`
|
|
624
|
+
`))}return{markdown:["# Summaries Task","",`project_id: ${$}`,`scope: ${q}`,`sessions: ${O.length}`,"",Z5,"","---","",O.join(`
|
|
625
625
|
|
|
626
626
|
---
|
|
627
627
|
|
|
628
628
|
`),""].join(`
|
|
629
|
-
`),sessionCount:O.length}}function
|
|
629
|
+
`),sessionCount:O.length}}function J5(_){return h(_)}function _H(_,$){let q=new Date().toISOString(),T=0,O=[];return _.transaction(()=>{for(let X of $.summaries){let U=_.query("SELECT project_id FROM sessions WHERE id = ?").get(X.sessionId);if(!U){O.push(X.sessionId);continue}_.query(`
|
|
630
630
|
INSERT INTO session_summaries (id, session_id, project_id, title, value, summary_markdown, metadata_json, created_at, updated_at)
|
|
631
631
|
VALUES ($id, $sessionId, $projectId, $title, $value, $summaryMarkdown, $metadata, $now, $now)
|
|
632
632
|
ON CONFLICT(id) DO UPDATE SET
|
|
@@ -635,18 +635,18 @@ summaries:
|
|
|
635
635
|
summary_markdown = excluded.summary_markdown,
|
|
636
636
|
metadata_json = excluded.metadata_json,
|
|
637
637
|
updated_at = excluded.updated_at
|
|
638
|
-
`).run({$id:`sum_${
|
|
639
|
-
`)){let q=$.trim();if(q===""||/^[-=*#>`~]+$/.test(q))continue;return q}return null}function i(_){for(let $ of _){if($.role!=="user")continue;let q=
|
|
640
|
-
`).trim();if(_==null)return"";return JSON.stringify(_)}var
|
|
641
|
-
`),T=[],O=null,H=null;for(let U of q){let
|
|
642
|
-
`)){let
|
|
643
|
-
`)&&$.length<256}function
|
|
638
|
+
`).run({$id:`sum_${J5(X.sessionId)}`,$sessionId:X.sessionId,$projectId:U.project_id??$.projectId,$title:X.title,$value:X.value,$summaryMarkdown:X.summaryMarkdown,$metadata:JSON.stringify(X.metadata),$now:q}),T+=1}})(),{written:T,skipped:O}}import{existsSync as TH,readdirSync as qH,readFileSync as G5,realpathSync as R5,statSync as Y5}from"node:fs";import{basename as L5,join as Q0}from"node:path";import{tmpdir as z5}from"node:os";var $H=120,Q5=["/tmp/","/private/tmp/","/var/folders/","/private/var/folders/"];function s(_){if(!_)return!1;let $=z5();if(_===$)return!0;let q=_.endsWith("/")?_:`${_}/`;return[...Q5,`${$}/`].some((O)=>q.startsWith(O))}function J$(_){return _.length>$H?`${_.slice(0,$H)}…`:_}function W5(_){for(let $ of _.split(`
|
|
639
|
+
`)){let q=$.trim();if(q===""||/^[-=*#>`~]+$/.test(q))continue;return q}return null}function i(_){for(let $ of _){if($.role!=="user")continue;let q=W5($.content);if(q)return J$(q)}return null}function j_(_){if(typeof _==="string")return _;if(Array.isArray(_))return _.map(($)=>{if(typeof $==="string")return $;if($&&typeof $==="object"){let q=$;if(typeof q.text==="string")return q.text;return JSON.stringify(q)}return String($)}).join(`
|
|
640
|
+
`).trim();if(_==null)return"";return JSON.stringify(_)}var OH=[".claude/projects",".claude-internal/projects"];function V5(_){let q=G5(_,"utf8").split(`
|
|
641
|
+
`),T=[],O=null,H=null;for(let U of q){let Z=U.trim();if(Z==="")continue;let J;try{J=JSON.parse(Z)}catch{continue}if(typeof J.sessionId==="string"&&!H)H=J.sessionId;if(typeof J.cwd==="string"&&!O)O=J.cwd;let z=J.type;if(z!=="user"&&z!=="assistant")continue;if(J.isSidechain===!0)continue;let Q=J.message;if(!Q||typeof Q!=="object")continue;let W=Q,Y=typeof W.role==="string"?W.role:z,R=j_(W.content);if(R.trim()==="")continue;T.push({role:Y,content:R,timestamp:typeof J.timestamp==="string"?J.timestamp:null})}if(T.length===0)return null;if(s(O))return null;H??=L5(_).replace(/\.jsonl$/,"");let X=T.map((U)=>U.timestamp).filter((U)=>U!=null);return{sourceSessionId:H,rawPath:_,rawProjectPath:O,title:i(T),createdAt:X[0]??null,updatedAt:X[X.length-1]??null,messages:T}}function B5(_){let $=[],q=new Set;for(let T of OH){let O=Q0(_,T);if(!TH(O))continue;let H;try{H=R5(O)}catch{H=O}if(q.has(H))continue;q.add(H);for(let X of qH(O,{withFileTypes:!0})){if(!X.isDirectory())continue;let U=Q0(O,X.name);for(let Z of qH(U,{withFileTypes:!0}))if(Z.isFile()&&Z.name.endsWith(".jsonl"))$.push(Q0(U,Z.name))}}return $}var HH={id:"claude-code",name:"Claude Code",detect(_){return OH.some(($)=>TH(Q0(_,$)))},collect(_){let $=[];for(let q of B5(_))try{if(!Y5(q).isFile())continue;let T=V5(q);if(T)$.push(T)}catch{continue}return $}};import{existsSync as UH,readdirSync as ZH,readFileSync as w5,statSync as D5}from"node:fs";import{join as z_}from"node:path";var A5="Library/Application Support",M5=["CodeBuddyExtension","CodeBuddy CN"];function JH(_,$,q=0){if(q>6)return;let T;try{T=ZH(_,{withFileTypes:!0})}catch{return}for(let O of T){if(!O.isDirectory())continue;let H=z_(_,O.name);if(O.name==="history")$.push(H);else if(O.name!=="messages")JH(H,$,q+1)}}function dq(_){try{return JSON.parse(w5(_,"utf8"))}catch{return null}}function I5(_){if(typeof _!=="string")return j_(_);let $=_.trim();if($.startsWith("{")||$.startsWith("["))try{let q=JSON.parse($);if(q&&typeof q==="object"&&"content"in q)return j_(q.content);return j_(q)}catch{return _}return _}function F5(_){let $=_.match(/Workspace Folder:\s*(.+)/);if(!$)return null;let q=$[1].trim();return q===""?null:q}function S5(_,$,q){let T=dq(z_(_,"index.json"));if(!T?.messages)return null;let O=[],H=null;for(let U of T.messages){let Z=dq(z_(_,"messages",`${U.id}.json`));if(!Z)continue;let J=U.role??Z.role??"user";if(J!=="user"&&J!=="assistant")continue;let z=I5(Z.message);if(z.trim()==="")continue;if(!H&&J==="user")H=F5(z);O.push({role:J,content:z,timestamp:null})}if(O.length===0)return null;if(s(H))return null;let X=q.name&&q.name.trim()!==""?J$(q.name.trim()):i(O);return{sourceSessionId:$,rawPath:_,rawProjectPath:H,title:X,createdAt:q.createdAt??null,updatedAt:q.lastMessageAt??null,messages:O}}function K5(_,$){for(let q of ZH(_,{withFileTypes:!0})){if(!q.isDirectory())continue;let T=z_(_,q.name),O=dq(z_(T,"index.json"));if(!O?.conversations?.length)continue;for(let H of O.conversations){if(!H.id)continue;let X=z_(T,H.id);if(!UH(X))continue;try{let U=S5(X,H.id,H);if(U)$.push(U)}catch{continue}}}}function XH(_){return M5.map(($)=>z_(_,A5,$)).filter(($)=>UH($))}var zH={id:"codebuddy",name:"CodeBuddy",detect(_){return XH(_).length>0},collect(_){let $=[],q=new Set;for(let T of XH(_)){let O=[];JH(z_(T,"Data"),O);for(let H of O){try{if(!D5(H).isDirectory())continue}catch{continue}K5(H,$)}}return $.filter((T)=>{if(q.has(T.sourceSessionId))return!1;return q.add(T.sourceSessionId),!0})}};import{existsSync as QH,readdirSync as N5,readFileSync as C5,realpathSync as P5,statSync as f5}from"node:fs";import{basename as E5,join as cq}from"node:path";var WH=[".codex/sessions",".codex-internal/sessions"];function j5(_){return _.replace(/\[REQ:[0-9a-f-]+\]/gi,"").replace(/\[AMP_DONE:[0-9a-f-]+\]/gi,"").trim()}function GH(_,$){for(let q of N5(_,{withFileTypes:!0})){let T=cq(_,q.name);if(q.isDirectory())GH(T,$);else if(q.isFile()&&q.name.startsWith("rollout-")&&q.name.endsWith(".jsonl"))$.push(T)}}function b5(_){let $=C5(_,"utf8"),q=[],T=null,O=null,H=null;for(let U of $.split(`
|
|
642
|
+
`)){let Z=U.trim();if(Z==="")continue;let J;try{J=JSON.parse(Z)}catch{continue}let z=J.payload;if(!z||typeof z!=="object")continue;let Q=z,W=typeof J.timestamp==="string"?J.timestamp:null;if(J.type==="session_meta"){if(typeof Q.id==="string")O=Q.id;if(typeof Q.cwd==="string")T=Q.cwd;if(typeof Q.timestamp==="string")H=Q.timestamp;continue}if(J.type!=="event_msg")continue;let Y=Q.type;if(Y!=="user_message"&&Y!=="agent_message")continue;if(typeof Q.message!=="string")continue;let R=j5(Q.message);if(R==="")continue;q.push({role:Y==="user_message"?"user":"assistant",content:R,timestamp:W})}if(q.length===0)return null;if(s(T))return null;O??=E5(_).replace(/\.jsonl$/,"");let X=q.map((U)=>U.timestamp).filter((U)=>U!=null);return{sourceSessionId:O,rawPath:_,rawProjectPath:T,title:i(q),createdAt:H??X[0]??null,updatedAt:X[X.length-1]??null,messages:q}}function y5(_){let $=[],q=new Set;for(let T of WH){let O=cq(_,T);if(!QH(O))continue;let H;try{H=P5(O)}catch{H=O}if(q.has(H))continue;q.add(H),GH(O,$)}return $}var RH={id:"codex",name:"Codex",detect(_){return WH.some(($)=>QH(cq(_,$)))},collect(_){let $=[];for(let q of y5(_))try{if(!f5(q).isFile())continue;let T=b5(q);if(T)$.push(T)}catch{continue}return $}};import{existsSync as z$,readdirSync as g5,readFileSync as x5}from"node:fs";import{join as w_}from"node:path";var YH="Library/Application Support/Cursor/User";function sq(_){if(typeof _!=="number"||!Number.isFinite(_))return null;let $=new Date(_);return Number.isNaN($.getTime())?null:$.toISOString()}function k5(_){if(!_.startsWith("file://"))return null;try{return decodeURIComponent(_.replace(/^file:\/\//,"")).replace(/\/+$/,"")}catch{return null}}function LH(_){return BO(_)}function u5(_){let $=new Map,q=w_(_,"workspaceStorage");if(!z$(q))return $;for(let T of g5(q,{withFileTypes:!0})){if(!T.isDirectory())continue;let O=w_(q,T.name),H=null,X=w_(O,"workspace.json");if(z$(X))try{let J=JSON.parse(x5(X,"utf8"));if(typeof J.folder==="string")H=k5(J.folder)}catch{}let U=w_(O,"state.vscdb");if(!z$(U))continue;let Z=LH(U);if(!Z)continue;try{let J=Z.query("SELECT value FROM ItemTable WHERE key = ?").get("composer.composerData");if(!J)continue;let z=JSON.parse(J.value);for(let Q of z.allComposers??[]){let W=Q.composerId;if(typeof W!=="string")continue;if($.has(W))continue;$.set(W,{cwd:H,name:typeof Q.name==="string"?Q.name:null,createdAt:sq(Q.createdAt),updatedAt:sq(Q.lastUpdatedAt)})}}catch{}finally{Z.close()}}return $}function h5(_,$,q,T){let O=_.query("SELECT value FROM cursorDiskKV WHERE key = ?").get(`composerData:${q}`);if(!O)return null;let H;try{H=JSON.parse(O.value)}catch{return null}let X=H.fullConversationHeadersOnly??[];if(X.length===0)return null;let U=_.query("SELECT value FROM cursorDiskKV WHERE key = ?"),Z=[];for(let Q of X){if(Q.type!==1&&Q.type!==2)continue;let W=U.get(`bubbleId:${q}:${Q.bubbleId}`);if(!W)continue;let Y;try{Y=JSON.parse(W.value)}catch{continue}let R=typeof Y.text==="string"?Y.text.trim():"";if(R==="")continue;Z.push({role:Q.type===1?"user":"assistant",content:R,timestamp:null})}if(Z.length===0)return null;if(s(T.cwd))return null;let J=T.name??H.name??null,z=J&&J.trim()!==""?J$(J.trim()):i(Z);return{sourceSessionId:q,rawPath:`${$}#${q}`,rawProjectPath:T.cwd,title:z,createdAt:T.createdAt??sq(H.createdAt),updatedAt:T.updatedAt,messages:Z}}var VH={id:"cursor",name:"Cursor",detect(_){return z$(w_(_,YH,"globalStorage","state.vscdb"))},collect(_){let $=w_(_,YH),q=w_($,"globalStorage","state.vscdb");if(!z$(q))return[];let T=u5($);if(T.size===0)return[];let O=LH(q);if(!O)return[];let H=[];try{for(let[X,U]of T)try{let Z=h5(O,q,X,U);if(Z)H.push(Z)}catch{continue}}finally{O.close()}return H}};import{existsSync as Q$,readdirSync as BH,readFileSync as AH,realpathSync as v5,statSync as m5}from"node:fs";import{basename as MH,dirname as wH,join as b_}from"node:path";var l5=[".gemini-internal",".gemini"];function p5(_){let $=new Map,q=b_(_,"projects.json");if(!Q$(q))return $;try{let T=JSON.parse(AH(q,"utf8"));for(let[O,H]of Object.entries(T.projects??{}))if(typeof H==="string"&&!$.has(H))$.set(H,O)}catch{}return $}function d5(_){let $=_.trim();return $.startsWith("/")&&!$.includes(`
|
|
643
|
+
`)&&$.length<256}function c5(_,$,q){let T;try{T=JSON.parse(AH(_,"utf8"))}catch{return null}let O=[];for(let U of T.messages??[]){if(U.type!=="user"&&U.type!=="gemini")continue;let Z=typeof U.content==="string"?U.content:"";if(Z.trim()==="")continue;O.push({role:U.type==="user"?"user":"assistant",content:Z,timestamp:typeof U.timestamp==="string"?U.timestamp:null})}if(O.length===0)return null;let H=q.get($)??null;if(!H){let U=O.find((Z)=>Z.role==="user");if(U&&d5(U.content))H=U.content.trim().replace(/\/+$/,"")}if(s(H))return null;let X=O.map((U)=>U.timestamp).filter((U)=>U!=null);return{sourceSessionId:T.sessionId??MH(_).replace(/\.json$/,""),rawPath:_,rawProjectPath:H,title:i(O),createdAt:T.startTime??X[0]??null,updatedAt:T.lastUpdated??X[X.length-1]??null,messages:O}}function DH(_){let $=new Set;for(let q of l5){let T=b_(_,q);if(!Q$(T))continue;let O;try{O=v5(T)}catch{O=T}if($.has(O))continue;return $.add(O),T}return null}function s5(_){let $=b_(_,"tmp");if(!Q$($))return[];let q=[];for(let T of BH($,{withFileTypes:!0})){if(!T.isDirectory())continue;let O=b_($,T.name,"chats");if(!Q$(O))continue;for(let H of BH(O,{withFileTypes:!0}))if(H.isFile()&&H.name.startsWith("session-")&&H.name.endsWith(".json"))q.push(b_(O,H.name))}return q}var IH={id:"gemini",name:"Gemini",detect(_){let $=DH(_);return $!=null&&Q$(b_($,"tmp"))},collect(_){let $=DH(_);if(!$)return[];let q=p5($),T=[];for(let O of s5($))try{if(!m5(O).isFile())continue;let H=MH(wH(wH(O))),X=c5(O,H,q);if(X)T.push(X)}catch{continue}return T}};var FH=[HH,RH,VH,IH,zH];function iq(_){return h(_)}function i5(_,$){return`ses_${iq(`${_}\x00${$.sourceSessionId}\x00${$.rawPath}`)}`}function n5(_,$){return iq(`${_}\x00${$}`)}function a5(_){return iq(`${_.length}\x00${_.join("\x00")}`)}function r5(_,$,q){_.query(`
|
|
644
644
|
INSERT INTO sources (id, name, enabled, scan_paths, config_json, last_sync_at)
|
|
645
645
|
VALUES ($id, $name, 1, NULL, NULL, $now)
|
|
646
646
|
ON CONFLICT(id) DO UPDATE SET
|
|
647
647
|
name = excluded.name,
|
|
648
648
|
last_sync_at = excluded.last_sync_at
|
|
649
|
-
`).run({$id:$.id,$name:$.name,$now:q})}function
|
|
649
|
+
`).run({$id:$.id,$name:$.name,$now:q})}function o5(_,$){if(!$)return null;try{return MO(_,$).id}catch{return null}}function t5(_,$,q,T,O){let H=i5($.id,q),X=q.messages.map((W)=>n5(W.role,W.content)),U=a5(X),Z=o5(_,q.rawProjectPath),J=_.query("SELECT content_hash, first_seen_at FROM sessions WHERE id = ?").get(H);if(J&&J.content_hash===U)return _.query("UPDATE sessions SET project_id = $projectId, status = $status, last_seen_at = $now WHERE id = $id").run({$projectId:Z,$status:"unchanged",$now:T,$id:H}),O.unchanged+=1,H;let z=J?"changed":"new",Q=J?.first_seen_at??T;if(_.query(`
|
|
650
650
|
INSERT INTO sessions (
|
|
651
651
|
id, source_id, source_session_id, project_id, checkout_id, raw_project_path, raw_path,
|
|
652
652
|
title, message_count, content_hash, status, created_at, updated_at, first_seen_at, last_seen_at
|
|
@@ -664,10 +664,10 @@ summaries:
|
|
|
664
664
|
created_at = excluded.created_at,
|
|
665
665
|
updated_at = excluded.updated_at,
|
|
666
666
|
last_seen_at = excluded.last_seen_at
|
|
667
|
-
`).run({$id:H,$sourceId:$.id,$sourceSessionId:q.sourceSessionId,$projectId:
|
|
667
|
+
`).run({$id:H,$sourceId:$.id,$sourceSessionId:q.sourceSessionId,$projectId:Z,$rawProjectPath:q.rawProjectPath,$rawPath:q.rawPath,$title:q.title,$messageCount:q.messages.length,$contentHash:U,$status:z,$createdAt:q.createdAt,$updatedAt:q.updatedAt,$firstSeenAt:Q,$now:T}),_.query("DELETE FROM messages WHERE session_id = ?").run(H),q.messages.forEach((W,Y)=>{_.query(`
|
|
668
668
|
INSERT INTO messages (id, session_id, role, content, timestamp, seq_order, content_hash)
|
|
669
669
|
VALUES ($id, $sessionId, $role, $content, $timestamp, $seqOrder, $contentHash)
|
|
670
|
-
`).run({$id:`msg_${H}_${Y}`,$sessionId:H,$role:
|
|
670
|
+
`).run({$id:`msg_${H}_${Y}`,$sessionId:H,$role:W.role,$content:W.content,$timestamp:W.timestamp,$seqOrder:Y,$contentHash:X[Y]})}),z==="new")O.new+=1;else O.changed+=1;return H}function e5(_,$,q,T,O){let H=_.query("SELECT id FROM sessions WHERE source_id = ? AND status != 'source_missing'").all($);for(let X of H){if(q.has(X.id))continue;_.query("UPDATE sessions SET status = $status, last_seen_at = $now WHERE id = $id").run({$status:"source_missing",$now:T,$id:X.id}),O.sourceMissing+=1}}function SH(_,$){let q=new Date().toISOString(),T=[],O=$.projectFilter??null;$.onProgress?.({type:"scan-start",homeDir:$.homeDir,projectFilter:O});for(let H of FH){if(!H.detect($.homeDir))continue;$.onProgress?.({type:"source-detected",source:H.id}),r5(_,H,q);let X={source:H.id,new:0,changed:0,unchanged:0,sourceMissing:0,total:0},U=H.collect($.homeDir);$.onProgress?.({type:"source-collected",source:H.id,candidateSessions:U.length});let Z=new Set;_.transaction(()=>{for(let z of U){if($.projectFilter&&z.rawProjectPath!==$.projectFilter)continue;let Q=t5(_,H,z,q,X);Z.add(Q),X.total+=1}if(!$.projectFilter)e5(_,H.id,Z,q,X)})(),T.push(X)}return{bySource:T}}var q3=new URL("../package.json",import.meta.url),CH=`llm-iwiki
|
|
671
671
|
|
|
672
672
|
提示:所有 --project 都接受「路径 / proj_xxx / 项目名或 slug」三种形式。
|
|
673
673
|
|
|
@@ -700,8 +700,9 @@ Usage:
|
|
|
700
700
|
llm-iwiki skills init [--target codex|claude-code|cursor] [--force] [--dry-run]
|
|
701
701
|
|
|
702
702
|
Global flags:
|
|
703
|
+
-v, --version 打印版本号
|
|
703
704
|
--debug 出错时打印详细堆栈
|
|
704
705
|
`,PH=`用法:
|
|
705
706
|
llm-iwiki skills list # 列出可用 target 与将写入的 skill
|
|
706
|
-
llm-iwiki skills init [--target codex|claude-code|cursor] [--force] [--dry-run]`;function x(_,$){return
|
|
707
|
-
`);let O=C(T.databaseFile);try{P(O)}finally{O.close()}return $.stdout(`Initialized llm-iwiki at ${T.configDir}`),0}if(_[0]==="doctor"){let T=N($.homeDir);if(!nq(T.configFile))return $.stderr("llm-iwiki is not initialized. Run: llm-iwiki init"),1;if(!nq(T.databaseFile))return $.stderr("llm-iwiki database is missing. Run: llm-iwiki init"),1;let O=C(T.databaseFile);try{P(O)}finally{O.close()}return $.stdout(`config: ${T.configFile}`),$.stdout(`database: ${T.databaseFile}`),$.stdout("status: ok"),0}if(_[0]==="sync"){let T=g(_,"--project"),O=T?x($.cwd,T):null,H=N($.homeDir),X=C(H.databaseFile);try{if(P(X),$.stdout("Scanning local AI session stores..."),O)$.stdout(`Project filter: ${O}`);let U=FH(X,{homeDir:$.homeDir??H.homeDir,projectFilter:O,onProgress:(J)=>{if(J.type==="source-detected")$.stdout(`- ${J.source}: detected, scanning sessions...`);else if(J.type==="source-collected")$.stdout(`- ${J.source}: found ${J.candidateSessions} candidate sessions`)}});if(U.bySource.length===0)return $.stdout("No collectors detected on this machine."),0;$.stdout("Sync summary:");for(let J of U.bySource)$.stdout(`${J.source}: ${J.total} sessions (new ${J.new}, changed ${J.changed}, unchanged ${J.unchanged}, missing ${J.sourceMissing})`);return 0}catch(U){return $.stderr(U instanceof Error?U.message:String(U)),1}finally{X.close()}}if(_[0]==="projects"&&_[1]==="list"){let T=N($.homeDir),O=C(T.databaseFile);try{P(O);let H=Z_(O);if(H.length===0)return $.stdout("No projects yet. Run: llm-iwiki sync"),0;for(let X of H){let U=X.displayName??X.slug,J=X.canonicalRepoUrl?` repo: ${X.canonicalRepoUrl}`:"";$.stdout(`${X.id} ${X.sessionCount} sessions ${U}${J}`)}return 0}finally{O.close()}}if(_[0]==="projects"&&_[1]==="inspect"){let T=_[2];if(!T)return $.stderr("Usage: llm-iwiki projects inspect <project>"),1;let O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=c(H,T,$.cwd),U=cO(H,X.id);if($.stdout(`project: ${X.displayName??X.canonicalName}`),$.stdout(`id: ${X.id}`),X.canonicalRepoUrl)$.stdout(`repo: ${X.canonicalRepoUrl}`);$.stdout(`sources: ${U.sources.map((J)=>`${J.source}(${J.sessionCount})`).join(", ")||"none"}`),$.stdout(`sessions: ${U.sessions.length}`);for(let J of U.sessions)$.stdout(` ${J.id} [${J.sourceId}] ${J.title??J.sourceSessionId} (${J.messageCount} msgs, ${J.status})`);return 0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="projects"&&_[1]==="merge"){let T=_[2],O=_[3];if(!T||!O)return $.stderr("Usage: llm-iwiki projects merge <from-project-id> <into-project-id>"),1;let H=N($.homeDir),X=C(H.databaseFile);try{P(X);let U=Eq(X,T,O);return $.stdout(`merged ${U.fromId} -> ${U.intoId} (moved ${U.movedSessions} sessions)`),0}catch(U){return l(U,$,q),1}finally{X.close()}}if(_[0]==="projects"&&_[1]==="dedupe"){let T=_.includes("--dry-run"),O=N($.homeDir),H=C(O.databaseFile);try{if(P(H),T){let U=Z_(H),J=new Map;for(let z of U){let G=z.canonicalRepoUrl?`repo:${z.canonicalRepoUrl}`:`slug:${z.slug}`;J.set(G,[...J.get(G)??[],z])}let Z=0;for(let[,z]of J){if(z.length<2)continue;Z+=1,$.stdout(`would merge ${z.length} duplicates of ${z[0].canonicalName}`)}return $.stdout(`dry-run: ${Z} duplicate group(s)`),0}let X=MO(H);$.stdout(`deduped: merged ${X.merges.length} duplicate project(s)`);for(let U of X.merges)$.stdout(` ${U.fromId} -> ${U.intoId} (moved ${U.movedSessions} sessions)`);return 0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="sessions"&&_[1]==="list"){let T=g(_,"--project"),O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=T?c(H,T,$.cwd):q5(H,_,$),U=hq(H,X.id);$.stdout(`project: ${X.displayName??X.canonicalName} (${X.id})`),$.stdout(`sessions: ${U.length}`);for(let J of U)$.stdout(` ${J.id} [${J.sourceId}] ${J.title??J.sourceSessionId} (${J.messageCount} msgs, ${J.status})`);return 0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="sessions"&&_[1]==="read"){let T=_[2];if(!T||T.startsWith("--"))return $.stderr("Usage: llm-iwiki sessions read <session-id> [--full]"),1;let O=N($.homeDir),H=C(O.databaseFile);try{P(H);let{session:X,transcript:U,messageCount:J}=pO(H,T,{full:_.includes("--full")});return $.stdout(`# ${X.title??X.sourceSessionId}`),$.stdout(`session: ${X.id} source: ${X.sourceId} messages: ${J}`),$.stdout(""),$.stdout(U),0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="projects"&&_[1]==="resolve"){let T=_[2]??$.cwd,O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=fq(H,x($.cwd,T));return $.stdout(JSON.stringify(X,null,2)),0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}finally{H.close()}}if(_[0]==="projects"&&_[1]==="rename"){let T=_[2],O=_[3];if(!T||!O)return $.stderr("Usage: llm-iwiki projects rename <path-or-project-id> <display-name>"),1;let H=N($.homeDir),X=C(H.databaseFile);try{P(X);let U=T.startsWith("proj_")?jq(X,T,O):jq(X,fq(X,x($.cwd,T)).id,O);return $.stdout(JSON.stringify(U,null,2)),0}catch(U){return $.stderr(U instanceof Error?U.message:String(U)),1}finally{X.close()}}if(_[0]==="summarize"&&_[1]==="prepare"){let T=_[2]&&!_[2].startsWith("--")?_[2]:"changed";if(T!=="changed"&&T!=="all")return $.stderr("Usage: llm-iwiki summarize prepare [changed|all] --project <path> [--out <file>]"),1;let O=g(_,"--project")??$.cwd,H=O.startsWith("proj_")?$.cwd:x($.cwd,O),X=g(_,"--out")??NH(kq(H),"summaries-task.md"),U=N($.homeDir),J=C(U.databaseFile);try{P(J);let Z=c(J,O,$.cwd),z=tO(J,Z.id,T);return Q0(KH(x($.cwd,X)),{recursive:!0}),aq(x($.cwd,X),z.markdown),$.stdout(`prepared summaries task: ${z.sessionCount} sessions -> ${X}`),0}catch(Z){return l(Z,$,q),1}finally{J.close()}}if(_[0]==="summarize"&&_[1]==="apply"){let T=g(_,"--file");if(!T)return $.stderr("Usage: llm-iwiki summarize apply --project <path> --file <summaries.yaml>"),1;let O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=JO(SH(x($.cwd,T),"utf8")),U=eO(H,X);if($.stdout(`applied summaries: ${U.written}`),U.skipped.length>0)$.stdout(`skipped (unknown session): ${U.skipped.length}`);return 0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}finally{H.close()}}if(_[0]==="experiences"&&_[1]==="prepare"){let T=g(_,"--from")??"changed-summaries";if(T!=="changed-summaries"&&T!=="all-recent")return $.stderr("Invalid --from. Use changed-summaries or all-recent."),1;let O=g(_,"--project")??$.cwd,H=O.startsWith("proj_")?$.cwd:x($.cwd,O),X=g(_,"--out")??NH(kq(H),"experiences-task.md"),U=g(_,"--since"),J=N($.homeDir),Z=C(J.databaseFile);try{P(Z);let z=U?T5(U):null,G=c(Z,O,$.cwd),Q=IO(Z,G.id,T,z);return Q0(KH(x($.cwd,X)),{recursive:!0}),aq(x($.cwd,X),Q.markdown),$.stdout(`prepared experiences task: ${Q.summaryCount} summaries -> ${X}`),0}catch(z){return l(z,$,q),1}finally{Z.close()}}if(_[0]==="experiences"&&_[1]==="propose"){let T=g(_,"--file");if(!T)return $.stderr("Usage: llm-iwiki experiences propose --project <path> --file <experiences.yaml>"),1;let O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=ZO(SH(x($.cwd,T),"utf8")),U=SO(H,X);return $.stdout(`proposed experiences: ${U.written}`),0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}finally{H.close()}}if(_[0]==="experiences"&&_[1]==="candidates"){let T=g(_,"--project"),O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=T?c(H,T,$.cwd).id:null,U=KO(H,X);if(U.length===0)return $.stdout("No experience candidates. Run: llm-iwiki experiences propose"),0;for(let J of U)$.stdout(`${J.id} [${J.status}] ${J.confidence??"-"} ${J.proposed_title}`);return 0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="experiences"&&(_[1]==="accept"||_[1]==="reject")){let T=_[2];if(!T)return $.stderr(`Usage: llm-iwiki experiences ${_[1]} <candidate-id>`),1;let O=N($.homeDir),H=C(O.databaseFile);try{if(P(H),_[1]==="accept"){let X=NO(H,T);$.stdout(`accepted: ${X.experienceId} (${X.slug}), linked sessions: ${X.linkedSessions}`)}else CO(H,T),$.stdout(`rejected: ${T}`);return 0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}finally{H.close()}}if(_[0]==="config"&&_[1]==="show"){let T=N($.homeDir),O=O0(T.configFile);return $.stdout(`config: ${T.configFile}`),$.stdout(`obsidian.vault: ${O.obsidianVault??"(unset)"}`),0}if(_[0]==="config"&&_[1]==="set"){let T=_[2],O=_[3];if(!T||O===void 0)return $.stderr("Usage: llm-iwiki config set <key> <value>"),1;let H=N($.homeDir);Q0(H.configDir,{recursive:!0});try{let X=QO(H.configFile,T,O);return $.stdout(`set ${X} = ${O}`),0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}}if(_[0]==="obsidian"&&_[1]==="export"){let T=N($.homeDir),O=g(_,"--vault"),H=O?x($.cwd,O):O0(T.configFile).obsidianVault;if(!H)return $.stderr("No Obsidian vault configured. Run: llm-iwiki config set obsidian.vault <dir>"),1;let X=_.includes("--all"),U=g(_,"--project")??$.cwd,J=_.includes("--force"),Z=C(T.databaseFile);try{P(Z);let z;if(X)z=uO(Z,H,{force:J});else{let G=c(Z,U,$.cwd);z=gq(Z,H,G,{force:J});let Q=yq(Z,H,{force:J});z.created+=Q.created,z.updated+=Q.updated,z.forced+=Q.forced,z.conflicts.push(...Q.conflicts)}$.stdout(`vault: ${H}`),$.stdout(`exported: created ${z.created}, updated ${z.updated}, forced ${z.forced}, conflicts ${z.conflicts.length}`);for(let G of z.conflicts)$.stdout(` conflict (skipped): ${G}`);if(z.conflicts.length>0&&!J)$.stdout("Re-run with --force to overwrite managed blocks of conflicting notes.");return 0}catch(z){return l(z,$,q),1}finally{Z.close()}}if(_[0]==="obsidian"&&_[1]==="move-project"){let T=_[2];if(!T||T.startsWith("--"))return $.stderr("Usage: llm-iwiki obsidian move-project <project> [--vault <dir>]"),1;let O=N($.homeDir),H=g(_,"--vault"),X=H?x($.cwd,H):O0(O.configFile).obsidianVault;if(!X)return $.stderr("No Obsidian vault configured. Run: llm-iwiki config set obsidian.vault <dir>"),1;let U=C(O.databaseFile);try{P(U);let J=c(U,T,$.cwd),Z=hO(U,X,J);if(Z.moved===0)$.stdout("nothing to move (already at target or no exported notes).");else{$.stdout(`moved project notes to slug directory: ${J.slug}`);for(let z of Z.fromDirs)$.stdout(` from: ${z}`)}return 0}catch(J){return l(J,$,q),1}finally{U.close()}}if(_[0]==="search"){let T=_[1],O=_[2];if(T!=="sessions"&&T!=="experiences"||!O||O.startsWith("--"))return $.stderr("Usage: llm-iwiki search <sessions|experiences> <query> [--project <project>]"),1;let H=g(_,"--project"),X=N($.homeDir),U=C(X.databaseFile);try{P(U);let J=H?c(U,H,$.cwd).id:null,Z=lO(U,T,O,J);$.stdout(`matches: ${Z.length}`);for(let z of Z)$.stdout(` ${z.id} ${z.title}`),$.stdout(` ${z.snippet}`);return 0}catch(J){return l(J,$,q),1}finally{U.close()}}if(_[0]==="obsidian"&&_[1]==="check"){let T=N($.homeDir),O=C(T.databaseFile);try{P(O);let H=vO(O);$.stdout(`notes: ${H.total}, clean: ${H.clean}, needs attention: ${H.entries.length}`);for(let X of H.entries)$.stdout(` ${X.status}: ${X.filePath}`);return 0}finally{O.close()}}if(_[0]==="skills"&&_[1]==="init"){let T=g(_,"--target");if(_.includes("--target")&&!T)return $.stderr("Invalid --target. Use codex, claude-code, or cursor."),1;if(T&&!lq.includes(T))return $.stderr("Invalid --target. Use codex, claude-code, or cursor."),1;let O=T,H=oO({cwd:$.cwd,target:O,force:_.includes("--force"),dryRun:_.includes("--dry-run")});return $.stdout(`skills written: ${H.written.length}`),$.stdout(`skills skipped: ${H.skipped.length}`),0}if(_[0]==="skills"&&(_[1]===void 0||_[1]==="list")){$.stdout(PH),$.stdout(""),$.stdout("可用 target:");for(let T of aO())$.stdout(` ${T.id} (${T.name})`);$.stdout(""),$.stdout(`将写入的 skill (位于 ${pq}/):`);for(let T of rO())$.stdout(` ${T.directory} -> ${T.relPath}`);return 0}if(_[0]==="skills")return $.stderr(`Unknown skills subcommand: ${_[1]}`),$.stderr(PH),1;return $.stderr(`Unknown command: ${_.join(" ")}`),$.stderr(CH),1}var O5=await fH(process.argv.slice(2),{cwd:process.cwd(),stdout:console.log,stderr:console.error});process.exit(O5);
|
|
707
|
+
llm-iwiki skills init [--target codex|claude-code|cursor] [--force] [--dry-run]`;function x(_,$){return _3($)?$:$3(_,$)}function y(_,$){let q=_.indexOf($);if(q===-1)return null;let T=_[q+1];if(!T||T.startsWith("--"))return null;return T}function l(_,$,q){if(_ instanceof O$){if($.stderr(`找不到唯一项目:${_.ref}`),_.candidates.length===0)$.stderr("可能原因:路径下尚无会话、或项目名写错。建议:"),$.stderr(" - 先运行 llm-iwiki sync 采集会话"),$.stderr(" - 用 llm-iwiki projects list 查看已有项目,再用 proj_xxx 精确指定");else{$.stderr("存在多个候选(按会话数排序):");for(let T of _.candidates){let O=T.displayName??T.canonicalName;$.stderr(` ${T.id} ${T.sessionCount} sessions ${O}`)}$.stderr("建议:用 --project <proj_xxx> 精确指定,或先 llm-iwiki projects dedupe 合并重复项目。")}if(q&&_.stack)$.stderr(_.stack);return}if($.stderr(_ instanceof Error?_.message:String(_)),q&&_ instanceof Error&&_.stack)$.stderr(_.stack)}function T3(){let _=JSON.parse(rq(q3,"utf8"));if(typeof _.version!=="string"||_.version.length===0)throw Error("Unable to read package version.");return _.version}function O3(_,$,q){let T=y($,"--project")??q.cwd;return c(_,T,q.cwd)}function H3(_){let $=_.match(/^(\d+)([dhw])$/);if(!$)throw Error(`Invalid --since: ${_}. Use forms like 30d, 12h, 2w.`);let q=Number($[1]),T=$[2]==="h"?3600000:$[2]==="w"?604800000:86400000;return new Date(Date.now()-q*T).toISOString()}async function fH(_,$){let q=_.includes("--debug");if(_.length===0||_[0]==="--help"||_[0]==="-h")return $.stdout(CH),0;if(_[0]==="--version"||_[0]==="-v")return $.stdout(T3()),0;if(_[0]==="init"){let T=N($.homeDir);if(W0(T.configDir,{recursive:!0}),!nq(T.configFile))aq(T.configFile,`obsidian_vault = ""
|
|
708
|
+
`);let O=C(T.databaseFile);try{P(O)}finally{O.close()}return $.stdout(`Initialized llm-iwiki at ${T.configDir}`),0}if(_[0]==="doctor"){let T=N($.homeDir);if(!nq(T.configFile))return $.stderr("llm-iwiki is not initialized. Run: llm-iwiki init"),1;if(!nq(T.databaseFile))return $.stderr("llm-iwiki database is missing. Run: llm-iwiki init"),1;let O=C(T.databaseFile);try{P(O)}finally{O.close()}return $.stdout(`config: ${T.configFile}`),$.stdout(`database: ${T.databaseFile}`),$.stdout("status: ok"),0}if(_[0]==="sync"){let T=y(_,"--project"),O=T?x($.cwd,T):null,H=N($.homeDir),X=C(H.databaseFile);try{if(P(X),$.stdout("Scanning local AI session stores..."),O)$.stdout(`Project filter: ${O}`);let U=SH(X,{homeDir:$.homeDir??H.homeDir,projectFilter:O,onProgress:(Z)=>{if(Z.type==="source-detected")$.stdout(`- ${Z.source}: detected, scanning sessions...`);else if(Z.type==="source-collected")$.stdout(`- ${Z.source}: found ${Z.candidateSessions} candidate sessions`)}});if(U.bySource.length===0)return $.stdout("No collectors detected on this machine."),0;$.stdout("Sync summary:");for(let Z of U.bySource)$.stdout(`${Z.source}: ${Z.total} sessions (new ${Z.new}, changed ${Z.changed}, unchanged ${Z.unchanged}, missing ${Z.sourceMissing})`);return 0}catch(U){return $.stderr(U instanceof Error?U.message:String(U)),1}finally{X.close()}}if(_[0]==="projects"&&_[1]==="list"){let T=N($.homeDir),O=C(T.databaseFile);try{P(O);let H=J_(O);if(H.length===0)return $.stdout("No projects yet. Run: llm-iwiki sync"),0;for(let X of H){let U=X.displayName??X.slug,Z=X.canonicalRepoUrl?` repo: ${X.canonicalRepoUrl}`:"";$.stdout(`${X.id} ${X.sessionCount} sessions ${U}${Z}`)}return 0}finally{O.close()}}if(_[0]==="projects"&&_[1]==="inspect"){let T=_[2];if(!T)return $.stderr("Usage: llm-iwiki projects inspect <project>"),1;let O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=c(H,T,$.cwd),U=sO(H,X.id);if($.stdout(`project: ${X.displayName??X.canonicalName}`),$.stdout(`id: ${X.id}`),X.canonicalRepoUrl)$.stdout(`repo: ${X.canonicalRepoUrl}`);$.stdout(`sources: ${U.sources.map((Z)=>`${Z.source}(${Z.sessionCount})`).join(", ")||"none"}`),$.stdout(`sessions: ${U.sessions.length}`);for(let Z of U.sessions)$.stdout(` ${Z.id} [${Z.sourceId}] ${Z.title??Z.sourceSessionId} (${Z.messageCount} msgs, ${Z.status})`);return 0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="projects"&&_[1]==="merge"){let T=_[2],O=_[3];if(!T||!O)return $.stderr("Usage: llm-iwiki projects merge <from-project-id> <into-project-id>"),1;let H=N($.homeDir),X=C(H.databaseFile);try{P(X);let U=Eq(X,T,O);return $.stdout(`merged ${U.fromId} -> ${U.intoId} (moved ${U.movedSessions} sessions)`),0}catch(U){return l(U,$,q),1}finally{X.close()}}if(_[0]==="projects"&&_[1]==="dedupe"){let T=_.includes("--dry-run"),O=N($.homeDir),H=C(O.databaseFile);try{if(P(H),T){let U=J_(H),Z=new Map;for(let z of U){let Q=z.canonicalRepoUrl?`repo:${z.canonicalRepoUrl}`:`slug:${z.slug}`;Z.set(Q,[...Z.get(Q)??[],z])}let J=0;for(let[,z]of Z){if(z.length<2)continue;J+=1,$.stdout(`would merge ${z.length} duplicates of ${z[0].canonicalName}`)}return $.stdout(`dry-run: ${J} duplicate group(s)`),0}let X=IO(H);$.stdout(`deduped: merged ${X.merges.length} duplicate project(s)`);for(let U of X.merges)$.stdout(` ${U.fromId} -> ${U.intoId} (moved ${U.movedSessions} sessions)`);return 0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="sessions"&&_[1]==="list"){let T=y(_,"--project"),O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=T?c(H,T,$.cwd):O3(H,_,$),U=hq(H,X.id);$.stdout(`project: ${X.displayName??X.canonicalName} (${X.id})`),$.stdout(`sessions: ${U.length}`);for(let Z of U)$.stdout(` ${Z.id} [${Z.sourceId}] ${Z.title??Z.sourceSessionId} (${Z.messageCount} msgs, ${Z.status})`);return 0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="sessions"&&_[1]==="read"){let T=_[2];if(!T||T.startsWith("--"))return $.stderr("Usage: llm-iwiki sessions read <session-id> [--full]"),1;let O=N($.homeDir),H=C(O.databaseFile);try{P(H);let{session:X,transcript:U,messageCount:Z}=dO(H,T,{full:_.includes("--full")});return $.stdout(`# ${X.title??X.sourceSessionId}`),$.stdout(`session: ${X.id} source: ${X.sourceId} messages: ${Z}`),$.stdout(""),$.stdout(U),0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="projects"&&_[1]==="resolve"){let T=_[2]??$.cwd,O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=fq(H,x($.cwd,T));return $.stdout(JSON.stringify(X,null,2)),0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}finally{H.close()}}if(_[0]==="projects"&&_[1]==="rename"){let T=_[2],O=_[3];if(!T||!O)return $.stderr("Usage: llm-iwiki projects rename <path-or-project-id> <display-name>"),1;let H=N($.homeDir),X=C(H.databaseFile);try{P(X);let U=T.startsWith("proj_")?jq(X,T,O):jq(X,fq(X,x($.cwd,T)).id,O);return $.stdout(JSON.stringify(U,null,2)),0}catch(U){return $.stderr(U instanceof Error?U.message:String(U)),1}finally{X.close()}}if(_[0]==="summarize"&&_[1]==="prepare"){let T=_[2]&&!_[2].startsWith("--")?_[2]:"changed";if(T!=="changed"&&T!=="all")return $.stderr("Usage: llm-iwiki summarize prepare [changed|all] --project <path> [--out <file>]"),1;let O=y(_,"--project")??$.cwd,H=O.startsWith("proj_")?$.cwd:x($.cwd,O),X=y(_,"--out")??NH(kq(H),"summaries-task.md"),U=N($.homeDir),Z=C(U.databaseFile);try{P(Z);let J=c(Z,O,$.cwd),z=eO(Z,J.id,T);return W0(KH(x($.cwd,X)),{recursive:!0}),aq(x($.cwd,X),z.markdown),$.stdout(`prepared summaries task: ${z.sessionCount} sessions -> ${X}`),0}catch(J){return l(J,$,q),1}finally{Z.close()}}if(_[0]==="summarize"&&_[1]==="apply"){let T=y(_,"--file");if(!T)return $.stderr("Usage: llm-iwiki summarize apply --project <path> --file <summaries.yaml>"),1;let O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=JO(rq(x($.cwd,T),"utf8")),U=_H(H,X);if($.stdout(`applied summaries: ${U.written}`),U.skipped.length>0)$.stdout(`skipped (unknown session): ${U.skipped.length}`);return 0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}finally{H.close()}}if(_[0]==="experiences"&&_[1]==="prepare"){let T=y(_,"--from")??"changed-summaries";if(T!=="changed-summaries"&&T!=="all-recent")return $.stderr("Invalid --from. Use changed-summaries or all-recent."),1;let O=y(_,"--project")??$.cwd,H=O.startsWith("proj_")?$.cwd:x($.cwd,O),X=y(_,"--out")??NH(kq(H),"experiences-task.md"),U=y(_,"--since"),Z=N($.homeDir),J=C(Z.databaseFile);try{P(J);let z=U?H3(U):null,Q=c(J,O,$.cwd),W=FO(J,Q.id,T,z);return W0(KH(x($.cwd,X)),{recursive:!0}),aq(x($.cwd,X),W.markdown),$.stdout(`prepared experiences task: ${W.summaryCount} summaries -> ${X}`),0}catch(z){return l(z,$,q),1}finally{J.close()}}if(_[0]==="experiences"&&_[1]==="propose"){let T=y(_,"--file");if(!T)return $.stderr("Usage: llm-iwiki experiences propose --project <path> --file <experiences.yaml>"),1;let O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=zO(rq(x($.cwd,T),"utf8")),U=KO(H,X);return $.stdout(`proposed experiences: ${U.written}`),0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}finally{H.close()}}if(_[0]==="experiences"&&_[1]==="candidates"){let T=y(_,"--project"),O=N($.homeDir),H=C(O.databaseFile);try{P(H);let X=T?c(H,T,$.cwd).id:null,U=NO(H,X);if(U.length===0)return $.stdout("No experience candidates. Run: llm-iwiki experiences propose"),0;for(let Z of U)$.stdout(`${Z.id} [${Z.status}] ${Z.confidence??"-"} ${Z.proposed_title}`);return 0}catch(X){return l(X,$,q),1}finally{H.close()}}if(_[0]==="experiences"&&(_[1]==="accept"||_[1]==="reject")){let T=_[2];if(!T)return $.stderr(`Usage: llm-iwiki experiences ${_[1]} <candidate-id>`),1;let O=N($.homeDir),H=C(O.databaseFile);try{if(P(H),_[1]==="accept"){let X=CO(H,T);$.stdout(`accepted: ${X.experienceId} (${X.slug}), linked sessions: ${X.linkedSessions}`)}else PO(H,T),$.stdout(`rejected: ${T}`);return 0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}finally{H.close()}}if(_[0]==="config"&&_[1]==="show"){let T=N($.homeDir),O=O0(T.configFile);return $.stdout(`config: ${T.configFile}`),$.stdout(`obsidian.vault: ${O.obsidianVault??"(unset)"}`),0}if(_[0]==="config"&&_[1]==="set"){let T=_[2],O=_[3];if(!T||O===void 0)return $.stderr("Usage: llm-iwiki config set <key> <value>"),1;let H=N($.homeDir);W0(H.configDir,{recursive:!0});try{let X=GO(H.configFile,T,O);return $.stdout(`set ${X} = ${O}`),0}catch(X){return $.stderr(X instanceof Error?X.message:String(X)),1}}if(_[0]==="obsidian"&&_[1]==="export"){let T=N($.homeDir),O=y(_,"--vault"),H=O?x($.cwd,O):O0(T.configFile).obsidianVault;if(!H)return $.stderr("No Obsidian vault configured. Run: llm-iwiki config set obsidian.vault <dir>"),1;let X=_.includes("--all"),U=y(_,"--project")??$.cwd,Z=_.includes("--force"),J=C(T.databaseFile);try{P(J);let z;if(X)z=hO(J,H,{force:Z});else{let Q=c(J,U,$.cwd);z=yq(J,H,Q,{force:Z});let W=gq(J,H,{force:Z});z.created+=W.created,z.updated+=W.updated,z.forced+=W.forced,z.conflicts.push(...W.conflicts)}$.stdout(`vault: ${H}`),$.stdout(`exported: created ${z.created}, updated ${z.updated}, forced ${z.forced}, conflicts ${z.conflicts.length}`);for(let Q of z.conflicts)$.stdout(` conflict (skipped): ${Q}`);if(z.conflicts.length>0&&!Z)$.stdout("Re-run with --force to overwrite managed blocks of conflicting notes.");return 0}catch(z){return l(z,$,q),1}finally{J.close()}}if(_[0]==="obsidian"&&_[1]==="move-project"){let T=_[2];if(!T||T.startsWith("--"))return $.stderr("Usage: llm-iwiki obsidian move-project <project> [--vault <dir>]"),1;let O=N($.homeDir),H=y(_,"--vault"),X=H?x($.cwd,H):O0(O.configFile).obsidianVault;if(!X)return $.stderr("No Obsidian vault configured. Run: llm-iwiki config set obsidian.vault <dir>"),1;let U=C(O.databaseFile);try{P(U);let Z=c(U,T,$.cwd),J=vO(U,X,Z);if(J.moved===0)$.stdout("nothing to move (already at target or no exported notes).");else{$.stdout(`moved project notes to slug directory: ${Z.slug}`);for(let z of J.fromDirs)$.stdout(` from: ${z}`)}return 0}catch(Z){return l(Z,$,q),1}finally{U.close()}}if(_[0]==="search"){let T=_[1],O=_[2];if(T!=="sessions"&&T!=="experiences"||!O||O.startsWith("--"))return $.stderr("Usage: llm-iwiki search <sessions|experiences> <query> [--project <project>]"),1;let H=y(_,"--project"),X=N($.homeDir),U=C(X.databaseFile);try{P(U);let Z=H?c(U,H,$.cwd).id:null,J=pO(U,T,O,Z);$.stdout(`matches: ${J.length}`);for(let z of J)$.stdout(` ${z.id} ${z.title}`),$.stdout(` ${z.snippet}`);return 0}catch(Z){return l(Z,$,q),1}finally{U.close()}}if(_[0]==="obsidian"&&_[1]==="check"){let T=N($.homeDir),O=C(T.databaseFile);try{P(O);let H=mO(O);$.stdout(`notes: ${H.total}, clean: ${H.clean}, needs attention: ${H.entries.length}`);for(let X of H.entries)$.stdout(` ${X.status}: ${X.filePath}`);return 0}finally{O.close()}}if(_[0]==="skills"&&_[1]==="init"){let T=y(_,"--target");if(_.includes("--target")&&!T)return $.stderr("Invalid --target. Use codex, claude-code, or cursor."),1;if(T&&!lq.includes(T))return $.stderr("Invalid --target. Use codex, claude-code, or cursor."),1;let O=T,H=tO({cwd:$.cwd,target:O,force:_.includes("--force"),dryRun:_.includes("--dry-run")});return $.stdout(`skills written: ${H.written.length}`),$.stdout(`skills skipped: ${H.skipped.length}`),0}if(_[0]==="skills"&&(_[1]===void 0||_[1]==="list")){$.stdout(PH),$.stdout(""),$.stdout("可用 target:");for(let T of rO())$.stdout(` ${T.id} (${T.name})`);$.stdout(""),$.stdout(`将写入的 skill (位于 ${pq}/):`);for(let T of oO())$.stdout(` ${T.directory} -> ${T.relPath}`);return 0}if(_[0]==="skills")return $.stderr(`Unknown skills subcommand: ${_[1]}`),$.stderr(PH),1;return $.stderr(`Unknown command: ${_.join(" ")}`),$.stderr(CH),1}var X3=await fH(process.argv.slice(2),{cwd:process.cwd(),stdout:console.log,stderr:console.error});process.exit(X3);
|