@thegpvc/gp-foundry 0.2.13 → 0.2.15

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,147 +1,238 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var Zr=Object.create;var gi=Object.defineProperty;var eo=Object.getOwnPropertyDescriptor;var to=Object.getOwnPropertyNames;var no=Object.getPrototypeOf,io=Object.prototype.hasOwnProperty;var ro=(i,e,t)=>()=>{if(t)throw t[0];try{return i&&(e=i(i=0)),e}catch(r){throw t=[r],r}};var Te=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var oo=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of to(e))!io.call(i,o)&&o!==t&&gi(i,o,{get:()=>e[o],enumerable:!(r=eo(e,o))||r.enumerable});return i};var It=(i,e,t)=>(t=i!=null?Zr(no(i)):{},oo(e||!i||!i.__esModule?gi(t,"default",{value:i,enumerable:!0}):t,i));var so,W,P=ro(()=>{"use strict";so=()=>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,W=so()});var lt=Te(pn=>{"use strict";P();var Ht=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}},dn=class extends Ht{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};pn.CommanderError=Ht;pn.InvalidArgumentError=dn});var Pt=Te(hn=>{"use strict";P();var{InvalidArgumentError:ao}=lt(),fn=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 ao(`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 lo(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}hn.Argument=fn;hn.humanReadableArgName=lo});var gn=Te(bi=>{"use strict";P();var{humanReadableArgName:co}=Pt(),mn=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,a)=>o.name().localeCompare(a.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),a=r.long&&e._findOption(r.long);!o&&!a?t.push(r):r.long&&!a?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(a=>!a.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=>co(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,a=2,c=2;function p(O,y){if(y){let _=`${O.padEnd(r+c)}${y}`;return t.wrap(_,o-a,r+c)}return O}function s(O){return O.join(`
3
- `).replace(/^/gm," ".repeat(a))}let l=[`Usage: ${t.commandUsage(e)}`,""],d=t.commandDescription(e);d.length>0&&(l=l.concat([t.wrap(d,o,0),""]));let f=t.visibleArguments(e).map(O=>p(t.argumentTerm(O),t.argumentDescription(O)));f.length>0&&(l=l.concat(["Arguments:",s(f),""]));let w=t.visibleOptions(e).map(O=>p(t.optionTerm(O),t.optionDescription(O)));if(w.length>0&&(l=l.concat(["Options:",s(w),""])),this.showGlobalOptions){let O=t.visibleGlobalOptions(e).map(y=>p(t.optionTerm(y),t.optionDescription(y)));O.length>0&&(l=l.concat(["Global Options:",s(O),""]))}let m=t.visibleCommands(e).map(O=>p(t.subcommandTerm(O),t.subcommandDescription(O)));return m.length>0&&(l=l.concat(["Commands:",s(m),""])),l.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 a=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",c=new RegExp(`[\\n][${a}]+`);if(e.match(c))return e;let p=t-r;if(p<o)return e;let s=e.slice(0,r),l=e.slice(r).replace(`\r
2
+ "use strict";var yo=Object.create;var xi=Object.defineProperty;var _o=Object.getOwnPropertyDescriptor;var $o=Object.getOwnPropertyNames;var Eo=Object.getPrototypeOf,Ao=Object.prototype.hasOwnProperty;var vo=(n,e,t)=>()=>{if(t)throw t[0];try{return n&&(e=n(n=0)),e}catch(o){throw t=[o],o}};var Pe=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var ko=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of $o(e))!Ao.call(n,s)&&s!==t&&xi(n,s,{get:()=>e[s],enumerable:!(o=_o(e,s))||o.enumerable});return n};var Ut=(n,e,t)=>(t=n!=null?yo(Eo(n)):{},ko(e||!n||!n.__esModule?xi(t,"default",{value:n,enumerable:!0}):t,n));var So,G,I=vo(()=>{"use strict";So=()=>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=So()});var mt=Pe(_n=>{"use strict";I();var Bt=class extends Error{constructor(e,t,o){super(o),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},yn=class extends Bt{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};_n.CommanderError=Bt;_n.InvalidArgumentError=yn});var Gt=Pe(En=>{"use strict";I();var{InvalidArgumentError:Oo}=mt(),$n=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,o)=>{if(!this.argChoices.includes(t))throw new Oo(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,o):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Co(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}En.Argument=$n;En.humanReadableArgName=Co});var vn=Pe(Ri=>{"use strict";I();var{humanReadableArgName:To}=Gt(),An=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(s=>!s._hidden),o=e._getHelpCommand();return o&&!o._hidden&&t.push(o),this.sortSubcommands&&t.sort((s,a)=>s.name().localeCompare(a.name())),t}compareOptions(e,t){let o=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return o(e).localeCompare(o(t))}visibleOptions(e){let t=e.options.filter(s=>!s.hidden),o=e._getHelpOption();if(o&&!o.hidden){let s=o.short&&e._findOption(o.short),a=o.long&&e._findOption(o.long);!s&&!a?t.push(o):o.long&&!a?t.push(e.createOption(o.long,o.description)):o.short&&!s&&t.push(e.createOption(o.short,o.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let o=e.parent;o;o=o.parent){let s=o.options.filter(a=>!a.hidden);t.push(...s)}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(o=>To(o)).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((o,s)=>Math.max(o,t.subcommandTerm(s).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((o,s)=>Math.max(o,t.optionTerm(s).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((o,s)=>Math.max(o,t.optionTerm(s).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((o,s)=>Math.max(o,t.argumentTerm(s).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let o="";for(let s=e.parent;s;s=s.parent)o=s.name()+" "+o;return o+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(o=>JSON.stringify(o)).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(o=>JSON.stringify(o)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let o=`(${t.join(", ")})`;return e.description?`${e.description} ${o}`:o}return e.description}formatHelp(e,t){let o=t.padWidth(e,t),s=t.helpWidth||80,a=2,l=2;function u($,E){if(E){let b=`${$.padEnd(o+l)}${E}`;return t.wrap(b,s-a,o+l)}return $}function p($){return $.join(`
3
+ `).replace(/^/gm," ".repeat(a))}let r=[`Usage: ${t.commandUsage(e)}`,""],d=t.commandDescription(e);d.length>0&&(r=r.concat([t.wrap(d,s,0),""]));let h=t.visibleArguments(e).map($=>u(t.argumentTerm($),t.argumentDescription($)));h.length>0&&(r=r.concat(["Arguments:",p(h),""]));let y=t.visibleOptions(e).map($=>u(t.optionTerm($),t.optionDescription($)));if(y.length>0&&(r=r.concat(["Options:",p(y),""])),this.showGlobalOptions){let $=t.visibleGlobalOptions(e).map(E=>u(t.optionTerm(E),t.optionDescription(E)));$.length>0&&(r=r.concat(["Global Options:",p($),""]))}let m=t.visibleCommands(e).map($=>u(t.subcommandTerm($),t.subcommandDescription($)));return m.length>0&&(r=r.concat(["Commands:",p(m),""])),r.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,o,s=40){let a=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",l=new RegExp(`[\\n][${a}]+`);if(e.match(l))return e;let u=t-o;if(u<s)return e;let p=e.slice(0,o),r=e.slice(o).replace(`\r
5
5
  `,`
6
- `),d=" ".repeat(r),w="\\s\u200B",m=new RegExp(`
7
- |.{1,${p-1}}([${w}]|$)|[^${w}]+?([${w}]|$)`,"g"),O=l.match(m)||[];return s+O.map((y,_)=>y===`
8
- `?"":(_>0?d:"")+y.trimEnd()).join(`
9
- `)}};bi.Help=mn});var _n=Te(wn=>{"use strict";P();var{InvalidArgumentError:uo}=lt(),bn=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=fo(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 uo(`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 po(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},yn=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,a=o!==void 0?o:!1;return t.negate===(a===e)}};function po(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function fo(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}}wn.Option=bn;wn.DualOptions=yn});var wi=Te(yi=>{"use strict";P();function ho(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 a=1;i[o-1]===e[r-1]?a=0:a=1,t[o][r]=Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+a),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 mo(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(c=>c.slice(2)));let r=[],o=3,a=.4;return e.forEach(c=>{if(c.length<=1)return;let p=ho(i,c),s=Math.max(i.length,c.length);(s-p)/s>a&&(p<o?(o=p,r=[c]):p===o&&r.push(c))}),r.sort((c,p)=>c.localeCompare(p)),t&&(r=r.map(c=>`--${c}`)),r.length>1?`
10
- (Did you mean one of ${r.join(", ")}?)`:r.length===1?`
11
- (Did you mean ${r[0]}?)`:""}yi.suggestSimilar=mo});var Ei=Te(ki=>{"use strict";P();var go=require("events").EventEmitter,$n=require("child_process"),ke=require("path"),An=require("fs"),Q=require("process"),{Argument:bo,humanReadableArgName:yo}=Pt(),{CommanderError:kn}=lt(),{Help:wo}=gn(),{Option:_i,DualOptions:_o}=_n(),{suggestSimilar:$i}=wi(),En=class i extends go{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=>Q.stdout.write(t),writeErr:t=>Q.stderr.write(t),getOutHelpWidth:()=>Q.stdout.isTTY?Q.stdout.columns:void 0,getErrHelpWidth:()=>Q.stderr.isTTY?Q.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,a=r;typeof o=="object"&&o!==null&&(a=o,o=null),a=a||{};let[,c,p]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(c);return o&&(s.description(o),s._executableHandler=!0),a.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(a.noHelp||a.hidden),s._executableFile=a.executableFile||null,p&&s.arguments(p),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),o?this:s}createCommand(e){return new i(e)}createHelp(){return Object.assign(new wo,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 bo(e,t)}argument(e,t,r,o){let a=this.createArgument(e,t);return typeof r=="function"?a.default(o).argParser(r):a.default(r),this.addArgument(a),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(/([^ ]+) *(.*)/),a=t??"display help for command",c=this.createCommand(r);return c.helpOption(!1),o&&c.arguments(o),a&&c.description(a),this._addImplicitHelpCommand=!0,this._helpCommand=c,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 kn(e,t,r)),Q.exit(e)}action(e){let t=r=>{let o=this.registeredArguments.length,a=r.slice(0,o);return this._storeOptionsAsProperties?a[o]=this:a[o]=this.opts(),a.push(this),e.apply(this,a)};return this._actionHandler=t,this}createOption(e,t){return new _i(e,t)}_callParseArg(e,t,r,o){try{return e.parseArg(t,r)}catch(a){if(a.code==="commander.invalidArgument"){let c=`${o} ${a.message}`;this.error(c,{exitCode:a.exitCode,code:a.code})}throw a}}_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("|"),a=t(e).join("|");throw new Error(`cannot add command '${a}' 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 a=e.long.replace(/^--no-/,"--");this._findOption(a)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let o=(a,c,p)=>{a==null&&e.presetArg!==void 0&&(a=e.presetArg);let s=this.getOptionValue(r);a!==null&&e.parseArg?a=this._callParseArg(e,a,s,c):a!==null&&e.variadic&&(a=e._concatValue(a,s)),a==null&&(e.negate?a=!1:e.isBoolean()||e.optional?a=!0:a=""),this.setOptionValueWithSource(r,a,p)};return this.on("option:"+t,a=>{let c=`error: option '${e.flags}' argument '${a}' is invalid.`;o(a,c,"cli")}),e.envVar&&this.on("optionEnv:"+t,a=>{let c=`error: option '${e.flags}' value '${a}' from env '${e.envVar}' is invalid.`;o(a,c,"env")}),this}_optionEx(e,t,r,o,a){if(typeof t=="object"&&t instanceof _i)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let c=this.createOption(t,r);if(c.makeOptionMandatory(!!e.mandatory),typeof o=="function")c.default(a).argParser(o);else if(o instanceof RegExp){let p=o;o=(s,l)=>{let d=p.exec(s);return d?d[0]:l},c.default(a).argParser(o)}else c.default(o);return this.addOption(c)}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){Q.versions?.electron&&(t.from="electron");let o=Q.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(t.from="eval")}e===void 0&&(e=Q.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":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: '${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 a(d,f){let w=ke.resolve(d,f);if(An.existsSync(w))return w;if(o.includes(ke.extname(f)))return;let m=o.find(O=>An.existsSync(`${w}${O}`));if(m)return`${w}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let c=e._executableFile||`${this._name}-${e._name}`,p=this._executableDir||"";if(this._scriptPath){let d;try{d=An.realpathSync(this._scriptPath)}catch{d=this._scriptPath}p=ke.resolve(ke.dirname(d),p)}if(p){let d=a(p,c);if(!d&&!e._executableFile&&this._scriptPath){let f=ke.basename(this._scriptPath,ke.extname(this._scriptPath));f!==this._name&&(d=a(p,`${f}-${e._name}`))}c=d||c}r=o.includes(ke.extname(c));let s;Q.platform!=="win32"?r?(t.unshift(c),t=Ai(Q.execArgv).concat(t),s=$n.spawn(Q.argv[0],t,{stdio:"inherit"})):s=$n.spawn(c,t,{stdio:"inherit"}):(t.unshift(c),t=Ai(Q.execArgv).concat(t),s=$n.spawn(Q.execPath,t,{stdio:"inherit"})),s.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{Q.on(f,()=>{s.killed===!1&&s.exitCode===null&&s.kill(f)})});let l=this._exitCallback;s.on("close",d=>{d=d??1,l?l(new kn(d,"commander.executeSubCommandAsync","(close)")):Q.exit(d)}),s.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",w=`'${c}' does not exist
6
+ `),d=" ".repeat(o),y="\\s\u200B",m=new RegExp(`
7
+ |.{1,${u-1}}([${y}]|$)|[^${y}]+?([${y}]|$)`,"g"),$=r.match(m)||[];return p+$.map((E,b)=>E===`
8
+ `?"":(b>0?d:"")+E.trimEnd()).join(`
9
+ `)}};Ri.Help=An});var Cn=Pe(On=>{"use strict";I();var{InvalidArgumentError:xo}=mt(),kn=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 o=No(e);this.short=o.shortFlag,this.long=o.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,o)=>{if(!this.argChoices.includes(t))throw new xo(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,o):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Ro(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Sn=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,o)=>{this.positiveOptions.has(o)&&this.dualOptions.add(o)})}valueFromOption(e,t){let o=t.attributeName();if(!this.dualOptions.has(o))return!0;let s=this.negativeOptions.get(o).presetArg,a=s!==void 0?s:!1;return t.negate===(a===e)}};function Ro(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function No(n){let e,t,o=n.split(/[ |,]+/);return o.length>1&&!/^[[<]/.test(o[1])&&(e=o.shift()),t=o.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}On.Option=kn;On.DualOptions=Sn});var Ii=Pe(Ni=>{"use strict";I();function Io(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let o=0;o<=n.length;o++)t[o]=[o];for(let o=0;o<=e.length;o++)t[0][o]=o;for(let o=1;o<=e.length;o++)for(let s=1;s<=n.length;s++){let a=1;n[s-1]===e[o-1]?a=0:a=1,t[s][o]=Math.min(t[s-1][o]+1,t[s][o-1]+1,t[s-1][o-1]+a),s>1&&o>1&&n[s-1]===e[o-2]&&n[s-2]===e[o-1]&&(t[s][o]=Math.min(t[s][o],t[s-2][o-2]+1))}return t[n.length][e.length]}function Ho(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(l=>l.slice(2)));let o=[],s=3,a=.4;return e.forEach(l=>{if(l.length<=1)return;let u=Io(n,l),p=Math.max(n.length,l.length);(p-u)/p>a&&(u<s?(s=u,o=[l]):u===s&&o.push(l))}),o.sort((l,u)=>l.localeCompare(u)),t&&(o=o.map(l=>`--${l}`)),o.length>1?`
10
+ (Did you mean one of ${o.join(", ")}?)`:o.length===1?`
11
+ (Did you mean ${o[0]}?)`:""}Ni.suggestSimilar=Ho});var Mi=Pe(Di=>{"use strict";I();var Po=require("events").EventEmitter,Tn=require("child_process"),Oe=require("path"),xn=require("fs"),Z=require("process"),{Argument:Lo,humanReadableArgName:Do}=Gt(),{CommanderError:Rn}=mt(),{Help:Mo}=vn(),{Option:Hi,DualOptions:Fo}=Cn(),{suggestSimilar:Pi}=Ii(),Nn=class n extends Po{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=>Z.stdout.write(t),writeErr:t=>Z.stderr.write(t),getOutHelpWidth:()=>Z.stdout.isTTY?Z.stdout.columns:void 0,getErrHelpWidth:()=>Z.stderr.isTTY?Z.stderr.columns:void 0,outputError:(t,o)=>o(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,o){let s=t,a=o;typeof s=="object"&&s!==null&&(a=s,s=null),a=a||{};let[,l,u]=e.match(/([^ ]+) *(.*)/),p=this.createCommand(l);return s&&(p.description(s),p._executableHandler=!0),a.isDefault&&(this._defaultCommandName=p._name),p._hidden=!!(a.noHelp||a.hidden),p._executableFile=a.executableFile||null,u&&p.arguments(u),this._registerCommand(p),p.parent=this,p.copyInheritedSettings(this),s?this:p}createCommand(e){return new n(e)}createHelp(){return Object.assign(new Mo,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 Lo(e,t)}argument(e,t,o,s){let a=this.createArgument(e,t);return typeof o=="function"?a.default(s).argParser(o):a.default(o),this.addArgument(a),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[,o,s]=e.match(/([^ ]+) *(.*)/),a=t??"display help for command",l=this.createCommand(o);return l.helpOption(!1),s&&l.arguments(s),a&&l.description(a),this._addImplicitHelpCommand=!0,this._helpCommand=l,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 o=["preSubcommand","preAction","postAction"];if(!o.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
13
+ Expecting one of '${o.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,o){this._exitCallback&&this._exitCallback(new Rn(e,t,o)),Z.exit(e)}action(e){let t=o=>{let s=this.registeredArguments.length,a=o.slice(0,s);return this._storeOptionsAsProperties?a[s]=this:a[s]=this.opts(),a.push(this),e.apply(this,a)};return this._actionHandler=t,this}createOption(e,t){return new Hi(e,t)}_callParseArg(e,t,o,s){try{return e.parseArg(t,o)}catch(a){if(a.code==="commander.invalidArgument"){let l=`${s} ${a.message}`;this.error(l,{exitCode:a.exitCode,code:a.code})}throw a}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let o=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 '${o}'
14
+ - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=s=>[s.name()].concat(s.aliases()),o=t(e).find(s=>this._findCommand(s));if(o){let s=t(this._findCommand(o)).join("|"),a=t(e).join("|");throw new Error(`cannot add command '${a}' as already have command '${s}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),o=e.attributeName();if(e.negate){let a=e.long.replace(/^--no-/,"--");this._findOption(a)||this.setOptionValueWithSource(o,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(o,e.defaultValue,"default");let s=(a,l,u)=>{a==null&&e.presetArg!==void 0&&(a=e.presetArg);let p=this.getOptionValue(o);a!==null&&e.parseArg?a=this._callParseArg(e,a,p,l):a!==null&&e.variadic&&(a=e._concatValue(a,p)),a==null&&(e.negate?a=!1:e.isBoolean()||e.optional?a=!0:a=""),this.setOptionValueWithSource(o,a,u)};return this.on("option:"+t,a=>{let l=`error: option '${e.flags}' argument '${a}' is invalid.`;s(a,l,"cli")}),e.envVar&&this.on("optionEnv:"+t,a=>{let l=`error: option '${e.flags}' value '${a}' from env '${e.envVar}' is invalid.`;s(a,l,"env")}),this}_optionEx(e,t,o,s,a){if(typeof t=="object"&&t instanceof Hi)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let l=this.createOption(t,o);if(l.makeOptionMandatory(!!e.mandatory),typeof s=="function")l.default(a).argParser(s);else if(s instanceof RegExp){let u=s;s=(p,r)=>{let d=u.exec(p);return d?d[0]:r},l.default(a).argParser(s)}else l.default(s);return this.addOption(l)}option(e,t,o,s){return this._optionEx({},e,t,o,s)}requiredOption(e,t,o,s){return this._optionEx({mandatory:!0},e,t,o,s)}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,o){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=o,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(o=>{o.getOptionValueSource(e)!==void 0&&(t=o.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){Z.versions?.electron&&(t.from="electron");let s=Z.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(t.from="eval")}e===void 0&&(e=Z.argv),this.rawArgs=e.slice();let o;switch(t.from){case void 0:case"node":this._scriptPath=e[1],o=e.slice(2);break;case"electron":Z.defaultApp?(this._scriptPath=e[1],o=e.slice(2)):o=e.slice(1);break;case"user":o=e.slice(0);break;case"eval":o=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",o}parse(e,t){let o=this._prepareUserArgs(e,t);return this._parseCommand([],o),this}async parseAsync(e,t){let o=this._prepareUserArgs(e,t);return await this._parseCommand([],o),this}_executeSubCommand(e,t){t=t.slice();let o=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function a(d,h){let y=Oe.resolve(d,h);if(xn.existsSync(y))return y;if(s.includes(Oe.extname(h)))return;let m=s.find($=>xn.existsSync(`${y}${$}`));if(m)return`${y}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let l=e._executableFile||`${this._name}-${e._name}`,u=this._executableDir||"";if(this._scriptPath){let d;try{d=xn.realpathSync(this._scriptPath)}catch{d=this._scriptPath}u=Oe.resolve(Oe.dirname(d),u)}if(u){let d=a(u,l);if(!d&&!e._executableFile&&this._scriptPath){let h=Oe.basename(this._scriptPath,Oe.extname(this._scriptPath));h!==this._name&&(d=a(u,`${h}-${e._name}`))}l=d||l}o=s.includes(Oe.extname(l));let p;Z.platform!=="win32"?o?(t.unshift(l),t=Li(Z.execArgv).concat(t),p=Tn.spawn(Z.argv[0],t,{stdio:"inherit"})):p=Tn.spawn(l,t,{stdio:"inherit"}):(t.unshift(l),t=Li(Z.execArgv).concat(t),p=Tn.spawn(Z.execPath,t,{stdio:"inherit"})),p.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{Z.on(h,()=>{p.killed===!1&&p.exitCode===null&&p.kill(h)})});let r=this._exitCallback;p.on("close",d=>{d=d??1,r?r(new Rn(d,"commander.executeSubCommandAsync","(close)")):Z.exit(d)}),p.on("error",d=>{if(d.code==="ENOENT"){let h=u?`searched for local subcommand relative to directory '${u}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",y=`'${l}' 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
- - ${f}`;throw new Error(w)}else if(d.code==="EACCES")throw new Error(`'${c}' not executable`);if(!l)Q.exit(1);else{let f=new kn(1,"commander.executeSubCommandAsync","(error)");f.nestedError=d,l(f)}}),this.runningCommand=s}_dispatchSubcommand(e,t,r){let o=this._findCommand(e);o||this.help({error:!0});let a;return a=this._chainOrCallSubCommandHook(a,o,"preSubcommand"),a=this._chainOrCall(a,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(r));else return o._parseCommand(t,r)}),a}_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,a)=>{let c=o;if(o!==null&&r.parseArg){let p=`error: command-argument value '${o}' is invalid for argument '${r.name()}'.`;c=this._callParseArg(r,o,a,p)}return c};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,o)=>{let a=r.defaultValue;r.variadic?o<this.args.length?(a=this.args.slice(o),r.parseArg&&(a=a.reduce((c,p)=>e(r,p,c),r.defaultValue))):a===void 0&&(a=[]):o<this.args.length&&(a=this.args[o],r.parseArg&&(a=e(r,a,r.defaultValue))),t[o]=a}),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(a=>a._lifeCycleHooks[t]!==void 0).forEach(a=>{a._lifeCycleHooks[t].forEach(c=>{o.push({hookedCommand:a,callback:c})})}),t==="postAction"&&o.reverse(),o.forEach(a=>{r=this._chainOrCall(r,()=>a.callback(a.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(a=>{o=this._chainOrCall(o,()=>a(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])},a=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let c;return c=this._chainOrCallHooks(c,"preAction"),c=this._chainOrCall(c,()=>this._actionHandler(this.processedArgs)),this.parent&&(c=this._chainOrCall(c,()=>{this.parent.emit(a,e,t)})),c=this._chainOrCallHooks(c,"postAction"),c}if(this.parent&&this.parent.listenerCount(a))o(),this._processArguments(),this.parent.emit(a,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(a=>r.conflictsWith.includes(a.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],o=t,a=e.slice();function c(s){return s.length>1&&s[0]==="-"}let p=null;for(;a.length;){let s=a.shift();if(s==="--"){o===r&&o.push(s),o.push(...a);break}if(p&&!c(s)){this.emit(`option:${p.name()}`,s);continue}if(p=null,c(s)){let l=this._findOption(s);if(l){if(l.required){let d=a.shift();d===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,d)}else if(l.optional){let d=null;a.length>0&&!c(a[0])&&(d=a.shift()),this.emit(`option:${l.name()}`,d)}else this.emit(`option:${l.name()}`);p=l.variadic?l:null;continue}}if(s.length>2&&s[0]==="-"&&s[1]!=="-"){let l=this._findOption(`-${s[1]}`);if(l){l.required||l.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${l.name()}`,s.slice(2)):(this.emit(`option:${l.name()}`),a.unshift(`-${s.slice(2)}`));continue}}if(/^--[^=]+=/.test(s)){let l=s.indexOf("="),d=this._findOption(s.slice(0,l));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,s.slice(l+1));continue}}if(c(s)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(s)){t.push(s),a.length>0&&r.push(...a);break}else if(this._getHelpCommand()&&s===this._getHelpCommand().name()){t.push(s),a.length>0&&t.push(...a);break}else if(this._defaultCommandName){r.push(s),a.length>0&&r.push(...a);break}}if(this._passThroughOptions){o.push(s),a.length>0&&o.push(...a);break}o.push(s)}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
+ - ${h}`;throw new Error(y)}else if(d.code==="EACCES")throw new Error(`'${l}' not executable`);if(!r)Z.exit(1);else{let h=new Rn(1,"commander.executeSubCommandAsync","(error)");h.nestedError=d,r(h)}}),this.runningCommand=p}_dispatchSubcommand(e,t,o){let s=this._findCommand(e);s||this.help({error:!0});let a;return a=this._chainOrCallSubCommandHook(a,s,"preSubcommand"),a=this._chainOrCall(a,()=>{if(s._executableHandler)this._executeSubCommand(s,t.concat(o));else return s._parseCommand(t,o)}),a}_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=(o,s,a)=>{let l=s;if(s!==null&&o.parseArg){let u=`error: command-argument value '${s}' is invalid for argument '${o.name()}'.`;l=this._callParseArg(o,s,a,u)}return l};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((o,s)=>{let a=o.defaultValue;o.variadic?s<this.args.length?(a=this.args.slice(s),o.parseArg&&(a=a.reduce((l,u)=>e(o,u,l),o.defaultValue))):a===void 0&&(a=[]):s<this.args.length&&(a=this.args[s],o.parseArg&&(a=e(o,a,o.defaultValue))),t[s]=a}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let o=e,s=[];return this._getCommandAndAncestors().reverse().filter(a=>a._lifeCycleHooks[t]!==void 0).forEach(a=>{a._lifeCycleHooks[t].forEach(l=>{s.push({hookedCommand:a,callback:l})})}),t==="postAction"&&s.reverse(),s.forEach(a=>{o=this._chainOrCall(o,()=>a.callback(a.hookedCommand,this))}),o}_chainOrCallSubCommandHook(e,t,o){let s=e;return this._lifeCycleHooks[o]!==void 0&&this._lifeCycleHooks[o].forEach(a=>{s=this._chainOrCall(s,()=>a(this,t))}),s}_parseCommand(e,t){let o=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(o.operands),t=o.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(o.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{o.unknown.length>0&&this.unknownOption(o.unknown[0])},a=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let l;return l=this._chainOrCallHooks(l,"preAction"),l=this._chainOrCall(l,()=>this._actionHandler(this.processedArgs)),this.parent&&(l=this._chainOrCall(l,()=>{this.parent.emit(a,e,t)})),l=this._chainOrCallHooks(l,"postAction"),l}if(this.parent&&this.parent.listenerCount(a))s(),this._processArguments(),this.parent.emit(a,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():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),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(o=>{let s=o.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});e.filter(o=>o.conflictsWith.length>0).forEach(o=>{let s=e.find(a=>o.conflictsWith.includes(a.attributeName()));s&&this._conflictingOption(o,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],o=[],s=t,a=e.slice();function l(p){return p.length>1&&p[0]==="-"}let u=null;for(;a.length;){let p=a.shift();if(p==="--"){s===o&&s.push(p),s.push(...a);break}if(u&&!l(p)){this.emit(`option:${u.name()}`,p);continue}if(u=null,l(p)){let r=this._findOption(p);if(r){if(r.required){let d=a.shift();d===void 0&&this.optionMissingArgument(r),this.emit(`option:${r.name()}`,d)}else if(r.optional){let d=null;a.length>0&&!l(a[0])&&(d=a.shift()),this.emit(`option:${r.name()}`,d)}else this.emit(`option:${r.name()}`);u=r.variadic?r:null;continue}}if(p.length>2&&p[0]==="-"&&p[1]!=="-"){let r=this._findOption(`-${p[1]}`);if(r){r.required||r.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${r.name()}`,p.slice(2)):(this.emit(`option:${r.name()}`),a.unshift(`-${p.slice(2)}`));continue}}if(/^--[^=]+=/.test(p)){let r=p.indexOf("="),d=this._findOption(p.slice(0,r));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,p.slice(r+1));continue}}if(l(p)&&(s=o),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&o.length===0){if(this._findCommand(p)){t.push(p),a.length>0&&o.push(...a);break}else if(this._getHelpCommand()&&p===this._getHelpCommand().name()){t.push(p),a.length>0&&t.push(...a);break}else if(this._defaultCommandName){o.push(p),a.length>0&&o.push(...a);break}}if(this._passThroughOptions){s.push(p),a.length>0&&s.push(...a);break}s.push(p)}return{operands:t,unknown:o}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let o=0;o<t;o++){let s=this.options[o].attributeName();e[s]=s===this._versionOptionName?this._version:this[s]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){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,a=r.code||"commander.error";this._exit(o,a,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in Q.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()}`,Q.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new _o(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=c=>{let p=c.attributeName(),s=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&&s===!1||l.presetArg!==void 0&&s===l.presetArg)?l:d||c},o=c=>{let p=r(c),s=p.attributeName();return this.getOptionValueSource(s)==="env"?`environment variable '${p.envVar}'`:`option '${p.flags}'`},a=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],a=this;do{let c=a.createHelp().visibleOptions(a).filter(p=>p.long).map(p=>p.long);o=o.concat(c),a=a.parent}while(a&&!a._enablePositionalOptions);t=$i(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",a=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(a=>{o.push(a.name()),a.alias()&&o.push(a.alias())}),t=$i(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=>yo(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=ke.basename(e,ke.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(a=>a.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(a=>a.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=Q.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,a=>{let c;typeof t=="function"?c=t({error:a.error,command:a.command}):c=t,c&&a.write(`${c}
23
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(o=>t.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Ai(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",o="9229",a;return(a=e.match(/^(--inspect(-brk)?)$/))!==null?t=a[1]:(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=a[1],/^\d+$/.test(a[3])?o=a[3]:r=a[3]):(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=a[1],r=a[3],o=a[4]),t&&o!=="0"?`${t}=${r}:${parseInt(o)+1}`:e})}ki.Command=En});var Ci=Te(pe=>{"use strict";P();var{Argument:Si}=Pt(),{Command:Sn}=Ei(),{CommanderError:$o,InvalidArgumentError:vi}=lt(),{Help:Ao}=gn(),{Option:xi}=_n();pe.program=new Sn;pe.createCommand=i=>new Sn(i);pe.createOption=(i,e)=>new xi(i,e);pe.createArgument=(i,e)=>new Si(i,e);pe.Command=Sn;pe.Option=xi;pe.Argument=Si;pe.Help=Ao;pe.CommanderError=$o;pe.InvalidArgumentError=vi;pe.InvalidOptionArgumentError=vi});var Mt=Te((sa,vn)=>{"use strict";P();var Lt=process||{},Ri=Lt.argv||[],Ft=Lt.env||{},ko=!(Ft.NO_COLOR||Ri.includes("--no-color"))&&(!!Ft.FORCE_COLOR||Ri.includes("--color")||Lt.platform==="win32"||(Lt.stdout||{}).isTTY&&Ft.TERM!=="dumb"||!!Ft.CI),Eo=(i,e,t=i)=>r=>{let o=""+r,a=o.indexOf(e,i.length);return~a?i+So(o,e,t,a)+e:i+o+e},So=(i,e,t,r)=>{let o="",a=0;do o+=i.substring(a,r)+t,a=r+e.length,r=i.indexOf(e,a);while(~r);return o+i.substring(a)},Ni=(i=ko)=>{let e=i?Eo:()=>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")}};vn.exports=Ni();vn.exports.createColors=Ni});P();P();var Oi=It(Ci(),1),{program:Ks,createCommand:Js,createArgument:Xs,createOption:zs,CommanderError:Qs,InvalidArgumentError:Zs,InvalidOptionArgumentError:ea,Command:Ti,Argument:ta,Option:na,Help:ia}=Oi.default;var J=It(Mt(),1),Qr=require("child_process"),Y=require("fs"),te=require("path");P();P();P();var Ve=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function Ii(i){return i.uses!==void 0}P();function ct(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 xn=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","title","harness_ref","persist_credentials","repo_guides","opt_in_label"]),Cn=new Set(["on","when","do"]);function Hi(i,e){let t=(a,c)=>{let p=Array.from({length:c.length+1},(s,l)=>l);for(let s=1;s<=a.length;s++){let l=p[0];p[0]=s;for(let d=1;d<=c.length;d++){let f=p[d];p[d]=Math.min(p[d]+1,p[d-1]+1,l+(a[s-1]===c[d-1]?0:1)),l=f}}return p[c.length]},r,o=3;for(let a of e){let c=t(i.toLowerCase(),a);c<o&&([r,o]=[a,c])}return r}function On(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 t=[];for(let r of e.split(",").map(o=>o.trim()).filter(Boolean)){let[o,...a]=r.split("?"),c=o.trim();if(!c)throw new Error(`node '${i.id}': gates= entry '${r}' names no workflow or check`);let p={name:c,kind:/\.ya?ml$/i.test(c)?"workflow":"check"};for(let s of a.map(l=>l.trim()))if(s==="info")p.info=!0;else if(/^[1-9]\d*$/.test(s)&&p.graceSeconds===void 0)p.graceSeconds=Number(s);else throw new Error(`node '${i.id}': gates= entry '${r}' has a bad '?${s}' suffix \u2014 expected '?<seconds>' (a whole number >= 1) and/or '?info', e.g. "${c}?90" or "${c}?info"`);t.push(p)}return t}function Pi(i){try{return On(i)}catch{return[]}}function Tn(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 t=[],r=new Set;for(let o of e.split(",").map(a=>a.trim()).filter(Boolean))if(!r.has(o))if(r.add(o),o==="draft"||o==="bot-author"||o==="unchanged-diff")t.push({kind:o});else if(o.startsWith("label:")&&o.slice(6).trim())t.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(!t.length)throw new Error(`node '${i.id}': skip= has no entries`);return t}function Fe(i){try{return Tn(i)}catch{return[]}}var vo=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function Fi(i,e){let t=[];for(let r of i){let o=String(r).trim();if(!o)continue;if(!vo.test(o))throw new Error(`${e}: '${o}' is not a GitHub login`);let a=o.toLowerCase();t.includes(a)||t.push(a)}if(!t.length)throw new Error(`${e}: names no login \u2014 an empty allowlist would match nobody`);return t}function Dt(i){return i.type==="pr-fix"||(i.type==="pr-review"||i.type==="analyst")&&Ee(i)}function jt(i,e){let t=i.attrs.authors;return t!==void 0?Fi(String(t).split(","),`node '${i.id}': authors=`):ut(e)}function ut(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 Fi(e,"repo.authors")}}function Le(i,e){if(Dt(i))try{return jt(i,e)}catch{return[Rn]}}var Rn="no author matches a malformed allowlist";function Li(i,e){let t=i.map(o=>`github.event.pull_request.user.login == '${o}'`),r=t.length===1?t[0]:`(${t.join(" || ")})`;return e===void 0?r:`(${r} || contains(github.event.pull_request.labels.*.name, ${qt(e)}))`}function qt(i){return`'${i.replace(/'/g,"''")}'`}function Nn(i,e){let t=i.attrs.opt_in_label;if(t===void 0)return;if(typeof t!="string"||!t.trim())throw new Error(`node '${i.id}': opt_in_label= must be a label key like "agent_review"`);let r=t.trim();return e.labels?.[r]??r}function dt(i,e){if(Le(i,e)!==void 0)try{return Nn(i,e)}catch{return}}function Ee(i){return i.context==="pr-diff"||i.context==="pr-review"}function Ye(i){return i.attrs.select==="sweep"&&i.type==="pr-review"&&Ee(i)&&i.attrs.schedule!==void 0}function Me(i,e){return(i.type==="pr-review"||i.type==="analyst")&&Ee(i)&&i.attrs.schedule===void 0&&(Fe(i).length>0||Le(i,e)!==void 0)}function Ke(i){return Ye(i)?`${i.id}_select`:`${i.id}_guard`}function Ut(i){return`${i.id} #`}function In(i){return`gp-foundry/sweep-failed (${i.id})`}function Hn(i){return`gp-foundry/swept (${i.id})`}function Bt(i){return`<!-- gp-foundry:diff:${i.id}:`}var Mi="**Verdict:**";P();function Xe(i){return`\${{ secrets.${i} }}`}function Se(i,e){if(!e)return"";let t=i.specDir?.replace(/\/+$/,"");return t?`${t}/${e}`:e}function ce(i){let e=ct(i.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?Xe(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}var xo=new Set(["actions","checks","contents","deployments","issues","packages","pages","pull-requests","security-events","statuses","workflows"]);function Gt(i,e){let t=ct(i.config);if(t.mode!=="app"||!t.appIdSecret||!t.appKeySecret)return;let r={"client-id":Xe(t.appIdSecret),"private-key":Xe(t.appKeySecret)};for(let[o,a]of Object.entries(e??{}))xo.has(o)&&a!=="none"&&(r[`permission-${o}`]=a);return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:r}}var Je=".gp-foundry/harness";function Wt(i,e=!1){return i.attrs.harness_ref==="head"?!1:e||i.type==="pr-fix"||(i.type==="pr-review"||i.type==="analyst")&&Ee(i)}function Vt(i,e){let t=i.config.runtime?.mode==="vendored",r=i.specDir.replace(/\/+$/,""),o=[i.node.files.role,i.node.files.prompt,"agents/scope.yaml","agents/communication.md"].filter(d=>!!d).map(d=>r?`${r}/${d}`:d),a=new Set([".github/agent-setup"]);t&&a.add(".github/actions");for(let d of o){let f=d.includes("/")?d.slice(0,d.lastIndexOf("/")):"";f&&a.add(f)}let c=[...a].sort(),p=c.filter(d=>!c.some(f=>f!==d&&d.startsWith(`${f}/`))),s=[{uses:"actions/checkout@v5",name:"Checkout harness files (base ref)",with:{ref:e,path:Je,"fetch-depth":1,"sparse-checkout":p.join(`
24
- `),token:ce(i),"persist-credentials":!1}},re({name:"Keep the harness copy out of the working tree",run:`mkdir -p .git/info
25
- echo "/${Je.split("/")[0]}/" >> .git/info/exclude`})],l=t?d=>`./${Je}/.github/actions/${d}`:i.actionRef;return{ctx:{...i,specDir:r?`${Je}/${r}`:Je,harnessRoot:Je,actionRef:l},steps:s}}function Yt(i,e={}){let t={token:ce(i)};return e.ref&&(t.ref=e.ref),e.persistCredentials===!1&&(t["persist-credentials"]=!1),i.node.attrs.checkout==="partial"?(t["fetch-depth"]=0,t.filter="blob:none"):e.fetchDepth!==void 0&&(t["fetch-depth"]=e.fetchDepth),{uses:"actions/checkout@v5",name:"Checkout",with:t}}function ze(i){return{uses:`${i?.harnessRoot?`./${i.harnessRoot}`:"."}/.github/agent-setup`,name:"Setup agent toolchain"}}function Di(i){let e=i.attrs.persist_credentials;return typeof e=="boolean"?e:i.attrs.checkout==="partial"}function Co(i){return i===void 0?!0:i.split(",").some(e=>{let t=e.trim();return t==="Bash"||/^Bash\(\s*gh\b/.test(t)})}function ji(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 re({name:"Configure git identity",env:{GIT_NAME:t,GIT_EMAIL:r},run:`git config user.name "$GIT_NAME"
26
- git config user.email "$GIT_EMAIL"`})}function pt(i,e,t,r={}){let o={type:e,number:t,token:ce(i)};r.checks&&(o["checks-token"]="${{ github.token }}");let a=i.config.identity?.bot_login;return a&&(o["trusted-authors"]=a,r.framing==="baseline"&&(o["trusted-framing"]="baseline")),{uses:i.actionRef("agent-context"),id:"ctx",name:"Fetch context",with:o}}function Qe(i,e){let t=i.node,r=i.config,o={"role-file":Se(i,t.files.role),model:r.agent.model,"comms-file":Se(i,"agents/communication.md"),"scope-path":Se(i,"agents/scope.yaml"),...r.agent.api_key_secret?{"anthropic-api-key":Xe(r.agent.api_key_secret)}:{"claude-code-oauth-token":Xe(r.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")}};Co(i.roleTools?.(t.id))&&(o["github-token"]=ce(i)),t.attrs.repo_guides===!1&&(o["repo-guides"]="false"),e.withContext&&(o["context-file"]="${{ steps.ctx.outputs.context-file }}"),r.agent.conventions&&(o.conventions=r.agent.conventions);let a=typeof t.attrs.secrets=="string"?t.attrs.secrets.split(",").map(l=>l.trim()).filter(Boolean):[],c=[...new Set([...r.agent.secrets??[],...a])];c.length&&(o["extra-env"]=c.map(l=>`${l}=${Xe(l)}`).join(`
27
- `));let p=t.attrs.agent_attempts;p!==void 0&&(o["max-attempts"]=String(p));let s=t.files.prompt;return s&&(o["prompt-override-file"]=Se(i,s)),{uses:i.actionRef("run-agent"),name:"Run agent",with:o}}function re(i){return{shell:"bash",...i}}function Kt(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 a=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(o);if(!a)throw new Error(`node '${i.id}': bad permissions= entry '${o.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);t[a[1]]=a[2]}return t}function Ui(i,e){let t;try{t=Kt(i)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var De="${{ github.event.issue.number }}",Ze="${{ github.event.pull_request.number }}",Fn="${{ github.event.pull_request.head.sha }}",qi="${{ github.event.pull_request.head.ref }}",Ln="${{ github.event.pull_request.base.ref }}";function Mn(i,e){try{return{...e,...Kt(i)}}catch{return e}}function Re(i,e){let t=i.attrs.timeout;return typeof t=="number"?t:e}var Oo=10;function Jt(i){return Math.max(1,i-Oo)}function Xt(i,e,t){let r=[],o=Gt(i,t&&Mn(i.node,t));return o&&r.push(o),r.push(Yt(i,e)),r.push(ji(i)),r}function Pn(i){let e=i,t=e.node,r=t.context??"issue",o=r==="pr-diff"||r==="pr-review",a=o?{contents:"read","pull-requests":"write",checks:"read"}:{contents:"read",issues:"write"},c=Ye(t),p=!c&&Me(t,e.config),s=Ke(t),l=c?"${{ matrix.pr.number }}":Ze,d=c?"${{ matrix.pr.sha }}":Fn,f=[],w=Gt(e,Mn(t,a));w&&f.push(w);let m=Di(t);if(f.push(Yt(e,o?{ref:d,fetchDepth:0,persistCredentials:m}:{persistCredentials:m})),o&&Wt(t)){let q=Vt(e,c?"${{ matrix.pr.base }}":Ln);f.push(...q.steps),e=q.ctx}let O=o?Pi(t):[],y=O.map(q=>q.name),_=y.map((q,Z)=>Ro(`gate-${q}`,Z,y));O.forEach((q,Z)=>{f.push({uses:e.actionRef("wait-for-checks"),id:_[Z],name:`Wait for ${q.name}`,with:{sha:d,...q.kind==="workflow"?{"workflow-name":q.name,token:ce(e)}:{"check-name":q.name,token:"${{ github.token }}"},...q.graceSeconds!==void 0?{"missing-grace-seconds":q.graceSeconds}:{}}})}),f.push(ze(e));let R=r==="pr-diff"?"pr-diff":r==="pr-review"?"pr-review":"issue";f.push(pt(e,R,o?l:De,{framing:"baseline",checks:o})),O.length&&f.push(No(O,_));let I=Re(t,y.length?15+15*y.length:25),M=Qe(e,{withContext:!0});f.push(y.length?M:{...M,timeoutMinutes:Jt(I)});let D={jobId:t.id,name:t.id,permissions:a,timeoutMinutes:I,steps:f};return c?(D.needs=[s],D.displayName=`${Ut(t)}\${{ matrix.pr.number }}`,D.if=`needs.${s}.outputs.count != '0'`,D.strategy={"fail-fast":!1,matrix:{pr:`\${{ fromJSON(needs.${s}.outputs.prs) }}`}}):p&&(D.needs=[s],D.if=`needs.${s}.outputs.run == 'true'`,Fe(t).some(q=>q.kind==="unchanged-diff")&&f.push(To(e,s))),D}function To(i,e){return re({name:"Stamp the review with the diff hash",if:`\${{ success() && needs.${e}.outputs.diff_hash != '' }}`,env:{GH_TOKEN:ce(i),PR:Ze,HEAD_SHA:`\${{ needs.${e}.outputs.head_sha }}`,DIFF_HASH:`\${{ needs.${e}.outputs.diff_hash }}`,BOT_LOGIN:i.config.identity?.bot_login??"",MARKER_PREFIX:Bt(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(`
28
- `)})}function Ro(i,e,t){let r=c=>c.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),o=r(i)||`gate-${e+1}`;return t.filter((c,p)=>p!==e&&r(`gate-${c}`)===o).length>0?`${o}-${e+1}`:o}function No(i,e){let t={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},r=["{",' echo ""',' echo "=== CI GATES ==="'],o=p=>` echo "$GATE_${p+1}_NAME: $GATE_${p+1}_RESULT"`;i.forEach((p,s)=>{t[`GATE_${s+1}_NAME`]=p.name,t[`GATE_${s+1}_RESULT`]=`\${{ steps.${e[s]}.outputs.conclusion }}`});let a=i.map((p,s)=>({g:p,i:s})).filter(({g:p})=>!p.info),c=i.map((p,s)=>({g:p,i:s})).filter(({g:p})=>p.info);return a.length&&(a.forEach(({i:p})=>r.push(o(p))),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."')),c.length&&(a.length&&r.push(' echo ""'),r.push(' echo "Informational checks (advisory \u2014 never blocking on their own):"'),c.forEach(({i:p})=>r.push(o(p))),r.push(' echo ""',` echo "'skipped', 'neutral' or 'timeout' here means the check did not run or had"`,' echo "nothing to report on this head \u2014 that is normal and is not a finding. A"',` echo "'failure' is input to weigh alongside your own review, not a verdict."`)),r.push('} >> "$CONTEXT_FILE"'),re({name:"Record CI gate results in the context",env:t,run:r.join(`
29
- `)})}function Io(i){let e=i.node,t=i.config,r=Xt(i,void 0,{contents:"write","pull-requests":"write",issues:"write"});r.push(re({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:De,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(`
30
- `)}));let o=Re(e,35);return r.push(ze(i)),r.push(pt(i,"issue",De)),r.push({...Qe(i,{withContext:!0}),timeoutMinutes:Jt(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":De,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
20
+ `),this.outputHelp({error:!0}));let o=t||{},s=o.exitCode||1,a=o.code||"commander.error";this._exit(s,a,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in Z.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()}`,Z.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Fo(this.options),t=o=>this.getOptionValue(o)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(o));this.options.filter(o=>o.implied!==void 0&&t(o.attributeName())&&e.valueFromOption(this.getOptionValue(o.attributeName()),o)).forEach(o=>{Object.keys(o.implied).filter(s=>!t(s)).forEach(s=>{this.setOptionValueWithSource(s,o.implied[s],"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 o=l=>{let u=l.attributeName(),p=this.getOptionValue(u),r=this.options.find(h=>h.negate&&u===h.attributeName()),d=this.options.find(h=>!h.negate&&u===h.attributeName());return r&&(r.presetArg===void 0&&p===!1||r.presetArg!==void 0&&p===r.presetArg)?r:d||l},s=l=>{let u=o(l),p=u.attributeName();return this.getOptionValueSource(p)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},a=`error: ${s(e)} cannot be used with ${s(t)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let s=[],a=this;do{let l=a.createHelp().visibleOptions(a).filter(u=>u.long).map(u=>u.long);s=s.concat(l),a=a.parent}while(a&&!a._enablePositionalOptions);t=Pi(e,s)}let o=`error: unknown option '${e}'${t}`;this.error(o,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,o=t===1?"":"s",a=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${o} but got ${e.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(a=>{s.push(a.name()),a.alias()&&s.push(a.alias())}),t=Pi(e,s)}let o=`error: unknown command '${e}'${t}`;this.error(o,{code:"commander.unknownCommand"})}version(e,t,o){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",o=o||"output the version number";let s=this.createOption(t,o);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.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 o=this.parent?._findCommand(e);if(o){let s=[o.name()].concat(o.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}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(o=>Do(o));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=Oe.basename(e,Oe.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},o;return t.error?o=s=>this._outputConfiguration.writeErr(s):o=s=>this._outputConfiguration.writeOut(s),t.write=e.write||o,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let o=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(a=>a.emit("beforeAllHelp",o)),this.emit("beforeHelp",o);let s=this.helpInformation(o);if(t&&(s=t(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");o.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",o),this._getCommandAndAncestors().forEach(a=>a.emit("afterAllHelp",o))}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=Z.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let o=["beforeAll","before","after","afterAll"];if(!o.includes(e))throw new Error(`Unexpected value for position to addHelpText.
22
+ Expecting one of '${o.join("', '")}'`);let s=`${e}Help`;return this.on(s,a=>{let l;typeof t=="function"?l=t({error:a.error,command:a.command}):l=t,l&&a.write(`${l}
23
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Li(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,o="127.0.0.1",s="9229",a;return(a=e.match(/^(--inspect(-brk)?)$/))!==null?t=a[1]:(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=a[1],/^\d+$/.test(a[3])?s=a[3]:o=a[3]):(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=a[1],o=a[3],s=a[4]),t&&s!=="0"?`${t}=${o}:${parseInt(s)+1}`:e})}Di.Command=Nn});var Ui=Pe(pe=>{"use strict";I();var{Argument:Fi}=Gt(),{Command:In}=Mi(),{CommanderError:jo,InvalidArgumentError:ji}=mt(),{Help:qo}=vn(),{Option:qi}=Cn();pe.program=new In;pe.createCommand=n=>new In(n);pe.createOption=(n,e)=>new qi(n,e);pe.createArgument=(n,e)=>new Fi(n,e);pe.Command=In;pe.Option=qi;pe.Argument=Fi;pe.Help=qo;pe.CommanderError=jo;pe.InvalidArgumentError=ji;pe.InvalidOptionArgumentError=ji});var Yt=Pe((Ia,Hn)=>{"use strict";I();var Wt=process||{},Vi=Wt.argv||[],Vt=Wt.env||{},Uo=!(Vt.NO_COLOR||Vi.includes("--no-color"))&&(!!Vt.FORCE_COLOR||Vi.includes("--color")||Wt.platform==="win32"||(Wt.stdout||{}).isTTY&&Vt.TERM!=="dumb"||!!Vt.CI),Bo=(n,e,t=n)=>o=>{let s=""+o,a=s.indexOf(e,n.length);return~a?n+Go(s,e,t,a)+e:n+s+e},Go=(n,e,t,o)=>{let s="",a=0;do s+=n.substring(a,o)+t,a=o+e.length,o=n.indexOf(e,a);while(~o);return s+n.substring(a)},Wi=(n=Uo)=>{let e=n?Bo:()=>String;return{isColorSupported:n,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")}};Hn.exports=Wi();Hn.exports.createColors=Wi});I();I();var Bi=Ut(Ui(),1),{program:$a,createCommand:Ea,createArgument:Aa,createOption:va,CommanderError:ka,InvalidArgumentError:Sa,InvalidOptionArgumentError:Oa,Command:Gi,Argument:Ca,Option:Ta,Help:xa}=Bi.default;var X=Ut(Yt(),1),wo=require("child_process"),K=require("fs"),re=require("path");I();I();I();var Qe=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function Yi(n){return n.uses!==void 0}I();function bt(n){let e=n.auth;return e?.mode?{mode:e.mode,appIdSecret:e.app_id_secret??n.identity.app_id_secret,appKeySecret:e.app_key_secret??n.identity.app_key_secret,tokenSecret:e.token_secret}:n.identity.app_id_secret&&n.identity.app_key_secret?{mode:"app",appIdSecret:n.identity.app_id_secret,appKeySecret:n.identity.app_key_secret}:{mode:"github-token"}}I();I();var Vo="**Verdict:**",Wo=["APPROVE","REQUEST_CHANGES","ESCALATE"],Yo=/^[A-Za-z][A-Za-z0-9_-]*$/;function je(n){if(n==null||n===""){let[o,s,a]=Wo;return{approve:o,requestChanges:s,escalate:a}}let e=typeof n=="string"?n.split(",").map(o=>o.trim()):n;if(!Array.isArray(e)||e.length!==3)throw new Error("verdicts must list exactly three words: approve, request changes, escalate (e.g. [APPROVE, REQUEST_CHANGES, ESCALATE])");let t=e.map(o=>String(o).trim());for(let o of t)if(!Yo.test(o))throw new Error(`verdicts: '${o}' is not a verdict word (letters, digits, _ and -)`);if(new Set(t).size!==3)throw new Error("verdicts: the three words must be distinct");return{approve:t[0],requestChanges:t[1],escalate:t[2]}}function Ko(n){return`${Vo} ${n}`}function Pn(n){return[n.approve,n.requestChanges,n.escalate].map(Ko).join(`
24
+ `)}I();I();var Ln=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","title","harness_ref","persist_credentials","repo_guides","opt_in_label","mode","check_name","requires_review","post","post_marker"]),Dn=new Set(["on","when","do"]);function Ki(n,e){let t=(a,l)=>{let u=Array.from({length:l.length+1},(p,r)=>r);for(let p=1;p<=a.length;p++){let r=u[0];u[0]=p;for(let d=1;d<=l.length;d++){let h=u[d];u[d]=Math.min(u[d]+1,u[d-1]+1,r+(a[p-1]===l[d-1]?0:1)),r=h}}return u[l.length]},o,s=3;for(let a of e){let l=t(n.toLowerCase(),a);l<s&&([o,s]=[a,l])}return o}function Mn(n){let e=n.attrs.gates;if(e===void 0)return[];if(typeof e!="string")throw new Error(`node '${n.id}': gates= must be a string like "ci.yml" or "lint?90"`);let t=[];for(let o of e.split(",").map(s=>s.trim()).filter(Boolean)){let[s,...a]=o.split("?"),l=s.trim();if(!l)throw new Error(`node '${n.id}': gates= entry '${o}' names no workflow or check`);let u={name:l,kind:/\.ya?ml$/i.test(l)?"workflow":"check"};for(let p of a.map(r=>r.trim()))if(p==="info")u.info=!0;else if(/^[1-9]\d*$/.test(p)&&u.graceSeconds===void 0)u.graceSeconds=Number(p);else throw new Error(`node '${n.id}': gates= entry '${o}' has a bad '?${p}' suffix \u2014 expected '?<seconds>' (a whole number >= 1) and/or '?info', e.g. "${l}?90" or "${l}?info"`);t.push(u)}return t}function Ji(n){try{return Mn(n)}catch{return[]}}function Fn(n){let e=n.attrs.skip;if(e===void 0)return[];if(typeof e!="string"||!e.trim())throw new Error(`node '${n.id}': skip= must be a non-empty string like "draft,unchanged-diff"`);let t=[],o=new Set;for(let s of e.split(",").map(a=>a.trim()).filter(Boolean))if(!o.has(s))if(o.add(s),s==="draft"||s==="bot-author"||s==="unchanged-diff")t.push({kind:s});else if(s.startsWith("label:")&&s.slice(6).trim())t.push({kind:"label",label:s.slice(6).trim()});else throw new Error(`node '${n.id}': unknown skip= entry '${s}' \u2014 expected draft, bot-author, label:<key> or unchanged-diff`);if(!t.length)throw new Error(`node '${n.id}': skip= has no entries`);return t}function Ce(n){try{return Fn(n)}catch{return[]}}var Jo=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function Xi(n,e){let t=[];for(let o of n){let s=String(o).trim();if(!s)continue;if(!Jo.test(s))throw new Error(`${e}: '${s}' is not a GitHub login`);let a=s.toLowerCase();t.includes(a)||t.push(a)}if(!t.length)throw new Error(`${e}: names no login \u2014 an empty allowlist would match nobody`);return t}function Kt(n){return n.type==="pr-fix"||(n.type==="pr-review"||n.type==="analyst")&&we(n)||he(n)}function Jt(n,e){let t=n.attrs.authors;return t!==void 0?Xi(String(t).split(","),`node '${n.id}': authors=`):wt(e)}function wt(n){let e=n.repo?.authors;if(e!==void 0){if(!Array.isArray(e))throw new Error("repo.authors must be a list of GitHub logins");return Xi(e,"repo.authors")}}function Te(n,e){if(Kt(n))try{return Jt(n,e)}catch{return[jn]}}var jn="no author matches a malformed allowlist";function zi(n,e){let t=n.map(s=>`github.event.pull_request.user.login == '${s}'`),o=t.length===1?t[0]:`(${t.join(" || ")})`;return e===void 0?o:`(${o} || contains(github.event.pull_request.labels.*.name, ${qe(e)}))`}function qe(n){return`'${n.replace(/'/g,"''")}'`}function qn(n,e){let t=n.attrs.opt_in_label;if(t===void 0)return;if(typeof t!="string"||!t.trim())throw new Error(`node '${n.id}': opt_in_label= must be a label key like "agent_review"`);let o=t.trim();return e.labels?.[o]??o}function Ue(n,e){if(Te(n,e)!==void 0)try{return qn(n,e)}catch{return}}function Un(n){let e=n.attrs.mode;if(e===void 0)return"merge";if(e==="merge"||e==="evaluate")return e;throw new Error(`node '${n.id}': mode= must be "merge" or "evaluate", got ${JSON.stringify(e)}`)}function he(n){if(n.type!=="merge-gate")return!1;try{return Un(n)==="evaluate"}catch{return!1}}function Be(n){let e=n.attrs.check_name;if(e===void 0)return`gp-foundry/approval (${n.id})`;if(typeof e!="string"||!e.trim()||/[\u0000-\u001f\u007f]/.test(e))throw new Error(`node '${n.id}': check_name= must be a non-empty, single-line check-run name like "fletch/approval"`);return e.trim()}function we(n){return n.context==="pr-diff"||n.context==="pr-review"}function ye(n){return n.attrs.select==="sweep"&&n.type==="pr-review"&&we(n)&&n.attrs.schedule!==void 0}function Bn(n){return ye(n)&&n.attrs.requires_review===!0}var Qi="<!-- gp-foundry:also-head:[^:\\s]+:";function Xt(n){return n.attrs.post==="review"&&(n.type==="pr-review"||n.type==="analyst")&&we(n)}var Gn="PR #<n> head <sha>";function zt(n){let e=n.attrs.post_marker;if(e===void 0)return Gn;if(typeof e!="string"||!e.trim()||/[\u0000-\u001f\u007f]/.test(e))throw new Error(`node '${n.id}': post_marker= must be a non-empty single line, e.g. "PR #<n> head <sha>"`);return e.trim()}function Ge(n,e){return(n.type==="pr-review"||n.type==="analyst")&&we(n)&&n.attrs.schedule===void 0&&(Ce(n).length>0||Te(n,e)!==void 0)}function Ze(n){return ye(n)?`${n.id}_select`:`${n.id}_guard`}function Qt(n){return`${n.id} #`}function Vn(n){return`gp-foundry/sweep-failed (${n.id})`}function Wn(n){return`gp-foundry/sweep-idle (${n.id})`}function Yn(n){return`gp-foundry/swept (${n.id})`}function Zt(n){return`<!-- gp-foundry:diff:${n.id}:`}function Zi(n){return`<!-- gp-foundry:also-head:${n.id}:`}var yt='(((.body // "") | gsub("<!--[\\\\s\\\\S]*?-->"; "") | split("\\n") | map(gsub("^\\\\s+|\\\\s+$"; "")) | map(select(length > 0)) | (last // "")) as $line | env.VERDICT_LINES | split("\\n") | any(.[]; . == $line))';function et(n){try{return Pn(je(n.verdicts))}catch{return Pn(je(void 0))}}I();function nt(n){return`\${{ secrets.${n} }}`}function _e(n,e){if(!e)return"";let t=n.specDir?.replace(/\/+$/,"");return t?`${t}/${e}`:e}function ne(n){let e=bt(n.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?nt(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}var Xo=new Set(["actions","checks","contents","deployments","issues","packages","pages","pull-requests","security-events","statuses","workflows"]);function it(n,e){let t=bt(n.config);if(t.mode!=="app"||!t.appIdSecret||!t.appKeySecret)return;let o={"client-id":nt(t.appIdSecret),"private-key":nt(t.appKeySecret)};for(let[s,a]of Object.entries(e??{}))Xo.has(s)&&a!=="none"&&(o[`permission-${s}`]=a);return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:o}}var tt=".gp-foundry/harness";function en(n,e=!1){return n.attrs.harness_ref==="head"?!1:e||n.type==="pr-fix"||(n.type==="pr-review"||n.type==="analyst")&&we(n)}function tn(n,e){let t=n.config.runtime?.mode==="vendored",o=n.specDir.replace(/\/+$/,""),s=[n.node.files.role,n.node.files.prompt,"agents/scope.yaml","agents/communication.md"].filter(d=>!!d).map(d=>o?`${o}/${d}`:d),a=new Set([".github/agent-setup"]);t&&a.add(".github/actions");for(let d of s){let h=d.includes("/")?d.slice(0,d.lastIndexOf("/")):"";h&&a.add(h)}let l=[...a].sort(),u=l.filter(d=>!l.some(h=>h!==d&&d.startsWith(`${h}/`))),p=[{uses:"actions/checkout@v5",name:"Checkout harness files (base ref)",with:{ref:e,path:tt,"fetch-depth":1,"sparse-checkout":u.join(`
25
+ `),token:ne(n),"persist-credentials":!1}},ie({name:"Keep the harness copy out of the working tree",run:`mkdir -p .git/info
26
+ echo "/${tt.split("/")[0]}/" >> .git/info/exclude`})],r=t?d=>`./${tt}/.github/actions/${d}`:n.actionRef;return{ctx:{...n,specDir:o?`${tt}/${o}`:tt,harnessRoot:tt,actionRef:r},steps:p}}function _t(n,e={}){let t={token:ne(n)};return e.ref&&(t.ref=e.ref),e.persistCredentials===!1&&(t["persist-credentials"]=!1),n.node.attrs.checkout==="partial"?(t["fetch-depth"]=0,t.filter="blob:none"):e.fetchDepth!==void 0&&(t["fetch-depth"]=e.fetchDepth),{uses:"actions/checkout@v5",name:"Checkout",with:t}}function rt(n){return{uses:`${n?.harnessRoot?`./${n.harnessRoot}`:"."}/.github/agent-setup`,name:"Setup agent toolchain"}}function er(n){let e=n.attrs.persist_credentials;return typeof e=="boolean"?e:n.attrs.checkout==="partial"}function Kn(n){return n===void 0?!0:n.split(",").some(e=>{let t=e.trim();return t==="Bash"||/^Bash\(\s*gh\b/.test(t)})}function tr(n){let e=n.config.identity,t=e.git_name??e.bot_login??"gp-foundry agent",o=e.git_email??`${e.bot_login??"gp-foundry-agent"}@users.noreply.github.com`;return ie({name:"Configure git identity",env:{GIT_NAME:t,GIT_EMAIL:o},run:`git config user.name "$GIT_NAME"
27
+ git config user.email "$GIT_EMAIL"`})}function $t(n,e,t,o={}){let s={type:e,number:t,token:ne(n)};o.checks&&(s["checks-token"]="${{ github.token }}");let a=n.config.identity?.bot_login;return a&&(s["trusted-authors"]=a,o.framing==="baseline"&&(s["trusted-framing"]="baseline")),{uses:n.actionRef("agent-context"),id:"ctx",name:"Fetch context",with:s}}function ot(n,e){let t=n.node,o=n.config,s={"role-file":_e(n,t.files.role),model:o.agent.model,"comms-file":_e(n,"agents/communication.md"),"scope-path":_e(n,"agents/scope.yaml"),...o.agent.api_key_secret?{"anthropic-api-key":nt(o.agent.api_key_secret)}:{"claude-code-oauth-token":nt(o.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")}};!e.outputContract&&Kn(n.roleTools?.(t.id))&&(s["github-token"]=ne(n)),e.outputContract&&(s["output-contract"]=e.outputContract),t.attrs.repo_guides===!1&&(s["repo-guides"]="false"),e.withContext&&(s["context-file"]="${{ steps.ctx.outputs.context-file }}"),o.agent.conventions&&(s.conventions=o.agent.conventions);let a=typeof t.attrs.secrets=="string"?t.attrs.secrets.split(",").map(r=>r.trim()).filter(Boolean):[],l=[...new Set([...o.agent.secrets??[],...a])];l.length&&(s["extra-env"]=l.map(r=>`${r}=${nt(r)}`).join(`
28
+ `));let u=t.attrs.agent_attempts;u!==void 0&&(s["max-attempts"]=String(u));let p=t.files.prompt;return p&&(s["prompt-override-file"]=_e(n,p)),{uses:n.actionRef("run-agent"),...e.outputContract?{id:"agent"}:{},name:"Run agent",with:s}}function ie(n){return{shell:"bash",...n}}var zo=`set -euo pipefail
29
+ # post="review": the agent printed its review; this step posts it with the lane's
30
+ # token. The agent's output is DATA \u2014 nothing here evaluates it, and it reaches gh
31
+ # only as a JSON file built by jq.
32
+ preview() { head -c 200 "$STDOUT_FILE" | tr '\\n\\r' ' '; }
33
+ if [ -z "\${STDOUT_FILE:-}" ] || [ ! -s "$STDOUT_FILE" ]; then
34
+ echo "::warning::the agent printed nothing \u2014 no review posted"
35
+ exit 0
36
+ fi
37
+
38
+ # The LAST fenced json block in the output. A json string cannot hold a raw
39
+ # newline, so a fence inside the review's own markdown never closes this block.
40
+ BLOCK=$(awk '
41
+ /^[ \\t]*\`\`\`[ \\t]*json[ \\t]*$/ { inb = 1; buf = ""; next }
42
+ inb && /^[ \\t]*\`\`\`[ \\t]*$/ { inb = 0; last = buf; found = 1; next }
43
+ inb { buf = buf $0 "\\n" }
44
+ END { if (found) printf "%s", last }' "$STDOUT_FILE")
45
+ if [ -z "$BLOCK" ]; then
46
+ echo "::warning::no fenced json review block in the agent's output \u2014 nothing posted. It began: $(preview)"
47
+ exit 0
48
+ fi
49
+
50
+ ERR=$(mktemp)
51
+ if ! REVIEW=$(jq -c '
52
+ def fail(m): error(m);
53
+ if type != "object" then fail("the block is not a JSON object") else . end
54
+ | if ((.body | type) != "string") or ((.body | length) == 0) then fail("body must be a non-empty string") else . end
55
+ | if (.event // "COMMENT") != "COMMENT" then fail("event must be COMMENT") else . end
56
+ | (.comments // []) as $c
57
+ | if ($c | type) != "array" then fail("comments must be an array") else . end
58
+ | if any($c[]; (type != "object") or ((.path | type) != "string") or ((.line | type) != "number")
59
+ or (.line != (.line | floor)) or (.line < 1) or ((.body | type) != "string"))
60
+ then fail("each comment needs a string path, a positive integer line and a string body") else . end
61
+ | {body, event: "COMMENT", comments: [$c[] | {path, line, side: (if .side == "LEFT" then "LEFT" else "RIGHT" end), body}]}
62
+ ' <<< "$BLOCK" 2> "$ERR"); then
63
+ echo "::warning::the review block is not a valid review \u2014 nothing posted: $(head -c 300 "$ERR" | tr '\\n\\r' ' ')"
64
+ exit 0
65
+ fi
66
+
67
+ # A verdict lane's review IS its verdict: the last visible line must be one of
68
+ # the exact verdict lines, or the sweep and the gate would read it differently.
69
+ if [ "$REQUIRE_VERDICT" = "true" ] && ! jq -e '__IS_VERDICT_JQ__' <<< "$REVIEW" > /dev/null; then
70
+ echo "::warning::the review's last line is not one of the verdict lines ($(tr '\\n' '|' <<< "$VERDICT_LINES")) \u2014 nothing posted"
71
+ exit 0
72
+ fi
73
+
74
+ # Line 1 of the posted body: the heading that makes a re-run idempotent.
75
+ MARKER="\${POST_MARKER//<n>/$PR}"
76
+ MARKER="\${MARKER//<sha>/$HEAD_SHA}"
77
+ export MARKER
78
+ if ! EXISTING=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews?per_page=100" --paginate --jq '
79
+ [.[] | select(.user.login == env.BOT_LOGIN and .commit_id == env.HEAD_SHA)
80
+ | select((((.body // "") | split("\\n") | .[0]) // "" | gsub("^\\\\s+|\\\\s+$"; "")) == env.MARKER)] | length' \\
81
+ | awk '{s+=$1} END {print s+0}'); then
82
+ echo "::error::could not read the PR's reviews \u2014 not posting, so a re-run cannot post the review twice"
83
+ exit 1
84
+ fi
85
+ if [ "$EXISTING" != "0" ]; then
86
+ echo "a review headed '$MARKER' by $BOT_LOGIN is already on $HEAD_SHA \u2014 not posting it again"
87
+ exit 0
88
+ fi
89
+
90
+ PAYLOAD=$(mktemp)
91
+ jq -c --arg sha "$HEAD_SHA" --arg head "$MARKER" \\
92
+ '{commit_id: $sha, event, body: ($head + "\\n\\n" + .body), comments}' <<< "$REVIEW" > "$PAYLOAD"
93
+ post() { gh api --method POST "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --input "$1" > /dev/null 2> "$ERR"; }
94
+ if post "$PAYLOAD"; then
95
+ echo "posted the review on $HEAD_SHA"
96
+ exit 0
97
+ fi
98
+
99
+ # GitHub rejects the whole review when one inline comment is on a line outside
100
+ # the diff, and does not say which. Retry once with every inline finding moved
101
+ # into the body (before the verdict line, on a verdict lane).
102
+ if grep -q "422" "$ERR" && grep -qiE "line|diff|position|resolve" "$ERR" && [ "$(jq '.comments | length' "$PAYLOAD")" != "0" ]; then
103
+ echo "::warning::GitHub rejected an inline comment ($(head -c 200 "$ERR" | tr '\\n\\r' ' ')) \u2014 posting the findings in the body instead"
104
+ jq -c --argjson rv "$([ "$REQUIRE_VERDICT" = "true" ] && echo true || echo false)" '
105
+ ("### Findings on unchanged lines\\n\\n" + ([.comments[] | "- \`\\(.path):\\(.line)\` \u2014 \\(.body | gsub("\\n"; " "))"] | join("\\n"))) as $f
106
+ | (.body | sub("\\\\s+$"; "") | split("\\n")) as $l
107
+ | .body = ((if $rv then ($l[:-1] + [$f, ""] + $l[-1:]) else ($l + ["", $f]) end) | join("\\n"))
108
+ | .comments = []' "$PAYLOAD" > "$PAYLOAD.flat"
109
+ if post "$PAYLOAD.flat"; then
110
+ echo "posted the review on $HEAD_SHA, with its inline findings in the body"
111
+ exit 0
112
+ fi
113
+ fi
114
+ echo "::error::could not post the review: $(head -c 500 "$ERR" | tr '\\n\\r' ' ')"
115
+ exit 1
116
+ `;function nr(n,e){let t=Gn;try{t=zt(n.node)}catch{}return ie({name:"Post the review",if:"${{ success() }}",env:{GH_TOKEN:ne(n),PR:e.prNumber,HEAD_SHA:e.headSha,STDOUT_FILE:"${{ steps.agent.outputs.stdout-file }}",BOT_LOGIN:n.config.identity?.bot_login??"",POST_MARKER:t,REQUIRE_VERDICT:String(e.verdictLane),VERDICT_LINES:et(n.config)},run:zo.replace("__IS_VERDICT_JQ__",yt)})}function ir(n,e){let t=et(n.config).split(`
117
+ `);return["Do not post anything to GitHub yourself, and do not run `gh`: a workflow step posts your review for you.","End your final message with exactly one fenced code block tagged `json` holding one object:","","```json",'{"body": "<the whole review, in markdown>", "comments": [{"path": "src/file.ts", "line": 42, "side": "RIGHT", "body": "<one finding>"}], "event": "COMMENT"}',"```","","- `body`: the review. Do not add a heading with the PR number or commit; the step adds it.","- `comments`: optional inline findings, each on a line of the diff (`side` RIGHT is the new file, LEFT the old). Use `[]` for none.",'- `event`: always `"COMMENT"`. Do not include a `commit_id`; the step sets it to the head you reviewed.',...e?[`- The LAST line of \`body\` must be exactly one of: ${t.map(o=>`\`${o}\``).join(", ")}. Anything else, and nothing is posted.`]:[],"If the block is missing or is not valid JSON, nothing is posted."].join(`
118
+ `)}function rn(n){let e=n.attrs.permissions;if(e===void 0)return{};if(typeof e!="string"||!e.trim())throw new Error(`node '${n.id}': permissions= must be a non-empty string like "id-token: write"`);let t={},o=e.split(",").filter(s=>s.trim());if(!o.length)throw new Error(`node '${n.id}': permissions= has no entries \u2014 expected e.g. "id-token: write"`);for(let s of o){let a=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(s);if(!a)throw new Error(`node '${n.id}': bad permissions= entry '${s.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);t[a[1]]=a[2]}return t}function or(n,e){let t;try{t=rn(n)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var Ve="${{ github.event.issue.number }}",st="${{ github.event.pull_request.number }}",Xn="${{ github.event.pull_request.head.sha }}",rr="${{ github.event.pull_request.head.ref }}",zn="${{ github.event.pull_request.base.ref }}";function Qn(n,e){try{return{...e,...rn(n)}}catch{return e}}function xe(n,e){let t=n.attrs.timeout;return typeof t=="number"?t:e}var Qo=10;function on(n){return Math.max(1,n-Qo)}function sn(n,e,t){let o=[],s=it(n,t&&Qn(n.node,t));return s&&o.push(s),o.push(_t(n,e)),o.push(tr(n)),o}function Jn(n){let e=n,t=e.node,o=t.context??"issue",s=o==="pr-diff"||o==="pr-review",a=s?{contents:"read","pull-requests":"write",checks:"read"}:{contents:"read",issues:"write"},l=ye(t),u=!l&&Ge(t,e.config),p=Ze(t),r=l?"${{ matrix.pr.number }}":st,d=l?"${{ matrix.pr.sha }}":Xn,h=[],y=it(e,Qn(t,a));y&&h.push(y);let m=er(t);if(h.push(_t(e,s?{ref:d,fetchDepth:0,persistCredentials:m}:{persistCredentials:m})),s&&en(t)){let B=tn(e,l?"${{ matrix.pr.base }}":zn);h.push(...B.steps),e=B.ctx}let $=s?Ji(t):[],E=$.map(B=>B.name),b=E.map((B,te)=>es(`gate-${B}`,te,E));$.forEach((B,te)=>{h.push({uses:e.actionRef("wait-for-checks"),id:b[te],name:`Wait for ${B.name}`,with:{sha:d,...B.kind==="workflow"?{"workflow-name":B.name,token:ne(e)}:{"check-name":B.name,token:"${{ github.token }}"},...B.graceSeconds!==void 0?{"missing-grace-seconds":B.graceSeconds}:{}}})}),h.push(rt(e));let x=o==="pr-diff"?"pr-diff":o==="pr-review"?"pr-review":"issue";h.push($t(e,x,s?r:Ve,{framing:"baseline",checks:s})),$.length&&h.push(ts($,b));let H=xe(t,E.length?15+15*E.length:25),M=Xt(t),j=ot(e,{withContext:!0,...M?{outputContract:ir(e,l)}:{}});h.push(E.length?j:{...j,timeoutMinutes:on(H)}),M&&h.push(nr(e,{prNumber:r,headSha:d,verdictLane:l}));let W={jobId:t.id,name:t.id,permissions:a,timeoutMinutes:H,steps:h};return l?(W.needs=[p],W.displayName=`${Qt(t)}\${{ matrix.pr.number }}`,W.if=`needs.${p}.outputs.count != '0'`,W.strategy={"fail-fast":!1,matrix:{pr:`\${{ fromJSON(needs.${p}.outputs.prs) }}`}}):u&&(W.needs=[p],W.if=`needs.${p}.outputs.run == 'true'`,Ce(t).some(B=>B.kind==="unchanged-diff")&&h.push(Zo(e,p))),W}function Zo(n,e){return ie({name:"Stamp the review with the diff hash",if:`\${{ success() && needs.${e}.outputs.diff_hash != '' }}`,env:{GH_TOKEN:ne(n),PR:st,HEAD_SHA:`\${{ needs.${e}.outputs.head_sha }}`,DIFF_HASH:`\${{ needs.${e}.outputs.diff_hash }}`,BOT_LOGIN:n.config.identity?.bot_login??"",MARKER_PREFIX:Zt(n.node),STARTED_AT:`\${{ needs.${e}.outputs.started_at }}`},run:["# Best-effort: a missing stamp only means the next event is reviewed again.","# Only a review THIS run posted (submitted after the guard ran): another lane","# posting as the same bot \u2014 an approver's verdict on this head \u2014 is not this","# lane's review, and stamping it would make the guard compare against, and","# mark, someone else's review.",`ID=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," .[] | select(.user.login == env.BOT_LOGIN and .commit_id == env.HEAD_SHA)",' | select((.submitted_at // "") >= env.STARTED_AT)',` | 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 posted since $STARTED_AT \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(`
119
+ `)})}function es(n,e,t){let o=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),s=o(n)||`gate-${e+1}`;return t.filter((l,u)=>u!==e&&o(`gate-${l}`)===s).length>0?`${s}-${e+1}`:s}function ts(n,e){let t={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},o=["{",' echo ""',' echo "=== CI GATES ==="'],s=u=>` echo "$GATE_${u+1}_NAME: $GATE_${u+1}_RESULT"`;n.forEach((u,p)=>{t[`GATE_${p+1}_NAME`]=u.name,t[`GATE_${p+1}_RESULT`]=`\${{ steps.${e[p]}.outputs.conclusion }}`});let a=n.map((u,p)=>({g:u,i:p})).filter(({g:u})=>!u.info),l=n.map((u,p)=>({g:u,i:p})).filter(({g:u})=>u.info);return a.length&&(a.forEach(({i:u})=>o.push(s(u))),o.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."')),l.length&&(a.length&&o.push(' echo ""'),o.push(' echo "Informational checks (advisory \u2014 never blocking on their own):"'),l.forEach(({i:u})=>o.push(s(u))),o.push(' echo ""',` echo "'skipped', 'neutral' or 'timeout' here means the check did not run or had"`,' echo "nothing to report on this head \u2014 that is normal and is not a finding. A"',` echo "'failure' is input to weigh alongside your own review, not a verdict."`)),o.push('} >> "$CONTEXT_FILE"'),ie({name:"Record CI gate results in the context",env:t,run:o.join(`
120
+ `)})}function ns(n){let e=n.node,t=n.config,o=sn(n,void 0,{contents:"write","pull-requests":"write",issues:"write"});o.push(ie({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:Ve,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(`
121
+ `)}));let s=xe(e,35);return o.push(rt(n)),o.push($t(n,"issue",Ve)),o.push({...ot(n,{withContext:!0}),timeoutMinutes:on(s)}),o.push({uses:n.actionRef("agent-fallback"),name:"Fallback: commit / push / PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}",token:ne(n),"agent-name":e.id,"base-branch":t.repo.base_branch,"issue-number":Ve,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
31
122
 
32
123
  The agent finished but didn't open a PR itself, so one was created automatically. See the commits and the linked issue for context.
33
124
 
34
- Closes #${De}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:o,steps:r}}function Ho(i){let e=i,t=e.node,r=Xt(e,{ref:qi,fetchDepth:0},{contents:"write","pull-requests":"write",checks:"read"});if(Wt(t)){let l=Vt(e,Ln);r.push(...l.steps),e=l.ctx}let o=typeof t.attrs.max_attempts=="number"?t.attrs.max_attempts:3,a=`<!-- gp-foundry:attempt:${t.id} -->`,c=e.config.labels?.["needs-human"]??"needs-human",p=e.config.identity?.bot_login??"";r.push(re({id:"attempts",name:`Enforce attempt budget (max ${o})`,env:{GH_TOKEN:ce(e),PR:Ze,MARKER:a,MAX:String(o),BOT_LOGIN:p},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 "${c}" 2>/dev/null || gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/labels" -f 'labels[]=${c}'`,` gh pr comment "$PR" --body "$(printf '## \u26D4 Attempt budget (${t.id})\\n\\nExhausted (%s/%s requested-changes rounds) \u2014 labeling \`${c}\` 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(`
35
- `)}));let s="steps.attempts.outputs.exhausted != 'true'";return r.push({...ze(e),if:s}),r.push({...pt(e,"pr-review",Ze,{framing:"work-item",checks:!0}),if:s}),r.push({...Qe(e,{withContext:!0}),if:s,timeoutMinutes:Jt(Re(t,35))}),r.push(re({name:"Commit and push fixes",if:`${s} && !cancelled()`,env:{BRANCH:qi},run:["# Commit anything the agent left uncommitted...",'if [ -n "$(git status --porcelain)" ]; then'," git add -A",` git commit -m "agent fix: ${t.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(`
36
- `)})),{jobId:t.id,name:t.id,permissions:{contents:"write","pull-requests":"write",checks:"read"},timeoutMinutes:Re(t,35),steps:r}}function Bi(i){return`gp-foundry/human-approval (${String(i.attrs.environment??"production")})`}var Po="github-actions";function Fo(i){return`${Bi(i)}@${Po}`}function Lo(i){let e=i.node,t=Xt(i,{fetchDepth:0}),o=i.inEdges.map(a=>i.nodeById?.(a.from)).filter(a=>!!a&&a.type==="human-gate").map(Fo);return t.push({uses:i.actionRef("merge-gate"),name:"Evaluate merge gate",with:{token:ce(i),"checks-token":"${{ github.token }}","policy-path":Se(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:Re(e,10),steps:t}}function Mo(i){let e=i.node,t=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:t,steps:[re({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME:Bi(e),HEAD_SHA:Fn,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(`
37
- `)})]}}function Do(i){let e=i.node,t=i.config,r=Xt(i,{fetchDepth:0}),o=typeof e.attrs.commit=="string"?e.attrs.commit:"direct",a=typeof e.attrs.paths=="string"?e.attrs.paths:"";return o==="pr"&&r.push(re({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(`
38
- `)})),r.push(ze(i)),r.push({...Qe(i,{withContext:!1}),id:"agent",timeoutMinutes:Jt(Re(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":Se(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.`,...a?{"allowed-paths":a}:{}}}):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":Se(i,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...a?{"allowed-paths":a}:{}}}),r.push(re({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(`
39
- `)})),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":Se(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",...a?{"allowed-paths":a}:{}}})),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:Re(e,20),steps:r}}function Gi(i,e,t){let r=i,o=r.node,a=t?{contents:"read","pull-requests":"write",issues:"write",checks:"read"}:{contents:"read",issues:"write"},c=[],p=Gt(r,Mn(o,a));if(p&&c.push(p),c.push(Yt(r,t?{ref:Fn,fetchDepth:0,persistCredentials:!1}:{persistCredentials:!1})),Wt(o,t)){let l=Vt(r,Ln);c.push(...l.steps),r=l.ctx}c.push(ze(r)),c.push(pt(r,t?"pr-review":"issue",t?Ze:De,{framing:"baseline",checks:t})),o.files.role&&c.push(Qe(r,{withContext:!0}));let s=o.attrs.on_complete_label;if(typeof s=="string"&&s){let l=r.config.labels?.[s]??s;c.push(re({name:"Apply completion label",env:{GH_TOKEN:ce(r),NUM:t?Ze:De},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${l}'`}))}return Ui(o,{jobId:o.id,name:o.id,needs:e,permissions:a,timeoutMinutes:Re(o,15),steps:c})}var jo={analyst:Pn,"issue-agent":Pn,"pr-review":Pn,producer:Io,"pr-fix":Ho,"merge-gate":Lo,"human-gate":Mo,"scheduled-agent":Do,start:()=>null,exit:()=>null};function Dn(i,e,t){let r=jo[i.type];if(!r)return null;let o=r(t);return o&&Ui(i,o)}P();var qo=new Set(Ve);function je(i){let e=new Map(i.nodes.map(c=>[c.id,c])),t=new Map,r=new Map;for(let c of i.nodes)t.set(c.id,[]),r.set(c.id,[]);for(let c of i.edges)t.get(c.to)?.push(c),r.get(c.from)?.push(c);let o=new Map,a=new Set;for(let c of i.nodes){if(c.type!=="fan_in")continue;let p=t.get(c.id)??[];if(p.length<2)continue;let s=[],l,d=!0;for(let O of p){let y=e.get(O.from);if(!y||!qo.has(y.type)){d=!1;break}let _=t.get(y.id)??[],R=r.get(y.id)??[];if(_.length!==1||R.length!==1||R[0].to!==c.id){d=!1;break}let I=e.get(_[0].from);if(!I||I.type!=="parallel"){d=!1;break}if(_[0].on||_[0].when){d=!1;break}if(l===void 0)l=I.id;else if(l!==I.id){d=!1;break}s.push(y.id)}if(!d||l===void 0)continue;let f=t.get(l)??[],w=r.get(l)??[];if(f.length!==1||!f[0].on)continue;let m=new Set(s);if(!(!w.every(O=>m.has(O.to))||w.length!==s.length)){o.set(c.id,{parallelId:l,entryEdge:f[0],legIds:s,faninId:c.id}),a.add(l);for(let O of s)a.add(O)}}return{byFanin:o,memberIds:a}}var et=new Set(Ve);function ft(i,e={}){let t=[],r=new Map(i.nodes.map(s=>[s.id,s])),o=je(i).memberIds;for(let s of i.nodes)s.declared||t.push({level:"error",code:"node.undeclared",message:`node '${s.id}' is referenced in an edge but never declared`,where:{node:s.id,line:s.line},hint:`add a node statement, e.g. ${s.id} [type=...]`});let a=(s,l,d,f)=>{let w=Hi(s,l);t.push({level:"error",code:"attr.unknown",message:`unknown attribute '${s}=' on ${d} \u2014 it would be silently ignored`,where:f,hint:w?`did you mean '${w}='?`:"see reference/node-types.md for the attributes this version of gp-foundry understands"})};for(let s of i.nodes)for(let l of Object.keys(s.raw))xn.has(l)||a(l,xn,`node '${s.id}'`,{node:s.id,line:s.line});for(let s of i.edges)for(let l of Object.keys(s.raw))Cn.has(l)||a(l,Cn,`edge '${s.from} -> ${s.to}'`,{edge:[s.from,s.to],line:s.line});try{ut(i.config)}catch(s){t.push({level:"error",code:"config.bad-authors",message:s.message,hint:"repo.authors is a list of GitHub logins, e.g. authors: [dpup]"})}for(let s of i.nodes){if(s.attrs.authors!==void 0)if(!Dt(s)||o.has(s.id))t.push({level:"error",code:"node.authors-unsupported",message:`authors= on '${s.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:s.id,line:s.line},hint:o.has(s.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{jt(s,i.config)}catch(m){t.push({level:"error",code:"node.bad-authors",message:m.message,where:{node:s.id,line:s.line},hint:'comma-separated GitHub logins, e.g. authors="dpup, octocat"'})}if(s.attrs.opt_in_label!==void 0)if(!Dt(s)||o.has(s.id))t.push({level:"error",code:"node.opt-in-label-unsupported",message:`opt_in_label= on '${s.id}' is not supported here \u2014 it widens the allowlist of a standalone pr-review / pr-fix node, or an analyst with context="pr-diff" or "pr-review"`,where:{node:s.id,line:s.line}});else{try{Nn(s,i.config)}catch(O){t.push({level:"error",code:"node.bad-opt-in-label",message:O.message,where:{node:s.id,line:s.line},hint:'a key into labels: in foundry.config.yaml (or a literal label), e.g. opt_in_label="agent_review"'})}let m;try{m=jt(s,i.config)}catch{m=[]}m===void 0&&t.push({level:"error",code:"node.opt-in-without-authors",message:`opt_in_label= on '${s.id}' has no allowlist to widen \u2014 the lane already runs for every author`,where:{node:s.id,line:s.line},hint:"opt_in_label= widens an allowlist; set authors= or repo.authors, or drop the label to run for everyone"})}if(et.has(s.type)&&!s.files.role&&t.push({level:"error",code:"node.missing-role",message:`agent node '${s.id}' (type ${s.type}) needs a role="..." job description`,where:{node:s.id,line:s.line}}),s.attrs.permissions!==void 0){try{Kt(s)}catch(m){t.push({level:"error",code:"node.bad-permissions",message:m.message,where:{node:s.id,line:s.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(s.type==="start"||s.type==="exit"||s.type==="parallel")&&t.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${s.id}' (type ${s.type}) is ignored \u2014 this node emits no workflow job`,where:{node:s.id,line:s.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}if(s.attrs.agent_attempts!==void 0){let m=s.attrs.agent_attempts;(typeof m!="number"||!Number.isInteger(m)||m<1)&&t.push({level:"error",code:"node.bad-agent-attempts",message:`agent_attempts= on '${s.id}' must be a whole number >= 1, got ${JSON.stringify(m)}`,where:{node:s.id,line:s.line},hint:"1 disables retrying; omit the attr to use run-agent's default \u2014 e.g. agent_attempts=1"}),et.has(s.type)||t.push({level:"warning",code:"node.agent-attempts-ignored",message:`agent_attempts= on '${s.id}' (type ${s.type}) is ignored \u2014 this node runs no agent`,where:{node:s.id,line:s.line},hint:"move agent_attempts= to the agent lane whose retry budget you meant to change"})}let l=s.type!=="start"&&s.type!=="exit"&&s.type!=="parallel",d=s.type==="analyst"||s.type==="issue-agent"||s.type==="pr-review"||s.type==="fan_in",f=s.type==="pr-fix"||(s.type==="pr-review"||s.type==="analyst")&&Ee(s)||s.type==="fan_in",w=(m,O,y)=>{t.push({level:"error",code:m,message:O,where:{node:s.id,line:s.line},...y?{hint:y}:{}})};if(s.attrs.title!==void 0&&(typeof s.attrs.title!="string"||!s.attrs.title.trim()||s.attrs.title.includes("${{")?w("node.bad-title",`title= on '${s.id}' must be a plain, non-empty string, got ${JSON.stringify(s.attrs.title)}`):(!l||o.has(s.id))&&w("node.title-unsupported",`title= on '${s.id}' has no workflow to name \u2014 this node does not own one`,"set it on the node that owns the workflow (for a diamond, the fan_in)")),s.attrs.harness_ref!==void 0&&(s.attrs.harness_ref!=="base"&&s.attrs.harness_ref!=="head"?w("node.bad-harness-ref",`harness_ref= on '${s.id}' must be "base" or "head", got ${JSON.stringify(s.attrs.harness_ref)}`):f?s.attrs.harness_ref==="head"&&t.push({level:"warning",code:"node.harness-from-head",message:`harness_ref="head" on '${s.id}': its role, scope and setup composite are read from the PR under review, so a PR can rewrite the instructions it is judged by \u2014 and the setup step that runs with this job's secrets`,where:{node:s.id,line:s.line},hint:"omit harness_ref (the default is the base ref) unless you are testing a harness change in its own PR"}):w("node.harness-ref-unsupported",`harness_ref= on '${s.id}' does not apply \u2014 only a lane handed a pull request chooses between the base ref's harness files and the PR head's`)),s.attrs.persist_credentials!==void 0&&(typeof s.attrs.persist_credentials!="boolean"?w("node.bad-persist-credentials",`persist_credentials= on '${s.id}' must be true or false, got ${JSON.stringify(s.attrs.persist_credentials)}`):d?s.attrs.persist_credentials===!1&&s.attrs.checkout==="partial"&&w("node.partial-needs-credentials",`'${s.id}' sets checkout="partial" with persist_credentials=false \u2014 a blob-less clone fetches file contents on demand and cannot without the credential`,'drop checkout="partial" (a full clone needs no credential after checkout), or drop persist_credentials=false'):w("node.persist-credentials-unsupported",`persist_credentials= on '${s.id}' (type ${s.type}) does not apply \u2014 only read-and-advise lanes drop the checkout credential; a lane that pushes needs it`)),s.attrs.repo_guides!==void 0&&(typeof s.attrs.repo_guides!="boolean"?w("node.bad-repo-guides",`repo_guides= on '${s.id}' must be true or false, got ${JSON.stringify(s.attrs.repo_guides)}`):!et.has(s.type)&&s.type!=="fan_in"&&w("node.repo-guides-unsupported",`repo_guides= on '${s.id}' (type ${s.type}) does not apply \u2014 this node runs no agent`)),s.attrs.cancel_in_progress!==void 0&&(typeof s.attrs.cancel_in_progress!="boolean"&&t.push({level:"error",code:"node.bad-cancel-in-progress",message:`cancel_in_progress= on '${s.id}' must be true or false, got ${JSON.stringify(s.attrs.cancel_in_progress)}`,where:{node:s.id,line:s.line}}),!et.has(s.type)||o.has(s.id)?t.push({level:"warning",code:"node.cancel-in-progress-ignored",message:`cancel_in_progress= on '${s.id}' is ignored \u2014 it applies to an agent node that owns its own workflow`,where:{node:s.id,line:s.line},hint:"set it on a standalone agent lane (analyst, issue-agent, producer, pr-review, pr-fix, scheduled-agent)"}):s.attrs.cancel_in_progress===!0&&(s.type==="producer"||s.type==="pr-fix"||s.type==="scheduled-agent"&&s.attrs.commit!=="none")&&t.push({level:"warning",code:"node.cancel-in-progress-discards-work",message:`cancel_in_progress=true on '${s.id}' (type ${s.type}): a cancelled run skips the commit/push salvage, so whatever the agent had written but not yet pushed is lost`,where:{node:s.id,line:s.line},hint:"keep it for lanes where the newer event supersedes the older run's work; otherwise leave the default (queue)"})),s.attrs.checkout!==void 0&&(s.attrs.checkout!=="partial"?t.push({level:"error",code:"node.bad-checkout",message:`checkout= on '${s.id}' must be "partial", got ${JSON.stringify(s.attrs.checkout)}`,where:{node:s.id,line:s.line},hint:`checkout="partial" is a blob-less clone with full history; omit the attr for the lane's default checkout`}):(s.type==="start"||s.type==="exit"||s.type==="parallel"||s.type==="human-gate")&&t.push({level:"warning",code:"node.checkout-ignored",message:`checkout= on '${s.id}' (type ${s.type}) is ignored \u2014 this node checks nothing out`,where:{node:s.id,line:s.line}})),s.attrs.gates!==void 0)try{On(s)}catch(m){t.push({level:"error",code:"node.bad-gates",message:m.message,where:{node:s.id,line:s.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(s.attrs.skip!==void 0){let m=[];try{m=Tn(s)}catch(y){t.push({level:"error",code:"node.bad-skip",message:y.message,where:{node:s.id,line:s.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}(s.type==="pr-review"||s.type==="analyst")&&Ee(s)&&s.attrs.schedule===void 0&&!o.has(s.id)||t.push({level:"error",code:"node.skip-unsupported",message:`skip= on '${s.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:s.id,line:s.line},hint:s.attrs.select!==void 0||s.attrs.schedule!==void 0?'a scheduled (select="sweep") lane picks its own PRs; skip= guards a lane that reacts to PR events':o.has(s.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'}),m.some(y=>y.kind==="unchanged-diff")&&!i.config.identity?.bot_login&&t.push({level:"error",code:"node.skip-needs-bot-login",message:`skip="unchanged-diff" on '${s.id}' compares against the bot's last review, but identity.bot_login is unset`,where:{node:s.id,line:s.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"})}s.attrs.select!==void 0&&(s.attrs.select!=="sweep"?t.push({level:"error",code:"node.bad-select",message:`select= on '${s.id}' must be "sweep", got ${JSON.stringify(s.attrs.select)}`,where:{node:s.id,line:s.line}}):s.type!=="pr-review"||!Ee(s)||o.has(s.id)?t.push({level:"error",code:"node.select-unsupported",message:`select="sweep" on '${s.id}' needs a standalone pr-review node with context="pr-diff" or "pr-review"`,where:{node:s.id,line:s.line}}):s.attrs.schedule===void 0?t.push({level:"error",code:"node.sweep-no-schedule",message:`select="sweep" on '${s.id}' needs schedule="<cron>" \u2014 a sweep is driven by its schedule, not by PR events`,where:{node:s.id,line:s.line},hint:'e.g. schedule="*/15 * * * *"'}):i.config.identity?.bot_login||t.push({level:"warning",code:"node.sweep-no-bot-login",message:`select="sweep" on '${s.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:s.id,line:s.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the verdict"})),s.type==="human-gate"&&s.attrs.environment===void 0&&t.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${s.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:s.id,line:s.line}}),s.type==="merge-gate"&&!s.files.policy&&t.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${s.id}' has no policy="..."; default merge policy will be used`,where:{node:s.id,line:s.line}})}if(e.fileExists)for(let s of i.nodes)for(let l of["role","policy","prompt","tools"]){let d=s.files[l];d&&!e.fileExists(d)&&t.push({level:"error",code:"file.missing",message:`node '${s.id}' references ${l}="${d}" which does not exist`,where:{node:s.id,line:s.line,file:d}})}if(e.roles){let s=new Map;for(let d of i.nodes)s.set(d.id,[]);for(let d of i.edges){let f=r.get(d.to);f&&s.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 w=s.get(d.id)??[],m=new Set(w.flatMap(y=>[y.node.id.toLowerCase(),l(y.node)])),O=new Set(f.handoffs.map(y=>String(y.to).toLowerCase()));for(let y of f.handoffs)m.has(String(y.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${f.role}' (node '${d.id}') declares a handoff to '${y.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:y,edge:_}of w)y.type==="exit"&&!_.when||!O.has(y.id.toLowerCase())&&!O.has(l(y))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${d.id}' has an out-edge to '${y.id}' not declared as a handoff in role '${f.role}'`,where:{node:d.id,edge:[d.id,y.id]},hint:"document the handoff in the role, or remove the edge"})}}let c=(s,l)=>{if(typeof s=="string"){let d=s.match(/<[A-Za-z][^<>]{0,80}>/);d&&t.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(s))s.forEach((d,f)=>c(d,`${l}[${f}]`));else if(s&&typeof s=="object")for(let[d,f]of Object.entries(s))c(f,l?`${l}.${d}`:d)};if(c(i.config,""),e.fileExists&&(i.config.runtime?.mode??"pinned")==="vendored"){let s=new Set,l=!1;for(let d of i.nodes)et.has(d.type)&&(l=!0,s.add("run-agent")),et.has(d.type)&&d.type!=="scheduled-agent"&&s.add("agent-context"),(d.type==="producer"||d.type==="scheduled-agent")&&s.add("agent-fallback"),d.type==="merge-gate"&&s.add("merge-gate"),d.type==="pr-review"&&d.attrs.gates!==void 0&&s.add("wait-for-checks");for(let d of s)e.fileExists(`actions/${d}/action.yml`)||t.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")&&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:s,memberIds:l}=je(i);for(let d of i.nodes)if(d.type==="parallel"&&!l.has(d.id)&&t.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=s.get(d.id);if(!f)t.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&&t.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 w=f.legIds.filter(m=>r.get(m)?.type==="pr-review");w.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${d.id}' lanes [${w.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(ct(i.config).mode==="github-token"){let s=i.edges.filter(l=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(l.on??"")||/^(label=|verdict=)/.test(l.when??""));s.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 ${s.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(s=>/^verdict=/.test(s.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(s=>s.type==="start"||s.attrs.schedule!==void 0||s.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}P();var Uo=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),Wi=new Set(["start"]);function ht(i){let e=[],t=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 t)o.set(l,[]);for(let l of i.edges)t.has(l.from)&&t.has(l.to)&&o.get(l.from).push(l.to);let a=i.nodes.filter(l=>Wi.has(l.type)||l.attrs.schedule!==void 0||l.type==="merge-gate"),c=new Set,p=a.map(l=>l.id);for(;p.length;){let l=p.pop();if(!c.has(l)){c.add(l);for(let d of o.get(l)??[])p.push(d)}}for(let l of i.nodes)!c.has(l.id)&&!Wi.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&&!Uo.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 Wo(t,o)){if(!(l.length>1||(o.get(l[0])??[]).includes(l[0])))continue;let f=new Set(l),w=[];for(let m of l)for(let O of o.get(m)??[])f.has(O)||w.push({from:m,to:O});w.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)'}):w.some(m=>Go(Bo(i,m.from,m.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 s=new Map;for(let l of i.edges){let d=`${l.on??""}|${l.when??""}`;s.has(l.from)||s.set(l.from,new Map);let f=s.get(l.from);f.has(d)||f.set(d,new Set),f.get(d).add(l.to)}for(let[l,d]of s)for(let[f,w]of d)w.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: ${[...w].join(", ")}`,where:{node:l},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function Bo(i,e,t){return i.edges.find(r=>r.from===e&&r.to===t)?.when}function Go(i){return i?/(>=|>|attempts|max|count|limit)/i.test(i):!1}function Wo(i,e){let t=0,r=new Map,o=new Map,a=new Set,c=[],p=[],s=l=>{r.set(l,t),o.set(l,t),t++,c.push(l),a.add(l);for(let d of e.get(l)??[])r.has(d)?a.has(d)&&o.set(l,Math.min(o.get(l),r.get(d))):(s(d),o.set(l,Math.min(o.get(l),o.get(d))));if(o.get(l)===r.get(l)){let d=[],f;do f=c.pop(),a.delete(f),d.push(f);while(f!==l);p.push(d.reverse())}};for(let l of i)r.has(l)||s(l);return p}P();var Vo=new Set(Ve),Yo=new Set(["pr-review","pr-fix"]);function Ko(i,e){return e.labels?.[i]??i}function Zt(i){return Yo.has(i.type)||i.context==="pr-diff"||i.context==="pr-review"}function zt(i,e,t){let r=(o,a)=>{i[o]??={},i[o].types??=[],i[o].types.includes(a)||i[o].types.push(a)};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(Zt(t))return r("pull_request","synchronize");i.push??={};return;case"workflow_dispatch":i.workflow_dispatch??={};return;default:i[e]??={}}}function mt(i,e){return i==="push"&&Zt(e)?"pull_request.synchronize":i}function jn(i){let[e,t]=i.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function Jo(i,e,t){if(i.on){let o=i.on.split(",").map(c=>c.trim()).filter(Boolean),a=o.map(c=>mt(c,e));return{events:o,guard:i.when?Qt(i.when,a,t):void 0}}if(!i.when)return;let r=i.when;if(r.startsWith("label=")){let o=[Zt(e)?"pull_request.labeled":"issues.labeled"];return{events:o,guard:Qt(r,o,t)}}if(r.startsWith("verdict=")){let o=["pull_request_review.submitted"];return{events:o,guard:Qt(r,o,t)}}}function Qt(i,e,t){if(i.startsWith("label=")){let o=`github.event.label.name == '${Ko(i.slice(6),t)}'`,a=Xo(e);return a?`${o} && ${a}`: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}')`,a=zo(t);return a?`${o} && ${a}`:o}}function Xo(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 zo(i){let e=i.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function Vi(i){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(i)}function Qo(i){let e=i.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function Yi(i,e,t){return qn(i,e,Qo(t))}function Ki(i,e,t,r){return qn(i,e,t?Li(t,r):void 0)}function qn(i,e,t){let r=[...e].filter(Vi);if(!t||r.length===0)return i;let o=[...e].filter(c=>!Vi(c)),a=o.length?`(${o.map(jn).join(" || ")} || ${t})`:t;return i?`(${i}) && ${a}`:a}function Ji(i,e){let t=i.attrs.cancel_in_progress;return typeof t=="boolean"&&Vo.has(i.type)?t:e}function Zo(i){if(i.attrs.schedule!==void 0)return{group:i.id,"cancel-in-progress":Ji(i,!1)};let t=Zt(i)||i.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${i.id}-${t}`,"cancel-in-progress":Ji(i,i.type==="issue-agent")}}function Xi(i){let e={},t=new Map(i.nodes.map(a=>[a.id,a])),r=new Map;for(let a of i.nodes)r.set(a.id,[]);for(let a of i.edges)r.get(a.to)?.push(a);let o=je(i);for(let a of i.nodes){if(a.type==="start"||a.type==="exit"||o.memberIds.has(a.id))continue;let c=o.byFanin.get(a.id);if(c){let _=c.entryEdge,R=t.get(c.legIds[0]),I={},M=(_.on??"").split(",").map(ne=>ne.trim()).filter(Boolean);for(let ne of M)zt(I,ne,R);let D={nodeId:a.id,triggers:I,dispatches:[]},q=new Set(M.map(ne=>mt(ne,R))),Z;try{Z=ut(i.config)}catch{Z=[Rn]}let ie=Ki(Yi(_.when?Qt(_.when,[...q],i.config):void 0,q,i.config),q,Z);ie&&(D.guard=ie);let se=M.some(ne=>mt(ne,R).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";D.concurrency={group:`${a.id}-${se}`,"cancel-in-progress":!1},e[a.id]=D;continue}if(a.type==="parallel"||a.type==="fan_in")continue;let p={},s=new Set,l=new Set,d=new Set,f=[],w=dt(a,i.config),m=!1;if(a.attrs.schedule!==void 0)p.schedule=[{cron:String(a.attrs.schedule)}],p.workflow_dispatch={};else{for(let _ of r.get(a.id)??[]){let R=Jo(_,a,i.config);if(R){for(let I of R.events)zt(p,I,a);for(let I of R.events)d.add(mt(I,a));if(R.guard)s.add(R.guard);else for(let I of R.events)l.add(mt(I,a))}}if(p.pull_request&&Me(a,i.config)&&Fe(a).some(_=>_.kind==="draft")&&(zt(p,"pull_request.ready_for_review",a),d.add("pull_request.ready_for_review"),l.add("pull_request.ready_for_review")),w&&p.pull_request&&Me(a,i.config)&&(d.has("pull_request.labeled")?l.has("pull_request.labeled")||s.add(`(${jn("pull_request.labeled")} && github.event.label.name == ${qt(w)})`):(zt(p,"pull_request.labeled",a),d.add("pull_request.labeled"),l.add("pull_request.labeled"),m=!0)),s.size&&l.size)for(let _ of l)s.add(jn(_))}for(let _ of i.edges)_.from===a.id&&_.do&&f.push({toNode:_.to,when:_.when});let O=Ki(Yi(s.size?[...s].join(" || "):void 0,d,i.config),d,Le(a,i.config),w);m&&w&&(O=qn(O,d,`(github.event.action != 'labeled' || github.event.label.name == ${qt(w)})`));let y={nodeId:a.id,triggers:p,dispatches:f};O&&(y.guard=O),Object.keys(p).length&&(y.concurrency=Zo(a)),e[a.id]=y}return{perNode:e}}P();P();function es(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var oe={},en={},Ne={},zi;function gt(){if(zi)return Ne;zi=1;function i(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function t(c){return Array.isArray(c)?c:i(c)?[]:[c]}function r(c,p){if(p){let s=Object.keys(p);for(let l=0,d=s.length;l<d;l+=1){let f=s[l];c[f]=p[f]}}return c}function o(c,p){let s="";for(let l=0;l<p;l+=1)s+=c;return s}function a(c){return c===0&&Number.NEGATIVE_INFINITY===1/c}return Ne.isNothing=i,Ne.isObject=e,Ne.toArray=t,Ne.repeat=o,Ne.isNegativeZero=a,Ne.extend=r,Ne}var Un,Qi;function bt(){if(Qi)return Un;Qi=1;function i(t,r){let o="",a=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+=`
125
+ Closes #${Ve}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:s,steps:o}}function is(n){let e=n,t=e.node,o=sn(e,{ref:rr,fetchDepth:0},{contents:"write","pull-requests":"write",checks:"read"});if(en(t)){let r=tn(e,zn);o.push(...r.steps),e=r.ctx}let s=typeof t.attrs.max_attempts=="number"?t.attrs.max_attempts:3,a=`<!-- gp-foundry:attempt:${t.id} -->`,l=e.config.labels?.["needs-human"]??"needs-human",u=e.config.identity?.bot_login??"";o.push(ie({id:"attempts",name:`Enforce attempt budget (max ${s})`,env:{GH_TOKEN:ne(e),PR:st,MARKER:a,MAX:String(s),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 "${l}" 2>/dev/null || gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/labels" -f 'labels[]=${l}'`,` gh pr comment "$PR" --body "$(printf '## \u26D4 Attempt budget (${t.id})\\n\\nExhausted (%s/%s requested-changes rounds) \u2014 labeling \`${l}\` 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(`
126
+ `)}));let p="steps.attempts.outputs.exhausted != 'true'";return o.push({...rt(e),if:p}),o.push({...$t(e,"pr-review",st,{framing:"work-item",checks:!0}),if:p}),o.push({...ot(e,{withContext:!0}),if:p,timeoutMinutes:on(xe(t,35))}),o.push(ie({name:"Commit and push fixes",if:`${p} && !cancelled()`,env:{BRANCH:rr},run:["# Commit anything the agent left uncommitted...",'if [ -n "$(git status --porcelain)" ]; then'," git add -A",` git commit -m "agent fix: ${t.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(`
127
+ `)})),{jobId:t.id,name:t.id,permissions:{contents:"write","pull-requests":"write",checks:"read"},timeoutMinutes:xe(t,35),steps:o}}function sr(n){return`gp-foundry/human-approval (${String(n.attrs.environment??"production")})`}var rs="github-actions";function os(n){return`${sr(n)}@${rs}`}function nn(n){if(n.config.verdicts!==void 0)try{let e=je(n.config.verdicts);return[e.approve,e.requestChanges,e.escalate].join(",")}catch{return}}function ss(n){let e=n.node,o=n.inEdges.map(a=>n.nodeById?.(a.from)).filter(a=>!!a&&a.type==="human-gate").map(os);if(he(e))return as(n,o);let s=sn(n,{fetchDepth:0});return s.push({uses:n.actionRef("merge-gate"),name:"Evaluate merge gate",with:{token:ne(n),"checks-token":"${{ github.token }}","policy-path":_e(n,e.files.policy),"base-branch":n.config.repo.base_branch,"branch-prefix":n.config.repo.branch_prefix,...n.config.identity?.bot_login?{"bot-login":n.config.identity.bot_login}:{},...nn(n)?{verdicts:nn(n)}:{},...o.length?{"required-checks":o.join(",")}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write",checks:"read"},timeoutMinutes:xe(e,10),steps:s}}function as(n,e){let t=n.node,o=_t(n,{persistCredentials:!1});o.with={...o.with,token:"${{ github.token }}"};let s;try{s=Be(t)}catch{s=`gp-foundry/approval (${t.id})`}let a=Te(t,n.config),l=Ue(t,n.config),u=Ce(t),p=u.flatMap(d=>d.kind==="label"?[n.config.labels?.[d.label]??d.label]:[]),r=u.some(d=>d.kind==="bot-author");return{jobId:t.id,name:t.id,permissions:{contents:"read","pull-requests":"read",checks:"write"},timeoutMinutes:xe(t,10),steps:[o,{uses:n.actionRef("merge-gate"),name:"Evaluate merge gate (publish check, never merge)",with:{mode:"evaluate","check-name":s,token:"${{ github.token }}","checks-token":"${{ github.token }}","policy-path":_e(n,t.files.policy),"base-branch":n.config.repo.base_branch,"branch-prefix":n.config.repo.branch_prefix,...n.config.identity?.bot_login?{"bot-login":n.config.identity.bot_login}:{},...nn(n)?{verdicts:nn(n)}:{},...e.length?{"required-checks":e.join(",")}:{},...a?{authors:a.join(",")}:{},...a&&l?{"opt-in-label":l}:{},...p.length?{"skip-labels":p.join(",")}:{},...r?{"skip-bot-authors":"true"}:{}}}]}}function ls(n){let e=n.node,t=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:t,steps:[ie({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME:sr(e),HEAD_SHA:Xn,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(`
128
+ `)})]}}function cs(n){let e=n.node,t=n.config,o=sn(n,{fetchDepth:0}),s=typeof e.attrs.commit=="string"?e.attrs.commit:"direct",a=typeof e.attrs.paths=="string"?e.attrs.paths:"";return s==="pr"&&o.push(ie({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(`
129
+ `)})),o.push(rt(n)),o.push({...ot(n,{withContext:!1}),id:"agent",timeoutMinutes:on(xe(e,20))}),s==="pr"?o.push({uses:n.actionRef("agent-fallback"),name:"Commit, push branch, open PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}","base-branch":t.repo.base_branch,token:ne(n),"agent-name":e.id,"scope-path":_e(n,"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.`,...a?{"allowed-paths":a}:{}}}):s==="direct"&&(o.push({uses:n.actionRef("agent-fallback"),name:"Strip protected paths, commit, push",with:{branch:t.repo.base_branch,"base-branch":t.repo.base_branch,token:ne(n),"agent-name":e.id,"scope-path":_e(n,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...a?{"allowed-paths":a}:{}}}),o.push(ie({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(`
130
+ `)})),o.push({uses:n.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:ne(n),"agent-name":e.id,"scope-path":_e(n,"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":n.config.labels?.["needs-human"]??"needs-human",...a?{"allowed-paths":a}:{}}})),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:xe(e,20),steps:o}}function ar(n,e,t){let o=n,s=o.node,a=t?{contents:"read","pull-requests":"write",issues:"write",checks:"read"}:{contents:"read",issues:"write"},l=[],u=it(o,Qn(s,a));if(u&&l.push(u),l.push(_t(o,t?{ref:Xn,fetchDepth:0,persistCredentials:!1}:{persistCredentials:!1})),en(s,t)){let r=tn(o,zn);l.push(...r.steps),o=r.ctx}l.push(rt(o)),l.push($t(o,t?"pr-review":"issue",t?st:Ve,{framing:"baseline",checks:t})),s.files.role&&l.push(ot(o,{withContext:!0}));let p=s.attrs.on_complete_label;if(typeof p=="string"&&p){let r=o.config.labels?.[p]??p;l.push(ie({name:"Apply completion label",env:{GH_TOKEN:ne(o),NUM:t?st:Ve},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${r}'`}))}return or(s,{jobId:s.id,name:s.id,needs:e,permissions:a,timeoutMinutes:xe(s,15),steps:l})}var us={analyst:Jn,"issue-agent":Jn,"pr-review":Jn,producer:ns,"pr-fix":is,"merge-gate":ss,"human-gate":ls,"scheduled-agent":cs,start:()=>null,exit:()=>null};function Zn(n,e,t){let o=us[n.type];if(!o)return null;let s=o(t);return s&&or(n,s)}I();var ds=new Set(Qe);function We(n){let e=new Map(n.nodes.map(l=>[l.id,l])),t=new Map,o=new Map;for(let l of n.nodes)t.set(l.id,[]),o.set(l.id,[]);for(let l of n.edges)t.get(l.to)?.push(l),o.get(l.from)?.push(l);let s=new Map,a=new Set;for(let l of n.nodes){if(l.type!=="fan_in")continue;let u=t.get(l.id)??[];if(u.length<2)continue;let p=[],r,d=!0;for(let $ of u){let E=e.get($.from);if(!E||!ds.has(E.type)){d=!1;break}let b=t.get(E.id)??[],x=o.get(E.id)??[];if(b.length!==1||x.length!==1||x[0].to!==l.id){d=!1;break}let H=e.get(b[0].from);if(!H||H.type!=="parallel"){d=!1;break}if(b[0].on||b[0].when){d=!1;break}if(r===void 0)r=H.id;else if(r!==H.id){d=!1;break}p.push(E.id)}if(!d||r===void 0)continue;let h=t.get(r)??[],y=o.get(r)??[];if(h.length!==1||!h[0].on)continue;let m=new Set(p);if(!(!y.every($=>m.has($.to))||y.length!==p.length)){s.set(l.id,{parallelId:r,entryEdge:h[0],legIds:p,faninId:l.id}),a.add(r);for(let $ of p)a.add($)}}return{byFanin:s,memberIds:a}}I();I();function ps(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var se={},an={},Le={},lr;function Et(){if(lr)return Le;lr=1;function n(l){return typeof l>"u"||l===null}function e(l){return typeof l=="object"&&l!==null}function t(l){return Array.isArray(l)?l:n(l)?[]:[l]}function o(l,u){if(u){let p=Object.keys(u);for(let r=0,d=p.length;r<d;r+=1){let h=p[r];l[h]=u[h]}}return l}function s(l,u){let p="";for(let r=0;r<u;r+=1)p+=l;return p}function a(l){return l===0&&Number.NEGATIVE_INFINITY===1/l}return Le.isNothing=n,Le.isObject=e,Le.toArray=t,Le.repeat=s,Le.isNegativeZero=a,Le.extend=o,Le}var ei,cr;function At(){if(cr)return ei;cr=1;function n(t,o){let s="",a=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(s+='in "'+t.mark.name+'" '),s+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!o&&t.mark.snippet&&(s+=`
40
131
 
41
- `+t.mark.snippet),a+" "+o):a}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)},Un=e,Un}var Bn,Zi;function ts(){if(Zi)return Bn;Zi=1;let i=gt();function e(o,a,c,p,s){let l="",d="",f=Math.floor(s/2)-1;return p-a>f&&(l=" ... ",a=p-f+l.length),c-p>f&&(d=" ...",c=p+f-d.length),{str:l+o.slice(a,c).replace(/\t/g,"\u2192")+d,pos:p-a+l.length}}function t(o,a){return i.repeat(" ",a-o.length)+o}function r(o,a){if(a=Object.create(a||null),!o.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);let c=/\r?\n|\r|\0/g,p=[0],s=[],l,d=-1;for(;l=c.exec(o.buffer);)s.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="",w=Math.min(o.line+a.linesAfter,s.length).toString().length,m=a.maxLength-(a.indent+w+3);for(let y=1;y<=a.linesBefore&&!(d-y<0);y++){let _=e(o.buffer,p[d-y],s[d-y],o.position-(p[d]-p[d-y]),m);f=i.repeat(" ",a.indent)+t((o.line-y+1).toString(),w)+" | "+_.str+`
42
- `+f}let O=e(o.buffer,p[d],s[d],o.position,m);f+=i.repeat(" ",a.indent)+t((o.line+1).toString(),w)+" | "+O.str+`
43
- `,f+=i.repeat("-",a.indent+w+3+O.pos)+`^
44
- `;for(let y=1;y<=a.linesAfter&&!(d+y>=s.length);y++){let _=e(o.buffer,p[d+y],s[d+y],o.position-(p[d]-p[d+y]),m);f+=i.repeat(" ",a.indent)+t((o.line+y+1).toString(),w)+" | "+_.str+`
45
- `}return f.replace(/\n$/,"")}return Bn=r,Bn}var Gn,er;function le(){if(er)return Gn;er=1;let i=bt(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],t=["scalar","sequence","mapping"];function r(a){let c={};return a!==null&&Object.keys(a).forEach(function(p){a[p].forEach(function(s){c[String(s)]=p})}),c}function o(a,c){if(c=c||{},Object.keys(c).forEach(function(p){if(e.indexOf(p)===-1)throw new i('Unknown option "'+p+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(p){return p},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),t.indexOf(this.kind)===-1)throw new i('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Gn=o,Gn}var Wn,tr;function Ar(){if(tr)return Wn;tr=1;let i=bt(),e=le();function t(a,c){let p=[];return a[c].forEach(function(s){let l=p.length;p.forEach(function(d,f){d.tag===s.tag&&d.kind===s.kind&&d.multi===s.multi&&(l=f)}),p[l]=s}),p}function r(){let a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(p){p.multi?(a.multi[p.kind].push(p),a.multi.fallback.push(p)):a[p.kind][p.tag]=a.fallback[p.tag]=p}for(let p=0,s=arguments.length;p<s;p+=1)arguments[p].forEach(c);return a}function o(a){return this.extend(a)}return o.prototype.extend=function(c){let p=[],s=[];if(c instanceof e)s.push(c);else if(Array.isArray(c))s=s.concat(c);else if(c&&(Array.isArray(c.implicit)||Array.isArray(c.explicit)))c.implicit&&(p=p.concat(c.implicit)),c.explicit&&(s=s.concat(c.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.")}),s.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(s),l.compiledImplicit=t(l,"implicit"),l.compiledExplicit=t(l,"explicit"),l.compiledTypeMap=r(l.compiledImplicit,l.compiledExplicit),l},Wn=o,Wn}var Vn,nr;function kr(){if(nr)return Vn;nr=1;let i=le();return Vn=new i("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Vn}var Yn,ir;function Er(){if(ir)return Yn;ir=1;let i=le();return Yn=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Yn}var Kn,rr;function Sr(){if(rr)return Kn;rr=1;let i=le();return Kn=new i("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Kn}var Jn,or;function vr(){if(or)return Jn;or=1;let i=Ar();return Jn=new i({explicit:[kr(),Er(),Sr()]}),Jn}var Xn,sr;function xr(){if(sr)return Xn;sr=1;let i=le();function e(o){if(o===null)return!0;let a=o.length;return a===1&&o==="~"||a===4&&(o==="null"||o==="Null"||o==="NULL")}function t(){return null}function r(o){return o===null}return Xn=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"}),Xn}var zn,ar;function Cr(){if(ar)return zn;ar=1;let i=le();function e(o){if(o===null)return!1;let a=o.length;return a===4&&(o==="true"||o==="True"||o==="TRUE")||a===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 zn=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"}),zn}var Qn,lr;function Or(){if(lr)return Qn;lr=1;let i=gt(),e=le();function t(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 a(l){if(l===null)return!1;let d=l.length,f=0,w=!1;if(!d)return!1;let m=l[f];if((m==="-"||m==="+")&&(m=l[++f]),m==="0"){if(f+1===d)return!0;if(m=l[++f],m==="b"){for(f++;f<d;f++){if(m=l[f],m!=="0"&&m!=="1")return!1;w=!0}return w&&isFinite(c(l))}if(m==="x"){for(f++;f<d;f++){if(!t(l.charCodeAt(f)))return!1;w=!0}return w&&isFinite(c(l))}if(m==="o"){for(f++;f<d;f++){if(!r(l.charCodeAt(f)))return!1;w=!0}return w&&isFinite(c(l))}}for(;f<d;f++){if(!o(l.charCodeAt(f)))return!1;w=!0}return w?isFinite(c(l)):!1}function c(l){let d=l,f=1,w=d[0];if((w==="-"||w==="+")&&(w==="-"&&(f=-1),d=d.slice(1),w=d[0]),d==="0")return 0;if(w==="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 c(l)}function s(l){return Object.prototype.toString.call(l)==="[object Number]"&&l%1===0&&!i.isNegativeZero(l)}return Qn=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:a,construct:p,predicate:s,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"]}}),Qn}var Zn,cr;function Tr(){if(cr)return Zn;cr=1;let i=gt(),e=le(),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(l){return l===null||!t.test(l)?!1:isFinite(parseFloat(l,10))?!0:r.test(l)}function a(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 c=/^[-+]?[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 c.test(f)?f.replace("e",".e"):f}function s(l){return Object.prototype.toString.call(l)==="[object Number]"&&(l%1!==0||i.isNegativeZero(l))}return Zn=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:o,construct:a,predicate:s,represent:p,defaultStyle:"lowercase"}),Zn}var ei,ur;function Rr(){return ur||(ur=1,ei=vr().extend({implicit:[xr(),Cr(),Or(),Tr()]})),ei}var ti,dr;function Nr(){return dr||(dr=1,ti=Rr()),ti}var ni,pr;function Ir(){if(pr)return ni;pr=1;let i=le(),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(c){return c===null?!1:e.exec(c)!==null||t.exec(c)!==null}function o(c){let p=0,s=null,l=e.exec(c);if(l===null&&(l=t.exec(c)),l===null)throw new Error("Date resolve error");let d=+l[1],f=+l[2]-1,w=+l[3];if(!l[4])return new Date(Date.UTC(d,f,w));let m=+l[4],O=+l[5],y=+l[6];if(l[7]){for(p=l[7].slice(0,3);p.length<3;)p+="0";p=+p}if(l[9]){let R=+l[10],I=+(l[11]||0);s=(R*60+I)*6e4,l[9]==="-"&&(s=-s)}let _=new Date(Date.UTC(d,f,w,m,O,y,p));return s&&_.setTime(_.getTime()-s),_}function a(c){return c.toISOString()}return ni=new i("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:o,instanceOf:Date,represent:a}),ni}var ii,fr;function Hr(){if(fr)return ii;fr=1;let i=le();function e(t){return t==="<<"||t===null}return ii=new i("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),ii}var ri,hr;function Pr(){if(hr)return ri;hr=1;let i=le(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
46
- \r`;function t(c){if(c===null)return!1;let p=0,s=c.length,l=e;for(let d=0;d<s;d++){let f=l.indexOf(c.charAt(d));if(!(f>64)){if(f<0)return!1;p+=6}}return p%8===0}function r(c){let p=c.replace(/[\r\n=]/g,""),s=p.length,l=e,d=0,f=[];for(let m=0;m<s;m++)m%4===0&&m&&(f.push(d>>16&255),f.push(d>>8&255),f.push(d&255)),d=d<<6|l.indexOf(p.charAt(m));let w=s%4*6;return w===0?(f.push(d>>16&255),f.push(d>>8&255),f.push(d&255)):w===18?(f.push(d>>10&255),f.push(d>>2&255)):w===12&&f.push(d>>4&255),new Uint8Array(f)}function o(c){let p="",s=0,l=c.length,d=e;for(let w=0;w<l;w++)w%3===0&&w&&(p+=d[s>>18&63],p+=d[s>>12&63],p+=d[s>>6&63],p+=d[s&63]),s=(s<<8)+c[w];let f=l%3;return f===0?(p+=d[s>>18&63],p+=d[s>>12&63],p+=d[s>>6&63],p+=d[s&63]):f===2?(p+=d[s>>10&63],p+=d[s>>4&63],p+=d[s<<2&63],p+=d[64]):f===1&&(p+=d[s>>2&63],p+=d[s<<4&63],p+=d[64],p+=d[64]),p}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return ri=new i("tag:yaml.org,2002:binary",{kind:"scalar",resolve:t,construct:r,predicate:a,represent:o}),ri}var oi,mr;function Fr(){if(mr)return oi;mr=1;let i=le(),e=Object.prototype.hasOwnProperty,t=Object.prototype.toString;function r(a){if(a===null)return!0;let c=[],p=a;for(let s=0,l=p.length;s<l;s+=1){let d=p[s],f=!1;if(t.call(d)!=="[object Object]")return!1;let w;for(w in d)if(e.call(d,w))if(!f)f=!0;else return!1;if(!f)return!1;if(c.indexOf(w)===-1)c.push(w);else return!1}return!0}function o(a){return a!==null?a:[]}return oi=new i("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:o}),oi}var si,gr;function Lr(){if(gr)return si;gr=1;let i=le(),e=Object.prototype.toString;function t(o){if(o===null)return!0;let a=o,c=new Array(a.length);for(let p=0,s=a.length;p<s;p+=1){let l=a[p];if(e.call(l)!=="[object Object]")return!1;let d=Object.keys(l);if(d.length!==1)return!1;c[p]=[d[0],l[d[0]]]}return!0}function r(o){if(o===null)return[];let a=o,c=new Array(a.length);for(let p=0,s=a.length;p<s;p+=1){let l=a[p],d=Object.keys(l);c[p]=[d[0],l[d[0]]]}return c}return si=new i("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:t,construct:r}),si}var ai,br;function Mr(){if(br)return ai;br=1;let i=le(),e=Object.prototype.hasOwnProperty;function t(o){if(o===null)return!0;let a=o;for(let c in a)if(e.call(a,c)&&a[c]!==null)return!1;return!0}function r(o){return o!==null?o:{}}return ai=new i("tag:yaml.org,2002:set",{kind:"mapping",resolve:t,construct:r}),ai}var li,yr;function ui(){return yr||(yr=1,li=Nr().extend({implicit:[Ir(),Hr()],explicit:[Pr(),Fr(),Lr(),Mr()]})),li}var wr;function ns(){if(wr)return en;wr=1;let i=gt(),e=bt(),t=ts(),r=ui(),o=Object.prototype.hasOwnProperty,a=1,c=2,p=3,s=4,l=1,d=2,f=3,w=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,m=/[\x85\u2028\u2029]/,O=/[,\[\]{}]/,y=/^(?:!|!!|![0-9A-Za-z-]+!)$/,_=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function R(n){return Object.prototype.toString.call(n)}function I(n){return n===10||n===13}function M(n){return n===9||n===32}function D(n){return n===9||n===32||n===10||n===13}function q(n){return n===44||n===91||n===93||n===123||n===125}function Z(n){if(n>=48&&n<=57)return n-48;let h=n|32;return h>=97&&h<=102?h-97+10:-1}function ie(n){return n===120?2:n===117?4:n===85?8:0}function me(n){return n>=48&&n<=57?n-48:-1}function se(n){switch(n){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
47
- `;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 ne(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}function ge(n,h,$){h==="__proto__"?Object.defineProperty(n,h,{configurable:!0,enumerable:!0,writable:!0,value:$}):n[h]=$}let j=new Array(256),ue=new Array(256);for(let n=0;n<256;n++)j[n]=se(n)?1:0,ue[n]=se(n);function ee(n,h){this.input=n,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=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 ae(n,h){let $={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return $.snippet=t($),new e(h,$)}function H(n,h){throw ae(n,h)}function Ue(n,h){n.onWarning&&n.onWarning.call(null,ae(n,h))}function ye(n,h,$){let E=n.anchorMapTransactions;if(E.length!==0){let b=E[E.length-1];o.call(b,h)||(b[h]={existed:o.call(n.anchorMap,h),value:n.anchorMap[h]})}n.anchorMap[h]=$}function on(n){n.anchorMapTransactions.push(Object.create(null))}function Pe(n){let h=n.anchorMapTransactions.pop(),$=n.anchorMapTransactions;if($.length===0)return;let E=$[$.length-1],b=Object.keys(h);for(let C=0,u=b.length;C<u;C+=1){let g=b[C];o.call(E,g)||(E[g]=h[g])}}function sn(n){let h=n.anchorMapTransactions.pop(),$=Object.keys(h);for(let E=$.length-1;E>=0;E-=1){let b=h[$[E]];b.existed?n.anchorMap[$[E]]=b.value:delete n.anchorMap[$[E]]}}function rt(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 Be(n,h){n.position=h.position,n.line=h.line,n.lineStart=h.lineStart,n.lineIndent=h.lineIndent,n.firstTabInLine=h.firstTabInLine,n.tag=h.tag,n.anchor=h.anchor,n.kind=h.kind,n.result=h.result}let kt={YAML:function(h,$,E){h.version!==null&&H(h,"duplication of %YAML directive"),E.length!==1&&H(h,"YAML directive accepts exactly one argument");let b=/^([0-9]+)\.([0-9]+)$/.exec(E[0]);b===null&&H(h,"ill-formed argument of the YAML directive");let C=parseInt(b[1],10),u=parseInt(b[2],10);C!==1&&H(h,"unacceptable YAML version of the document"),h.version=E[0],h.checkLineBreaks=u<2,u!==1&&u!==2&&Ue(h,"unsupported YAML version of the document")},TAG:function(h,$,E){let b;E.length!==2&&H(h,"TAG directive accepts exactly two arguments");let C=E[0];b=E[1],y.test(C)||H(h,"ill-formed tag handle (first argument) of the TAG directive"),o.call(h.tagMap,C)&&H(h,'there is a previously declared suffix for "'+C+'" tag handle'),_.test(b)||H(h,"ill-formed tag prefix (second argument) of the TAG directive");try{b=decodeURIComponent(b)}catch{H(h,"tag prefix is malformed: "+b)}h.tagMap[C]=b}};function de(n,h,$,E){if(h<$){let b=n.input.slice(h,$);if(E)for(let C=0,u=b.length;C<u;C+=1){let g=b.charCodeAt(C);g===9||g>=32&&g<=1114111||H(n,"expected valid JSON character")}else w.test(b)&&H(n,"the stream contains non-printable characters");n.result+=b}}function Oe(n,h,$,E){i.isObject($)||H(n,"cannot merge mappings; the provided source object is unacceptable");let b=Object.keys($);for(let C=0,u=b.length;C<u;C+=1){let g=b[C];n.maxTotalMergeKeys!==-1&&++n.totalMergeKeys>n.maxTotalMergeKeys&&H(n,"merge keys exceeded maxTotalMergeKeys ("+n.maxTotalMergeKeys+")"),o.call(h,g)||(ge(h,g,$[g]),E[g]=!0)}}function we(n,h,$,E,b,C,u,g,v){if(Array.isArray(b)){b=Array.prototype.slice.call(b);for(let A=0,k=b.length;A<k;A+=1)Array.isArray(b[A])&&H(n,"nested arrays are not supported inside keys"),typeof b=="object"&&R(b[A])==="[object Object]"&&(b[A]="[object Object]")}if(typeof b=="object"&&R(b)==="[object Object]"&&(b="[object Object]"),b=String(b),h===null&&(h={}),E==="tag:yaml.org,2002:merge")if(Array.isArray(C))for(let A=0,k=C.length;A<k;A+=1)Oe(n,h,C[A],$);else Oe(n,h,C,$);else!n.json&&!o.call($,b)&&o.call(h,b)&&(n.line=u||n.line,n.lineStart=g||n.lineStart,n.position=v||n.position,H(n,"duplicated mapping key")),ge(h,b,C),delete $[b];return h}function Ge(n){let h=n.input.charCodeAt(n.position);h===10?n.position++:h===13?(n.position++,n.input.charCodeAt(n.position)===10&&n.position++):H(n,"a line break is expected"),n.line+=1,n.lineStart=n.position,n.firstTabInLine=-1}function z(n,h,$){let E=0,b=n.input.charCodeAt(n.position);for(;b!==0;){for(;M(b);)b===9&&n.firstTabInLine===-1&&(n.firstTabInLine=n.position),b=n.input.charCodeAt(++n.position);if(h&&b===35)do b=n.input.charCodeAt(++n.position);while(b!==10&&b!==13&&b!==0);if(I(b))for(Ge(n),b=n.input.charCodeAt(n.position),E++,n.lineIndent=0;b===32;)n.lineIndent++,b=n.input.charCodeAt(++n.position);else break}return $!==-1&&E!==0&&n.lineIndent<$&&Ue(n,"deficient indentation"),E}function We(n){let h=n.position,$=n.input.charCodeAt(h);return!!(($===45||$===46)&&$===n.input.charCodeAt(h+1)&&$===n.input.charCodeAt(h+2)&&(h+=3,$=n.input.charCodeAt(h),$===0||D($)))}function _e(n,h){h===1?n.result+=" ":h>1&&(n.result+=i.repeat(`
48
- `,h-1))}function Et(n,h,$){let E,b,C,u,g,v,A=n.kind,k=n.result,x=n.input.charCodeAt(n.position);if(D(x)||q(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=n.input.charCodeAt(n.position+1);if(D(S)||$&&q(S))return!1}for(n.kind="scalar",n.result="",E=b=n.position,C=!1;x!==0;){if(x===58){let S=n.input.charCodeAt(n.position+1);if(D(S)||$&&q(S))break}else if(x===35){let S=n.input.charCodeAt(n.position-1);if(D(S))break}else{if(n.position===n.lineStart&&We(n)||$&&q(x))break;if(I(x))if(u=n.line,g=n.lineStart,v=n.lineIndent,z(n,!1,-1),n.lineIndent>=h){C=!0,x=n.input.charCodeAt(n.position);continue}else{n.position=b,n.line=u,n.lineStart=g,n.lineIndent=v;break}}C&&(de(n,E,b,!1),_e(n,n.line-u),E=b=n.position,C=!1),M(x)||(b=n.position+1),x=n.input.charCodeAt(++n.position)}return de(n,E,b,!1),n.result?!0:(n.kind=A,n.result=k,!1)}function St(n,h){let $,E,b=n.input.charCodeAt(n.position);if(b!==39)return!1;for(n.kind="scalar",n.result="",n.position++,$=E=n.position;(b=n.input.charCodeAt(n.position))!==0;)if(b===39)if(de(n,$,n.position,!0),b=n.input.charCodeAt(++n.position),b===39)$=n.position,n.position++,E=n.position;else return!0;else I(b)?(de(n,$,E,!0),_e(n,z(n,!1,h)),$=E=n.position):n.position===n.lineStart&&We(n)?H(n,"unexpected end of the document within a single quoted scalar"):(n.position++,M(b)||(E=n.position));H(n,"unexpected end of the stream within a single quoted scalar")}function ot(n,h){let $,E,b,C=n.input.charCodeAt(n.position);if(C!==34)return!1;for(n.kind="scalar",n.result="",n.position++,$=E=n.position;(C=n.input.charCodeAt(n.position))!==0;){if(C===34)return de(n,$,n.position,!0),n.position++,!0;if(C===92){if(de(n,$,n.position,!0),C=n.input.charCodeAt(++n.position),I(C))z(n,!1,h);else if(C<256&&j[C])n.result+=ue[C],n.position++;else if((b=ie(C))>0){let u=b,g=0;for(;u>0;u--)C=n.input.charCodeAt(++n.position),(b=Z(C))>=0?g=(g<<4)+b:H(n,"expected hexadecimal character");n.result+=ne(g),n.position++}else H(n,"unknown escape sequence");$=E=n.position}else I(C)?(de(n,$,E,!0),_e(n,z(n,!1,h)),$=E=n.position):n.position===n.lineStart&&We(n)?H(n,"unexpected end of the document within a double quoted scalar"):(n.position++,M(C)||(E=n.position))}H(n,"unexpected end of the stream within a double quoted scalar")}function vt(n,h){let $=!0,E,b,C,u=n.tag,g,v=n.anchor,A,k,x,S,N=Object.create(null),T,F,L,U=n.input.charCodeAt(n.position);if(U===91)A=93,S=!1,g=[];else if(U===123)A=125,S=!0,g={};else return!1;for(n.anchor!==null&&ye(n,n.anchor,g),U=n.input.charCodeAt(++n.position);U!==0;){if(z(n,!0,h),U=n.input.charCodeAt(n.position),U===A)return n.position++,n.tag=u,n.anchor=v,n.kind=S?"mapping":"sequence",n.result=g,!0;if($?U===44&&H(n,"expected the node content, but found ','"):H(n,"missed comma between flow collection entries"),F=T=L=null,k=x=!1,U===63){let K=n.input.charCodeAt(n.position+1);D(K)&&(k=x=!0,n.position++,z(n,!0,h))}E=n.line,b=n.lineStart,C=n.position,Ae(n,h,a,!1,!0),F=n.tag,T=n.result,z(n,!0,h),U=n.input.charCodeAt(n.position),(x||n.line===E)&&U===58&&(k=!0,U=n.input.charCodeAt(++n.position),z(n,!0,h),Ae(n,h,a,!1,!0),L=n.result),S?we(n,g,N,F,T,L,E,b,C):k?g.push(we(n,null,N,F,T,L,E,b,C)):g.push(T),z(n,!0,h),U=n.input.charCodeAt(n.position),U===44?($=!0,U=n.input.charCodeAt(++n.position)):$=!1}H(n,"unexpected end of the stream within a flow collection")}function xt(n,h){let $,E=l,b=!1,C=!1,u=h,g=0,v=!1,A,k=n.input.charCodeAt(n.position);if(k===124)$=!1;else if(k===62)$=!0;else return!1;for(n.kind="scalar",n.result="";k!==0;)if(k=n.input.charCodeAt(++n.position),k===43||k===45)l===E?E=k===43?f:d:H(n,"repeat of a chomping mode identifier");else if((A=me(k))>=0)A===0?H(n,"bad explicit indentation width of a block scalar; it cannot be less than one"):C?H(n,"repeat of an indentation width identifier"):(u=h+A-1,C=!0);else break;if(M(k)){do k=n.input.charCodeAt(++n.position);while(M(k));if(k===35)do k=n.input.charCodeAt(++n.position);while(!I(k)&&k!==0)}for(;k!==0;){for(Ge(n),n.lineIndent=0,k=n.input.charCodeAt(n.position);(!C||n.lineIndent<u)&&k===32;)n.lineIndent++,k=n.input.charCodeAt(++n.position);if(!C&&n.lineIndent>u&&(u=n.lineIndent),I(k)){g++;continue}if(!C&&u===0&&H(n,"missing indentation for block scalar"),n.lineIndent<u){E===f?n.result+=i.repeat(`
49
- `,b?1+g:g):E===l&&b&&(n.result+=`
50
- `);break}$?M(k)?(v=!0,n.result+=i.repeat(`
51
- `,b?1+g:g)):v?(v=!1,n.result+=i.repeat(`
52
- `,g+1)):g===0?b&&(n.result+=" "):n.result+=i.repeat(`
53
- `,g):n.result+=i.repeat(`
54
- `,b?1+g:g),b=!0,C=!0,g=0;let x=n.position;for(;!I(k)&&k!==0;)k=n.input.charCodeAt(++n.position);de(n,x,n.position,!1)}return!0}function $e(n,h){let $=n.tag,E=n.anchor,b=[],C=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&ye(n,n.anchor,b);let u=n.input.charCodeAt(n.position);for(;u!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,H(n,"tab characters must not be used in indentation")),u===45);){let g=n.input.charCodeAt(n.position+1);if(!D(g))break;if(C=!0,n.position++,z(n,!0,-1)&&n.lineIndent<=h){b.push(null),u=n.input.charCodeAt(n.position);continue}let v=n.line;if(Ae(n,h,p,!1,!0),b.push(n.result),z(n,!0,-1),u=n.input.charCodeAt(n.position),(n.line===v||n.lineIndent>h)&&u!==0)H(n,"bad indentation of a sequence entry");else if(n.lineIndent<h)break}return C?(n.tag=$,n.anchor=E,n.kind="sequence",n.result=b,!0):!1}function Ct(n,h,$){let E,b,C,u,g=n.tag,v=n.anchor,A={},k=Object.create(null),x=null,S=null,N=null,T=!1,F=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&ye(n,n.anchor,A);let L=n.input.charCodeAt(n.position);for(;L!==0;){!T&&n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,H(n,"tab characters must not be used in indentation"));let U=n.input.charCodeAt(n.position+1),K=n.line;if((L===63||L===58)&&D(U))L===63?(T&&(we(n,A,k,x,S,null,b,C,u),x=S=N=null),F=!0,T=!0,E=!0):T?(T=!1,E=!0):H(n,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),n.position+=1,L=U;else{if(b=n.line,C=n.lineStart,u=n.position,!Ae(n,$,c,!1,!0))break;if(n.line===K){for(L=n.input.charCodeAt(n.position);M(L);)L=n.input.charCodeAt(++n.position);if(L===58)L=n.input.charCodeAt(++n.position),D(L)||H(n,"a whitespace character is expected after the key-value separator within a block mapping"),T&&(we(n,A,k,x,S,null,b,C,u),x=S=N=null),F=!0,T=!1,E=!1,x=n.tag,S=n.result;else if(F)H(n,"can not read an implicit mapping pair; a colon is missed");else return n.tag=g,n.anchor=v,!0}else if(F)H(n,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.tag=g,n.anchor=v,!0}if((n.line===K||n.lineIndent>h)&&(T&&(b=n.line,C=n.lineStart,u=n.position),Ae(n,h,s,!0,E)&&(T?S=n.result:N=n.result),T||(we(n,A,k,x,S,N,b,C,u),x=S=N=null),z(n,!0,-1),L=n.input.charCodeAt(n.position)),(n.line===K||n.lineIndent>h)&&L!==0)H(n,"bad indentation of a mapping entry");else if(n.lineIndent<h)break}return T&&we(n,A,k,x,S,null,b,C,u),F&&(n.tag=g,n.anchor=v,n.kind="mapping",n.result=A),F}function an(n){let h=!1,$=!1,E,b,C=n.input.charCodeAt(n.position);if(C!==33)return!1;n.tag!==null&&H(n,"duplication of a tag property"),C=n.input.charCodeAt(++n.position),C===60?(h=!0,C=n.input.charCodeAt(++n.position)):C===33?($=!0,E="!!",C=n.input.charCodeAt(++n.position)):E="!";let u=n.position;if(h){do C=n.input.charCodeAt(++n.position);while(C!==0&&C!==62);n.position<n.length?(b=n.input.slice(u,n.position),C=n.input.charCodeAt(++n.position)):H(n,"unexpected end of the stream within a verbatim tag")}else{for(;C!==0&&!D(C);)C===33&&($?H(n,"tag suffix cannot contain exclamation marks"):(E=n.input.slice(u-1,n.position+1),y.test(E)||H(n,"named tag handle cannot contain such characters"),$=!0,u=n.position+1)),C=n.input.charCodeAt(++n.position);b=n.input.slice(u,n.position),O.test(b)&&H(n,"tag suffix cannot contain flow indicator characters")}b&&!_.test(b)&&H(n,"tag name cannot contain such characters: "+b);try{b=decodeURIComponent(b)}catch{H(n,"tag name is malformed: "+b)}return h?n.tag=b:o.call(n.tagMap,E)?n.tag=n.tagMap[E]+b:E==="!"?n.tag="!"+b:E==="!!"?n.tag="tag:yaml.org,2002:"+b:H(n,'undeclared tag handle "'+E+'"'),!0}function Ot(n){let h=n.input.charCodeAt(n.position);if(h!==38)return!1;n.anchor!==null&&H(n,"duplication of an anchor property"),h=n.input.charCodeAt(++n.position);let $=n.position;for(;h!==0&&!D(h)&&!q(h);)h=n.input.charCodeAt(++n.position);return n.position===$&&H(n,"name of an anchor node must contain at least one character"),n.anchor=n.input.slice($,n.position),!0}function Tt(n){let h=n.input.charCodeAt(n.position);if(h!==42)return!1;h=n.input.charCodeAt(++n.position);let $=n.position;for(;h!==0&&!D(h)&&!q(h);)h=n.input.charCodeAt(++n.position);n.position===$&&H(n,"name of an alias node must contain at least one character");let E=n.input.slice($,n.position);return o.call(n.anchorMap,E)||H(n,'unidentified alias "'+E+'"'),n.result=n.anchorMap[E],z(n,!0,-1),!0}function ln(n,h,$,E){let b=rt(n);return on(n),Be(n,h),n.tag=null,n.anchor=null,n.kind=null,n.result=null,Ct(n,$,E)&&n.kind==="mapping"?(Pe(n),!0):(sn(n),Be(n,b),!1)}function Ae(n,h,$,E,b){let C,u,g=1,v=!1,A=!1,k=null,x,S,N;n.depth>=n.maxDepth&&H(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=C=u=s===$||p===$;if(E&&z(n,!0,-1)&&(v=!0,n.lineIndent>h?g=1:n.lineIndent===h?g=0:n.lineIndent<h&&(g=-1)),g===1)for(;;){let F=n.input.charCodeAt(n.position),L=rt(n);if(v&&(F===33&&n.tag!==null||F===38&&n.anchor!==null)||!an(n)&&!Ot(n))break;k===null&&(k=L),z(n,!0,-1)?(v=!0,u=T,n.lineIndent>h?g=1:n.lineIndent===h?g=0:n.lineIndent<h&&(g=-1)):u=!1}if(u&&(u=v||b),g===1||s===$)if(a===$||c===$?S=h:S=h+1,N=n.position-n.lineStart,g===1)if(u&&($e(n,N)||Ct(n,N,S))||vt(n,S))A=!0;else{let F=n.input.charCodeAt(n.position);k!==null&&T&&!u&&F!==124&&F!==62&&ln(n,k,k.position-k.lineStart,S)||C&&xt(n,S)||St(n,S)||ot(n,S)?A=!0:Tt(n)?(A=!0,(n.tag!==null||n.anchor!==null)&&H(n,"alias node should not have any properties")):Et(n,S,a===$)&&(A=!0,n.tag===null&&(n.tag="?")),n.anchor!==null&&ye(n,n.anchor,n.result)}else g===0&&(A=u&&$e(n,N));if(n.tag===null)n.anchor!==null&&ye(n,n.anchor,n.result);else if(n.tag==="?"){n.result!==null&&n.kind!=="scalar"&&H(n,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+n.kind+'"');for(let F=0,L=n.implicitTypes.length;F<L;F+=1)if(x=n.implicitTypes[F],x.resolve(n.result)){n.result=x.construct(n.result),n.tag=x.tag,n.anchor!==null&&ye(n,n.anchor,n.result);break}}else if(n.tag!=="!"){if(o.call(n.typeMap[n.kind||"fallback"],n.tag))x=n.typeMap[n.kind||"fallback"][n.tag];else{x=null;let F=n.typeMap.multi[n.kind||"fallback"];for(let L=0,U=F.length;L<U;L+=1)if(n.tag.slice(0,F[L].tag.length)===F[L].tag){x=F[L];break}}x||H(n,"unknown tag !<"+n.tag+">"),n.result!==null&&x.kind!==n.kind&&H(n,"unacceptable node kind for !<"+n.tag+'> tag; it should be "'+x.kind+'", not "'+n.kind+'"'),x.resolve(n.result,n.tag)?(n.result=x.construct(n.result,n.tag),n.anchor!==null&&ye(n,n.anchor,n.result)):H(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||A}function cn(n){let h=n.position,$=!1,E;for(n.version=null,n.checkLineBreaks=n.legacy,n.tagMap=Object.create(null),n.anchorMap=Object.create(null);(E=n.input.charCodeAt(n.position))!==0&&(z(n,!0,-1),E=n.input.charCodeAt(n.position),!(n.lineIndent>0||E!==37));){$=!0,E=n.input.charCodeAt(++n.position);let b=n.position;for(;E!==0&&!D(E);)E=n.input.charCodeAt(++n.position);let C=n.input.slice(b,n.position),u=[];for(C.length<1&&H(n,"directive name must not be less than one character in length");E!==0;){for(;M(E);)E=n.input.charCodeAt(++n.position);if(E===35){do E=n.input.charCodeAt(++n.position);while(E!==0&&!I(E));break}if(I(E))break;for(b=n.position;E!==0&&!D(E);)E=n.input.charCodeAt(++n.position);u.push(n.input.slice(b,n.position))}E!==0&&Ge(n),o.call(kt,C)?kt[C](n,C,u):Ue(n,'unknown document directive "'+C+'"')}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)):$&&H(n,"directives end mark is expected"),Ae(n,n.lineIndent-1,s,!1,!0),z(n,!0,-1),n.checkLineBreaks&&m.test(n.input.slice(h,n.position))&&Ue(n,"non-ASCII line breaks are interpreted as content"),n.documents.push(n.result),n.position===n.lineStart&&We(n)){n.input.charCodeAt(n.position)===46&&(n.position+=3,z(n,!0,-1));return}n.position<n.length-1&&H(n,"end of the stream or a document separator is expected")}function Rt(n,h){n=String(n),h=h||{},n.length!==0&&(n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13&&(n+=`
55
- `),n.charCodeAt(0)===65279&&(n=n.slice(1)));let $=new ee(n,h),E=n.indexOf("\0");for(E!==-1&&($.position=E,H($,"null byte is not allowed in input")),$.input+="\0";$.input.charCodeAt($.position)===32;)$.lineIndent+=1,$.position+=1;for(;$.position<$.length-1;)cn($);return $.documents}function Nt(n,h,$){h!==null&&typeof h=="object"&&typeof $>"u"&&($=h,h=null);let E=Rt(n,$);if(typeof h!="function")return E;for(let b=0,C=E.length;b<C;b+=1)h(E[b])}function un(n,h){let $=Rt(n,h);if($.length!==0){if($.length===1)return $[0];throw new e("expected a single document in the stream, but found more")}}return en.loadAll=Nt,en.load=un,en}var ci={},_r;function is(){if(_r)return ci;_r=1;let i=gt(),e=bt(),t=ui(),r=Object.prototype.toString,o=Object.prototype.hasOwnProperty,a=65279,c=9,p=10,s=13,l=32,d=33,f=34,w=35,m=37,O=38,y=39,_=42,R=44,I=45,M=58,D=61,q=62,Z=63,ie=64,me=91,se=93,ne=96,ge=123,j=124,ue=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 ae=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],H=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Ue(u,g){if(g===null)return{};let v={},A=Object.keys(g);for(let k=0,x=A.length;k<x;k+=1){let S=A[k],N=String(g[S]);S.slice(0,2)==="!!"&&(S="tag:yaml.org,2002:"+S.slice(2));let T=u.compiledTypeMap.fallback[S];T&&o.call(T.styleAliases,N)&&(N=T.styleAliases[N]),v[S]=N}return v}function ye(u){let g,v,A=u.toString(16).toUpperCase();if(u<=255)g="x",v=2;else if(u<=65535)g="u",v=4;else if(u<=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-A.length)+A}let on=1,Pe=2;function sn(u){this.schema=u.schema||t,this.indent=Math.max(1,u.indent||2),this.noArrayIndent=u.noArrayIndent||!1,this.skipInvalid=u.skipInvalid||!1,this.flowLevel=i.isNothing(u.flowLevel)?-1:u.flowLevel,this.styleMap=Ue(this.schema,u.styles||null),this.sortKeys=u.sortKeys||!1,this.lineWidth=u.lineWidth||80,this.noRefs=u.noRefs||!1,this.noCompatMode=u.noCompatMode||!1,this.condenseFlow=u.condenseFlow||!1,this.quotingType=u.quotingType==='"'?Pe:on,this.forceQuotes=u.forceQuotes||!1,this.replacer=typeof u.replacer=="function"?u.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function rt(u,g){let v=i.repeat(" ",g),A=0,k="",x=u.length;for(;A<x;){let S,N=u.indexOf(`
56
- `,A);N===-1?(S=u.slice(A),A=x):(S=u.slice(A,N+1),A=N+1),S.length&&S!==`
57
- `&&(k+=v),k+=S}return k}function Be(u,g){return`
58
- `+i.repeat(" ",u.indent*g)}function kt(u,g){for(let v=0,A=u.implicitTypes.length;v<A;v+=1)if(u.implicitTypes[v].resolve(g))return!0;return!1}function de(u){return u===l||u===c}function Oe(u){return u>=32&&u<=126||u>=161&&u<=55295&&u!==8232&&u!==8233||u>=57344&&u<=65533&&u!==a||u>=65536&&u<=1114111}function we(u){return Oe(u)&&u!==a&&u!==s&&u!==p}function Ge(u,g,v){let A=we(u),k=A&&!de(u);return(v?A:A&&u!==R&&u!==me&&u!==se&&u!==ge&&u!==ue)&&u!==w&&!(g===M&&!k)||we(g)&&!de(g)&&u===w||g===M&&k}function z(u){return Oe(u)&&u!==a&&!de(u)&&u!==I&&u!==Z&&u!==M&&u!==R&&u!==me&&u!==se&&u!==ge&&u!==ue&&u!==w&&u!==O&&u!==_&&u!==d&&u!==j&&u!==D&&u!==q&&u!==y&&u!==f&&u!==m&&u!==ie&&u!==ne}function We(u){return!de(u)&&u!==M}function _e(u,g){let v=u.charCodeAt(g),A;return v>=55296&&v<=56319&&g+1<u.length&&(A=u.charCodeAt(g+1),A>=56320&&A<=57343)?(v-55296)*1024+A-56320+65536:v}function Et(u){return/^\n* /.test(u)}let St=1,ot=2,vt=3,xt=4,$e=5;function Ct(u,g,v,A,k,x,S,N){let T,F=0,L=null,U=!1,K=!1,mi=A!==-1,st=-1,at=z(_e(u,0))&&We(_e(u,u.length-1));if(g||S)for(T=0;T<u.length;F>=65536?T+=2:T++){if(F=_e(u,T),!Oe(F))return $e;at=at&&Ge(F,L,N),L=F}else{for(T=0;T<u.length;F>=65536?T+=2:T++){if(F=_e(u,T),F===p)U=!0,mi&&(K=K||T-st-1>A&&u[st+1]!==" ",st=T);else if(!Oe(F))return $e;at=at&&Ge(F,L,N),L=F}K=K||mi&&T-st-1>A&&u[st+1]!==" "}return!U&&!K?at&&!S&&!k(u)?St:x===Pe?$e:ot:v>9&&Et(u)?$e:S?x===Pe?$e:ot:K?xt:vt}function an(u,g,v,A,k){u.dump=(function(){if(g.length===0)return u.quotingType===Pe?'""':"''";if(!u.noCompatMode&&(ae.indexOf(g)!==-1||H.test(g)))return u.quotingType===Pe?'"'+g+'"':"'"+g+"'";let x=u.indent*Math.max(1,v),S=u.lineWidth===-1?-1:Math.max(Math.min(u.lineWidth,40),u.lineWidth-x),N=A||u.flowLevel>-1&&v>=u.flowLevel;function T(F){return kt(u,F)}switch(Ct(g,N,u.indent,S,T,u.quotingType,u.forceQuotes&&!A,k)){case St:return g;case ot:return"'"+g.replace(/'/g,"''")+"'";case vt:return"|"+Ot(g,u.indent)+Tt(rt(g,x));case xt:return">"+Ot(g,u.indent)+Tt(rt(ln(g,S),x));case $e:return'"'+cn(g)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function Ot(u,g){let v=Et(u)?String(g):"",A=u[u.length-1]===`
59
- `,x=A&&(u[u.length-2]===`
60
- `||u===`
61
- `)?"+":A?"":"-";return v+x+`
62
- `}function Tt(u){return u[u.length-1]===`
63
- `?u.slice(0,-1):u}function ln(u,g){let v=/(\n+)([^\n]*)/g,A=(function(){let N=u.indexOf(`
64
- `);return N=N!==-1?N:u.length,v.lastIndex=N,Ae(u.slice(0,N),g)})(),k=u[0]===`
65
- `||u[0]===" ",x,S;for(;S=v.exec(u);){let N=S[1],T=S[2];x=T[0]===" ",A+=N+(!k&&!x&&T!==""?`
66
- `:"")+Ae(T,g),k=x}return A}function Ae(u,g){if(u===""||u[0]===" ")return u;let v=/ [^ ]/g,A,k=0,x,S=0,N=0,T="";for(;A=v.exec(u);)N=A.index,N-k>g&&(x=S>k?S:N,T+=`
67
- `+u.slice(k,x),k=x+1),S=N;return T+=`
68
- `,u.length-k>g&&S>k?T+=u.slice(k,S)+`
69
- `+u.slice(S+1):T+=u.slice(k),T.slice(1)}function cn(u){let g="",v=0;for(let A=0;A<u.length;v>=65536?A+=2:A++){v=_e(u,A);let k=ee[v];!k&&Oe(v)?(g+=u[A],v>=65536&&(g+=u[A+1])):g+=k||ye(v)}return g}function Rt(u,g,v){let A="",k=u.tag;for(let x=0,S=v.length;x<S;x+=1){let N=v[x];u.replacer&&(N=u.replacer.call(v,String(x),N)),($(u,g,N,!1,!1)||typeof N>"u"&&$(u,g,null,!1,!1))&&(A!==""&&(A+=","+(u.condenseFlow?"":" ")),A+=u.dump)}u.tag=k,u.dump="["+A+"]"}function Nt(u,g,v,A){let k="",x=u.tag;for(let S=0,N=v.length;S<N;S+=1){let T=v[S];u.replacer&&(T=u.replacer.call(v,String(S),T)),($(u,g+1,T,!0,!0,!1,!0)||typeof T>"u"&&$(u,g+1,null,!0,!0,!1,!0))&&((!A||k!=="")&&(k+=Be(u,g)),u.dump&&p===u.dump.charCodeAt(0)?k+="-":k+="- ",k+=u.dump)}u.tag=x,u.dump=k||"[]"}function un(u,g,v){let A="",k=u.tag,x=Object.keys(v);for(let S=0,N=x.length;S<N;S+=1){let T="";A!==""&&(T+=", "),u.condenseFlow&&(T+='"');let F=x[S],L=v[F];u.replacer&&(L=u.replacer.call(v,F,L)),$(u,g,F,!1,!1)&&(u.dump.length>1024&&(T+="? "),T+=u.dump+(u.condenseFlow?'"':"")+":"+(u.condenseFlow?"":" "),$(u,g,L,!1,!1)&&(T+=u.dump,A+=T))}u.tag=k,u.dump="{"+A+"}"}function n(u,g,v,A){let k="",x=u.tag,S=Object.keys(v);if(u.sortKeys===!0)S.sort();else if(typeof u.sortKeys=="function")S.sort(u.sortKeys);else if(u.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let N=0,T=S.length;N<T;N+=1){let F="";(!A||k!=="")&&(F+=Be(u,g));let L=S[N],U=v[L];if(u.replacer&&(U=u.replacer.call(v,L,U)),!$(u,g+1,L,!0,!0,!0))continue;let K=u.tag!==null&&u.tag!=="?"||u.dump&&u.dump.length>1024;K&&(u.dump&&p===u.dump.charCodeAt(0)?F+="?":F+="? "),F+=u.dump,K&&(F+=Be(u,g)),$(u,g+1,U,!0,K)&&(u.dump&&p===u.dump.charCodeAt(0)?F+=":":F+=": ",F+=u.dump,k+=F)}u.tag=x,u.dump=k||"{}"}function h(u,g,v){let A=v?u.explicitTypes:u.implicitTypes;for(let k=0,x=A.length;k<x;k+=1){let S=A[k];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?u.tag=S.representName(g):u.tag=S.tag:u.tag="?",S.represent){let N=u.styleMap[S.tag]||S.defaultStyle,T;if(r.call(S.represent)==="[object Function]")T=S.represent(g,N);else if(o.call(S.represent,N))T=S.represent[N](g,N);else throw new e("!<"+S.tag+'> tag resolver accepts not "'+N+'" style');u.dump=T}return!0}}return!1}function $(u,g,v,A,k,x,S){u.tag=null,u.dump=v,h(u,v,!1)||h(u,v,!0);let N=r.call(u.dump),T=A;A&&(A=u.flowLevel<0||u.flowLevel>g);let F=N==="[object Object]"||N==="[object Array]",L,U;if(F&&(L=u.duplicates.indexOf(v),U=L!==-1),(u.tag!==null&&u.tag!=="?"||U||u.indent!==2&&g>0)&&(k=!1),U&&u.usedDuplicates[L])u.dump="*ref_"+L;else{if(F&&U&&!u.usedDuplicates[L]&&(u.usedDuplicates[L]=!0),N==="[object Object]")A&&Object.keys(u.dump).length!==0?(n(u,g,u.dump,k),U&&(u.dump="&ref_"+L+u.dump)):(un(u,g,u.dump),U&&(u.dump="&ref_"+L+" "+u.dump));else if(N==="[object Array]")A&&u.dump.length!==0?(u.noArrayIndent&&!S&&g>0?Nt(u,g-1,u.dump,k):Nt(u,g,u.dump,k),U&&(u.dump="&ref_"+L+u.dump)):(Rt(u,g,u.dump),U&&(u.dump="&ref_"+L+" "+u.dump));else if(N==="[object String]")u.tag!=="?"&&an(u,u.dump,g,x,T);else{if(N==="[object Undefined]")return!1;if(u.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+N)}if(u.tag!==null&&u.tag!=="?"){let K=encodeURI(u.tag[0]==="!"?u.tag.slice(1):u.tag).replace(/!/g,"%21");u.tag[0]==="!"?K="!"+K:K.slice(0,18)==="tag:yaml.org,2002:"?K="!!"+K.slice(18):K="!<"+K+">",u.dump=K+" "+u.dump}}return!0}function E(u,g){let v=[],A=[];b(u,v,A);let k=A.length;for(let x=0;x<k;x+=1)g.duplicates.push(v[A[x]]);g.usedDuplicates=new Array(k)}function b(u,g,v){if(u!==null&&typeof u=="object"){let A=g.indexOf(u);if(A!==-1)v.indexOf(A)===-1&&v.push(A);else if(g.push(u),Array.isArray(u))for(let k=0,x=u.length;k<x;k+=1)b(u[k],g,v);else{let k=Object.keys(u);for(let x=0,S=k.length;x<S;x+=1)b(u[k[x]],g,v)}}}function C(u,g){g=g||{};let v=new sn(g);v.noRefs||E(u,v);let A=u;return v.replacer&&(A=v.replacer.call({"":A},"",A)),$(v,0,A,!0,!0)?v.dump+`
70
- `:""}return ci.dump=C,ci}var $r;function rs(){if($r)return oe;$r=1;let i=ns(),e=is();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 oe.Type=le(),oe.Schema=Ar(),oe.FAILSAFE_SCHEMA=vr(),oe.JSON_SCHEMA=Rr(),oe.CORE_SCHEMA=Nr(),oe.DEFAULT_SCHEMA=ui(),oe.load=i.load,oe.loadAll=i.loadAll,oe.dump=e.dump,oe.YAMLException=bt(),oe.types={binary:Pr(),float:Tr(),map:Sr(),null:xr(),pairs:Lr(),set:Mr(),timestamp:Ir(),bool:Cr(),int:Or(),merge:Hr(),omap:Fr(),seq:Er(),str:kr()},oe.safeLoad=t("safeLoad","load"),oe.safeLoadAll=t("safeLoadAll","loadAll"),oe.safeDump=t("safeDump","dump"),oe}var os=rs(),ve=es(os),{Type:Da,Schema:ja,FAILSAFE_SCHEMA:qa,JSON_SCHEMA:Ua,CORE_SCHEMA:Ba,DEFAULT_SCHEMA:Ga,load:Wa,loadAll:Va,dump:Ya,YAMLException:Ka,types:Ja,safeLoad:Xa,safeLoadAll:za,safeDump:Qa}=ve;P();var ss="${{ github.event.pull_request.number }}",as=10,Dr=3,ls=600;function jr(i){return Ye(i.node)?ds(i):Me(i.node,i.config)?us(i):null}function qr(i){return Ye(i.node)?ps(i):null}var cs="github-actions";function us(i){let e=i.node,t=Fe(e),r=Le(e,i.config),o=dt(e,i.config),a={GH_TOKEN:"${{ github.token }}",PR:ss,NODE:e.id,BOT_LOGIN:i.config.identity?.bot_login??""};r&&(a.AUTHORS=r.join(",")),o&&(a.OPT_IN_LABEL=o);let c=["# 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")`];if(r){let s='((.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a))';c.push("",`# authors: only these logins' PRs (case-insensitive)${o?", or a PR carrying the opt-in label":""}.`,"# 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.",...o?[`if ! jq -e '${s} or any(.labels[]?; .name == env.OPT_IN_LABEL)' <<< "$PR_JSON" >/dev/null; then`,` skip "the author $(jq -r '.user.login // "?"' <<< "$PR_JSON") is not in the allowlist and no $OPT_IN_LABEL label"`]:[`if ! jq -e '${s}' <<< "$PR_JSON" >/dev/null; then`,` skip "the author $(jq -r '.user.login // "?"' <<< "$PR_JSON") is not in the allowlist"`],"fi")}let p=0;for(let s of t)if(c.push(""),s.kind==="draft")c.push("# draft",`if [ "$(jq -r '.draft' <<< "$PR_JSON")" = "true" ]; then skip "the PR is a draft"; fi`);else if(s.kind==="bot-author")c.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(s.kind==="label"){p+=1;let l=`SKIP_LABEL_${p}`;a[l]=i.config.labels?.[s.label]??s.label,c.push(`# label:${s.label}`,`if jq -e --arg l "$${l}" 'any(.labels[]?; .name == $l)' <<< "$PR_JSON" >/dev/null; then`,` skip "the PR carries the label $${l}"`,"fi")}else a.MARKER_PREFIX=Bt(e),a.EVENT_ACTION="${{ github.event.action }}",c.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 c.push("","finish"),{jobId:Ke(e),name:`${e.id} skip guard`,displayName:`${e.id} 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:a,run:c.join(`
71
- `)})]}}function ds(i){let e=i.node,t=Le(e,i.config),r=dt(e,i.config),o='((.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a))',a=["# 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${t?", by an allowlisted author":""}${r?" or labelled $OPT_IN_LABEL":""}`,"# 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 \u2014 and at least one check-run exists, unless the PR has","# been quiet for $SETTLE_SECONDS s (a repo with no CI still gets swept)","# undecided no verdict review on this exact head yet, and no earlier","# sweep has already run the lane on it (the swept check)","# not spent fewer than $MAX_FAILURES failed lane runs on this head",`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))",...t?[r?` | select(${o} or ((.labels // []) | any(.name == env.OPT_IN_LABEL)))`:` | select(${o})`]:[],` | "\\(.number) \\(.head.sha) \\((.requested_reviewers | length) + (.requested_teams | length)) \\(now - (.updated_at | fromdateiso8601) | floor) \\(.base.ref)"') || {`,' echo "::error::could not list open pull requests"'," exit 1","}","SELECTED='[]'","while read -r NUM SHA REQUESTED QUIET BASE; do",' [ -n "$NUM" ] || continue',' if [ "$REQUESTED" != "0" ]; then echo "#$NUM: $REQUESTED review request(s) outstanding"; continue; fi'," # One read of the head's check-runs answers four questions: how many exist,"," # how many are still running, has the lane already run here, how often has it failed.",` CHECKS=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100" --paginate --jq '`," .check_runs | [ length,",' ([.[] | select(.status != "completed")] | length),'," ([.[] | select(.name == env.SWEPT_CHECK and .app.slug == env.MARK_APP)] | length),"," ([.[] | select(.name == env.FAILED_CHECK and .app.slug == env.MARK_APP)] | length) ] | @tsv' \\",` | awk '{t+=$1; r+=$2; s+=$3; f+=$4} END {print t+0, r+0, s+0, f+0}') || { echo "#$NUM: could not read check-runs"; continue; }`,' read -r TOTAL RUNNING SWEPT FAILURES <<< "$CHECKS"',' if [ "$RUNNING" != "0" ]; then echo "#$NUM: $RUNNING check-run(s) still running"; continue; fi',' if [ "$TOTAL" = "0" ] && [ "$QUIET" -lt "$SETTLE_SECONDS" ]; then',' echo "#$NUM: no check-run on $SHA yet and the PR changed ${QUIET}s ago \u2014 waiting for CI to register"'," 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.",' if [ "$SWEPT" != "0" ]; then echo "#$NUM: already swept at $SHA"; continue; fi'," # \u2026and a lane that keeps FAILING on a head is not retried forever either.",' if [ "$FAILURES" -ge "$MAX_FAILURES" ]; then echo "#$NUM: gave up on $SHA after $FAILURES failed runs"; 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',' echo "#$NUM: selected at $SHA"',` SELECTED=$(jq -c --argjson n "$NUM" --arg s "$SHA" --arg b "$BASE" '. + [{number: $n, sha: $s, base: $b}]' <<< "$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(`
72
- `);return{jobId:Ke(e),name:`${e.id} sweep select`,displayName:`${e.id} 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:Mi,SWEPT_CHECK:Hn(e),FAILED_CHECK:In(e),MARK_APP:cs,LIMIT:String(as),MAX_FAILURES:String(Dr),SETTLE_SECONDS:String(ls),...t?{AUTHORS:t.join(",")}:{},...r?{OPT_IN_LABEL:r}:{}},run:a})]}}function ps(i){let e=i.node,t=Ke(e);return{jobId:`${e.id}_mark`,name:`${e.id} sweep mark`,displayName:`${e.id} mark`,needs:[t,e.id],if:`\${{ always() && needs.${t}.result == 'success' && needs.${t}.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.${t}.outputs.prs }}`,NODE:e.id,JOB_PREFIX:Ut(e),SWEPT_CHECK:Hn(e),FAILED_CHECK:In(e),MAX_FAILURES:String(Dr),RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:[`JOBS=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/attempts/$RUN_ATTEMPT/jobs?per_page=100" --paginate --jq '`,` .jobs[] | [(.conclusion // "none"), .name] | @tsv') || {`,` echo "::error::could not read this run's jobs \u2014 no head marked, so the next sweep will repeat them"`," exit 1","}","publish() { # <check name> <sha> <title> <summary>",' gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$1" -f head_sha="$2" -f status=completed -f conclusion=neutral \\',' -f "output[title]=$3" -f "output[summary]=$4" >/dev/null',"}","FAILED=0","while read -r NUM SHA; do",' [ -n "$NUM" ] || continue',` RESULT=$(awk -F'\\t' -v n="$JOB_PREFIX$NUM" '$2 == n {print $1}' <<< "$JOBS" | tail -n 1)`,' case "$RESULT" in'," success)",' if publish "$SWEPT_CHECK" "$SHA" "Swept by $NODE" "The $NODE lane ran on $SHA. This is a record that it ran, not a verdict."; 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 ;;"," failure|timed_out)"," # One check-run per failed attempt; the selector counts them and stops at $MAX_FAILURES.",` PRIOR=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100" --paginate --jq '`," [.check_runs[] | select(.name == env.FAILED_CHECK)] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}') || PRIOR=0"," N=$((PRIOR + 1))",' if [ "$N" -ge "$MAX_FAILURES" ]; then',' TITLE="$NODE gave up after $N failed runs"',' SUMMARY="The $NODE lane failed $N times on $SHA and will not be run on this head again. Push a new commit, or re-run the lane by hand, to try again."'," else",' TITLE="$NODE run $N of $MAX_FAILURES failed"',' SUMMARY="The $NODE lane failed on $SHA. The next sweep retries it; after $MAX_FAILURES failures it stops."'," fi",' if publish "$FAILED_CHECK" "$SHA" "$TITLE" "$SUMMARY"; then',' echo "#$NUM: lane $RESULT \u2014 recorded failed run $N of $MAX_FAILURES on $SHA"'," else",' echo "::error::#$NUM: could not record the failed run on $SHA \u2014 its retries are not being counted"'," FAILED=1"," fi ;;"," *)",' echo "#$NUM: lane did not finish (${RESULT:-no job}) \u2014 left for the next sweep, not counted as a failure" ;;'," esac",`done < <(jq -r '.[] | "\\(.number) \\(.sha)"' <<< "$PRS")`,'exit "$FAILED"'].join(`
73
- `)})]}}P();var Ur=[" /^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 di="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.",fs=`${di}
132
+ `+t.mark.snippet),a+" "+s):a}function e(t,o){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=o,this.message=n(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(o){return this.name+": "+n(this,o)},ei=e,ei}var ti,ur;function hs(){if(ur)return ti;ur=1;let n=Et();function e(s,a,l,u,p){let r="",d="",h=Math.floor(p/2)-1;return u-a>h&&(r=" ... ",a=u-h+r.length),l-u>h&&(d=" ...",l=u+h-d.length),{str:r+s.slice(a,l).replace(/\t/g,"\u2192")+d,pos:u-a+r.length}}function t(s,a){return n.repeat(" ",a-s.length)+s}function o(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);let l=/\r?\n|\r|\0/g,u=[0],p=[],r,d=-1;for(;r=l.exec(s.buffer);)p.push(r.index),u.push(r.index+r[0].length),s.position<=r.index&&d<0&&(d=u.length-2);d<0&&(d=u.length-1);let h="",y=Math.min(s.line+a.linesAfter,p.length).toString().length,m=a.maxLength-(a.indent+y+3);for(let E=1;E<=a.linesBefore&&!(d-E<0);E++){let b=e(s.buffer,u[d-E],p[d-E],s.position-(u[d]-u[d-E]),m);h=n.repeat(" ",a.indent)+t((s.line-E+1).toString(),y)+" | "+b.str+`
133
+ `+h}let $=e(s.buffer,u[d],p[d],s.position,m);h+=n.repeat(" ",a.indent)+t((s.line+1).toString(),y)+" | "+$.str+`
134
+ `,h+=n.repeat("-",a.indent+y+3+$.pos)+`^
135
+ `;for(let E=1;E<=a.linesAfter&&!(d+E>=p.length);E++){let b=e(s.buffer,u[d+E],p[d+E],s.position-(u[d]-u[d+E]),m);h+=n.repeat(" ",a.indent)+t((s.line+E+1).toString(),y)+" | "+b.str+`
136
+ `}return h.replace(/\n$/,"")}return ti=o,ti}var ni,dr;function ce(){if(dr)return ni;dr=1;let n=At(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],t=["scalar","sequence","mapping"];function o(a){let l={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(p){l[String(p)]=u})}),l}function s(a,l){if(l=l||{},Object.keys(l).forEach(function(u){if(e.indexOf(u)===-1)throw new n('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=l,this.tag=a,this.kind=l.kind||null,this.resolve=l.resolve||function(){return!0},this.construct=l.construct||function(u){return u},this.instanceOf=l.instanceOf||null,this.predicate=l.predicate||null,this.represent=l.represent||null,this.representName=l.representName||null,this.defaultStyle=l.defaultStyle||null,this.multi=l.multi||!1,this.styleAliases=o(l.styleAliases||null),t.indexOf(this.kind)===-1)throw new n('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return ni=s,ni}var ii,pr;function Ir(){if(pr)return ii;pr=1;let n=At(),e=ce();function t(a,l){let u=[];return a[l].forEach(function(p){let r=u.length;u.forEach(function(d,h){d.tag===p.tag&&d.kind===p.kind&&d.multi===p.multi&&(r=h)}),u[r]=p}),u}function o(){let a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function l(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,p=arguments.length;u<p;u+=1)arguments[u].forEach(l);return a}function s(a){return this.extend(a)}return s.prototype.extend=function(l){let u=[],p=[];if(l instanceof e)p.push(l);else if(Array.isArray(l))p=p.concat(l);else if(l&&(Array.isArray(l.implicit)||Array.isArray(l.explicit)))l.implicit&&(u=u.concat(l.implicit)),l.explicit&&(p=p.concat(l.explicit));else throw new n("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");u.forEach(function(d){if(!(d instanceof e))throw new n("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(d.loadKind&&d.loadKind!=="scalar")throw new n("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 n("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),p.forEach(function(d){if(!(d instanceof e))throw new n("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let r=Object.create(s.prototype);return r.implicit=(this.implicit||[]).concat(u),r.explicit=(this.explicit||[]).concat(p),r.compiledImplicit=t(r,"implicit"),r.compiledExplicit=t(r,"explicit"),r.compiledTypeMap=o(r.compiledImplicit,r.compiledExplicit),r},ii=s,ii}var ri,hr;function Hr(){if(hr)return ri;hr=1;let n=ce();return ri=new n("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),ri}var oi,fr;function Pr(){if(fr)return oi;fr=1;let n=ce();return oi=new n("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),oi}var si,gr;function Lr(){if(gr)return si;gr=1;let n=ce();return si=new n("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),si}var ai,mr;function Dr(){if(mr)return ai;mr=1;let n=Ir();return ai=new n({explicit:[Hr(),Pr(),Lr()]}),ai}var li,br;function Mr(){if(br)return li;br=1;let n=ce();function e(s){if(s===null)return!0;let a=s.length;return a===1&&s==="~"||a===4&&(s==="null"||s==="Null"||s==="NULL")}function t(){return null}function o(s){return s===null}return li=new n("tag:yaml.org,2002:null",{kind:"scalar",resolve:e,construct:t,predicate:o,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),li}var ci,wr;function Fr(){if(wr)return ci;wr=1;let n=ce();function e(s){if(s===null)return!1;let a=s.length;return a===4&&(s==="true"||s==="True"||s==="TRUE")||a===5&&(s==="false"||s==="False"||s==="FALSE")}function t(s){return s==="true"||s==="True"||s==="TRUE"}function o(s){return Object.prototype.toString.call(s)==="[object Boolean]"}return ci=new n("tag:yaml.org,2002:bool",{kind:"scalar",resolve:e,construct:t,predicate:o,represent:{lowercase:function(s){return s?"true":"false"},uppercase:function(s){return s?"TRUE":"FALSE"},camelcase:function(s){return s?"True":"False"}},defaultStyle:"lowercase"}),ci}var ui,yr;function jr(){if(yr)return ui;yr=1;let n=Et(),e=ce();function t(r){return r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102}function o(r){return r>=48&&r<=55}function s(r){return r>=48&&r<=57}function a(r){if(r===null)return!1;let d=r.length,h=0,y=!1;if(!d)return!1;let m=r[h];if((m==="-"||m==="+")&&(m=r[++h]),m==="0"){if(h+1===d)return!0;if(m=r[++h],m==="b"){for(h++;h<d;h++){if(m=r[h],m!=="0"&&m!=="1")return!1;y=!0}return y&&isFinite(l(r))}if(m==="x"){for(h++;h<d;h++){if(!t(r.charCodeAt(h)))return!1;y=!0}return y&&isFinite(l(r))}if(m==="o"){for(h++;h<d;h++){if(!o(r.charCodeAt(h)))return!1;y=!0}return y&&isFinite(l(r))}}for(;h<d;h++){if(!s(r.charCodeAt(h)))return!1;y=!0}return y?isFinite(l(r)):!1}function l(r){let d=r,h=1,y=d[0];if((y==="-"||y==="+")&&(y==="-"&&(h=-1),d=d.slice(1),y=d[0]),d==="0")return 0;if(y==="0"){if(d[1]==="b")return h*parseInt(d.slice(2),2);if(d[1]==="x")return h*parseInt(d.slice(2),16);if(d[1]==="o")return h*parseInt(d.slice(2),8)}return h*parseInt(d,10)}function u(r){return l(r)}function p(r){return Object.prototype.toString.call(r)==="[object Number]"&&r%1===0&&!n.isNegativeZero(r)}return ui=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:a,construct:u,predicate:p,represent:{binary:function(r){return r>=0?"0b"+r.toString(2):"-0b"+r.toString(2).slice(1)},octal:function(r){return r>=0?"0o"+r.toString(8):"-0o"+r.toString(8).slice(1)},decimal:function(r){return r.toString(10)},hexadecimal:function(r){return r>=0?"0x"+r.toString(16).toUpperCase():"-0x"+r.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),ui}var di,_r;function qr(){if(_r)return di;_r=1;let n=Et(),e=ce(),t=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),o=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(r){return r===null||!t.test(r)?!1:isFinite(parseFloat(r,10))?!0:o.test(r)}function a(r){let d=r.toLowerCase(),h=d[0]==="-"?-1:1;return"+-".indexOf(d[0])>=0&&(d=d.slice(1)),d===".inf"?h===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:d===".nan"?NaN:h*parseFloat(d,10)}let l=/^[-+]?[0-9]+e/;function u(r,d){if(isNaN(r))switch(d){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===r)switch(d){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===r)switch(d){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(n.isNegativeZero(r))return"-0.0";let h=r.toString(10);return l.test(h)?h.replace("e",".e"):h}function p(r){return Object.prototype.toString.call(r)==="[object Number]"&&(r%1!==0||n.isNegativeZero(r))}return di=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:p,represent:u,defaultStyle:"lowercase"}),di}var pi,$r;function Ur(){return $r||($r=1,pi=Dr().extend({implicit:[Mr(),Fr(),jr(),qr()]})),pi}var hi,Er;function Br(){return Er||(Er=1,hi=Ur()),hi}var fi,Ar;function Gr(){if(Ar)return fi;Ar=1;let n=ce(),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 o(l){return l===null?!1:e.exec(l)!==null||t.exec(l)!==null}function s(l){let u=0,p=null,r=e.exec(l);if(r===null&&(r=t.exec(l)),r===null)throw new Error("Date resolve error");let d=+r[1],h=+r[2]-1,y=+r[3];if(!r[4])return new Date(Date.UTC(d,h,y));let m=+r[4],$=+r[5],E=+r[6];if(r[7]){for(u=r[7].slice(0,3);u.length<3;)u+="0";u=+u}if(r[9]){let x=+r[10],H=+(r[11]||0);p=(x*60+H)*6e4,r[9]==="-"&&(p=-p)}let b=new Date(Date.UTC(d,h,y,m,$,E,u));return p&&b.setTime(b.getTime()-p),b}function a(l){return l.toISOString()}return fi=new n("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:o,construct:s,instanceOf:Date,represent:a}),fi}var gi,vr;function Vr(){if(vr)return gi;vr=1;let n=ce();function e(t){return t==="<<"||t===null}return gi=new n("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),gi}var mi,kr;function Wr(){if(kr)return mi;kr=1;let n=ce(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
137
+ \r`;function t(l){if(l===null)return!1;let u=0,p=l.length,r=e;for(let d=0;d<p;d++){let h=r.indexOf(l.charAt(d));if(!(h>64)){if(h<0)return!1;u+=6}}return u%8===0}function o(l){let u=l.replace(/[\r\n=]/g,""),p=u.length,r=e,d=0,h=[];for(let m=0;m<p;m++)m%4===0&&m&&(h.push(d>>16&255),h.push(d>>8&255),h.push(d&255)),d=d<<6|r.indexOf(u.charAt(m));let y=p%4*6;return y===0?(h.push(d>>16&255),h.push(d>>8&255),h.push(d&255)):y===18?(h.push(d>>10&255),h.push(d>>2&255)):y===12&&h.push(d>>4&255),new Uint8Array(h)}function s(l){let u="",p=0,r=l.length,d=e;for(let y=0;y<r;y++)y%3===0&&y&&(u+=d[p>>18&63],u+=d[p>>12&63],u+=d[p>>6&63],u+=d[p&63]),p=(p<<8)+l[y];let h=r%3;return h===0?(u+=d[p>>18&63],u+=d[p>>12&63],u+=d[p>>6&63],u+=d[p&63]):h===2?(u+=d[p>>10&63],u+=d[p>>4&63],u+=d[p<<2&63],u+=d[64]):h===1&&(u+=d[p>>2&63],u+=d[p<<4&63],u+=d[64],u+=d[64]),u}function a(l){return Object.prototype.toString.call(l)==="[object Uint8Array]"}return mi=new n("tag:yaml.org,2002:binary",{kind:"scalar",resolve:t,construct:o,predicate:a,represent:s}),mi}var bi,Sr;function Yr(){if(Sr)return bi;Sr=1;let n=ce(),e=Object.prototype.hasOwnProperty,t=Object.prototype.toString;function o(a){if(a===null)return!0;let l=[],u=a;for(let p=0,r=u.length;p<r;p+=1){let d=u[p],h=!1;if(t.call(d)!=="[object Object]")return!1;let y;for(y in d)if(e.call(d,y))if(!h)h=!0;else return!1;if(!h)return!1;if(l.indexOf(y)===-1)l.push(y);else return!1}return!0}function s(a){return a!==null?a:[]}return bi=new n("tag:yaml.org,2002:omap",{kind:"sequence",resolve:o,construct:s}),bi}var wi,Or;function Kr(){if(Or)return wi;Or=1;let n=ce(),e=Object.prototype.toString;function t(s){if(s===null)return!0;let a=s,l=new Array(a.length);for(let u=0,p=a.length;u<p;u+=1){let r=a[u];if(e.call(r)!=="[object Object]")return!1;let d=Object.keys(r);if(d.length!==1)return!1;l[u]=[d[0],r[d[0]]]}return!0}function o(s){if(s===null)return[];let a=s,l=new Array(a.length);for(let u=0,p=a.length;u<p;u+=1){let r=a[u],d=Object.keys(r);l[u]=[d[0],r[d[0]]]}return l}return wi=new n("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:t,construct:o}),wi}var yi,Cr;function Jr(){if(Cr)return yi;Cr=1;let n=ce(),e=Object.prototype.hasOwnProperty;function t(s){if(s===null)return!0;let a=s;for(let l in a)if(e.call(a,l)&&a[l]!==null)return!1;return!0}function o(s){return s!==null?s:{}}return yi=new n("tag:yaml.org,2002:set",{kind:"mapping",resolve:t,construct:o}),yi}var _i,Tr;function Ei(){return Tr||(Tr=1,_i=Br().extend({implicit:[Gr(),Vr()],explicit:[Wr(),Yr(),Kr(),Jr()]})),_i}var xr;function fs(){if(xr)return an;xr=1;let n=Et(),e=At(),t=hs(),o=Ei(),s=Object.prototype.hasOwnProperty,a=1,l=2,u=3,p=4,r=1,d=2,h=3,y=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,m=/[\x85\u2028\u2029]/,$=/[,\[\]{}]/,E=/^(?:!|!!|![0-9A-Za-z-]+!)$/,b=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function x(i){return Object.prototype.toString.call(i)}function H(i){return i===10||i===13}function M(i){return i===9||i===32}function j(i){return i===9||i===32||i===10||i===13}function W(i){return i===44||i===91||i===93||i===123||i===125}function B(i){if(i>=48&&i<=57)return i-48;let f=i|32;return f>=97&&f<=102?f-97+10:-1}function te(i){return i===120?2:i===117?4:i===85?8:0}function me(i){return i>=48&&i<=57?i-48:-1}function ae(i){switch(i){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
138
+ `;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 oe(i){return i<=65535?String.fromCharCode(i):String.fromCharCode((i-65536>>10)+55296,(i-65536&1023)+56320)}function be(i,f,_){f==="__proto__"?Object.defineProperty(i,f,{configurable:!0,enumerable:!0,writable:!0,value:_}):i[f]=_}let F=new Array(256),ue=new Array(256);for(let i=0;i<256;i++)F[i]=ae(i)?1:0,ue[i]=ae(i);function ee(i,f){this.input=i,this.filename=f.filename||null,this.schema=f.schema||o,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=i.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 le(i,f){let _={name:i.filename,buffer:i.input.slice(0,-1),position:i.position,line:i.line,column:i.position-i.lineStart};return _.snippet=t(_),new e(f,_)}function P(i,f){throw le(i,f)}function Ke(i,f){i.onWarning&&i.onWarning.call(null,le(i,f))}function Ee(i,f,_){let k=i.anchorMapTransactions;if(k.length!==0){let w=k[k.length-1];s.call(w,f)||(w[f]={existed:s.call(i.anchorMap,f),value:i.anchorMap[f]})}i.anchorMap[f]=_}function hn(i){i.anchorMapTransactions.push(Object.create(null))}function Fe(i){let f=i.anchorMapTransactions.pop(),_=i.anchorMapTransactions;if(_.length===0)return;let k=_[_.length-1],w=Object.keys(f);for(let T=0,c=w.length;T<c;T+=1){let g=w[T];s.call(k,g)||(k[g]=f[g])}}function fn(i){let f=i.anchorMapTransactions.pop(),_=Object.keys(f);for(let k=_.length-1;k>=0;k-=1){let w=f[_[k]];w.existed?i.anchorMap[_[k]]=w.value:delete i.anchorMap[_[k]]}}function pt(i){return{position:i.position,line:i.line,lineStart:i.lineStart,lineIndent:i.lineIndent,firstTabInLine:i.firstTabInLine,tag:i.tag,anchor:i.anchor,kind:i.kind,result:i.result}}function Je(i,f){i.position=f.position,i.line=f.line,i.lineStart=f.lineStart,i.lineIndent=f.lineIndent,i.firstTabInLine=f.firstTabInLine,i.tag=f.tag,i.anchor=f.anchor,i.kind=f.kind,i.result=f.result}let Nt={YAML:function(f,_,k){f.version!==null&&P(f,"duplication of %YAML directive"),k.length!==1&&P(f,"YAML directive accepts exactly one argument");let w=/^([0-9]+)\.([0-9]+)$/.exec(k[0]);w===null&&P(f,"ill-formed argument of the YAML directive");let T=parseInt(w[1],10),c=parseInt(w[2],10);T!==1&&P(f,"unacceptable YAML version of the document"),f.version=k[0],f.checkLineBreaks=c<2,c!==1&&c!==2&&Ke(f,"unsupported YAML version of the document")},TAG:function(f,_,k){let w;k.length!==2&&P(f,"TAG directive accepts exactly two arguments");let T=k[0];w=k[1],E.test(T)||P(f,"ill-formed tag handle (first argument) of the TAG directive"),s.call(f.tagMap,T)&&P(f,'there is a previously declared suffix for "'+T+'" tag handle'),b.test(w)||P(f,"ill-formed tag prefix (second argument) of the TAG directive");try{w=decodeURIComponent(w)}catch{P(f,"tag prefix is malformed: "+w)}f.tagMap[T]=w}};function de(i,f,_,k){if(f<_){let w=i.input.slice(f,_);if(k)for(let T=0,c=w.length;T<c;T+=1){let g=w.charCodeAt(T);g===9||g>=32&&g<=1114111||P(i,"expected valid JSON character")}else y.test(w)&&P(i,"the stream contains non-printable characters");i.result+=w}}function He(i,f,_,k){n.isObject(_)||P(i,"cannot merge mappings; the provided source object is unacceptable");let w=Object.keys(_);for(let T=0,c=w.length;T<c;T+=1){let g=w[T];i.maxTotalMergeKeys!==-1&&++i.totalMergeKeys>i.maxTotalMergeKeys&&P(i,"merge keys exceeded maxTotalMergeKeys ("+i.maxTotalMergeKeys+")"),s.call(f,g)||(be(f,g,_[g]),k[g]=!0)}}function Ae(i,f,_,k,w,T,c,g,O){if(Array.isArray(w)){w=Array.prototype.slice.call(w);for(let A=0,v=w.length;A<v;A+=1)Array.isArray(w[A])&&P(i,"nested arrays are not supported inside keys"),typeof w=="object"&&x(w[A])==="[object Object]"&&(w[A]="[object Object]")}if(typeof w=="object"&&x(w)==="[object Object]"&&(w="[object Object]"),w=String(w),f===null&&(f={}),k==="tag:yaml.org,2002:merge")if(Array.isArray(T))for(let A=0,v=T.length;A<v;A+=1)He(i,f,T[A],_);else He(i,f,T,_);else!i.json&&!s.call(_,w)&&s.call(f,w)&&(i.line=c||i.line,i.lineStart=g||i.lineStart,i.position=O||i.position,P(i,"duplicated mapping key")),be(f,w,T),delete _[w];return f}function Xe(i){let f=i.input.charCodeAt(i.position);f===10?i.position++:f===13?(i.position++,i.input.charCodeAt(i.position)===10&&i.position++):P(i,"a line break is expected"),i.line+=1,i.lineStart=i.position,i.firstTabInLine=-1}function Q(i,f,_){let k=0,w=i.input.charCodeAt(i.position);for(;w!==0;){for(;M(w);)w===9&&i.firstTabInLine===-1&&(i.firstTabInLine=i.position),w=i.input.charCodeAt(++i.position);if(f&&w===35)do w=i.input.charCodeAt(++i.position);while(w!==10&&w!==13&&w!==0);if(H(w))for(Xe(i),w=i.input.charCodeAt(i.position),k++,i.lineIndent=0;w===32;)i.lineIndent++,w=i.input.charCodeAt(++i.position);else break}return _!==-1&&k!==0&&i.lineIndent<_&&Ke(i,"deficient indentation"),k}function ze(i){let f=i.position,_=i.input.charCodeAt(f);return!!((_===45||_===46)&&_===i.input.charCodeAt(f+1)&&_===i.input.charCodeAt(f+2)&&(f+=3,_=i.input.charCodeAt(f),_===0||j(_)))}function ve(i,f){f===1?i.result+=" ":f>1&&(i.result+=n.repeat(`
139
+ `,f-1))}function It(i,f,_){let k,w,T,c,g,O,A=i.kind,v=i.result,C=i.input.charCodeAt(i.position);if(j(C)||W(C)||C===35||C===38||C===42||C===33||C===124||C===62||C===39||C===34||C===37||C===64||C===96)return!1;if(C===63||C===45){let S=i.input.charCodeAt(i.position+1);if(j(S)||_&&W(S))return!1}for(i.kind="scalar",i.result="",k=w=i.position,T=!1;C!==0;){if(C===58){let S=i.input.charCodeAt(i.position+1);if(j(S)||_&&W(S))break}else if(C===35){let S=i.input.charCodeAt(i.position-1);if(j(S))break}else{if(i.position===i.lineStart&&ze(i)||_&&W(C))break;if(H(C))if(c=i.line,g=i.lineStart,O=i.lineIndent,Q(i,!1,-1),i.lineIndent>=f){T=!0,C=i.input.charCodeAt(i.position);continue}else{i.position=w,i.line=c,i.lineStart=g,i.lineIndent=O;break}}T&&(de(i,k,w,!1),ve(i,i.line-c),k=w=i.position,T=!1),M(C)||(w=i.position+1),C=i.input.charCodeAt(++i.position)}return de(i,k,w,!1),i.result?!0:(i.kind=A,i.result=v,!1)}function Ht(i,f){let _,k,w=i.input.charCodeAt(i.position);if(w!==39)return!1;for(i.kind="scalar",i.result="",i.position++,_=k=i.position;(w=i.input.charCodeAt(i.position))!==0;)if(w===39)if(de(i,_,i.position,!0),w=i.input.charCodeAt(++i.position),w===39)_=i.position,i.position++,k=i.position;else return!0;else H(w)?(de(i,_,k,!0),ve(i,Q(i,!1,f)),_=k=i.position):i.position===i.lineStart&&ze(i)?P(i,"unexpected end of the document within a single quoted scalar"):(i.position++,M(w)||(k=i.position));P(i,"unexpected end of the stream within a single quoted scalar")}function ht(i,f){let _,k,w,T=i.input.charCodeAt(i.position);if(T!==34)return!1;for(i.kind="scalar",i.result="",i.position++,_=k=i.position;(T=i.input.charCodeAt(i.position))!==0;){if(T===34)return de(i,_,i.position,!0),i.position++,!0;if(T===92){if(de(i,_,i.position,!0),T=i.input.charCodeAt(++i.position),H(T))Q(i,!1,f);else if(T<256&&F[T])i.result+=ue[T],i.position++;else if((w=te(T))>0){let c=w,g=0;for(;c>0;c--)T=i.input.charCodeAt(++i.position),(w=B(T))>=0?g=(g<<4)+w:P(i,"expected hexadecimal character");i.result+=oe(g),i.position++}else P(i,"unknown escape sequence");_=k=i.position}else H(T)?(de(i,_,k,!0),ve(i,Q(i,!1,f)),_=k=i.position):i.position===i.lineStart&&ze(i)?P(i,"unexpected end of the document within a double quoted scalar"):(i.position++,M(T)||(k=i.position))}P(i,"unexpected end of the stream within a double quoted scalar")}function Pt(i,f){let _=!0,k,w,T,c=i.tag,g,O=i.anchor,A,v,C,S,N=Object.create(null),R,L,D,q=i.input.charCodeAt(i.position);if(q===91)A=93,S=!1,g=[];else if(q===123)A=125,S=!0,g={};else return!1;for(i.anchor!==null&&Ee(i,i.anchor,g),q=i.input.charCodeAt(++i.position);q!==0;){if(Q(i,!0,f),q=i.input.charCodeAt(i.position),q===A)return i.position++,i.tag=c,i.anchor=O,i.kind=S?"mapping":"sequence",i.result=g,!0;if(_?q===44&&P(i,"expected the node content, but found ','"):P(i,"missed comma between flow collection entries"),L=R=D=null,v=C=!1,q===63){let J=i.input.charCodeAt(i.position+1);j(J)&&(v=C=!0,i.position++,Q(i,!0,f))}k=i.line,w=i.lineStart,T=i.position,Se(i,f,a,!1,!0),L=i.tag,R=i.result,Q(i,!0,f),q=i.input.charCodeAt(i.position),(C||i.line===k)&&q===58&&(v=!0,q=i.input.charCodeAt(++i.position),Q(i,!0,f),Se(i,f,a,!1,!0),D=i.result),S?Ae(i,g,N,L,R,D,k,w,T):v?g.push(Ae(i,null,N,L,R,D,k,w,T)):g.push(R),Q(i,!0,f),q=i.input.charCodeAt(i.position),q===44?(_=!0,q=i.input.charCodeAt(++i.position)):_=!1}P(i,"unexpected end of the stream within a flow collection")}function Lt(i,f){let _,k=r,w=!1,T=!1,c=f,g=0,O=!1,A,v=i.input.charCodeAt(i.position);if(v===124)_=!1;else if(v===62)_=!0;else return!1;for(i.kind="scalar",i.result="";v!==0;)if(v=i.input.charCodeAt(++i.position),v===43||v===45)r===k?k=v===43?h:d:P(i,"repeat of a chomping mode identifier");else if((A=me(v))>=0)A===0?P(i,"bad explicit indentation width of a block scalar; it cannot be less than one"):T?P(i,"repeat of an indentation width identifier"):(c=f+A-1,T=!0);else break;if(M(v)){do v=i.input.charCodeAt(++i.position);while(M(v));if(v===35)do v=i.input.charCodeAt(++i.position);while(!H(v)&&v!==0)}for(;v!==0;){for(Xe(i),i.lineIndent=0,v=i.input.charCodeAt(i.position);(!T||i.lineIndent<c)&&v===32;)i.lineIndent++,v=i.input.charCodeAt(++i.position);if(!T&&i.lineIndent>c&&(c=i.lineIndent),H(v)){g++;continue}if(!T&&c===0&&P(i,"missing indentation for block scalar"),i.lineIndent<c){k===h?i.result+=n.repeat(`
140
+ `,w?1+g:g):k===r&&w&&(i.result+=`
141
+ `);break}_?M(v)?(O=!0,i.result+=n.repeat(`
142
+ `,w?1+g:g)):O?(O=!1,i.result+=n.repeat(`
143
+ `,g+1)):g===0?w&&(i.result+=" "):i.result+=n.repeat(`
144
+ `,g):i.result+=n.repeat(`
145
+ `,w?1+g:g),w=!0,T=!0,g=0;let C=i.position;for(;!H(v)&&v!==0;)v=i.input.charCodeAt(++i.position);de(i,C,i.position,!1)}return!0}function ke(i,f){let _=i.tag,k=i.anchor,w=[],T=!1;if(i.firstTabInLine!==-1)return!1;i.anchor!==null&&Ee(i,i.anchor,w);let c=i.input.charCodeAt(i.position);for(;c!==0&&(i.firstTabInLine!==-1&&(i.position=i.firstTabInLine,P(i,"tab characters must not be used in indentation")),c===45);){let g=i.input.charCodeAt(i.position+1);if(!j(g))break;if(T=!0,i.position++,Q(i,!0,-1)&&i.lineIndent<=f){w.push(null),c=i.input.charCodeAt(i.position);continue}let O=i.line;if(Se(i,f,u,!1,!0),w.push(i.result),Q(i,!0,-1),c=i.input.charCodeAt(i.position),(i.line===O||i.lineIndent>f)&&c!==0)P(i,"bad indentation of a sequence entry");else if(i.lineIndent<f)break}return T?(i.tag=_,i.anchor=k,i.kind="sequence",i.result=w,!0):!1}function Dt(i,f,_){let k,w,T,c,g=i.tag,O=i.anchor,A={},v=Object.create(null),C=null,S=null,N=null,R=!1,L=!1;if(i.firstTabInLine!==-1)return!1;i.anchor!==null&&Ee(i,i.anchor,A);let D=i.input.charCodeAt(i.position);for(;D!==0;){!R&&i.firstTabInLine!==-1&&(i.position=i.firstTabInLine,P(i,"tab characters must not be used in indentation"));let q=i.input.charCodeAt(i.position+1),J=i.line;if((D===63||D===58)&&j(q))D===63?(R&&(Ae(i,A,v,C,S,null,w,T,c),C=S=N=null),L=!0,R=!0,k=!0):R?(R=!1,k=!0):P(i,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),i.position+=1,D=q;else{if(w=i.line,T=i.lineStart,c=i.position,!Se(i,_,l,!1,!0))break;if(i.line===J){for(D=i.input.charCodeAt(i.position);M(D);)D=i.input.charCodeAt(++i.position);if(D===58)D=i.input.charCodeAt(++i.position),j(D)||P(i,"a whitespace character is expected after the key-value separator within a block mapping"),R&&(Ae(i,A,v,C,S,null,w,T,c),C=S=N=null),L=!0,R=!1,k=!1,C=i.tag,S=i.result;else if(L)P(i,"can not read an implicit mapping pair; a colon is missed");else return i.tag=g,i.anchor=O,!0}else if(L)P(i,"can not read a block mapping entry; a multiline key may not be an implicit key");else return i.tag=g,i.anchor=O,!0}if((i.line===J||i.lineIndent>f)&&(R&&(w=i.line,T=i.lineStart,c=i.position),Se(i,f,p,!0,k)&&(R?S=i.result:N=i.result),R||(Ae(i,A,v,C,S,N,w,T,c),C=S=N=null),Q(i,!0,-1),D=i.input.charCodeAt(i.position)),(i.line===J||i.lineIndent>f)&&D!==0)P(i,"bad indentation of a mapping entry");else if(i.lineIndent<f)break}return R&&Ae(i,A,v,C,S,null,w,T,c),L&&(i.tag=g,i.anchor=O,i.kind="mapping",i.result=A),L}function gn(i){let f=!1,_=!1,k,w,T=i.input.charCodeAt(i.position);if(T!==33)return!1;i.tag!==null&&P(i,"duplication of a tag property"),T=i.input.charCodeAt(++i.position),T===60?(f=!0,T=i.input.charCodeAt(++i.position)):T===33?(_=!0,k="!!",T=i.input.charCodeAt(++i.position)):k="!";let c=i.position;if(f){do T=i.input.charCodeAt(++i.position);while(T!==0&&T!==62);i.position<i.length?(w=i.input.slice(c,i.position),T=i.input.charCodeAt(++i.position)):P(i,"unexpected end of the stream within a verbatim tag")}else{for(;T!==0&&!j(T);)T===33&&(_?P(i,"tag suffix cannot contain exclamation marks"):(k=i.input.slice(c-1,i.position+1),E.test(k)||P(i,"named tag handle cannot contain such characters"),_=!0,c=i.position+1)),T=i.input.charCodeAt(++i.position);w=i.input.slice(c,i.position),$.test(w)&&P(i,"tag suffix cannot contain flow indicator characters")}w&&!b.test(w)&&P(i,"tag name cannot contain such characters: "+w);try{w=decodeURIComponent(w)}catch{P(i,"tag name is malformed: "+w)}return f?i.tag=w:s.call(i.tagMap,k)?i.tag=i.tagMap[k]+w:k==="!"?i.tag="!"+w:k==="!!"?i.tag="tag:yaml.org,2002:"+w:P(i,'undeclared tag handle "'+k+'"'),!0}function Mt(i){let f=i.input.charCodeAt(i.position);if(f!==38)return!1;i.anchor!==null&&P(i,"duplication of an anchor property"),f=i.input.charCodeAt(++i.position);let _=i.position;for(;f!==0&&!j(f)&&!W(f);)f=i.input.charCodeAt(++i.position);return i.position===_&&P(i,"name of an anchor node must contain at least one character"),i.anchor=i.input.slice(_,i.position),!0}function Ft(i){let f=i.input.charCodeAt(i.position);if(f!==42)return!1;f=i.input.charCodeAt(++i.position);let _=i.position;for(;f!==0&&!j(f)&&!W(f);)f=i.input.charCodeAt(++i.position);i.position===_&&P(i,"name of an alias node must contain at least one character");let k=i.input.slice(_,i.position);return s.call(i.anchorMap,k)||P(i,'unidentified alias "'+k+'"'),i.result=i.anchorMap[k],Q(i,!0,-1),!0}function mn(i,f,_,k){let w=pt(i);return hn(i),Je(i,f),i.tag=null,i.anchor=null,i.kind=null,i.result=null,Dt(i,_,k)&&i.kind==="mapping"?(Fe(i),!0):(fn(i),Je(i,w),!1)}function Se(i,f,_,k,w){let T,c,g=1,O=!1,A=!1,v=null,C,S,N;i.depth>=i.maxDepth&&P(i,"nesting exceeded maxDepth ("+i.maxDepth+")"),i.depth+=1,i.listener!==null&&i.listener("open",i),i.tag=null,i.anchor=null,i.kind=null,i.result=null;let R=T=c=p===_||u===_;if(k&&Q(i,!0,-1)&&(O=!0,i.lineIndent>f?g=1:i.lineIndent===f?g=0:i.lineIndent<f&&(g=-1)),g===1)for(;;){let L=i.input.charCodeAt(i.position),D=pt(i);if(O&&(L===33&&i.tag!==null||L===38&&i.anchor!==null)||!gn(i)&&!Mt(i))break;v===null&&(v=D),Q(i,!0,-1)?(O=!0,c=R,i.lineIndent>f?g=1:i.lineIndent===f?g=0:i.lineIndent<f&&(g=-1)):c=!1}if(c&&(c=O||w),g===1||p===_)if(a===_||l===_?S=f:S=f+1,N=i.position-i.lineStart,g===1)if(c&&(ke(i,N)||Dt(i,N,S))||Pt(i,S))A=!0;else{let L=i.input.charCodeAt(i.position);v!==null&&R&&!c&&L!==124&&L!==62&&mn(i,v,v.position-v.lineStart,S)||T&&Lt(i,S)||Ht(i,S)||ht(i,S)?A=!0:Ft(i)?(A=!0,(i.tag!==null||i.anchor!==null)&&P(i,"alias node should not have any properties")):It(i,S,a===_)&&(A=!0,i.tag===null&&(i.tag="?")),i.anchor!==null&&Ee(i,i.anchor,i.result)}else g===0&&(A=c&&ke(i,N));if(i.tag===null)i.anchor!==null&&Ee(i,i.anchor,i.result);else if(i.tag==="?"){i.result!==null&&i.kind!=="scalar"&&P(i,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+i.kind+'"');for(let L=0,D=i.implicitTypes.length;L<D;L+=1)if(C=i.implicitTypes[L],C.resolve(i.result)){i.result=C.construct(i.result),i.tag=C.tag,i.anchor!==null&&Ee(i,i.anchor,i.result);break}}else if(i.tag!=="!"){if(s.call(i.typeMap[i.kind||"fallback"],i.tag))C=i.typeMap[i.kind||"fallback"][i.tag];else{C=null;let L=i.typeMap.multi[i.kind||"fallback"];for(let D=0,q=L.length;D<q;D+=1)if(i.tag.slice(0,L[D].tag.length)===L[D].tag){C=L[D];break}}C||P(i,"unknown tag !<"+i.tag+">"),i.result!==null&&C.kind!==i.kind&&P(i,"unacceptable node kind for !<"+i.tag+'> tag; it should be "'+C.kind+'", not "'+i.kind+'"'),C.resolve(i.result,i.tag)?(i.result=C.construct(i.result,i.tag),i.anchor!==null&&Ee(i,i.anchor,i.result)):P(i,"cannot resolve a node with !<"+i.tag+"> explicit tag")}return i.listener!==null&&i.listener("close",i),i.depth-=1,i.tag!==null||i.anchor!==null||A}function bn(i){let f=i.position,_=!1,k;for(i.version=null,i.checkLineBreaks=i.legacy,i.tagMap=Object.create(null),i.anchorMap=Object.create(null);(k=i.input.charCodeAt(i.position))!==0&&(Q(i,!0,-1),k=i.input.charCodeAt(i.position),!(i.lineIndent>0||k!==37));){_=!0,k=i.input.charCodeAt(++i.position);let w=i.position;for(;k!==0&&!j(k);)k=i.input.charCodeAt(++i.position);let T=i.input.slice(w,i.position),c=[];for(T.length<1&&P(i,"directive name must not be less than one character in length");k!==0;){for(;M(k);)k=i.input.charCodeAt(++i.position);if(k===35){do k=i.input.charCodeAt(++i.position);while(k!==0&&!H(k));break}if(H(k))break;for(w=i.position;k!==0&&!j(k);)k=i.input.charCodeAt(++i.position);c.push(i.input.slice(w,i.position))}k!==0&&Xe(i),s.call(Nt,T)?Nt[T](i,T,c):Ke(i,'unknown document directive "'+T+'"')}if(Q(i,!0,-1),i.lineIndent===0&&i.input.charCodeAt(i.position)===45&&i.input.charCodeAt(i.position+1)===45&&i.input.charCodeAt(i.position+2)===45?(i.position+=3,Q(i,!0,-1)):_&&P(i,"directives end mark is expected"),Se(i,i.lineIndent-1,p,!1,!0),Q(i,!0,-1),i.checkLineBreaks&&m.test(i.input.slice(f,i.position))&&Ke(i,"non-ASCII line breaks are interpreted as content"),i.documents.push(i.result),i.position===i.lineStart&&ze(i)){i.input.charCodeAt(i.position)===46&&(i.position+=3,Q(i,!0,-1));return}i.position<i.length-1&&P(i,"end of the stream or a document separator is expected")}function jt(i,f){i=String(i),f=f||{},i.length!==0&&(i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
146
+ `),i.charCodeAt(0)===65279&&(i=i.slice(1)));let _=new ee(i,f),k=i.indexOf("\0");for(k!==-1&&(_.position=k,P(_,"null byte is not allowed in input")),_.input+="\0";_.input.charCodeAt(_.position)===32;)_.lineIndent+=1,_.position+=1;for(;_.position<_.length-1;)bn(_);return _.documents}function qt(i,f,_){f!==null&&typeof f=="object"&&typeof _>"u"&&(_=f,f=null);let k=jt(i,_);if(typeof f!="function")return k;for(let w=0,T=k.length;w<T;w+=1)f(k[w])}function wn(i,f){let _=jt(i,f);if(_.length!==0){if(_.length===1)return _[0];throw new e("expected a single document in the stream, but found more")}}return an.loadAll=qt,an.load=wn,an}var $i={},Rr;function gs(){if(Rr)return $i;Rr=1;let n=Et(),e=At(),t=Ei(),o=Object.prototype.toString,s=Object.prototype.hasOwnProperty,a=65279,l=9,u=10,p=13,r=32,d=33,h=34,y=35,m=37,$=38,E=39,b=42,x=44,H=45,M=58,j=61,W=62,B=63,te=64,me=91,ae=93,oe=96,be=123,F=124,ue=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 le=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],P=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Ke(c,g){if(g===null)return{};let O={},A=Object.keys(g);for(let v=0,C=A.length;v<C;v+=1){let S=A[v],N=String(g[S]);S.slice(0,2)==="!!"&&(S="tag:yaml.org,2002:"+S.slice(2));let R=c.compiledTypeMap.fallback[S];R&&s.call(R.styleAliases,N)&&(N=R.styleAliases[N]),O[S]=N}return O}function Ee(c){let g,O,A=c.toString(16).toUpperCase();if(c<=255)g="x",O=2;else if(c<=65535)g="u",O=4;else if(c<=4294967295)g="U",O=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+g+n.repeat("0",O-A.length)+A}let hn=1,Fe=2;function fn(c){this.schema=c.schema||t,this.indent=Math.max(1,c.indent||2),this.noArrayIndent=c.noArrayIndent||!1,this.skipInvalid=c.skipInvalid||!1,this.flowLevel=n.isNothing(c.flowLevel)?-1:c.flowLevel,this.styleMap=Ke(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==='"'?Fe:hn,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 pt(c,g){let O=n.repeat(" ",g),A=0,v="",C=c.length;for(;A<C;){let S,N=c.indexOf(`
147
+ `,A);N===-1?(S=c.slice(A),A=C):(S=c.slice(A,N+1),A=N+1),S.length&&S!==`
148
+ `&&(v+=O),v+=S}return v}function Je(c,g){return`
149
+ `+n.repeat(" ",c.indent*g)}function Nt(c,g){for(let O=0,A=c.implicitTypes.length;O<A;O+=1)if(c.implicitTypes[O].resolve(g))return!0;return!1}function de(c){return c===r||c===l}function He(c){return c>=32&&c<=126||c>=161&&c<=55295&&c!==8232&&c!==8233||c>=57344&&c<=65533&&c!==a||c>=65536&&c<=1114111}function Ae(c){return He(c)&&c!==a&&c!==p&&c!==u}function Xe(c,g,O){let A=Ae(c),v=A&&!de(c);return(O?A:A&&c!==x&&c!==me&&c!==ae&&c!==be&&c!==ue)&&c!==y&&!(g===M&&!v)||Ae(g)&&!de(g)&&c===y||g===M&&v}function Q(c){return He(c)&&c!==a&&!de(c)&&c!==H&&c!==B&&c!==M&&c!==x&&c!==me&&c!==ae&&c!==be&&c!==ue&&c!==y&&c!==$&&c!==b&&c!==d&&c!==F&&c!==j&&c!==W&&c!==E&&c!==h&&c!==m&&c!==te&&c!==oe}function ze(c){return!de(c)&&c!==M}function ve(c,g){let O=c.charCodeAt(g),A;return O>=55296&&O<=56319&&g+1<c.length&&(A=c.charCodeAt(g+1),A>=56320&&A<=57343)?(O-55296)*1024+A-56320+65536:O}function It(c){return/^\n* /.test(c)}let Ht=1,ht=2,Pt=3,Lt=4,ke=5;function Dt(c,g,O,A,v,C,S,N){let R,L=0,D=null,q=!1,J=!1,Ti=A!==-1,ft=-1,gt=Q(ve(c,0))&&ze(ve(c,c.length-1));if(g||S)for(R=0;R<c.length;L>=65536?R+=2:R++){if(L=ve(c,R),!He(L))return ke;gt=gt&&Xe(L,D,N),D=L}else{for(R=0;R<c.length;L>=65536?R+=2:R++){if(L=ve(c,R),L===u)q=!0,Ti&&(J=J||R-ft-1>A&&c[ft+1]!==" ",ft=R);else if(!He(L))return ke;gt=gt&&Xe(L,D,N),D=L}J=J||Ti&&R-ft-1>A&&c[ft+1]!==" "}return!q&&!J?gt&&!S&&!v(c)?Ht:C===Fe?ke:ht:O>9&&It(c)?ke:S?C===Fe?ke:ht:J?Lt:Pt}function gn(c,g,O,A,v){c.dump=(function(){if(g.length===0)return c.quotingType===Fe?'""':"''";if(!c.noCompatMode&&(le.indexOf(g)!==-1||P.test(g)))return c.quotingType===Fe?'"'+g+'"':"'"+g+"'";let C=c.indent*Math.max(1,O),S=c.lineWidth===-1?-1:Math.max(Math.min(c.lineWidth,40),c.lineWidth-C),N=A||c.flowLevel>-1&&O>=c.flowLevel;function R(L){return Nt(c,L)}switch(Dt(g,N,c.indent,S,R,c.quotingType,c.forceQuotes&&!A,v)){case Ht:return g;case ht:return"'"+g.replace(/'/g,"''")+"'";case Pt:return"|"+Mt(g,c.indent)+Ft(pt(g,C));case Lt:return">"+Mt(g,c.indent)+Ft(pt(mn(g,S),C));case ke:return'"'+bn(g)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function Mt(c,g){let O=It(c)?String(g):"",A=c[c.length-1]===`
150
+ `,C=A&&(c[c.length-2]===`
151
+ `||c===`
152
+ `)?"+":A?"":"-";return O+C+`
153
+ `}function Ft(c){return c[c.length-1]===`
154
+ `?c.slice(0,-1):c}function mn(c,g){let O=/(\n+)([^\n]*)/g,A=(function(){let N=c.indexOf(`
155
+ `);return N=N!==-1?N:c.length,O.lastIndex=N,Se(c.slice(0,N),g)})(),v=c[0]===`
156
+ `||c[0]===" ",C,S;for(;S=O.exec(c);){let N=S[1],R=S[2];C=R[0]===" ",A+=N+(!v&&!C&&R!==""?`
157
+ `:"")+Se(R,g),v=C}return A}function Se(c,g){if(c===""||c[0]===" ")return c;let O=/ [^ ]/g,A,v=0,C,S=0,N=0,R="";for(;A=O.exec(c);)N=A.index,N-v>g&&(C=S>v?S:N,R+=`
158
+ `+c.slice(v,C),v=C+1),S=N;return R+=`
159
+ `,c.length-v>g&&S>v?R+=c.slice(v,S)+`
160
+ `+c.slice(S+1):R+=c.slice(v),R.slice(1)}function bn(c){let g="",O=0;for(let A=0;A<c.length;O>=65536?A+=2:A++){O=ve(c,A);let v=ee[O];!v&&He(O)?(g+=c[A],O>=65536&&(g+=c[A+1])):g+=v||Ee(O)}return g}function jt(c,g,O){let A="",v=c.tag;for(let C=0,S=O.length;C<S;C+=1){let N=O[C];c.replacer&&(N=c.replacer.call(O,String(C),N)),(_(c,g,N,!1,!1)||typeof N>"u"&&_(c,g,null,!1,!1))&&(A!==""&&(A+=","+(c.condenseFlow?"":" ")),A+=c.dump)}c.tag=v,c.dump="["+A+"]"}function qt(c,g,O,A){let v="",C=c.tag;for(let S=0,N=O.length;S<N;S+=1){let R=O[S];c.replacer&&(R=c.replacer.call(O,String(S),R)),(_(c,g+1,R,!0,!0,!1,!0)||typeof R>"u"&&_(c,g+1,null,!0,!0,!1,!0))&&((!A||v!=="")&&(v+=Je(c,g)),c.dump&&u===c.dump.charCodeAt(0)?v+="-":v+="- ",v+=c.dump)}c.tag=C,c.dump=v||"[]"}function wn(c,g,O){let A="",v=c.tag,C=Object.keys(O);for(let S=0,N=C.length;S<N;S+=1){let R="";A!==""&&(R+=", "),c.condenseFlow&&(R+='"');let L=C[S],D=O[L];c.replacer&&(D=c.replacer.call(O,L,D)),_(c,g,L,!1,!1)&&(c.dump.length>1024&&(R+="? "),R+=c.dump+(c.condenseFlow?'"':"")+":"+(c.condenseFlow?"":" "),_(c,g,D,!1,!1)&&(R+=c.dump,A+=R))}c.tag=v,c.dump="{"+A+"}"}function i(c,g,O,A){let v="",C=c.tag,S=Object.keys(O);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 N=0,R=S.length;N<R;N+=1){let L="";(!A||v!=="")&&(L+=Je(c,g));let D=S[N],q=O[D];if(c.replacer&&(q=c.replacer.call(O,D,q)),!_(c,g+1,D,!0,!0,!0))continue;let J=c.tag!==null&&c.tag!=="?"||c.dump&&c.dump.length>1024;J&&(c.dump&&u===c.dump.charCodeAt(0)?L+="?":L+="? "),L+=c.dump,J&&(L+=Je(c,g)),_(c,g+1,q,!0,J)&&(c.dump&&u===c.dump.charCodeAt(0)?L+=":":L+=": ",L+=c.dump,v+=L)}c.tag=C,c.dump=v||"{}"}function f(c,g,O){let A=O?c.explicitTypes:c.implicitTypes;for(let v=0,C=A.length;v<C;v+=1){let S=A[v];if((S.instanceOf||S.predicate)&&(!S.instanceOf||typeof g=="object"&&g instanceof S.instanceOf)&&(!S.predicate||S.predicate(g))){if(O?S.multi&&S.representName?c.tag=S.representName(g):c.tag=S.tag:c.tag="?",S.represent){let N=c.styleMap[S.tag]||S.defaultStyle,R;if(o.call(S.represent)==="[object Function]")R=S.represent(g,N);else if(s.call(S.represent,N))R=S.represent[N](g,N);else throw new e("!<"+S.tag+'> tag resolver accepts not "'+N+'" style');c.dump=R}return!0}}return!1}function _(c,g,O,A,v,C,S){c.tag=null,c.dump=O,f(c,O,!1)||f(c,O,!0);let N=o.call(c.dump),R=A;A&&(A=c.flowLevel<0||c.flowLevel>g);let L=N==="[object Object]"||N==="[object Array]",D,q;if(L&&(D=c.duplicates.indexOf(O),q=D!==-1),(c.tag!==null&&c.tag!=="?"||q||c.indent!==2&&g>0)&&(v=!1),q&&c.usedDuplicates[D])c.dump="*ref_"+D;else{if(L&&q&&!c.usedDuplicates[D]&&(c.usedDuplicates[D]=!0),N==="[object Object]")A&&Object.keys(c.dump).length!==0?(i(c,g,c.dump,v),q&&(c.dump="&ref_"+D+c.dump)):(wn(c,g,c.dump),q&&(c.dump="&ref_"+D+" "+c.dump));else if(N==="[object Array]")A&&c.dump.length!==0?(c.noArrayIndent&&!S&&g>0?qt(c,g-1,c.dump,v):qt(c,g,c.dump,v),q&&(c.dump="&ref_"+D+c.dump)):(jt(c,g,c.dump),q&&(c.dump="&ref_"+D+" "+c.dump));else if(N==="[object String]")c.tag!=="?"&&gn(c,c.dump,g,C,R);else{if(N==="[object Undefined]")return!1;if(c.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+N)}if(c.tag!==null&&c.tag!=="?"){let J=encodeURI(c.tag[0]==="!"?c.tag.slice(1):c.tag).replace(/!/g,"%21");c.tag[0]==="!"?J="!"+J:J.slice(0,18)==="tag:yaml.org,2002:"?J="!!"+J.slice(18):J="!<"+J+">",c.dump=J+" "+c.dump}}return!0}function k(c,g){let O=[],A=[];w(c,O,A);let v=A.length;for(let C=0;C<v;C+=1)g.duplicates.push(O[A[C]]);g.usedDuplicates=new Array(v)}function w(c,g,O){if(c!==null&&typeof c=="object"){let A=g.indexOf(c);if(A!==-1)O.indexOf(A)===-1&&O.push(A);else if(g.push(c),Array.isArray(c))for(let v=0,C=c.length;v<C;v+=1)w(c[v],g,O);else{let v=Object.keys(c);for(let C=0,S=v.length;C<S;C+=1)w(c[v[C]],g,O)}}}function T(c,g){g=g||{};let O=new fn(g);O.noRefs||k(c,O);let A=c;return O.replacer&&(A=O.replacer.call({"":A},"",A)),_(O,0,A,!0,!0)?O.dump+`
161
+ `:""}return $i.dump=T,$i}var Nr;function ms(){if(Nr)return se;Nr=1;let n=fs(),e=gs();function t(o,s){return function(){throw new Error("Function yaml."+o+" is removed in js-yaml 4. Use yaml."+s+" instead, which is now safe by default.")}}return se.Type=ce(),se.Schema=Ir(),se.FAILSAFE_SCHEMA=Dr(),se.JSON_SCHEMA=Ur(),se.CORE_SCHEMA=Br(),se.DEFAULT_SCHEMA=Ei(),se.load=n.load,se.loadAll=n.loadAll,se.dump=e.dump,se.YAMLException=At(),se.types={binary:Wr(),float:qr(),map:Lr(),null:Mr(),pairs:Kr(),set:Jr(),timestamp:Gr(),bool:Fr(),int:jr(),merge:Vr(),omap:Yr(),seq:Pr(),str:Hr()},se.safeLoad=t("safeLoad","load"),se.safeLoadAll=t("safeLoadAll","loadAll"),se.safeDump=t("safeDump","dump"),se}var bs=ms(),Re=ps(bs),{Type:al,Schema:ll,FAILSAFE_SCHEMA:cl,JSON_SCHEMA:ul,CORE_SCHEMA:dl,DEFAULT_SCHEMA:pl,load:hl,loadAll:fl,dump:gl,YAMLException:ml,types:bl,safeLoad:wl,safeLoadAll:yl,safeDump:_l}=Re;var ws=/^---\r?\n([\s\S]*?)\r?\n---/;function at(n){let e=ws.exec(n);if(e)try{let t=Re.load(e[1]);if(t&&typeof t=="object")return t}catch{return}}var lt=new Set(Qe);function vt(n,e={}){let t=[],o=new Map(n.nodes.map(r=>[r.id,r])),s=We(n).memberIds;for(let r of n.nodes)r.declared||t.push({level:"error",code:"node.undeclared",message:`node '${r.id}' is referenced in an edge but never declared`,where:{node:r.id,line:r.line},hint:`add a node statement, e.g. ${r.id} [type=...]`});let a=(r,d,h,y)=>{let m=Ki(r,d);t.push({level:"error",code:"attr.unknown",message:`unknown attribute '${r}=' on ${h} \u2014 it would be silently ignored`,where:y,hint:m?`did you mean '${m}='?`:"see reference/node-types.md for the attributes this version of gp-foundry understands"})};for(let r of n.nodes)for(let d of Object.keys(r.raw))Ln.has(d)||a(d,Ln,`node '${r.id}'`,{node:r.id,line:r.line});for(let r of n.edges)for(let d of Object.keys(r.raw))Dn.has(d)||a(d,Dn,`edge '${r.from} -> ${r.to}'`,{edge:[r.from,r.to],line:r.line});try{je(n.config.verdicts)}catch(r){t.push({level:"error",code:"config.bad-verdicts",message:r.message,hint:"verdicts: [APPROVE, REQUEST_CHANGES, ESCALATE] \u2014 approve, request changes, escalate, in that order"})}try{wt(n.config)}catch(r){t.push({level:"error",code:"config.bad-authors",message:r.message,hint:"repo.authors is a list of GitHub logins, e.g. authors: [dpup]"})}let l=new Map;for(let r of n.nodes){if(!he(r))continue;let d;try{d=Be(r)}catch{continue}let h=l.get(d);h?t.push({level:"error",code:"node.duplicate-check-name",message:`merge gates '${h}' and '${r.id}' both publish the check '${d}'`,where:{node:r.id,line:r.line},hint:"give each evaluate gate its own check_name="}):l.set(d,r.id)}for(let r of n.nodes){if(r.attrs.authors!==void 0)if(!Kt(r)||s.has(r.id))t.push({level:"error",code:"node.authors-unsupported",message:`authors= on '${r.id}' is not supported here \u2014 it binds a standalone pr-review / pr-fix node, an analyst with context="pr-diff" or "pr-review", or a merge-gate with mode="evaluate"`,where:{node:r.id,line:r.line},hint:s.has(r.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{Jt(r,n.config)}catch($){t.push({level:"error",code:"node.bad-authors",message:$.message,where:{node:r.id,line:r.line},hint:'comma-separated GitHub logins, e.g. authors="dpup, octocat"'})}if(r.attrs.opt_in_label!==void 0)if(!Kt(r)||s.has(r.id))t.push({level:"error",code:"node.opt-in-label-unsupported",message:`opt_in_label= on '${r.id}' is not supported here \u2014 it widens the allowlist of a standalone pr-review / pr-fix node, an analyst with context="pr-diff" or "pr-review", or a merge-gate with mode="evaluate"`,where:{node:r.id,line:r.line}});else{try{qn(r,n.config)}catch(E){t.push({level:"error",code:"node.bad-opt-in-label",message:E.message,where:{node:r.id,line:r.line},hint:'a key into labels: in foundry.config.yaml (or a literal label), e.g. opt_in_label="agent_review"'})}let $;try{$=Jt(r,n.config)}catch{$=[]}$===void 0&&t.push({level:"error",code:"node.opt-in-without-authors",message:`opt_in_label= on '${r.id}' has no allowlist to widen \u2014 the lane already runs for every author`,where:{node:r.id,line:r.line},hint:"opt_in_label= widens an allowlist; set authors= or repo.authors, or drop the label to run for everyone"})}if(lt.has(r.type)&&!r.files.role&&t.push({level:"error",code:"node.missing-role",message:`agent node '${r.id}' (type ${r.type}) needs a role="..." job description`,where:{node:r.id,line:r.line}}),r.attrs.permissions!==void 0){try{rn(r)}catch($){t.push({level:"error",code:"node.bad-permissions",message:$.message,where:{node:r.id,line:r.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(r.type==="start"||r.type==="exit"||r.type==="parallel")&&t.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${r.id}' (type ${r.type}) is ignored \u2014 this node emits no workflow job`,where:{node:r.id,line:r.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}if(r.attrs.agent_attempts!==void 0){let $=r.attrs.agent_attempts;(typeof $!="number"||!Number.isInteger($)||$<1)&&t.push({level:"error",code:"node.bad-agent-attempts",message:`agent_attempts= on '${r.id}' must be a whole number >= 1, got ${JSON.stringify($)}`,where:{node:r.id,line:r.line},hint:"1 disables retrying; omit the attr to use run-agent's default \u2014 e.g. agent_attempts=1"}),lt.has(r.type)||t.push({level:"warning",code:"node.agent-attempts-ignored",message:`agent_attempts= on '${r.id}' (type ${r.type}) is ignored \u2014 this node runs no agent`,where:{node:r.id,line:r.line},hint:"move agent_attempts= to the agent lane whose retry budget you meant to change"})}let d=r.type!=="start"&&r.type!=="exit"&&r.type!=="parallel",h=r.type==="analyst"||r.type==="issue-agent"||r.type==="pr-review"||r.type==="fan_in",y=r.type==="pr-fix"||(r.type==="pr-review"||r.type==="analyst")&&we(r)||r.type==="fan_in",m=($,E,b)=>{t.push({level:"error",code:$,message:E,where:{node:r.id,line:r.line},...b?{hint:b}:{}})};if(r.attrs.title!==void 0&&(typeof r.attrs.title!="string"||!r.attrs.title.trim()||r.attrs.title.includes("${{")?m("node.bad-title",`title= on '${r.id}' must be a plain, non-empty string, got ${JSON.stringify(r.attrs.title)}`):(!d||s.has(r.id))&&m("node.title-unsupported",`title= on '${r.id}' has no workflow to name \u2014 this node does not own one`,"set it on the node that owns the workflow (for a diamond, the fan_in)")),r.attrs.harness_ref!==void 0&&(r.attrs.harness_ref!=="base"&&r.attrs.harness_ref!=="head"?m("node.bad-harness-ref",`harness_ref= on '${r.id}' must be "base" or "head", got ${JSON.stringify(r.attrs.harness_ref)}`):y?r.attrs.harness_ref==="head"&&t.push({level:"warning",code:"node.harness-from-head",message:`harness_ref="head" on '${r.id}': its role, scope and setup composite are read from the PR under review, so a PR can rewrite the instructions it is judged by \u2014 and the setup step that runs with this job's secrets`,where:{node:r.id,line:r.line},hint:"omit harness_ref (the default is the base ref) unless you are testing a harness change in its own PR"}):m("node.harness-ref-unsupported",`harness_ref= on '${r.id}' does not apply \u2014 only a lane handed a pull request chooses between the base ref's harness files and the PR head's`)),r.attrs.persist_credentials!==void 0&&(typeof r.attrs.persist_credentials!="boolean"?m("node.bad-persist-credentials",`persist_credentials= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.persist_credentials)}`):h?r.attrs.persist_credentials===!1&&r.attrs.checkout==="partial"&&m("node.partial-needs-credentials",`'${r.id}' sets checkout="partial" with persist_credentials=false \u2014 a blob-less clone fetches file contents on demand and cannot without the credential`,'drop checkout="partial" (a full clone needs no credential after checkout), or drop persist_credentials=false'):m("node.persist-credentials-unsupported",`persist_credentials= on '${r.id}' (type ${r.type}) does not apply \u2014 only read-and-advise lanes drop the checkout credential; a lane that pushes needs it`)),r.attrs.repo_guides!==void 0&&(typeof r.attrs.repo_guides!="boolean"?m("node.bad-repo-guides",`repo_guides= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.repo_guides)}`):!lt.has(r.type)&&r.type!=="fan_in"&&m("node.repo-guides-unsupported",`repo_guides= on '${r.id}' (type ${r.type}) does not apply \u2014 this node runs no agent`)),r.attrs.cancel_in_progress!==void 0&&(typeof r.attrs.cancel_in_progress!="boolean"&&t.push({level:"error",code:"node.bad-cancel-in-progress",message:`cancel_in_progress= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.cancel_in_progress)}`,where:{node:r.id,line:r.line}}),!lt.has(r.type)||s.has(r.id)?t.push({level:"warning",code:"node.cancel-in-progress-ignored",message:`cancel_in_progress= on '${r.id}' is ignored \u2014 it applies to an agent node that owns its own workflow`,where:{node:r.id,line:r.line},hint:"set it on a standalone agent lane (analyst, issue-agent, producer, pr-review, pr-fix, scheduled-agent)"}):r.attrs.cancel_in_progress===!0&&(r.type==="producer"||r.type==="pr-fix"||r.type==="scheduled-agent"&&r.attrs.commit!=="none")&&t.push({level:"warning",code:"node.cancel-in-progress-discards-work",message:`cancel_in_progress=true on '${r.id}' (type ${r.type}): a cancelled run skips the commit/push salvage, so whatever the agent had written but not yet pushed is lost`,where:{node:r.id,line:r.line},hint:"keep it for lanes where the newer event supersedes the older run's work; otherwise leave the default (queue)"})),r.attrs.checkout!==void 0&&(r.attrs.checkout!=="partial"?t.push({level:"error",code:"node.bad-checkout",message:`checkout= on '${r.id}' must be "partial", got ${JSON.stringify(r.attrs.checkout)}`,where:{node:r.id,line:r.line},hint:`checkout="partial" is a blob-less clone with full history; omit the attr for the lane's default checkout`}):(r.type==="start"||r.type==="exit"||r.type==="parallel"||r.type==="human-gate")&&t.push({level:"warning",code:"node.checkout-ignored",message:`checkout= on '${r.id}' (type ${r.type}) is ignored \u2014 this node checks nothing out`,where:{node:r.id,line:r.line}})),r.attrs.gates!==void 0)try{Mn(r)}catch($){t.push({level:"error",code:"node.bad-gates",message:$.message,where:{node:r.id,line:r.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(r.attrs.skip!==void 0){let $=[];try{$=Fn(r)}catch(b){t.push({level:"error",code:"node.bad-skip",message:b.message,where:{node:r.id,line:r.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}let E=(r.type==="pr-review"||r.type==="analyst")&&we(r)&&r.attrs.schedule===void 0&&!s.has(r.id);ye(r)&&!s.has(r.id)||he(r)?$.some(b=>b.kind==="unchanged-diff")&&t.push({level:"error",code:"node.skip-unsupported",message:`skip="unchanged-diff" on '${r.id}' is not supported on a ${he(r)?"merge gate":"sweep"} \u2014 it compares a push against the last review, and a ${he(r)?"merge gate":"sweep"} reacts to no push`,where:{node:r.id,line:r.line},hint:he(r)?"keep draft, bot-author and label:<key>":"a sweep already skips a head it has run on; keep draft, bot-author and label:<key>"}):E||t.push({level:"error",code:"node.skip-unsupported",message:`skip= on '${r.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:r.id,line:r.line},hint:r.attrs.select!==void 0||r.attrs.schedule!==void 0?'a scheduled (select="sweep") lane picks its own PRs; skip= guards a lane that reacts to PR events':s.has(r.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'}),$.some(b=>b.kind==="unchanged-diff")&&!n.config.identity?.bot_login&&t.push({level:"error",code:"node.skip-needs-bot-login",message:`skip="unchanged-diff" on '${r.id}' compares against the bot's last review, but identity.bot_login is unset`,where:{node:r.id,line:r.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"})}if(r.attrs.select!==void 0&&(r.attrs.select!=="sweep"?t.push({level:"error",code:"node.bad-select",message:`select= on '${r.id}' must be "sweep", got ${JSON.stringify(r.attrs.select)}`,where:{node:r.id,line:r.line}}):r.type!=="pr-review"||!we(r)||s.has(r.id)?t.push({level:"error",code:"node.select-unsupported",message:`select="sweep" on '${r.id}' needs a standalone pr-review node with context="pr-diff" or "pr-review"`,where:{node:r.id,line:r.line}}):r.attrs.schedule===void 0?t.push({level:"error",code:"node.sweep-no-schedule",message:`select="sweep" on '${r.id}' needs schedule="<cron>" \u2014 a sweep is driven by its schedule, not by PR events`,where:{node:r.id,line:r.line},hint:'e.g. schedule="*/15 * * * *"'}):n.config.identity?.bot_login||t.push({level:"warning",code:"node.sweep-no-bot-login",message:`select="sweep" on '${r.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:r.id,line:r.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the verdict"})),r.attrs.post!==void 0)if(r.attrs.post!=="review")t.push({level:"error",code:"node.bad-post",message:`post= on '${r.id}' must be "review", got ${JSON.stringify(r.attrs.post)}`,where:{node:r.id,line:r.line}});else if(!Xt(r)||s.has(r.id))t.push({level:"error",code:"node.post-unsupported",message:`post="review" on '${r.id}' needs a standalone pr-review node, or an analyst, with context="pr-diff" or "pr-review"`,where:{node:r.id,line:r.line}});else{let $=e.roles?.get(r.id)?.tools??(r.files.role&&e.readFile?at(e.readFile(r.files.role)??"")?.tools:void 0);typeof $=="string"&&Kn($)&&t.push({level:"warning",code:"node.post-review-gh-tools",message:`post="review" on '${r.id}': its role still lists gh tools (${$}), but the agent gets no GitHub token \u2014 the post step posts; drop gh from tools`,where:{node:r.id,line:r.line},hint:"remove Bash(gh \u2026) / Bash from the role's tools: front-matter"})}if(r.attrs.post_marker!==void 0)if(r.attrs.post!=="review")t.push({level:"error",code:"node.post-marker-without-post",message:`post_marker= on '${r.id}' needs post="review" \u2014 it heads the review the post step posts`,where:{node:r.id,line:r.line}});else try{zt(r)}catch($){t.push({level:"error",code:"node.bad-post-marker",message:$.message,where:{node:r.id,line:r.line}})}if(r.attrs.requires_review!==void 0&&(typeof r.attrs.requires_review!="boolean"?t.push({level:"error",code:"node.bad-requires-review",message:`requires_review= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.requires_review)}`,where:{node:r.id,line:r.line}}):(!ye(r)||s.has(r.id))&&t.push({level:"error",code:"node.requires-review-unsupported",message:`requires_review= on '${r.id}' is not supported here \u2014 it narrows the heads a select="sweep" lane picks`,where:{node:r.id,line:r.line}})),r.type==="human-gate"&&r.attrs.environment===void 0&&t.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${r.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:r.id,line:r.line}}),r.attrs.mode!==void 0)if(r.type!=="merge-gate")t.push({level:"error",code:"node.mode-unsupported",message:`mode= on '${r.id}' is not supported here \u2014 it selects a merge-gate's mode ("merge" or "evaluate")`,where:{node:r.id,line:r.line}});else try{Un(r)}catch($){t.push({level:"error",code:"node.bad-mode",message:$.message,where:{node:r.id,line:r.line},hint:`mode="evaluate" publishes the gate's result as a check run and never merges`})}if(r.attrs.check_name!==void 0)if(!he(r))t.push({level:"error",code:"node.check-name-without-evaluate",message:`check_name= on '${r.id}' needs a merge-gate with mode="evaluate" \u2014 only that mode publishes a check run`,where:{node:r.id,line:r.line},hint:'add mode="evaluate" to the merge-gate, or drop check_name='});else try{Be(r)}catch($){t.push({level:"error",code:"node.bad-check-name",message:$.message,where:{node:r.id,line:r.line}})}r.type==="merge-gate"&&!r.files.policy&&t.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${r.id}' has no policy="..."; default merge policy will be used`,where:{node:r.id,line:r.line}})}if(e.fileExists)for(let r of n.nodes)for(let d of["role","policy","prompt","tools"]){let h=r.files[d];h&&!e.fileExists(h)&&t.push({level:"error",code:"file.missing",message:`node '${r.id}' references ${d}="${h}" which does not exist`,where:{node:r.id,line:r.line,file:h}})}if(e.roles){let r=new Map;for(let h of n.nodes)r.set(h.id,[]);for(let h of n.edges){let y=o.get(h.to);y&&r.get(h.from)?.push({node:y,edge:h})}let d=h=>(e.roles?.get(h.id)?.role??h.id).toLowerCase();for(let h of n.nodes){let y=e.roles.get(h.id);if(!y?.handoffs)continue;let m=r.get(h.id)??[],$=new Set(m.flatMap(b=>[b.node.id.toLowerCase(),d(b.node)])),E=new Set(y.handoffs.map(b=>String(b.to).toLowerCase()));for(let b of y.handoffs)$.has(String(b.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${y.role}' (node '${h.id}') declares a handoff to '${b.to}' but there is no matching out-edge`,where:{node:h.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:b,edge:x}of m)b.type==="exit"&&!x.when||!E.has(b.id.toLowerCase())&&!E.has(d(b))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${h.id}' has an out-edge to '${b.id}' not declared as a handoff in role '${y.role}'`,where:{node:h.id,edge:[h.id,b.id]},hint:"document the handoff in the role, or remove the edge"})}}let u=(r,d)=>{if(typeof r=="string"){let h=r.match(/<[A-Za-z][^<>]{0,80}>/);h&&t.push({level:"error",code:"config.placeholder",message:`config value ${d} still contains the placeholder ${h[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(r))r.forEach((h,y)=>u(h,`${d}[${y}]`));else if(r&&typeof r=="object")for(let[h,y]of Object.entries(r))u(y,d?`${d}.${h}`:h)};if(u(n.config,""),e.fileExists&&(n.config.runtime?.mode??"pinned")==="vendored"){let r=new Set,d=!1;for(let h of n.nodes)lt.has(h.type)&&(d=!0,r.add("run-agent")),lt.has(h.type)&&h.type!=="scheduled-agent"&&r.add("agent-context"),(h.type==="producer"||h.type==="scheduled-agent")&&r.add("agent-fallback"),h.type==="merge-gate"&&r.add("merge-gate"),h.type==="pr-review"&&h.attrs.gates!==void 0&&r.add("wait-for-checks");for(let h of r)e.fileExists(`actions/${h}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${h}/ 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:r,memberIds:d}=We(n);for(let h of n.nodes)if(h.type==="parallel"&&!d.has(h.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${h.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:h.id,line:h.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),h.type==="fan_in"){let y=r.get(h.id);if(!y)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${h.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:h.id,line:h.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!h.files.role&&h.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${h.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:h.id,line:h.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let m=y.legIds.filter($=>o.get($)?.type==="pr-review");m.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${h.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:h.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(bt(n.config).mode==="github-token"){let r=n.edges.filter(d=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(d.on??"")||/^(label=|verdict=)/.test(d.when??""));r.length&&t.push({level:n.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 ${r.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!n.config.identity?.bot_login&&n.edges.some(r=>/^verdict=/.test(r.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"}),n.nodes.some(r=>r.type==="start"||r.attrs.schedule!==void 0||r.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 ys=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),Xr=new Set(["start"]);function kt(n){let e=[],t=new Set(n.nodes.map(r=>r.id)),o=new Map(n.nodes.map(r=>[r.id,r])),s=new Map;for(let r of t)s.set(r,[]);for(let r of n.edges)t.has(r.from)&&t.has(r.to)&&s.get(r.from).push(r.to);let a=n.nodes.filter(r=>Xr.has(r.type)||r.attrs.schedule!==void 0||r.type==="merge-gate"),l=new Set,u=a.map(r=>r.id);for(;u.length;){let r=u.pop();if(!l.has(r)){l.add(r);for(let d of s.get(r)??[])u.push(d)}}for(let r of n.nodes)!l.has(r.id)&&!Xr.has(r.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${r.id}' is unreachable from any entry (start/scheduled) node`,where:{node:r.id,line:r.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let r of n.nodes)(s.get(r.id)??[]).length===0&&!ys.has(r.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${r.id}' (type ${r.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:r.id,line:r.line},hint:"route it to a next node, or make it an exit"});for(let r of Es(t,s)){if(!(r.length>1||(s.get(r[0])??[]).includes(r[0])))continue;let h=new Set(r),y=[];for(let m of r)for(let $ of s.get(m)??[])h.has($)||y.push({from:m,to:$});y.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${r.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:r[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):y.some(m=>$s(_s(n,m.from,m.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${r.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:r[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let p=new Map;for(let r of n.edges){let d=`${r.on??""}|${r.when??""}`;p.has(r.from)||p.set(r.from,new Map);let h=p.get(r.from);h.has(d)||h.set(d,new Set),h.get(d).add(r.to)}for(let[r,d]of p)for(let[h,y]of d)y.size>1&&h!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${r}' has multiple edges with identical trigger/guard (${h}) to different targets: ${[...y].join(", ")}`,where:{node:r},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function _s(n,e,t){return n.edges.find(o=>o.from===e&&o.to===t)?.when}function $s(n){return n?/(>=|>|attempts|max|count|limit)/i.test(n):!1}function Es(n,e){let t=0,o=new Map,s=new Map,a=new Set,l=[],u=[],p=r=>{o.set(r,t),s.set(r,t),t++,l.push(r),a.add(r);for(let d of e.get(r)??[])o.has(d)?a.has(d)&&s.set(r,Math.min(s.get(r),o.get(d))):(p(d),s.set(r,Math.min(s.get(r),s.get(d))));if(s.get(r)===o.get(r)){let d=[],h;do h=l.pop(),a.delete(h),d.push(h);while(h!==r);u.push(d.reverse())}};for(let r of n)o.has(r)||p(r);return u}I();var As=new Set(Qe),vs=new Set(["pr-review","pr-fix"]);function ks(n,e){return e.labels?.[n]??n}function un(n){return vs.has(n.type)||n.context==="pr-diff"||n.context==="pr-review"}function ln(n,e,t){let o=(s,a)=>{n[s]??={},n[s].types??=[],n[s].types.includes(a)||n[s].types.push(a)};switch(e){case"issues.opened":return o("issues","opened");case"issues.labeled":return o("issues","labeled");case"issue_comment.created":return o("issue_comment","created");case"pull_request.opened":return o("pull_request","opened");case"pull_request.synchronize":return o("pull_request","synchronize");case"pull_request.labeled":return o("pull_request","labeled");case"pull_request.closed":return o("pull_request","closed");case"pull_request.ready_for_review":return o("pull_request","ready_for_review");case"pull_request_review.submitted":return o("pull_request_review","submitted");case"push":if(un(t))return o("pull_request","synchronize");n.push??={};return;case"workflow_dispatch":n.workflow_dispatch??={};return;default:n[e]??={}}}function St(n,e){return n==="push"&&un(e)?"pull_request.synchronize":n}function Ai(n){let[e,t]=n.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function Ss(n,e,t){if(n.on){let s=n.on.split(",").map(l=>l.trim()).filter(Boolean),a=s.map(l=>St(l,e));return{events:s,guard:n.when?cn(n.when,a,t):void 0}}if(!n.when)return;let o=n.when;if(o.startsWith("label=")){let s=[un(e)?"pull_request.labeled":"issues.labeled"];return{events:s,guard:cn(o,s,t)}}if(o.startsWith("verdict=")){let s=["pull_request_review.submitted"];return{events:s,guard:cn(o,s,t)}}}function cn(n,e,t){if(n.startsWith("label=")){let s=`github.event.label.name == '${ks(n.slice(6),t)}'`,a=Os(e);return a?`${s} && ${a}`:s}let o=n==="verdict=approve"?"APPROVE":n==="verdict=request_changes"?"REQUEST_CHANGES":void 0;if(o){let s=`contains(github.event.review.body, '**Verdict:** ${o}')`,a=Cs(t);return a?`${s} && ${a}`:s}}function Os(n){if(n.length&&n.every(e=>e.split(".")[0]==="issues"))return"github.event.issue.state == 'open'";if(n.length&&n.every(e=>e.split(".")[0]==="pull_request"))return"github.event.pull_request.state == 'open'"}function Cs(n){let e=n.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function zr(n){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(n)}function Ts(n){let e=n.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function Qr(n,e,t){return vi(n,e,Ts(t))}function Zr(n,e,t,o){return vi(n,e,t?zi(t,o):void 0)}function vi(n,e,t){let o=[...e].filter(zr);if(!t||o.length===0)return n;let s=[...e].filter(l=>!zr(l)),a=s.length?`(${s.map(Ai).join(" || ")} || ${t})`:t;return n?`(${n}) && ${a}`:a}function eo(n,e){let t=n.attrs.cancel_in_progress;return typeof t=="boolean"&&As.has(n.type)?t:e}function xs(n,e){if(n.attrs.schedule!==void 0)return{group:n.id,"cancel-in-progress":eo(n,!1)};let t=un(n)||n.type==="human-gate",o=t?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}",s=eo(n,n.type==="issue-agent");return e!==void 0&&t?{group:`\${{ github.event.action == 'labeled' && github.event.label.name != ${qe(e)} && format(${qe(`${n.id}-noop-{0}`)}, github.run_id) || format(${qe(`${n.id}-{0}`)}, github.event.pull_request.number) }}`,"cancel-in-progress":s}:{group:`${n.id}-${o}`,"cancel-in-progress":s}}function to(n){let e={},t=new Map(n.nodes.map(a=>[a.id,a])),o=new Map;for(let a of n.nodes)o.set(a.id,[]);for(let a of n.edges)o.get(a.to)?.push(a);let s=We(n);for(let a of n.nodes){if(a.type==="start"||a.type==="exit"||s.memberIds.has(a.id))continue;let l=s.byFanin.get(a.id);if(l){let b=l.entryEdge,x=t.get(l.legIds[0]),H={},M=(b.on??"").split(",").map(oe=>oe.trim()).filter(Boolean);for(let oe of M)ln(H,oe,x);let j={nodeId:a.id,triggers:H,dispatches:[]},W=new Set(M.map(oe=>St(oe,x))),B;try{B=wt(n.config)}catch{B=[jn]}let te=Zr(Qr(b.when?cn(b.when,[...W],n.config):void 0,W,n.config),W,B);te&&(j.guard=te);let ae=M.some(oe=>St(oe,x).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";j.concurrency={group:`${a.id}-${ae}`,"cancel-in-progress":!1},e[a.id]=j;continue}if(a.type==="parallel"||a.type==="fan_in")continue;let u={},p=new Set,r=new Set,d=new Set,h=[],y=Ue(a,n.config),m=!1;if(a.attrs.schedule!==void 0)u.schedule=[{cron:String(a.attrs.schedule)}],u.workflow_dispatch={};else{for(let b of o.get(a.id)??[]){let x=Ss(b,a,n.config);if(x){for(let H of x.events)ln(u,H,a);for(let H of x.events)d.add(St(H,a));if(x.guard)p.add(x.guard);else for(let H of x.events)r.add(St(H,a))}}if(u.pull_request&&Ge(a,n.config)&&Ce(a).some(b=>b.kind==="draft")&&(ln(u,"pull_request.ready_for_review",a),d.add("pull_request.ready_for_review"),r.add("pull_request.ready_for_review")),y&&u.pull_request&&Ge(a,n.config)&&(d.has("pull_request.labeled")?r.has("pull_request.labeled")||p.add(`(${Ai("pull_request.labeled")} && github.event.label.name == ${qe(y)})`):(ln(u,"pull_request.labeled",a),d.add("pull_request.labeled"),r.add("pull_request.labeled"),m=!0)),p.size&&r.size)for(let b of r)p.add(Ai(b))}for(let b of n.edges)b.from===a.id&&b.do&&h.push({toNode:b.to,when:b.when});let $=Zr(Qr(p.size?[...p].join(" || "):void 0,d,n.config),d,Te(a,n.config),y);m&&y&&($=vi($,d,`(github.event.action != 'labeled' || github.event.label.name == ${qe(y)})`));let E={nodeId:a.id,triggers:u,dispatches:h};$&&(E.guard=$),Object.keys(u).length&&(E.concurrency=xs(a,m?y:void 0)),e[a.id]=E}return{perNode:e}}I();I();var Rs="${{ github.event.pull_request.number }}",Ns=10,no=3,io=3,Is=600;function ro(n){return ye(n.node)?Ms(n):Ge(n.node,n.config)?Ds(n):null}function oo(n){return ye(n.node)?Fs(n):null}var so='(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',Hs=["[ .[] | select(.commit_id == env.SHA)",` | select(${so})`,` | select(${yt}) ] | length`],Ps=[`[ .[] | select(${so}) | ${yt} as $verdict`," | { decided: (.commit_id == env.SHA and $verdict),",' reviewed: ((.commit_id == env.SHA or ((.body // "") | test(env.ALSO_HEAD_PATTERN + env.SHA + " -->"))) and ($verdict | not)) } ]',"| [ (map(select(.decided)) | length), (map(select(.reviewed)) | length) ] | @tsv"],Ls="github-actions";function Ds(n){let e=n.node,t=Ce(e),o=Te(e,n.config),s=Ue(e,n.config),a={GH_TOKEN:"${{ github.token }}",PR:Rs,NODE:e.id,BOT_LOGIN:n.config.identity?.bot_login??""};o&&(a.AUTHORS=o.join(",")),s&&(a.OPT_IN_LABEL=s);let l=["# 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=""',"# The lane's stamp step edits only a review submitted after this moment (its own).","STARTED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)","finish() {",' { echo "run=$RUN"; echo "reason=$REASON"; echo "head_sha=$HEAD_SHA"; echo "diff_hash=$DIFF_HASH"; echo "started_at=$STARTED_AT"; } >> "$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',...o?[' 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")`];if(o){let h='((.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a))';l.push("",`# authors: only these logins' PRs (case-insensitive)${s?", or a PR carrying the opt-in label":""}.`,"# 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.",...s?[`if ! jq -e '${h} or any(.labels[]?; .name == env.OPT_IN_LABEL)' <<< "$PR_JSON" >/dev/null; then`,` skip "the author $(jq -r '.user.login // "?"' <<< "$PR_JSON") is not in the allowlist and no $OPT_IN_LABEL label"`]:[`if ! jq -e '${h}' <<< "$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 h of t)if(l.push(""),h.kind==="draft")l.push("# draft",`if [ "$(jq -r '.draft' <<< "$PR_JSON")" = "true" ]; then skip "the PR is a draft"; fi`);else if(h.kind==="bot-author")l.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(h.kind==="label"){u+=1;let y=`SKIP_LABEL_${u}`;a[y]=n.config.labels?.[h.label]??h.label,l.push(`# label:${h.label}`,`if jq -e --arg l "$${y}" 'any(.labels[]?; .name == $l)' <<< "$PR_JSON" >/dev/null; then`,` skip "the PR carries the label $${y}"`,"fi")}else a.MARKER_PREFIX=Zt(e),a.ALSO_HEAD_PREFIX=Zi(e),a.EVENT_ACTION="${{ github.event.action }}",a.STAMP_TOKEN=ne(n),l.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_REVIEW=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`,' .[] | select(.user.login == env.BOT_LOGIN) | select((.body // "") | contains(env.MARKER_PREFIX))',` | "\\(.id) \\((.body // "") | split(env.MARKER_PREFIX) | last | .[0:64])"' 2>/dev/null | tail -n 1) || LAST_REVIEW=""`," LAST_ID=${LAST_REVIEW%% *}; LAST=${LAST_REVIEW#* }",' if [ "$EVENT_ACTION" = "synchronize" ] && [ -n "$LAST" ] && [ "$LAST" = "$DIFF_HASH" ]; then'," # That review covers this head too: say so in it, so a downstream lane can",' # tell "reviewed" from the other reasons this lane skips. One marker per'," # head, appended; best-effort \u2014 the skip stands either way.",' MARK="$ALSO_HEAD_PREFIX$HEAD_SHA -->"',` if BODY=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$LAST_ID" --jq '.body // ""' 2>/dev/null); then`,' case "$BODY" in',' *"$MARK"*) ;;',' *) GH_TOKEN="$STAMP_TOKEN" gh api --method PUT "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$LAST_ID" \\',` -f body="$(printf '%s\\n%s' "$BODY" "$MARK")" >/dev/null \\`,' || echo "::warning::could not mark review $LAST_ID as covering $HEAD_SHA" ;;'," esac"," else",' echo "::warning::could not read review $LAST_ID to mark it as covering $HEAD_SHA"'," fi",' 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");l.push("","finish");let p=t.some(h=>h.kind==="unchanged-diff"),r=p?it(n,{"pull-requests":"write"}):void 0,d=p&&ne(n)==="${{ github.token }}";return{jobId:Ze(e),name:`${e.id} skip guard`,displayName:`${e.id} guard`,permissions:{contents:"read","pull-requests":d?"write":"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 }}",started_at:"${{ steps.decide.outputs.started_at }}"},steps:[...r?[r]:[],ie({id:"decide",name:"Decide whether to run",env:a,run:l.join(`
162
+ `)})]}}function Ms(n){let e=n.node,t=Te(e,n.config),o=Ue(e,n.config),s='((.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a))',a=Ce(e),l=a.some(r=>r.kind==="bot-author"),u={};for(let r of a)r.kind==="label"&&(u[`SKIP_LABEL_${Object.keys(u).length+1}`]=n.config.labels?.[r.label]??r.label);let p=["# 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${t?", by an allowlisted author":""}${o?" or labelled $OPT_IN_LABEL":""}`,...l||Object.keys(u).length?[`# not skipped ${[l?"not opened by a bot (the harness's own is exempt)":"",Object.keys(u).length?"no skip= label":""].filter(Boolean).join(", ")}`]:[],"# 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 \u2014 and at least one check-run exists, unless the PR has","# been quiet for $SETTLE_SECONDS s (a repo with no CI still gets swept)","# undecided no verdict review on this exact head yet, and no earlier","# sweep has marked it delivered (the swept check)",...Bn(e)?["# reviewed a non-verdict review by the bot covers the head (on it, or marked also-head)"]:[],"# not spent fewer than $MAX_FAILURES failed lane runs on this head, and fewer","# than $MAX_IDLE runs that succeeded without leaving a verdict",`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))",...t?[o?` | select(${s} or ((.labels // []) | any(.name == env.OPT_IN_LABEL)))`:` | select(${s})`]:[],...l?[' | select((.user.login // "") == env.BOT_LOGIN or (((.user.type // "") != "Bot") and ((.user.login // "") | endswith("[bot]") | not)))']:[],...Object.keys(u).map(r=>` | select((.labels // []) | any(.name == env.${r}) | not)`),` | "\\(.number) \\(.head.sha) \\((.requested_reviewers | length) + (.requested_teams | length)) \\(now - (.updated_at | fromdateiso8601) | floor) \\(.base.ref)"') || {`,' echo "::error::could not list open pull requests"'," exit 1","}","SELECTED='[]'","while read -r NUM SHA REQUESTED QUIET BASE; do",' [ -n "$NUM" ] || continue',' if [ "$REQUESTED" != "0" ]; then echo "#$NUM: $REQUESTED review request(s) outstanding"; continue; fi'," # One read of the head's check-runs answers four questions: how many exist,"," # how many are still running, has the lane already run here, how often has it failed."," # filter=all: the default (latest) keeps only the newest run per check name, which"," # hides all but one sweep-failed record and lets a newer skipped run of a job mask"," # an older one still in progress.",` CHECKS=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100&filter=all" --paginate --jq '`," .check_runs | [ length,",' ([.[] | select(.status != "completed")] | length),'," ([.[] | select(.name == env.SWEPT_CHECK and .app.slug == env.MARK_APP)] | length),"," ([.[] | select(.name == env.FAILED_CHECK and .app.slug == env.MARK_APP)] | length),"," ([.[] | select(.name == env.IDLE_CHECK and .app.slug == env.MARK_APP)] | length) ] | @tsv' \\",` | awk '{t+=$1; r+=$2; s+=$3; f+=$4; i+=$5} END {print t+0, r+0, s+0, f+0, i+0}') || { echo "#$NUM: could not read check-runs"; continue; }`,' read -r TOTAL RUNNING SWEPT FAILURES IDLE <<< "$CHECKS"',' if [ "$RUNNING" != "0" ]; then echo "#$NUM: $RUNNING check-run(s) still running"; continue; fi',' if [ "$TOTAL" = "0" ] && [ "$QUIET" -lt "$SETTLE_SECONDS" ]; then',' echo "#$NUM: no check-run on $SHA yet and the PR changed ${QUIET}s ago \u2014 waiting for CI to register"'," continue"," fi"," # The lane's own record that it ran here and delivered a verdict (the mark"," # job publishes it only then). Normally redundant with the verdict test below;"," # it still holds if the verdict review's body is later edited.",' if [ "$SWEPT" != "0" ]; then echo "#$NUM: already swept at $SHA"; continue; fi'," # \u2026and a lane that keeps FAILING on a head is not retried forever either.",' if [ "$FAILURES" -ge "$MAX_FAILURES" ]; then echo "#$NUM: gave up on $SHA after $FAILURES failed runs"; continue; fi'," # \u2026nor is one that keeps succeeding without ever leaving a verdict.",' if [ "$IDLE" -ge "$MAX_IDLE" ]; then echo "#$NUM: gave up on $SHA after $IDLE runs that posted no verdict"; 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',` REVIEWS=$(SHA="$SHA" gh api "repos/$GITHUB_REPOSITORY/pulls/$NUM/reviews?per_page=100" --paginate --jq '`,...Ps.map(r=>` ${r}`),` ' | awk '{d+=$1; r+=$2} END {print d+0, r+0}') || { echo "#$NUM: could not read reviews"; continue; }`,' read -r DECIDED REVIEWED <<< "$REVIEWS"',' if [ "$DECIDED" != "0" ]; then echo "#$NUM: already decided at $SHA"; continue; fi'," # requires_review: the lane acts on an upstream review, so a head no review covers is still waiting.",' if [ "$REQUIRES_REVIEW" = "true" ] && [ "$REVIEWED" = "0" ]; then echo "#$NUM: no review by $BOT_LOGIN covers $SHA yet"; continue; fi',' echo "#$NUM: selected at $SHA"',` SELECTED=$(jq -c --argjson n "$NUM" --arg s "$SHA" --arg b "$BASE" '. + [{number: $n, sha: $s, base: $b}]' <<< "$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(`
163
+ `);return{jobId:Ze(e),name:`${e.id} sweep select`,displayName:`${e.id} 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:[ie({id:"select",name:"Select pull requests ready for a decision",env:{GH_TOKEN:"${{ github.token }}",PREFIX:n.config.repo.branch_prefix,BOT_LOGIN:n.config.identity?.bot_login??"",VERDICT_LINES:et(n.config),REQUIRES_REVIEW:String(Bn(e)),ALSO_HEAD_PATTERN:Qi,SWEPT_CHECK:Yn(e),FAILED_CHECK:Vn(e),IDLE_CHECK:Wn(e),MAX_IDLE:String(io),MARK_APP:Ls,LIMIT:String(Ns),MAX_FAILURES:String(no),SETTLE_SECONDS:String(Is),...t?{AUTHORS:t.join(",")}:{},...o?{OPT_IN_LABEL:o}:{},...u},run:p})]}}function Fs(n){let e=n.node,t=Ze(e);return{jobId:`${e.id}_mark`,name:`${e.id} sweep mark`,displayName:`${e.id} mark`,needs:[t,e.id],if:`\${{ always() && needs.${t}.result == 'success' && needs.${t}.outputs.count != '0' }}`,permissions:{checks:"write",actions:"read","pull-requests":"read"},timeoutMinutes:5,steps:[ie({name:"Mark the heads this sweep covered",env:{GH_TOKEN:"${{ github.token }}",PRS:`\${{ needs.${t}.outputs.prs }}`,NODE:e.id,BOT_LOGIN:n.config.identity?.bot_login??"",VERDICT_LINES:et(n.config),JOB_PREFIX:Qt(e),SWEPT_CHECK:Yn(e),FAILED_CHECK:Vn(e),IDLE_CHECK:Wn(e),MAX_IDLE:String(io),MAX_FAILURES:String(no),RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:[`JOBS=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/attempts/$RUN_ATTEMPT/jobs?per_page=100" --paginate --jq '`,` .jobs[] | [(.conclusion // "none"), .name] | @tsv') || {`,` echo "::error::could not read this run's jobs \u2014 no head marked, so the next sweep will repeat them"`," exit 1","}","publish() { # <check name> <sha> <title> <summary>",' gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$1" -f head_sha="$2" -f status=completed -f conclusion=neutral \\',' -f "output[title]=$3" -f "output[summary]=$4" >/dev/null',"}","FAILED=0","while read -r NUM SHA; do",' [ -n "$NUM" ] || continue',` RESULT=$(awk -F'\\t' -v n="$JOB_PREFIX$NUM" '$2 == n {print $1}' <<< "$JOBS" | tail -n 1)`,' case "$RESULT" in'," success)"," # The lane's post-condition: the bot's verdict on this head. A run that"," # posted none had nothing to decide yet \u2014 leave it for the next sweep,"," # not as a failure, but recorded: $MAX_FAILURES such runs on one head and"," # the sweep stops (a role that always abstains would otherwise run every tick).",` VERDICTS=$(SHA="$SHA" gh api "repos/$GITHUB_REPOSITORY/pulls/$NUM/reviews?per_page=100" --paginate --jq '`,...Hs.map(o=>` ${o}`),` ' | awk '{s+=$1} END {print s+0}') || VERDICTS=""`,' if [ -z "$VERDICTS" ]; then',' echo "::warning::#$NUM: could not read reviews on $SHA \u2014 left for the next sweep"',' elif [ "$VERDICTS" = "0" ]; then'," # Retried \u2014 but counted, so a role that never posts a verdict is not"," # run on every tick forever. One check-run per such run; the selector"," # stops at $MAX_IDLE.",` PRIOR=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100&filter=all" --paginate --jq '`," [.check_runs[] | select(.name == env.IDLE_CHECK)] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}') || PRIOR=0"," N=$((PRIOR + 1))",' if [ "$N" -ge "$MAX_IDLE" ]; then',' TITLE="$NODE stopped after $N runs without a verdict"',' SUMMARY="The $NODE lane ran $N times on $SHA and never posted a verdict there. It will not be run on this head again; push a new commit, or re-run the lane by hand, to try again."'," else",' TITLE="$NODE run $N of $MAX_IDLE posted no verdict"',' SUMMARY="The $NODE lane ran on $SHA and posted no verdict. The next sweep retries it; after $MAX_IDLE such runs it stops."'," fi",' if publish "$IDLE_CHECK" "$SHA" "$TITLE" "$SUMMARY"; then',' echo "::notice::#$NUM: no verdict posted on $SHA \u2014 recorded run $N of $MAX_IDLE without one"'," else",' echo "::error::#$NUM: could not record the verdict-less run on $SHA \u2014 its retries are not being counted"'," FAILED=1"," fi",' if [ "$N" -ge "$MAX_IDLE" ]; then'," # Visible where a failed head shows: the same sweep-failed record as a failed run.",' publish "$FAILED_CHECK" "$SHA" "$NODE gave up after $N runs without a verdict" "$SUMMARY" \\',' || { echo "::error::#$NUM: could not record giving up on $SHA"; FAILED=1; }',' echo "#$NUM: gave up on $SHA after $N runs without a verdict"'," fi",' elif publish "$SWEPT_CHECK" "$SHA" "Swept by $NODE" "The $NODE lane ran on $SHA and posted its verdict."; 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 ;;"," failure|timed_out)"," # One check-run per failed attempt; the selector counts them and stops at $MAX_FAILURES."," # filter=all, or GitHub returns only the newest one and the count never passes 1.",` PRIOR=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100&filter=all" --paginate --jq '`," [.check_runs[] | select(.name == env.FAILED_CHECK)] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}') || PRIOR=0"," N=$((PRIOR + 1))",' if [ "$N" -ge "$MAX_FAILURES" ]; then',' TITLE="$NODE gave up after $N failed runs"',' SUMMARY="The $NODE lane failed $N times on $SHA and will not be run on this head again. Push a new commit, or re-run the lane by hand, to try again."'," else",' TITLE="$NODE run $N of $MAX_FAILURES failed"',' SUMMARY="The $NODE lane failed on $SHA. The next sweep retries it; after $MAX_FAILURES failures it stops."'," fi",' if publish "$FAILED_CHECK" "$SHA" "$TITLE" "$SUMMARY"; then',' echo "#$NUM: lane $RESULT \u2014 recorded failed run $N of $MAX_FAILURES on $SHA"'," else",' echo "::error::#$NUM: could not record the failed run on $SHA \u2014 its retries are not being counted"'," FAILED=1"," fi ;;"," *)",' echo "#$NUM: lane did not finish (${RESULT:-no job}) \u2014 left for the next sweep, not counted as a failure" ;;'," esac",`done < <(jq -r '.[] | "\\(.number) \\(.sha)"' <<< "$PRS")`,'exit "$FAILED"'].join(`
164
+ `)})]}}I();var ao=[" /^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 ki="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.",js=`${ki}
74
165
  # Edit harness.dot / roles / foundry.config.yaml and run \`gp-foundry build\`.
75
- `;function hs(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 ms(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),Ii(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 Br(i){return String(i.attrs.title??i.attrs.name??i.id)}function gs(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 '",...Ur,` ' "$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(`
76
- `)}]}}}}function bs(i){return i.nodes.some(e=>e.type==="producer"||e.type==="pr-fix"||e.type==="scheduled-agent"&&e.attrs.commit!=="none")}function Gr(i,e,t="",r={}){let o=[],a=hs(i.config),c=new Map(i.nodes.map(m=>[m.id,m])),p=new Map,s=new Map;for(let m of i.nodes)p.set(m.id,[]),s.set(m.id,[]);for(let m of i.edges)p.get(m.from)?.push(m),s.get(m.to)?.push(m);let l=m=>({config:i.config,node:m,outEdges:p.get(m.id)??[],inEdges:s.get(m.id)??[],actionRef:a,nodeById:O=>c.get(O),specDir:t,roleTools:r.roleTools}),d=(m,O)=>{let y={};m.displayName&&(y.name=m.displayName),y["runs-on"]="ubuntu-latest";let _=m.if??O;return _&&(y.if=_),m.environment&&(y.environment=m.environment),m.permissions&&Object.keys(m.permissions).length&&(y.permissions=m.permissions),m.timeoutMinutes&&(y["timeout-minutes"]=m.timeoutMinutes),m.needs?.length&&(y.needs=m.needs),m.outputs&&Object.keys(m.outputs).length&&(y.outputs=m.outputs),m.strategy&&(y.strategy=m.strategy),y.steps=m.steps.map(ms),y},f=(m,O)=>{let y=ve.dump(O,{lineWidth:-1,noRefs:!0,quotingType:'"'});o.push({path:`.github/workflows/${m}.yml`,contents:fs+y,generated:!0})},w=je(i);bs(i)&&f("immutable-guard",gs(i.config,t));for(let m of i.nodes){if(w.memberIds.has(m.id))continue;let O=e.perNode[m.id];if(!O||Object.keys(O.triggers).length===0)continue;let y=w.byFanin.get(m.id);if(y){let D={};for(let ie of y.legIds){let{skip:me,select:se,...ne}=c.get(ie).attrs,ge={...c.get(ie),attrs:ne},j=Dn(ge,i,l(ge));j&&(D[j.jobId]=d(j,O.guard))}let q=JSON.stringify(O.triggers).includes('"pull_request"'),Z=Gi(l(m),y.legIds,q);D[Z.jobId]=d(Z),f(m.id,{name:Br(m),on:O.triggers,...O.concurrency?{concurrency:O.concurrency}:{},permissions:{contents:"read"},jobs:D});continue}let _=Dn(m,i,l(m));if(!_)continue;let R=jr(l(m)),I=R?{[R.jobId]:d(R,O.guard),[_.jobId]:d(_)}:{[_.jobId]:d(_,O.guard)},M=qr(l(m));M&&(I[M.jobId]=d(M)),f(m.id,{name:Br(m),on:O.triggers,...O.concurrency?{concurrency:O.concurrency}:{},permissions:{contents:"read"},jobs:I})}return o}P();function ys(i){return Object.entries(i).map(([e,t])=>{if(e==="schedule"&&Array.isArray(t))return`schedule: ${t.map(o=>`\`${o.cron??"?"}\``).join(", ")}`;let r=t?.types;return r?.length?`${e}: ${r.join(", ")}`:e}).join(" \xB7 ")}function ws(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 _s(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 tn(i,e){let t=["```mermaid","flowchart TD"];for(let o of i.nodes){let[a,c]=ws(o);t.push(` ${o.id}${a}"${_s(o)}"${c}`)}for(let o of i.edges){let a=[o.on,o.when].filter(Boolean).join(" \xB7 ");t.push(a?` ${o.from} -->|"${a}"| ${o.to}`:` ${o.from} --> ${o.to}`)}t.push("```","");let r=Object.values(e?.perNode??{}).filter(o=>Object.keys(o.triggers).length);if(r.length){t.push("## Triggers","","| Workflow | Runs on |","|----------|---------|");for(let o of r)t.push(`| \`${o.nodeId}\` | ${ys(o.triggers)} |`);t.push("")}return`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
166
+ `;function qs(n){let e=n.runtime??{};if(e.mode==="vendored")return s=>`./.github/actions/${s}`;let t=e.owner_repo??"thegpvc/gp-foundry",o=e.ref??"v1";return s=>`${t}/actions/${s}@${o}`}function Us(n){let e={};return n.name&&(e.name=n.name),n.id&&(e.id=n.id),n.if&&(e.if=n.if),n.timeoutMinutes&&(e["timeout-minutes"]=n.timeoutMinutes),Yi(n)?(e.uses=n.uses,n.with&&Object.keys(n.with).length&&(e.with=n.with)):(n.shell&&(e.shell=n.shell),n.env&&Object.keys(n.env).length&&(e.env=n.env),e.run=n.run),e}function lo(n){return String(n.attrs.title??n.attrs.name??n.id)}function Bs(n,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, '${n.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 '",...ao,` ' "$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(`
167
+ `)}]}}}}function Gs(n){return n.nodes.some(e=>e.type==="producer"||e.type==="pr-fix"||e.type==="scheduled-agent"&&e.attrs.commit!=="none")}function co(n,e,t="",o={}){let s=[],a=qs(n.config),l=new Map(n.nodes.map(m=>[m.id,m])),u=new Map,p=new Map;for(let m of n.nodes)u.set(m.id,[]),p.set(m.id,[]);for(let m of n.edges)u.get(m.from)?.push(m),p.get(m.to)?.push(m);let r=m=>({config:n.config,node:m,outEdges:u.get(m.id)??[],inEdges:p.get(m.id)??[],actionRef:a,nodeById:$=>l.get($),specDir:t,roleTools:o.roleTools}),d=(m,$)=>{let E={};m.displayName&&(E.name=m.displayName),E["runs-on"]="ubuntu-latest";let b=m.if??$;return b&&(E.if=b),m.environment&&(E.environment=m.environment),m.permissions&&Object.keys(m.permissions).length&&(E.permissions=m.permissions),m.timeoutMinutes&&(E["timeout-minutes"]=m.timeoutMinutes),m.needs?.length&&(E.needs=m.needs),m.outputs&&Object.keys(m.outputs).length&&(E.outputs=m.outputs),m.strategy&&(E.strategy=m.strategy),E.steps=m.steps.map(Us),E},h=(m,$)=>{let E=Re.dump($,{lineWidth:-1,noRefs:!0,quotingType:'"'});s.push({path:`.github/workflows/${m}.yml`,contents:js+E,generated:!0})},y=We(n);Gs(n)&&h("immutable-guard",Bs(n.config,t));for(let m of n.nodes){if(y.memberIds.has(m.id))continue;let $=e.perNode[m.id];if(!$||Object.keys($.triggers).length===0)continue;let E=y.byFanin.get(m.id);if(E){let j={};for(let te of E.legIds){let{skip:me,select:ae,...oe}=l.get(te).attrs,be={...l.get(te),attrs:oe},F=Zn(be,n,r(be));F&&(j[F.jobId]=d(F,$.guard))}let W=JSON.stringify($.triggers).includes('"pull_request"'),B=ar(r(m),E.legIds,W);j[B.jobId]=d(B),h(m.id,{name:lo(m),on:$.triggers,...$.concurrency?{concurrency:$.concurrency}:{},permissions:{contents:"read"},jobs:j});continue}let b=Zn(m,n,r(m));if(!b)continue;let x=ro(r(m)),H=x?{[x.jobId]:d(x,$.guard),[b.jobId]:d(b)}:{[b.jobId]:d(b,$.guard)},M=oo(r(m));M&&(H[M.jobId]=d(M)),h(m.id,{name:lo(m),on:$.triggers,...$.concurrency?{concurrency:$.concurrency}:{},permissions:{contents:"read"},jobs:H})}return s}I();function Vs(n){return Object.entries(n).map(([e,t])=>{if(e==="schedule"&&Array.isArray(t))return`schedule: ${t.map(s=>`\`${s.cron??"?"}\``).join(", ")}`;let o=t?.types;return o?.length?`${e}: ${o.join(", ")}`:e}).join(" \xB7 ")}function Ws(n){switch(n.type){case"start":case"exit":return["([","])"];case"human-gate":return["{{","}}"];case"merge-gate":return["[/","/]"];case"parallel":case"fan_in":return["[[","]]"];default:return["[","]"]}}function Ys(n){let e=n.files.role?.replace(/^.*\//,"").replace(/\.md$/,""),t=e&&e!==n.id?`${e} \xB7 ${n.type}`:n.type;return`${n.id}<br/><small>${t}${Ks(n)}</small>`}function Ks(n){if(!he(n))return"";let e;try{e=Be(n)}catch{return" \xB7 evaluate"}return` \xB7 evaluate \u2192 check ${e.replace(/"/g,"'")}`}function dn(n,e){let t=["```mermaid","flowchart TD"];for(let s of n.nodes){let[a,l]=Ws(s);t.push(` ${s.id}${a}"${Ys(s)}"${l}`)}for(let s of n.edges){let a=[s.on,s.when].filter(Boolean).join(" \xB7 ");t.push(a?` ${s.from} -->|"${a}"| ${s.to}`:` ${s.from} --> ${s.to}`)}t.push("```","");let o=Object.values(e?.perNode??{}).filter(s=>Object.keys(s.triggers).length);if(o.length){t.push("## Triggers","","| Workflow | Runs on |","|----------|---------|");for(let s of o)t.push(`| \`${s.nodeId}\` | ${Vs(s.triggers)} |`);t.push("")}return`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
77
168
 
78
- # ${i.config?.name&&i.config.name!=="harness"?i.config.name:i.name} \u2014 agent harness
169
+ # ${n.config?.name&&n.config.name!=="harness"?n.config.name:n.name} \u2014 agent harness
79
170
 
80
171
  ${t.join(`
81
- `)}`}P();var $s=/^---\r?\n([\s\S]*?)\r?\n---/;function nn(i){let e=$s.exec(i);if(e)try{let t=ve.load(e[1]);if(t&&typeof t=="object")return t}catch{return}}P();var As=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),ks=new Set(["role","prompt","policy","tools"]);function Es(i){let e=[],t=[],r=1,o=0,a=i;for(;o<a.length;){let c=a[o];if(c===`
82
- `){r++,o++;continue}if(c===" "||c===" "||c==="\r"){o++;continue}if(c==="/"&&a[o+1]==="/"){for(;o<a.length&&a[o]!==`
83
- `;)o++;continue}if(c==="/"&&a[o+1]==="*"){for(o+=2;o<a.length&&!(a[o]==="*"&&a[o+1]==="/");)a[o]===`
84
- `&&r++,o++;o+=2;continue}if(c==="-"&&a[o+1]===">"){e.push({kind:"arrow",value:"->",line:r}),o+=2;continue}if(c==="{"){e.push({kind:"lbrace",value:c,line:r}),o++;continue}if(c==="}"){e.push({kind:"rbrace",value:c,line:r}),o++;continue}if(c==="["){e.push({kind:"lbrack",value:c,line:r}),o++;continue}if(c==="]"){e.push({kind:"rbrack",value:c,line:r}),o++;continue}if(c==="="){e.push({kind:"eq",value:c,line:r}),o++;continue}if(c===","){e.push({kind:"comma",value:c,line:r}),o++;continue}if(c===";"){e.push({kind:"semi",value:c,line:r}),o++;continue}if(c==='"'){let p=o+1,s="";for(;p<a.length&&a[p]!=='"';){if(a[p]==="\\"&&p+1<a.length){s+=a[p+1],p+=2;continue}a[p]===`
85
- `&&r++,s+=a[p],p++}p>=a.length&&t.push({message:"unterminated string",line:r}),e.push({kind:"id",value:s,line:r}),o=p+1;continue}if(/[A-Za-z0-9_]/.test(c)){let p=o,s="";for(;p<a.length&&/[A-Za-z0-9_.\-]/.test(a[p]);)s+=a[p],p++;e.push({kind:"id",value:s,line:r}),o=p;continue}t.push({message:`unexpected character '${c}'`,line:r}),o++}return{toks:e,errors:t}}function Ss(i){return i==="true"?!0:i==="false"?!1:/^-?\d+$/.test(i)?Number(i):i}function yt(i){let{toks:e,errors:t}=Es(i),r=[],o=[],a=new Map,c="harness",p=0,s=()=>e[p],l=()=>e[p++],d=(y,_)=>t.push({message:y,line:_});s()?.kind==="id"&&s()?.value==="digraph"?(l(),s()?.kind==="id"&&s()?.value!==void 0&&(c=l().value),s()?.kind==="lbrace"?l():d("expected '{' after digraph header",s()?.line)):d("expected 'digraph' keyword",s()?.line);function f(){let y={};if(s()?.kind!=="lbrack")return{attrs:y};let _=l().line;for(;s()&&s().kind!=="rbrack";){let R=l();if(!R||R.kind!=="id"){d("expected attribute name",R?.line);break}if(s()?.kind!=="eq"){d(`expected '=' after attribute '${R.value}'`,R.line);break}l();let I=l();if(!I||I.kind!=="id"){d(`expected value for attribute '${R.value}'`,I?.line);break}y[R.value]=I.value,s()?.kind==="comma"&&l()}return s()?.kind==="rbrack"?l():d("unterminated attribute list '['",_),{attrs:y,line:_}}function w(y,_){let R=a.get(y);return R||(R={id:y,type:"analyst",attrs:{},files:{},raw:{},line:_},a.set(y,R),r.push(R)),R}function m(y,_,R){y.declared=!0,y.raw={...y.raw,..._},R!==void 0&&(y.line=y.line??R);for(let[I,M]of Object.entries(_))I==="type"?(As.has(M)||d(`unknown node type '${M}' on node '${y.id}'`,R),y.type=M):I==="context"?y.context=M:ks.has(I)?y.files[I]=M:y.attrs[I]=Ss(M)}let O=0;for(;s()&&s().kind!=="rbrace"&&!(O++>1e5);){let y=s();if(y.kind==="semi"){l();continue}if(y.kind!=="id"){d(`unexpected token '${y.value}'`,y.line),l();continue}let _=l();if(s()?.kind==="arrow"){let R=[{id:_.value,line:_.line}];for(;s()?.kind==="arrow";){l();let D=l();if(!D||D.kind!=="id"){d("expected node id after '->'",D?.line);break}R.push({id:D.value,line:D.line})}let{attrs:I,line:M}=f();for(let D=0;D+1<R.length;D++){let q=R[D],Z=R[D+1];w(q.id,q.line),w(Z.id,Z.line);let ie={from:q.id,to:Z.id,raw:{...I},line:M??q.line};I.on!==void 0&&(ie.on=I.on),I.when!==void 0&&(ie.when=I.when),I.do!==void 0&&(ie.do=I.do),o.push(ie)}}else{let{attrs:R,line:I}=f(),M=w(_.value,_.line);m(M,R,I??_.line)}s()?.kind==="semi"&&l()}return s()?.kind==="rbrace"&&l(),{name:c,nodes:r,edges:o,errors:t}}P();var wt=require("fs");var tt={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 rn(i){if(!i||!(0,wt.existsSync)(i))return structuredClone(tt);let e=ve.load((0,wt.readFileSync)(i,"utf8"))??{};return{...tt,...e,identity:{...tt.identity,...e.identity??{}},agent:{...tt.agent,...e.agent??{}},repo:{...tt.repo,...e.repo??{}},labels:{...tt.labels,...e.labels??{}}}}function be(i,e){let t=yt((0,wt.readFileSync)(i,"utf8")),r=rn(e);return{harness:{name:t.name,nodes:t.nodes,edges:t.edges,config:r,sourcePath:i},parseErrors:t.errors}}function nt(i,e={},t={}){let r=[...ft(i,e),...ht(i)],o=p=>{let s=i.nodes.find(f=>f.id===p)?.files.role,l=s&&e.readFile?e.readFile(s):void 0;if(l===void 0)return;let d=nn(l)?.tools;return typeof d=="string"?d:void 0},a=Xi(i),c=Gr(i,a,t.specDir??"",{roleTools:o});return c.push({path:".github/HARNESS.md",contents:tn(i,a),generated:!0}),{files:c,diagnostics:r}}function _t(i){return i.some(e=>e.level==="error")}P();var xe=require("fs"),fe=require("path"),Wr=require("url"),qe=It(Mt(),1);function $t(i,e){let t=(0,fe.join)(i,".github","workflows");if(!(0,xe.existsSync)(t))return[];let r=new Set(e.map(o=>o.path));return(0,xe.readdirSync)(t).filter(o=>/\.ya?ml$/.test(o)).map(o=>`.github/workflows/${o}`).filter(o=>!r.has(o)).filter(o=>(0,xe.readFileSync)((0,fe.join)(i,o),"utf8").startsWith(di)).sort()}function he(i){return(0,Wr.fileURLToPath)(new URL(`../../${i}`,W))}function X(i){process.stdout.write(JSON.stringify(i,null,2)+`
86
- `)}function pi(i){for(let e of i){let t=e.level==="error"?qe.default.red("error"):e.level==="warning"?qe.default.yellow("warn"):qe.default.blue("info"),r=e.where?.node?qe.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${t} ${qe.default.dim(e.code)}${r} ${e.message}
87
- `),e.hint&&process.stderr.write(` ${qe.default.dim("hint: "+e.hint)}
88
- `)}}function Ce(i){let e=(0,fe.resolve)(i.dot??".github/harness.dot"),t=(0,fe.dirname)(e),r=i.config?(0,fe.resolve)(i.config):void 0;if(!r){for(let a of[(0,fe.join)(t,"foundry.config.yaml"),(0,fe.join)(t,"agents/foundry.config.yaml")])if((0,xe.existsSync)(a)){r=a;break}}let o=t.endsWith(".github")?(0,fe.dirname)(t):t;return{dot:e,config:r,base:t,root:o}}function At(i){return e=>{let t=(0,fe.join)(i,e);try{return(0,xe.existsSync)(t)?(0,xe.readFileSync)(t,"utf8"):void 0}catch{return}}}P();var fi=require("child_process"),B=require("fs"),V=require("path");var G=It(Mt(),1);var hi=require("path");function it(i,e={}){try{return{ok:!0,out:(0,fi.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 Ie(i,e){let t=it(i,{cwd:e});if(!t.ok)return null;try{return JSON.parse(t.out)}catch{return null}}function Jr(){let i=he("actions");return(0,B.readdirSync)(i,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(0,B.existsSync)((0,V.join)(i,e.name,"action.yml"))).map(e=>e.name)}function Xr(i){let e=rn(i),t=new Map([["build","ready to implement"],["plan","needs design first"]]),r=[];for(let[o,a]of t)r.push({name:e.labels?.[o]??o,description:a,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 Vr(i){let e={ok:G.default.green("\u2713"),warn:G.default.yellow("!"),fail:G.default.red("\u2717"),skip:G.default.dim("-")};for(let t of i)process.stdout.write(`${e[t.status]} ${t.name.padEnd(28)} ${t.detail}
89
- `),t.hint&&t.status!=="ok"&&process.stdout.write(` ${G.default.dim("hint: "+t.hint)}
90
- `)}function vs(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,V.dirname)(i.sourcePath??""),a=(0,V.join)(e,o,r.files.policy);if(!(0,B.existsSync)(a))return!0;try{let c=ve.load((0,B.readFileSync)(a,"utf8"));return(c?.require_ci??c?.requireCi)!==!1}catch{return!0}})}function Yr(i){let e=[];for(let r of Jr()){let o=he(`actions/${r}`),a=(0,V.join)(i,".github/actions",r);(0,B.mkdirSync)(a,{recursive:!0}),(0,B.cpSync)((0,V.join)(o,"action.yml"),(0,V.join)(a,"action.yml")),(0,B.existsSync)((0,V.join)(o,"dist"))&&(0,B.cpSync)((0,V.join)(o,"dist"),(0,V.join)(a,"dist"),{recursive:!0}),e.push(`.github/actions/${r}/`)}let t=(0,V.join)(i,".github/agent-setup/action.yml");return(0,B.existsSync)(t)||((0,B.mkdirSync)((0,V.dirname)(t),{recursive:!0}),(0,B.writeFileSync)(t,(0,B.readFileSync)(he("skill/templates/agent-setup.yml"),"utf8")),e.push(".github/agent-setup/action.yml")),e}function xs(i){(0,B.mkdirSync)(i,{recursive:!0}),(0,B.cpSync)(he("skill/SKILL.md"),(0,V.join)(i,"SKILL.md")),(0,B.cpSync)(he("skill/reference"),(0,V.join)(i,"reference"),{recursive:!0}),(0,B.cpSync)(he("skill/templates"),(0,V.join)(i,"templates"),{recursive:!0})}function Kr(i){let e=[],{dot:t,config:r,base:o,root:a}=Ce(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:c,parseErrors:p}=be(t,r),s=j=>(0,B.existsSync)((0,V.join)(o,j)),l=(0,hi.relative)(a,o).replace(/\\/g,"/"),{files:d,diagnostics:f}=nt(c,{fileExists:s,readFile:At(o)},{specDir:l}),w=f.filter(j=>j.level==="error").length+p.length,m=f.filter(j=>j.level==="warning");e.push(w?{name:"validate",status:"fail",detail:`${w} error(s)`,hint:"run `gp-foundry validate` for details"}:{name:"validate",status:m.length?"warn":"ok",detail:m.length?`${m.length} warning(s): ${m.map(j=>j.code).join(", ")}`:"no diagnostics"});let O=d.filter(j=>{let ue=(0,V.join)(a,j.path);return((0,B.existsSync)(ue)?(0,B.readFileSync)(ue,"utf8"):null)!==j.contents}),y=$t(a,d),_=[...O.map(j=>j.path),...y.map(j=>`${j} (stale)`)];if(e.push(_.length?{name:"workflows in sync",status:"fail",detail:`${_.length} file(s) out of sync: ${_.slice(0,3).join(", ")}${_.length>3?", \u2026":""}`,hint:"run `gp-foundry build`"}:{name:"workflows in sync",status:"ok",detail:`${d.length} generated files match`}),(c.config.runtime?.mode??"pinned")==="vendored"){let j=Jr().filter(ue=>!(0,B.existsSync)((0,V.join)(a,".github/actions",ue,"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,V.join)(a,".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`)"}),!it(["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 I=Ie(["repo","view","--json","nameWithOwner,defaultBranchRef"],a);if(!I)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:I.nameWithOwner});let M=I.defaultBranchRef?.name;M&&e.push(M===c.config.repo.base_branch?{name:"base branch",status:"ok",detail:M}:{name:"base branch",status:"fail",detail:`config says '${c.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 D=new Set((Ie(["label","list","--json","name","--limit","1000"],a)??[]).map(j=>j.name)),q=Xr(r).map(j=>j.name),Z=q.filter(j=>!D.has(j));e.push(Z.length?{name:"labels",status:"fail",detail:`missing: ${Z.join(", ")}`,hint:"run `gp-foundry up` to create them"}:{name:"labels",status:"ok",detail:q.join(", ")});let ie=new Set((Ie(["secret","list","--json","name"],a)??[]).map(j=>j.name)),me=[c.config.agent.api_key_secret||(c.config.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")],se=c.config.auth;se?.mode==="pat"&&se.token_secret&&me.push(se.token_secret),se?.mode==="app"&&me.push(se.app_id_secret??"APP_ID",se.app_key_secret??"APP_PRIVATE_KEY");let ne=me.filter(j=>!ie.has(j));if(e.push(ne.length?{name:"secrets",status:"fail",detail:`missing: ${ne.join(", ")}`,hint:`gh secret set ${ne[0]}`}:{name:"secrets",status:"ok",detail:me.join(", ")}),vs(c,a)){let ue=d.filter(ae=>/\/workflows\/.*\.yml$/.test(ae.path)&&ae.contents.includes("actions/merge-gate")).map(ae=>(0,V.join)(a,ae.path)).filter(ae=>(0,B.existsSync)(ae)).map(ae=>(0,B.readFileSync)(ae,"utf8")),ee=ue.filter(ae=>!ae.includes("checks-token"));ue.length&&ee.length&&e.push({name:"merge gate ci read",status:"fail",detail:`${ee.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 ge=it(["--version"]);try{let j=(0,fi.execFileSync)("git",["status","--porcelain",".github"],{cwd:a,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 Cs(i){let{dot:e,config:t,root:r}=Ce(i);if(!it(["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=Ie(["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:a}=be(e,t),c=a.config.repo.branch_prefix,p=Date.now(),s=_=>Math.round((p-Date.parse(_))/36e5),l={};for(let _ of["plan","build","needs-human"]){let R=_==="needs-human"?"needs-human":a.config.labels?.[_]??_,I=Ie(["issue","list","--label",R,"--state","open","--json","number,title,createdAt","--limit","50"],r)??[];l[R]=I.map(M=>({number:M.number,title:M.title,ageHours:s(M.createdAt)}))}let f=(Ie(["pr","list","--state","open","--json","number,title,labels,mergeable,headRefName,body,updatedAt","--limit","50"],r)??[]).filter(_=>_.headRefName.startsWith(c)),w=[],m=new Set;for(let _ of f)for(let R of _.body?.matchAll(/[Cc]loses #(\d+)/g)??[])m.add(Number(R[1]));let O=a.config.labels?.build??"build";for(let _ of l[O]??[])!m.has(_.number)&&_.ageHours>=2&&w.push({kind:"issue-no-pr",number:_.number,title:_.title,detail:`labeled ${O} ${_.ageHours}h ago, no open PR closes it`});for(let _ of f)_.updatedAt&&s(_.updatedAt)>=4&&w.push({kind:"pr-idle",number:_.number,title:_.title,detail:`no activity for ${s(_.updatedAt)}h`});let y=(Ie(["run","list","--status","failure","--limit","15","--json","name,url,createdAt,conclusion"],r)??[]).filter(_=>s(_.createdAt)<=24).map(_=>({workflow:_.name,url:_.url,ageHours:s(_.createdAt)}));return{repo:o.nameWithOwner,lanes:l,prs:f.map(_=>({number:_.number,title:_.title,labels:_.labels.map(R=>R.name),mergeable:_.mergeable,headRefName:_.headRefName})),stalled:w,recentFailures:y}}function zr(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=Yr(e.dir);if(e.json)return X({written:t});for(let r of t)process.stdout.write(G.default.green(`vendored ${r}
91
- `));process.stdout.write(G.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
92
- `))}),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,V.join)(t,".claude/skills/gp-foundry"):(0,V.join)(e.dir,".claude/skills/gp-foundry");if(xs(r),e.json)return X({installed:r});process.stdout.write(G.default.green(`installed skill \u2192 ${r}
93
- `)),process.stdout.write(G.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
172
+ `)}`}I();var Js=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),Xs=new Set(["role","prompt","policy","tools"]);function zs(n){let e=[],t=[],o=1,s=0,a=n;for(;s<a.length;){let l=a[s];if(l===`
173
+ `){o++,s++;continue}if(l===" "||l===" "||l==="\r"){s++;continue}if(l==="/"&&a[s+1]==="/"){for(;s<a.length&&a[s]!==`
174
+ `;)s++;continue}if(l==="/"&&a[s+1]==="*"){for(s+=2;s<a.length&&!(a[s]==="*"&&a[s+1]==="/");)a[s]===`
175
+ `&&o++,s++;s+=2;continue}if(l==="-"&&a[s+1]===">"){e.push({kind:"arrow",value:"->",line:o}),s+=2;continue}if(l==="{"){e.push({kind:"lbrace",value:l,line:o}),s++;continue}if(l==="}"){e.push({kind:"rbrace",value:l,line:o}),s++;continue}if(l==="["){e.push({kind:"lbrack",value:l,line:o}),s++;continue}if(l==="]"){e.push({kind:"rbrack",value:l,line:o}),s++;continue}if(l==="="){e.push({kind:"eq",value:l,line:o}),s++;continue}if(l===","){e.push({kind:"comma",value:l,line:o}),s++;continue}if(l===";"){e.push({kind:"semi",value:l,line:o}),s++;continue}if(l==='"'){let u=s+1,p="";for(;u<a.length&&a[u]!=='"';){if(a[u]==="\\"&&u+1<a.length){p+=a[u+1],u+=2;continue}a[u]===`
176
+ `&&o++,p+=a[u],u++}u>=a.length&&t.push({message:"unterminated string",line:o}),e.push({kind:"id",value:p,line:o}),s=u+1;continue}if(/[A-Za-z0-9_]/.test(l)){let u=s,p="";for(;u<a.length&&/[A-Za-z0-9_.\-]/.test(a[u]);)p+=a[u],u++;e.push({kind:"id",value:p,line:o}),s=u;continue}t.push({message:`unexpected character '${l}'`,line:o}),s++}return{toks:e,errors:t}}function Qs(n){return n==="true"?!0:n==="false"?!1:/^-?\d+$/.test(n)?Number(n):n}function Ot(n){let{toks:e,errors:t}=zs(n),o=[],s=[],a=new Map,l="harness",u=0,p=()=>e[u],r=()=>e[u++],d=(E,b)=>t.push({message:E,line:b});p()?.kind==="id"&&p()?.value==="digraph"?(r(),p()?.kind==="id"&&p()?.value!==void 0&&(l=r().value),p()?.kind==="lbrace"?r():d("expected '{' after digraph header",p()?.line)):d("expected 'digraph' keyword",p()?.line);function h(){let E={};if(p()?.kind!=="lbrack")return{attrs:E};let b=r().line;for(;p()&&p().kind!=="rbrack";){let x=r();if(!x||x.kind!=="id"){d("expected attribute name",x?.line);break}if(p()?.kind!=="eq"){d(`expected '=' after attribute '${x.value}'`,x.line);break}r();let H=r();if(!H||H.kind!=="id"){d(`expected value for attribute '${x.value}'`,H?.line);break}E[x.value]=H.value,p()?.kind==="comma"&&r()}return p()?.kind==="rbrack"?r():d("unterminated attribute list '['",b),{attrs:E,line:b}}function y(E,b){let x=a.get(E);return x||(x={id:E,type:"analyst",attrs:{},files:{},raw:{},line:b},a.set(E,x),o.push(x)),x}function m(E,b,x){E.declared=!0,E.raw={...E.raw,...b},x!==void 0&&(E.line=E.line??x);for(let[H,M]of Object.entries(b))H==="type"?(Js.has(M)||d(`unknown node type '${M}' on node '${E.id}'`,x),E.type=M):H==="context"?E.context=M:Xs.has(H)?E.files[H]=M:E.attrs[H]=Qs(M)}let $=0;for(;p()&&p().kind!=="rbrace"&&!($++>1e5);){let E=p();if(E.kind==="semi"){r();continue}if(E.kind!=="id"){d(`unexpected token '${E.value}'`,E.line),r();continue}let b=r();if(p()?.kind==="arrow"){let x=[{id:b.value,line:b.line}];for(;p()?.kind==="arrow";){r();let j=r();if(!j||j.kind!=="id"){d("expected node id after '->'",j?.line);break}x.push({id:j.value,line:j.line})}let{attrs:H,line:M}=h();for(let j=0;j+1<x.length;j++){let W=x[j],B=x[j+1];y(W.id,W.line),y(B.id,B.line);let te={from:W.id,to:B.id,raw:{...H},line:M??W.line};H.on!==void 0&&(te.on=H.on),H.when!==void 0&&(te.when=H.when),H.do!==void 0&&(te.do=H.do),s.push(te)}}else{let{attrs:x,line:H}=h(),M=y(b.value,b.line);m(M,x,H??b.line)}p()?.kind==="semi"&&r()}return p()?.kind==="rbrace"&&r(),{name:l,nodes:o,edges:s,errors:t}}I();var Ct=require("fs");var ct={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 pn(n){if(!n||!(0,Ct.existsSync)(n))return structuredClone(ct);let e=Re.load((0,Ct.readFileSync)(n,"utf8"))??{};return{...ct,...e,identity:{...ct.identity,...e.identity??{}},agent:{...ct.agent,...e.agent??{}},repo:{...ct.repo,...e.repo??{}},labels:{...ct.labels,...e.labels??{}}}}function $e(n,e){let t=Ot((0,Ct.readFileSync)(n,"utf8")),o=pn(e);return{harness:{name:t.name,nodes:t.nodes,edges:t.edges,config:o,sourcePath:n},parseErrors:t.errors}}function ut(n,e={},t={}){let o=[...vt(n,e),...kt(n)],s=u=>{let p=n.nodes.find(h=>h.id===u)?.files.role,r=p&&e.readFile?e.readFile(p):void 0;if(r===void 0)return;let d=at(r)?.tools;return typeof d=="string"?d:void 0},a=to(n),l=co(n,a,t.specDir??"",{roleTools:s});return l.push({path:".github/HARNESS.md",contents:dn(n,a),generated:!0}),{files:l,diagnostics:o}}function Tt(n){return n.some(e=>e.level==="error")}I();var Ne=require("fs"),fe=require("path"),uo=require("url"),Ye=Ut(Yt(),1);function xt(n,e){let t=(0,fe.join)(n,".github","workflows");if(!(0,Ne.existsSync)(t))return[];let o=new Set(e.map(s=>s.path));return(0,Ne.readdirSync)(t).filter(s=>/\.ya?ml$/.test(s)).map(s=>`.github/workflows/${s}`).filter(s=>!o.has(s)).filter(s=>(0,Ne.readFileSync)((0,fe.join)(n,s),"utf8").startsWith(ki)).sort()}function ge(n){return(0,uo.fileURLToPath)(new URL(`../../${n}`,G))}function z(n){process.stdout.write(JSON.stringify(n,null,2)+`
177
+ `)}function Si(n){for(let e of n){let t=e.level==="error"?Ye.default.red("error"):e.level==="warning"?Ye.default.yellow("warn"):Ye.default.blue("info"),o=e.where?.node?Ye.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${t} ${Ye.default.dim(e.code)}${o} ${e.message}
178
+ `),e.hint&&process.stderr.write(` ${Ye.default.dim("hint: "+e.hint)}
179
+ `)}}function Ie(n){let e=(0,fe.resolve)(n.dot??".github/harness.dot"),t=(0,fe.dirname)(e),o=n.config?(0,fe.resolve)(n.config):void 0;if(!o){for(let a of[(0,fe.join)(t,"foundry.config.yaml"),(0,fe.join)(t,"agents/foundry.config.yaml")])if((0,Ne.existsSync)(a)){o=a;break}}let s=t.endsWith(".github")?(0,fe.dirname)(t):t;return{dot:e,config:o,base:t,root:s}}function Rt(n){return e=>{let t=(0,fe.join)(n,e);try{return(0,Ne.existsSync)(t)?(0,Ne.readFileSync)(t,"utf8"):void 0}catch{return}}}I();var Oi=require("child_process"),U=require("fs"),Y=require("path");var V=Ut(Yt(),1);var Ci=require("path");function dt(n,e={}){try{return{ok:!0,out:(0,Oi.execFileSync)("gh",n,{encoding:"utf8",stdio:["ignore","pipe","pipe"],cwd:e.cwd}).trim()}}catch(t){return{ok:!1,out:t.stderr?.toString().trim()??String(t.message)}}}function De(n,e){let t=dt(n,{cwd:e});if(!t.ok)return null;try{return JSON.parse(t.out)}catch{return null}}function go(){let n=ge("actions");return(0,U.readdirSync)(n,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(0,U.existsSync)((0,Y.join)(n,e.name,"action.yml"))).map(e=>e.name)}function mo(n){let e=pn(n),t=new Map([["build","ready to implement"],["plan","needs design first"]]),o=[];for(let[s,a]of t)o.push({name:e.labels?.[s]??s,description:a,color:s==="build"?"0e8a16":"5319e7"});return o.push({name:"needs-human",description:"agents are blocked; a human should take over",color:"b60205"}),o.push({name:"needs-rebase",description:"PR conflicts with base; the janitor sweep rebases it",color:"d93f0b"}),o}function po(n){let e={ok:V.default.green("\u2713"),warn:V.default.yellow("!"),fail:V.default.red("\u2717"),skip:V.default.dim("-")};for(let t of n)process.stdout.write(`${e[t.status]} ${t.name.padEnd(28)} ${t.detail}
180
+ `),t.hint&&t.status!=="ok"&&process.stdout.write(` ${V.default.dim("hint: "+t.hint)}
181
+ `)}function Zs(n,e){let t=n.nodes.filter(o=>o.type==="merge-gate");return t.length===0?!1:t.some(o=>{if(!o.files.policy)return!0;let s=(0,Y.dirname)(n.sourcePath??""),a=(0,Y.join)(e,s,o.files.policy);if(!(0,U.existsSync)(a))return!0;try{let l=Re.load((0,U.readFileSync)(a,"utf8"));return(l?.require_ci??l?.requireCi)!==!1}catch{return!0}})}function ho(n){let e=[];for(let o of go()){let s=ge(`actions/${o}`),a=(0,Y.join)(n,".github/actions",o);(0,U.mkdirSync)(a,{recursive:!0}),(0,U.cpSync)((0,Y.join)(s,"action.yml"),(0,Y.join)(a,"action.yml")),(0,U.existsSync)((0,Y.join)(s,"dist"))&&(0,U.cpSync)((0,Y.join)(s,"dist"),(0,Y.join)(a,"dist"),{recursive:!0}),e.push(`.github/actions/${o}/`)}let t=(0,Y.join)(n,".github/agent-setup/action.yml");return(0,U.existsSync)(t)||((0,U.mkdirSync)((0,Y.dirname)(t),{recursive:!0}),(0,U.writeFileSync)(t,(0,U.readFileSync)(ge("skill/templates/agent-setup.yml"),"utf8")),e.push(".github/agent-setup/action.yml")),e}function ea(n){(0,U.mkdirSync)(n,{recursive:!0}),(0,U.cpSync)(ge("skill/SKILL.md"),(0,Y.join)(n,"SKILL.md")),(0,U.cpSync)(ge("skill/reference"),(0,Y.join)(n,"reference"),{recursive:!0}),(0,U.cpSync)(ge("skill/templates"),(0,Y.join)(n,"templates"),{recursive:!0})}function fo(n){let e=[],{dot:t,config:o,base:s,root:a}=Ie(n);if(!(0,U.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:l,parseErrors:u}=$e(t,o),p=F=>(0,U.existsSync)((0,Y.join)(s,F)),r=(0,Ci.relative)(a,s).replace(/\\/g,"/"),{files:d,diagnostics:h}=ut(l,{fileExists:p,readFile:Rt(s)},{specDir:r}),y=h.filter(F=>F.level==="error").length+u.length,m=h.filter(F=>F.level==="warning");e.push(y?{name:"validate",status:"fail",detail:`${y} error(s)`,hint:"run `gp-foundry validate` for details"}:{name:"validate",status:m.length?"warn":"ok",detail:m.length?`${m.length} warning(s): ${m.map(F=>F.code).join(", ")}`:"no diagnostics"});let $=d.filter(F=>{let ue=(0,Y.join)(a,F.path);return((0,U.existsSync)(ue)?(0,U.readFileSync)(ue,"utf8"):null)!==F.contents}),E=xt(a,d),b=[...$.map(F=>F.path),...E.map(F=>`${F} (stale)`)];if(e.push(b.length?{name:"workflows in sync",status:"fail",detail:`${b.length} file(s) out of sync: ${b.slice(0,3).join(", ")}${b.length>3?", \u2026":""}`,hint:"run `gp-foundry build`"}:{name:"workflows in sync",status:"ok",detail:`${d.length} generated files match`}),(l.config.runtime?.mode??"pinned")==="vendored"){let F=go().filter(ue=>!(0,U.existsSync)((0,Y.join)(a,".github/actions",ue,"action.yml")));e.push(F.length?{name:"vendored actions",status:"fail",detail:`missing: ${F.join(", ")}`,hint:"run `gp-foundry vendor`"}:{name:"vendored actions",status:"ok",detail:"all runtime actions vendored"})}if(e.push((0,U.existsSync)((0,Y.join)(a,".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`)"}),!dt(["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(F=>F.status==="fail")};e.push({name:"gh cli",status:"ok",detail:"authenticated"});let H=De(["repo","view","--json","nameWithOwner,defaultBranchRef"],a);if(!H)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(F=>F.status==="fail")};e.push({name:"github repo",status:"ok",detail:H.nameWithOwner});let M=H.defaultBranchRef?.name;M&&e.push(M===l.config.repo.base_branch?{name:"base branch",status:"ok",detail:M}:{name:"base branch",status:"fail",detail:`config says '${l.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 j=new Set((De(["label","list","--json","name","--limit","1000"],a)??[]).map(F=>F.name)),W=mo(o).map(F=>F.name),B=W.filter(F=>!j.has(F));e.push(B.length?{name:"labels",status:"fail",detail:`missing: ${B.join(", ")}`,hint:"run `gp-foundry up` to create them"}:{name:"labels",status:"ok",detail:W.join(", ")});let te=new Set((De(["secret","list","--json","name"],a)??[]).map(F=>F.name)),me=[l.config.agent.api_key_secret||(l.config.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")],ae=l.config.auth;ae?.mode==="pat"&&ae.token_secret&&me.push(ae.token_secret),ae?.mode==="app"&&me.push(ae.app_id_secret??"APP_ID",ae.app_key_secret??"APP_PRIVATE_KEY");let oe=me.filter(F=>!te.has(F));if(e.push(oe.length?{name:"secrets",status:"fail",detail:`missing: ${oe.join(", ")}`,hint:`gh secret set ${oe[0]}`}:{name:"secrets",status:"ok",detail:me.join(", ")}),Zs(l,a)){let ue=d.filter(le=>/\/workflows\/.*\.yml$/.test(le.path)&&le.contents.includes("actions/merge-gate")).map(le=>(0,Y.join)(a,le.path)).filter(le=>(0,U.existsSync)(le)).map(le=>(0,U.readFileSync)(le,"utf8")),ee=ue.filter(le=>!le.includes("checks-token"));ue.length&&ee.length&&e.push({name:"merge gate ci read",status:"fail",detail:`${ee.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 be=dt(["--version"]);try{let F=(0,Oi.execFileSync)("git",["status","--porcelain",".github"],{cwd:a,encoding:"utf8"}).trim();e.push(F?{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(F=>F.status==="fail")}}function ta(n){let{dot:e,config:t,root:o}=Ie(n);if(!dt(["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 s=De(["repo","view","--json","nameWithOwner"],o);if(!s)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:a}=$e(e,t),l=a.config.repo.branch_prefix,u=Date.now(),p=b=>Math.round((u-Date.parse(b))/36e5),r={};for(let b of["plan","build","needs-human"]){let x=b==="needs-human"?"needs-human":a.config.labels?.[b]??b,H=De(["issue","list","--label",x,"--state","open","--json","number,title,createdAt","--limit","50"],o)??[];r[x]=H.map(M=>({number:M.number,title:M.title,ageHours:p(M.createdAt)}))}let h=(De(["pr","list","--state","open","--json","number,title,labels,mergeable,headRefName,body,updatedAt","--limit","50"],o)??[]).filter(b=>b.headRefName.startsWith(l)),y=[],m=new Set;for(let b of h)for(let x of b.body?.matchAll(/[Cc]loses #(\d+)/g)??[])m.add(Number(x[1]));let $=a.config.labels?.build??"build";for(let b of r[$]??[])!m.has(b.number)&&b.ageHours>=2&&y.push({kind:"issue-no-pr",number:b.number,title:b.title,detail:`labeled ${$} ${b.ageHours}h ago, no open PR closes it`});for(let b of h)b.updatedAt&&p(b.updatedAt)>=4&&y.push({kind:"pr-idle",number:b.number,title:b.title,detail:`no activity for ${p(b.updatedAt)}h`});let E=(De(["run","list","--status","failure","--limit","15","--json","name,url,createdAt,conclusion"],o)??[]).filter(b=>p(b.createdAt)<=24).map(b=>({workflow:b.name,url:b.url,ageHours:p(b.createdAt)}));return{repo:s.nameWithOwner,lanes:r,prs:h.map(b=>({number:b.number,title:b.title,labels:b.labels.map(x=>x.name),mergeable:b.mergeable,headRefName:b.headRefName})),stalled:y,recentFailures:E}}function bo(n){n.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=ho(e.dir);if(e.json)return z({written:t});for(let o of t)process.stdout.write(V.default.green(`vendored ${o}
182
+ `));process.stdout.write(V.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
183
+ `))}),n.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??".",o=e.user?(0,Y.join)(t,".claude/skills/gp-foundry"):(0,Y.join)(e.dir,".claude/skills/gp-foundry");if(ea(o),e.json)return z({installed:o});process.stdout.write(V.default.green(`installed skill \u2192 ${o}
184
+ `)),process.stdout.write(V.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
94
185
  The skill interviews you Socratically, drafts harness.dot + roles, and drives this CLI.
95
- `))}),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}=Kr(e);e.json?X({ok:!r,checks:t}):(Vr(t),process.stdout.write(r?G.default.red(`
186
+ `))}),n.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:o}=fo(e);e.json?z({ok:!o,checks:t}):(po(t),process.stdout.write(o?V.default.red(`
96
187
  not ready \u2014 fix the \u2717 items above
97
- `):G.default.green(`
188
+ `):V.default.green(`
98
189
  factory is ready
99
- `))),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=Cs(e);if("error"in t&&(e.json?X(t):(process.stderr.write(G.default.red(t.error+`
100
- `)),t.hint&&process.stderr.write(G.default.dim("hint: "+t.hint+`
101
- `))),process.exit(1)),e.json)return X(t);process.stdout.write(G.default.bold(`
190
+ `))),process.exit(o?1:0)}),n.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=ta(e);if("error"in t&&(e.json?z(t):(process.stderr.write(V.default.red(t.error+`
191
+ `)),t.hint&&process.stderr.write(V.default.dim("hint: "+t.hint+`
192
+ `))),process.exit(1)),e.json)return z(t);process.stdout.write(V.default.bold(`
102
193
  ${t.repo} \u2014 factory status
103
194
 
104
- `));for(let[r,o]of Object.entries(t.lanes)){process.stdout.write(G.default.cyan(`${r} (${o.length})
105
- `));for(let a of o.slice(0,10))process.stdout.write(` #${a.number} ${a.title} ${G.default.dim(`(${a.ageHours}h)`)}
106
- `)}process.stdout.write(G.default.cyan(`
195
+ `));for(let[o,s]of Object.entries(t.lanes)){process.stdout.write(V.default.cyan(`${o} (${s.length})
196
+ `));for(let a of s.slice(0,10))process.stdout.write(` #${a.number} ${a.title} ${V.default.dim(`(${a.ageHours}h)`)}
197
+ `)}process.stdout.write(V.default.cyan(`
107
198
  agent PRs (${t.prs.length})
108
- `));for(let r of t.prs)process.stdout.write(` #${r.number} ${r.title} ${G.default.dim(r.mergeable??"")} ${r.labels.length?G.default.yellow(r.labels.join(",")):""}
109
- `);if(t.stalled.length){process.stdout.write(G.default.red(`
199
+ `));for(let o of t.prs)process.stdout.write(` #${o.number} ${o.title} ${V.default.dim(o.mergeable??"")} ${o.labels.length?V.default.yellow(o.labels.join(",")):""}
200
+ `);if(t.stalled.length){process.stdout.write(V.default.red(`
110
201
  stalled (${t.stalled.length})
111
- `));for(let r of t.stalled)process.stdout.write(` #${r.number} ${r.title} \u2014 ${r.detail}
112
- `)}if(t.recentFailures.length){process.stdout.write(G.default.red(`
202
+ `));for(let o of t.stalled)process.stdout.write(` #${o.number} ${o.title} \u2014 ${o.detail}
203
+ `)}if(t.recentFailures.length){process.stdout.write(V.default.red(`
113
204
  failed runs, last 24h (${t.recentFailures.length})
114
- `));for(let r of t.recentFailures.slice(0,10))process.stdout.write(` ${r.workflow} ${G.default.dim(`${r.ageHours}h ago`)} ${r.url}
115
- `)}!t.stalled.length&&!t.recentFailures.length&&process.stdout.write(G.default.green(`
205
+ `));for(let o of t.recentFailures.slice(0,10))process.stdout.write(` ${o.workflow} ${V.default.dim(`${o.ageHours}h ago`)} ${o.url}
206
+ `)}!t.stalled.length&&!t.recentFailures.length&&process.stdout.write(V.default.green(`
116
207
  no stalled work, no recent failures
117
- `))}),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:a}=Ce(e),c={};if(it(["auth","status"]).ok&&Ie(["repo","view","--json","nameWithOwner"],a)){let _=[];for(let R of Xr(r))it(["label","create",R.name,"--color",R.color,"--description",R.description],{cwd:a}).ok&&_.push(R.name);c.labels=_,e.json||process.stdout.write(G.default.green(`labels ensured (created: ${_.length?_.join(", "):"none \u2014 already present"})
118
- `))}else c.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(G.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(t,r);(p.config.runtime?.mode??"pinned")==="vendored"&&(c.vendored=Yr(a),e.json||process.stdout.write(G.default.green(`vendored ${c.vendored.length} runtime action(s)
119
- `)));let s=_=>(0,B.existsSync)((0,V.join)(o,_)),l=(0,hi.relative)(a,o).replace(/\\/g,"/"),{files:d,diagnostics:f}=nt(p,{fileExists:s,readFile:At(o)},{specDir:l});_t(f)&&(e.json?X({ok:!1,diagnostics:f}):process.stderr.write(G.default.red("build errors \u2014 run `gp-foundry validate` for details\n")),process.exit(1));for(let _ of d){let R=(0,V.join)(a,_.path);(0,B.mkdirSync)((0,V.dirname)(R),{recursive:!0}),(0,B.writeFileSync)(R,_.contents)}c.wrote=d.map(_=>_.path);let w=$t(a,d);for(let _ of w)(0,B.rmSync)((0,V.join)(a,_));c.removed=w,w.length&&!e.json&&process.stdout.write(G.default.yellow(`removed ${w.length} stale generated workflow(s): ${w.join(", ")}
120
- `));let m=d.filter(_=>_.path.startsWith(".github/workflows/")).length;e.json||process.stdout.write(G.default.green(`built ${m} workflows + HARNESS.md
121
- `));let{checks:O,failed:y}=Kr(e);if(c.checks=O,c.ok=!y,e.json)return X(c);process.stdout.write(`
122
- `),Vr(O),process.stdout.write(y?G.default.yellow(`
208
+ `))}),n.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:o,base:s,root:a}=Ie(e),l={};if(dt(["auth","status"]).ok&&De(["repo","view","--json","nameWithOwner"],a)){let b=[];for(let x of mo(o))dt(["label","create",x.name,"--color",x.color,"--description",x.description],{cwd:a}).ok&&b.push(x.name);l.labels=b,e.json||process.stdout.write(V.default.green(`labels ensured (created: ${b.length?b.join(", "):"none \u2014 already present"})
209
+ `))}else l.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(V.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:u}=$e(t,o);(u.config.runtime?.mode??"pinned")==="vendored"&&(l.vendored=ho(a),e.json||process.stdout.write(V.default.green(`vendored ${l.vendored.length} runtime action(s)
210
+ `)));let p=b=>(0,U.existsSync)((0,Y.join)(s,b)),r=(0,Ci.relative)(a,s).replace(/\\/g,"/"),{files:d,diagnostics:h}=ut(u,{fileExists:p,readFile:Rt(s)},{specDir:r});Tt(h)&&(e.json?z({ok:!1,diagnostics:h}):process.stderr.write(V.default.red("build errors \u2014 run `gp-foundry validate` for details\n")),process.exit(1));for(let b of d){let x=(0,Y.join)(a,b.path);(0,U.mkdirSync)((0,Y.dirname)(x),{recursive:!0}),(0,U.writeFileSync)(x,b.contents)}l.wrote=d.map(b=>b.path);let y=xt(a,d);for(let b of y)(0,U.rmSync)((0,Y.join)(a,b));l.removed=y,y.length&&!e.json&&process.stdout.write(V.default.yellow(`removed ${y.length} stale generated workflow(s): ${y.join(", ")}
211
+ `));let m=d.filter(b=>b.path.startsWith(".github/workflows/")).length;e.json||process.stdout.write(V.default.green(`built ${m} workflows + HARNESS.md
212
+ `));let{checks:$,failed:E}=fo(e);if(l.checks=$,l.ok=!E,e.json)return z(l);process.stdout.write(`
213
+ `),po($),process.stdout.write(E?V.default.yellow(`
123
214
  almost there \u2014 fix the \u2717 items above, commit .github/, push, then file an issue
124
- `):G.default.green(`
215
+ `):V.default.green(`
125
216
  factory is up \u2014 commit .github/, push, then file an issue to watch it run
126
- `)),process.exit(y?1:0)})}var He=new Ti,Os=JSON.parse((0,Y.readFileSync)(he("package.json"),"utf8")).version;He.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(Os);function Ts(i,e){let t=new Map;for(let r of i.nodes){if(!r.files.role)continue;let o=(0,te.join)(e,r.files.role);if((0,Y.existsSync)(o)){let a=nn((0,Y.readFileSync)(o,"utf8"));a&&t.set(r.id,a)}}return t}var Rs=[["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"]];He.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,te.resolve)(i.dir),t=[],r=[],o=(p,s)=>{let l=(0,te.join)(e,p);if((0,Y.existsSync)(l)&&!i.force){r.push(p);return}(0,Y.mkdirSync)((0,te.dirname)(l),{recursive:!0}),(0,Y.writeFileSync)(l,s),t.push(p)},a="main";try{let p=(0,Qr.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();p&&(a=p)}catch{}for(let[p,s]of Rs){let l=(0,Y.readFileSync)(he(p),"utf8");s.endsWith("foundry.config.yaml")&&a!=="main"&&(l=l.replace(/^(\s*base_branch:\s*)main\b/m,`$1${a}`)),o(s,l)}let c=(0,te.join)(e,".github/harness.dot");if((0,Y.existsSync)(c))for(let p of yt((0,Y.readFileSync)(c,"utf8")).nodes){if(!p.files.role)continue;let s=p.files.role.replace(/^.*\//,"").replace(/\.md$/,""),l=he(`roles/software/${s}.md`),d=(0,Y.existsSync)(l)?l:he("skill/templates/role.md");o((0,te.join)(".github",p.files.role),(0,Y.readFileSync)(d,"utf8"))}if(i.json)return X({written:t,skipped:r});for(let p of t)process.stdout.write(J.default.green(`created ${p}
127
- `));for(let p of r)process.stderr.write(J.default.yellow(`skipped ${p} (exists; --force to overwrite)
128
- `));process.stdout.write(["",J.default.bold("Next steps \u2014 dark factory in 4 moves:"),` 1. ${J.default.cyan("gp-foundry up")} vendor actions, create labels, build workflows, run checks`,` 2. set two secrets: ${J.default.cyan("gh secret set CLAUDE_CODE_OAUTH_TOKEN")} (agent auth)`,` ${J.default.cyan("gh secret set AGENT_PAT")} (fine-grained PAT: contents/PRs/issues RW)`,` 3. commit + push ${J.default.cyan(".github/")}`," 4. file an issue \u2192 the \u{1F575}\uFE0F scout triages it and the factory takes it from there","",J.default.dim("Tune later: .github/harness.dot (topology) \xB7 agents/roles/*.md (behavior) \xB7 agents/policy/merge.yaml (merge rules)"),""].join(`
129
- `))});He.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}=Ce(i);(0,Y.existsSync)(e)||(i.json?X({error:`no harness.dot at ${e}`}):process.stderr.write(J.default.red(`no harness.dot at ${e}
130
- `)),process.exit(1));let{harness:a,parseErrors:c}=be(e,t);if(c.length){if(i.json)X({parseErrors:c});else for(let m of c)process.stderr.write(J.default.red(`parse: ${m.message}${m.line?` (line ${m.line})`:""}
131
- `));process.exit(1)}let p=(0,te.resolve)(i.out??o),s=(0,te.relative)(p,r).replace(/\\/g,"/"),l=m=>(0,Y.existsSync)((0,te.join)(r,m)),{files:d,diagnostics:f}=nt(a,{fileExists:l,readFile:At(r)},{specDir:s});i.json||pi(f);let w=$t(p,d);if(i.check){let m=d.filter(y=>{let _=(0,te.join)(p,y.path);return((0,Y.existsSync)(_)?(0,Y.readFileSync)(_,"utf8"):null)!==y.contents}),O=m.length===0&&w.length===0;if(i.json)X({upToDate:O,drift:m.map(y=>y.path),stale:w,diagnostics:f});else if(O)process.stdout.write(J.default.green(`up to date
132
- `));else{for(let y of m)process.stderr.write(J.default.yellow(`drift: ${y.path}
133
- `));for(let y of w)process.stderr.write(J.default.yellow(`stale: ${y} (no longer generated)
134
- `));process.stderr.write(J.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}process.exit(O?0:1)}if(_t(f)&&!i.force&&(i.json?X({ok:!1,diagnostics:f,wrote:[]}):process.stderr.write(J.default.red(`errors present \u2014 not writing (use --force to override)
135
- `)),process.exit(1)),i.dryRun){if(i.json)X({diagnostics:f,files:d,stale:w});else{for(let m of d)process.stdout.write(J.default.cyan(`--- ${m.path}
217
+ `)),process.exit(E?1:0)})}var Me=new Gi,na=JSON.parse((0,K.readFileSync)(ge("package.json"),"utf8")).version;Me.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(na);function ia(n,e){let t=new Map;for(let o of n.nodes){if(!o.files.role)continue;let s=(0,re.join)(e,o.files.role);if((0,K.existsSync)(s)){let a=at((0,K.readFileSync)(s,"utf8"));a&&t.set(o.id,a)}}return t}var ra=[["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"]];Me.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(n=>{let e=(0,re.resolve)(n.dir),t=[],o=[],s=(u,p)=>{let r=(0,re.join)(e,u);if((0,K.existsSync)(r)&&!n.force){o.push(u);return}(0,K.mkdirSync)((0,re.dirname)(r),{recursive:!0}),(0,K.writeFileSync)(r,p),t.push(u)},a="main";try{let u=(0,wo.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();u&&(a=u)}catch{}for(let[u,p]of ra){let r=(0,K.readFileSync)(ge(u),"utf8");p.endsWith("foundry.config.yaml")&&a!=="main"&&(r=r.replace(/^(\s*base_branch:\s*)main\b/m,`$1${a}`)),s(p,r)}let l=(0,re.join)(e,".github/harness.dot");if((0,K.existsSync)(l))for(let u of Ot((0,K.readFileSync)(l,"utf8")).nodes){if(!u.files.role)continue;let p=u.files.role.replace(/^.*\//,"").replace(/\.md$/,""),r=ge(`roles/software/${p}.md`),d=(0,K.existsSync)(r)?r:ge("skill/templates/role.md");s((0,re.join)(".github",u.files.role),(0,K.readFileSync)(d,"utf8"))}if(n.json)return z({written:t,skipped:o});for(let u of t)process.stdout.write(X.default.green(`created ${u}
218
+ `));for(let u of o)process.stderr.write(X.default.yellow(`skipped ${u} (exists; --force to overwrite)
219
+ `));process.stdout.write(["",X.default.bold("Next steps \u2014 dark factory in 4 moves:"),` 1. ${X.default.cyan("gp-foundry up")} vendor actions, create labels, build workflows, run checks`,` 2. set two secrets: ${X.default.cyan("gh secret set CLAUDE_CODE_OAUTH_TOKEN")} (agent auth)`,` ${X.default.cyan("gh secret set AGENT_PAT")} (fine-grained PAT: contents/PRs/issues RW)`,` 3. commit + push ${X.default.cyan(".github/")}`," 4. file an issue \u2192 the \u{1F575}\uFE0F scout triages it and the factory takes it from there","",X.default.dim("Tune later: .github/harness.dot (topology) \xB7 agents/roles/*.md (behavior) \xB7 agents/policy/merge.yaml (merge rules)"),""].join(`
220
+ `))});Me.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(n=>{let{dot:e,config:t,base:o,root:s}=Ie(n);(0,K.existsSync)(e)||(n.json?z({error:`no harness.dot at ${e}`}):process.stderr.write(X.default.red(`no harness.dot at ${e}
221
+ `)),process.exit(1));let{harness:a,parseErrors:l}=$e(e,t);if(l.length){if(n.json)z({parseErrors:l});else for(let m of l)process.stderr.write(X.default.red(`parse: ${m.message}${m.line?` (line ${m.line})`:""}
222
+ `));process.exit(1)}let u=(0,re.resolve)(n.out??s),p=(0,re.relative)(u,o).replace(/\\/g,"/"),r=m=>(0,K.existsSync)((0,re.join)(o,m)),{files:d,diagnostics:h}=ut(a,{fileExists:r,readFile:Rt(o)},{specDir:p});n.json||Si(h);let y=xt(u,d);if(n.check){let m=d.filter(E=>{let b=(0,re.join)(u,E.path);return((0,K.existsSync)(b)?(0,K.readFileSync)(b,"utf8"):null)!==E.contents}),$=m.length===0&&y.length===0;if(n.json)z({upToDate:$,drift:m.map(E=>E.path),stale:y,diagnostics:h});else if($)process.stdout.write(X.default.green(`up to date
223
+ `));else{for(let E of m)process.stderr.write(X.default.yellow(`drift: ${E.path}
224
+ `));for(let E of y)process.stderr.write(X.default.yellow(`stale: ${E} (no longer generated)
225
+ `));process.stderr.write(X.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}process.exit($?0:1)}if(Tt(h)&&!n.force&&(n.json?z({ok:!1,diagnostics:h,wrote:[]}):process.stderr.write(X.default.red(`errors present \u2014 not writing (use --force to override)
226
+ `)),process.exit(1)),n.dryRun){if(n.json)z({diagnostics:h,files:d,stale:y});else{for(let m of d)process.stdout.write(X.default.cyan(`--- ${m.path}
136
227
  `)+m.contents+`
137
- `);for(let m of w)process.stdout.write(J.default.yellow(`would remove ${m} (no longer generated)
138
- `))}return}for(let m of d){let O=(0,te.join)(p,m.path);(0,Y.mkdirSync)((0,te.dirname)(O),{recursive:!0}),(0,Y.writeFileSync)(O,m.contents),i.json||process.stdout.write(J.default.green(`wrote ${m.path}
139
- `))}for(let m of w)(0,Y.rmSync)((0,te.join)(p,m)),i.json||process.stdout.write(J.default.yellow(`removed ${m} (no longer generated)
140
- `));i.json&&X({ok:!_t(f),diagnostics:f,wrote:d.map(m=>m.path),removed:w})});He.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}=Ce(i);(0,Y.existsSync)(e)||(i.json?X({ok:!1,error:`no harness.dot at ${e}`}):process.stderr.write(J.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
141
- `)),process.exit(1));let{harness:o,parseErrors:a}=be(e,t),c=d=>(0,Y.existsSync)((0,te.join)(r,d)),p=Ts(o,r),s=[...ft(o,{fileExists:c,roles:p}),...ht(o)],l=s.some(d=>d.level==="error")||a.length>0;if(i.json)X({ok:!l,parseErrors:a,diagnostics:s});else{for(let d of a)process.stderr.write(J.default.red(`parse: ${d.message}
142
- `));pi(s)}process.exit(l?1:0)});He.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}=Ce(i);(0,Y.existsSync)(e)||(i.json?X({error:`no harness.dot at ${e}`}):process.stderr.write(J.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
143
- `)),process.exit(1));let{harness:t}=be(e);i.json?X({name:t.name,nodes:t.nodes,edges:t.edges}):process.stdout.write(tn(t)+`
144
- `)});He.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}=Ce(e);(0,Y.existsSync)(t)||(e.json?X({error:`no harness.dot at ${t}`}):process.stderr.write(J.default.red(`no harness.dot at ${t} \u2014 run \`gp-foundry init\` first
145
- `)),process.exit(1));let{harness:o}=be(t,r),{files:a}=nt(o),c=a.find(p=>p.path.endsWith(`/${i}.yml`))??a.find(p=>p.path.startsWith(".github/workflows/")&&new RegExp(`^ ${i}:`,"m").test(p.contents));c||(e.json?X({error:`no generated workflow for node '${i}'`}):process.stderr.write(J.default.red(`no generated workflow for node '${i}'
146
- `)),process.exit(1)),e.json?X({node:i,path:c.path,contents:c.contents}):process.stdout.write(c.contents+`
147
- `)});zr(He);He.parseAsync(process.argv);
228
+ `);for(let m of y)process.stdout.write(X.default.yellow(`would remove ${m} (no longer generated)
229
+ `))}return}for(let m of d){let $=(0,re.join)(u,m.path);(0,K.mkdirSync)((0,re.dirname)($),{recursive:!0}),(0,K.writeFileSync)($,m.contents),n.json||process.stdout.write(X.default.green(`wrote ${m.path}
230
+ `))}for(let m of y)(0,K.rmSync)((0,re.join)(u,m)),n.json||process.stdout.write(X.default.yellow(`removed ${m} (no longer generated)
231
+ `));n.json&&z({ok:!Tt(h),diagnostics:h,wrote:d.map(m=>m.path),removed:y})});Me.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(n=>{let{dot:e,config:t,base:o}=Ie(n);(0,K.existsSync)(e)||(n.json?z({ok:!1,error:`no harness.dot at ${e}`}):process.stderr.write(X.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
232
+ `)),process.exit(1));let{harness:s,parseErrors:a}=$e(e,t),l=d=>(0,K.existsSync)((0,re.join)(o,d)),u=ia(s,o),p=[...vt(s,{fileExists:l,roles:u}),...kt(s)],r=p.some(d=>d.level==="error")||a.length>0;if(n.json)z({ok:!r,parseErrors:a,diagnostics:p});else{for(let d of a)process.stderr.write(X.default.red(`parse: ${d.message}
233
+ `));Si(p)}process.exit(r?1:0)});Me.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(n=>{let{dot:e}=Ie(n);(0,K.existsSync)(e)||(n.json?z({error:`no harness.dot at ${e}`}):process.stderr.write(X.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
234
+ `)),process.exit(1));let{harness:t}=$e(e);n.json?z({name:t.name,nodes:t.nodes,edges:t.edges}):process.stdout.write(dn(t)+`
235
+ `)});Me.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((n,e)=>{let{dot:t,config:o}=Ie(e);(0,K.existsSync)(t)||(e.json?z({error:`no harness.dot at ${t}`}):process.stderr.write(X.default.red(`no harness.dot at ${t} \u2014 run \`gp-foundry init\` first
236
+ `)),process.exit(1));let{harness:s}=$e(t,o),{files:a}=ut(s),l=a.find(u=>u.path.endsWith(`/${n}.yml`))??a.find(u=>u.path.startsWith(".github/workflows/")&&new RegExp(`^ ${n}:`,"m").test(u.contents));l||(e.json?z({error:`no generated workflow for node '${n}'`}):process.stderr.write(X.default.red(`no generated workflow for node '${n}'
237
+ `)),process.exit(1)),e.json?z({node:n,path:l.path,contents:l.contents}):process.stdout.write(l.contents+`
238
+ `)});bo(Me);Me.parseAsync(process.argv);