@thegpvc/gp-foundry 0.2.9 → 0.2.11

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.
@@ -1,135 +1,145 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var pr=Object.create;var Mt=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var br=(i,e,t)=>()=>{if(t)throw t[0];try{return i&&(e=i(i=0)),e}catch(r){throw t=[r],r}};var Ee=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var yr=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of hr(e))!gr.call(i,o)&&o!==t&&Mt(i,o,{get:()=>e[o],enumerable:!(r=fr(e,o))||r.enumerable});return i};var _n=(i,e,t)=>(t=i!=null?pr(mr(i)):{},yr(e||!i||!i.__esModule?Mt(t,"default",{value:i,enumerable:!0}):t,i));var wr,V,I=br(()=>{"use strict";wr=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,V=wr()});var Je=Ee(Gn=>{"use strict";I();var An=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Vn=class extends An{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Gn.CommanderError=An;Gn.InvalidArgumentError=Vn});var kn=Ee(Yn=>{"use strict";I();var{InvalidArgumentError:_r}=Je(),Wn=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new _r(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ar(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}Yn.Argument=Wn;Yn.humanReadableArgName=Ar});var Jn=Ee(Ft=>{"use strict";I();var{humanReadableArgName:kr}=kn(),Kn=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(o=>!o._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((o,s)=>o.name().localeCompare(s.name())),t}compareOptions(e,t){let r=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(o=>!o.hidden),r=e._getHelpOption();if(r&&!r.hidden){let o=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!o&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!o&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let o=r.options.filter(s=>!s.hidden);t.push(...o)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>kr(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,o)=>Math.max(r,t.subcommandTerm(o).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,o)=>Math.max(r,t.argumentTerm(o).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let o=e.parent;o;o=o.parent)r=o.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),o=t.helpWidth||80,s=2,a=2;function d($,S){if(S){let v=`${$.padEnd(r+a)}${S}`;return t.wrap(v,o-s,r+a)}return $}function u($){return $.join(`
3
- `).replace(/^/gm," ".repeat(s))}let c=[`Usage: ${t.commandUsage(e)}`,""],p=t.commandDescription(e);p.length>0&&(c=c.concat([t.wrap(p,o,0),""]));let m=t.visibleArguments(e).map($=>d(t.argumentTerm($),t.argumentDescription($)));m.length>0&&(c=c.concat(["Arguments:",u(m),""]));let g=t.visibleOptions(e).map($=>d(t.optionTerm($),t.optionDescription($)));if(g.length>0&&(c=c.concat(["Options:",u(g),""])),this.showGlobalOptions){let $=t.visibleGlobalOptions(e).map(S=>d(t.optionTerm(S),t.optionDescription(S)));$.length>0&&(c=c.concat(["Global Options:",u($),""]))}let k=t.visibleCommands(e).map($=>d(t.subcommandTerm($),t.subcommandDescription($)));return k.length>0&&(c=c.concat(["Commands:",u(k),""])),c.join(`
4
- `)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,r,o=40){let s=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",a=new RegExp(`[\\n][${s}]+`);if(e.match(a))return e;let d=t-r;if(d<o)return e;let u=e.slice(0,r),c=e.slice(r).replace(`\r
2
+ "use strict";var qr=Object.create;var ii=Object.defineProperty;var Ur=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Gr=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty;var Vr=(i,e,n)=>()=>{if(n)throw n[0];try{return i&&(e=i(i=0)),e}catch(r){throw n=[r],r}};var Ce=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var Yr=(i,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Br(e))!Wr.call(i,o)&&o!==n&&ii(i,o,{get:()=>e[o],enumerable:!(r=Ur(e,o))||r.enumerable});return i};var Rn=(i,e,n)=>(n=i!=null?qr(Gr(i)):{},Yr(e||!i||!i.__esModule?ii(n,"default",{value:i,enumerable:!0}):n,i));var Kr,G,P=Vr(()=>{"use strict";Kr=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,G=Kr()});var an=Ce(nt=>{"use strict";P();var Nn=class extends Error{constructor(e,n,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=n,this.exitCode=e,this.nestedError=void 0}},et=class extends Nn{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};nt.CommanderError=Nn;nt.InvalidArgumentError=et});var Hn=Ce(it=>{"use strict";P();var{InvalidArgumentError:Jr}=an(),tt=class{constructor(e,n){switch(this.description=n||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,n){return n===this.defaultValue||!Array.isArray(n)?[e]:n.concat(e)}default(e,n){return this.defaultValue=e,this.defaultValueDescription=n,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(n,r)=>{if(!this.argChoices.includes(n))throw new Jr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,r):n},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function zr(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}it.Argument=tt;it.humanReadableArgName=zr});var ot=Ce(ri=>{"use strict";P();var{humanReadableArgName:Xr}=Hn(),rt=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let n=e.commands.filter(o=>!o._hidden),r=e._getHelpCommand();return r&&!r._hidden&&n.push(r),this.sortSubcommands&&n.sort((o,s)=>o.name().localeCompare(s.name())),n}compareOptions(e,n){let r=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return r(e).localeCompare(r(n))}visibleOptions(e){let n=e.options.filter(o=>!o.hidden),r=e._getHelpOption();if(r&&!r.hidden){let o=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!o&&!s?n.push(r):r.long&&!s?n.push(e.createOption(r.long,r.description)):r.short&&!o&&n.push(e.createOption(r.short,r.description))}return this.sortOptions&&n.sort(this.compareOptions),n}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let n=[];for(let r=e.parent;r;r=r.parent){let o=r.options.filter(s=>!s.hidden);n.push(...o)}return this.sortOptions&&n.sort(this.compareOptions),n}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(n=>{n.description=n.description||e._argsDescription[n.name()]||""}),e.registeredArguments.find(n=>n.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(r=>Xr(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(n?" "+n:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,n){return n.visibleCommands(e).reduce((r,o)=>Math.max(r,n.subcommandTerm(o).length),0)}longestOptionTermLength(e,n){return n.visibleOptions(e).reduce((r,o)=>Math.max(r,n.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,n){return n.visibleGlobalOptions(e).reduce((r,o)=>Math.max(r,n.optionTerm(o).length),0)}longestArgumentTermLength(e,n){return n.visibleArguments(e).reduce((r,o)=>Math.max(r,n.argumentTerm(o).length),0)}commandUsage(e){let n=e._name;e._aliases[0]&&(n=n+"|"+e._aliases[0]);let r="";for(let o=e.parent;o;o=o.parent)r=o.name()+" "+r;return r+n+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let n=[];return e.argChoices&&n.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&n.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&n.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&n.push(`env: ${e.envVar}`),n.length>0?`${e.description} (${n.join(", ")})`:e.description}argumentDescription(e){let n=[];if(e.argChoices&&n.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&n.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),n.length>0){let r=`(${n.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,n){let r=n.padWidth(e,n),o=n.helpWidth||80,s=2,u=2;function p(C,w){if(w){let k=`${C.padEnd(r+u)}${w}`;return n.wrap(k,o-s,r+u)}return C}function a(C){return C.join(`
3
+ `).replace(/^/gm," ".repeat(s))}let l=[`Usage: ${n.commandUsage(e)}`,""],d=n.commandDescription(e);d.length>0&&(l=l.concat([n.wrap(d,o,0),""]));let f=n.visibleArguments(e).map(C=>p(n.argumentTerm(C),n.argumentDescription(C)));f.length>0&&(l=l.concat(["Arguments:",a(f),""]));let m=n.visibleOptions(e).map(C=>p(n.optionTerm(C),n.optionDescription(C)));if(m.length>0&&(l=l.concat(["Options:",a(m),""])),this.showGlobalOptions){let C=n.visibleGlobalOptions(e).map(w=>p(n.optionTerm(w),n.optionDescription(w)));C.length>0&&(l=l.concat(["Global Options:",a(C),""]))}let A=n.visibleCommands(e).map(C=>p(n.subcommandTerm(C),n.subcommandDescription(C)));return A.length>0&&(l=l.concat(["Commands:",a(A),""])),l.join(`
4
+ `)}padWidth(e,n){return Math.max(n.longestOptionTermLength(e,n),n.longestGlobalOptionTermLength(e,n),n.longestSubcommandTermLength(e,n),n.longestArgumentTermLength(e,n))}wrap(e,n,r,o=40){let s=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",u=new RegExp(`[\\n][${s}]+`);if(e.match(u))return e;let p=n-r;if(p<o)return e;let a=e.slice(0,r),l=e.slice(r).replace(`\r
5
5
  `,`
6
- `),p=" ".repeat(r),g="\\s\u200B",k=new RegExp(`
7
- |.{1,${d-1}}([${g}]|$)|[^${g}]+?([${g}]|$)`,"g"),$=c.match(k)||[];return u+$.map((S,v)=>S===`
8
- `?"":(v>0?p:"")+S.trimEnd()).join(`
9
- `)}};Ft.Help=Kn});var Zn=Ee(Qn=>{"use strict";I();var{InvalidArgumentError:xr}=Je(),zn=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=Er(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new xr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Cr(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Xn=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let o=this.negativeOptions.get(r).presetArg,s=o!==void 0?o:!1;return t.negate===(s===e)}};function Cr(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Er(i){let e,t,r=i.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),t=r.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}Qn.Option=zn;Qn.DualOptions=Xn});var Lt=Ee(jt=>{"use strict";I();function Sr(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let t=[];for(let r=0;r<=i.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=i.length;o++){let s=1;i[o-1]===e[r-1]?s=0:s=1,t[o][r]=Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+s),o>1&&r>1&&i[o-1]===e[r-2]&&i[o-2]===e[r-1]&&(t[o][r]=Math.min(t[o][r],t[o-2][r-2]+1))}return t[i.length][e.length]}function vr(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=i.startsWith("--");t&&(i=i.slice(2),e=e.map(a=>a.slice(2)));let r=[],o=3,s=.4;return e.forEach(a=>{if(a.length<=1)return;let d=Sr(i,a),u=Math.max(i.length,a.length);(u-d)/u>s&&(d<o?(o=d,r=[a]):d===o&&r.push(a))}),r.sort((a,d)=>a.localeCompare(d)),t&&(r=r.map(a=>`--${a}`)),r.length>1?`
6
+ `),d=" ".repeat(r),m="\\s\u200B",A=new RegExp(`
7
+ |.{1,${p-1}}([${m}]|$)|[^${m}]+?([${m}]|$)`,"g"),C=l.match(A)||[];return a+C.map((w,k)=>w===`
8
+ `?"":(k>0?d:"")+w.trimEnd()).join(`
9
+ `)}};ri.Help=rt});var ct=Ce(lt=>{"use strict";P();var{InvalidArgumentError:Qr}=an(),st=class{constructor(e,n){this.flags=e,this.description=n||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=eo(e);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,n){return this.defaultValue=e,this.defaultValueDescription=n,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let n=e;return typeof e=="string"&&(n={[e]:!0}),this.implied=Object.assign(this.implied||{},n),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,n){return n===this.defaultValue||!Array.isArray(n)?[e]:n.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(n,r)=>{if(!this.argChoices.includes(n))throw new Qr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,r):n},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Zr(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},at=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(n=>{n.negate?this.negativeOptions.set(n.attributeName(),n):this.positiveOptions.set(n.attributeName(),n)}),this.negativeOptions.forEach((n,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,n){let r=n.attributeName();if(!this.dualOptions.has(r))return!0;let o=this.negativeOptions.get(r).presetArg,s=o!==void 0?o:!1;return n.negate===(s===e)}};function Zr(i){return i.split("-").reduce((e,n)=>e+n[0].toUpperCase()+n.slice(1))}function eo(i){let e,n,r=i.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),n=r.shift(),!e&&/^-[^-]$/.test(n)&&(e=n,n=void 0),{shortFlag:e,longFlag:n}}lt.Option=st;lt.DualOptions=at});var si=Ce(oi=>{"use strict";P();function no(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let n=[];for(let r=0;r<=i.length;r++)n[r]=[r];for(let r=0;r<=e.length;r++)n[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=i.length;o++){let s=1;i[o-1]===e[r-1]?s=0:s=1,n[o][r]=Math.min(n[o-1][r]+1,n[o][r-1]+1,n[o-1][r-1]+s),o>1&&r>1&&i[o-1]===e[r-2]&&i[o-2]===e[r-1]&&(n[o][r]=Math.min(n[o][r],n[o-2][r-2]+1))}return n[i.length][e.length]}function to(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let n=i.startsWith("--");n&&(i=i.slice(2),e=e.map(u=>u.slice(2)));let r=[],o=3,s=.4;return e.forEach(u=>{if(u.length<=1)return;let p=no(i,u),a=Math.max(i.length,u.length);(a-p)/a>s&&(p<o?(o=p,r=[u]):p===o&&r.push(u))}),r.sort((u,p)=>u.localeCompare(p)),n&&(r=r.map(u=>`--${u}`)),r.length>1?`
10
10
  (Did you mean one of ${r.join(", ")}?)`:r.length===1?`
11
- (Did you mean ${r[0]}?)`:""}jt.suggestSimilar=vr});var Vt=Ee(Ut=>{"use strict";I();var Or=require("events").EventEmitter,et=require("child_process"),ye=require("path"),nt=require("fs"),X=require("process"),{Argument:$r,humanReadableArgName:Tr}=kn(),{CommanderError:tt}=Je(),{Help:Nr}=Jn(),{Option:Dt,DualOptions:Rr}=Zn(),{suggestSimilar:qt}=Lt(),it=class i extends Or{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>X.stdout.write(t),writeErr:t=>X.stderr.write(t),getOutHelpWidth:()=>X.stdout.isTTY?X.stdout.columns:void 0,getErrHelpWidth:()=>X.stderr.isTTY?X.stderr.columns:void 0,outputError:(t,r)=>r(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let o=t,s=r;typeof o=="object"&&o!==null&&(s=o,o=null),s=s||{};let[,a,d]=e.match(/([^ ]+) *(.*)/),u=this.createCommand(a);return o&&(u.description(o),u._executableHandler=!0),s.isDefault&&(this._defaultCommandName=u._name),u._hidden=!!(s.noHelp||s.hidden),u._executableFile=s.executableFile||null,d&&u.arguments(d),this._registerCommand(u),u.parent=this,u.copyInheritedSettings(this),o?this:u}createCommand(e){return new i(e)}createHelp(){return Object.assign(new Nr,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
12
- - specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new $r(e,t)}argument(e,t,r,o){let s=this.createArgument(e,t);return typeof r=="function"?s.default(o).argParser(r):s.default(r),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,r,o]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",a=this.createCommand(r);return a.helpOption(!1),o&&a.arguments(o),s&&a.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=a,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
13
- Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new tt(e,t,r)),X.exit(e)}action(e){let t=r=>{let o=this.registeredArguments.length,s=r.slice(0,o);return this._storeOptionsAsProperties?s[o]=this:s[o]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new Dt(e,t)}_callParseArg(e,t,r,o){try{return e.parseArg(t,r)}catch(s){if(s.code==="commander.invalidArgument"){let a=`${o} ${s.message}`;this.error(a,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
14
- - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=o=>[o.name()].concat(o.aliases()),r=t(e).find(o=>this._findCommand(o));if(r){let o=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${o}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let o=(s,a,d)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let u=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,u,a):s!==null&&e.variadic&&(s=e._concatValue(s,u)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,d)};return this.on("option:"+t,s=>{let a=`error: option '${e.flags}' argument '${s}' is invalid.`;o(s,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let a=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;o(s,a,"env")}),this}_optionEx(e,t,r,o,s){if(typeof t=="object"&&t instanceof Dt)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let a=this.createOption(t,r);if(a.makeOptionMandatory(!!e.mandatory),typeof o=="function")a.default(s).argParser(o);else if(o instanceof RegExp){let d=o;o=(u,c)=>{let p=d.exec(u);return p?p[0]:c},a.default(s).argParser(o)}else a.default(o);return this.addOption(a)}option(e,t,r,o){return this._optionEx({},e,t,r,o)}requiredOption(e,t,r,o){return this._optionEx({mandatory:!0},e,t,r,o)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){X.versions?.electron&&(t.from="electron");let o=X.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(t.from="eval")}e===void 0&&(e=X.argv),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":X.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function s(p,m){let g=ye.resolve(p,m);if(nt.existsSync(g))return g;if(o.includes(ye.extname(m)))return;let k=o.find($=>nt.existsSync(`${g}${$}`));if(k)return`${g}${k}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||"";if(this._scriptPath){let p;try{p=nt.realpathSync(this._scriptPath)}catch{p=this._scriptPath}d=ye.resolve(ye.dirname(p),d)}if(d){let p=s(d,a);if(!p&&!e._executableFile&&this._scriptPath){let m=ye.basename(this._scriptPath,ye.extname(this._scriptPath));m!==this._name&&(p=s(d,`${m}-${e._name}`))}a=p||a}r=o.includes(ye.extname(a));let u;X.platform!=="win32"?r?(t.unshift(a),t=Bt(X.execArgv).concat(t),u=et.spawn(X.argv[0],t,{stdio:"inherit"})):u=et.spawn(a,t,{stdio:"inherit"}):(t.unshift(a),t=Bt(X.execArgv).concat(t),u=et.spawn(X.execPath,t,{stdio:"inherit"})),u.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(m=>{X.on(m,()=>{u.killed===!1&&u.exitCode===null&&u.kill(m)})});let c=this._exitCallback;u.on("close",p=>{p=p??1,c?c(new tt(p,"commander.executeSubCommandAsync","(close)")):X.exit(p)}),u.on("error",p=>{if(p.code==="ENOENT"){let m=d?`searched for local subcommand relative to directory '${d}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",g=`'${a}' does not exist
11
+ (Did you mean ${r[0]}?)`:""}oi.suggestSimilar=to});var di=Ce(ui=>{"use strict";P();var io=require("events").EventEmitter,ut=require("child_process"),$e=require("path"),dt=require("fs"),Q=require("process"),{Argument:ro,humanReadableArgName:oo}=Hn(),{CommanderError:pt}=an(),{Help:so}=ot(),{Option:ai,DualOptions:ao}=ct(),{suggestSimilar:li}=si(),ft=class i extends io{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:n=>Q.stdout.write(n),writeErr:n=>Q.stderr.write(n),getOutHelpWidth:()=>Q.stdout.isTTY?Q.stdout.columns:void 0,getErrHelpWidth:()=>Q.stderr.isTTY?Q.stderr.columns:void 0,outputError:(n,r)=>r(n)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let n=this;n;n=n.parent)e.push(n);return e}command(e,n,r){let o=n,s=r;typeof o=="object"&&o!==null&&(s=o,o=null),s=s||{};let[,u,p]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(u);return o&&(a.description(o),a._executableHandler=!0),s.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(s.noHelp||s.hidden),a._executableFile=s.executableFile||null,p&&a.arguments(p),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),o?this:a}createCommand(e){return new i(e)}createHelp(){return Object.assign(new so,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,n){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
12
+ - specify the name in Command constructor or using .name()`);return n=n||{},n.isDefault&&(this._defaultCommandName=e._name),(n.noHelp||n.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,n){return new ro(e,n)}argument(e,n,r,o){let s=this.createArgument(e,n);return typeof r=="function"?s.default(o).argParser(r):s.default(r),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(n=>{this.argument(n)}),this}addArgument(e){let n=this.registeredArguments.slice(-1)[0];if(n&&n.variadic)throw new Error(`only the last argument can be variadic '${n.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,n){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,r,o]=e.match(/([^ ]+) *(.*)/),s=n??"display help for command",u=this.createCommand(r);return u.helpOption(!1),o&&u.arguments(o),s&&u.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=u,this}addHelpCommand(e,n){return typeof e!="object"?(this.helpCommand(e,n),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,n){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
13
+ Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(n):this._lifeCycleHooks[e]=[n],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=n=>{if(n.code!=="commander.executeSubCommandAsync")throw n},this}_exit(e,n,r){this._exitCallback&&this._exitCallback(new pt(e,n,r)),Q.exit(e)}action(e){let n=r=>{let o=this.registeredArguments.length,s=r.slice(0,o);return this._storeOptionsAsProperties?s[o]=this:s[o]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=n,this}createOption(e,n){return new ai(e,n)}_callParseArg(e,n,r,o){try{return e.parseArg(n,r)}catch(s){if(s.code==="commander.invalidArgument"){let u=`${o} ${s.message}`;this.error(u,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let n=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(n){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
14
+ - already used by option '${n.flags}'`)}this.options.push(e)}_registerCommand(e){let n=o=>[o.name()].concat(o.aliases()),r=n(e).find(o=>this._findCommand(o));if(r){let o=n(this._findCommand(r)).join("|"),s=n(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${o}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let n=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let o=(s,u,p)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let a=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,a,u):s!==null&&e.variadic&&(s=e._concatValue(s,a)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,p)};return this.on("option:"+n,s=>{let u=`error: option '${e.flags}' argument '${s}' is invalid.`;o(s,u,"cli")}),e.envVar&&this.on("optionEnv:"+n,s=>{let u=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;o(s,u,"env")}),this}_optionEx(e,n,r,o,s){if(typeof n=="object"&&n instanceof ai)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let u=this.createOption(n,r);if(u.makeOptionMandatory(!!e.mandatory),typeof o=="function")u.default(s).argParser(o);else if(o instanceof RegExp){let p=o;o=(a,l)=>{let d=p.exec(a);return d?d[0]:l},u.default(s).argParser(o)}else u.default(o);return this.addOption(u)}option(e,n,r,o){return this._optionEx({},e,n,r,o)}requiredOption(e,n,r,o){return this._optionEx({mandatory:!0},e,n,r,o)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,n){return this.setOptionValueWithSource(e,n,void 0)}setOptionValueWithSource(e,n,r){return this._storeOptionsAsProperties?this[e]=n:this._optionValues[e]=n,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let n;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(n=r.getOptionValueSource(e))}),n}_prepareUserArgs(e,n){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(n=n||{},e===void 0&&n.from===void 0){Q.versions?.electron&&(n.from="electron");let o=Q.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(n.from="eval")}e===void 0&&(e=Q.argv),this.rawArgs=e.slice();let r;switch(n.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":Q.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${n.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,n){let r=this._prepareUserArgs(e,n);return this._parseCommand([],r),this}async parseAsync(e,n){let r=this._prepareUserArgs(e,n);return await this._parseCommand([],r),this}_executeSubCommand(e,n){n=n.slice();let r=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function s(d,f){let m=$e.resolve(d,f);if(dt.existsSync(m))return m;if(o.includes($e.extname(f)))return;let A=o.find(C=>dt.existsSync(`${m}${C}`));if(A)return`${m}${A}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,p=this._executableDir||"";if(this._scriptPath){let d;try{d=dt.realpathSync(this._scriptPath)}catch{d=this._scriptPath}p=$e.resolve($e.dirname(d),p)}if(p){let d=s(p,u);if(!d&&!e._executableFile&&this._scriptPath){let f=$e.basename(this._scriptPath,$e.extname(this._scriptPath));f!==this._name&&(d=s(p,`${f}-${e._name}`))}u=d||u}r=o.includes($e.extname(u));let a;Q.platform!=="win32"?r?(n.unshift(u),n=ci(Q.execArgv).concat(n),a=ut.spawn(Q.argv[0],n,{stdio:"inherit"})):a=ut.spawn(u,n,{stdio:"inherit"}):(n.unshift(u),n=ci(Q.execArgv).concat(n),a=ut.spawn(Q.execPath,n,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{Q.on(f,()=>{a.killed===!1&&a.exitCode===null&&a.kill(f)})});let l=this._exitCallback;a.on("close",d=>{d=d??1,l?l(new pt(d,"commander.executeSubCommandAsync","(close)")):Q.exit(d)}),a.on("error",d=>{if(d.code==="ENOENT"){let f=p?`searched for local subcommand relative to directory '${p}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",m=`'${u}' does not exist
15
15
  - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
16
16
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
- - ${m}`;throw new Error(g)}else if(p.code==="EACCES")throw new Error(`'${a}' not executable`);if(!c)X.exit(1);else{let m=new tt(1,"commander.executeSubCommandAsync","(error)");m.nestedError=p,c(m)}}),this.runningCommand=u}_dispatchSubcommand(e,t,r){let o=this._findCommand(e);o||this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,o,"preSubcommand"),s=this._chainOrCall(s,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(r));else return o._parseCommand(t,r)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,o,s)=>{let a=o;if(o!==null&&r.parseArg){let d=`error: command-argument value '${o}' is invalid for argument '${r.name()}'.`;a=this._callParseArg(r,o,s,d)}return a};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,o)=>{let s=r.defaultValue;r.variadic?o<this.args.length?(s=this.args.slice(o),r.parseArg&&(s=s.reduce((a,d)=>e(r,d,a),r.defaultValue))):s===void 0&&(s=[]):o<this.args.length&&(s=this.args[o],r.parseArg&&(s=e(r,s,r.defaultValue))),t[o]=s}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,o=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(a=>{o.push({hookedCommand:s,callback:a})})}),t==="postAction"&&o.reverse(),o.forEach(s=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(s=>{o=this._chainOrCall(o,()=>s(this,t))}),o}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let a;return a=this._chainOrCallHooks(a,"preAction"),a=this._chainOrCall(a,()=>this._actionHandler(this.processedArgs)),this.parent&&(a=this._chainOrCall(a,()=>{this.parent.emit(s,e,t)})),a=this._chainOrCallHooks(a,"postAction"),a}if(this.parent&&this.parent.listenerCount(s))o(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let o=r.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let o=e.find(s=>r.conflictsWith.includes(s.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],o=t,s=e.slice();function a(u){return u.length>1&&u[0]==="-"}let d=null;for(;s.length;){let u=s.shift();if(u==="--"){o===r&&o.push(u),o.push(...s);break}if(d&&!a(u)){this.emit(`option:${d.name()}`,u);continue}if(d=null,a(u)){let c=this._findOption(u);if(c){if(c.required){let p=s.shift();p===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,p)}else if(c.optional){let p=null;s.length>0&&!a(s[0])&&(p=s.shift()),this.emit(`option:${c.name()}`,p)}else this.emit(`option:${c.name()}`);d=c.variadic?c:null;continue}}if(u.length>2&&u[0]==="-"&&u[1]!=="-"){let c=this._findOption(`-${u[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,u.slice(2)):(this.emit(`option:${c.name()}`),s.unshift(`-${u.slice(2)}`));continue}}if(/^--[^=]+=/.test(u)){let c=u.indexOf("="),p=this._findOption(u.slice(0,c));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,u.slice(c+1));continue}}if(a(u)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(u)){t.push(u),s.length>0&&r.push(...s);break}else if(this._getHelpCommand()&&u===this._getHelpCommand().name()){t.push(u),s.length>0&&t.push(...s);break}else if(this._defaultCommandName){r.push(u),s.length>0&&r.push(...s);break}}if(this._passThroughOptions){o.push(u),s.length>0&&o.push(...s);break}o.push(u)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let o=this.options[r].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
17
+ - ${f}`;throw new Error(m)}else if(d.code==="EACCES")throw new Error(`'${u}' not executable`);if(!l)Q.exit(1);else{let f=new pt(1,"commander.executeSubCommandAsync","(error)");f.nestedError=d,l(f)}}),this.runningCommand=a}_dispatchSubcommand(e,n,r){let o=this._findCommand(e);o||this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,o,"preSubcommand"),s=this._chainOrCall(s,()=>{if(o._executableHandler)this._executeSubCommand(o,n.concat(r));else return o._parseCommand(n,r)}),s}_dispatchHelpCommand(e){e||this.help();let n=this._findCommand(e);return n&&!n._executableHandler&&n.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,n)=>{e.required&&this.args[n]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,o,s)=>{let u=o;if(o!==null&&r.parseArg){let p=`error: command-argument value '${o}' is invalid for argument '${r.name()}'.`;u=this._callParseArg(r,o,s,p)}return u};this._checkNumberOfArguments();let n=[];this.registeredArguments.forEach((r,o)=>{let s=r.defaultValue;r.variadic?o<this.args.length?(s=this.args.slice(o),r.parseArg&&(s=s.reduce((u,p)=>e(r,p,u),r.defaultValue))):s===void 0&&(s=[]):o<this.args.length&&(s=this.args[o],r.parseArg&&(s=e(r,s,r.defaultValue))),n[o]=s}),this.processedArgs=n}_chainOrCall(e,n){return e&&e.then&&typeof e.then=="function"?e.then(()=>n()):n()}_chainOrCallHooks(e,n){let r=e,o=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[n]!==void 0).forEach(s=>{s._lifeCycleHooks[n].forEach(u=>{o.push({hookedCommand:s,callback:u})})}),n==="postAction"&&o.reverse(),o.forEach(s=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,n,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(s=>{o=this._chainOrCall(o,()=>s(this,n))}),o}_parseCommand(e,n){let r=this.parseOptions(n);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),n=r.unknown,this.args=e.concat(n),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),n);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(n),this._dispatchSubcommand(this._defaultCommandName,e,n);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let u;return u=this._chainOrCallHooks(u,"preAction"),u=this._chainOrCall(u,()=>this._actionHandler(this.processedArgs)),this.parent&&(u=this._chainOrCall(u,()=>{this.parent.emit(s,e,n)})),u=this._chainOrCallHooks(u,"postAction"),u}if(this.parent&&this.parent.listenerCount(s))o(),this._processArguments(),this.parent.emit(s,e,n);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,n);this.listenerCount("command:*")?this.emit("command:*",e,n):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(n=>n._name===e||n._aliases.includes(e))}_findOption(e){return this.options.find(n=>n.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(n=>{n.mandatory&&e.getOptionValue(n.attributeName())===void 0&&e.missingMandatoryOptionValue(n)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let o=r.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let o=e.find(s=>r.conflictsWith.includes(s.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let n=[],r=[],o=n,s=e.slice();function u(a){return a.length>1&&a[0]==="-"}let p=null;for(;s.length;){let a=s.shift();if(a==="--"){o===r&&o.push(a),o.push(...s);break}if(p&&!u(a)){this.emit(`option:${p.name()}`,a);continue}if(p=null,u(a)){let l=this._findOption(a);if(l){if(l.required){let d=s.shift();d===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,d)}else if(l.optional){let d=null;s.length>0&&!u(s[0])&&(d=s.shift()),this.emit(`option:${l.name()}`,d)}else this.emit(`option:${l.name()}`);p=l.variadic?l:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let l=this._findOption(`-${a[1]}`);if(l){l.required||l.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${l.name()}`,a.slice(2)):(this.emit(`option:${l.name()}`),s.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let l=a.indexOf("="),d=this._findOption(a.slice(0,l));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,a.slice(l+1));continue}}if(u(a)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&n.length===0&&r.length===0){if(this._findCommand(a)){n.push(a),s.length>0&&r.push(...s);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){n.push(a),s.length>0&&n.push(...s);break}else if(this._defaultCommandName){r.push(a),s.length>0&&r.push(...s);break}}if(this._passThroughOptions){o.push(a),s.length>0&&o.push(...s);break}o.push(a)}return{operands:n,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},n=this.options.length;for(let r=0;r<n;r++){let o=this.options[r].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,n)=>Object.assign(e,n.opts()),{})}error(e,n){this._outputConfiguration.outputError(`${e}
18
18
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
19
19
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
20
- `),this.outputHelp({error:!0}));let r=t||{},o=r.exitCode||1,s=r.code||"commander.error";this._exit(o,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in X.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,X.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Rr(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(o=>!t(o)).forEach(o=>{this.setOptionValueWithSource(o,r.implied[o],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=a=>{let d=a.attributeName(),u=this.getOptionValue(d),c=this.options.find(m=>m.negate&&d===m.attributeName()),p=this.options.find(m=>!m.negate&&d===m.attributeName());return c&&(c.presetArg===void 0&&u===!1||c.presetArg!==void 0&&u===c.presetArg)?c:p||a},o=a=>{let d=r(a),u=d.attributeName();return this.getOptionValueSource(u)==="env"?`environment variable '${d.envVar}'`:`option '${d.flags}'`},s=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],s=this;do{let a=s.createHelp().visibleOptions(s).filter(d=>d.long).map(d=>d.long);o=o.concat(a),s=s.parent}while(s&&!s._enablePositionalOptions);t=qt(e,o)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(s=>{o.push(s.name()),s.alias()&&o.push(s.alias())}),t=qt(e,o)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let o=this.createOption(t,r);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
21
- `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let o=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${o}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(r=>Tr(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=ye.basename(e,ye.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},r;return t.error?r=o=>this._outputConfiguration.writeErr(o):r=o=>this._outputConfiguration.writeOut(o),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation(r);if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=X.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
22
- Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,s=>{let a;typeof t=="function"?a=t({error:s.error,command:s.command}):a=t,a&&s.write(`${a}
23
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(o=>t.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Bt(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",o="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?o=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],o=s[4]),t&&o!=="0"?`${t}=${r}:${parseInt(o)+1}`:e})}Ut.Command=it});var Kt=Ee(le=>{"use strict";I();var{Argument:Gt}=kn(),{Command:rt}=Vt(),{CommanderError:Hr,InvalidArgumentError:Wt}=Je(),{Help:Ir}=Jn(),{Option:Yt}=Zn();le.program=new rt;le.createCommand=i=>new rt(i);le.createOption=(i,e)=>new Yt(i,e);le.createArgument=(i,e)=>new Gt(i,e);le.Command=rt;le.Option=Yt;le.Argument=Gt;le.Help=Ir;le.CommanderError=Hr;le.InvalidArgumentError=Wt;le.InvalidOptionArgumentError=Wt});var En=Ee((os,ot)=>{"use strict";I();var Cn=process||{},Xt=Cn.argv||[],xn=Cn.env||{},Pr=!(xn.NO_COLOR||Xt.includes("--no-color"))&&(!!xn.FORCE_COLOR||Xt.includes("--color")||Cn.platform==="win32"||(Cn.stdout||{}).isTTY&&xn.TERM!=="dumb"||!!xn.CI),Mr=(i,e,t=i)=>r=>{let o=""+r,s=o.indexOf(e,i.length);return~s?i+Fr(o,e,t,s)+e:i+o+e},Fr=(i,e,t,r)=>{let o="",s=0;do o+=i.substring(s,r)+t,s=r+e.length,r=i.indexOf(e,s);while(~r);return o+i.substring(s)},Qt=(i=Pr)=>{let e=i?Mr:()=>String;return{isColorSupported:i,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};ot.exports=Qt();ot.exports.createColors=Qt});I();I();var Jt=_n(Kt(),1),{program:Yo,createCommand:Ko,createArgument:Jo,createOption:zo,CommanderError:Xo,InvalidArgumentError:Qo,InvalidOptionArgumentError:Zo,Command:zt,Argument:es,Option:ns,Help:ts}=Jt.default;var Q=_n(En(),1),dr=require("child_process"),Y=require("fs"),ne=require("path");I();I();I();var Sn=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function Zt(i){return i.uses!==void 0}I();function ze(i){let e=i.auth;return e?.mode?{mode:e.mode,appIdSecret:e.app_id_secret??i.identity.app_id_secret,appKeySecret:e.app_key_secret??i.identity.app_key_secret,tokenSecret:e.token_secret}:i.identity.app_id_secret&&i.identity.app_key_secret?{mode:"app",appIdSecret:i.identity.app_id_secret,appKeySecret:i.identity.app_key_secret}:{mode:"github-token"}}I();I();function Xe(i){return`\${{ secrets.${i} }}`}function we(i,e){if(!e)return"";let t=i.specDir?.replace(/\/+$/,"");return t?`${t}/${e}`:e}function ce(i){let e=ze(i.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?Xe(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}function vn(i){let e=ze(i.config);if(!(e.mode!=="app"||!e.appIdSecret||!e.appKeySecret))return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:{"app-id":Xe(e.appIdSecret),"private-key":Xe(e.appKeySecret)}}}function On(i,e={}){let t={token:ce(i)};return e.ref&&(t.ref=e.ref),e.fetchDepth!==void 0&&(t["fetch-depth"]=e.fetchDepth),{uses:"actions/checkout@v5",name:"Checkout",with:t}}function Le(){return{uses:"./.github/agent-setup",name:"Setup agent toolchain"}}function ei(i){let e=i.config.identity,t=e.git_name??e.bot_login??"gp-foundry agent",r=e.git_email??`${e.bot_login??"gp-foundry-agent"}@users.noreply.github.com`;return de({name:"Configure git identity",env:{GIT_NAME:t,GIT_EMAIL:r},run:`git config user.name "$GIT_NAME"
24
- git config user.email "$GIT_EMAIL"`})}function Qe(i,e,t){let r={type:e,number:t,token:ce(i)},o=i.config.identity?.bot_login;return o&&(r["trusted-authors"]=o),{uses:i.actionRef("agent-context"),id:"ctx",name:"Fetch context",with:r}}function De(i,e){let t=i.node,r=i.config,o={"role-file":we(i,t.files.role),model:r.agent.model,"comms-file":we(i,"agents/communication.md"),"scope-path":we(i,"agents/scope.yaml"),"claude-code-oauth-token":Xe(r.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN"),"github-token":ce(i)};e.withContext&&(o["context-file"]="${{ steps.ctx.outputs.context-file }}"),r.agent.conventions&&(o.conventions=r.agent.conventions);let s=typeof t.attrs.secrets=="string"?t.attrs.secrets.split(",").map(c=>c.trim()).filter(Boolean):[],a=[...new Set([...r.agent.secrets??[],...s])];a.length&&(o["extra-env"]=a.map(c=>`${c}=${Xe(c)}`).join(`
25
- `));let d=t.attrs.agent_attempts;d!==void 0&&(o["max-attempts"]=String(d));let u=t.files.prompt;return u&&(o["prompt-override-file"]=we(i,u)),{uses:i.actionRef("run-agent"),name:"Run agent",with:o}}function de(i){return{shell:"bash",...i}}function at(i){let e=i.attrs.permissions;if(e===void 0)return{};if(typeof e!="string"||!e.trim())throw new Error(`node '${i.id}': permissions= must be a non-empty string like "id-token: write"`);let t={},r=e.split(",").filter(o=>o.trim());if(!r.length)throw new Error(`node '${i.id}': permissions= has no entries \u2014 expected e.g. "id-token: write"`);for(let o of r){let s=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(o);if(!s)throw new Error(`node '${i.id}': bad permissions= entry '${o.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);t[s[1]]=s[2]}return t}function ti(i,e){let t;try{t=at(i)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var He="${{ github.event.issue.number }}",Ze="${{ github.event.pull_request.number }}",$n="${{ github.event.pull_request.head.sha }}",ni="${{ github.event.pull_request.head.ref }}";function Se(i,e){let t=i.attrs.timeout;return typeof t=="number"?t:e}var jr=10;function Tn(i){return Math.max(1,i-jr)}function Nn(i,e){let t=[],r=vn(i);return r&&t.push(r),t.push(On(i,e)),t.push(ei(i)),t}function st(i){let e=i.node,t=e.context??"issue",r=t==="pr-diff"||t==="pr-review",o=r?{contents:"read","pull-requests":"write"}:{contents:"read",issues:"write"},s=[],a=vn(i);a&&s.push(a),s.push(On(i,r?{ref:$n,fetchDepth:0}:void 0));let d=typeof e.attrs.gates=="string"?e.attrs.gates:void 0,u=r&&d?d.split(",").map(k=>k.trim()).filter(Boolean):[],c=u.map((k,$)=>Lr(`gate-${k}`,$,u));u.forEach((k,$)=>{s.push({uses:i.actionRef("wait-for-checks"),id:c[$],name:`Wait for ${k}`,with:{sha:$n,"workflow-name":k,token:ce(i)}})}),s.push(Le());let p=t==="pr-diff"?"pr-diff":t==="pr-review"?"pr-review":"issue";s.push(Qe(i,p,r?Ze:He)),u.length&&s.push(Dr(u,c));let m=Se(e,u.length?15+15*u.length:25),g=De(i,{withContext:!0});return s.push(u.length?g:{...g,timeoutMinutes:Tn(m)}),{jobId:e.id,name:e.id,permissions:o,timeoutMinutes:m,steps:s}}function Lr(i,e,t){let r=a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),o=r(i)||`gate-${e+1}`;return t.filter((a,d)=>d!==e&&r(`gate-${a}`)===o).length>0?`${o}-${e+1}`:o}function Dr(i,e){let t={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},r=["{",' echo ""',' echo "=== CI GATES ==="'];return i.forEach((o,s)=>{t[`GATE_${s+1}_NAME`]=o,t[`GATE_${s+1}_RESULT`]=`\${{ steps.${e[s]}.outputs.conclusion }}`,r.push(` echo "$GATE_${s+1}_NAME: $GATE_${s+1}_RESULT"`)}),r.push(' echo ""',` echo "A gate whose result is not 'success' is a blocking finding: say which one"`,` echo "failed and request changes. 'timeout' or 'skipped' means CI never gave an"`,' echo "answer \u2014 treat it as unverified, not as a pass."','} >> "$CONTEXT_FILE"'),de({name:"Record CI gate results in the context",env:t,run:r.join(`
26
- `)})}function qr(i){let e=i.node,t=i.config,r=Nn(i);r.push(de({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:He,ISSUE_TITLE:"${{ github.event.issue.title }}",PREFIX:t.repo.branch_prefix},run:[`SLUG=$(printf '%s' "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-50 | sed 's/-$//')`,'BRANCH="$PREFIX$ISSUE_NUMBER-$SLUG"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
27
- `)}));let o=Se(e,35);return r.push(Le()),r.push(Qe(i,"issue",He)),r.push({...De(i,{withContext:!0}),timeoutMinutes:Tn(o)}),r.push({uses:i.actionRef("agent-fallback"),name:"Fallback: commit / push / PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}",token:ce(i),"agent-name":e.id,"base-branch":t.repo.base_branch,"issue-number":He,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
20
+ `),this.outputHelp({error:!0}));let r=n||{},o=r.exitCode||1,s=r.code||"commander.error";this._exit(o,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in Q.env){let n=e.attributeName();(this.getOptionValue(n)===void 0||["default","config","env"].includes(this.getOptionValueSource(n)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,Q.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new ao(this.options),n=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&n(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(o=>!n(o)).forEach(o=>{this.setOptionValueWithSource(o,r.implied[o],"implied")})})}missingArgument(e){let n=`error: missing required argument '${e}'`;this.error(n,{code:"commander.missingArgument"})}optionMissingArgument(e){let n=`error: option '${e.flags}' argument missing`;this.error(n,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let n=`error: required option '${e.flags}' not specified`;this.error(n,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,n){let r=u=>{let p=u.attributeName(),a=this.getOptionValue(p),l=this.options.find(f=>f.negate&&p===f.attributeName()),d=this.options.find(f=>!f.negate&&p===f.attributeName());return l&&(l.presetArg===void 0&&a===!1||l.presetArg!==void 0&&a===l.presetArg)?l:d||u},o=u=>{let p=r(u),a=p.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${p.envVar}'`:`option '${p.flags}'`},s=`error: ${o(e)} cannot be used with ${o(n)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let n="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],s=this;do{let u=s.createHelp().visibleOptions(s).filter(p=>p.long).map(p=>p.long);o=o.concat(u),s=s.parent}while(s&&!s._enablePositionalOptions);n=li(e,o)}let r=`error: unknown option '${e}'${n}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let n=this.registeredArguments.length,r=n===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${n} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],n="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(s=>{o.push(s.name()),s.alias()&&o.push(s.alias())}),n=li(e,o)}let r=`error: unknown command '${e}'${n}`;this.error(r,{code:"commander.unknownCommand"})}version(e,n,r){if(e===void 0)return this._version;this._version=e,n=n||"-V, --version",r=r||"output the version number";let o=this.createOption(n,r);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
21
+ `),this._exit(0,"commander.version",e)}),this}description(e,n){return e===void 0&&n===void 0?this._description:(this._description=e,n&&(this._argsDescription=n),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let n=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(n=this.commands[this.commands.length-1]),e===n._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let o=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${o}'`)}return n._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(n=>this.alias(n)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let n=this.registeredArguments.map(r=>oo(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?n:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=$e.basename(e,$e.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let n=this.createHelp();return n.helpWidth===void 0&&(n.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),n.formatHelp(this,n)}_getHelpContext(e){e=e||{};let n={error:!!e.error},r;return n.error?r=o=>this._outputConfiguration.writeErr(o):r=o=>this._outputConfiguration.writeOut(o),n.write=e.write||r,n.command=this,n}outputHelp(e){let n;typeof e=="function"&&(n=e,e=void 0);let r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation(r);if(n&&(o=n(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}helpOption(e,n){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",n=n??"display help for command",this._helpOption=this.createOption(e,n),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let n=Q.exitCode||0;n===0&&e&&typeof e!="function"&&e.error&&(n=1),this._exit(n,"commander.help","(outputHelp)")}addHelpText(e,n){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
22
+ Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,s=>{let u;typeof n=="function"?u=n({error:s.error,command:s.command}):u=n,u&&s.write(`${u}
23
+ `)}),this}_outputHelpIfRequested(e){let n=this._getHelpOption();n&&e.find(o=>n.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ci(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let n,r="127.0.0.1",o="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?n=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(n=s[1],/^\d+$/.test(s[3])?o=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(n=s[1],r=s[3],o=s[4]),n&&o!=="0"?`${n}=${r}:${parseInt(o)+1}`:e})}ui.Command=ft});var mi=Ce(pe=>{"use strict";P();var{Argument:pi}=Hn(),{Command:ht}=di(),{CommanderError:lo,InvalidArgumentError:fi}=an(),{Help:co}=ot(),{Option:hi}=ct();pe.program=new ht;pe.createCommand=i=>new ht(i);pe.createOption=(i,e)=>new hi(i,e);pe.createArgument=(i,e)=>new pi(i,e);pe.Command=ht;pe.Option=hi;pe.Argument=pi;pe.Help=co;pe.CommanderError=lo;pe.InvalidArgumentError=fi;pe.InvalidOptionArgumentError=fi});var Mn=Ce((Gs,mt)=>{"use strict";P();var Pn=process||{},yi=Pn.argv||[],In=Pn.env||{},uo=!(In.NO_COLOR||yi.includes("--no-color"))&&(!!In.FORCE_COLOR||yi.includes("--color")||Pn.platform==="win32"||(Pn.stdout||{}).isTTY&&In.TERM!=="dumb"||!!In.CI),po=(i,e,n=i)=>r=>{let o=""+r,s=o.indexOf(e,i.length);return~s?i+fo(o,e,n,s)+e:i+o+e},fo=(i,e,n,r)=>{let o="",s=0;do o+=i.substring(s,r)+n,s=r+e.length,r=i.indexOf(e,s);while(~r);return o+i.substring(s)},wi=(i=uo)=>{let e=i?po:()=>String;return{isColorSupported:i,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};mt.exports=wi();mt.exports.createColors=wi});P();P();var gi=Rn(mi(),1),{program:Ns,createCommand:Hs,createArgument:Is,createOption:Ps,CommanderError:Ms,InvalidArgumentError:Fs,InvalidOptionArgumentError:Ds,Command:bi,Argument:js,Option:Ls,Help:qs}=gi.default;var K=Rn(Mn(),1),Lr=require("child_process"),V=require("fs"),ne=require("path");P();P();P();var Be=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function _i(i){return i.uses!==void 0}P();function ln(i){let e=i.auth;return e?.mode?{mode:e.mode,appIdSecret:e.app_id_secret??i.identity.app_id_secret,appKeySecret:e.app_key_secret??i.identity.app_key_secret,tokenSecret:e.token_secret}:i.identity.app_id_secret&&i.identity.app_key_secret?{mode:"app",appIdSecret:i.identity.app_id_secret,appKeySecret:i.identity.app_key_secret}:{mode:"github-token"}}P();P();var gt=new Set(["type","role","prompt","policy","tools","context","name","output","gates","skip","select","authors","max_attempts","agent_attempts","schedule","timeout","environment","paths","commit","secrets","permissions","on_complete_label","cancel_in_progress","checkout"]),bt=new Set(["on","when","do"]);function Ai(i,e){let n=(s,u)=>{let p=Array.from({length:u.length+1},(a,l)=>l);for(let a=1;a<=s.length;a++){let l=p[0];p[0]=a;for(let d=1;d<=u.length;d++){let f=p[d];p[d]=Math.min(p[d]+1,p[d-1]+1,l+(s[a-1]===u[d-1]?0:1)),l=f}}return p[u.length]},r,o=3;for(let s of e){let u=n(i.toLowerCase(),s);u<o&&([r,o]=[s,u])}return r}function yt(i){let e=i.attrs.gates;if(e===void 0)return[];if(typeof e!="string")throw new Error(`node '${i.id}': gates= must be a string like "ci.yml" or "lint?90"`);let n=[];for(let r of e.split(",").map(o=>o.trim()).filter(Boolean)){let o=/^(.*?)(?:\?([^?]*))?$/.exec(r),s=o[1].trim(),u=o[2];if(!s)throw new Error(`node '${i.id}': gates= entry '${r}' names no workflow or check`);let p={name:s,kind:/\.ya?ml$/i.test(s)?"workflow":"check"};if(u!==void 0){if(!/^[1-9]\d*$/.test(u.trim()))throw new Error(`node '${i.id}': gates= entry '${r}' has a bad grace suffix \u2014 expected '?<seconds>' with a whole number >= 1, e.g. "${s}?90"`);p.graceSeconds=Number(u.trim())}n.push(p)}return n}function ki(i){try{return yt(i)}catch{return[]}}function wt(i){let e=i.attrs.skip;if(e===void 0)return[];if(typeof e!="string"||!e.trim())throw new Error(`node '${i.id}': skip= must be a non-empty string like "draft,unchanged-diff"`);let n=[],r=new Set;for(let o of e.split(",").map(s=>s.trim()).filter(Boolean))if(!r.has(o))if(r.add(o),o==="draft"||o==="bot-author"||o==="unchanged-diff")n.push({kind:o});else if(o.startsWith("label:")&&o.slice(6).trim())n.push({kind:"label",label:o.slice(6).trim()});else throw new Error(`node '${i.id}': unknown skip= entry '${o}' \u2014 expected draft, bot-author, label:<key> or unchanged-diff`);if(!n.length)throw new Error(`node '${i.id}': skip= has no entries`);return n}function Ie(i){try{return wt(i)}catch{return[]}}var ho=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function $i(i,e){let n=[];for(let r of i){let o=String(r).trim();if(!o)continue;if(!ho.test(o))throw new Error(`${e}: '${o}' is not a GitHub login`);let s=o.toLowerCase();n.includes(s)||n.push(s)}if(!n.length)throw new Error(`${e}: names no login \u2014 an empty allowlist would match nobody`);return n}function _t(i){return i.type==="pr-fix"||(i.type==="pr-review"||i.type==="analyst")&&We(i)}function At(i,e){let n=i.attrs.authors;return n!==void 0?$i(String(n).split(","),`node '${i.id}': authors=`):cn(e)}function cn(i){let e=i.repo?.authors;if(e!==void 0){if(!Array.isArray(e))throw new Error("repo.authors must be a list of GitHub logins");return $i(e,"repo.authors")}}function Ge(i,e){if(_t(i))try{return At(i,e)}catch{return[kt]}}var kt="no author matches a malformed allowlist";function Ei(i){let e=i.map(n=>`github.event.pull_request.user.login == '${n}'`);return e.length===1?e[0]:`(${e.join(" || ")})`}function We(i){return i.context==="pr-diff"||i.context==="pr-review"}function Ve(i){return i.attrs.select==="sweep"&&i.type==="pr-review"&&We(i)&&i.attrs.schedule!==void 0}function Ye(i,e){return(i.type==="pr-review"||i.type==="analyst")&&We(i)&&i.attrs.schedule===void 0&&(Ie(i).length>0||Ge(i,e)!==void 0)}function Ke(i){return Ve(i)?`${i.id}_select`:`${i.id}_guard`}function Fn(i){return`${i.id} #`}function $t(i){return`gp-foundry/swept (${i.id})`}function Dn(i){return`<!-- gp-foundry:diff:${i.id}:`}var Si="**Verdict:**";P();function Je(i){return`\${{ secrets.${i} }}`}function Ee(i,e){if(!e)return"";let n=i.specDir?.replace(/\/+$/,"");return n?`${n}/${e}`:e}function de(i){let e=ln(i.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?Je(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}function jn(i){let e=ln(i.config);if(!(e.mode!=="app"||!e.appIdSecret||!e.appKeySecret))return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:{"app-id":Je(e.appIdSecret),"private-key":Je(e.appKeySecret)}}}function Ln(i,e={}){let n={token:de(i)};return e.ref&&(n.ref=e.ref),i.node.attrs.checkout==="partial"?(n["fetch-depth"]=0,n.filter="blob:none"):e.fetchDepth!==void 0&&(n["fetch-depth"]=e.fetchDepth),{uses:"actions/checkout@v5",name:"Checkout",with:n}}function ze(){return{uses:"./.github/agent-setup",name:"Setup agent toolchain"}}function vi(i){let e=i.config.identity,n=e.git_name??e.bot_login??"gp-foundry agent",r=e.git_email??`${e.bot_login??"gp-foundry-agent"}@users.noreply.github.com`;return re({name:"Configure git identity",env:{GIT_NAME:n,GIT_EMAIL:r},run:`git config user.name "$GIT_NAME"
24
+ git config user.email "$GIT_EMAIL"`})}function un(i,e,n){let r={type:e,number:n,token:de(i)},o=i.config.identity?.bot_login;return o&&(r["trusted-authors"]=o),{uses:i.actionRef("agent-context"),id:"ctx",name:"Fetch context",with:r}}function Xe(i,e){let n=i.node,r=i.config,o={"role-file":Ee(i,n.files.role),model:r.agent.model,"comms-file":Ee(i,"agents/communication.md"),"scope-path":Ee(i,"agents/scope.yaml"),...r.agent.api_key_secret?{"anthropic-api-key":Je(r.agent.api_key_secret)}:{"claude-code-oauth-token":Je(r.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")},"github-token":de(i)};e.withContext&&(o["context-file"]="${{ steps.ctx.outputs.context-file }}"),r.agent.conventions&&(o.conventions=r.agent.conventions);let s=typeof n.attrs.secrets=="string"?n.attrs.secrets.split(",").map(l=>l.trim()).filter(Boolean):[],u=[...new Set([...r.agent.secrets??[],...s])];u.length&&(o["extra-env"]=u.map(l=>`${l}=${Je(l)}`).join(`
25
+ `));let p=n.attrs.agent_attempts;p!==void 0&&(o["max-attempts"]=String(p));let a=n.files.prompt;return a&&(o["prompt-override-file"]=Ee(i,a)),{uses:i.actionRef("run-agent"),name:"Run agent",with:o}}function re(i){return{shell:"bash",...i}}function St(i){let e=i.attrs.permissions;if(e===void 0)return{};if(typeof e!="string"||!e.trim())throw new Error(`node '${i.id}': permissions= must be a non-empty string like "id-token: write"`);let n={},r=e.split(",").filter(o=>o.trim());if(!r.length)throw new Error(`node '${i.id}': permissions= has no entries \u2014 expected e.g. "id-token: write"`);for(let o of r){let s=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(o);if(!s)throw new Error(`node '${i.id}': bad permissions= entry '${o.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);n[s[1]]=s[2]}return n}function Ci(i,e){let n;try{n=St(i)}catch{return e}return Object.keys(n).length?{...e,permissions:{...e.permissions,...n}}:e}var Pe="${{ github.event.issue.number }}",Qe="${{ github.event.pull_request.number }}",vt="${{ github.event.pull_request.head.sha }}",xi="${{ github.event.pull_request.head.ref }}";function Oe(i,e){let n=i.attrs.timeout;return typeof n=="number"?n:e}var mo=10;function qn(i){return Math.max(1,i-mo)}function Un(i,e){let n=[],r=jn(i);return r&&n.push(r),n.push(Ln(i,e)),n.push(vi(i)),n}function Et(i){let e=i.node,n=e.context??"issue",r=n==="pr-diff"||n==="pr-review",o=r?{contents:"read","pull-requests":"write"}:{contents:"read",issues:"write"},s=Ve(e),u=!s&&Ye(e,i.config),p=Ke(e),a=s?"${{ matrix.pr.number }}":Qe,l=s?"${{ matrix.pr.sha }}":vt,d=[],f=jn(i);f&&d.push(f),d.push(Ln(i,r?{ref:l,fetchDepth:0}:void 0));let m=r?ki(e):[],A=m.map(M=>M.name),C=A.map((M,L)=>bo(`gate-${M}`,L,A));m.forEach((M,L)=>{d.push({uses:i.actionRef("wait-for-checks"),id:C[L],name:`Wait for ${M.name}`,with:{sha:l,...M.kind==="workflow"?{"workflow-name":M.name,token:de(i)}:{"check-name":M.name,token:"${{ github.token }}"},...M.graceSeconds!==void 0?{"missing-grace-seconds":M.graceSeconds}:{}}})}),m.some(M=>M.kind==="check")&&(o.checks="read"),d.push(ze());let w=n==="pr-diff"?"pr-diff":n==="pr-review"?"pr-review":"issue";d.push(un(i,w,r?a:Pe)),A.length&&d.push(yo(A,C));let k=Oe(e,A.length?15+15*A.length:25),H=Xe(i,{withContext:!0});d.push(A.length?H:{...H,timeoutMinutes:qn(k)});let N={jobId:e.id,name:e.id,permissions:o,timeoutMinutes:k,steps:d};return s?(N.needs=[p],N.displayName=`${Fn(e)}\${{ matrix.pr.number }}`,N.if=`needs.${p}.outputs.count != '0'`,N.strategy={"fail-fast":!1,matrix:{pr:`\${{ fromJSON(needs.${p}.outputs.prs) }}`}}):u&&(N.needs=[p],N.if=`needs.${p}.outputs.run == 'true'`,Ie(e).some(M=>M.kind==="unchanged-diff")&&d.push(go(i,p))),N}function go(i,e){return re({name:"Stamp the review with the diff hash",if:`\${{ success() && needs.${e}.outputs.diff_hash != '' }}`,env:{GH_TOKEN:de(i),PR:Qe,HEAD_SHA:`\${{ needs.${e}.outputs.head_sha }}`,DIFF_HASH:`\${{ needs.${e}.outputs.diff_hash }}`,BOT_LOGIN:i.config.identity?.bot_login??"",MARKER_PREFIX:Dn(i.node)},run:["# Best-effort: a missing stamp only means the next event is reviewed again.",`ID=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," .[] | select(.user.login == env.BOT_LOGIN and .commit_id == env.HEAD_SHA)",` | select((.body // "") | contains(env.MARKER_PREFIX) | not) | .id' 2>/dev/null | tail -n 1) || ID=""`,'if [ -z "$ID" ]; then',' echo "no unstamped review by $BOT_LOGIN on $HEAD_SHA \u2014 nothing to stamp"'," exit 0","fi",`BODY=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$ID" --jq '.body // ""') || exit 0`,'gh api --method PUT "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$ID" \\',` -f body="$(printf '%s\\n\\n%s%s -->' "$BODY" "$MARKER_PREFIX" "$DIFF_HASH")" >/dev/null \\`,' || echo "::warning::could not stamp review $ID with the diff hash"'].join(`
26
+ `)})}function bo(i,e,n){let r=u=>u.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),o=r(i)||`gate-${e+1}`;return n.filter((u,p)=>p!==e&&r(`gate-${u}`)===o).length>0?`${o}-${e+1}`:o}function yo(i,e){let n={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},r=["{",' echo ""',' echo "=== CI GATES ==="'];return i.forEach((o,s)=>{n[`GATE_${s+1}_NAME`]=o,n[`GATE_${s+1}_RESULT`]=`\${{ steps.${e[s]}.outputs.conclusion }}`,r.push(` echo "$GATE_${s+1}_NAME: $GATE_${s+1}_RESULT"`)}),r.push(' echo ""',` echo "A gate whose result is not 'success' is a blocking finding: say which one"`,` echo "failed and request changes. 'timeout' or 'skipped' means CI never gave an"`,' echo "answer \u2014 treat it as unverified, not as a pass."','} >> "$CONTEXT_FILE"'),re({name:"Record CI gate results in the context",env:n,run:r.join(`
27
+ `)})}function wo(i){let e=i.node,n=i.config,r=Un(i);r.push(re({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:Pe,ISSUE_TITLE:"${{ github.event.issue.title }}",PREFIX:n.repo.branch_prefix},run:[`SLUG=$(printf '%s' "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-50 | sed 's/-$//')`,'BRANCH="$PREFIX$ISSUE_NUMBER-$SLUG"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
28
+ `)}));let o=Oe(e,35);return r.push(ze()),r.push(un(i,"issue",Pe)),r.push({...Xe(i,{withContext:!0}),timeoutMinutes:qn(o)}),r.push({uses:i.actionRef("agent-fallback"),name:"Fallback: commit / push / PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}",token:de(i),"agent-name":e.id,"base-branch":n.repo.base_branch,"issue-number":Pe,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
28
29
 
29
30
  The agent finished but didn't open a PR itself, so one was created automatically. See the commits and the linked issue for context.
30
31
 
31
- Closes #${He}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:o,steps:r}}function Br(i){let e=i.node,t=Nn(i,{ref:ni,fetchDepth:0}),r=typeof e.attrs.max_attempts=="number"?e.attrs.max_attempts:3,o=`<!-- gp-foundry:attempt:${e.id} -->`,s=i.config.labels?.["needs-human"]??"needs-human",a=i.config.identity?.bot_login??"";t.push(de({id:"attempts",name:`Enforce attempt budget (max ${r})`,env:{GH_TOKEN:ce(i),PR:Ze,MARKER:o,MAX:String(r),BOT_LOGIN:a},run:["# One request-changes verdict = one attempt. The jq filter reads the bot","# login from the environment (never interpolated into the script), and an","# empty BOT_LOGIN counts any reviewer's request-changes.","# (--paginate emits one count per page, so the counts are summed.)",`COUNT=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," [ .[]",' | select(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',' | select(.state == "CHANGES_REQUESTED" or ((.body // "") | test("Verdict.*REQUEST_CHANGES")))'," ] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}')",'[ -n "$COUNT" ] || COUNT=0','echo "attempts so far: $COUNT / $MAX"','if [ "$COUNT" -gt "$MAX" ]; then',` gh pr edit "$PR" --add-label "${s}" 2>/dev/null || gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/labels" -f 'labels[]=${s}'`,` gh pr comment "$PR" --body "$(printf '## \u26D4 Attempt budget (${e.id})\\n\\nExhausted (%s/%s requested-changes rounds) \u2014 labeling \`${s}\` and stopping. A human should take this over.\\n\\n%s' "$COUNT" "$MAX" "$MARKER")"`,' echo "exhausted=true" >> "$GITHUB_OUTPUT"',"else",` gh pr comment "$PR" --body "$(printf '%s attempt %s of %s' "$MARKER" "$COUNT" "$MAX")" >/dev/null`,' echo "exhausted=false" >> "$GITHUB_OUTPUT"',"fi"].join(`
32
- `)}));let d="steps.attempts.outputs.exhausted != 'true'";return t.push({...Le(),if:d}),t.push({...Qe(i,"pr-review",Ze),if:d}),t.push({...De(i,{withContext:!0}),if:d,timeoutMinutes:Tn(Se(e,35))}),t.push(de({name:"Commit and push fixes",if:`${d} && !cancelled()`,env:{BRANCH:ni},run:["# Commit anything the agent left uncommitted...",'if [ -n "$(git status --porcelain)" ]; then'," git add -A",` git commit -m "agent fix: ${e.id}"`,"fi","# ...then push if HEAD is ahead of the remote (the agent may have committed itself).",'git fetch origin "$BRANCH" --quiet 2>/dev/null || true','if [ "$(git rev-parse HEAD)" != "$(git rev-parse "origin/$BRANCH" 2>/dev/null || echo none)" ]; then',' git push origin "HEAD:$BRANCH"',' echo "pushed fix to $BRANCH"',"else",' echo "no changes to push"',"fi"].join(`
33
- `)})),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write"},timeoutMinutes:Se(e,35),steps:t}}function ii(i){return`gp-foundry/human-approval (${String(i.attrs.environment??"production")})`}var Ur="github-actions";function Vr(i){return`${ii(i)}@${Ur}`}function Gr(i){let e=i.node,t=Nn(i,{fetchDepth:0}),o=i.inEdges.map(s=>i.nodeById?.(s.from)).filter(s=>!!s&&s.type==="human-gate").map(Vr);return t.push({uses:i.actionRef("merge-gate"),name:"Evaluate merge gate",with:{token:ce(i),"checks-token":"${{ github.token }}","policy-path":we(i,e.files.policy),"base-branch":i.config.repo.base_branch,"branch-prefix":i.config.repo.branch_prefix,...i.config.identity?.bot_login?{"bot-login":i.config.identity.bot_login}:{},...o.length?{"required-checks":o.join(",")}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write",checks:"read"},timeoutMinutes:Se(e,10),steps:t}}function Wr(i){let e=i.node,t=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:t,steps:[de({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME:ii(e),HEAD_SHA:$n,ENVIRONMENT:t},run:['if ! gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$CHECK_NAME" \\',' -f head_sha="$HEAD_SHA" \\'," -f status=completed \\"," -f conclusion=success \\"," -f 'output[title]=Approved' \\",' -f "output[summary]=Environment \\"$ENVIRONMENT\\" was approved by a human for $HEAD_SHA."; then',' echo "::error::Approved for $ENVIRONMENT, but publishing the approval check failed."',' echo "::error::The merge gate requires \\"$CHECK_NAME\\" on $HEAD_SHA, so this PR will not merge until it is published."'," exit 1","fi",'echo "Approved for $ENVIRONMENT."'].join(`
34
- `)})]}}function Yr(i){let e=i.node,t=i.config,r=Nn(i,{fetchDepth:0}),o=typeof e.attrs.commit=="string"?e.attrs.commit:"direct",s=typeof e.attrs.paths=="string"?e.attrs.paths:"";return o==="pr"&&r.push(de({id:"branch",name:"Create branch",env:{PREFIX:t.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}"},run:['BRANCH="$PREFIX$NODE-$RUN_ID"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
35
- `)})),r.push(Le()),r.push({...De(i,{withContext:!1}),id:"agent",timeoutMinutes:Tn(Se(e,20))}),o==="pr"?r.push({uses:i.actionRef("agent-fallback"),name:"Commit, push branch, open PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}","base-branch":t.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":we(i,"agents/scope.yaml"),"pr-title":`${e.id}: scheduled update`,"pr-body":`Scheduled output from the \`${e.id}\` lane \u2014 review and merge like any agent PR.`,...s?{"allowed-paths":s}:{}}}):o==="direct"&&(r.push({uses:i.actionRef("agent-fallback"),name:"Strip protected paths, commit, push",with:{branch:t.repo.base_branch,"base-branch":t.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":we(i,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...s?{"allowed-paths":s}:{}}}),r.push(de({id:"recovery",name:"Create recovery branch",if:"${{ !cancelled() && steps.agent.outcome == 'failure' }}",env:{PREFIX:t.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:['BRANCH="$PREFIX$NODE-recovery-$RUN_ID-$RUN_ATTEMPT"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
36
- `)})),r.push({uses:i.actionRef("agent-fallback"),name:"Preserve failed agent output for review",if:"${{ !cancelled() && steps.agent.outcome == 'failure' && steps.recovery.outcome == 'success' }}",with:{branch:"${{ steps.recovery.outputs.branch }}","base-branch":t.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":we(i,"agents/scope.yaml"),"pr-title":`${e.id}: recover incomplete scheduled output`,"pr-body":`Partial output from a failed \`${e.id}\` run. Review for completeness before merging. Run: \${{ github.server_url }}/\${{ github.repository }}/actions/runs/\${{ github.run_id }}`,"pr-label":i.config.labels?.["needs-human"]??"needs-human",...s?{"allowed-paths":s}:{}}})),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:Se(e,20),steps:r}}function ri(i,e,t){let r=i.node,o=[],s=vn(i);s&&o.push(s),o.push(On(i,t?{ref:$n,fetchDepth:0}:void 0)),o.push(Le()),o.push(Qe(i,t?"pr-review":"issue",t?Ze:He)),r.files.role&&o.push(De(i,{withContext:!0}));let a=r.attrs.on_complete_label;if(typeof a=="string"&&a){let d=i.config.labels?.[a]??a;o.push(de({name:"Apply completion label",env:{GH_TOKEN:ce(i),NUM:t?Ze:He},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${d}'`}))}return ti(r,{jobId:r.id,name:r.id,needs:e,permissions:t?{contents:"read","pull-requests":"write",issues:"write"}:{contents:"read",issues:"write"},timeoutMinutes:Se(r,15),steps:o})}var Kr={analyst:st,"issue-agent":st,"pr-review":st,producer:qr,"pr-fix":Br,"merge-gate":Gr,"human-gate":Wr,"scheduled-agent":Yr,start:()=>null,exit:()=>null};function lt(i,e,t){let r=Kr[i.type];if(!r)return null;let o=r(t);return o&&ti(i,o)}I();var Jr=new Set(Sn);function qe(i){let e=new Map(i.nodes.map(a=>[a.id,a])),t=new Map,r=new Map;for(let a of i.nodes)t.set(a.id,[]),r.set(a.id,[]);for(let a of i.edges)t.get(a.to)?.push(a),r.get(a.from)?.push(a);let o=new Map,s=new Set;for(let a of i.nodes){if(a.type!=="fan_in")continue;let d=t.get(a.id)??[];if(d.length<2)continue;let u=[],c,p=!0;for(let $ of d){let S=e.get($.from);if(!S||!Jr.has(S.type)){p=!1;break}let v=t.get(S.id)??[],P=r.get(S.id)??[];if(v.length!==1||P.length!==1||P[0].to!==a.id){p=!1;break}let F=e.get(v[0].from);if(!F||F.type!=="parallel"){p=!1;break}if(v[0].on||v[0].when){p=!1;break}if(c===void 0)c=F.id;else if(c!==F.id){p=!1;break}u.push(S.id)}if(!p||c===void 0)continue;let m=t.get(c)??[],g=r.get(c)??[];if(m.length!==1||!m[0].on)continue;let k=new Set(u);if(!(!g.every($=>k.has($.to))||g.length!==u.length)){o.set(a.id,{parallelId:c,entryEdge:m[0],legIds:u,faninId:a.id}),s.add(c);for(let $ of u)s.add($)}}return{byFanin:o,memberIds:s}}var Rn=new Set(Sn);function en(i,e={}){let t=[],r=new Map(i.nodes.map(a=>[a.id,a]));for(let a of i.nodes)a.declared||t.push({level:"error",code:"node.undeclared",message:`node '${a.id}' is referenced in an edge but never declared`,where:{node:a.id,line:a.line},hint:`add a node statement, e.g. ${a.id} [type=...]`});for(let a of i.nodes){if(Rn.has(a.type)&&!a.files.role&&t.push({level:"error",code:"node.missing-role",message:`agent node '${a.id}' (type ${a.type}) needs a role="..." job description`,where:{node:a.id,line:a.line}}),a.attrs.permissions!==void 0){try{at(a)}catch(d){t.push({level:"error",code:"node.bad-permissions",message:d.message,where:{node:a.id,line:a.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(a.type==="start"||a.type==="exit"||a.type==="parallel")&&t.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${a.id}' (type ${a.type}) is ignored \u2014 this node emits no workflow job`,where:{node:a.id,line:a.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}if(a.attrs.agent_attempts!==void 0){let d=a.attrs.agent_attempts;(typeof d!="number"||!Number.isInteger(d)||d<1)&&t.push({level:"error",code:"node.bad-agent-attempts",message:`agent_attempts= on '${a.id}' must be a whole number >= 1, got ${JSON.stringify(d)}`,where:{node:a.id,line:a.line},hint:"1 disables retrying; omit the attr to use run-agent's default \u2014 e.g. agent_attempts=1"}),Rn.has(a.type)||t.push({level:"warning",code:"node.agent-attempts-ignored",message:`agent_attempts= on '${a.id}' (type ${a.type}) is ignored \u2014 this node runs no agent`,where:{node:a.id,line:a.line},hint:"move agent_attempts= to the agent lane whose retry budget you meant to change"})}a.type==="human-gate"&&a.attrs.environment===void 0&&t.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${a.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:a.id,line:a.line}}),a.type==="merge-gate"&&!a.files.policy&&t.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${a.id}' has no policy="..."; default merge policy will be used`,where:{node:a.id,line:a.line}})}if(e.fileExists)for(let a of i.nodes)for(let d of["role","policy","prompt","tools"]){let u=a.files[d];u&&!e.fileExists(u)&&t.push({level:"error",code:"file.missing",message:`node '${a.id}' references ${d}="${u}" which does not exist`,where:{node:a.id,line:a.line,file:u}})}if(e.roles){let a=new Map;for(let u of i.nodes)a.set(u.id,[]);for(let u of i.edges){let c=r.get(u.to);c&&a.get(u.from)?.push({node:c,edge:u})}let d=u=>(e.roles?.get(u.id)?.role??u.id).toLowerCase();for(let u of i.nodes){let c=e.roles.get(u.id);if(!c?.handoffs)continue;let p=a.get(u.id)??[],m=new Set(p.flatMap(k=>[k.node.id.toLowerCase(),d(k.node)])),g=new Set(c.handoffs.map(k=>String(k.to).toLowerCase()));for(let k of c.handoffs)m.has(String(k.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${c.role}' (node '${u.id}') declares a handoff to '${k.to}' but there is no matching out-edge`,where:{node:u.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:k,edge:$}of p)k.type==="exit"&&!$.when||!g.has(k.id.toLowerCase())&&!g.has(d(k))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${u.id}' has an out-edge to '${k.id}' not declared as a handoff in role '${c.role}'`,where:{node:u.id,edge:[u.id,k.id]},hint:"document the handoff in the role, or remove the edge"})}}let o=(a,d)=>{if(typeof a=="string"){let u=a.match(/<[A-Za-z][^<>]{0,80}>/);u&&t.push({level:"error",code:"config.placeholder",message:`config value ${d} still contains the placeholder ${u[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(a))a.forEach((u,c)=>o(u,`${d}[${c}]`));else if(a&&typeof a=="object")for(let[u,c]of Object.entries(a))o(c,d?`${d}.${u}`:u)};if(o(i.config,""),e.fileExists&&(i.config.runtime?.mode??"pinned")==="vendored"){let a=new Set,d=!1;for(let u of i.nodes)Rn.has(u.type)&&(d=!0,a.add("run-agent")),Rn.has(u.type)&&u.type!=="scheduled-agent"&&a.add("agent-context"),(u.type==="producer"||u.type==="scheduled-agent")&&a.add("agent-fallback"),u.type==="merge-gate"&&a.add("merge-gate"),u.type==="pr-review"&&u.attrs.gates!==void 0&&a.add("wait-for-checks");for(let u of a)e.fileExists(`actions/${u}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${u}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});d&&!e.fileExists("agent-setup/action.yml")&&t.push({level:"warning",code:"runtime.agent-setup-missing",message:"generated agent jobs use ./.github/agent-setup, which does not exist",hint:"run `gp-foundry vendor` (or `gp-foundry init`) to scaffold the agent-setup shim"})}{let{byFanin:a,memberIds:d}=qe(i);for(let u of i.nodes)if(u.type==="parallel"&&!d.has(u.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${u.id}' is not part of a clean diamond (need: exactly one in-edge carrying on=, \u22652 bare out-edges to agent legs that each flow into one fan_in)`,where:{node:u.id,line:u.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),u.type==="fan_in"){let c=a.get(u.id);if(!c)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${u.id}' is not the join of a clean diamond (need \u22652 legs, each with exactly one in-edge from a shared parallel and one out-edge into this fan_in)`,where:{node:u.id,line:u.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!u.files.role&&u.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${u.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:u.id,line:u.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let p=c.legIds.filter(m=>r.get(m)?.type==="pr-review");p.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${u.id}' lanes [${p.join(", ")}] are pr-review typed \u2014 if a lane role posts a '**Verdict:**' review, the merge gate acts on ONE lane's opinion and the join is bypassed`,where:{node:u.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(ze(i.config).mode==="github-token"){let a=i.edges.filter(d=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(d.on??"")||/^(label=|verdict=)/.test(d.when??""));a.length&&t.push({level:i.config.auth?.mode==="github-token"?"error":"warning",code:"auth.github-token-no-cascade",message:`auth mode 'github-token': commits/PRs made with GITHUB_TOKEN do not trigger other workflows, so ${a.length} event-cascade edge(s) (pull_request.opened/synchronize/push) will not fire and the harness will stall`,hint:"use auth.mode 'app' or 'pat' (a fine-grained PAT secret), or drive those stages via explicit dispatch"})}return!i.config.identity?.bot_login&&i.edges.some(a=>/^verdict=/.test(a.when??""))&&t.push({level:"warning",code:"auth.no-bot-login",message:"identity.bot_login is unset, so verdict-triggered workflows (fixer, human-gate) guard only on the verdict marker \u2014 any user who can review the PR can fire them",hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"}),i.nodes.some(a=>a.type==="start"||a.attrs.schedule!==void 0||a.type==="merge-gate")||t.push({level:"warning",code:"graph.no-entry",message:"harness has no entry node (a start node or a scheduled node) \u2014 nothing will trigger it"}),t}I();var zr=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),oi=new Set(["start"]);function nn(i){let e=[],t=new Set(i.nodes.map(c=>c.id)),r=new Map(i.nodes.map(c=>[c.id,c])),o=new Map;for(let c of t)o.set(c,[]);for(let c of i.edges)t.has(c.from)&&t.has(c.to)&&o.get(c.from).push(c.to);let s=i.nodes.filter(c=>oi.has(c.type)||c.attrs.schedule!==void 0||c.type==="merge-gate"),a=new Set,d=s.map(c=>c.id);for(;d.length;){let c=d.pop();if(!a.has(c)){a.add(c);for(let p of o.get(c)??[])d.push(p)}}for(let c of i.nodes)!a.has(c.id)&&!oi.has(c.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${c.id}' is unreachable from any entry (start/scheduled) node`,where:{node:c.id,line:c.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let c of i.nodes)(o.get(c.id)??[]).length===0&&!zr.has(c.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${c.id}' (type ${c.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:c.id,line:c.line},hint:"route it to a next node, or make it an exit"});for(let c of Zr(t,o)){if(!(c.length>1||(o.get(c[0])??[]).includes(c[0])))continue;let m=new Set(c),g=[];for(let k of c)for(let $ of o.get(k)??[])m.has($)||g.push({from:k,to:$});g.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${c.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:c[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):g.some(k=>Qr(Xr(i,k.from,k.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${c.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:c[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let u=new Map;for(let c of i.edges){let p=`${c.on??""}|${c.when??""}`;u.has(c.from)||u.set(c.from,new Map);let m=u.get(c.from);m.has(p)||m.set(p,new Set),m.get(p).add(c.to)}for(let[c,p]of u)for(let[m,g]of p)g.size>1&&m!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${c}' has multiple edges with identical trigger/guard (${m}) to different targets: ${[...g].join(", ")}`,where:{node:c},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function Xr(i,e,t){return i.edges.find(r=>r.from===e&&r.to===t)?.when}function Qr(i){return i?/(>=|>|attempts|max|count|limit)/i.test(i):!1}function Zr(i,e){let t=0,r=new Map,o=new Map,s=new Set,a=[],d=[],u=c=>{r.set(c,t),o.set(c,t),t++,a.push(c),s.add(c);for(let p of e.get(c)??[])r.has(p)?s.has(p)&&o.set(c,Math.min(o.get(c),r.get(p))):(u(p),o.set(c,Math.min(o.get(c),o.get(p))));if(o.get(c)===r.get(c)){let p=[],m;do m=a.pop(),s.delete(m),p.push(m);while(m!==c);d.push(p.reverse())}};for(let c of i)r.has(c)||u(c);return d}I();var eo=new Set(["pr-review","pr-fix"]);function no(i,e){return e.labels?.[i]??i}function In(i){return eo.has(i.type)||i.context==="pr-diff"||i.context==="pr-review"}function si(i,e,t){let r=(o,s)=>{i[o]??={},i[o].types??=[],i[o].types.includes(s)||i[o].types.push(s)};switch(e){case"issues.opened":return r("issues","opened");case"issues.labeled":return r("issues","labeled");case"issue_comment.created":return r("issue_comment","created");case"pull_request.opened":return r("pull_request","opened");case"pull_request.synchronize":return r("pull_request","synchronize");case"pull_request.labeled":return r("pull_request","labeled");case"pull_request.closed":return r("pull_request","closed");case"pull_request_review.submitted":return r("pull_request_review","submitted");case"push":if(In(t))return r("pull_request","synchronize");i.push??={};return;case"workflow_dispatch":i.workflow_dispatch??={};return;default:i[e]??={}}}function tn(i,e){return i==="push"&&In(e)?"pull_request.synchronize":i}function ci(i){let[e,t]=i.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function to(i,e,t){if(i.on){let o=i.on.split(",").map(a=>a.trim()).filter(Boolean),s=o.map(a=>tn(a,e));return{events:o,guard:i.when?Hn(i.when,s,t):void 0}}if(!i.when)return;let r=i.when;if(r.startsWith("label=")){let o=[In(e)?"pull_request.labeled":"issues.labeled"];return{events:o,guard:Hn(r,o,t)}}if(r.startsWith("verdict=")){let o=["pull_request_review.submitted"];return{events:o,guard:Hn(r,o,t)}}}function Hn(i,e,t){if(i.startsWith("label=")){let o=`github.event.label.name == '${no(i.slice(6),t)}'`,s=io(e);return s?`${o} && ${s}`:o}let r=i==="verdict=approve"?"APPROVE":i==="verdict=request_changes"?"REQUEST_CHANGES":void 0;if(r){let o=`contains(github.event.review.body, '**Verdict:** ${r}')`,s=ro(t);return s?`${o} && ${s}`:o}}function io(i){if(i.length&&i.every(e=>e.split(".")[0]==="issues"))return"github.event.issue.state == 'open'";if(i.length&&i.every(e=>e.split(".")[0]==="pull_request"))return"github.event.pull_request.state == 'open'"}function ro(i){let e=i.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function ai(i){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(i)}function oo(i){let e=i.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function li(i,e,t){let r=oo(t),o=[...e].filter(ai);if(!r||o.length===0)return i;let s=[...e].filter(d=>!ai(d)),a=s.length?`(${s.map(ci).join(" || ")} || ${r})`:r;return i?`(${i}) && ${a}`:a}function so(i){if(i.attrs.schedule!==void 0)return{group:i.id,"cancel-in-progress":!1};let t=In(i)||i.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${i.id}-${t}`,"cancel-in-progress":i.type==="issue-agent"}}function ui(i){let e={},t=new Map(i.nodes.map(s=>[s.id,s])),r=new Map;for(let s of i.nodes)r.set(s.id,[]);for(let s of i.edges)r.get(s.to)?.push(s);let o=qe(i);for(let s of i.nodes){if(s.type==="start"||s.type==="exit"||o.memberIds.has(s.id))continue;let a=o.byFanin.get(s.id);if(a){let $=a.entryEdge,S=t.get(a.legIds[0]),v={},P=($.on??"").split(",").map(K=>K.trim()).filter(Boolean);for(let K of P)si(v,K,S);let F={nodeId:s.id,triggers:v,dispatches:[]},L=new Set(P.map(K=>tn(K,S))),D=li($.when?Hn($.when,[...L],i.config):void 0,L,i.config);D&&(F.guard=D);let oe=P.some(K=>tn(K,S).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";F.concurrency={group:`${s.id}-${oe}`,"cancel-in-progress":!1},e[s.id]=F;continue}if(s.type==="parallel"||s.type==="fan_in")continue;let d={},u=new Set,c=new Set,p=new Set,m=[];if(s.attrs.schedule!==void 0)d.schedule=[{cron:String(s.attrs.schedule)}],d.workflow_dispatch={};else{for(let $ of r.get(s.id)??[]){let S=to($,s,i.config);if(S){for(let v of S.events)si(d,v,s);for(let v of S.events)p.add(tn(v,s));if(S.guard)u.add(S.guard);else for(let v of S.events)c.add(tn(v,s))}}if(u.size&&c.size)for(let $ of c)u.add(ci($))}for(let $ of i.edges)$.from===s.id&&$.do&&m.push({toNode:$.to,when:$.when});let g=li(u.size?[...u].join(" || "):void 0,p,i.config),k={nodeId:s.id,triggers:d,dispatches:m};g&&(k.guard=g),Object.keys(d).length&&(k.concurrency=so(s)),e[s.id]=k}return{perNode:e}}I();I();function ao(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ie={},Pn={},ve={},di;function rn(){if(di)return ve;di=1;function i(a){return typeof a>"u"||a===null}function e(a){return typeof a=="object"&&a!==null}function t(a){return Array.isArray(a)?a:i(a)?[]:[a]}function r(a,d){if(d){let u=Object.keys(d);for(let c=0,p=u.length;c<p;c+=1){let m=u[c];a[m]=d[m]}}return a}function o(a,d){let u="";for(let c=0;c<d;c+=1)u+=a;return u}function s(a){return a===0&&Number.NEGATIVE_INFINITY===1/a}return ve.isNothing=i,ve.isObject=e,ve.toArray=t,ve.repeat=o,ve.isNegativeZero=s,ve.extend=r,ve}var ct,pi;function on(){if(pi)return ct;pi=1;function i(t,r){let o="",s=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(o+='in "'+t.mark.name+'" '),o+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!r&&t.mark.snippet&&(o+=`
32
+ Closes #${Pe}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:o,steps:r}}function _o(i){let e=i.node,n=Un(i,{ref:xi,fetchDepth:0}),r=typeof e.attrs.max_attempts=="number"?e.attrs.max_attempts:3,o=`<!-- gp-foundry:attempt:${e.id} -->`,s=i.config.labels?.["needs-human"]??"needs-human",u=i.config.identity?.bot_login??"";n.push(re({id:"attempts",name:`Enforce attempt budget (max ${r})`,env:{GH_TOKEN:de(i),PR:Qe,MARKER:o,MAX:String(r),BOT_LOGIN:u},run:["# One request-changes verdict = one attempt. The jq filter reads the bot","# login from the environment (never interpolated into the script), and an","# empty BOT_LOGIN counts any reviewer's request-changes.","# (--paginate emits one count per page, so the counts are summed.)",`COUNT=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," [ .[]",' | select(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',' | select(.state == "CHANGES_REQUESTED" or ((.body // "") | test("Verdict.*REQUEST_CHANGES")))'," ] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}')",'[ -n "$COUNT" ] || COUNT=0','echo "attempts so far: $COUNT / $MAX"','if [ "$COUNT" -gt "$MAX" ]; then',` gh pr edit "$PR" --add-label "${s}" 2>/dev/null || gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/labels" -f 'labels[]=${s}'`,` gh pr comment "$PR" --body "$(printf '## \u26D4 Attempt budget (${e.id})\\n\\nExhausted (%s/%s requested-changes rounds) \u2014 labeling \`${s}\` and stopping. A human should take this over.\\n\\n%s' "$COUNT" "$MAX" "$MARKER")"`,' echo "exhausted=true" >> "$GITHUB_OUTPUT"',"else",` gh pr comment "$PR" --body "$(printf '%s attempt %s of %s' "$MARKER" "$COUNT" "$MAX")" >/dev/null`,' echo "exhausted=false" >> "$GITHUB_OUTPUT"',"fi"].join(`
33
+ `)}));let p="steps.attempts.outputs.exhausted != 'true'";return n.push({...ze(),if:p}),n.push({...un(i,"pr-review",Qe),if:p}),n.push({...Xe(i,{withContext:!0}),if:p,timeoutMinutes:qn(Oe(e,35))}),n.push(re({name:"Commit and push fixes",if:`${p} && !cancelled()`,env:{BRANCH:xi},run:["# Commit anything the agent left uncommitted...",'if [ -n "$(git status --porcelain)" ]; then'," git add -A",` git commit -m "agent fix: ${e.id}"`,"fi","# ...then push if HEAD is ahead of the remote (the agent may have committed itself).",'git fetch origin "$BRANCH" --quiet 2>/dev/null || true','if [ "$(git rev-parse HEAD)" != "$(git rev-parse "origin/$BRANCH" 2>/dev/null || echo none)" ]; then',' git push origin "HEAD:$BRANCH"',' echo "pushed fix to $BRANCH"',"else",' echo "no changes to push"',"fi"].join(`
34
+ `)})),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write"},timeoutMinutes:Oe(e,35),steps:n}}function Oi(i){return`gp-foundry/human-approval (${String(i.attrs.environment??"production")})`}var Ao="github-actions";function ko(i){return`${Oi(i)}@${Ao}`}function $o(i){let e=i.node,n=Un(i,{fetchDepth:0}),o=i.inEdges.map(s=>i.nodeById?.(s.from)).filter(s=>!!s&&s.type==="human-gate").map(ko);return n.push({uses:i.actionRef("merge-gate"),name:"Evaluate merge gate",with:{token:de(i),"checks-token":"${{ github.token }}","policy-path":Ee(i,e.files.policy),"base-branch":i.config.repo.base_branch,"branch-prefix":i.config.repo.branch_prefix,...i.config.identity?.bot_login?{"bot-login":i.config.identity.bot_login}:{},...o.length?{"required-checks":o.join(",")}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write",checks:"read"},timeoutMinutes:Oe(e,10),steps:n}}function Eo(i){let e=i.node,n=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:n,steps:[re({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME:Oi(e),HEAD_SHA:vt,ENVIRONMENT:n},run:['if ! gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$CHECK_NAME" \\',' -f head_sha="$HEAD_SHA" \\'," -f status=completed \\"," -f conclusion=success \\"," -f 'output[title]=Approved' \\",' -f "output[summary]=Environment \\"$ENVIRONMENT\\" was approved by a human for $HEAD_SHA."; then',' echo "::error::Approved for $ENVIRONMENT, but publishing the approval check failed."',' echo "::error::The merge gate requires \\"$CHECK_NAME\\" on $HEAD_SHA, so this PR will not merge until it is published."'," exit 1","fi",'echo "Approved for $ENVIRONMENT."'].join(`
35
+ `)})]}}function So(i){let e=i.node,n=i.config,r=Un(i,{fetchDepth:0}),o=typeof e.attrs.commit=="string"?e.attrs.commit:"direct",s=typeof e.attrs.paths=="string"?e.attrs.paths:"";return o==="pr"&&r.push(re({id:"branch",name:"Create branch",env:{PREFIX:n.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}"},run:['BRANCH="$PREFIX$NODE-$RUN_ID"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
36
+ `)})),r.push(ze()),r.push({...Xe(i,{withContext:!1}),id:"agent",timeoutMinutes:qn(Oe(e,20))}),o==="pr"?r.push({uses:i.actionRef("agent-fallback"),name:"Commit, push branch, open PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}","base-branch":n.repo.base_branch,token:de(i),"agent-name":e.id,"scope-path":Ee(i,"agents/scope.yaml"),"pr-title":`${e.id}: scheduled update`,"pr-body":`Scheduled output from the \`${e.id}\` lane \u2014 review and merge like any agent PR.`,...s?{"allowed-paths":s}:{}}}):o==="direct"&&(r.push({uses:i.actionRef("agent-fallback"),name:"Strip protected paths, commit, push",with:{branch:n.repo.base_branch,"base-branch":n.repo.base_branch,token:de(i),"agent-name":e.id,"scope-path":Ee(i,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...s?{"allowed-paths":s}:{}}}),r.push(re({id:"recovery",name:"Create recovery branch",if:"${{ !cancelled() && steps.agent.outcome == 'failure' }}",env:{PREFIX:n.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:['BRANCH="$PREFIX$NODE-recovery-$RUN_ID-$RUN_ATTEMPT"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
37
+ `)})),r.push({uses:i.actionRef("agent-fallback"),name:"Preserve failed agent output for review",if:"${{ !cancelled() && steps.agent.outcome == 'failure' && steps.recovery.outcome == 'success' }}",with:{branch:"${{ steps.recovery.outputs.branch }}","base-branch":n.repo.base_branch,token:de(i),"agent-name":e.id,"scope-path":Ee(i,"agents/scope.yaml"),"pr-title":`${e.id}: recover incomplete scheduled output`,"pr-body":`Partial output from a failed \`${e.id}\` run. Review for completeness before merging. Run: \${{ github.server_url }}/\${{ github.repository }}/actions/runs/\${{ github.run_id }}`,"pr-label":i.config.labels?.["needs-human"]??"needs-human",...s?{"allowed-paths":s}:{}}})),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:Oe(e,20),steps:r}}function Ti(i,e,n){let r=i.node,o=[],s=jn(i);s&&o.push(s),o.push(Ln(i,n?{ref:vt,fetchDepth:0}:void 0)),o.push(ze()),o.push(un(i,n?"pr-review":"issue",n?Qe:Pe)),r.files.role&&o.push(Xe(i,{withContext:!0}));let u=r.attrs.on_complete_label;if(typeof u=="string"&&u){let p=i.config.labels?.[u]??u;o.push(re({name:"Apply completion label",env:{GH_TOKEN:de(i),NUM:n?Qe:Pe},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${p}'`}))}return Ci(r,{jobId:r.id,name:r.id,needs:e,permissions:n?{contents:"read","pull-requests":"write",issues:"write"}:{contents:"read",issues:"write"},timeoutMinutes:Oe(r,15),steps:o})}var vo={analyst:Et,"issue-agent":Et,"pr-review":Et,producer:wo,"pr-fix":_o,"merge-gate":$o,"human-gate":Eo,"scheduled-agent":So,start:()=>null,exit:()=>null};function xt(i,e,n){let r=vo[i.type];if(!r)return null;let o=r(n);return o&&Ci(i,o)}P();var xo=new Set(Be);function Me(i){let e=new Map(i.nodes.map(u=>[u.id,u])),n=new Map,r=new Map;for(let u of i.nodes)n.set(u.id,[]),r.set(u.id,[]);for(let u of i.edges)n.get(u.to)?.push(u),r.get(u.from)?.push(u);let o=new Map,s=new Set;for(let u of i.nodes){if(u.type!=="fan_in")continue;let p=n.get(u.id)??[];if(p.length<2)continue;let a=[],l,d=!0;for(let C of p){let w=e.get(C.from);if(!w||!xo.has(w.type)){d=!1;break}let k=n.get(w.id)??[],H=r.get(w.id)??[];if(k.length!==1||H.length!==1||H[0].to!==u.id){d=!1;break}let N=e.get(k[0].from);if(!N||N.type!=="parallel"){d=!1;break}if(k[0].on||k[0].when){d=!1;break}if(l===void 0)l=N.id;else if(l!==N.id){d=!1;break}a.push(w.id)}if(!d||l===void 0)continue;let f=n.get(l)??[],m=r.get(l)??[];if(f.length!==1||!f[0].on)continue;let A=new Set(a);if(!(!m.every(C=>A.has(C.to))||m.length!==a.length)){o.set(u.id,{parallelId:l,entryEdge:f[0],legIds:a,faninId:u.id}),s.add(l);for(let C of a)s.add(C)}}return{byFanin:o,memberIds:s}}var dn=new Set(Be);function pn(i,e={}){let n=[],r=new Map(i.nodes.map(a=>[a.id,a])),o=Me(i).memberIds;for(let a of i.nodes)a.declared||n.push({level:"error",code:"node.undeclared",message:`node '${a.id}' is referenced in an edge but never declared`,where:{node:a.id,line:a.line},hint:`add a node statement, e.g. ${a.id} [type=...]`});let s=(a,l,d,f)=>{let m=Ai(a,l);n.push({level:"error",code:"attr.unknown",message:`unknown attribute '${a}=' on ${d} \u2014 it would be silently ignored`,where:f,hint:m?`did you mean '${m}='?`:"see reference/node-types.md for the attributes this version of gp-foundry understands"})};for(let a of i.nodes)for(let l of Object.keys(a.raw))gt.has(l)||s(l,gt,`node '${a.id}'`,{node:a.id,line:a.line});for(let a of i.edges)for(let l of Object.keys(a.raw))bt.has(l)||s(l,bt,`edge '${a.from} -> ${a.to}'`,{edge:[a.from,a.to],line:a.line});try{cn(i.config)}catch(a){n.push({level:"error",code:"config.bad-authors",message:a.message,hint:"repo.authors is a list of GitHub logins, e.g. authors: [dpup]"})}for(let a of i.nodes){if(a.attrs.authors!==void 0)if(!_t(a)||o.has(a.id))n.push({level:"error",code:"node.authors-unsupported",message:`authors= on '${a.id}' is not supported here \u2014 it binds a standalone pr-review / pr-fix node, or an analyst with context="pr-diff" or "pr-review"`,where:{node:a.id,line:a.line},hint:o.has(a.id)?"a diamond is bound by repo.authors in foundry.config.yaml":"to restrict every PR lane at once, set repo.authors in foundry.config.yaml"});else try{At(a,i.config)}catch(l){n.push({level:"error",code:"node.bad-authors",message:l.message,where:{node:a.id,line:a.line},hint:'comma-separated GitHub logins, e.g. authors="dpup, octocat"'})}if(dn.has(a.type)&&!a.files.role&&n.push({level:"error",code:"node.missing-role",message:`agent node '${a.id}' (type ${a.type}) needs a role="..." job description`,where:{node:a.id,line:a.line}}),a.attrs.permissions!==void 0){try{St(a)}catch(l){n.push({level:"error",code:"node.bad-permissions",message:l.message,where:{node:a.id,line:a.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(a.type==="start"||a.type==="exit"||a.type==="parallel")&&n.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${a.id}' (type ${a.type}) is ignored \u2014 this node emits no workflow job`,where:{node:a.id,line:a.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}if(a.attrs.agent_attempts!==void 0){let l=a.attrs.agent_attempts;(typeof l!="number"||!Number.isInteger(l)||l<1)&&n.push({level:"error",code:"node.bad-agent-attempts",message:`agent_attempts= on '${a.id}' must be a whole number >= 1, got ${JSON.stringify(l)}`,where:{node:a.id,line:a.line},hint:"1 disables retrying; omit the attr to use run-agent's default \u2014 e.g. agent_attempts=1"}),dn.has(a.type)||n.push({level:"warning",code:"node.agent-attempts-ignored",message:`agent_attempts= on '${a.id}' (type ${a.type}) is ignored \u2014 this node runs no agent`,where:{node:a.id,line:a.line},hint:"move agent_attempts= to the agent lane whose retry budget you meant to change"})}if(a.attrs.cancel_in_progress!==void 0&&(typeof a.attrs.cancel_in_progress!="boolean"&&n.push({level:"error",code:"node.bad-cancel-in-progress",message:`cancel_in_progress= on '${a.id}' must be true or false, got ${JSON.stringify(a.attrs.cancel_in_progress)}`,where:{node:a.id,line:a.line}}),!dn.has(a.type)||o.has(a.id)?n.push({level:"warning",code:"node.cancel-in-progress-ignored",message:`cancel_in_progress= on '${a.id}' is ignored \u2014 it applies to an agent node that owns its own workflow`,where:{node:a.id,line:a.line},hint:"set it on a standalone agent lane (analyst, issue-agent, producer, pr-review, pr-fix, scheduled-agent)"}):a.attrs.cancel_in_progress===!0&&(a.type==="producer"||a.type==="pr-fix"||a.type==="scheduled-agent"&&a.attrs.commit!=="none")&&n.push({level:"warning",code:"node.cancel-in-progress-discards-work",message:`cancel_in_progress=true on '${a.id}' (type ${a.type}): a cancelled run skips the commit/push salvage, so whatever the agent had written but not yet pushed is lost`,where:{node:a.id,line:a.line},hint:"keep it for lanes where the newer event supersedes the older run's work; otherwise leave the default (queue)"})),a.attrs.checkout!==void 0&&(a.attrs.checkout!=="partial"?n.push({level:"error",code:"node.bad-checkout",message:`checkout= on '${a.id}' must be "partial", got ${JSON.stringify(a.attrs.checkout)}`,where:{node:a.id,line:a.line},hint:`checkout="partial" is a blob-less clone with full history; omit the attr for the lane's default checkout`}):(a.type==="start"||a.type==="exit"||a.type==="parallel"||a.type==="human-gate")&&n.push({level:"warning",code:"node.checkout-ignored",message:`checkout= on '${a.id}' (type ${a.type}) is ignored \u2014 this node checks nothing out`,where:{node:a.id,line:a.line}})),a.attrs.gates!==void 0)try{yt(a)}catch(l){n.push({level:"error",code:"node.bad-gates",message:l.message,where:{node:a.id,line:a.line},hint:'comma-separated workflow files or check-run names, each with an optional ?<seconds> grace \u2014 e.g. gates="ci.yml, e2e (chromium)?90"'})}if(a.attrs.skip!==void 0){let l=[];try{l=wt(a)}catch(f){n.push({level:"error",code:"node.bad-skip",message:f.message,where:{node:a.id,line:a.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}(a.type==="pr-review"||a.type==="analyst")&&We(a)&&a.attrs.schedule===void 0&&!o.has(a.id)||n.push({level:"error",code:"node.skip-unsupported",message:`skip= on '${a.id}' is not supported here \u2014 it needs a standalone, event-driven pr-review/analyst node with context="pr-diff" or "pr-review"`,where:{node:a.id,line:a.line},hint:a.attrs.select!==void 0||a.attrs.schedule!==void 0?'a scheduled (select="sweep") lane picks its own PRs; skip= guards a lane that reacts to PR events':o.has(a.id)?"a diamond leg has no guard job of its own; put the review lane outside the diamond":'set context="pr-diff" on the node \u2014 skip= reads the pull request the event is about'}),l.some(f=>f.kind==="unchanged-diff")&&!i.config.identity?.bot_login&&n.push({level:"error",code:"node.skip-needs-bot-login",message:`skip="unchanged-diff" on '${a.id}' compares against the bot's last review, but identity.bot_login is unset`,where:{node:a.id,line:a.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"})}a.attrs.select!==void 0&&(a.attrs.select!=="sweep"?n.push({level:"error",code:"node.bad-select",message:`select= on '${a.id}' must be "sweep", got ${JSON.stringify(a.attrs.select)}`,where:{node:a.id,line:a.line}}):a.type!=="pr-review"||!We(a)||o.has(a.id)?n.push({level:"error",code:"node.select-unsupported",message:`select="sweep" on '${a.id}' needs a standalone pr-review node with context="pr-diff" or "pr-review"`,where:{node:a.id,line:a.line}}):a.attrs.schedule===void 0?n.push({level:"error",code:"node.sweep-no-schedule",message:`select="sweep" on '${a.id}' needs schedule="<cron>" \u2014 a sweep is driven by its schedule, not by PR events`,where:{node:a.id,line:a.line},hint:'e.g. schedule="*/15 * * * *"'}):i.config.identity?.bot_login||n.push({level:"warning",code:"node.sweep-no-bot-login",message:`select="sweep" on '${a.id}': identity.bot_login is unset, so ANY review carrying a '**Verdict:**' marker counts as the decision \u2014 a user can pre-empt the lane by posting one`,where:{node:a.id,line:a.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the verdict"})),a.type==="human-gate"&&a.attrs.environment===void 0&&n.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${a.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:a.id,line:a.line}}),a.type==="merge-gate"&&!a.files.policy&&n.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${a.id}' has no policy="..."; default merge policy will be used`,where:{node:a.id,line:a.line}})}if(e.fileExists)for(let a of i.nodes)for(let l of["role","policy","prompt","tools"]){let d=a.files[l];d&&!e.fileExists(d)&&n.push({level:"error",code:"file.missing",message:`node '${a.id}' references ${l}="${d}" which does not exist`,where:{node:a.id,line:a.line,file:d}})}if(e.roles){let a=new Map;for(let d of i.nodes)a.set(d.id,[]);for(let d of i.edges){let f=r.get(d.to);f&&a.get(d.from)?.push({node:f,edge:d})}let l=d=>(e.roles?.get(d.id)?.role??d.id).toLowerCase();for(let d of i.nodes){let f=e.roles.get(d.id);if(!f?.handoffs)continue;let m=a.get(d.id)??[],A=new Set(m.flatMap(w=>[w.node.id.toLowerCase(),l(w.node)])),C=new Set(f.handoffs.map(w=>String(w.to).toLowerCase()));for(let w of f.handoffs)A.has(String(w.to).toLowerCase())||n.push({level:"warning",code:"role.handoff-no-edge",message:`role '${f.role}' (node '${d.id}') declares a handoff to '${w.to}' but there is no matching out-edge`,where:{node:d.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:w,edge:k}of m)w.type==="exit"&&!k.when||!C.has(w.id.toLowerCase())&&!C.has(l(w))&&n.push({level:"warning",code:"role.edge-no-handoff",message:`node '${d.id}' has an out-edge to '${w.id}' not declared as a handoff in role '${f.role}'`,where:{node:d.id,edge:[d.id,w.id]},hint:"document the handoff in the role, or remove the edge"})}}let u=(a,l)=>{if(typeof a=="string"){let d=a.match(/<[A-Za-z][^<>]{0,80}>/);d&&n.push({level:"error",code:"config.placeholder",message:`config value ${l} still contains the placeholder ${d[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(a))a.forEach((d,f)=>u(d,`${l}[${f}]`));else if(a&&typeof a=="object")for(let[d,f]of Object.entries(a))u(f,l?`${l}.${d}`:d)};if(u(i.config,""),e.fileExists&&(i.config.runtime?.mode??"pinned")==="vendored"){let a=new Set,l=!1;for(let d of i.nodes)dn.has(d.type)&&(l=!0,a.add("run-agent")),dn.has(d.type)&&d.type!=="scheduled-agent"&&a.add("agent-context"),(d.type==="producer"||d.type==="scheduled-agent")&&a.add("agent-fallback"),d.type==="merge-gate"&&a.add("merge-gate"),d.type==="pr-review"&&d.attrs.gates!==void 0&&a.add("wait-for-checks");for(let d of a)e.fileExists(`actions/${d}/action.yml`)||n.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${d}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});l&&!e.fileExists("agent-setup/action.yml")&&n.push({level:"warning",code:"runtime.agent-setup-missing",message:"generated agent jobs use ./.github/agent-setup, which does not exist",hint:"run `gp-foundry vendor` (or `gp-foundry init`) to scaffold the agent-setup shim"})}{let{byFanin:a,memberIds:l}=Me(i);for(let d of i.nodes)if(d.type==="parallel"&&!l.has(d.id)&&n.push({level:"error",code:"diamond.malformed",message:`parallel '${d.id}' is not part of a clean diamond (need: exactly one in-edge carrying on=, \u22652 bare out-edges to agent legs that each flow into one fan_in)`,where:{node:d.id,line:d.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),d.type==="fan_in"){let f=a.get(d.id);if(!f)n.push({level:"error",code:"diamond.malformed",message:`fan_in '${d.id}' is not the join of a clean diamond (need \u22652 legs, each with exactly one in-edge from a shared parallel and one out-edge into this fan_in)`,where:{node:d.id,line:d.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!d.files.role&&d.attrs.on_complete_label===void 0&&n.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${d.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:d.id,line:d.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let m=f.legIds.filter(A=>r.get(A)?.type==="pr-review");m.length&&n.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${d.id}' lanes [${m.join(", ")}] are pr-review typed \u2014 if a lane role posts a '**Verdict:**' review, the merge gate acts on ONE lane's opinion and the join is bypassed`,where:{node:d.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(ln(i.config).mode==="github-token"){let a=i.edges.filter(l=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(l.on??"")||/^(label=|verdict=)/.test(l.when??""));a.length&&n.push({level:i.config.auth?.mode==="github-token"?"error":"warning",code:"auth.github-token-no-cascade",message:`auth mode 'github-token': commits/PRs made with GITHUB_TOKEN do not trigger other workflows, so ${a.length} event-cascade edge(s) (pull_request.opened/synchronize/push) will not fire and the harness will stall`,hint:"use auth.mode 'app' or 'pat' (a fine-grained PAT secret), or drive those stages via explicit dispatch"})}return!i.config.identity?.bot_login&&i.edges.some(a=>/^verdict=/.test(a.when??""))&&n.push({level:"warning",code:"auth.no-bot-login",message:"identity.bot_login is unset, so verdict-triggered workflows (fixer, human-gate) guard only on the verdict marker \u2014 any user who can review the PR can fire them",hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"}),i.nodes.some(a=>a.type==="start"||a.attrs.schedule!==void 0||a.type==="merge-gate")||n.push({level:"warning",code:"graph.no-entry",message:"harness has no entry node (a start node or a scheduled node) \u2014 nothing will trigger it"}),n}P();var Co=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),Ri=new Set(["start"]);function fn(i){let e=[],n=new Set(i.nodes.map(l=>l.id)),r=new Map(i.nodes.map(l=>[l.id,l])),o=new Map;for(let l of n)o.set(l,[]);for(let l of i.edges)n.has(l.from)&&n.has(l.to)&&o.get(l.from).push(l.to);let s=i.nodes.filter(l=>Ri.has(l.type)||l.attrs.schedule!==void 0||l.type==="merge-gate"),u=new Set,p=s.map(l=>l.id);for(;p.length;){let l=p.pop();if(!u.has(l)){u.add(l);for(let d of o.get(l)??[])p.push(d)}}for(let l of i.nodes)!u.has(l.id)&&!Ri.has(l.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${l.id}' is unreachable from any entry (start/scheduled) node`,where:{node:l.id,line:l.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let l of i.nodes)(o.get(l.id)??[]).length===0&&!Co.has(l.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${l.id}' (type ${l.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:l.id,line:l.line},hint:"route it to a next node, or make it an exit"});for(let l of Ro(n,o)){if(!(l.length>1||(o.get(l[0])??[]).includes(l[0])))continue;let f=new Set(l),m=[];for(let A of l)for(let C of o.get(A)??[])f.has(C)||m.push({from:A,to:C});m.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${l.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:l[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):m.some(A=>To(Oo(i,A.from,A.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${l.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:l[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let a=new Map;for(let l of i.edges){let d=`${l.on??""}|${l.when??""}`;a.has(l.from)||a.set(l.from,new Map);let f=a.get(l.from);f.has(d)||f.set(d,new Set),f.get(d).add(l.to)}for(let[l,d]of a)for(let[f,m]of d)m.size>1&&f!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${l}' has multiple edges with identical trigger/guard (${f}) to different targets: ${[...m].join(", ")}`,where:{node:l},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function Oo(i,e,n){return i.edges.find(r=>r.from===e&&r.to===n)?.when}function To(i){return i?/(>=|>|attempts|max|count|limit)/i.test(i):!1}function Ro(i,e){let n=0,r=new Map,o=new Map,s=new Set,u=[],p=[],a=l=>{r.set(l,n),o.set(l,n),n++,u.push(l),s.add(l);for(let d of e.get(l)??[])r.has(d)?s.has(d)&&o.set(l,Math.min(o.get(l),r.get(d))):(a(d),o.set(l,Math.min(o.get(l),o.get(d))));if(o.get(l)===r.get(l)){let d=[],f;do f=u.pop(),s.delete(f),d.push(f);while(f!==l);p.push(d.reverse())}};for(let l of i)r.has(l)||a(l);return p}P();var No=new Set(Be),Ho=new Set(["pr-review","pr-fix"]);function Io(i,e){return e.labels?.[i]??i}function Gn(i){return Ho.has(i.type)||i.context==="pr-diff"||i.context==="pr-review"}function Ct(i,e,n){let r=(o,s)=>{i[o]??={},i[o].types??=[],i[o].types.includes(s)||i[o].types.push(s)};switch(e){case"issues.opened":return r("issues","opened");case"issues.labeled":return r("issues","labeled");case"issue_comment.created":return r("issue_comment","created");case"pull_request.opened":return r("pull_request","opened");case"pull_request.synchronize":return r("pull_request","synchronize");case"pull_request.labeled":return r("pull_request","labeled");case"pull_request.closed":return r("pull_request","closed");case"pull_request.ready_for_review":return r("pull_request","ready_for_review");case"pull_request_review.submitted":return r("pull_request_review","submitted");case"push":if(Gn(n))return r("pull_request","synchronize");i.push??={};return;case"workflow_dispatch":i.workflow_dispatch??={};return;default:i[e]??={}}}function hn(i,e){return i==="push"&&Gn(e)?"pull_request.synchronize":i}function Mi(i){let[e,n]=i.split(".");return n?`(github.event_name == '${e}' && github.event.action == '${n}')`:`github.event_name == '${e}'`}function Po(i,e,n){if(i.on){let o=i.on.split(",").map(u=>u.trim()).filter(Boolean),s=o.map(u=>hn(u,e));return{events:o,guard:i.when?Bn(i.when,s,n):void 0}}if(!i.when)return;let r=i.when;if(r.startsWith("label=")){let o=[Gn(e)?"pull_request.labeled":"issues.labeled"];return{events:o,guard:Bn(r,o,n)}}if(r.startsWith("verdict=")){let o=["pull_request_review.submitted"];return{events:o,guard:Bn(r,o,n)}}}function Bn(i,e,n){if(i.startsWith("label=")){let o=`github.event.label.name == '${Io(i.slice(6),n)}'`,s=Mo(e);return s?`${o} && ${s}`:o}let r=i==="verdict=approve"?"APPROVE":i==="verdict=request_changes"?"REQUEST_CHANGES":void 0;if(r){let o=`contains(github.event.review.body, '**Verdict:** ${r}')`,s=Fo(n);return s?`${o} && ${s}`:o}}function Mo(i){if(i.length&&i.every(e=>e.split(".")[0]==="issues"))return"github.event.issue.state == 'open'";if(i.length&&i.every(e=>e.split(".")[0]==="pull_request"))return"github.event.pull_request.state == 'open'"}function Fo(i){let e=i.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function Ni(i){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(i)}function Do(i){let e=i.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function Hi(i,e,n){return Fi(i,e,Do(n))}function Ii(i,e,n){return Fi(i,e,n?Ei(n):void 0)}function Fi(i,e,n){let r=[...e].filter(Ni);if(!n||r.length===0)return i;let o=[...e].filter(u=>!Ni(u)),s=o.length?`(${o.map(Mi).join(" || ")} || ${n})`:n;return i?`(${i}) && ${s}`:s}function Pi(i,e){let n=i.attrs.cancel_in_progress;return typeof n=="boolean"&&No.has(i.type)?n:e}function jo(i){if(i.attrs.schedule!==void 0)return{group:i.id,"cancel-in-progress":Pi(i,!1)};let n=Gn(i)||i.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${i.id}-${n}`,"cancel-in-progress":Pi(i,i.type==="issue-agent")}}function Di(i){let e={},n=new Map(i.nodes.map(s=>[s.id,s])),r=new Map;for(let s of i.nodes)r.set(s.id,[]);for(let s of i.edges)r.get(s.to)?.push(s);let o=Me(i);for(let s of i.nodes){if(s.type==="start"||s.type==="exit"||o.memberIds.has(s.id))continue;let u=o.byFanin.get(s.id);if(u){let C=u.entryEdge,w=n.get(u.legIds[0]),k={},H=(C.on??"").split(",").map(ee=>ee.trim()).filter(Boolean);for(let ee of H)Ct(k,ee,w);let N={nodeId:s.id,triggers:k,dispatches:[]},M=new Set(H.map(ee=>hn(ee,w))),L;try{L=cn(i.config)}catch{L=[kt]}let z=Ii(Hi(C.when?Bn(C.when,[...M],i.config):void 0,M,i.config),M,L);z&&(N.guard=z);let le=H.some(ee=>hn(ee,w).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";N.concurrency={group:`${s.id}-${le}`,"cancel-in-progress":!1},e[s.id]=N;continue}if(s.type==="parallel"||s.type==="fan_in")continue;let p={},a=new Set,l=new Set,d=new Set,f=[];if(s.attrs.schedule!==void 0)p.schedule=[{cron:String(s.attrs.schedule)}],p.workflow_dispatch={};else{for(let C of r.get(s.id)??[]){let w=Po(C,s,i.config);if(w){for(let k of w.events)Ct(p,k,s);for(let k of w.events)d.add(hn(k,s));if(w.guard)a.add(w.guard);else for(let k of w.events)l.add(hn(k,s))}}if(p.pull_request&&Ye(s,i.config)&&Ie(s).some(C=>C.kind==="draft")&&(Ct(p,"pull_request.ready_for_review",s),d.add("pull_request.ready_for_review"),l.add("pull_request.ready_for_review")),a.size&&l.size)for(let C of l)a.add(Mi(C))}for(let C of i.edges)C.from===s.id&&C.do&&f.push({toNode:C.to,when:C.when});let m=Ii(Hi(a.size?[...a].join(" || "):void 0,d,i.config),d,Ge(s,i.config)),A={nodeId:s.id,triggers:p,dispatches:f};m&&(A.guard=m),Object.keys(p).length&&(A.concurrency=jo(s)),e[s.id]=A}return{perNode:e}}P();P();function Lo(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var te={},Wn={},Te={},ji;function mn(){if(ji)return Te;ji=1;function i(u){return typeof u>"u"||u===null}function e(u){return typeof u=="object"&&u!==null}function n(u){return Array.isArray(u)?u:i(u)?[]:[u]}function r(u,p){if(p){let a=Object.keys(p);for(let l=0,d=a.length;l<d;l+=1){let f=a[l];u[f]=p[f]}}return u}function o(u,p){let a="";for(let l=0;l<p;l+=1)a+=u;return a}function s(u){return u===0&&Number.NEGATIVE_INFINITY===1/u}return Te.isNothing=i,Te.isObject=e,Te.toArray=n,Te.repeat=o,Te.isNegativeZero=s,Te.extend=r,Te}var Ot,Li;function gn(){if(Li)return Ot;Li=1;function i(n,r){let o="",s=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(o+='in "'+n.mark.name+'" '),o+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!r&&n.mark.snippet&&(o+=`
37
38
 
38
- `+t.mark.snippet),s+" "+o):s}function e(t,r){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=r,this.message=i(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+i(this,r)},ct=e,ct}var ut,fi;function lo(){if(fi)return ut;fi=1;let i=rn();function e(o,s,a,d,u){let c="",p="",m=Math.floor(u/2)-1;return d-s>m&&(c=" ... ",s=d-m+c.length),a-d>m&&(p=" ...",a=d+m-p.length),{str:c+o.slice(s,a).replace(/\t/g,"\u2192")+p,pos:d-s+c.length}}function t(o,s){return i.repeat(" ",s-o.length)+o}function r(o,s){if(s=Object.create(s||null),!o.buffer)return null;s.maxLength||(s.maxLength=79),typeof s.indent!="number"&&(s.indent=1),typeof s.linesBefore!="number"&&(s.linesBefore=3),typeof s.linesAfter!="number"&&(s.linesAfter=2);let a=/\r?\n|\r|\0/g,d=[0],u=[],c,p=-1;for(;c=a.exec(o.buffer);)u.push(c.index),d.push(c.index+c[0].length),o.position<=c.index&&p<0&&(p=d.length-2);p<0&&(p=d.length-1);let m="",g=Math.min(o.line+s.linesAfter,u.length).toString().length,k=s.maxLength-(s.indent+g+3);for(let S=1;S<=s.linesBefore&&!(p-S<0);S++){let v=e(o.buffer,d[p-S],u[p-S],o.position-(d[p]-d[p-S]),k);m=i.repeat(" ",s.indent)+t((o.line-S+1).toString(),g)+" | "+v.str+`
39
- `+m}let $=e(o.buffer,d[p],u[p],o.position,k);m+=i.repeat(" ",s.indent)+t((o.line+1).toString(),g)+" | "+$.str+`
40
- `,m+=i.repeat("-",s.indent+g+3+$.pos)+`^
41
- `;for(let S=1;S<=s.linesAfter&&!(p+S>=u.length);S++){let v=e(o.buffer,d[p+S],u[p+S],o.position-(d[p]-d[p+S]),k);m+=i.repeat(" ",s.indent)+t((o.line+S+1).toString(),g)+" | "+v.str+`
42
- `}return m.replace(/\n$/,"")}return ut=r,ut}var dt,hi;function re(){if(hi)return dt;hi=1;let i=on(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],t=["scalar","sequence","mapping"];function r(s){let a={};return s!==null&&Object.keys(s).forEach(function(d){s[d].forEach(function(u){a[String(u)]=d})}),a}function o(s,a){if(a=a||{},Object.keys(a).forEach(function(d){if(e.indexOf(d)===-1)throw new i('Unknown option "'+d+'" is met in definition of "'+s+'" YAML type.')}),this.options=a,this.tag=s,this.kind=a.kind||null,this.resolve=a.resolve||function(){return!0},this.construct=a.construct||function(d){return d},this.instanceOf=a.instanceOf||null,this.predicate=a.predicate||null,this.represent=a.represent||null,this.representName=a.representName||null,this.defaultStyle=a.defaultStyle||null,this.multi=a.multi||!1,this.styleAliases=r(a.styleAliases||null),t.indexOf(this.kind)===-1)throw new i('Unknown kind "'+this.kind+'" is specified for "'+s+'" YAML type.')}return dt=o,dt}var pt,mi;function Mi(){if(mi)return pt;mi=1;let i=on(),e=re();function t(s,a){let d=[];return s[a].forEach(function(u){let c=d.length;d.forEach(function(p,m){p.tag===u.tag&&p.kind===u.kind&&p.multi===u.multi&&(c=m)}),d[c]=u}),d}function r(){let s={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function a(d){d.multi?(s.multi[d.kind].push(d),s.multi.fallback.push(d)):s[d.kind][d.tag]=s.fallback[d.tag]=d}for(let d=0,u=arguments.length;d<u;d+=1)arguments[d].forEach(a);return s}function o(s){return this.extend(s)}return o.prototype.extend=function(a){let d=[],u=[];if(a instanceof e)u.push(a);else if(Array.isArray(a))u=u.concat(a);else if(a&&(Array.isArray(a.implicit)||Array.isArray(a.explicit)))a.implicit&&(d=d.concat(a.implicit)),a.explicit&&(u=u.concat(a.explicit));else throw new i("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");d.forEach(function(p){if(!(p instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(p.loadKind&&p.loadKind!=="scalar")throw new i("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(p.multi)throw new i("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),u.forEach(function(p){if(!(p instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let c=Object.create(o.prototype);return c.implicit=(this.implicit||[]).concat(d),c.explicit=(this.explicit||[]).concat(u),c.compiledImplicit=t(c,"implicit"),c.compiledExplicit=t(c,"explicit"),c.compiledTypeMap=r(c.compiledImplicit,c.compiledExplicit),c},pt=o,pt}var ft,gi;function Fi(){if(gi)return ft;gi=1;let i=re();return ft=new i("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),ft}var ht,bi;function ji(){if(bi)return ht;bi=1;let i=re();return ht=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),ht}var mt,yi;function Li(){if(yi)return mt;yi=1;let i=re();return mt=new i("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),mt}var gt,wi;function Di(){if(wi)return gt;wi=1;let i=Mi();return gt=new i({explicit:[Fi(),ji(),Li()]}),gt}var bt,_i;function qi(){if(_i)return bt;_i=1;let i=re();function e(o){if(o===null)return!0;let s=o.length;return s===1&&o==="~"||s===4&&(o==="null"||o==="Null"||o==="NULL")}function t(){return null}function r(o){return o===null}return bt=new i("tag:yaml.org,2002:null",{kind:"scalar",resolve:e,construct:t,predicate:r,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),bt}var yt,Ai;function Bi(){if(Ai)return yt;Ai=1;let i=re();function e(o){if(o===null)return!1;let s=o.length;return s===4&&(o==="true"||o==="True"||o==="TRUE")||s===5&&(o==="false"||o==="False"||o==="FALSE")}function t(o){return o==="true"||o==="True"||o==="TRUE"}function r(o){return Object.prototype.toString.call(o)==="[object Boolean]"}return yt=new i("tag:yaml.org,2002:bool",{kind:"scalar",resolve:e,construct:t,predicate:r,represent:{lowercase:function(o){return o?"true":"false"},uppercase:function(o){return o?"TRUE":"FALSE"},camelcase:function(o){return o?"True":"False"}},defaultStyle:"lowercase"}),yt}var wt,ki;function Ui(){if(ki)return wt;ki=1;let i=rn(),e=re();function t(c){return c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102}function r(c){return c>=48&&c<=55}function o(c){return c>=48&&c<=57}function s(c){if(c===null)return!1;let p=c.length,m=0,g=!1;if(!p)return!1;let k=c[m];if((k==="-"||k==="+")&&(k=c[++m]),k==="0"){if(m+1===p)return!0;if(k=c[++m],k==="b"){for(m++;m<p;m++){if(k=c[m],k!=="0"&&k!=="1")return!1;g=!0}return g&&isFinite(a(c))}if(k==="x"){for(m++;m<p;m++){if(!t(c.charCodeAt(m)))return!1;g=!0}return g&&isFinite(a(c))}if(k==="o"){for(m++;m<p;m++){if(!r(c.charCodeAt(m)))return!1;g=!0}return g&&isFinite(a(c))}}for(;m<p;m++){if(!o(c.charCodeAt(m)))return!1;g=!0}return g?isFinite(a(c)):!1}function a(c){let p=c,m=1,g=p[0];if((g==="-"||g==="+")&&(g==="-"&&(m=-1),p=p.slice(1),g=p[0]),p==="0")return 0;if(g==="0"){if(p[1]==="b")return m*parseInt(p.slice(2),2);if(p[1]==="x")return m*parseInt(p.slice(2),16);if(p[1]==="o")return m*parseInt(p.slice(2),8)}return m*parseInt(p,10)}function d(c){return a(c)}function u(c){return Object.prototype.toString.call(c)==="[object Number]"&&c%1===0&&!i.isNegativeZero(c)}return wt=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:s,construct:d,predicate:u,represent:{binary:function(c){return c>=0?"0b"+c.toString(2):"-0b"+c.toString(2).slice(1)},octal:function(c){return c>=0?"0o"+c.toString(8):"-0o"+c.toString(8).slice(1)},decimal:function(c){return c.toString(10)},hexadecimal:function(c){return c>=0?"0x"+c.toString(16).toUpperCase():"-0x"+c.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),wt}var _t,xi;function Vi(){if(xi)return _t;xi=1;let i=rn(),e=re(),t=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function o(c){return c===null||!t.test(c)?!1:isFinite(parseFloat(c,10))?!0:r.test(c)}function s(c){let p=c.toLowerCase(),m=p[0]==="-"?-1:1;return"+-".indexOf(p[0])>=0&&(p=p.slice(1)),p===".inf"?m===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:p===".nan"?NaN:m*parseFloat(p,10)}let a=/^[-+]?[0-9]+e/;function d(c,p){if(isNaN(c))switch(p){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===c)switch(p){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===c)switch(p){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(c))return"-0.0";let m=c.toString(10);return a.test(m)?m.replace("e",".e"):m}function u(c){return Object.prototype.toString.call(c)==="[object Number]"&&(c%1!==0||i.isNegativeZero(c))}return _t=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:o,construct:s,predicate:u,represent:d,defaultStyle:"lowercase"}),_t}var At,Ci;function Gi(){return Ci||(Ci=1,At=Di().extend({implicit:[qi(),Bi(),Ui(),Vi()]})),At}var kt,Ei;function Wi(){return Ei||(Ei=1,kt=Gi()),kt}var xt,Si;function Yi(){if(Si)return xt;Si=1;let i=re(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(a){return a===null?!1:e.exec(a)!==null||t.exec(a)!==null}function o(a){let d=0,u=null,c=e.exec(a);if(c===null&&(c=t.exec(a)),c===null)throw new Error("Date resolve error");let p=+c[1],m=+c[2]-1,g=+c[3];if(!c[4])return new Date(Date.UTC(p,m,g));let k=+c[4],$=+c[5],S=+c[6];if(c[7]){for(d=c[7].slice(0,3);d.length<3;)d+="0";d=+d}if(c[9]){let P=+c[10],F=+(c[11]||0);u=(P*60+F)*6e4,c[9]==="-"&&(u=-u)}let v=new Date(Date.UTC(p,m,g,k,$,S,d));return u&&v.setTime(v.getTime()-u),v}function s(a){return a.toISOString()}return xt=new i("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:o,instanceOf:Date,represent:s}),xt}var Ct,vi;function Ki(){if(vi)return Ct;vi=1;let i=re();function e(t){return t==="<<"||t===null}return Ct=new i("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Ct}var Et,Oi;function Ji(){if(Oi)return Et;Oi=1;let i=re(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
43
- \r`;function t(a){if(a===null)return!1;let d=0,u=a.length,c=e;for(let p=0;p<u;p++){let m=c.indexOf(a.charAt(p));if(!(m>64)){if(m<0)return!1;d+=6}}return d%8===0}function r(a){let d=a.replace(/[\r\n=]/g,""),u=d.length,c=e,p=0,m=[];for(let k=0;k<u;k++)k%4===0&&k&&(m.push(p>>16&255),m.push(p>>8&255),m.push(p&255)),p=p<<6|c.indexOf(d.charAt(k));let g=u%4*6;return g===0?(m.push(p>>16&255),m.push(p>>8&255),m.push(p&255)):g===18?(m.push(p>>10&255),m.push(p>>2&255)):g===12&&m.push(p>>4&255),new Uint8Array(m)}function o(a){let d="",u=0,c=a.length,p=e;for(let g=0;g<c;g++)g%3===0&&g&&(d+=p[u>>18&63],d+=p[u>>12&63],d+=p[u>>6&63],d+=p[u&63]),u=(u<<8)+a[g];let m=c%3;return m===0?(d+=p[u>>18&63],d+=p[u>>12&63],d+=p[u>>6&63],d+=p[u&63]):m===2?(d+=p[u>>10&63],d+=p[u>>4&63],d+=p[u<<2&63],d+=p[64]):m===1&&(d+=p[u>>2&63],d+=p[u<<4&63],d+=p[64],d+=p[64]),d}function s(a){return Object.prototype.toString.call(a)==="[object Uint8Array]"}return Et=new i("tag:yaml.org,2002:binary",{kind:"scalar",resolve:t,construct:r,predicate:s,represent:o}),Et}var St,$i;function zi(){if($i)return St;$i=1;let i=re(),e=Object.prototype.hasOwnProperty,t=Object.prototype.toString;function r(s){if(s===null)return!0;let a=[],d=s;for(let u=0,c=d.length;u<c;u+=1){let p=d[u],m=!1;if(t.call(p)!=="[object Object]")return!1;let g;for(g in p)if(e.call(p,g))if(!m)m=!0;else return!1;if(!m)return!1;if(a.indexOf(g)===-1)a.push(g);else return!1}return!0}function o(s){return s!==null?s:[]}return St=new i("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:o}),St}var vt,Ti;function Xi(){if(Ti)return vt;Ti=1;let i=re(),e=Object.prototype.toString;function t(o){if(o===null)return!0;let s=o,a=new Array(s.length);for(let d=0,u=s.length;d<u;d+=1){let c=s[d];if(e.call(c)!=="[object Object]")return!1;let p=Object.keys(c);if(p.length!==1)return!1;a[d]=[p[0],c[p[0]]]}return!0}function r(o){if(o===null)return[];let s=o,a=new Array(s.length);for(let d=0,u=s.length;d<u;d+=1){let c=s[d],p=Object.keys(c);a[d]=[p[0],c[p[0]]]}return a}return vt=new i("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:t,construct:r}),vt}var Ot,Ni;function Qi(){if(Ni)return Ot;Ni=1;let i=re(),e=Object.prototype.hasOwnProperty;function t(o){if(o===null)return!0;let s=o;for(let a in s)if(e.call(s,a)&&s[a]!==null)return!1;return!0}function r(o){return o!==null?o:{}}return Ot=new i("tag:yaml.org,2002:set",{kind:"mapping",resolve:t,construct:r}),Ot}var $t,Ri;function Nt(){return Ri||(Ri=1,$t=Wi().extend({implicit:[Yi(),Ki()],explicit:[Ji(),zi(),Xi(),Qi()]})),$t}var Hi;function co(){if(Hi)return Pn;Hi=1;let i=rn(),e=on(),t=lo(),r=Nt(),o=Object.prototype.hasOwnProperty,s=1,a=2,d=3,u=4,c=1,p=2,m=3,g=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,k=/[\x85\u2028\u2029]/,$=/[,\[\]{}]/,S=/^(?:!|!!|![0-9A-Za-z-]+!)$/,v=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function P(n){return Object.prototype.toString.call(n)}function F(n){return n===10||n===13}function L(n){return n===9||n===32}function D(n){return n===9||n===32||n===10||n===13}function Z(n){return n===44||n===91||n===93||n===123||n===125}function oe(n){if(n>=48&&n<=57)return n-48;let f=n|32;return f>=97&&f<=102?f-97+10:-1}function K(n){return n===120?2:n===117?4:n===85?8:0}function xe(n){return n>=48&&n<=57?n-48:-1}function Te(n){switch(n){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
44
- `;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function j(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}function se(n,f,y){f==="__proto__"?Object.defineProperty(n,f,{configurable:!0,enumerable:!0,writable:!0,value:y}):n[f]=y}let Ne=new Array(256),te=new Array(256);for(let n=0;n<256;n++)Ne[n]=Te(n)?1:0,te[n]=Te(n);function ee(n,f){this.input=n,this.filename=f.filename||null,this.schema=f.schema||r,this.onWarning=f.onWarning||null,this.legacy=f.legacy||!1,this.json=f.json||!1,this.listener=f.listener||null,this.maxDepth=typeof f.maxDepth=="number"?f.maxDepth:100,this.maxTotalMergeKeys=typeof f.maxTotalMergeKeys=="number"?f.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=n.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function cn(n,f){let y={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return y.snippet=t(y),new e(f,y)}function R(n,f){throw cn(n,f)}function Pe(n,f){n.onWarning&&n.onWarning.call(null,cn(n,f))}function fe(n,f,y){let A=n.anchorMapTransactions;if(A.length!==0){let b=A[A.length-1];o.call(b,f)||(b[f]={existed:o.call(n.anchorMap,f),value:n.anchorMap[f]})}n.anchorMap[f]=y}function jn(n){n.anchorMapTransactions.push(Object.create(null))}function Re(n){let f=n.anchorMapTransactions.pop(),y=n.anchorMapTransactions;if(y.length===0)return;let A=y[y.length-1],b=Object.keys(f);for(let O=0,l=b.length;O<l;O+=1){let h=b[O];o.call(A,h)||(A[h]=f[h])}}function Ln(n){let f=n.anchorMapTransactions.pop(),y=Object.keys(f);for(let A=y.length-1;A>=0;A-=1){let b=f[y[A]];b.existed?n.anchorMap[y[A]]=b.value:delete n.anchorMap[y[A]]}}function Ge(n){return{position:n.position,line:n.line,lineStart:n.lineStart,lineIndent:n.lineIndent,firstTabInLine:n.firstTabInLine,tag:n.tag,anchor:n.anchor,kind:n.kind,result:n.result}}function Me(n,f){n.position=f.position,n.line=f.line,n.lineStart=f.lineStart,n.lineIndent=f.lineIndent,n.firstTabInLine=f.firstTabInLine,n.tag=f.tag,n.anchor=f.anchor,n.kind=f.kind,n.result=f.result}let un={YAML:function(f,y,A){f.version!==null&&R(f,"duplication of %YAML directive"),A.length!==1&&R(f,"YAML directive accepts exactly one argument");let b=/^([0-9]+)\.([0-9]+)$/.exec(A[0]);b===null&&R(f,"ill-formed argument of the YAML directive");let O=parseInt(b[1],10),l=parseInt(b[2],10);O!==1&&R(f,"unacceptable YAML version of the document"),f.version=A[0],f.checkLineBreaks=l<2,l!==1&&l!==2&&Pe(f,"unsupported YAML version of the document")},TAG:function(f,y,A){let b;A.length!==2&&R(f,"TAG directive accepts exactly two arguments");let O=A[0];b=A[1],S.test(O)||R(f,"ill-formed tag handle (first argument) of the TAG directive"),o.call(f.tagMap,O)&&R(f,'there is a previously declared suffix for "'+O+'" tag handle'),v.test(b)||R(f,"ill-formed tag prefix (second argument) of the TAG directive");try{b=decodeURIComponent(b)}catch{R(f,"tag prefix is malformed: "+b)}f.tagMap[O]=b}};function ae(n,f,y,A){if(f<y){let b=n.input.slice(f,y);if(A)for(let O=0,l=b.length;O<l;O+=1){let h=b.charCodeAt(O);h===9||h>=32&&h<=1114111||R(n,"expected valid JSON character")}else g.test(b)&&R(n,"the stream contains non-printable characters");n.result+=b}}function Ce(n,f,y,A){i.isObject(y)||R(n,"cannot merge mappings; the provided source object is unacceptable");let b=Object.keys(y);for(let O=0,l=b.length;O<l;O+=1){let h=b[O];n.maxTotalMergeKeys!==-1&&++n.totalMergeKeys>n.maxTotalMergeKeys&&R(n,"merge keys exceeded maxTotalMergeKeys ("+n.maxTotalMergeKeys+")"),o.call(f,h)||(se(f,h,y[h]),A[h]=!0)}}function he(n,f,y,A,b,O,l,h,C){if(Array.isArray(b)){b=Array.prototype.slice.call(b);for(let w=0,_=b.length;w<_;w+=1)Array.isArray(b[w])&&R(n,"nested arrays are not supported inside keys"),typeof b=="object"&&P(b[w])==="[object Object]"&&(b[w]="[object Object]")}if(typeof b=="object"&&P(b)==="[object Object]"&&(b="[object Object]"),b=String(b),f===null&&(f={}),A==="tag:yaml.org,2002:merge")if(Array.isArray(O))for(let w=0,_=O.length;w<_;w+=1)Ce(n,f,O[w],y);else Ce(n,f,O,y);else!n.json&&!o.call(y,b)&&o.call(f,b)&&(n.line=l||n.line,n.lineStart=h||n.lineStart,n.position=C||n.position,R(n,"duplicated mapping key")),se(f,b,O),delete y[b];return f}function Fe(n){let f=n.input.charCodeAt(n.position);f===10?n.position++:f===13?(n.position++,n.input.charCodeAt(n.position)===10&&n.position++):R(n,"a line break is expected"),n.line+=1,n.lineStart=n.position,n.firstTabInLine=-1}function z(n,f,y){let A=0,b=n.input.charCodeAt(n.position);for(;b!==0;){for(;L(b);)b===9&&n.firstTabInLine===-1&&(n.firstTabInLine=n.position),b=n.input.charCodeAt(++n.position);if(f&&b===35)do b=n.input.charCodeAt(++n.position);while(b!==10&&b!==13&&b!==0);if(F(b))for(Fe(n),b=n.input.charCodeAt(n.position),A++,n.lineIndent=0;b===32;)n.lineIndent++,b=n.input.charCodeAt(++n.position);else break}return y!==-1&&A!==0&&n.lineIndent<y&&Pe(n,"deficient indentation"),A}function je(n){let f=n.position,y=n.input.charCodeAt(f);return!!((y===45||y===46)&&y===n.input.charCodeAt(f+1)&&y===n.input.charCodeAt(f+2)&&(f+=3,y=n.input.charCodeAt(f),y===0||D(y)))}function me(n,f){f===1?n.result+=" ":f>1&&(n.result+=i.repeat(`
45
- `,f-1))}function dn(n,f,y){let A,b,O,l,h,C,w=n.kind,_=n.result,E=n.input.charCodeAt(n.position);if(D(E)||Z(E)||E===35||E===38||E===42||E===33||E===124||E===62||E===39||E===34||E===37||E===64||E===96)return!1;if(E===63||E===45){let x=n.input.charCodeAt(n.position+1);if(D(x)||y&&Z(x))return!1}for(n.kind="scalar",n.result="",A=b=n.position,O=!1;E!==0;){if(E===58){let x=n.input.charCodeAt(n.position+1);if(D(x)||y&&Z(x))break}else if(E===35){let x=n.input.charCodeAt(n.position-1);if(D(x))break}else{if(n.position===n.lineStart&&je(n)||y&&Z(E))break;if(F(E))if(l=n.line,h=n.lineStart,C=n.lineIndent,z(n,!1,-1),n.lineIndent>=f){O=!0,E=n.input.charCodeAt(n.position);continue}else{n.position=b,n.line=l,n.lineStart=h,n.lineIndent=C;break}}O&&(ae(n,A,b,!1),me(n,n.line-l),A=b=n.position,O=!1),L(E)||(b=n.position+1),E=n.input.charCodeAt(++n.position)}return ae(n,A,b,!1),n.result?!0:(n.kind=w,n.result=_,!1)}function pn(n,f){let y,A,b=n.input.charCodeAt(n.position);if(b!==39)return!1;for(n.kind="scalar",n.result="",n.position++,y=A=n.position;(b=n.input.charCodeAt(n.position))!==0;)if(b===39)if(ae(n,y,n.position,!0),b=n.input.charCodeAt(++n.position),b===39)y=n.position,n.position++,A=n.position;else return!0;else F(b)?(ae(n,y,A,!0),me(n,z(n,!1,f)),y=A=n.position):n.position===n.lineStart&&je(n)?R(n,"unexpected end of the document within a single quoted scalar"):(n.position++,L(b)||(A=n.position));R(n,"unexpected end of the stream within a single quoted scalar")}function We(n,f){let y,A,b,O=n.input.charCodeAt(n.position);if(O!==34)return!1;for(n.kind="scalar",n.result="",n.position++,y=A=n.position;(O=n.input.charCodeAt(n.position))!==0;){if(O===34)return ae(n,y,n.position,!0),n.position++,!0;if(O===92){if(ae(n,y,n.position,!0),O=n.input.charCodeAt(++n.position),F(O))z(n,!1,f);else if(O<256&&Ne[O])n.result+=te[O],n.position++;else if((b=K(O))>0){let l=b,h=0;for(;l>0;l--)O=n.input.charCodeAt(++n.position),(b=oe(O))>=0?h=(h<<4)+b:R(n,"expected hexadecimal character");n.result+=j(h),n.position++}else R(n,"unknown escape sequence");y=A=n.position}else F(O)?(ae(n,y,A,!0),me(n,z(n,!1,f)),y=A=n.position):n.position===n.lineStart&&je(n)?R(n,"unexpected end of the document within a double quoted scalar"):(n.position++,L(O)||(A=n.position))}R(n,"unexpected end of the stream within a double quoted scalar")}function fn(n,f){let y=!0,A,b,O,l=n.tag,h,C=n.anchor,w,_,E,x,N=Object.create(null),T,H,M,q=n.input.charCodeAt(n.position);if(q===91)w=93,x=!1,h=[];else if(q===123)w=125,x=!0,h={};else return!1;for(n.anchor!==null&&fe(n,n.anchor,h),q=n.input.charCodeAt(++n.position);q!==0;){if(z(n,!0,f),q=n.input.charCodeAt(n.position),q===w)return n.position++,n.tag=l,n.anchor=C,n.kind=x?"mapping":"sequence",n.result=h,!0;if(y?q===44&&R(n,"expected the node content, but found ','"):R(n,"missed comma between flow collection entries"),H=T=M=null,_=E=!1,q===63){let W=n.input.charCodeAt(n.position+1);D(W)&&(_=E=!0,n.position++,z(n,!0,f))}A=n.line,b=n.lineStart,O=n.position,be(n,f,s,!1,!0),H=n.tag,T=n.result,z(n,!0,f),q=n.input.charCodeAt(n.position),(E||n.line===A)&&q===58&&(_=!0,q=n.input.charCodeAt(++n.position),z(n,!0,f),be(n,f,s,!1,!0),M=n.result),x?he(n,h,N,H,T,M,A,b,O):_?h.push(he(n,null,N,H,T,M,A,b,O)):h.push(T),z(n,!0,f),q=n.input.charCodeAt(n.position),q===44?(y=!0,q=n.input.charCodeAt(++n.position)):y=!1}R(n,"unexpected end of the stream within a flow collection")}function hn(n,f){let y,A=c,b=!1,O=!1,l=f,h=0,C=!1,w,_=n.input.charCodeAt(n.position);if(_===124)y=!1;else if(_===62)y=!0;else return!1;for(n.kind="scalar",n.result="";_!==0;)if(_=n.input.charCodeAt(++n.position),_===43||_===45)c===A?A=_===43?m:p:R(n,"repeat of a chomping mode identifier");else if((w=xe(_))>=0)w===0?R(n,"bad explicit indentation width of a block scalar; it cannot be less than one"):O?R(n,"repeat of an indentation width identifier"):(l=f+w-1,O=!0);else break;if(L(_)){do _=n.input.charCodeAt(++n.position);while(L(_));if(_===35)do _=n.input.charCodeAt(++n.position);while(!F(_)&&_!==0)}for(;_!==0;){for(Fe(n),n.lineIndent=0,_=n.input.charCodeAt(n.position);(!O||n.lineIndent<l)&&_===32;)n.lineIndent++,_=n.input.charCodeAt(++n.position);if(!O&&n.lineIndent>l&&(l=n.lineIndent),F(_)){h++;continue}if(!O&&l===0&&R(n,"missing indentation for block scalar"),n.lineIndent<l){A===m?n.result+=i.repeat(`
46
- `,b?1+h:h):A===c&&b&&(n.result+=`
47
- `);break}y?L(_)?(C=!0,n.result+=i.repeat(`
48
- `,b?1+h:h)):C?(C=!1,n.result+=i.repeat(`
49
- `,h+1)):h===0?b&&(n.result+=" "):n.result+=i.repeat(`
50
- `,h):n.result+=i.repeat(`
51
- `,b?1+h:h),b=!0,O=!0,h=0;let E=n.position;for(;!F(_)&&_!==0;)_=n.input.charCodeAt(++n.position);ae(n,E,n.position,!1)}return!0}function ge(n,f){let y=n.tag,A=n.anchor,b=[],O=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&fe(n,n.anchor,b);let l=n.input.charCodeAt(n.position);for(;l!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,R(n,"tab characters must not be used in indentation")),l===45);){let h=n.input.charCodeAt(n.position+1);if(!D(h))break;if(O=!0,n.position++,z(n,!0,-1)&&n.lineIndent<=f){b.push(null),l=n.input.charCodeAt(n.position);continue}let C=n.line;if(be(n,f,d,!1,!0),b.push(n.result),z(n,!0,-1),l=n.input.charCodeAt(n.position),(n.line===C||n.lineIndent>f)&&l!==0)R(n,"bad indentation of a sequence entry");else if(n.lineIndent<f)break}return O?(n.tag=y,n.anchor=A,n.kind="sequence",n.result=b,!0):!1}function mn(n,f,y){let A,b,O,l,h=n.tag,C=n.anchor,w={},_=Object.create(null),E=null,x=null,N=null,T=!1,H=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&fe(n,n.anchor,w);let M=n.input.charCodeAt(n.position);for(;M!==0;){!T&&n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,R(n,"tab characters must not be used in indentation"));let q=n.input.charCodeAt(n.position+1),W=n.line;if((M===63||M===58)&&D(q))M===63?(T&&(he(n,w,_,E,x,null,b,O,l),E=x=N=null),H=!0,T=!0,A=!0):T?(T=!1,A=!0):R(n,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),n.position+=1,M=q;else{if(b=n.line,O=n.lineStart,l=n.position,!be(n,y,a,!1,!0))break;if(n.line===W){for(M=n.input.charCodeAt(n.position);L(M);)M=n.input.charCodeAt(++n.position);if(M===58)M=n.input.charCodeAt(++n.position),D(M)||R(n,"a whitespace character is expected after the key-value separator within a block mapping"),T&&(he(n,w,_,E,x,null,b,O,l),E=x=N=null),H=!0,T=!1,A=!1,E=n.tag,x=n.result;else if(H)R(n,"can not read an implicit mapping pair; a colon is missed");else return n.tag=h,n.anchor=C,!0}else if(H)R(n,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.tag=h,n.anchor=C,!0}if((n.line===W||n.lineIndent>f)&&(T&&(b=n.line,O=n.lineStart,l=n.position),be(n,f,u,!0,A)&&(T?x=n.result:N=n.result),T||(he(n,w,_,E,x,N,b,O,l),E=x=N=null),z(n,!0,-1),M=n.input.charCodeAt(n.position)),(n.line===W||n.lineIndent>f)&&M!==0)R(n,"bad indentation of a mapping entry");else if(n.lineIndent<f)break}return T&&he(n,w,_,E,x,null,b,O,l),H&&(n.tag=h,n.anchor=C,n.kind="mapping",n.result=w),H}function Dn(n){let f=!1,y=!1,A,b,O=n.input.charCodeAt(n.position);if(O!==33)return!1;n.tag!==null&&R(n,"duplication of a tag property"),O=n.input.charCodeAt(++n.position),O===60?(f=!0,O=n.input.charCodeAt(++n.position)):O===33?(y=!0,A="!!",O=n.input.charCodeAt(++n.position)):A="!";let l=n.position;if(f){do O=n.input.charCodeAt(++n.position);while(O!==0&&O!==62);n.position<n.length?(b=n.input.slice(l,n.position),O=n.input.charCodeAt(++n.position)):R(n,"unexpected end of the stream within a verbatim tag")}else{for(;O!==0&&!D(O);)O===33&&(y?R(n,"tag suffix cannot contain exclamation marks"):(A=n.input.slice(l-1,n.position+1),S.test(A)||R(n,"named tag handle cannot contain such characters"),y=!0,l=n.position+1)),O=n.input.charCodeAt(++n.position);b=n.input.slice(l,n.position),$.test(b)&&R(n,"tag suffix cannot contain flow indicator characters")}b&&!v.test(b)&&R(n,"tag name cannot contain such characters: "+b);try{b=decodeURIComponent(b)}catch{R(n,"tag name is malformed: "+b)}return f?n.tag=b:o.call(n.tagMap,A)?n.tag=n.tagMap[A]+b:A==="!"?n.tag="!"+b:A==="!!"?n.tag="tag:yaml.org,2002:"+b:R(n,'undeclared tag handle "'+A+'"'),!0}function gn(n){let f=n.input.charCodeAt(n.position);if(f!==38)return!1;n.anchor!==null&&R(n,"duplication of an anchor property"),f=n.input.charCodeAt(++n.position);let y=n.position;for(;f!==0&&!D(f)&&!Z(f);)f=n.input.charCodeAt(++n.position);return n.position===y&&R(n,"name of an anchor node must contain at least one character"),n.anchor=n.input.slice(y,n.position),!0}function bn(n){let f=n.input.charCodeAt(n.position);if(f!==42)return!1;f=n.input.charCodeAt(++n.position);let y=n.position;for(;f!==0&&!D(f)&&!Z(f);)f=n.input.charCodeAt(++n.position);n.position===y&&R(n,"name of an alias node must contain at least one character");let A=n.input.slice(y,n.position);return o.call(n.anchorMap,A)||R(n,'unidentified alias "'+A+'"'),n.result=n.anchorMap[A],z(n,!0,-1),!0}function qn(n,f,y,A){let b=Ge(n);return jn(n),Me(n,f),n.tag=null,n.anchor=null,n.kind=null,n.result=null,mn(n,y,A)&&n.kind==="mapping"?(Re(n),!0):(Ln(n),Me(n,b),!1)}function be(n,f,y,A,b){let O,l,h=1,C=!1,w=!1,_=null,E,x,N;n.depth>=n.maxDepth&&R(n,"nesting exceeded maxDepth ("+n.maxDepth+")"),n.depth+=1,n.listener!==null&&n.listener("open",n),n.tag=null,n.anchor=null,n.kind=null,n.result=null;let T=O=l=u===y||d===y;if(A&&z(n,!0,-1)&&(C=!0,n.lineIndent>f?h=1:n.lineIndent===f?h=0:n.lineIndent<f&&(h=-1)),h===1)for(;;){let H=n.input.charCodeAt(n.position),M=Ge(n);if(C&&(H===33&&n.tag!==null||H===38&&n.anchor!==null)||!Dn(n)&&!gn(n))break;_===null&&(_=M),z(n,!0,-1)?(C=!0,l=T,n.lineIndent>f?h=1:n.lineIndent===f?h=0:n.lineIndent<f&&(h=-1)):l=!1}if(l&&(l=C||b),h===1||u===y)if(s===y||a===y?x=f:x=f+1,N=n.position-n.lineStart,h===1)if(l&&(ge(n,N)||mn(n,N,x))||fn(n,x))w=!0;else{let H=n.input.charCodeAt(n.position);_!==null&&T&&!l&&H!==124&&H!==62&&qn(n,_,_.position-_.lineStart,x)||O&&hn(n,x)||pn(n,x)||We(n,x)?w=!0:bn(n)?(w=!0,(n.tag!==null||n.anchor!==null)&&R(n,"alias node should not have any properties")):dn(n,x,s===y)&&(w=!0,n.tag===null&&(n.tag="?")),n.anchor!==null&&fe(n,n.anchor,n.result)}else h===0&&(w=l&&ge(n,N));if(n.tag===null)n.anchor!==null&&fe(n,n.anchor,n.result);else if(n.tag==="?"){n.result!==null&&n.kind!=="scalar"&&R(n,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+n.kind+'"');for(let H=0,M=n.implicitTypes.length;H<M;H+=1)if(E=n.implicitTypes[H],E.resolve(n.result)){n.result=E.construct(n.result),n.tag=E.tag,n.anchor!==null&&fe(n,n.anchor,n.result);break}}else if(n.tag!=="!"){if(o.call(n.typeMap[n.kind||"fallback"],n.tag))E=n.typeMap[n.kind||"fallback"][n.tag];else{E=null;let H=n.typeMap.multi[n.kind||"fallback"];for(let M=0,q=H.length;M<q;M+=1)if(n.tag.slice(0,H[M].tag.length)===H[M].tag){E=H[M];break}}E||R(n,"unknown tag !<"+n.tag+">"),n.result!==null&&E.kind!==n.kind&&R(n,"unacceptable node kind for !<"+n.tag+'> tag; it should be "'+E.kind+'", not "'+n.kind+'"'),E.resolve(n.result,n.tag)?(n.result=E.construct(n.result,n.tag),n.anchor!==null&&fe(n,n.anchor,n.result)):R(n,"cannot resolve a node with !<"+n.tag+"> explicit tag")}return n.listener!==null&&n.listener("close",n),n.depth-=1,n.tag!==null||n.anchor!==null||w}function Bn(n){let f=n.position,y=!1,A;for(n.version=null,n.checkLineBreaks=n.legacy,n.tagMap=Object.create(null),n.anchorMap=Object.create(null);(A=n.input.charCodeAt(n.position))!==0&&(z(n,!0,-1),A=n.input.charCodeAt(n.position),!(n.lineIndent>0||A!==37));){y=!0,A=n.input.charCodeAt(++n.position);let b=n.position;for(;A!==0&&!D(A);)A=n.input.charCodeAt(++n.position);let O=n.input.slice(b,n.position),l=[];for(O.length<1&&R(n,"directive name must not be less than one character in length");A!==0;){for(;L(A);)A=n.input.charCodeAt(++n.position);if(A===35){do A=n.input.charCodeAt(++n.position);while(A!==0&&!F(A));break}if(F(A))break;for(b=n.position;A!==0&&!D(A);)A=n.input.charCodeAt(++n.position);l.push(n.input.slice(b,n.position))}A!==0&&Fe(n),o.call(un,O)?un[O](n,O,l):Pe(n,'unknown document directive "'+O+'"')}if(z(n,!0,-1),n.lineIndent===0&&n.input.charCodeAt(n.position)===45&&n.input.charCodeAt(n.position+1)===45&&n.input.charCodeAt(n.position+2)===45?(n.position+=3,z(n,!0,-1)):y&&R(n,"directives end mark is expected"),be(n,n.lineIndent-1,u,!1,!0),z(n,!0,-1),n.checkLineBreaks&&k.test(n.input.slice(f,n.position))&&Pe(n,"non-ASCII line breaks are interpreted as content"),n.documents.push(n.result),n.position===n.lineStart&&je(n)){n.input.charCodeAt(n.position)===46&&(n.position+=3,z(n,!0,-1));return}n.position<n.length-1&&R(n,"end of the stream or a document separator is expected")}function yn(n,f){n=String(n),f=f||{},n.length!==0&&(n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13&&(n+=`
52
- `),n.charCodeAt(0)===65279&&(n=n.slice(1)));let y=new ee(n,f),A=n.indexOf("\0");for(A!==-1&&(y.position=A,R(y,"null byte is not allowed in input")),y.input+="\0";y.input.charCodeAt(y.position)===32;)y.lineIndent+=1,y.position+=1;for(;y.position<y.length-1;)Bn(y);return y.documents}function wn(n,f,y){f!==null&&typeof f=="object"&&typeof y>"u"&&(y=f,f=null);let A=yn(n,y);if(typeof f!="function")return A;for(let b=0,O=A.length;b<O;b+=1)f(A[b])}function Un(n,f){let y=yn(n,f);if(y.length!==0){if(y.length===1)return y[0];throw new e("expected a single document in the stream, but found more")}}return Pn.loadAll=wn,Pn.load=Un,Pn}var Tt={},Ii;function uo(){if(Ii)return Tt;Ii=1;let i=rn(),e=on(),t=Nt(),r=Object.prototype.toString,o=Object.prototype.hasOwnProperty,s=65279,a=9,d=10,u=13,c=32,p=33,m=34,g=35,k=37,$=38,S=39,v=42,P=44,F=45,L=58,D=61,Z=62,oe=63,K=64,xe=91,Te=93,j=96,se=123,Ne=124,te=125,ee={};ee[0]="\\0",ee[7]="\\a",ee[8]="\\b",ee[9]="\\t",ee[10]="\\n",ee[11]="\\v",ee[12]="\\f",ee[13]="\\r",ee[27]="\\e",ee[34]='\\"',ee[92]="\\\\",ee[133]="\\N",ee[160]="\\_",ee[8232]="\\L",ee[8233]="\\P";let cn=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],R=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Pe(l,h){if(h===null)return{};let C={},w=Object.keys(h);for(let _=0,E=w.length;_<E;_+=1){let x=w[_],N=String(h[x]);x.slice(0,2)==="!!"&&(x="tag:yaml.org,2002:"+x.slice(2));let T=l.compiledTypeMap.fallback[x];T&&o.call(T.styleAliases,N)&&(N=T.styleAliases[N]),C[x]=N}return C}function fe(l){let h,C,w=l.toString(16).toUpperCase();if(l<=255)h="x",C=2;else if(l<=65535)h="u",C=4;else if(l<=4294967295)h="U",C=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+h+i.repeat("0",C-w.length)+w}let jn=1,Re=2;function Ln(l){this.schema=l.schema||t,this.indent=Math.max(1,l.indent||2),this.noArrayIndent=l.noArrayIndent||!1,this.skipInvalid=l.skipInvalid||!1,this.flowLevel=i.isNothing(l.flowLevel)?-1:l.flowLevel,this.styleMap=Pe(this.schema,l.styles||null),this.sortKeys=l.sortKeys||!1,this.lineWidth=l.lineWidth||80,this.noRefs=l.noRefs||!1,this.noCompatMode=l.noCompatMode||!1,this.condenseFlow=l.condenseFlow||!1,this.quotingType=l.quotingType==='"'?Re:jn,this.forceQuotes=l.forceQuotes||!1,this.replacer=typeof l.replacer=="function"?l.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Ge(l,h){let C=i.repeat(" ",h),w=0,_="",E=l.length;for(;w<E;){let x,N=l.indexOf(`
53
- `,w);N===-1?(x=l.slice(w),w=E):(x=l.slice(w,N+1),w=N+1),x.length&&x!==`
54
- `&&(_+=C),_+=x}return _}function Me(l,h){return`
55
- `+i.repeat(" ",l.indent*h)}function un(l,h){for(let C=0,w=l.implicitTypes.length;C<w;C+=1)if(l.implicitTypes[C].resolve(h))return!0;return!1}function ae(l){return l===c||l===a}function Ce(l){return l>=32&&l<=126||l>=161&&l<=55295&&l!==8232&&l!==8233||l>=57344&&l<=65533&&l!==s||l>=65536&&l<=1114111}function he(l){return Ce(l)&&l!==s&&l!==u&&l!==d}function Fe(l,h,C){let w=he(l),_=w&&!ae(l);return(C?w:w&&l!==P&&l!==xe&&l!==Te&&l!==se&&l!==te)&&l!==g&&!(h===L&&!_)||he(h)&&!ae(h)&&l===g||h===L&&_}function z(l){return Ce(l)&&l!==s&&!ae(l)&&l!==F&&l!==oe&&l!==L&&l!==P&&l!==xe&&l!==Te&&l!==se&&l!==te&&l!==g&&l!==$&&l!==v&&l!==p&&l!==Ne&&l!==D&&l!==Z&&l!==S&&l!==m&&l!==k&&l!==K&&l!==j}function je(l){return!ae(l)&&l!==L}function me(l,h){let C=l.charCodeAt(h),w;return C>=55296&&C<=56319&&h+1<l.length&&(w=l.charCodeAt(h+1),w>=56320&&w<=57343)?(C-55296)*1024+w-56320+65536:C}function dn(l){return/^\n* /.test(l)}let pn=1,We=2,fn=3,hn=4,ge=5;function mn(l,h,C,w,_,E,x,N){let T,H=0,M=null,q=!1,W=!1,Pt=w!==-1,Ye=-1,Ke=z(me(l,0))&&je(me(l,l.length-1));if(h||x)for(T=0;T<l.length;H>=65536?T+=2:T++){if(H=me(l,T),!Ce(H))return ge;Ke=Ke&&Fe(H,M,N),M=H}else{for(T=0;T<l.length;H>=65536?T+=2:T++){if(H=me(l,T),H===d)q=!0,Pt&&(W=W||T-Ye-1>w&&l[Ye+1]!==" ",Ye=T);else if(!Ce(H))return ge;Ke=Ke&&Fe(H,M,N),M=H}W=W||Pt&&T-Ye-1>w&&l[Ye+1]!==" "}return!q&&!W?Ke&&!x&&!_(l)?pn:E===Re?ge:We:C>9&&dn(l)?ge:x?E===Re?ge:We:W?hn:fn}function Dn(l,h,C,w,_){l.dump=(function(){if(h.length===0)return l.quotingType===Re?'""':"''";if(!l.noCompatMode&&(cn.indexOf(h)!==-1||R.test(h)))return l.quotingType===Re?'"'+h+'"':"'"+h+"'";let E=l.indent*Math.max(1,C),x=l.lineWidth===-1?-1:Math.max(Math.min(l.lineWidth,40),l.lineWidth-E),N=w||l.flowLevel>-1&&C>=l.flowLevel;function T(H){return un(l,H)}switch(mn(h,N,l.indent,x,T,l.quotingType,l.forceQuotes&&!w,_)){case pn:return h;case We:return"'"+h.replace(/'/g,"''")+"'";case fn:return"|"+gn(h,l.indent)+bn(Ge(h,E));case hn:return">"+gn(h,l.indent)+bn(Ge(qn(h,x),E));case ge:return'"'+Bn(h)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function gn(l,h){let C=dn(l)?String(h):"",w=l[l.length-1]===`
56
- `,E=w&&(l[l.length-2]===`
57
- `||l===`
58
- `)?"+":w?"":"-";return C+E+`
59
- `}function bn(l){return l[l.length-1]===`
60
- `?l.slice(0,-1):l}function qn(l,h){let C=/(\n+)([^\n]*)/g,w=(function(){let N=l.indexOf(`
61
- `);return N=N!==-1?N:l.length,C.lastIndex=N,be(l.slice(0,N),h)})(),_=l[0]===`
62
- `||l[0]===" ",E,x;for(;x=C.exec(l);){let N=x[1],T=x[2];E=T[0]===" ",w+=N+(!_&&!E&&T!==""?`
63
- `:"")+be(T,h),_=E}return w}function be(l,h){if(l===""||l[0]===" ")return l;let C=/ [^ ]/g,w,_=0,E,x=0,N=0,T="";for(;w=C.exec(l);)N=w.index,N-_>h&&(E=x>_?x:N,T+=`
64
- `+l.slice(_,E),_=E+1),x=N;return T+=`
65
- `,l.length-_>h&&x>_?T+=l.slice(_,x)+`
66
- `+l.slice(x+1):T+=l.slice(_),T.slice(1)}function Bn(l){let h="",C=0;for(let w=0;w<l.length;C>=65536?w+=2:w++){C=me(l,w);let _=ee[C];!_&&Ce(C)?(h+=l[w],C>=65536&&(h+=l[w+1])):h+=_||fe(C)}return h}function yn(l,h,C){let w="",_=l.tag;for(let E=0,x=C.length;E<x;E+=1){let N=C[E];l.replacer&&(N=l.replacer.call(C,String(E),N)),(y(l,h,N,!1,!1)||typeof N>"u"&&y(l,h,null,!1,!1))&&(w!==""&&(w+=","+(l.condenseFlow?"":" ")),w+=l.dump)}l.tag=_,l.dump="["+w+"]"}function wn(l,h,C,w){let _="",E=l.tag;for(let x=0,N=C.length;x<N;x+=1){let T=C[x];l.replacer&&(T=l.replacer.call(C,String(x),T)),(y(l,h+1,T,!0,!0,!1,!0)||typeof T>"u"&&y(l,h+1,null,!0,!0,!1,!0))&&((!w||_!=="")&&(_+=Me(l,h)),l.dump&&d===l.dump.charCodeAt(0)?_+="-":_+="- ",_+=l.dump)}l.tag=E,l.dump=_||"[]"}function Un(l,h,C){let w="",_=l.tag,E=Object.keys(C);for(let x=0,N=E.length;x<N;x+=1){let T="";w!==""&&(T+=", "),l.condenseFlow&&(T+='"');let H=E[x],M=C[H];l.replacer&&(M=l.replacer.call(C,H,M)),y(l,h,H,!1,!1)&&(l.dump.length>1024&&(T+="? "),T+=l.dump+(l.condenseFlow?'"':"")+":"+(l.condenseFlow?"":" "),y(l,h,M,!1,!1)&&(T+=l.dump,w+=T))}l.tag=_,l.dump="{"+w+"}"}function n(l,h,C,w){let _="",E=l.tag,x=Object.keys(C);if(l.sortKeys===!0)x.sort();else if(typeof l.sortKeys=="function")x.sort(l.sortKeys);else if(l.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let N=0,T=x.length;N<T;N+=1){let H="";(!w||_!=="")&&(H+=Me(l,h));let M=x[N],q=C[M];if(l.replacer&&(q=l.replacer.call(C,M,q)),!y(l,h+1,M,!0,!0,!0))continue;let W=l.tag!==null&&l.tag!=="?"||l.dump&&l.dump.length>1024;W&&(l.dump&&d===l.dump.charCodeAt(0)?H+="?":H+="? "),H+=l.dump,W&&(H+=Me(l,h)),y(l,h+1,q,!0,W)&&(l.dump&&d===l.dump.charCodeAt(0)?H+=":":H+=": ",H+=l.dump,_+=H)}l.tag=E,l.dump=_||"{}"}function f(l,h,C){let w=C?l.explicitTypes:l.implicitTypes;for(let _=0,E=w.length;_<E;_+=1){let x=w[_];if((x.instanceOf||x.predicate)&&(!x.instanceOf||typeof h=="object"&&h instanceof x.instanceOf)&&(!x.predicate||x.predicate(h))){if(C?x.multi&&x.representName?l.tag=x.representName(h):l.tag=x.tag:l.tag="?",x.represent){let N=l.styleMap[x.tag]||x.defaultStyle,T;if(r.call(x.represent)==="[object Function]")T=x.represent(h,N);else if(o.call(x.represent,N))T=x.represent[N](h,N);else throw new e("!<"+x.tag+'> tag resolver accepts not "'+N+'" style');l.dump=T}return!0}}return!1}function y(l,h,C,w,_,E,x){l.tag=null,l.dump=C,f(l,C,!1)||f(l,C,!0);let N=r.call(l.dump),T=w;w&&(w=l.flowLevel<0||l.flowLevel>h);let H=N==="[object Object]"||N==="[object Array]",M,q;if(H&&(M=l.duplicates.indexOf(C),q=M!==-1),(l.tag!==null&&l.tag!=="?"||q||l.indent!==2&&h>0)&&(_=!1),q&&l.usedDuplicates[M])l.dump="*ref_"+M;else{if(H&&q&&!l.usedDuplicates[M]&&(l.usedDuplicates[M]=!0),N==="[object Object]")w&&Object.keys(l.dump).length!==0?(n(l,h,l.dump,_),q&&(l.dump="&ref_"+M+l.dump)):(Un(l,h,l.dump),q&&(l.dump="&ref_"+M+" "+l.dump));else if(N==="[object Array]")w&&l.dump.length!==0?(l.noArrayIndent&&!x&&h>0?wn(l,h-1,l.dump,_):wn(l,h,l.dump,_),q&&(l.dump="&ref_"+M+l.dump)):(yn(l,h,l.dump),q&&(l.dump="&ref_"+M+" "+l.dump));else if(N==="[object String]")l.tag!=="?"&&Dn(l,l.dump,h,E,T);else{if(N==="[object Undefined]")return!1;if(l.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+N)}if(l.tag!==null&&l.tag!=="?"){let W=encodeURI(l.tag[0]==="!"?l.tag.slice(1):l.tag).replace(/!/g,"%21");l.tag[0]==="!"?W="!"+W:W.slice(0,18)==="tag:yaml.org,2002:"?W="!!"+W.slice(18):W="!<"+W+">",l.dump=W+" "+l.dump}}return!0}function A(l,h){let C=[],w=[];b(l,C,w);let _=w.length;for(let E=0;E<_;E+=1)h.duplicates.push(C[w[E]]);h.usedDuplicates=new Array(_)}function b(l,h,C){if(l!==null&&typeof l=="object"){let w=h.indexOf(l);if(w!==-1)C.indexOf(w)===-1&&C.push(w);else if(h.push(l),Array.isArray(l))for(let _=0,E=l.length;_<E;_+=1)b(l[_],h,C);else{let _=Object.keys(l);for(let E=0,x=_.length;E<x;E+=1)b(l[_[E]],h,C)}}}function O(l,h){h=h||{};let C=new Ln(h);C.noRefs||A(l,C);let w=l;return C.replacer&&(w=C.replacer.call({"":w},"",w)),y(C,0,w,!0,!0)?C.dump+`
67
- `:""}return Tt.dump=O,Tt}var Pi;function po(){if(Pi)return ie;Pi=1;let i=co(),e=uo();function t(r,o){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+o+" instead, which is now safe by default.")}}return ie.Type=re(),ie.Schema=Mi(),ie.FAILSAFE_SCHEMA=Di(),ie.JSON_SCHEMA=Gi(),ie.CORE_SCHEMA=Wi(),ie.DEFAULT_SCHEMA=Nt(),ie.load=i.load,ie.loadAll=i.loadAll,ie.dump=e.dump,ie.YAMLException=on(),ie.types={binary:Ji(),float:Vi(),map:Li(),null:qi(),pairs:Xi(),set:Qi(),timestamp:Yi(),bool:Bi(),int:Ui(),merge:Ki(),omap:zi(),seq:ji(),str:Fi()},ie.safeLoad=t("safeLoad","load"),ie.safeLoadAll=t("safeLoadAll","loadAll"),ie.safeDump=t("safeDump","dump"),ie}var fo=po(),_e=ao(fo),{Type:Ns,Schema:Rs,FAILSAFE_SCHEMA:Hs,JSON_SCHEMA:Is,CORE_SCHEMA:Ps,DEFAULT_SCHEMA:Ms,load:Fs,loadAll:js,dump:Ls,YAMLException:Ds,types:qs,safeLoad:Bs,safeLoadAll:Us,safeDump:Vs}=_e;I();var Zi=[" /^immutable_paths[[:space:]]*:/ { grab=1; next }"," grab {",' # A new top-level key (no leading whitespace, ends with ":") ends the list.'," if ($0 ~ /^[^[:space:]#][^:]*:/) { grab=0; next }",' # List item: " - some/path"'," if ($0 ~ /^[[:space:]]*-[[:space:]]*/) {"," line=$0",' sub(/^[[:space:]]*-[[:space:]]*/, "", line) # drop the "- " marker',' sub(/[[:space:]]*#.*$/, "", line) # drop trailing comment',' gsub(/^[[:space:]]+|[[:space:]]+$/, "", line) # trim',` gsub(/^["'\\'']|["'\\'']$/, "", line) # drop surrounding quotes`,' if (line != "") print line'," }"," }"];var ho="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.\n# Edit harness.dot / roles / foundry.config.yaml and run `gp-foundry build`.\n";function mo(i){let e=i.runtime??{};if(e.mode==="vendored")return o=>`./.github/actions/${o}`;let t=e.owner_repo??"thegpvc/gp-foundry",r=e.ref??"v1";return o=>`${t}/actions/${o}@${r}`}function go(i){let e={};return i.name&&(e.name=i.name),i.id&&(e.id=i.id),i.if&&(e.if=i.if),i.timeoutMinutes&&(e["timeout-minutes"]=i.timeoutMinutes),Zt(i)?(e.uses=i.uses,i.with&&Object.keys(i.with).length&&(e.with=i.with)):(i.shell&&(e.shell=i.shell),i.env&&Object.keys(i.env).length&&(e.env=i.env),e.run=i.run),e}function er(i){return String(i.attrs.name??i.id)}function bo(i,e){let t=e?`${e.replace(/\/+$/,"")}/agents/scope.yaml`:"agents/scope.yaml";return{name:"immutable-paths guard",on:{pull_request:{types:["opened","synchronize","reopened"]}},permissions:{contents:"read"},jobs:{"immutable-paths":{"runs-on":"ubuntu-latest",if:`startsWith(github.event.pull_request.head.ref, '${i.repo.branch_prefix}')`,"timeout-minutes":5,steps:[{name:"Checkout",uses:"actions/checkout@v5",with:{"fetch-depth":0}},{name:"Fail if the PR touches an immutable path",shell:"bash",env:{SCOPE_PATH:t,BASE_SHA:"${{ github.event.pull_request.base.sha }}",HEAD_SHA:"${{ github.event.pull_request.head.sha }}"},run:["# The immutable_paths list, read without a YAML parser. This scan is","# shared with the agent-fallback composite (src/shared/immutable-paths.ts);","# a test fails if the two copies drift.",'PATHS=""','HAS_KEY=""','if [ -f "$SCOPE_PATH" ]; then',` grep -q '^immutable_paths[[:space:]]*:' "$SCOPE_PATH" && HAS_KEY=1`," PATHS=$(awk '",...Zi,` ' "$SCOPE_PATH")`,"fi",'if [ -z "$PATHS" ]; then'," # An absent key falls back to the workflows directory. A key that IS"," # present but yields nothing means the scan could not read it (e.g. a"," # flow-style list) \u2014 silently guarding a different set of paths than"," # the file names is how a green check comes to mean nothing.",' if [ -n "$HAS_KEY" ]; then',' echo "::error::$SCOPE_PATH declares immutable_paths but none could be read."',` echo "Write it as a block list, one '- path/' entry per line; this guard"`,' echo "refuses to run against a list it cannot parse."'," exit 1"," fi",' PATHS=".github/workflows/"',"fi","","# Three-dot: compare against the MERGE BASE, so edits that landed on the","# base branch after this PR forked are not blamed on the PR. --no-renames","# keeps a rename visible as a delete of the protected path, which is","# exactly the move this guard must catch.",'VIOLATIONS=""',"while IFS= read -r P; do",' [ -z "$P" ] && continue',' # A git pathspec, not a substring: "$P" anchors at the repo root and'," # understands the glob forms scope.yaml is written in.",' HITS=$(git diff --no-renames --name-only "$BASE_SHA...$HEAD_SHA" -- "$P" || true)',` [ -n "$HITS" ] && VIOLATIONS="$VIOLATIONS$HITS"$'\\n'`,'done <<< "$PATHS"',"",`if [ -n "$(printf '%s' "$VIOLATIONS" | tr -d '[:space:]')" ]; then`,' echo "::error::This branch changes paths scope.yaml marks immutable:"',` printf '%s\\n' "$VIOLATIONS" | sed '/^$/d' | sort -u | sed 's/^/ - /'`,' echo "Agents must never modify these. If the change is intentional, a human"',' echo "should make it on their own branch."'," exit 1","fi",'echo "No immutable paths touched."'].join(`
68
- `)}]}}}}function nr(i,e,t=""){let r=[],o=mo(i.config),s=new Map(i.nodes.map(g=>[g.id,g])),a=new Map,d=new Map;for(let g of i.nodes)a.set(g.id,[]),d.set(g.id,[]);for(let g of i.edges)a.get(g.from)?.push(g),d.get(g.to)?.push(g);let u=g=>({config:i.config,node:g,outEdges:a.get(g.id)??[],inEdges:d.get(g.id)??[],actionRef:o,nodeById:k=>s.get(k),specDir:t}),c=(g,k)=>{let $={"runs-on":"ubuntu-latest"},S=g.if??k;return S&&($.if=S),g.environment&&($.environment=g.environment),g.permissions&&Object.keys(g.permissions).length&&($.permissions=g.permissions),g.timeoutMinutes&&($["timeout-minutes"]=g.timeoutMinutes),g.needs?.length&&($.needs=g.needs),g.strategy&&($.strategy=g.strategy),$.steps=g.steps.map(go),$},p=(g,k)=>{let $=_e.dump(k,{lineWidth:-1,noRefs:!0,quotingType:'"'});r.push({path:`.github/workflows/${g}.yml`,contents:ho+$,generated:!0})},m=qe(i);p("immutable-guard",bo(i.config,t));for(let g of i.nodes){if(m.memberIds.has(g.id))continue;let k=e.perNode[g.id];if(!k||Object.keys(k.triggers).length===0)continue;let $=m.byFanin.get(g.id);if($){let v={};for(let L of $.legIds){let D=s.get(L),Z=lt(D,i,u(D));Z&&(v[Z.jobId]=c(Z,k.guard))}let P=JSON.stringify(k.triggers).includes('"pull_request"'),F=ri(u(g),$.legIds,P);v[F.jobId]=c(F),p(g.id,{name:er(g),on:k.triggers,...k.concurrency?{concurrency:k.concurrency}:{},permissions:{contents:"read"},jobs:v});continue}let S=lt(g,i,u(g));S&&p(g.id,{name:er(g),on:k.triggers,...k.concurrency?{concurrency:k.concurrency}:{},permissions:{contents:"read"},jobs:{[S.jobId]:c(S,k.guard)}})}return r}I();function yo(i){switch(i.type){case"start":case"exit":return["([","])"];case"human-gate":return["{{","}}"];case"merge-gate":return["[/","/]"];case"parallel":case"fan_in":return["[[","]]"];default:return["[","]"]}}function wo(i){let e=i.files.role?.replace(/^.*\//,"").replace(/\.md$/,""),t=e&&e!==i.id?`${e} \xB7 ${i.type}`:i.type;return`${i.id}<br/><small>${t}</small>`}function Mn(i){let e=["```mermaid","flowchart TD"];for(let t of i.nodes){let[r,o]=yo(t);e.push(` ${t.id}${r}"${wo(t)}"${o}`)}for(let t of i.edges){let r=[t.on,t.when].filter(Boolean).join(" \xB7 ");e.push(r?` ${t.from} -->|"${r}"| ${t.to}`:` ${t.from} --> ${t.to}`)}return e.push("```",""),`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
39
+ `+n.mark.snippet),s+" "+o):s}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=i(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+i(this,r)},Ot=e,Ot}var Tt,qi;function qo(){if(qi)return Tt;qi=1;let i=mn();function e(o,s,u,p,a){let l="",d="",f=Math.floor(a/2)-1;return p-s>f&&(l=" ... ",s=p-f+l.length),u-p>f&&(d=" ...",u=p+f-d.length),{str:l+o.slice(s,u).replace(/\t/g,"\u2192")+d,pos:p-s+l.length}}function n(o,s){return i.repeat(" ",s-o.length)+o}function r(o,s){if(s=Object.create(s||null),!o.buffer)return null;s.maxLength||(s.maxLength=79),typeof s.indent!="number"&&(s.indent=1),typeof s.linesBefore!="number"&&(s.linesBefore=3),typeof s.linesAfter!="number"&&(s.linesAfter=2);let u=/\r?\n|\r|\0/g,p=[0],a=[],l,d=-1;for(;l=u.exec(o.buffer);)a.push(l.index),p.push(l.index+l[0].length),o.position<=l.index&&d<0&&(d=p.length-2);d<0&&(d=p.length-1);let f="",m=Math.min(o.line+s.linesAfter,a.length).toString().length,A=s.maxLength-(s.indent+m+3);for(let w=1;w<=s.linesBefore&&!(d-w<0);w++){let k=e(o.buffer,p[d-w],a[d-w],o.position-(p[d]-p[d-w]),A);f=i.repeat(" ",s.indent)+n((o.line-w+1).toString(),m)+" | "+k.str+`
40
+ `+f}let C=e(o.buffer,p[d],a[d],o.position,A);f+=i.repeat(" ",s.indent)+n((o.line+1).toString(),m)+" | "+C.str+`
41
+ `,f+=i.repeat("-",s.indent+m+3+C.pos)+`^
42
+ `;for(let w=1;w<=s.linesAfter&&!(d+w>=a.length);w++){let k=e(o.buffer,p[d+w],a[d+w],o.position-(p[d]-p[d+w]),A);f+=i.repeat(" ",s.indent)+n((o.line+w+1).toString(),m)+" | "+k.str+`
43
+ `}return f.replace(/\n$/,"")}return Tt=r,Tt}var Rt,Ui;function oe(){if(Ui)return Rt;Ui=1;let i=gn(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(s){let u={};return s!==null&&Object.keys(s).forEach(function(p){s[p].forEach(function(a){u[String(a)]=p})}),u}function o(s,u){if(u=u||{},Object.keys(u).forEach(function(p){if(e.indexOf(p)===-1)throw new i('Unknown option "'+p+'" is met in definition of "'+s+'" YAML type.')}),this.options=u,this.tag=s,this.kind=u.kind||null,this.resolve=u.resolve||function(){return!0},this.construct=u.construct||function(p){return p},this.instanceOf=u.instanceOf||null,this.predicate=u.predicate||null,this.represent=u.represent||null,this.representName=u.representName||null,this.defaultStyle=u.defaultStyle||null,this.multi=u.multi||!1,this.styleAliases=r(u.styleAliases||null),n.indexOf(this.kind)===-1)throw new i('Unknown kind "'+this.kind+'" is specified for "'+s+'" YAML type.')}return Rt=o,Rt}var Nt,Bi;function ur(){if(Bi)return Nt;Bi=1;let i=gn(),e=oe();function n(s,u){let p=[];return s[u].forEach(function(a){let l=p.length;p.forEach(function(d,f){d.tag===a.tag&&d.kind===a.kind&&d.multi===a.multi&&(l=f)}),p[l]=a}),p}function r(){let s={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function u(p){p.multi?(s.multi[p.kind].push(p),s.multi.fallback.push(p)):s[p.kind][p.tag]=s.fallback[p.tag]=p}for(let p=0,a=arguments.length;p<a;p+=1)arguments[p].forEach(u);return s}function o(s){return this.extend(s)}return o.prototype.extend=function(u){let p=[],a=[];if(u instanceof e)a.push(u);else if(Array.isArray(u))a=a.concat(u);else if(u&&(Array.isArray(u.implicit)||Array.isArray(u.explicit)))u.implicit&&(p=p.concat(u.implicit)),u.explicit&&(a=a.concat(u.explicit));else throw new i("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");p.forEach(function(d){if(!(d instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(d.loadKind&&d.loadKind!=="scalar")throw new i("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(d.multi)throw new i("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),a.forEach(function(d){if(!(d instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let l=Object.create(o.prototype);return l.implicit=(this.implicit||[]).concat(p),l.explicit=(this.explicit||[]).concat(a),l.compiledImplicit=n(l,"implicit"),l.compiledExplicit=n(l,"explicit"),l.compiledTypeMap=r(l.compiledImplicit,l.compiledExplicit),l},Nt=o,Nt}var Ht,Gi;function dr(){if(Gi)return Ht;Gi=1;let i=oe();return Ht=new i("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Ht}var It,Wi;function pr(){if(Wi)return It;Wi=1;let i=oe();return It=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),It}var Pt,Vi;function fr(){if(Vi)return Pt;Vi=1;let i=oe();return Pt=new i("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Pt}var Mt,Yi;function hr(){if(Yi)return Mt;Yi=1;let i=ur();return Mt=new i({explicit:[dr(),pr(),fr()]}),Mt}var Ft,Ki;function mr(){if(Ki)return Ft;Ki=1;let i=oe();function e(o){if(o===null)return!0;let s=o.length;return s===1&&o==="~"||s===4&&(o==="null"||o==="Null"||o==="NULL")}function n(){return null}function r(o){return o===null}return Ft=new i("tag:yaml.org,2002:null",{kind:"scalar",resolve:e,construct:n,predicate:r,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),Ft}var Dt,Ji;function gr(){if(Ji)return Dt;Ji=1;let i=oe();function e(o){if(o===null)return!1;let s=o.length;return s===4&&(o==="true"||o==="True"||o==="TRUE")||s===5&&(o==="false"||o==="False"||o==="FALSE")}function n(o){return o==="true"||o==="True"||o==="TRUE"}function r(o){return Object.prototype.toString.call(o)==="[object Boolean]"}return Dt=new i("tag:yaml.org,2002:bool",{kind:"scalar",resolve:e,construct:n,predicate:r,represent:{lowercase:function(o){return o?"true":"false"},uppercase:function(o){return o?"TRUE":"FALSE"},camelcase:function(o){return o?"True":"False"}},defaultStyle:"lowercase"}),Dt}var jt,zi;function br(){if(zi)return jt;zi=1;let i=mn(),e=oe();function n(l){return l>=48&&l<=57||l>=65&&l<=70||l>=97&&l<=102}function r(l){return l>=48&&l<=55}function o(l){return l>=48&&l<=57}function s(l){if(l===null)return!1;let d=l.length,f=0,m=!1;if(!d)return!1;let A=l[f];if((A==="-"||A==="+")&&(A=l[++f]),A==="0"){if(f+1===d)return!0;if(A=l[++f],A==="b"){for(f++;f<d;f++){if(A=l[f],A!=="0"&&A!=="1")return!1;m=!0}return m&&isFinite(u(l))}if(A==="x"){for(f++;f<d;f++){if(!n(l.charCodeAt(f)))return!1;m=!0}return m&&isFinite(u(l))}if(A==="o"){for(f++;f<d;f++){if(!r(l.charCodeAt(f)))return!1;m=!0}return m&&isFinite(u(l))}}for(;f<d;f++){if(!o(l.charCodeAt(f)))return!1;m=!0}return m?isFinite(u(l)):!1}function u(l){let d=l,f=1,m=d[0];if((m==="-"||m==="+")&&(m==="-"&&(f=-1),d=d.slice(1),m=d[0]),d==="0")return 0;if(m==="0"){if(d[1]==="b")return f*parseInt(d.slice(2),2);if(d[1]==="x")return f*parseInt(d.slice(2),16);if(d[1]==="o")return f*parseInt(d.slice(2),8)}return f*parseInt(d,10)}function p(l){return u(l)}function a(l){return Object.prototype.toString.call(l)==="[object Number]"&&l%1===0&&!i.isNegativeZero(l)}return jt=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:s,construct:p,predicate:a,represent:{binary:function(l){return l>=0?"0b"+l.toString(2):"-0b"+l.toString(2).slice(1)},octal:function(l){return l>=0?"0o"+l.toString(8):"-0o"+l.toString(8).slice(1)},decimal:function(l){return l.toString(10)},hexadecimal:function(l){return l>=0?"0x"+l.toString(16).toUpperCase():"-0x"+l.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),jt}var Lt,Xi;function yr(){if(Xi)return Lt;Xi=1;let i=mn(),e=oe(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function o(l){return l===null||!n.test(l)?!1:isFinite(parseFloat(l,10))?!0:r.test(l)}function s(l){let d=l.toLowerCase(),f=d[0]==="-"?-1:1;return"+-".indexOf(d[0])>=0&&(d=d.slice(1)),d===".inf"?f===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:d===".nan"?NaN:f*parseFloat(d,10)}let u=/^[-+]?[0-9]+e/;function p(l,d){if(isNaN(l))switch(d){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===l)switch(d){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===l)switch(d){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(l))return"-0.0";let f=l.toString(10);return u.test(f)?f.replace("e",".e"):f}function a(l){return Object.prototype.toString.call(l)==="[object Number]"&&(l%1!==0||i.isNegativeZero(l))}return Lt=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:o,construct:s,predicate:a,represent:p,defaultStyle:"lowercase"}),Lt}var qt,Qi;function wr(){return Qi||(Qi=1,qt=hr().extend({implicit:[mr(),gr(),br(),yr()]})),qt}var Ut,Zi;function _r(){return Zi||(Zi=1,Ut=wr()),Ut}var Bt,er;function Ar(){if(er)return Bt;er=1;let i=oe(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(u){return u===null?!1:e.exec(u)!==null||n.exec(u)!==null}function o(u){let p=0,a=null,l=e.exec(u);if(l===null&&(l=n.exec(u)),l===null)throw new Error("Date resolve error");let d=+l[1],f=+l[2]-1,m=+l[3];if(!l[4])return new Date(Date.UTC(d,f,m));let A=+l[4],C=+l[5],w=+l[6];if(l[7]){for(p=l[7].slice(0,3);p.length<3;)p+="0";p=+p}if(l[9]){let H=+l[10],N=+(l[11]||0);a=(H*60+N)*6e4,l[9]==="-"&&(a=-a)}let k=new Date(Date.UTC(d,f,m,A,C,w,p));return a&&k.setTime(k.getTime()-a),k}function s(u){return u.toISOString()}return Bt=new i("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:o,instanceOf:Date,represent:s}),Bt}var Gt,nr;function kr(){if(nr)return Gt;nr=1;let i=oe();function e(n){return n==="<<"||n===null}return Gt=new i("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Gt}var Wt,tr;function $r(){if(tr)return Wt;tr=1;let i=oe(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
44
+ \r`;function n(u){if(u===null)return!1;let p=0,a=u.length,l=e;for(let d=0;d<a;d++){let f=l.indexOf(u.charAt(d));if(!(f>64)){if(f<0)return!1;p+=6}}return p%8===0}function r(u){let p=u.replace(/[\r\n=]/g,""),a=p.length,l=e,d=0,f=[];for(let A=0;A<a;A++)A%4===0&&A&&(f.push(d>>16&255),f.push(d>>8&255),f.push(d&255)),d=d<<6|l.indexOf(p.charAt(A));let m=a%4*6;return m===0?(f.push(d>>16&255),f.push(d>>8&255),f.push(d&255)):m===18?(f.push(d>>10&255),f.push(d>>2&255)):m===12&&f.push(d>>4&255),new Uint8Array(f)}function o(u){let p="",a=0,l=u.length,d=e;for(let m=0;m<l;m++)m%3===0&&m&&(p+=d[a>>18&63],p+=d[a>>12&63],p+=d[a>>6&63],p+=d[a&63]),a=(a<<8)+u[m];let f=l%3;return f===0?(p+=d[a>>18&63],p+=d[a>>12&63],p+=d[a>>6&63],p+=d[a&63]):f===2?(p+=d[a>>10&63],p+=d[a>>4&63],p+=d[a<<2&63],p+=d[64]):f===1&&(p+=d[a>>2&63],p+=d[a<<4&63],p+=d[64],p+=d[64]),p}function s(u){return Object.prototype.toString.call(u)==="[object Uint8Array]"}return Wt=new i("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:s,represent:o}),Wt}var Vt,ir;function Er(){if(ir)return Vt;ir=1;let i=oe(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(s){if(s===null)return!0;let u=[],p=s;for(let a=0,l=p.length;a<l;a+=1){let d=p[a],f=!1;if(n.call(d)!=="[object Object]")return!1;let m;for(m in d)if(e.call(d,m))if(!f)f=!0;else return!1;if(!f)return!1;if(u.indexOf(m)===-1)u.push(m);else return!1}return!0}function o(s){return s!==null?s:[]}return Vt=new i("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:o}),Vt}var Yt,rr;function Sr(){if(rr)return Yt;rr=1;let i=oe(),e=Object.prototype.toString;function n(o){if(o===null)return!0;let s=o,u=new Array(s.length);for(let p=0,a=s.length;p<a;p+=1){let l=s[p];if(e.call(l)!=="[object Object]")return!1;let d=Object.keys(l);if(d.length!==1)return!1;u[p]=[d[0],l[d[0]]]}return!0}function r(o){if(o===null)return[];let s=o,u=new Array(s.length);for(let p=0,a=s.length;p<a;p+=1){let l=s[p],d=Object.keys(l);u[p]=[d[0],l[d[0]]]}return u}return Yt=new i("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:n,construct:r}),Yt}var Kt,or;function vr(){if(or)return Kt;or=1;let i=oe(),e=Object.prototype.hasOwnProperty;function n(o){if(o===null)return!0;let s=o;for(let u in s)if(e.call(s,u)&&s[u]!==null)return!1;return!0}function r(o){return o!==null?o:{}}return Kt=new i("tag:yaml.org,2002:set",{kind:"mapping",resolve:n,construct:r}),Kt}var Jt,sr;function Xt(){return sr||(sr=1,Jt=_r().extend({implicit:[Ar(),kr()],explicit:[$r(),Er(),Sr(),vr()]})),Jt}var ar;function Uo(){if(ar)return Wn;ar=1;let i=mn(),e=gn(),n=qo(),r=Xt(),o=Object.prototype.hasOwnProperty,s=1,u=2,p=3,a=4,l=1,d=2,f=3,m=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,A=/[\x85\u2028\u2029]/,C=/[,\[\]{}]/,w=/^(?:!|!!|![0-9A-Za-z-]+!)$/,k=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function H(t){return Object.prototype.toString.call(t)}function N(t){return t===10||t===13}function M(t){return t===9||t===32}function L(t){return t===9||t===32||t===10||t===13}function z(t){return t===44||t===91||t===93||t===123||t===125}function se(t){if(t>=48&&t<=57)return t-48;let h=t|32;return h>=97&&h<=102?h-97+10:-1}function le(t){return t===120?2:t===117?4:t===85?8:0}function ee(t){return t>=48&&t<=57?t-48:-1}function ae(t){switch(t){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
45
+ `;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function ge(t){return t<=65535?String.fromCharCode(t):String.fromCharCode((t-65536>>10)+55296,(t-65536&1023)+56320)}function he(t,h,y){h==="__proto__"?Object.defineProperty(t,h,{configurable:!0,enumerable:!0,writable:!0,value:y}):t[h]=y}let j=new Array(256),ce=new Array(256);for(let t=0;t<256;t++)j[t]=ae(t)?1:0,ce[t]=ae(t);function Z(t,h){this.input=t,this.filename=h.filename||null,this.schema=h.schema||r,this.onWarning=h.onWarning||null,this.legacy=h.legacy||!1,this.json=h.json||!1,this.listener=h.listener||null,this.maxDepth=typeof h.maxDepth=="number"?h.maxDepth:100,this.maxTotalMergeKeys=typeof h.maxTotalMergeKeys=="number"?h.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ie(t,h){let y={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return y.snippet=n(y),new e(h,y)}function I(t,h){throw ie(t,h)}function je(t,h){t.onWarning&&t.onWarning.call(null,ie(t,h))}function ye(t,h,y){let E=t.anchorMapTransactions;if(E.length!==0){let b=E[E.length-1];o.call(b,h)||(b[h]={existed:o.call(t.anchorMap,h),value:t.anchorMap[h]})}t.anchorMap[h]=y}function Kn(t){t.anchorMapTransactions.push(Object.create(null))}function He(t){let h=t.anchorMapTransactions.pop(),y=t.anchorMapTransactions;if(y.length===0)return;let E=y[y.length-1],b=Object.keys(h);for(let O=0,c=b.length;O<c;O+=1){let g=b[O];o.call(E,g)||(E[g]=h[g])}}function Jn(t){let h=t.anchorMapTransactions.pop(),y=Object.keys(h);for(let E=y.length-1;E>=0;E-=1){let b=h[y[E]];b.existed?t.anchorMap[y[E]]=b.value:delete t.anchorMap[y[E]]}}function tn(t){return{position:t.position,line:t.line,lineStart:t.lineStart,lineIndent:t.lineIndent,firstTabInLine:t.firstTabInLine,tag:t.tag,anchor:t.anchor,kind:t.kind,result:t.result}}function Le(t,h){t.position=h.position,t.line=h.line,t.lineStart=h.lineStart,t.lineIndent=h.lineIndent,t.firstTabInLine=h.firstTabInLine,t.tag=h.tag,t.anchor=h.anchor,t.kind=h.kind,t.result=h.result}let An={YAML:function(h,y,E){h.version!==null&&I(h,"duplication of %YAML directive"),E.length!==1&&I(h,"YAML directive accepts exactly one argument");let b=/^([0-9]+)\.([0-9]+)$/.exec(E[0]);b===null&&I(h,"ill-formed argument of the YAML directive");let O=parseInt(b[1],10),c=parseInt(b[2],10);O!==1&&I(h,"unacceptable YAML version of the document"),h.version=E[0],h.checkLineBreaks=c<2,c!==1&&c!==2&&je(h,"unsupported YAML version of the document")},TAG:function(h,y,E){let b;E.length!==2&&I(h,"TAG directive accepts exactly two arguments");let O=E[0];b=E[1],w.test(O)||I(h,"ill-formed tag handle (first argument) of the TAG directive"),o.call(h.tagMap,O)&&I(h,'there is a previously declared suffix for "'+O+'" tag handle'),k.test(b)||I(h,"ill-formed tag prefix (second argument) of the TAG directive");try{b=decodeURIComponent(b)}catch{I(h,"tag prefix is malformed: "+b)}h.tagMap[O]=b}};function ue(t,h,y,E){if(h<y){let b=t.input.slice(h,y);if(E)for(let O=0,c=b.length;O<c;O+=1){let g=b.charCodeAt(O);g===9||g>=32&&g<=1114111||I(t,"expected valid JSON character")}else m.test(b)&&I(t,"the stream contains non-printable characters");t.result+=b}}function xe(t,h,y,E){i.isObject(y)||I(t,"cannot merge mappings; the provided source object is unacceptable");let b=Object.keys(y);for(let O=0,c=b.length;O<c;O+=1){let g=b[O];t.maxTotalMergeKeys!==-1&&++t.totalMergeKeys>t.maxTotalMergeKeys&&I(t,"merge keys exceeded maxTotalMergeKeys ("+t.maxTotalMergeKeys+")"),o.call(h,g)||(he(h,g,y[g]),E[g]=!0)}}function we(t,h,y,E,b,O,c,g,v){if(Array.isArray(b)){b=Array.prototype.slice.call(b);for(let _=0,$=b.length;_<$;_+=1)Array.isArray(b[_])&&I(t,"nested arrays are not supported inside keys"),typeof b=="object"&&H(b[_])==="[object Object]"&&(b[_]="[object Object]")}if(typeof b=="object"&&H(b)==="[object Object]"&&(b="[object Object]"),b=String(b),h===null&&(h={}),E==="tag:yaml.org,2002:merge")if(Array.isArray(O))for(let _=0,$=O.length;_<$;_+=1)xe(t,h,O[_],y);else xe(t,h,O,y);else!t.json&&!o.call(y,b)&&o.call(h,b)&&(t.line=c||t.line,t.lineStart=g||t.lineStart,t.position=v||t.position,I(t,"duplicated mapping key")),he(h,b,O),delete y[b];return h}function qe(t){let h=t.input.charCodeAt(t.position);h===10?t.position++:h===13?(t.position++,t.input.charCodeAt(t.position)===10&&t.position++):I(t,"a line break is expected"),t.line+=1,t.lineStart=t.position,t.firstTabInLine=-1}function X(t,h,y){let E=0,b=t.input.charCodeAt(t.position);for(;b!==0;){for(;M(b);)b===9&&t.firstTabInLine===-1&&(t.firstTabInLine=t.position),b=t.input.charCodeAt(++t.position);if(h&&b===35)do b=t.input.charCodeAt(++t.position);while(b!==10&&b!==13&&b!==0);if(N(b))for(qe(t),b=t.input.charCodeAt(t.position),E++,t.lineIndent=0;b===32;)t.lineIndent++,b=t.input.charCodeAt(++t.position);else break}return y!==-1&&E!==0&&t.lineIndent<y&&je(t,"deficient indentation"),E}function Ue(t){let h=t.position,y=t.input.charCodeAt(h);return!!((y===45||y===46)&&y===t.input.charCodeAt(h+1)&&y===t.input.charCodeAt(h+2)&&(h+=3,y=t.input.charCodeAt(h),y===0||L(y)))}function _e(t,h){h===1?t.result+=" ":h>1&&(t.result+=i.repeat(`
46
+ `,h-1))}function kn(t,h,y){let E,b,O,c,g,v,_=t.kind,$=t.result,x=t.input.charCodeAt(t.position);if(L(x)||z(x)||x===35||x===38||x===42||x===33||x===124||x===62||x===39||x===34||x===37||x===64||x===96)return!1;if(x===63||x===45){let S=t.input.charCodeAt(t.position+1);if(L(S)||y&&z(S))return!1}for(t.kind="scalar",t.result="",E=b=t.position,O=!1;x!==0;){if(x===58){let S=t.input.charCodeAt(t.position+1);if(L(S)||y&&z(S))break}else if(x===35){let S=t.input.charCodeAt(t.position-1);if(L(S))break}else{if(t.position===t.lineStart&&Ue(t)||y&&z(x))break;if(N(x))if(c=t.line,g=t.lineStart,v=t.lineIndent,X(t,!1,-1),t.lineIndent>=h){O=!0,x=t.input.charCodeAt(t.position);continue}else{t.position=b,t.line=c,t.lineStart=g,t.lineIndent=v;break}}O&&(ue(t,E,b,!1),_e(t,t.line-c),E=b=t.position,O=!1),M(x)||(b=t.position+1),x=t.input.charCodeAt(++t.position)}return ue(t,E,b,!1),t.result?!0:(t.kind=_,t.result=$,!1)}function $n(t,h){let y,E,b=t.input.charCodeAt(t.position);if(b!==39)return!1;for(t.kind="scalar",t.result="",t.position++,y=E=t.position;(b=t.input.charCodeAt(t.position))!==0;)if(b===39)if(ue(t,y,t.position,!0),b=t.input.charCodeAt(++t.position),b===39)y=t.position,t.position++,E=t.position;else return!0;else N(b)?(ue(t,y,E,!0),_e(t,X(t,!1,h)),y=E=t.position):t.position===t.lineStart&&Ue(t)?I(t,"unexpected end of the document within a single quoted scalar"):(t.position++,M(b)||(E=t.position));I(t,"unexpected end of the stream within a single quoted scalar")}function rn(t,h){let y,E,b,O=t.input.charCodeAt(t.position);if(O!==34)return!1;for(t.kind="scalar",t.result="",t.position++,y=E=t.position;(O=t.input.charCodeAt(t.position))!==0;){if(O===34)return ue(t,y,t.position,!0),t.position++,!0;if(O===92){if(ue(t,y,t.position,!0),O=t.input.charCodeAt(++t.position),N(O))X(t,!1,h);else if(O<256&&j[O])t.result+=ce[O],t.position++;else if((b=le(O))>0){let c=b,g=0;for(;c>0;c--)O=t.input.charCodeAt(++t.position),(b=se(O))>=0?g=(g<<4)+b:I(t,"expected hexadecimal character");t.result+=ge(g),t.position++}else I(t,"unknown escape sequence");y=E=t.position}else N(O)?(ue(t,y,E,!0),_e(t,X(t,!1,h)),y=E=t.position):t.position===t.lineStart&&Ue(t)?I(t,"unexpected end of the document within a double quoted scalar"):(t.position++,M(O)||(E=t.position))}I(t,"unexpected end of the stream within a double quoted scalar")}function En(t,h){let y=!0,E,b,O,c=t.tag,g,v=t.anchor,_,$,x,S,R=Object.create(null),T,F,D,q=t.input.charCodeAt(t.position);if(q===91)_=93,S=!1,g=[];else if(q===123)_=125,S=!0,g={};else return!1;for(t.anchor!==null&&ye(t,t.anchor,g),q=t.input.charCodeAt(++t.position);q!==0;){if(X(t,!0,h),q=t.input.charCodeAt(t.position),q===_)return t.position++,t.tag=c,t.anchor=v,t.kind=S?"mapping":"sequence",t.result=g,!0;if(y?q===44&&I(t,"expected the node content, but found ','"):I(t,"missed comma between flow collection entries"),F=T=D=null,$=x=!1,q===63){let Y=t.input.charCodeAt(t.position+1);L(Y)&&($=x=!0,t.position++,X(t,!0,h))}E=t.line,b=t.lineStart,O=t.position,ke(t,h,s,!1,!0),F=t.tag,T=t.result,X(t,!0,h),q=t.input.charCodeAt(t.position),(x||t.line===E)&&q===58&&($=!0,q=t.input.charCodeAt(++t.position),X(t,!0,h),ke(t,h,s,!1,!0),D=t.result),S?we(t,g,R,F,T,D,E,b,O):$?g.push(we(t,null,R,F,T,D,E,b,O)):g.push(T),X(t,!0,h),q=t.input.charCodeAt(t.position),q===44?(y=!0,q=t.input.charCodeAt(++t.position)):y=!1}I(t,"unexpected end of the stream within a flow collection")}function Sn(t,h){let y,E=l,b=!1,O=!1,c=h,g=0,v=!1,_,$=t.input.charCodeAt(t.position);if($===124)y=!1;else if($===62)y=!0;else return!1;for(t.kind="scalar",t.result="";$!==0;)if($=t.input.charCodeAt(++t.position),$===43||$===45)l===E?E=$===43?f:d:I(t,"repeat of a chomping mode identifier");else if((_=ee($))>=0)_===0?I(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):O?I(t,"repeat of an indentation width identifier"):(c=h+_-1,O=!0);else break;if(M($)){do $=t.input.charCodeAt(++t.position);while(M($));if($===35)do $=t.input.charCodeAt(++t.position);while(!N($)&&$!==0)}for(;$!==0;){for(qe(t),t.lineIndent=0,$=t.input.charCodeAt(t.position);(!O||t.lineIndent<c)&&$===32;)t.lineIndent++,$=t.input.charCodeAt(++t.position);if(!O&&t.lineIndent>c&&(c=t.lineIndent),N($)){g++;continue}if(!O&&c===0&&I(t,"missing indentation for block scalar"),t.lineIndent<c){E===f?t.result+=i.repeat(`
47
+ `,b?1+g:g):E===l&&b&&(t.result+=`
48
+ `);break}y?M($)?(v=!0,t.result+=i.repeat(`
49
+ `,b?1+g:g)):v?(v=!1,t.result+=i.repeat(`
50
+ `,g+1)):g===0?b&&(t.result+=" "):t.result+=i.repeat(`
51
+ `,g):t.result+=i.repeat(`
52
+ `,b?1+g:g),b=!0,O=!0,g=0;let x=t.position;for(;!N($)&&$!==0;)$=t.input.charCodeAt(++t.position);ue(t,x,t.position,!1)}return!0}function Ae(t,h){let y=t.tag,E=t.anchor,b=[],O=!1;if(t.firstTabInLine!==-1)return!1;t.anchor!==null&&ye(t,t.anchor,b);let c=t.input.charCodeAt(t.position);for(;c!==0&&(t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,I(t,"tab characters must not be used in indentation")),c===45);){let g=t.input.charCodeAt(t.position+1);if(!L(g))break;if(O=!0,t.position++,X(t,!0,-1)&&t.lineIndent<=h){b.push(null),c=t.input.charCodeAt(t.position);continue}let v=t.line;if(ke(t,h,p,!1,!0),b.push(t.result),X(t,!0,-1),c=t.input.charCodeAt(t.position),(t.line===v||t.lineIndent>h)&&c!==0)I(t,"bad indentation of a sequence entry");else if(t.lineIndent<h)break}return O?(t.tag=y,t.anchor=E,t.kind="sequence",t.result=b,!0):!1}function vn(t,h,y){let E,b,O,c,g=t.tag,v=t.anchor,_={},$=Object.create(null),x=null,S=null,R=null,T=!1,F=!1;if(t.firstTabInLine!==-1)return!1;t.anchor!==null&&ye(t,t.anchor,_);let D=t.input.charCodeAt(t.position);for(;D!==0;){!T&&t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,I(t,"tab characters must not be used in indentation"));let q=t.input.charCodeAt(t.position+1),Y=t.line;if((D===63||D===58)&&L(q))D===63?(T&&(we(t,_,$,x,S,null,b,O,c),x=S=R=null),F=!0,T=!0,E=!0):T?(T=!1,E=!0):I(t,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),t.position+=1,D=q;else{if(b=t.line,O=t.lineStart,c=t.position,!ke(t,y,u,!1,!0))break;if(t.line===Y){for(D=t.input.charCodeAt(t.position);M(D);)D=t.input.charCodeAt(++t.position);if(D===58)D=t.input.charCodeAt(++t.position),L(D)||I(t,"a whitespace character is expected after the key-value separator within a block mapping"),T&&(we(t,_,$,x,S,null,b,O,c),x=S=R=null),F=!0,T=!1,E=!1,x=t.tag,S=t.result;else if(F)I(t,"can not read an implicit mapping pair; a colon is missed");else return t.tag=g,t.anchor=v,!0}else if(F)I(t,"can not read a block mapping entry; a multiline key may not be an implicit key");else return t.tag=g,t.anchor=v,!0}if((t.line===Y||t.lineIndent>h)&&(T&&(b=t.line,O=t.lineStart,c=t.position),ke(t,h,a,!0,E)&&(T?S=t.result:R=t.result),T||(we(t,_,$,x,S,R,b,O,c),x=S=R=null),X(t,!0,-1),D=t.input.charCodeAt(t.position)),(t.line===Y||t.lineIndent>h)&&D!==0)I(t,"bad indentation of a mapping entry");else if(t.lineIndent<h)break}return T&&we(t,_,$,x,S,null,b,O,c),F&&(t.tag=g,t.anchor=v,t.kind="mapping",t.result=_),F}function zn(t){let h=!1,y=!1,E,b,O=t.input.charCodeAt(t.position);if(O!==33)return!1;t.tag!==null&&I(t,"duplication of a tag property"),O=t.input.charCodeAt(++t.position),O===60?(h=!0,O=t.input.charCodeAt(++t.position)):O===33?(y=!0,E="!!",O=t.input.charCodeAt(++t.position)):E="!";let c=t.position;if(h){do O=t.input.charCodeAt(++t.position);while(O!==0&&O!==62);t.position<t.length?(b=t.input.slice(c,t.position),O=t.input.charCodeAt(++t.position)):I(t,"unexpected end of the stream within a verbatim tag")}else{for(;O!==0&&!L(O);)O===33&&(y?I(t,"tag suffix cannot contain exclamation marks"):(E=t.input.slice(c-1,t.position+1),w.test(E)||I(t,"named tag handle cannot contain such characters"),y=!0,c=t.position+1)),O=t.input.charCodeAt(++t.position);b=t.input.slice(c,t.position),C.test(b)&&I(t,"tag suffix cannot contain flow indicator characters")}b&&!k.test(b)&&I(t,"tag name cannot contain such characters: "+b);try{b=decodeURIComponent(b)}catch{I(t,"tag name is malformed: "+b)}return h?t.tag=b:o.call(t.tagMap,E)?t.tag=t.tagMap[E]+b:E==="!"?t.tag="!"+b:E==="!!"?t.tag="tag:yaml.org,2002:"+b:I(t,'undeclared tag handle "'+E+'"'),!0}function xn(t){let h=t.input.charCodeAt(t.position);if(h!==38)return!1;t.anchor!==null&&I(t,"duplication of an anchor property"),h=t.input.charCodeAt(++t.position);let y=t.position;for(;h!==0&&!L(h)&&!z(h);)h=t.input.charCodeAt(++t.position);return t.position===y&&I(t,"name of an anchor node must contain at least one character"),t.anchor=t.input.slice(y,t.position),!0}function Cn(t){let h=t.input.charCodeAt(t.position);if(h!==42)return!1;h=t.input.charCodeAt(++t.position);let y=t.position;for(;h!==0&&!L(h)&&!z(h);)h=t.input.charCodeAt(++t.position);t.position===y&&I(t,"name of an alias node must contain at least one character");let E=t.input.slice(y,t.position);return o.call(t.anchorMap,E)||I(t,'unidentified alias "'+E+'"'),t.result=t.anchorMap[E],X(t,!0,-1),!0}function Xn(t,h,y,E){let b=tn(t);return Kn(t),Le(t,h),t.tag=null,t.anchor=null,t.kind=null,t.result=null,vn(t,y,E)&&t.kind==="mapping"?(He(t),!0):(Jn(t),Le(t,b),!1)}function ke(t,h,y,E,b){let O,c,g=1,v=!1,_=!1,$=null,x,S,R;t.depth>=t.maxDepth&&I(t,"nesting exceeded maxDepth ("+t.maxDepth+")"),t.depth+=1,t.listener!==null&&t.listener("open",t),t.tag=null,t.anchor=null,t.kind=null,t.result=null;let T=O=c=a===y||p===y;if(E&&X(t,!0,-1)&&(v=!0,t.lineIndent>h?g=1:t.lineIndent===h?g=0:t.lineIndent<h&&(g=-1)),g===1)for(;;){let F=t.input.charCodeAt(t.position),D=tn(t);if(v&&(F===33&&t.tag!==null||F===38&&t.anchor!==null)||!zn(t)&&!xn(t))break;$===null&&($=D),X(t,!0,-1)?(v=!0,c=T,t.lineIndent>h?g=1:t.lineIndent===h?g=0:t.lineIndent<h&&(g=-1)):c=!1}if(c&&(c=v||b),g===1||a===y)if(s===y||u===y?S=h:S=h+1,R=t.position-t.lineStart,g===1)if(c&&(Ae(t,R)||vn(t,R,S))||En(t,S))_=!0;else{let F=t.input.charCodeAt(t.position);$!==null&&T&&!c&&F!==124&&F!==62&&Xn(t,$,$.position-$.lineStart,S)||O&&Sn(t,S)||$n(t,S)||rn(t,S)?_=!0:Cn(t)?(_=!0,(t.tag!==null||t.anchor!==null)&&I(t,"alias node should not have any properties")):kn(t,S,s===y)&&(_=!0,t.tag===null&&(t.tag="?")),t.anchor!==null&&ye(t,t.anchor,t.result)}else g===0&&(_=c&&Ae(t,R));if(t.tag===null)t.anchor!==null&&ye(t,t.anchor,t.result);else if(t.tag==="?"){t.result!==null&&t.kind!=="scalar"&&I(t,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+t.kind+'"');for(let F=0,D=t.implicitTypes.length;F<D;F+=1)if(x=t.implicitTypes[F],x.resolve(t.result)){t.result=x.construct(t.result),t.tag=x.tag,t.anchor!==null&&ye(t,t.anchor,t.result);break}}else if(t.tag!=="!"){if(o.call(t.typeMap[t.kind||"fallback"],t.tag))x=t.typeMap[t.kind||"fallback"][t.tag];else{x=null;let F=t.typeMap.multi[t.kind||"fallback"];for(let D=0,q=F.length;D<q;D+=1)if(t.tag.slice(0,F[D].tag.length)===F[D].tag){x=F[D];break}}x||I(t,"unknown tag !<"+t.tag+">"),t.result!==null&&x.kind!==t.kind&&I(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+x.kind+'", not "'+t.kind+'"'),x.resolve(t.result,t.tag)?(t.result=x.construct(t.result,t.tag),t.anchor!==null&&ye(t,t.anchor,t.result)):I(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return t.listener!==null&&t.listener("close",t),t.depth-=1,t.tag!==null||t.anchor!==null||_}function Qn(t){let h=t.position,y=!1,E;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);(E=t.input.charCodeAt(t.position))!==0&&(X(t,!0,-1),E=t.input.charCodeAt(t.position),!(t.lineIndent>0||E!==37));){y=!0,E=t.input.charCodeAt(++t.position);let b=t.position;for(;E!==0&&!L(E);)E=t.input.charCodeAt(++t.position);let O=t.input.slice(b,t.position),c=[];for(O.length<1&&I(t,"directive name must not be less than one character in length");E!==0;){for(;M(E);)E=t.input.charCodeAt(++t.position);if(E===35){do E=t.input.charCodeAt(++t.position);while(E!==0&&!N(E));break}if(N(E))break;for(b=t.position;E!==0&&!L(E);)E=t.input.charCodeAt(++t.position);c.push(t.input.slice(b,t.position))}E!==0&&qe(t),o.call(An,O)?An[O](t,O,c):je(t,'unknown document directive "'+O+'"')}if(X(t,!0,-1),t.lineIndent===0&&t.input.charCodeAt(t.position)===45&&t.input.charCodeAt(t.position+1)===45&&t.input.charCodeAt(t.position+2)===45?(t.position+=3,X(t,!0,-1)):y&&I(t,"directives end mark is expected"),ke(t,t.lineIndent-1,a,!1,!0),X(t,!0,-1),t.checkLineBreaks&&A.test(t.input.slice(h,t.position))&&je(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Ue(t)){t.input.charCodeAt(t.position)===46&&(t.position+=3,X(t,!0,-1));return}t.position<t.length-1&&I(t,"end of the stream or a document separator is expected")}function On(t,h){t=String(t),h=h||{},t.length!==0&&(t.charCodeAt(t.length-1)!==10&&t.charCodeAt(t.length-1)!==13&&(t+=`
53
+ `),t.charCodeAt(0)===65279&&(t=t.slice(1)));let y=new Z(t,h),E=t.indexOf("\0");for(E!==-1&&(y.position=E,I(y,"null byte is not allowed in input")),y.input+="\0";y.input.charCodeAt(y.position)===32;)y.lineIndent+=1,y.position+=1;for(;y.position<y.length-1;)Qn(y);return y.documents}function Tn(t,h,y){h!==null&&typeof h=="object"&&typeof y>"u"&&(y=h,h=null);let E=On(t,y);if(typeof h!="function")return E;for(let b=0,O=E.length;b<O;b+=1)h(E[b])}function Zn(t,h){let y=On(t,h);if(y.length!==0){if(y.length===1)return y[0];throw new e("expected a single document in the stream, but found more")}}return Wn.loadAll=Tn,Wn.load=Zn,Wn}var zt={},lr;function Bo(){if(lr)return zt;lr=1;let i=mn(),e=gn(),n=Xt(),r=Object.prototype.toString,o=Object.prototype.hasOwnProperty,s=65279,u=9,p=10,a=13,l=32,d=33,f=34,m=35,A=37,C=38,w=39,k=42,H=44,N=45,M=58,L=61,z=62,se=63,le=64,ee=91,ae=93,ge=96,he=123,j=124,ce=125,Z={};Z[0]="\\0",Z[7]="\\a",Z[8]="\\b",Z[9]="\\t",Z[10]="\\n",Z[11]="\\v",Z[12]="\\f",Z[13]="\\r",Z[27]="\\e",Z[34]='\\"',Z[92]="\\\\",Z[133]="\\N",Z[160]="\\_",Z[8232]="\\L",Z[8233]="\\P";let ie=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],I=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function je(c,g){if(g===null)return{};let v={},_=Object.keys(g);for(let $=0,x=_.length;$<x;$+=1){let S=_[$],R=String(g[S]);S.slice(0,2)==="!!"&&(S="tag:yaml.org,2002:"+S.slice(2));let T=c.compiledTypeMap.fallback[S];T&&o.call(T.styleAliases,R)&&(R=T.styleAliases[R]),v[S]=R}return v}function ye(c){let g,v,_=c.toString(16).toUpperCase();if(c<=255)g="x",v=2;else if(c<=65535)g="u",v=4;else if(c<=4294967295)g="U",v=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+g+i.repeat("0",v-_.length)+_}let Kn=1,He=2;function Jn(c){this.schema=c.schema||n,this.indent=Math.max(1,c.indent||2),this.noArrayIndent=c.noArrayIndent||!1,this.skipInvalid=c.skipInvalid||!1,this.flowLevel=i.isNothing(c.flowLevel)?-1:c.flowLevel,this.styleMap=je(this.schema,c.styles||null),this.sortKeys=c.sortKeys||!1,this.lineWidth=c.lineWidth||80,this.noRefs=c.noRefs||!1,this.noCompatMode=c.noCompatMode||!1,this.condenseFlow=c.condenseFlow||!1,this.quotingType=c.quotingType==='"'?He:Kn,this.forceQuotes=c.forceQuotes||!1,this.replacer=typeof c.replacer=="function"?c.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function tn(c,g){let v=i.repeat(" ",g),_=0,$="",x=c.length;for(;_<x;){let S,R=c.indexOf(`
54
+ `,_);R===-1?(S=c.slice(_),_=x):(S=c.slice(_,R+1),_=R+1),S.length&&S!==`
55
+ `&&($+=v),$+=S}return $}function Le(c,g){return`
56
+ `+i.repeat(" ",c.indent*g)}function An(c,g){for(let v=0,_=c.implicitTypes.length;v<_;v+=1)if(c.implicitTypes[v].resolve(g))return!0;return!1}function ue(c){return c===l||c===u}function xe(c){return c>=32&&c<=126||c>=161&&c<=55295&&c!==8232&&c!==8233||c>=57344&&c<=65533&&c!==s||c>=65536&&c<=1114111}function we(c){return xe(c)&&c!==s&&c!==a&&c!==p}function qe(c,g,v){let _=we(c),$=_&&!ue(c);return(v?_:_&&c!==H&&c!==ee&&c!==ae&&c!==he&&c!==ce)&&c!==m&&!(g===M&&!$)||we(g)&&!ue(g)&&c===m||g===M&&$}function X(c){return xe(c)&&c!==s&&!ue(c)&&c!==N&&c!==se&&c!==M&&c!==H&&c!==ee&&c!==ae&&c!==he&&c!==ce&&c!==m&&c!==C&&c!==k&&c!==d&&c!==j&&c!==L&&c!==z&&c!==w&&c!==f&&c!==A&&c!==le&&c!==ge}function Ue(c){return!ue(c)&&c!==M}function _e(c,g){let v=c.charCodeAt(g),_;return v>=55296&&v<=56319&&g+1<c.length&&(_=c.charCodeAt(g+1),_>=56320&&_<=57343)?(v-55296)*1024+_-56320+65536:v}function kn(c){return/^\n* /.test(c)}let $n=1,rn=2,En=3,Sn=4,Ae=5;function vn(c,g,v,_,$,x,S,R){let T,F=0,D=null,q=!1,Y=!1,ti=_!==-1,on=-1,sn=X(_e(c,0))&&Ue(_e(c,c.length-1));if(g||S)for(T=0;T<c.length;F>=65536?T+=2:T++){if(F=_e(c,T),!xe(F))return Ae;sn=sn&&qe(F,D,R),D=F}else{for(T=0;T<c.length;F>=65536?T+=2:T++){if(F=_e(c,T),F===p)q=!0,ti&&(Y=Y||T-on-1>_&&c[on+1]!==" ",on=T);else if(!xe(F))return Ae;sn=sn&&qe(F,D,R),D=F}Y=Y||ti&&T-on-1>_&&c[on+1]!==" "}return!q&&!Y?sn&&!S&&!$(c)?$n:x===He?Ae:rn:v>9&&kn(c)?Ae:S?x===He?Ae:rn:Y?Sn:En}function zn(c,g,v,_,$){c.dump=(function(){if(g.length===0)return c.quotingType===He?'""':"''";if(!c.noCompatMode&&(ie.indexOf(g)!==-1||I.test(g)))return c.quotingType===He?'"'+g+'"':"'"+g+"'";let x=c.indent*Math.max(1,v),S=c.lineWidth===-1?-1:Math.max(Math.min(c.lineWidth,40),c.lineWidth-x),R=_||c.flowLevel>-1&&v>=c.flowLevel;function T(F){return An(c,F)}switch(vn(g,R,c.indent,S,T,c.quotingType,c.forceQuotes&&!_,$)){case $n:return g;case rn:return"'"+g.replace(/'/g,"''")+"'";case En:return"|"+xn(g,c.indent)+Cn(tn(g,x));case Sn:return">"+xn(g,c.indent)+Cn(tn(Xn(g,S),x));case Ae:return'"'+Qn(g)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function xn(c,g){let v=kn(c)?String(g):"",_=c[c.length-1]===`
57
+ `,x=_&&(c[c.length-2]===`
58
+ `||c===`
59
+ `)?"+":_?"":"-";return v+x+`
60
+ `}function Cn(c){return c[c.length-1]===`
61
+ `?c.slice(0,-1):c}function Xn(c,g){let v=/(\n+)([^\n]*)/g,_=(function(){let R=c.indexOf(`
62
+ `);return R=R!==-1?R:c.length,v.lastIndex=R,ke(c.slice(0,R),g)})(),$=c[0]===`
63
+ `||c[0]===" ",x,S;for(;S=v.exec(c);){let R=S[1],T=S[2];x=T[0]===" ",_+=R+(!$&&!x&&T!==""?`
64
+ `:"")+ke(T,g),$=x}return _}function ke(c,g){if(c===""||c[0]===" ")return c;let v=/ [^ ]/g,_,$=0,x,S=0,R=0,T="";for(;_=v.exec(c);)R=_.index,R-$>g&&(x=S>$?S:R,T+=`
65
+ `+c.slice($,x),$=x+1),S=R;return T+=`
66
+ `,c.length-$>g&&S>$?T+=c.slice($,S)+`
67
+ `+c.slice(S+1):T+=c.slice($),T.slice(1)}function Qn(c){let g="",v=0;for(let _=0;_<c.length;v>=65536?_+=2:_++){v=_e(c,_);let $=Z[v];!$&&xe(v)?(g+=c[_],v>=65536&&(g+=c[_+1])):g+=$||ye(v)}return g}function On(c,g,v){let _="",$=c.tag;for(let x=0,S=v.length;x<S;x+=1){let R=v[x];c.replacer&&(R=c.replacer.call(v,String(x),R)),(y(c,g,R,!1,!1)||typeof R>"u"&&y(c,g,null,!1,!1))&&(_!==""&&(_+=","+(c.condenseFlow?"":" ")),_+=c.dump)}c.tag=$,c.dump="["+_+"]"}function Tn(c,g,v,_){let $="",x=c.tag;for(let S=0,R=v.length;S<R;S+=1){let T=v[S];c.replacer&&(T=c.replacer.call(v,String(S),T)),(y(c,g+1,T,!0,!0,!1,!0)||typeof T>"u"&&y(c,g+1,null,!0,!0,!1,!0))&&((!_||$!=="")&&($+=Le(c,g)),c.dump&&p===c.dump.charCodeAt(0)?$+="-":$+="- ",$+=c.dump)}c.tag=x,c.dump=$||"[]"}function Zn(c,g,v){let _="",$=c.tag,x=Object.keys(v);for(let S=0,R=x.length;S<R;S+=1){let T="";_!==""&&(T+=", "),c.condenseFlow&&(T+='"');let F=x[S],D=v[F];c.replacer&&(D=c.replacer.call(v,F,D)),y(c,g,F,!1,!1)&&(c.dump.length>1024&&(T+="? "),T+=c.dump+(c.condenseFlow?'"':"")+":"+(c.condenseFlow?"":" "),y(c,g,D,!1,!1)&&(T+=c.dump,_+=T))}c.tag=$,c.dump="{"+_+"}"}function t(c,g,v,_){let $="",x=c.tag,S=Object.keys(v);if(c.sortKeys===!0)S.sort();else if(typeof c.sortKeys=="function")S.sort(c.sortKeys);else if(c.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let R=0,T=S.length;R<T;R+=1){let F="";(!_||$!=="")&&(F+=Le(c,g));let D=S[R],q=v[D];if(c.replacer&&(q=c.replacer.call(v,D,q)),!y(c,g+1,D,!0,!0,!0))continue;let Y=c.tag!==null&&c.tag!=="?"||c.dump&&c.dump.length>1024;Y&&(c.dump&&p===c.dump.charCodeAt(0)?F+="?":F+="? "),F+=c.dump,Y&&(F+=Le(c,g)),y(c,g+1,q,!0,Y)&&(c.dump&&p===c.dump.charCodeAt(0)?F+=":":F+=": ",F+=c.dump,$+=F)}c.tag=x,c.dump=$||"{}"}function h(c,g,v){let _=v?c.explicitTypes:c.implicitTypes;for(let $=0,x=_.length;$<x;$+=1){let S=_[$];if((S.instanceOf||S.predicate)&&(!S.instanceOf||typeof g=="object"&&g instanceof S.instanceOf)&&(!S.predicate||S.predicate(g))){if(v?S.multi&&S.representName?c.tag=S.representName(g):c.tag=S.tag:c.tag="?",S.represent){let R=c.styleMap[S.tag]||S.defaultStyle,T;if(r.call(S.represent)==="[object Function]")T=S.represent(g,R);else if(o.call(S.represent,R))T=S.represent[R](g,R);else throw new e("!<"+S.tag+'> tag resolver accepts not "'+R+'" style');c.dump=T}return!0}}return!1}function y(c,g,v,_,$,x,S){c.tag=null,c.dump=v,h(c,v,!1)||h(c,v,!0);let R=r.call(c.dump),T=_;_&&(_=c.flowLevel<0||c.flowLevel>g);let F=R==="[object Object]"||R==="[object Array]",D,q;if(F&&(D=c.duplicates.indexOf(v),q=D!==-1),(c.tag!==null&&c.tag!=="?"||q||c.indent!==2&&g>0)&&($=!1),q&&c.usedDuplicates[D])c.dump="*ref_"+D;else{if(F&&q&&!c.usedDuplicates[D]&&(c.usedDuplicates[D]=!0),R==="[object Object]")_&&Object.keys(c.dump).length!==0?(t(c,g,c.dump,$),q&&(c.dump="&ref_"+D+c.dump)):(Zn(c,g,c.dump),q&&(c.dump="&ref_"+D+" "+c.dump));else if(R==="[object Array]")_&&c.dump.length!==0?(c.noArrayIndent&&!S&&g>0?Tn(c,g-1,c.dump,$):Tn(c,g,c.dump,$),q&&(c.dump="&ref_"+D+c.dump)):(On(c,g,c.dump),q&&(c.dump="&ref_"+D+" "+c.dump));else if(R==="[object String]")c.tag!=="?"&&zn(c,c.dump,g,x,T);else{if(R==="[object Undefined]")return!1;if(c.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+R)}if(c.tag!==null&&c.tag!=="?"){let Y=encodeURI(c.tag[0]==="!"?c.tag.slice(1):c.tag).replace(/!/g,"%21");c.tag[0]==="!"?Y="!"+Y:Y.slice(0,18)==="tag:yaml.org,2002:"?Y="!!"+Y.slice(18):Y="!<"+Y+">",c.dump=Y+" "+c.dump}}return!0}function E(c,g){let v=[],_=[];b(c,v,_);let $=_.length;for(let x=0;x<$;x+=1)g.duplicates.push(v[_[x]]);g.usedDuplicates=new Array($)}function b(c,g,v){if(c!==null&&typeof c=="object"){let _=g.indexOf(c);if(_!==-1)v.indexOf(_)===-1&&v.push(_);else if(g.push(c),Array.isArray(c))for(let $=0,x=c.length;$<x;$+=1)b(c[$],g,v);else{let $=Object.keys(c);for(let x=0,S=$.length;x<S;x+=1)b(c[$[x]],g,v)}}}function O(c,g){g=g||{};let v=new Jn(g);v.noRefs||E(c,v);let _=c;return v.replacer&&(_=v.replacer.call({"":_},"",_)),y(v,0,_,!0,!0)?v.dump+`
68
+ `:""}return zt.dump=O,zt}var cr;function Go(){if(cr)return te;cr=1;let i=Uo(),e=Bo();function n(r,o){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+o+" instead, which is now safe by default.")}}return te.Type=oe(),te.Schema=ur(),te.FAILSAFE_SCHEMA=hr(),te.JSON_SCHEMA=wr(),te.CORE_SCHEMA=_r(),te.DEFAULT_SCHEMA=Xt(),te.load=i.load,te.loadAll=i.loadAll,te.dump=e.dump,te.YAMLException=gn(),te.types={binary:$r(),float:yr(),map:fr(),null:mr(),pairs:Sr(),set:vr(),timestamp:Ar(),bool:gr(),int:br(),merge:kr(),omap:Er(),seq:pr(),str:dr()},te.safeLoad=n("safeLoad","load"),te.safeLoadAll=n("safeLoadAll","loadAll"),te.safeDump=n("safeDump","dump"),te}var Wo=Go(),Se=Lo(Wo),{Type:ka,Schema:$a,FAILSAFE_SCHEMA:Ea,JSON_SCHEMA:Sa,CORE_SCHEMA:va,DEFAULT_SCHEMA:xa,load:Ca,loadAll:Oa,dump:Ta,YAMLException:Ra,types:Na,safeLoad:Ha,safeLoadAll:Ia,safeDump:Pa}=Se;P();var Vo="${{ github.event.pull_request.number }}",Yo=10;function xr(i){return Ve(i.node)?zo(i):Ye(i.node,i.config)?Jo(i):null}function Cr(i){return Ve(i.node)?Xo(i):null}var Ko="github-actions";function Jo(i){let e=i.node,n=Ie(e),r=Ge(e,i.config),o={GH_TOKEN:"${{ github.token }}",PR:Vo,NODE:e.id,BOT_LOGIN:i.config.identity?.bot_login??""};r&&(o.AUTHORS=r.join(","));let s=["# Decide whether this lane should run for the PR. The skip= reads fail OPEN:","# a lane that runs once too often costs a run, one that is wrongly skipped","# costs a review nobody knows is missing. The author allowlist is the one","# exception and fails CLOSED \u2014 it says whose PRs the lane may touch at all.",'RUN=true; REASON=""; HEAD_SHA=""; DIFF_HASH=""',"finish() {",' { echo "run=$RUN"; echo "reason=$REASON"; echo "head_sha=$HEAD_SHA"; echo "diff_hash=$DIFF_HASH"; } >> "$GITHUB_OUTPUT"',' if [ "$RUN" = "true" ]; then echo "Running $NODE."; else echo "::notice::Skipping $NODE: $REASON"; fi'," exit 0","}",'skip() { RUN=false; REASON="$1"; finish; }',"","# Live PR state, not the event payload: the run may have queued for a while.",'PR_JSON=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" 2>/dev/null) || PR_JSON=""','if [ -z "$PR_JSON" ]; then',...r?[' skip "could not read PR #$PR to verify its author"']:[' echo "::warning::could not read PR #$PR \u2014 not skipping"'," finish"],"fi",`HEAD_SHA=$(jq -r '.head.sha // ""' <<< "$PR_JSON")`];r&&s.push("","# authors: only these logins' PRs (case-insensitive). The job-level `if:`","# already turned everyone else away from the event payload; this is the","# same test against the PR as it is now, and anything but a match skips.",`if ! jq -e '(.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a)' <<< "$PR_JSON" >/dev/null; then`,` skip "the author $(jq -r '.user.login // "?"' <<< "$PR_JSON") is not in the allowlist"`,"fi");let u=0;for(let p of n)if(s.push(""),p.kind==="draft")s.push("# draft",`if [ "$(jq -r '.draft' <<< "$PR_JSON")" = "true" ]; then skip "the PR is a draft"; fi`);else if(p.kind==="bot-author")s.push("# bot-author: a PR opened by a bot (dependabot, renovate, \u2026). The harness's","# own bot is exempt \u2014 its PRs are the ones this lane exists to review.",`AUTHOR=$(jq -r '.user.login // ""' <<< "$PR_JSON")`,`AUTHOR_TYPE=$(jq -r '.user.type // ""' <<< "$PR_JSON")`,'if [ "$AUTHOR" != "$BOT_LOGIN" ]; then',' case "$AUTHOR_TYPE:$AUTHOR" in',' Bot:*|*"[bot]") skip "authored by the bot $AUTHOR" ;;'," esac","fi");else if(p.kind==="label"){u+=1;let a=`SKIP_LABEL_${u}`;o[a]=i.config.labels?.[p.label]??p.label,s.push(`# label:${p.label}`,`if jq -e --arg l "$${a}" 'any(.labels[]?; .name == $l)' <<< "$PR_JSON" >/dev/null; then`,` skip "the PR carries the label $${a}"`,"fi")}else o.MARKER_PREFIX=Dn(e),o.EVENT_ACTION="${{ github.event.action }}",s.push("# unchanged-diff: hash the PR's merge-base diff and compare it with the hash","# stamped into this bot's last review. Blob ids and hunk positions are","# dropped first, so a rebase or a merge from the base branch that leaves the","# change itself untouched hashes the same. Only a push (synchronize) is","# ever skipped this way: a label, a ready-for-review or a re-request is",'# someone asking for a review, and "nothing changed" is no answer to that.',`BASE_SHA=$(jq -r '.base.sha // ""' <<< "$PR_JSON")`,'if [ -n "$HEAD_SHA" ] && [ -n "$BASE_SHA" ] \\',' && DIFF=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA" -H "Accept: application/vnd.github.diff" 2>/dev/null) \\',' && [ -n "$DIFF" ]; then',` DIFF_HASH=$(printf '%s\\n' "$DIFF" \\`," | sed -E -e '/^index [0-9a-f]+\\.\\.[0-9a-f]+/d' -e 's/^@@ -[0-9,]+ \\+[0-9,]+ @@/@@/' \\"," | sha256sum | cut -d' ' -f1)",` LAST=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`,' .[] | select(.user.login == env.BOT_LOGIN) | (.body // "")',` | select(contains(env.MARKER_PREFIX)) | split(env.MARKER_PREFIX) | last | .[0:64]' 2>/dev/null | tail -n 1) || LAST=""`,' if [ "$EVENT_ACTION" = "synchronize" ] && [ -n "$LAST" ] && [ "$LAST" = "$DIFF_HASH" ]; then',' skip "the diff is unchanged since the last review"'," fi","else",' echo "::warning::could not hash the diff of PR #$PR \u2014 not skipping on unchanged-diff"',"fi");return s.push("","finish"),{jobId:Ke(e),name:`${e.id} skip guard`,permissions:{contents:"read","pull-requests":"read"},timeoutMinutes:5,outputs:{run:"${{ steps.decide.outputs.run }}",reason:"${{ steps.decide.outputs.reason }}",head_sha:"${{ steps.decide.outputs.head_sha }}",diff_hash:"${{ steps.decide.outputs.diff_hash }}"},steps:[re({id:"decide",name:"Decide whether to run",env:o,run:s.join(`
69
+ `)})]}}function zo(i){let e=i.node,n=Ge(e,i.config),r=["# Pick the PR heads that are ready for a decision. Selection is a pure","# function of repo state \u2014 no agent, no randomness \u2014 and every read fails","# CLOSED: a head whose state cannot be read is left for the next sweep.","#",`# candidate open, not a draft, on a harness branch${n?", by an allowlisted author":""}`,"# reviews in no review is still being waited on (no pending review request)","# checks in every check-run on the head is completed, no commit status pending","# undecided no verdict review on this exact head yet, and no earlier","# sweep has already run the lane on it (the swept check)",`LIST=$(gh api "repos/$GITHUB_REPOSITORY/pulls?state=open&sort=created&direction=asc&per_page=100" --paginate --jq '`," .[] | select(.draft | not)"," | select(.head.ref | startswith(env.PREFIX))",...n?[' | select((.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a))']:[],` | "\\(.number) \\(.head.sha) \\((.requested_reviewers | length) + (.requested_teams | length))"') || {`,' echo "::error::could not list open pull requests"'," exit 1","}","SELECTED='[]'","while read -r NUM SHA REQUESTED; do",' [ -n "$NUM" ] || continue',' if [ "$REQUESTED" != "0" ]; then echo "#$NUM: $REQUESTED review request(s) outstanding"; continue; fi',` RUNNING=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100" --paginate --jq '`,` [.check_runs[] | select(.status != "completed")] | length' | awk '{s+=$1} END {print s+0}') || { echo "#$NUM: could not read check-runs"; continue; }`,' if [ "$RUNNING" != "0" ]; then echo "#$NUM: $RUNNING check-run(s) still running"; continue; fi',` STATUS=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/status" --jq '`,` if .total_count == 0 then "none" else .state end') || { echo "#$NUM: could not read commit status"; continue; }`,' if [ "$STATUS" = "pending" ]; then echo "#$NUM: a commit status is pending"; continue; fi',` DECIDED=$(SHA="$SHA" gh api "repos/$GITHUB_REPOSITORY/pulls/$NUM/reviews?per_page=100" --paginate --jq '`," [ .[] | select(.commit_id == env.SHA)",' | select(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',` | select((.body // "") | contains(env.VERDICT_MARKER)) ] | length' | awk '{s+=$1} END {print s+0}') || { echo "#$NUM: could not read reviews"; continue; }`,' if [ "$DECIDED" != "0" ]; then echo "#$NUM: already decided at $SHA"; continue; fi'," # The lane's own record that it ran here. A role that posts nothing (a"," # shadow run, an abstention) leaves no verdict, and without this the same"," # head would be handed to the agent again on every tick, forever.",` SWEPT=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100" --paginate --jq '`,` [.check_runs[] | select(.name == env.SWEPT_CHECK and .app.slug == env.MARK_APP)] | length' | awk '{s+=$1} END {print s+0}') || { echo "#$NUM: could not read check-runs"; continue; }`,' if [ "$SWEPT" != "0" ]; then echo "#$NUM: already swept at $SHA"; continue; fi',' echo "#$NUM: selected at $SHA"',` SELECTED=$(jq -c --argjson n "$NUM" --arg s "$SHA" '. + [{number: $n, sha: $s}]' <<< "$SELECTED")`,` if [ "$(jq 'length' <<< "$SELECTED")" -ge "$LIMIT" ]; then`,' echo "limit of $LIMIT reached \u2014 the rest wait for the next sweep"'," break"," fi",'done <<< "$LIST"',`{ echo "prs=$SELECTED"; echo "count=$(jq 'length' <<< "$SELECTED")"; } >> "$GITHUB_OUTPUT"`].join(`
70
+ `);return{jobId:Ke(e),name:`${e.id} sweep select`,permissions:{contents:"read","pull-requests":"read",checks:"read",statuses:"read"},timeoutMinutes:10,outputs:{prs:"${{ steps.select.outputs.prs }}",count:"${{ steps.select.outputs.count }}"},steps:[re({id:"select",name:"Select pull requests ready for a decision",env:{GH_TOKEN:"${{ github.token }}",PREFIX:i.config.repo.branch_prefix,BOT_LOGIN:i.config.identity?.bot_login??"",VERDICT_MARKER:Si,SWEPT_CHECK:$t(e),MARK_APP:Ko,LIMIT:String(Yo),...n?{AUTHORS:n.join(",")}:{}},run:r})]}}function Xo(i){let e=i.node,n=Ke(e);return{jobId:`${e.id}_mark`,name:`${e.id} sweep mark`,needs:[n,e.id],if:`\${{ always() && needs.${n}.result == 'success' && needs.${n}.outputs.count != '0' }}`,permissions:{checks:"write",actions:"read"},timeoutMinutes:5,steps:[re({name:"Mark the heads this sweep covered",env:{GH_TOKEN:"${{ github.token }}",PRS:`\${{ needs.${n}.outputs.prs }}`,NODE:e.id,JOB_PREFIX:Fn(e),SWEPT_CHECK:$t(e),RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:[`DONE=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/attempts/$RUN_ATTEMPT/jobs?per_page=100" --paginate --jq '`,` .jobs[] | select(.conclusion == "success") | .name') || {`,` echo "::error::could not read this run's jobs \u2014 no head marked, so the next sweep will repeat them"`," exit 1","}","FAILED=0","while read -r NUM SHA; do",' [ -n "$NUM" ] || continue',' if ! grep -Fxq -- "$JOB_PREFIX$NUM" <<< "$DONE"; then',' echo "#$NUM: lane did not succeed \u2014 left unmarked for the next sweep"'," continue"," fi",' if gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$SWEPT_CHECK" \\',' -f head_sha="$SHA" \\'," -f status=completed \\"," -f conclusion=neutral \\",' -f "output[title]=Swept by $NODE" \\',' -f "output[summary]=The $NODE lane ran on $SHA. This is a record that it ran, not a verdict." >/dev/null; then',' echo "#$NUM: marked $SHA"'," else",' echo "::error::#$NUM: could not publish the swept check on $SHA \u2014 the next sweep will repeat it"'," FAILED=1"," fi",`done < <(jq -r '.[] | "\\(.number) \\(.sha)"' <<< "$PRS")`,'exit "$FAILED"'].join(`
71
+ `)})]}}P();var Or=[" /^immutable_paths[[:space:]]*:/ { grab=1; next }"," grab {",' # A new top-level key (no leading whitespace, ends with ":") ends the list.'," if ($0 ~ /^[^[:space:]#][^:]*:/) { grab=0; next }",' # List item: " - some/path"'," if ($0 ~ /^[[:space:]]*-[[:space:]]*/) {"," line=$0",' sub(/^[[:space:]]*-[[:space:]]*/, "", line) # drop the "- " marker',' sub(/[[:space:]]*#.*$/, "", line) # drop trailing comment',' gsub(/^[[:space:]]+|[[:space:]]+$/, "", line) # trim',` gsub(/^["'\\'']|["'\\'']$/, "", line) # drop surrounding quotes`,' if (line != "") print line'," }"," }"];var Qt="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.",Qo=`${Qt}
72
+ # Edit harness.dot / roles / foundry.config.yaml and run \`gp-foundry build\`.
73
+ `;function Zo(i){let e=i.runtime??{};if(e.mode==="vendored")return o=>`./.github/actions/${o}`;let n=e.owner_repo??"thegpvc/gp-foundry",r=e.ref??"v1";return o=>`${n}/actions/${o}@${r}`}function es(i){let e={};return i.name&&(e.name=i.name),i.id&&(e.id=i.id),i.if&&(e.if=i.if),i.timeoutMinutes&&(e["timeout-minutes"]=i.timeoutMinutes),_i(i)?(e.uses=i.uses,i.with&&Object.keys(i.with).length&&(e.with=i.with)):(i.shell&&(e.shell=i.shell),i.env&&Object.keys(i.env).length&&(e.env=i.env),e.run=i.run),e}function Tr(i){return String(i.attrs.name??i.id)}function ns(i,e){let n=e?`${e.replace(/\/+$/,"")}/agents/scope.yaml`:"agents/scope.yaml";return{name:"immutable-paths guard",on:{pull_request:{types:["opened","synchronize","reopened"]}},permissions:{contents:"read"},jobs:{"immutable-paths":{"runs-on":"ubuntu-latest",if:`startsWith(github.event.pull_request.head.ref, '${i.repo.branch_prefix}')`,"timeout-minutes":5,steps:[{name:"Checkout",uses:"actions/checkout@v5",with:{"fetch-depth":0}},{name:"Fail if the PR touches an immutable path",shell:"bash",env:{SCOPE_PATH:n,BASE_SHA:"${{ github.event.pull_request.base.sha }}",HEAD_SHA:"${{ github.event.pull_request.head.sha }}"},run:["# The immutable_paths list, read without a YAML parser. This scan is","# shared with the agent-fallback composite (src/shared/immutable-paths.ts);","# a test fails if the two copies drift.",'PATHS=""','HAS_KEY=""','if [ -f "$SCOPE_PATH" ]; then',` grep -q '^immutable_paths[[:space:]]*:' "$SCOPE_PATH" && HAS_KEY=1`," PATHS=$(awk '",...Or,` ' "$SCOPE_PATH")`,"fi",'if [ -z "$PATHS" ]; then'," # An absent key falls back to the workflows directory. A key that IS"," # present but yields nothing means the scan could not read it (e.g. a"," # flow-style list) \u2014 silently guarding a different set of paths than"," # the file names is how a green check comes to mean nothing.",' if [ -n "$HAS_KEY" ]; then',' echo "::error::$SCOPE_PATH declares immutable_paths but none could be read."',` echo "Write it as a block list, one '- path/' entry per line; this guard"`,' echo "refuses to run against a list it cannot parse."'," exit 1"," fi",' PATHS=".github/workflows/"',"fi","","# Three-dot: compare against the MERGE BASE, so edits that landed on the","# base branch after this PR forked are not blamed on the PR. --no-renames","# keeps a rename visible as a delete of the protected path, which is","# exactly the move this guard must catch.",'VIOLATIONS=""',"while IFS= read -r P; do",' [ -z "$P" ] && continue',' # A git pathspec, not a substring: "$P" anchors at the repo root and'," # understands the glob forms scope.yaml is written in.",' HITS=$(git diff --no-renames --name-only "$BASE_SHA...$HEAD_SHA" -- "$P" || true)',` [ -n "$HITS" ] && VIOLATIONS="$VIOLATIONS$HITS"$'\\n'`,'done <<< "$PATHS"',"",`if [ -n "$(printf '%s' "$VIOLATIONS" | tr -d '[:space:]')" ]; then`,' echo "::error::This branch changes paths scope.yaml marks immutable:"',` printf '%s\\n' "$VIOLATIONS" | sed '/^$/d' | sort -u | sed 's/^/ - /'`,' echo "Agents must never modify these. If the change is intentional, a human"',' echo "should make it on their own branch."'," exit 1","fi",'echo "No immutable paths touched."'].join(`
74
+ `)}]}}}}function ts(i){return i.nodes.some(e=>e.type==="producer"||e.type==="pr-fix"||e.type==="scheduled-agent"&&e.attrs.commit!=="none")}function Rr(i,e,n=""){let r=[],o=Zo(i.config),s=new Map(i.nodes.map(m=>[m.id,m])),u=new Map,p=new Map;for(let m of i.nodes)u.set(m.id,[]),p.set(m.id,[]);for(let m of i.edges)u.get(m.from)?.push(m),p.get(m.to)?.push(m);let a=m=>({config:i.config,node:m,outEdges:u.get(m.id)??[],inEdges:p.get(m.id)??[],actionRef:o,nodeById:A=>s.get(A),specDir:n}),l=(m,A)=>{let C={};m.displayName&&(C.name=m.displayName),C["runs-on"]="ubuntu-latest";let w=m.if??A;return w&&(C.if=w),m.environment&&(C.environment=m.environment),m.permissions&&Object.keys(m.permissions).length&&(C.permissions=m.permissions),m.timeoutMinutes&&(C["timeout-minutes"]=m.timeoutMinutes),m.needs?.length&&(C.needs=m.needs),m.outputs&&Object.keys(m.outputs).length&&(C.outputs=m.outputs),m.strategy&&(C.strategy=m.strategy),C.steps=m.steps.map(es),C},d=(m,A)=>{let C=Se.dump(A,{lineWidth:-1,noRefs:!0,quotingType:'"'});r.push({path:`.github/workflows/${m}.yml`,contents:Qo+C,generated:!0})},f=Me(i);ts(i)&&d("immutable-guard",ns(i.config,n));for(let m of i.nodes){if(f.memberIds.has(m.id))continue;let A=e.perNode[m.id];if(!A||Object.keys(A.triggers).length===0)continue;let C=f.byFanin.get(m.id);if(C){let M={};for(let se of C.legIds){let{skip:le,select:ee,...ae}=s.get(se).attrs,ge={...s.get(se),attrs:ae},he=xt(ge,i,a(ge));he&&(M[he.jobId]=l(he,A.guard))}let L=JSON.stringify(A.triggers).includes('"pull_request"'),z=Ti(a(m),C.legIds,L);M[z.jobId]=l(z),d(m.id,{name:Tr(m),on:A.triggers,...A.concurrency?{concurrency:A.concurrency}:{},permissions:{contents:"read"},jobs:M});continue}let w=xt(m,i,a(m));if(!w)continue;let k=xr(a(m)),H=k?{[k.jobId]:l(k,A.guard),[w.jobId]:l(w)}:{[w.jobId]:l(w,A.guard)},N=Cr(a(m));N&&(H[N.jobId]=l(N)),d(m.id,{name:Tr(m),on:A.triggers,...A.concurrency?{concurrency:A.concurrency}:{},permissions:{contents:"read"},jobs:H})}return r}P();function is(i){switch(i.type){case"start":case"exit":return["([","])"];case"human-gate":return["{{","}}"];case"merge-gate":return["[/","/]"];case"parallel":case"fan_in":return["[[","]]"];default:return["[","]"]}}function rs(i){let e=i.files.role?.replace(/^.*\//,"").replace(/\.md$/,""),n=e&&e!==i.id?`${e} \xB7 ${i.type}`:i.type;return`${i.id}<br/><small>${n}</small>`}function Vn(i){let e=["```mermaid","flowchart TD"];for(let n of i.nodes){let[r,o]=is(n);e.push(` ${n.id}${r}"${rs(n)}"${o}`)}for(let n of i.edges){let r=[n.on,n.when].filter(Boolean).join(" \xB7 ");e.push(r?` ${n.from} -->|"${r}"| ${n.to}`:` ${n.from} --> ${n.to}`)}return e.push("```",""),`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
69
75
 
70
76
  # ${i.config?.name&&i.config.name!=="harness"?i.config.name:i.name} \u2014 agent harness
71
77
 
72
78
  ${e.join(`
73
- `)}`}I();var _o=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),Ao=new Set(["role","prompt","policy","tools"]);function ko(i){let e=[],t=[],r=1,o=0,s=i;for(;o<s.length;){let a=s[o];if(a===`
74
- `){r++,o++;continue}if(a===" "||a===" "||a==="\r"){o++;continue}if(a==="/"&&s[o+1]==="/"){for(;o<s.length&&s[o]!==`
75
- `;)o++;continue}if(a==="/"&&s[o+1]==="*"){for(o+=2;o<s.length&&!(s[o]==="*"&&s[o+1]==="/");)s[o]===`
76
- `&&r++,o++;o+=2;continue}if(a==="-"&&s[o+1]===">"){e.push({kind:"arrow",value:"->",line:r}),o+=2;continue}if(a==="{"){e.push({kind:"lbrace",value:a,line:r}),o++;continue}if(a==="}"){e.push({kind:"rbrace",value:a,line:r}),o++;continue}if(a==="["){e.push({kind:"lbrack",value:a,line:r}),o++;continue}if(a==="]"){e.push({kind:"rbrack",value:a,line:r}),o++;continue}if(a==="="){e.push({kind:"eq",value:a,line:r}),o++;continue}if(a===","){e.push({kind:"comma",value:a,line:r}),o++;continue}if(a===";"){e.push({kind:"semi",value:a,line:r}),o++;continue}if(a==='"'){let d=o+1,u="";for(;d<s.length&&s[d]!=='"';){if(s[d]==="\\"&&d+1<s.length){u+=s[d+1],d+=2;continue}s[d]===`
77
- `&&r++,u+=s[d],d++}d>=s.length&&t.push({message:"unterminated string",line:r}),e.push({kind:"id",value:u,line:r}),o=d+1;continue}if(/[A-Za-z0-9_]/.test(a)){let d=o,u="";for(;d<s.length&&/[A-Za-z0-9_.\-]/.test(s[d]);)u+=s[d],d++;e.push({kind:"id",value:u,line:r}),o=d;continue}t.push({message:`unexpected character '${a}'`,line:r}),o++}return{toks:e,errors:t}}function xo(i){return i==="true"?!0:i==="false"?!1:/^-?\d+$/.test(i)?Number(i):i}function sn(i){let{toks:e,errors:t}=ko(i),r=[],o=[],s=new Map,a="harness",d=0,u=()=>e[d],c=()=>e[d++],p=(S,v)=>t.push({message:S,line:v});u()?.kind==="id"&&u()?.value==="digraph"?(c(),u()?.kind==="id"&&u()?.value!==void 0&&(a=c().value),u()?.kind==="lbrace"?c():p("expected '{' after digraph header",u()?.line)):p("expected 'digraph' keyword",u()?.line);function m(){let S={};if(u()?.kind!=="lbrack")return{attrs:S};let v=c().line;for(;u()&&u().kind!=="rbrack";){let P=c();if(!P||P.kind!=="id"){p("expected attribute name",P?.line);break}if(u()?.kind!=="eq"){p(`expected '=' after attribute '${P.value}'`,P.line);break}c();let F=c();if(!F||F.kind!=="id"){p(`expected value for attribute '${P.value}'`,F?.line);break}S[P.value]=F.value,u()?.kind==="comma"&&c()}return u()?.kind==="rbrack"?c():p("unterminated attribute list '['",v),{attrs:S,line:v}}function g(S,v){let P=s.get(S);return P||(P={id:S,type:"analyst",attrs:{},files:{},raw:{},line:v},s.set(S,P),r.push(P)),P}function k(S,v,P){S.declared=!0,S.raw={...S.raw,...v},P!==void 0&&(S.line=S.line??P);for(let[F,L]of Object.entries(v))F==="type"?(_o.has(L)||p(`unknown node type '${L}' on node '${S.id}'`,P),S.type=L):F==="context"?S.context=L:Ao.has(F)?S.files[F]=L:S.attrs[F]=xo(L)}let $=0;for(;u()&&u().kind!=="rbrace"&&!($++>1e5);){let S=u();if(S.kind==="semi"){c();continue}if(S.kind!=="id"){p(`unexpected token '${S.value}'`,S.line),c();continue}let v=c();if(u()?.kind==="arrow"){let P=[{id:v.value,line:v.line}];for(;u()?.kind==="arrow";){c();let D=c();if(!D||D.kind!=="id"){p("expected node id after '->'",D?.line);break}P.push({id:D.value,line:D.line})}let{attrs:F,line:L}=m();for(let D=0;D+1<P.length;D++){let Z=P[D],oe=P[D+1];g(Z.id,Z.line),g(oe.id,oe.line);let K={from:Z.id,to:oe.id,raw:{...F},line:L??Z.line};F.on!==void 0&&(K.on=F.on),F.when!==void 0&&(K.when=F.when),F.do!==void 0&&(K.do=F.do),o.push(K)}}else{let{attrs:P,line:F}=m(),L=g(v.value,v.line);k(L,P,F??v.line)}u()?.kind==="semi"&&c()}return u()?.kind==="rbrace"&&c(),{name:a,nodes:r,edges:o,errors:t}}I();var an=require("fs");var Be={name:"harness",identity:{},agent:{cli:"claude",model:"claude-opus-4-8",oauth_token_secret:"CLAUDE_CODE_OAUTH_TOKEN"},repo:{base_branch:"main",branch_prefix:"agent/"},labels:{}};function Fn(i){if(!i||!(0,an.existsSync)(i))return structuredClone(Be);let e=_e.load((0,an.readFileSync)(i,"utf8"))??{};return{...Be,...e,identity:{...Be.identity,...e.identity??{}},agent:{...Be.agent,...e.agent??{}},repo:{...Be.repo,...e.repo??{}},labels:{...Be.labels,...e.labels??{}}}}function pe(i,e){let t=sn((0,an.readFileSync)(i,"utf8")),r=Fn(e);return{harness:{name:t.name,nodes:t.nodes,edges:t.edges,config:r,sourcePath:i},parseErrors:t.errors}}function Ue(i,e={},t={}){let r=[...en(i,e),...nn(i)],o=nr(i,ui(i),t.specDir??"");return o.push({path:".github/HARNESS.md",contents:Mn(i),generated:!0}),{files:o,diagnostics:r}}function ln(i){return i.some(e=>e.level==="error")}I();var Co=/^---\r?\n([\s\S]*?)\r?\n---/;function tr(i){let e=Co.exec(i);if(e)try{let t=_e.load(e[1]);if(t&&typeof t=="object")return t}catch{return}}I();var ir=require("fs"),Ae=require("path"),rr=require("url"),Ie=_n(En(),1);function ue(i){return(0,rr.fileURLToPath)(new URL(`../../${i}`,V))}function J(i){process.stdout.write(JSON.stringify(i,null,2)+`
78
- `)}function Rt(i){for(let e of i){let t=e.level==="error"?Ie.default.red("error"):e.level==="warning"?Ie.default.yellow("warn"):Ie.default.blue("info"),r=e.where?.node?Ie.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${t} ${Ie.default.dim(e.code)}${r} ${e.message}
79
- `),e.hint&&process.stderr.write(` ${Ie.default.dim("hint: "+e.hint)}
80
- `)}}function ke(i){let e=(0,Ae.resolve)(i.dot??".github/harness.dot"),t=(0,Ae.dirname)(e),r=i.config?(0,Ae.resolve)(i.config):void 0;if(!r){for(let s of[(0,Ae.join)(t,"foundry.config.yaml"),(0,Ae.join)(t,"agents/foundry.config.yaml")])if((0,ir.existsSync)(s)){r=s;break}}let o=t.endsWith(".github")?(0,Ae.dirname)(t):t;return{dot:e,config:r,base:t,root:o}}I();var Ht=require("child_process"),B=require("fs"),G=require("path");var U=_n(En(),1);var It=require("path");function Ve(i,e={}){try{return{ok:!0,out:(0,Ht.execFileSync)("gh",i,{encoding:"utf8",stdio:["ignore","pipe","pipe"],cwd:e.cwd}).trim()}}catch(t){return{ok:!1,out:t.stderr?.toString().trim()??String(t.message)}}}function Oe(i,e){let t=Ve(i,{cwd:e});if(!t.ok)return null;try{return JSON.parse(t.out)}catch{return null}}function lr(){let i=ue("actions");return(0,B.readdirSync)(i,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(0,B.existsSync)((0,G.join)(i,e.name,"action.yml"))).map(e=>e.name)}function cr(i){let e=Fn(i),t=new Map([["build","ready to implement"],["plan","needs design first"]]),r=[];for(let[o,s]of t)r.push({name:e.labels?.[o]??o,description:s,color:o==="build"?"0e8a16":"5319e7"});return r.push({name:"needs-human",description:"agents are blocked; a human should take over",color:"b60205"}),r.push({name:"needs-rebase",description:"PR conflicts with base; the janitor sweep rebases it",color:"d93f0b"}),r}function or(i){let e={ok:U.default.green("\u2713"),warn:U.default.yellow("!"),fail:U.default.red("\u2717"),skip:U.default.dim("-")};for(let t of i)process.stdout.write(`${e[t.status]} ${t.name.padEnd(28)} ${t.detail}
81
- `),t.hint&&t.status!=="ok"&&process.stdout.write(` ${U.default.dim("hint: "+t.hint)}
82
- `)}function Eo(i,e){let t=i.nodes.filter(r=>r.type==="merge-gate");return t.length===0?!1:t.some(r=>{if(!r.files.policy)return!0;let o=(0,G.dirname)(i.sourcePath??""),s=(0,G.join)(e,o,r.files.policy);if(!(0,B.existsSync)(s))return!0;try{let a=_e.load((0,B.readFileSync)(s,"utf8"));return(a?.require_ci??a?.requireCi)!==!1}catch{return!0}})}function sr(i){let e=[];for(let r of lr()){let o=ue(`actions/${r}`),s=(0,G.join)(i,".github/actions",r);(0,B.mkdirSync)(s,{recursive:!0}),(0,B.cpSync)((0,G.join)(o,"action.yml"),(0,G.join)(s,"action.yml")),(0,B.existsSync)((0,G.join)(o,"dist"))&&(0,B.cpSync)((0,G.join)(o,"dist"),(0,G.join)(s,"dist"),{recursive:!0}),e.push(`.github/actions/${r}/`)}let t=(0,G.join)(i,".github/agent-setup/action.yml");return(0,B.existsSync)(t)||((0,B.mkdirSync)((0,G.dirname)(t),{recursive:!0}),(0,B.writeFileSync)(t,(0,B.readFileSync)(ue("skill/templates/agent-setup.yml"),"utf8")),e.push(".github/agent-setup/action.yml")),e}function So(i){(0,B.mkdirSync)(i,{recursive:!0}),(0,B.cpSync)(ue("skill/SKILL.md"),(0,G.join)(i,"SKILL.md")),(0,B.cpSync)(ue("skill/reference"),(0,G.join)(i,"reference"),{recursive:!0}),(0,B.cpSync)(ue("skill/templates"),(0,G.join)(i,"templates"),{recursive:!0})}function ar(i){let e=[],{dot:t,config:r,base:o,root:s}=ke(i);if(!(0,B.existsSync)(t))return e.push({name:"harness",status:"fail",detail:`no harness.dot at ${t}`,hint:"run `gp-foundry init`"}),{checks:e,failed:!0};let{harness:a,parseErrors:d}=pe(t,r),u=j=>(0,B.existsSync)((0,G.join)(o,j)),c=(0,It.relative)(s,o).replace(/\\/g,"/"),{files:p,diagnostics:m}=Ue(a,{fileExists:u},{specDir:c}),g=m.filter(j=>j.level==="error").length+d.length,k=m.filter(j=>j.level==="warning");e.push(g?{name:"validate",status:"fail",detail:`${g} error(s)`,hint:"run `gp-foundry validate` for details"}:{name:"validate",status:k.length?"warn":"ok",detail:k.length?`${k.length} warning(s): ${k.map(j=>j.code).join(", ")}`:"no diagnostics"});let $=p.filter(j=>{let se=(0,G.join)(s,j.path);return((0,B.existsSync)(se)?(0,B.readFileSync)(se,"utf8"):null)!==j.contents});if(e.push($.length?{name:"workflows in sync",status:"fail",detail:`${$.length} file(s) drifted: ${$.slice(0,3).map(j=>j.path).join(", ")}${$.length>3?", \u2026":""}`,hint:"run `gp-foundry build`"}:{name:"workflows in sync",status:"ok",detail:`${p.length} generated files match`}),(a.config.runtime?.mode??"pinned")==="vendored"){let j=lr().filter(se=>!(0,B.existsSync)((0,G.join)(s,".github/actions",se,"action.yml")));e.push(j.length?{name:"vendored actions",status:"fail",detail:`missing: ${j.join(", ")}`,hint:"run `gp-foundry vendor`"}:{name:"vendored actions",status:"ok",detail:"all runtime actions vendored"})}if(e.push((0,B.existsSync)((0,G.join)(s,".github/agent-setup/action.yml"))?{name:"agent-setup shim",status:"ok",detail:".github/agent-setup/action.yml present"}:{name:"agent-setup shim",status:"fail",detail:"missing \u2014 every agent job needs it",hint:"run `gp-foundry vendor` (or `init`)"}),!Ve(["auth","status"]).ok)return e.push({name:"gh cli",status:"skip",detail:"gh missing or unauthenticated \u2014 skipping repo checks",hint:"install GitHub CLI and `gh auth login`"}),{checks:e,failed:e.some(j=>j.status==="fail")};e.push({name:"gh cli",status:"ok",detail:"authenticated"});let v=Oe(["repo","view","--json","nameWithOwner,defaultBranchRef"],s);if(!v)return e.push({name:"github repo",status:"skip",detail:"not a GitHub repo (or no remote) \u2014 skipping labels/secrets checks",hint:"create it with `gh repo create`, then re-run `gp-foundry up` to create labels"}),{checks:e,failed:e.some(j=>j.status==="fail")};e.push({name:"github repo",status:"ok",detail:v.nameWithOwner});let P=v.defaultBranchRef?.name;P&&e.push(P===a.config.repo.base_branch?{name:"base branch",status:"ok",detail:P}:{name:"base branch",status:"fail",detail:`config says '${a.config.repo.base_branch}' but the repo default is '${P}'`,hint:"fix repo.base_branch in foundry.config.yaml and re-run `gp-foundry up`"});let F=new Set((Oe(["label","list","--json","name","--limit","1000"],s)??[]).map(j=>j.name)),L=cr(r).map(j=>j.name),D=L.filter(j=>!F.has(j));e.push(D.length?{name:"labels",status:"fail",detail:`missing: ${D.join(", ")}`,hint:"run `gp-foundry up` to create them"}:{name:"labels",status:"ok",detail:L.join(", ")});let Z=new Set((Oe(["secret","list","--json","name"],s)??[]).map(j=>j.name)),oe=[a.config.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN"],K=a.config.auth;K?.mode==="pat"&&K.token_secret&&oe.push(K.token_secret),K?.mode==="app"&&oe.push(K.app_id_secret??"APP_ID",K.app_key_secret??"APP_PRIVATE_KEY");let xe=oe.filter(j=>!Z.has(j));if(e.push(xe.length?{name:"secrets",status:"fail",detail:`missing: ${xe.join(", ")}`,hint:`gh secret set ${xe[0]}`}:{name:"secrets",status:"ok",detail:oe.join(", ")}),Eo(a,s)){let se=p.filter(te=>/\/workflows\/.*\.yml$/.test(te.path)&&te.contents.includes("actions/merge-gate")).map(te=>(0,G.join)(s,te.path)).filter(te=>(0,B.existsSync)(te)).map(te=>(0,B.readFileSync)(te,"utf8")),Ne=se.filter(te=>!te.includes("checks-token"));se.length&&Ne.length&&e.push({name:"merge gate ci read",status:"fail",detail:`${Ne.length} merge-gate workflow(s) read check-runs with the harness token`,hint:"a fine-grained PAT cannot be granted the Checks permission, so that read 403s and nothing merges \u2014 run `gp-foundry build` to pass GITHUB_TOKEN instead, then commit"})}let Te=Ve(["--version"]);try{let j=(0,Ht.execFileSync)("git",["status","--porcelain",".github"],{cwd:s,encoding:"utf8"}).trim();e.push(j?{name:"committed",status:"warn",detail:".github/ has uncommitted changes",hint:"commit + push so GitHub picks them up"}:{name:"committed",status:"ok",detail:".github/ clean"})}catch{e.push({name:"committed",status:"skip",detail:"not a git repo"})}return{checks:e,failed:e.some(j=>j.status==="fail")}}function vo(i){let{dot:e,config:t,root:r}=ke(i);if(!Ve(["auth","status"]).ok)return{error:"gh missing or unauthenticated \u2014 status needs the GitHub CLI",hint:"install the GitHub CLI and run `gh auth login`"};let o=Oe(["repo","view","--json","nameWithOwner"],r);if(!o)return{error:"not a GitHub repo (or no remote)",hint:"create it with `gh repo create`, push, then re-run `gp-foundry status`"};let{harness:s}=pe(e,t),a=s.config.repo.branch_prefix,d=Date.now(),u=v=>Math.round((d-Date.parse(v))/36e5),c={};for(let v of["plan","build","needs-human"]){let P=v==="needs-human"?"needs-human":s.config.labels?.[v]??v,F=Oe(["issue","list","--label",P,"--state","open","--json","number,title,createdAt","--limit","50"],r)??[];c[P]=F.map(L=>({number:L.number,title:L.title,ageHours:u(L.createdAt)}))}let m=(Oe(["pr","list","--state","open","--json","number,title,labels,mergeable,headRefName,body,updatedAt","--limit","50"],r)??[]).filter(v=>v.headRefName.startsWith(a)),g=[],k=new Set;for(let v of m)for(let P of v.body?.matchAll(/[Cc]loses #(\d+)/g)??[])k.add(Number(P[1]));let $=s.config.labels?.build??"build";for(let v of c[$]??[])!k.has(v.number)&&v.ageHours>=2&&g.push({kind:"issue-no-pr",number:v.number,title:v.title,detail:`labeled ${$} ${v.ageHours}h ago, no open PR closes it`});for(let v of m)v.updatedAt&&u(v.updatedAt)>=4&&g.push({kind:"pr-idle",number:v.number,title:v.title,detail:`no activity for ${u(v.updatedAt)}h`});let S=(Oe(["run","list","--status","failure","--limit","15","--json","name,url,createdAt,conclusion"],r)??[]).filter(v=>u(v.createdAt)<=24).map(v=>({workflow:v.name,url:v.url,ageHours:u(v.createdAt)}));return{repo:o.nameWithOwner,lanes:c,prs:m.map(v=>({number:v.number,title:v.title,labels:v.labels.map(P=>P.name),mergeable:v.mergeable,headRefName:v.headRefName})),stalled:g,recentFailures:S}}function ur(i){i.command("vendor").description("Copy the runtime-core actions into .github/actions/ (self-contained repo)").option("--dir <path>","target repo root",".").option("--json","machine-readable output").action(e=>{let t=sr(e.dir);if(e.json)return J({written:t});for(let r of t)process.stdout.write(U.default.green(`vendored ${r}
83
- `));process.stdout.write(U.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
84
- `))}),i.command("skill").description("Install the Claude skill (Socratic setup) into .claude/skills/gp-foundry/").option("--user","install for all projects (~/.claude/skills/) instead of this repo").option("--dir <path>","target repo root (project mode)",".").option("--json","machine-readable output").action(e=>{let t=process.env.HOME??process.env.USERPROFILE??".",r=e.user?(0,G.join)(t,".claude/skills/gp-foundry"):(0,G.join)(e.dir,".claude/skills/gp-foundry");if(So(r),e.json)return J({installed:r});process.stdout.write(U.default.green(`installed skill \u2192 ${r}
85
- `)),process.stdout.write(U.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
79
+ `)}`}P();var os=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),ss=new Set(["role","prompt","policy","tools"]);function as(i){let e=[],n=[],r=1,o=0,s=i;for(;o<s.length;){let u=s[o];if(u===`
80
+ `){r++,o++;continue}if(u===" "||u===" "||u==="\r"){o++;continue}if(u==="/"&&s[o+1]==="/"){for(;o<s.length&&s[o]!==`
81
+ `;)o++;continue}if(u==="/"&&s[o+1]==="*"){for(o+=2;o<s.length&&!(s[o]==="*"&&s[o+1]==="/");)s[o]===`
82
+ `&&r++,o++;o+=2;continue}if(u==="-"&&s[o+1]===">"){e.push({kind:"arrow",value:"->",line:r}),o+=2;continue}if(u==="{"){e.push({kind:"lbrace",value:u,line:r}),o++;continue}if(u==="}"){e.push({kind:"rbrace",value:u,line:r}),o++;continue}if(u==="["){e.push({kind:"lbrack",value:u,line:r}),o++;continue}if(u==="]"){e.push({kind:"rbrack",value:u,line:r}),o++;continue}if(u==="="){e.push({kind:"eq",value:u,line:r}),o++;continue}if(u===","){e.push({kind:"comma",value:u,line:r}),o++;continue}if(u===";"){e.push({kind:"semi",value:u,line:r}),o++;continue}if(u==='"'){let p=o+1,a="";for(;p<s.length&&s[p]!=='"';){if(s[p]==="\\"&&p+1<s.length){a+=s[p+1],p+=2;continue}s[p]===`
83
+ `&&r++,a+=s[p],p++}p>=s.length&&n.push({message:"unterminated string",line:r}),e.push({kind:"id",value:a,line:r}),o=p+1;continue}if(/[A-Za-z0-9_]/.test(u)){let p=o,a="";for(;p<s.length&&/[A-Za-z0-9_.\-]/.test(s[p]);)a+=s[p],p++;e.push({kind:"id",value:a,line:r}),o=p;continue}n.push({message:`unexpected character '${u}'`,line:r}),o++}return{toks:e,errors:n}}function ls(i){return i==="true"?!0:i==="false"?!1:/^-?\d+$/.test(i)?Number(i):i}function bn(i){let{toks:e,errors:n}=as(i),r=[],o=[],s=new Map,u="harness",p=0,a=()=>e[p],l=()=>e[p++],d=(w,k)=>n.push({message:w,line:k});a()?.kind==="id"&&a()?.value==="digraph"?(l(),a()?.kind==="id"&&a()?.value!==void 0&&(u=l().value),a()?.kind==="lbrace"?l():d("expected '{' after digraph header",a()?.line)):d("expected 'digraph' keyword",a()?.line);function f(){let w={};if(a()?.kind!=="lbrack")return{attrs:w};let k=l().line;for(;a()&&a().kind!=="rbrack";){let H=l();if(!H||H.kind!=="id"){d("expected attribute name",H?.line);break}if(a()?.kind!=="eq"){d(`expected '=' after attribute '${H.value}'`,H.line);break}l();let N=l();if(!N||N.kind!=="id"){d(`expected value for attribute '${H.value}'`,N?.line);break}w[H.value]=N.value,a()?.kind==="comma"&&l()}return a()?.kind==="rbrack"?l():d("unterminated attribute list '['",k),{attrs:w,line:k}}function m(w,k){let H=s.get(w);return H||(H={id:w,type:"analyst",attrs:{},files:{},raw:{},line:k},s.set(w,H),r.push(H)),H}function A(w,k,H){w.declared=!0,w.raw={...w.raw,...k},H!==void 0&&(w.line=w.line??H);for(let[N,M]of Object.entries(k))N==="type"?(os.has(M)||d(`unknown node type '${M}' on node '${w.id}'`,H),w.type=M):N==="context"?w.context=M:ss.has(N)?w.files[N]=M:w.attrs[N]=ls(M)}let C=0;for(;a()&&a().kind!=="rbrace"&&!(C++>1e5);){let w=a();if(w.kind==="semi"){l();continue}if(w.kind!=="id"){d(`unexpected token '${w.value}'`,w.line),l();continue}let k=l();if(a()?.kind==="arrow"){let H=[{id:k.value,line:k.line}];for(;a()?.kind==="arrow";){l();let L=l();if(!L||L.kind!=="id"){d("expected node id after '->'",L?.line);break}H.push({id:L.value,line:L.line})}let{attrs:N,line:M}=f();for(let L=0;L+1<H.length;L++){let z=H[L],se=H[L+1];m(z.id,z.line),m(se.id,se.line);let le={from:z.id,to:se.id,raw:{...N},line:M??z.line};N.on!==void 0&&(le.on=N.on),N.when!==void 0&&(le.when=N.when),N.do!==void 0&&(le.do=N.do),o.push(le)}}else{let{attrs:H,line:N}=f(),M=m(k.value,k.line);A(M,H,N??k.line)}a()?.kind==="semi"&&l()}return a()?.kind==="rbrace"&&l(),{name:u,nodes:r,edges:o,errors:n}}P();var yn=require("fs");var Ze={name:"harness",identity:{},agent:{cli:"claude",model:"claude-opus-4-8",oauth_token_secret:"CLAUDE_CODE_OAUTH_TOKEN"},repo:{base_branch:"main",branch_prefix:"agent/"},labels:{}};function Yn(i){if(!i||!(0,yn.existsSync)(i))return structuredClone(Ze);let e=Se.load((0,yn.readFileSync)(i,"utf8"))??{};return{...Ze,...e,identity:{...Ze.identity,...e.identity??{}},agent:{...Ze.agent,...e.agent??{}},repo:{...Ze.repo,...e.repo??{}},labels:{...Ze.labels,...e.labels??{}}}}function be(i,e){let n=bn((0,yn.readFileSync)(i,"utf8")),r=Yn(e);return{harness:{name:n.name,nodes:n.nodes,edges:n.edges,config:r,sourcePath:i},parseErrors:n.errors}}function en(i,e={},n={}){let r=[...pn(i,e),...fn(i)],o=Rr(i,Di(i),n.specDir??"");return o.push({path:".github/HARNESS.md",contents:Vn(i),generated:!0}),{files:o,diagnostics:r}}function wn(i){return i.some(e=>e.level==="error")}P();var cs=/^---\r?\n([\s\S]*?)\r?\n---/;function Nr(i){let e=cs.exec(i);if(e)try{let n=Se.load(e[1]);if(n&&typeof n=="object")return n}catch{return}}P();var De=require("fs"),me=require("path"),Hr=require("url"),Fe=Rn(Mn(),1);function _n(i,e){let n=(0,me.join)(i,".github","workflows");if(!(0,De.existsSync)(n))return[];let r=new Set(e.map(o=>o.path));return(0,De.readdirSync)(n).filter(o=>/\.ya?ml$/.test(o)).map(o=>`.github/workflows/${o}`).filter(o=>!r.has(o)).filter(o=>(0,De.readFileSync)((0,me.join)(i,o),"utf8").startsWith(Qt)).sort()}function fe(i){return(0,Hr.fileURLToPath)(new URL(`../../${i}`,G))}function J(i){process.stdout.write(JSON.stringify(i,null,2)+`
84
+ `)}function Zt(i){for(let e of i){let n=e.level==="error"?Fe.default.red("error"):e.level==="warning"?Fe.default.yellow("warn"):Fe.default.blue("info"),r=e.where?.node?Fe.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${n} ${Fe.default.dim(e.code)}${r} ${e.message}
85
+ `),e.hint&&process.stderr.write(` ${Fe.default.dim("hint: "+e.hint)}
86
+ `)}}function ve(i){let e=(0,me.resolve)(i.dot??".github/harness.dot"),n=(0,me.dirname)(e),r=i.config?(0,me.resolve)(i.config):void 0;if(!r){for(let s of[(0,me.join)(n,"foundry.config.yaml"),(0,me.join)(n,"agents/foundry.config.yaml")])if((0,De.existsSync)(s)){r=s;break}}let o=n.endsWith(".github")?(0,me.dirname)(n):n;return{dot:e,config:r,base:n,root:o}}P();var ei=require("child_process"),U=require("fs"),W=require("path");var B=Rn(Mn(),1);var ni=require("path");function nn(i,e={}){try{return{ok:!0,out:(0,ei.execFileSync)("gh",i,{encoding:"utf8",stdio:["ignore","pipe","pipe"],cwd:e.cwd}).trim()}}catch(n){return{ok:!1,out:n.stderr?.toString().trim()??String(n.message)}}}function Re(i,e){let n=nn(i,{cwd:e});if(!n.ok)return null;try{return JSON.parse(n.out)}catch{return null}}function Fr(){let i=fe("actions");return(0,U.readdirSync)(i,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(0,U.existsSync)((0,W.join)(i,e.name,"action.yml"))).map(e=>e.name)}function Dr(i){let e=Yn(i),n=new Map([["build","ready to implement"],["plan","needs design first"]]),r=[];for(let[o,s]of n)r.push({name:e.labels?.[o]??o,description:s,color:o==="build"?"0e8a16":"5319e7"});return r.push({name:"needs-human",description:"agents are blocked; a human should take over",color:"b60205"}),r.push({name:"needs-rebase",description:"PR conflicts with base; the janitor sweep rebases it",color:"d93f0b"}),r}function Ir(i){let e={ok:B.default.green("\u2713"),warn:B.default.yellow("!"),fail:B.default.red("\u2717"),skip:B.default.dim("-")};for(let n of i)process.stdout.write(`${e[n.status]} ${n.name.padEnd(28)} ${n.detail}
87
+ `),n.hint&&n.status!=="ok"&&process.stdout.write(` ${B.default.dim("hint: "+n.hint)}
88
+ `)}function us(i,e){let n=i.nodes.filter(r=>r.type==="merge-gate");return n.length===0?!1:n.some(r=>{if(!r.files.policy)return!0;let o=(0,W.dirname)(i.sourcePath??""),s=(0,W.join)(e,o,r.files.policy);if(!(0,U.existsSync)(s))return!0;try{let u=Se.load((0,U.readFileSync)(s,"utf8"));return(u?.require_ci??u?.requireCi)!==!1}catch{return!0}})}function Pr(i){let e=[];for(let r of Fr()){let o=fe(`actions/${r}`),s=(0,W.join)(i,".github/actions",r);(0,U.mkdirSync)(s,{recursive:!0}),(0,U.cpSync)((0,W.join)(o,"action.yml"),(0,W.join)(s,"action.yml")),(0,U.existsSync)((0,W.join)(o,"dist"))&&(0,U.cpSync)((0,W.join)(o,"dist"),(0,W.join)(s,"dist"),{recursive:!0}),e.push(`.github/actions/${r}/`)}let n=(0,W.join)(i,".github/agent-setup/action.yml");return(0,U.existsSync)(n)||((0,U.mkdirSync)((0,W.dirname)(n),{recursive:!0}),(0,U.writeFileSync)(n,(0,U.readFileSync)(fe("skill/templates/agent-setup.yml"),"utf8")),e.push(".github/agent-setup/action.yml")),e}function ds(i){(0,U.mkdirSync)(i,{recursive:!0}),(0,U.cpSync)(fe("skill/SKILL.md"),(0,W.join)(i,"SKILL.md")),(0,U.cpSync)(fe("skill/reference"),(0,W.join)(i,"reference"),{recursive:!0}),(0,U.cpSync)(fe("skill/templates"),(0,W.join)(i,"templates"),{recursive:!0})}function Mr(i){let e=[],{dot:n,config:r,base:o,root:s}=ve(i);if(!(0,U.existsSync)(n))return e.push({name:"harness",status:"fail",detail:`no harness.dot at ${n}`,hint:"run `gp-foundry init`"}),{checks:e,failed:!0};let{harness:u,parseErrors:p}=be(n,r),a=j=>(0,U.existsSync)((0,W.join)(o,j)),l=(0,ni.relative)(s,o).replace(/\\/g,"/"),{files:d,diagnostics:f}=en(u,{fileExists:a},{specDir:l}),m=f.filter(j=>j.level==="error").length+p.length,A=f.filter(j=>j.level==="warning");e.push(m?{name:"validate",status:"fail",detail:`${m} error(s)`,hint:"run `gp-foundry validate` for details"}:{name:"validate",status:A.length?"warn":"ok",detail:A.length?`${A.length} warning(s): ${A.map(j=>j.code).join(", ")}`:"no diagnostics"});let C=d.filter(j=>{let ce=(0,W.join)(s,j.path);return((0,U.existsSync)(ce)?(0,U.readFileSync)(ce,"utf8"):null)!==j.contents}),w=_n(s,d),k=[...C.map(j=>j.path),...w.map(j=>`${j} (stale)`)];if(e.push(k.length?{name:"workflows in sync",status:"fail",detail:`${k.length} file(s) out of sync: ${k.slice(0,3).join(", ")}${k.length>3?", \u2026":""}`,hint:"run `gp-foundry build`"}:{name:"workflows in sync",status:"ok",detail:`${d.length} generated files match`}),(u.config.runtime?.mode??"pinned")==="vendored"){let j=Fr().filter(ce=>!(0,U.existsSync)((0,W.join)(s,".github/actions",ce,"action.yml")));e.push(j.length?{name:"vendored actions",status:"fail",detail:`missing: ${j.join(", ")}`,hint:"run `gp-foundry vendor`"}:{name:"vendored actions",status:"ok",detail:"all runtime actions vendored"})}if(e.push((0,U.existsSync)((0,W.join)(s,".github/agent-setup/action.yml"))?{name:"agent-setup shim",status:"ok",detail:".github/agent-setup/action.yml present"}:{name:"agent-setup shim",status:"fail",detail:"missing \u2014 every agent job needs it",hint:"run `gp-foundry vendor` (or `init`)"}),!nn(["auth","status"]).ok)return e.push({name:"gh cli",status:"skip",detail:"gh missing or unauthenticated \u2014 skipping repo checks",hint:"install GitHub CLI and `gh auth login`"}),{checks:e,failed:e.some(j=>j.status==="fail")};e.push({name:"gh cli",status:"ok",detail:"authenticated"});let N=Re(["repo","view","--json","nameWithOwner,defaultBranchRef"],s);if(!N)return e.push({name:"github repo",status:"skip",detail:"not a GitHub repo (or no remote) \u2014 skipping labels/secrets checks",hint:"create it with `gh repo create`, then re-run `gp-foundry up` to create labels"}),{checks:e,failed:e.some(j=>j.status==="fail")};e.push({name:"github repo",status:"ok",detail:N.nameWithOwner});let M=N.defaultBranchRef?.name;M&&e.push(M===u.config.repo.base_branch?{name:"base branch",status:"ok",detail:M}:{name:"base branch",status:"fail",detail:`config says '${u.config.repo.base_branch}' but the repo default is '${M}'`,hint:"fix repo.base_branch in foundry.config.yaml and re-run `gp-foundry up`"});let L=new Set((Re(["label","list","--json","name","--limit","1000"],s)??[]).map(j=>j.name)),z=Dr(r).map(j=>j.name),se=z.filter(j=>!L.has(j));e.push(se.length?{name:"labels",status:"fail",detail:`missing: ${se.join(", ")}`,hint:"run `gp-foundry up` to create them"}:{name:"labels",status:"ok",detail:z.join(", ")});let le=new Set((Re(["secret","list","--json","name"],s)??[]).map(j=>j.name)),ee=[u.config.agent.api_key_secret||(u.config.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")],ae=u.config.auth;ae?.mode==="pat"&&ae.token_secret&&ee.push(ae.token_secret),ae?.mode==="app"&&ee.push(ae.app_id_secret??"APP_ID",ae.app_key_secret??"APP_PRIVATE_KEY");let ge=ee.filter(j=>!le.has(j));if(e.push(ge.length?{name:"secrets",status:"fail",detail:`missing: ${ge.join(", ")}`,hint:`gh secret set ${ge[0]}`}:{name:"secrets",status:"ok",detail:ee.join(", ")}),us(u,s)){let ce=d.filter(ie=>/\/workflows\/.*\.yml$/.test(ie.path)&&ie.contents.includes("actions/merge-gate")).map(ie=>(0,W.join)(s,ie.path)).filter(ie=>(0,U.existsSync)(ie)).map(ie=>(0,U.readFileSync)(ie,"utf8")),Z=ce.filter(ie=>!ie.includes("checks-token"));ce.length&&Z.length&&e.push({name:"merge gate ci read",status:"fail",detail:`${Z.length} merge-gate workflow(s) read check-runs with the harness token`,hint:"a fine-grained PAT cannot be granted the Checks permission, so that read 403s and nothing merges \u2014 run `gp-foundry build` to pass GITHUB_TOKEN instead, then commit"})}let he=nn(["--version"]);try{let j=(0,ei.execFileSync)("git",["status","--porcelain",".github"],{cwd:s,encoding:"utf8"}).trim();e.push(j?{name:"committed",status:"warn",detail:".github/ has uncommitted changes",hint:"commit + push so GitHub picks them up"}:{name:"committed",status:"ok",detail:".github/ clean"})}catch{e.push({name:"committed",status:"skip",detail:"not a git repo"})}return{checks:e,failed:e.some(j=>j.status==="fail")}}function ps(i){let{dot:e,config:n,root:r}=ve(i);if(!nn(["auth","status"]).ok)return{error:"gh missing or unauthenticated \u2014 status needs the GitHub CLI",hint:"install the GitHub CLI and run `gh auth login`"};let o=Re(["repo","view","--json","nameWithOwner"],r);if(!o)return{error:"not a GitHub repo (or no remote)",hint:"create it with `gh repo create`, push, then re-run `gp-foundry status`"};let{harness:s}=be(e,n),u=s.config.repo.branch_prefix,p=Date.now(),a=k=>Math.round((p-Date.parse(k))/36e5),l={};for(let k of["plan","build","needs-human"]){let H=k==="needs-human"?"needs-human":s.config.labels?.[k]??k,N=Re(["issue","list","--label",H,"--state","open","--json","number,title,createdAt","--limit","50"],r)??[];l[H]=N.map(M=>({number:M.number,title:M.title,ageHours:a(M.createdAt)}))}let f=(Re(["pr","list","--state","open","--json","number,title,labels,mergeable,headRefName,body,updatedAt","--limit","50"],r)??[]).filter(k=>k.headRefName.startsWith(u)),m=[],A=new Set;for(let k of f)for(let H of k.body?.matchAll(/[Cc]loses #(\d+)/g)??[])A.add(Number(H[1]));let C=s.config.labels?.build??"build";for(let k of l[C]??[])!A.has(k.number)&&k.ageHours>=2&&m.push({kind:"issue-no-pr",number:k.number,title:k.title,detail:`labeled ${C} ${k.ageHours}h ago, no open PR closes it`});for(let k of f)k.updatedAt&&a(k.updatedAt)>=4&&m.push({kind:"pr-idle",number:k.number,title:k.title,detail:`no activity for ${a(k.updatedAt)}h`});let w=(Re(["run","list","--status","failure","--limit","15","--json","name,url,createdAt,conclusion"],r)??[]).filter(k=>a(k.createdAt)<=24).map(k=>({workflow:k.name,url:k.url,ageHours:a(k.createdAt)}));return{repo:o.nameWithOwner,lanes:l,prs:f.map(k=>({number:k.number,title:k.title,labels:k.labels.map(H=>H.name),mergeable:k.mergeable,headRefName:k.headRefName})),stalled:m,recentFailures:w}}function jr(i){i.command("vendor").description("Copy the runtime-core actions into .github/actions/ (self-contained repo)").option("--dir <path>","target repo root",".").option("--json","machine-readable output").action(e=>{let n=Pr(e.dir);if(e.json)return J({written:n});for(let r of n)process.stdout.write(B.default.green(`vendored ${r}
89
+ `));process.stdout.write(B.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
90
+ `))}),i.command("skill").description("Install the Claude skill (Socratic setup) into .claude/skills/gp-foundry/").option("--user","install for all projects (~/.claude/skills/) instead of this repo").option("--dir <path>","target repo root (project mode)",".").option("--json","machine-readable output").action(e=>{let n=process.env.HOME??process.env.USERPROFILE??".",r=e.user?(0,W.join)(n,".claude/skills/gp-foundry"):(0,W.join)(e.dir,".claude/skills/gp-foundry");if(ds(r),e.json)return J({installed:r});process.stdout.write(B.default.green(`installed skill \u2192 ${r}
91
+ `)),process.stdout.write(B.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
86
92
  The skill interviews you Socratically, drafts harness.dot + roles, and drives this CLI.
87
- `))}),i.command("doctor").description("Preflight the factory: config, drift, vendored actions, gh auth, labels, secrets").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{checks:t,failed:r}=ar(e);e.json?J({ok:!r,checks:t}):(or(t),process.stdout.write(r?U.default.red(`
93
+ `))}),i.command("doctor").description("Preflight the factory: config, drift, vendored actions, gh auth, labels, secrets").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{checks:n,failed:r}=Mr(e);e.json?J({ok:!r,checks:n}):(Ir(n),process.stdout.write(r?B.default.red(`
88
94
  not ready \u2014 fix the \u2717 items above
89
- `):U.default.green(`
95
+ `):B.default.green(`
90
96
  factory is ready
91
- `))),process.exit(r?1:0)}),i.command("status").description("Factory dashboard: work in flight, stalled items, recent failures").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let t=vo(e);if("error"in t&&(e.json?J(t):(process.stderr.write(U.default.red(t.error+`
92
- `)),t.hint&&process.stderr.write(U.default.dim("hint: "+t.hint+`
93
- `))),process.exit(1)),e.json)return J(t);process.stdout.write(U.default.bold(`
94
- ${t.repo} \u2014 factory status
97
+ `))),process.exit(r?1:0)}),i.command("status").description("Factory dashboard: work in flight, stalled items, recent failures").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let n=ps(e);if("error"in n&&(e.json?J(n):(process.stderr.write(B.default.red(n.error+`
98
+ `)),n.hint&&process.stderr.write(B.default.dim("hint: "+n.hint+`
99
+ `))),process.exit(1)),e.json)return J(n);process.stdout.write(B.default.bold(`
100
+ ${n.repo} \u2014 factory status
95
101
 
96
- `));for(let[r,o]of Object.entries(t.lanes)){process.stdout.write(U.default.cyan(`${r} (${o.length})
97
- `));for(let s of o.slice(0,10))process.stdout.write(` #${s.number} ${s.title} ${U.default.dim(`(${s.ageHours}h)`)}
98
- `)}process.stdout.write(U.default.cyan(`
99
- agent PRs (${t.prs.length})
100
- `));for(let r of t.prs)process.stdout.write(` #${r.number} ${r.title} ${U.default.dim(r.mergeable??"")} ${r.labels.length?U.default.yellow(r.labels.join(",")):""}
101
- `);if(t.stalled.length){process.stdout.write(U.default.red(`
102
- stalled (${t.stalled.length})
103
- `));for(let r of t.stalled)process.stdout.write(` #${r.number} ${r.title} \u2014 ${r.detail}
104
- `)}if(t.recentFailures.length){process.stdout.write(U.default.red(`
105
- failed runs, last 24h (${t.recentFailures.length})
106
- `));for(let r of t.recentFailures.slice(0,10))process.stdout.write(` ${r.workflow} ${U.default.dim(`${r.ageHours}h ago`)} ${r.url}
107
- `)}!t.stalled.length&&!t.recentFailures.length&&process.stdout.write(U.default.green(`
102
+ `));for(let[r,o]of Object.entries(n.lanes)){process.stdout.write(B.default.cyan(`${r} (${o.length})
103
+ `));for(let s of o.slice(0,10))process.stdout.write(` #${s.number} ${s.title} ${B.default.dim(`(${s.ageHours}h)`)}
104
+ `)}process.stdout.write(B.default.cyan(`
105
+ agent PRs (${n.prs.length})
106
+ `));for(let r of n.prs)process.stdout.write(` #${r.number} ${r.title} ${B.default.dim(r.mergeable??"")} ${r.labels.length?B.default.yellow(r.labels.join(",")):""}
107
+ `);if(n.stalled.length){process.stdout.write(B.default.red(`
108
+ stalled (${n.stalled.length})
109
+ `));for(let r of n.stalled)process.stdout.write(` #${r.number} ${r.title} \u2014 ${r.detail}
110
+ `)}if(n.recentFailures.length){process.stdout.write(B.default.red(`
111
+ failed runs, last 24h (${n.recentFailures.length})
112
+ `));for(let r of n.recentFailures.slice(0,10))process.stdout.write(` ${r.workflow} ${B.default.dim(`${r.ageHours}h ago`)} ${r.url}
113
+ `)}!n.stalled.length&&!n.recentFailures.length&&process.stdout.write(B.default.green(`
108
114
  no stalled work, no recent failures
109
- `))}),i.command("up").description("Bring the factory up: create labels, vendor actions, build workflows, run doctor").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{dot:t,config:r,base:o,root:s}=ke(e),a={};if(Ve(["auth","status"]).ok&&Oe(["repo","view","--json","nameWithOwner"],s)){let S=[];for(let v of cr(r))Ve(["label","create",v.name,"--color",v.color,"--description",v.description],{cwd:s}).ok&&S.push(v.name);a.labels=S,e.json||process.stdout.write(U.default.green(`labels ensured (created: ${S.length?S.join(", "):"none \u2014 already present"})
110
- `))}else a.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(U.default.yellow("skipped label creation (gh unavailable or no GitHub repo yet) \u2014 re-run `gp-foundry up` once the repo exists\n"));let{harness:d}=pe(t,r);(d.config.runtime?.mode??"pinned")==="vendored"&&(a.vendored=sr(s),e.json||process.stdout.write(U.default.green(`vendored ${a.vendored.length} runtime action(s)
111
- `)));let u=S=>(0,B.existsSync)((0,G.join)(o,S)),c=(0,It.relative)(s,o).replace(/\\/g,"/"),{files:p,diagnostics:m}=Ue(d,{fileExists:u},{specDir:c});ln(m)&&(e.json?J({ok:!1,diagnostics:m}):process.stderr.write(U.default.red("build errors \u2014 run `gp-foundry validate` for details\n")),process.exit(1));for(let S of p){let v=(0,G.join)(s,S.path);(0,B.mkdirSync)((0,G.dirname)(v),{recursive:!0}),(0,B.writeFileSync)(v,S.contents)}a.wrote=p.map(S=>S.path);let g=p.filter(S=>S.path.startsWith(".github/workflows/")).length;e.json||process.stdout.write(U.default.green(`built ${g} workflows + HARNESS.md
112
- `));let{checks:k,failed:$}=ar(e);if(a.checks=k,a.ok=!$,e.json)return J(a);process.stdout.write(`
113
- `),or(k),process.stdout.write($?U.default.yellow(`
115
+ `))}),i.command("up").description("Bring the factory up: create labels, vendor actions, build workflows, run doctor").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{dot:n,config:r,base:o,root:s}=ve(e),u={};if(nn(["auth","status"]).ok&&Re(["repo","view","--json","nameWithOwner"],s)){let k=[];for(let H of Dr(r))nn(["label","create",H.name,"--color",H.color,"--description",H.description],{cwd:s}).ok&&k.push(H.name);u.labels=k,e.json||process.stdout.write(B.default.green(`labels ensured (created: ${k.length?k.join(", "):"none \u2014 already present"})
116
+ `))}else u.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(B.default.yellow("skipped label creation (gh unavailable or no GitHub repo yet) \u2014 re-run `gp-foundry up` once the repo exists\n"));let{harness:p}=be(n,r);(p.config.runtime?.mode??"pinned")==="vendored"&&(u.vendored=Pr(s),e.json||process.stdout.write(B.default.green(`vendored ${u.vendored.length} runtime action(s)
117
+ `)));let a=k=>(0,U.existsSync)((0,W.join)(o,k)),l=(0,ni.relative)(s,o).replace(/\\/g,"/"),{files:d,diagnostics:f}=en(p,{fileExists:a},{specDir:l});wn(f)&&(e.json?J({ok:!1,diagnostics:f}):process.stderr.write(B.default.red("build errors \u2014 run `gp-foundry validate` for details\n")),process.exit(1));for(let k of d){let H=(0,W.join)(s,k.path);(0,U.mkdirSync)((0,W.dirname)(H),{recursive:!0}),(0,U.writeFileSync)(H,k.contents)}u.wrote=d.map(k=>k.path);let m=_n(s,d);for(let k of m)(0,U.rmSync)((0,W.join)(s,k));u.removed=m,m.length&&!e.json&&process.stdout.write(B.default.yellow(`removed ${m.length} stale generated workflow(s): ${m.join(", ")}
118
+ `));let A=d.filter(k=>k.path.startsWith(".github/workflows/")).length;e.json||process.stdout.write(B.default.green(`built ${A} workflows + HARNESS.md
119
+ `));let{checks:C,failed:w}=Mr(e);if(u.checks=C,u.ok=!w,e.json)return J(u);process.stdout.write(`
120
+ `),Ir(C),process.stdout.write(w?B.default.yellow(`
114
121
  almost there \u2014 fix the \u2717 items above, commit .github/, push, then file an issue
115
- `):U.default.green(`
122
+ `):B.default.green(`
116
123
  factory is up \u2014 commit .github/, push, then file an issue to watch it run
117
- `)),process.exit($?1:0)})}var $e=new zt,Oo=JSON.parse((0,Y.readFileSync)(ue("package.json"),"utf8")).version;$e.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(Oo);function $o(i,e){let t=new Map;for(let r of i.nodes){if(!r.files.role)continue;let o=(0,ne.join)(e,r.files.role);if((0,Y.existsSync)(o)){let s=tr((0,Y.readFileSync)(o,"utf8"));s&&t.set(r.id,s)}}return t}var To=[["skill/templates/harness.dot",".github/harness.dot"],["skill/templates/foundry.config.yaml",".github/agents/foundry.config.yaml"],["skill/templates/scope.yaml",".github/agents/scope.yaml"],["skill/templates/policy-merge.yaml",".github/agents/policy/merge.yaml"],["skill/templates/communication.md",".github/agents/communication.md"],["skill/templates/agent-setup.yml",".github/agent-setup/action.yml"]];$e.command("init").description("Scaffold a starter harness (harness.dot + config + roles + scope + policy) into a repo").option("--dir <path>","target repo root",".").option("--force","overwrite existing files").option("--json","machine-readable output").action(i=>{let e=(0,ne.resolve)(i.dir),t=[],r=[],o=(d,u)=>{let c=(0,ne.join)(e,d);if((0,Y.existsSync)(c)&&!i.force){r.push(d);return}(0,Y.mkdirSync)((0,ne.dirname)(c),{recursive:!0}),(0,Y.writeFileSync)(c,u),t.push(d)},s="main";try{let d=(0,dr.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();d&&(s=d)}catch{}for(let[d,u]of To){let c=(0,Y.readFileSync)(ue(d),"utf8");u.endsWith("foundry.config.yaml")&&s!=="main"&&(c=c.replace(/^(\s*base_branch:\s*)main\b/m,`$1${s}`)),o(u,c)}let a=(0,ne.join)(e,".github/harness.dot");if((0,Y.existsSync)(a))for(let d of sn((0,Y.readFileSync)(a,"utf8")).nodes){if(!d.files.role)continue;let u=d.files.role.replace(/^.*\//,"").replace(/\.md$/,""),c=ue(`roles/software/${u}.md`),p=(0,Y.existsSync)(c)?c:ue("skill/templates/role.md");o((0,ne.join)(".github",d.files.role),(0,Y.readFileSync)(p,"utf8"))}if(i.json)return J({written:t,skipped:r});for(let d of t)process.stdout.write(Q.default.green(`created ${d}
118
- `));for(let d of r)process.stderr.write(Q.default.yellow(`skipped ${d} (exists; --force to overwrite)
119
- `));process.stdout.write(["",Q.default.bold("Next steps \u2014 dark factory in 4 moves:"),` 1. ${Q.default.cyan("gp-foundry up")} vendor actions, create labels, build workflows, run checks`,` 2. set two secrets: ${Q.default.cyan("gh secret set CLAUDE_CODE_OAUTH_TOKEN")} (agent auth)`,` ${Q.default.cyan("gh secret set AGENT_PAT")} (fine-grained PAT: contents/PRs/issues RW)`,` 3. commit + push ${Q.default.cyan(".github/")}`," 4. file an issue \u2192 the \u{1F575}\uFE0F scout triages it and the factory takes it from there","",Q.default.dim("Tune later: .github/harness.dot (topology) \xB7 agents/roles/*.md (behavior) \xB7 agents/policy/merge.yaml (merge rules)"),""].join(`
120
- `))});$e.command("build").description("Compile harness.dot \u2192 .github/workflows/*.yml (+ HARNESS.md)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--out <dir>","output repo root (default: dir of harness.dot)").option("--check","verify generated files are in sync; exit 1 on drift").option("--dry-run","print what would be written; do not write").option("--force","write even if there are error diagnostics").option("--json","machine-readable output").action(i=>{let{dot:e,config:t,base:r,root:o}=ke(i);(0,Y.existsSync)(e)||(i.json?J({error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e}
121
- `)),process.exit(1));let{harness:s,parseErrors:a}=pe(e,t);if(a.length){if(i.json)J({parseErrors:a});else for(let g of a)process.stderr.write(Q.default.red(`parse: ${g.message}${g.line?` (line ${g.line})`:""}
122
- `));process.exit(1)}let d=(0,ne.resolve)(i.out??o),u=(0,ne.relative)(d,r).replace(/\\/g,"/"),c=g=>(0,Y.existsSync)((0,ne.join)(r,g)),{files:p,diagnostics:m}=Ue(s,{fileExists:c},{specDir:u});if(i.json||Rt(m),i.check){let g=p.filter(k=>{let $=(0,ne.join)(d,k.path);return((0,Y.existsSync)($)?(0,Y.readFileSync)($,"utf8"):null)!==k.contents});if(i.json)J({upToDate:g.length===0,drift:g.map(k=>k.path),diagnostics:m});else if(g.length){for(let k of g)process.stderr.write(Q.default.yellow(`drift: ${k.path}
123
- `));process.stderr.write(Q.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}else process.stdout.write(Q.default.green(`up to date
124
- `));process.exit(g.length?1:0)}if(ln(m)&&!i.force&&(i.json?J({ok:!1,diagnostics:m,wrote:[]}):process.stderr.write(Q.default.red(`errors present \u2014 not writing (use --force to override)
125
- `)),process.exit(1)),i.dryRun){if(i.json)J({diagnostics:m,files:p});else for(let g of p)process.stdout.write(Q.default.cyan(`--- ${g.path}
126
- `)+g.contents+`
127
- `);return}for(let g of p){let k=(0,ne.join)(d,g.path);(0,Y.mkdirSync)((0,ne.dirname)(k),{recursive:!0}),(0,Y.writeFileSync)(k,g.contents),i.json||process.stdout.write(Q.default.green(`wrote ${g.path}
128
- `))}i.json&&J({ok:!ln(m),diagnostics:m,wrote:p.map(g=>g.path)})});$e.command("validate").description("Validate the harness (structural + files + role handoffs + topology)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(i=>{let{dot:e,config:t,base:r}=ke(i);(0,Y.existsSync)(e)||(i.json?J({ok:!1,error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
129
- `)),process.exit(1));let{harness:o,parseErrors:s}=pe(e,t),a=p=>(0,Y.existsSync)((0,ne.join)(r,p)),d=$o(o,r),u=[...en(o,{fileExists:a,roles:d}),...nn(o)],c=u.some(p=>p.level==="error")||s.length>0;if(i.json)J({ok:!c,parseErrors:s,diagnostics:u});else{for(let p of s)process.stderr.write(Q.default.red(`parse: ${p.message}
130
- `));Rt(u)}process.exit(c?1:0)});$e.command("graph").description("Print the harness topology (Mermaid, or --json for the IR)").option("--dot <path>","path to harness.dot").option("--json","output the parsed nodes/edges as JSON").action(i=>{let{dot:e}=ke(i);(0,Y.existsSync)(e)||(i.json?J({error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
131
- `)),process.exit(1));let{harness:t}=pe(e);i.json?J({name:t.name,nodes:t.nodes,edges:t.edges}):process.stdout.write(Mn(t)+`
132
- `)});$e.command("explain <node>").description("Show the workflow a single node compiles to").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action((i,e)=>{let{dot:t,config:r}=ke(e);(0,Y.existsSync)(t)||(e.json?J({error:`no harness.dot at ${t}`}):process.stderr.write(Q.default.red(`no harness.dot at ${t} \u2014 run \`gp-foundry init\` first
133
- `)),process.exit(1));let{harness:o}=pe(t,r),{files:s}=Ue(o),a=s.find(d=>d.path.endsWith(`/${i}.yml`))??s.find(d=>d.path.startsWith(".github/workflows/")&&new RegExp(`^ ${i}:`,"m").test(d.contents));a||(e.json?J({error:`no generated workflow for node '${i}'`}):process.stderr.write(Q.default.red(`no generated workflow for node '${i}'
134
- `)),process.exit(1)),e.json?J({node:i,path:a.path,contents:a.contents}):process.stdout.write(a.contents+`
135
- `)});ur($e);$e.parseAsync(process.argv);
124
+ `)),process.exit(w?1:0)})}var Ne=new bi,fs=JSON.parse((0,V.readFileSync)(fe("package.json"),"utf8")).version;Ne.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(fs);function hs(i,e){let n=new Map;for(let r of i.nodes){if(!r.files.role)continue;let o=(0,ne.join)(e,r.files.role);if((0,V.existsSync)(o)){let s=Nr((0,V.readFileSync)(o,"utf8"));s&&n.set(r.id,s)}}return n}var ms=[["skill/templates/harness.dot",".github/harness.dot"],["skill/templates/foundry.config.yaml",".github/agents/foundry.config.yaml"],["skill/templates/scope.yaml",".github/agents/scope.yaml"],["skill/templates/policy-merge.yaml",".github/agents/policy/merge.yaml"],["skill/templates/communication.md",".github/agents/communication.md"],["skill/templates/agent-setup.yml",".github/agent-setup/action.yml"]];Ne.command("init").description("Scaffold a starter harness (harness.dot + config + roles + scope + policy) into a repo").option("--dir <path>","target repo root",".").option("--force","overwrite existing files").option("--json","machine-readable output").action(i=>{let e=(0,ne.resolve)(i.dir),n=[],r=[],o=(p,a)=>{let l=(0,ne.join)(e,p);if((0,V.existsSync)(l)&&!i.force){r.push(p);return}(0,V.mkdirSync)((0,ne.dirname)(l),{recursive:!0}),(0,V.writeFileSync)(l,a),n.push(p)},s="main";try{let p=(0,Lr.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();p&&(s=p)}catch{}for(let[p,a]of ms){let l=(0,V.readFileSync)(fe(p),"utf8");a.endsWith("foundry.config.yaml")&&s!=="main"&&(l=l.replace(/^(\s*base_branch:\s*)main\b/m,`$1${s}`)),o(a,l)}let u=(0,ne.join)(e,".github/harness.dot");if((0,V.existsSync)(u))for(let p of bn((0,V.readFileSync)(u,"utf8")).nodes){if(!p.files.role)continue;let a=p.files.role.replace(/^.*\//,"").replace(/\.md$/,""),l=fe(`roles/software/${a}.md`),d=(0,V.existsSync)(l)?l:fe("skill/templates/role.md");o((0,ne.join)(".github",p.files.role),(0,V.readFileSync)(d,"utf8"))}if(i.json)return J({written:n,skipped:r});for(let p of n)process.stdout.write(K.default.green(`created ${p}
125
+ `));for(let p of r)process.stderr.write(K.default.yellow(`skipped ${p} (exists; --force to overwrite)
126
+ `));process.stdout.write(["",K.default.bold("Next steps \u2014 dark factory in 4 moves:"),` 1. ${K.default.cyan("gp-foundry up")} vendor actions, create labels, build workflows, run checks`,` 2. set two secrets: ${K.default.cyan("gh secret set CLAUDE_CODE_OAUTH_TOKEN")} (agent auth)`,` ${K.default.cyan("gh secret set AGENT_PAT")} (fine-grained PAT: contents/PRs/issues RW)`,` 3. commit + push ${K.default.cyan(".github/")}`," 4. file an issue \u2192 the \u{1F575}\uFE0F scout triages it and the factory takes it from there","",K.default.dim("Tune later: .github/harness.dot (topology) \xB7 agents/roles/*.md (behavior) \xB7 agents/policy/merge.yaml (merge rules)"),""].join(`
127
+ `))});Ne.command("build").description("Compile harness.dot \u2192 .github/workflows/*.yml (+ HARNESS.md)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--out <dir>","output repo root (default: dir of harness.dot)").option("--check","verify generated files are in sync; exit 1 on drift").option("--dry-run","print what would be written; do not write").option("--force","write even if there are error diagnostics").option("--json","machine-readable output").action(i=>{let{dot:e,config:n,base:r,root:o}=ve(i);(0,V.existsSync)(e)||(i.json?J({error:`no harness.dot at ${e}`}):process.stderr.write(K.default.red(`no harness.dot at ${e}
128
+ `)),process.exit(1));let{harness:s,parseErrors:u}=be(e,n);if(u.length){if(i.json)J({parseErrors:u});else for(let A of u)process.stderr.write(K.default.red(`parse: ${A.message}${A.line?` (line ${A.line})`:""}
129
+ `));process.exit(1)}let p=(0,ne.resolve)(i.out??o),a=(0,ne.relative)(p,r).replace(/\\/g,"/"),l=A=>(0,V.existsSync)((0,ne.join)(r,A)),{files:d,diagnostics:f}=en(s,{fileExists:l},{specDir:a});i.json||Zt(f);let m=_n(p,d);if(i.check){let A=d.filter(w=>{let k=(0,ne.join)(p,w.path);return((0,V.existsSync)(k)?(0,V.readFileSync)(k,"utf8"):null)!==w.contents}),C=A.length===0&&m.length===0;if(i.json)J({upToDate:C,drift:A.map(w=>w.path),stale:m,diagnostics:f});else if(C)process.stdout.write(K.default.green(`up to date
130
+ `));else{for(let w of A)process.stderr.write(K.default.yellow(`drift: ${w.path}
131
+ `));for(let w of m)process.stderr.write(K.default.yellow(`stale: ${w} (no longer generated)
132
+ `));process.stderr.write(K.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}process.exit(C?0:1)}if(wn(f)&&!i.force&&(i.json?J({ok:!1,diagnostics:f,wrote:[]}):process.stderr.write(K.default.red(`errors present \u2014 not writing (use --force to override)
133
+ `)),process.exit(1)),i.dryRun){if(i.json)J({diagnostics:f,files:d,stale:m});else{for(let A of d)process.stdout.write(K.default.cyan(`--- ${A.path}
134
+ `)+A.contents+`
135
+ `);for(let A of m)process.stdout.write(K.default.yellow(`would remove ${A} (no longer generated)
136
+ `))}return}for(let A of d){let C=(0,ne.join)(p,A.path);(0,V.mkdirSync)((0,ne.dirname)(C),{recursive:!0}),(0,V.writeFileSync)(C,A.contents),i.json||process.stdout.write(K.default.green(`wrote ${A.path}
137
+ `))}for(let A of m)(0,V.rmSync)((0,ne.join)(p,A)),i.json||process.stdout.write(K.default.yellow(`removed ${A} (no longer generated)
138
+ `));i.json&&J({ok:!wn(f),diagnostics:f,wrote:d.map(A=>A.path),removed:m})});Ne.command("validate").description("Validate the harness (structural + files + role handoffs + topology)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(i=>{let{dot:e,config:n,base:r}=ve(i);(0,V.existsSync)(e)||(i.json?J({ok:!1,error:`no harness.dot at ${e}`}):process.stderr.write(K.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
139
+ `)),process.exit(1));let{harness:o,parseErrors:s}=be(e,n),u=d=>(0,V.existsSync)((0,ne.join)(r,d)),p=hs(o,r),a=[...pn(o,{fileExists:u,roles:p}),...fn(o)],l=a.some(d=>d.level==="error")||s.length>0;if(i.json)J({ok:!l,parseErrors:s,diagnostics:a});else{for(let d of s)process.stderr.write(K.default.red(`parse: ${d.message}
140
+ `));Zt(a)}process.exit(l?1:0)});Ne.command("graph").description("Print the harness topology (Mermaid, or --json for the IR)").option("--dot <path>","path to harness.dot").option("--json","output the parsed nodes/edges as JSON").action(i=>{let{dot:e}=ve(i);(0,V.existsSync)(e)||(i.json?J({error:`no harness.dot at ${e}`}):process.stderr.write(K.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
141
+ `)),process.exit(1));let{harness:n}=be(e);i.json?J({name:n.name,nodes:n.nodes,edges:n.edges}):process.stdout.write(Vn(n)+`
142
+ `)});Ne.command("explain <node>").description("Show the workflow a single node compiles to").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action((i,e)=>{let{dot:n,config:r}=ve(e);(0,V.existsSync)(n)||(e.json?J({error:`no harness.dot at ${n}`}):process.stderr.write(K.default.red(`no harness.dot at ${n} \u2014 run \`gp-foundry init\` first
143
+ `)),process.exit(1));let{harness:o}=be(n,r),{files:s}=en(o),u=s.find(p=>p.path.endsWith(`/${i}.yml`))??s.find(p=>p.path.startsWith(".github/workflows/")&&new RegExp(`^ ${i}:`,"m").test(p.contents));u||(e.json?J({error:`no generated workflow for node '${i}'`}):process.stderr.write(K.default.red(`no generated workflow for node '${i}'
144
+ `)),process.exit(1)),e.json?J({node:i,path:u.path,contents:u.contents}):process.stdout.write(u.contents+`
145
+ `)});jr(Ne);Ne.parseAsync(process.argv);