@thegpvc/gp-foundry 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/merge-gate/README.md +49 -1
- package/actions/merge-gate/action.yml +20 -2
- package/actions/merge-gate/dist/index.cjs +87 -69
- package/actions/pr-scope/action.yml +11 -2
- package/actions/pr-scope/dist/index.cjs +29 -16
- package/dist/cli/index.cjs +90 -90
- package/package.json +1 -1
- package/skill/reference/node-types.md +2 -2
- package/skill/templates/policy-merge.yaml +7 -0
package/dist/cli/index.cjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Fo=Object.create;var Vi=Object.defineProperty;var jo=Object.getOwnPropertyDescriptor;var
|
|
3
|
-
`).replace(/^/gm," ".repeat(a))}let u=[`Usage: ${t.commandUsage(e)}`,""],r=t.commandDescription(e);r.length>0&&(u=u.concat([t.wrap(r,s,0),""]));let h=t.visibleArguments(e).map($=>
|
|
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
|
|
2
|
+
"use strict";var Fo=Object.create;var Vi=Object.defineProperty;var jo=Object.getOwnPropertyDescriptor;var qo=Object.getOwnPropertyNames;var Uo=Object.getPrototypeOf,Bo=Object.prototype.hasOwnProperty;var Go=(n,e,t)=>()=>{if(t)throw t[0];try{return n&&(e=n(n=0)),e}catch(o){throw t=[o],o}};var Me=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var Wo=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qo(e))!Bo.call(n,s)&&s!==t&&Vi(n,s,{get:()=>e[s],enumerable:!(o=jo(e,s))||o.enumerable});return n};var zt=(n,e,t)=>(t=n!=null?Fo(Uo(n)):{},Wo(e||!n||!n.__esModule?Vi(t,"default",{value:n,enumerable:!0}):t,n));var Vo,B,I=Go(()=>{"use strict";Vo=()=>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,B=Vo()});var Et=Me(In=>{"use strict";I();var Qt=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}},Nn=class extends Qt{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};In.CommanderError=Qt;In.InvalidArgumentError=Nn});var Zt=Me(Pn=>{"use strict";I();var{InvalidArgumentError:Ko}=Et(),Hn=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 Ko(`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 Yo(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}Pn.Argument=Hn;Pn.humanReadableArgName=Yo});var Dn=Me(Ki=>{"use strict";I();var{humanReadableArgName:Jo}=Zt(),Ln=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=>Jo(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 c($,w){if(w){let y=`${$.padEnd(o+l)}${w}`;return t.wrap(y,s-a,o+l)}return $}function p($){return $.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(a))}let u=[`Usage: ${t.commandUsage(e)}`,""],r=t.commandDescription(e);r.length>0&&(u=u.concat([t.wrap(r,s,0),""]));let h=t.visibleArguments(e).map($=>c(t.argumentTerm($),t.argumentDescription($)));h.length>0&&(u=u.concat(["Arguments:",p(h),""]));let f=t.visibleOptions(e).map($=>c(t.optionTerm($),t.optionDescription($)));if(f.length>0&&(u=u.concat(["Options:",p(f),""])),this.showGlobalOptions){let $=t.visibleGlobalOptions(e).map(w=>c(t.optionTerm(w),t.optionDescription(w)));$.length>0&&(u=u.concat(["Global Options:",p($),""]))}let m=t.visibleCommands(e).map($=>c(t.subcommandTerm($),t.subcommandDescription($)));return m.length>0&&(u=u.concat(["Commands:",p(m),""])),u.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 c=t-o;if(c<s)return e;let p=e.slice(0,o),u=e.slice(o).replace(`\r
|
|
5
5
|
`,`
|
|
6
6
|
`),r=" ".repeat(o),f="\\s\u200B",m=new RegExp(`
|
|
7
|
-
|.{1,${
|
|
7
|
+
|.{1,${c-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),$=u.match(m)||[];return p+$.map((w,y)=>w===`
|
|
8
8
|
`?"":(y>0?r:"")+w.trimEnd()).join(`
|
|
9
|
-
`)}};Ki.Help=
|
|
9
|
+
`)}};Ki.Help=Ln});var qn=Me(jn=>{"use strict";I();var{InvalidArgumentError:Xo}=Et(),Mn=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=Qo(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 zo(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Fn=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 zo(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Qo(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}}jn.Option=Mn;jn.DualOptions=Fn});var Ji=Me(Yi=>{"use strict";I();function Zo(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 es(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 c=Zo(n,l),p=Math.max(n.length,l.length);(p-c)/p>a&&(c<s?(s=c,o=[l]):c===s&&o.push(l))}),o.sort((l,c)=>l.localeCompare(c)),t&&(o=o.map(l=>`--${l}`)),o.length>1?`
|
|
10
10
|
(Did you mean one of ${o.join(", ")}?)`:o.length===1?`
|
|
11
|
-
(Did you mean ${o[0]}?)`:""}Yi.suggestSimilar=es});var er=Me(Zi=>{"use strict";
|
|
11
|
+
(Did you mean ${o[0]}?)`:""}Yi.suggestSimilar=es});var er=Me(Zi=>{"use strict";I();var ts=require("events").EventEmitter,Un=require("child_process"),xe=require("path"),Bn=require("fs"),te=require("process"),{Argument:ns,humanReadableArgName:is}=Zt(),{CommanderError:Gn}=Et(),{Help:rs}=Dn(),{Option:Xi,DualOptions:os}=qn(),{suggestSimilar:zi}=Ji(),Wn=class n extends ts{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=>te.stdout.write(t),writeErr:t=>te.stderr.write(t),getOutHelpWidth:()=>te.stdout.isTTY?te.stdout.columns:void 0,getErrHelpWidth:()=>te.stderr.isTTY?te.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,c]=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,c&&p.arguments(c),this._registerCommand(p),p.parent=this,p.copyInheritedSettings(this),s?this:p}createCommand(e){return new n(e)}createHelp(){return Object.assign(new rs,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
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 ns(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
|
|
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,
|
|
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 Gn(e,t,o)),te.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 Xi(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,c)=>{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,c)};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 Xi)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 c=s;s=(p,u)=>{let r=c.exec(p);return r?r[0]:u},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){te.versions?.electron&&(t.from="electron");let s=te.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(t.from="eval")}e===void 0&&(e=te.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":te.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(r,h){let f=xe.resolve(r,h);if(Bn.existsSync(f))return f;if(s.includes(xe.extname(h)))return;let m=s.find($=>Bn.existsSync(`${f}${$}`));if(m)return`${f}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let l=e._executableFile||`${this._name}-${e._name}`,c=this._executableDir||"";if(this._scriptPath){let r;try{r=Bn.realpathSync(this._scriptPath)}catch{r=this._scriptPath}c=xe.resolve(xe.dirname(r),c)}if(c){let r=a(c,l);if(!r&&!e._executableFile&&this._scriptPath){let h=xe.basename(this._scriptPath,xe.extname(this._scriptPath));h!==this._name&&(r=a(c,`${h}-${e._name}`))}l=r||l}o=s.includes(xe.extname(l));let p;te.platform!=="win32"?o?(t.unshift(l),t=Qi(te.execArgv).concat(t),p=Un.spawn(te.argv[0],t,{stdio:"inherit"})):p=Un.spawn(l,t,{stdio:"inherit"}):(t.unshift(l),t=Qi(te.execArgv).concat(t),p=Un.spawn(te.execPath,t,{stdio:"inherit"})),p.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{te.on(h,()=>{p.killed===!1&&p.exitCode===null&&p.kill(h)})});let u=this._exitCallback;p.on("close",r=>{r=r??1,u?u(new Gn(r,"commander.executeSubCommandAsync","(close)")):te.exit(r)}),p.on("error",r=>{if(r.code==="ENOENT"){let h=c?`searched for local subcommand relative to directory '${c}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",f=`'${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
|
-
- ${h}`;throw new Error(f)}else if(r.code==="EACCES")throw new Error(`'${l}' not executable`);if(!u)te.exit(1);else{let h=new
|
|
17
|
+
- ${h}`;throw new Error(f)}else if(r.code==="EACCES")throw new Error(`'${l}' not executable`);if(!u)te.exit(1);else{let h=new Gn(1,"commander.executeSubCommandAsync","(error)");h.nestedError=r,u(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 c=`error: command-argument value '${s}' is invalid for argument '${o.name()}'.`;l=this._callParseArg(o,s,a,c)}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,c)=>e(o,c,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 c=null;for(;a.length;){let p=a.shift();if(p==="--"){s===o&&s.push(p),s.push(...a);break}if(c&&!l(p)){this.emit(`option:${c.name()}`,p);continue}if(c=null,l(p)){let u=this._findOption(p);if(u){if(u.required){let r=a.shift();r===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,r)}else if(u.optional){let r=null;a.length>0&&!l(a[0])&&(r=a.shift()),this.emit(`option:${u.name()}`,r)}else this.emit(`option:${u.name()}`);c=u.variadic?u:null;continue}}if(p.length>2&&p[0]==="-"&&p[1]!=="-"){let u=this._findOption(`-${p[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,p.slice(2)):(this.emit(`option:${u.name()}`),a.unshift(`-${p.slice(2)}`));continue}}if(/^--[^=]+=/.test(p)){let u=p.indexOf("="),r=this._findOption(p.slice(0,u));if(r&&(r.required||r.optional)){this.emit(`option:${r.name()}`,p.slice(u+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 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 te.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()}`,te.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new os(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
|
|
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 te.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()}`,te.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new os(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 c=l.attributeName(),p=this.getOptionValue(c),u=this.options.find(h=>h.negate&&c===h.attributeName()),r=this.options.find(h=>!h.negate&&c===h.attributeName());return u&&(u.presetArg===void 0&&p===!1||u.presetArg!==void 0&&p===u.presetArg)?u:r||l},s=l=>{let c=o(l),p=c.attributeName();return this.getOptionValueSource(p)==="env"?`environment variable '${c.envVar}'`:`option '${c.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(c=>c.long).map(c=>c.long);s=s.concat(l),a=a.parent}while(a&&!a._enablePositionalOptions);t=zi(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=zi(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
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=>is(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=xe.basename(e,xe.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=te.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
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 Qi(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})}Zi.Command=
|
|
24
|
-
`)}N();var gs=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function ms(n,e){if(n!=null){if(typeof n!="string"||!n.trim())throw new Error(`rollout.${e} must be a non-empty label name`);if(/[\r\n]/.test(n))throw new Error(`rollout.${e} must be a single line`);return n.trim()}}function rt(n,e={}){if(n==null)return;if(typeof n!="object"||Array.isArray(n))throw new Error("rollout must be a mapping with authors, opt_in_label and/or skip_label");let t=n,o=new Set(["authors","opt_in_label","skip_label"]);for(let p of Object.keys(t))if(!o.has(p))throw new Error(`rollout: unknown key '${p}' \u2014 expected authors, opt_in_label or skip_label`);let s={};if(t.authors!==void 0&&t.authors!==null){if(!Array.isArray(t.authors))throw new Error("rollout.authors must be a list of GitHub logins");let p=[];for(let u of t.authors){let r=String(u).trim();if(!gs.test(r))throw new Error(`rollout.authors: '${r}' is not a GitHub login`);p.includes(r.toLowerCase())||p.push(r.toLowerCase())}s.authors=p}let a=p=>{let u=ms(t[p],p);return u===void 0?void 0:e[u]??u},l=a("opt_in_label"),d=a("skip_label");if(l!==void 0&&(s.optInLabel=l),d!==void 0&&(s.skipLabel=d),l!==void 0&&l===d)throw new Error(`rollout: opt_in_label and skip_label are the same label ('${l}')`);return s}N();N();var Yn=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","runs_on","opt_in_label","mode","merge","check_name","requires_review","post","post_marker"]),Jn=new Set(["on","when","do"]);function cr(n,e){let t=(a,l)=>{let d=Array.from({length:l.length+1},(p,u)=>u);for(let p=1;p<=a.length;p++){let u=d[0];d[0]=p;for(let r=1;r<=l.length;r++){let h=d[r];d[r]=Math.min(d[r]+1,d[r-1]+1,u+(a[p-1]===l[r-1]?0:1)),u=h}}return d[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 Xn(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 d={name:l,kind:/\.ya?ml$/i.test(l)?"workflow":"check"};for(let p of a.map(u=>u.trim()))if(p==="info")d.info=!0;else if(/^[1-9]\d*$/.test(p)&&d.graceSeconds===void 0)d.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(d)}return t}function dr(n){try{return Xn(n)}catch{return[]}}function on(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 $e(n){try{return on(n)}catch{return[]}}var bs=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function pr(n,e){let t=[];for(let o of n){let s=String(o).trim();if(!s)continue;if(!bs.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 sn(n){return n.type==="pr-fix"||(n.type==="pr-review"||n.type==="analyst")&&we(n)||be(n)}function an(n,e){let t=n.attrs.authors;return t!==void 0?pr(String(t).split(","),`node '${n.id}': authors=`):St(e)}function St(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 pr(e,"repo.authors")}}function Ne(n,e){if(sn(n))try{return an(n,e)}catch{return[vt]}}var vt="no author matches a malformed allowlist";function hr(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, ${_e(e)}))`}function _e(n){return`'${n.replace(/'/g,"''")}'`}function zn(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 Ke(n,e){if(Ne(n,e)!==void 0)try{return zn(n,e)}catch{return}}function Qn(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 be(n){if(n.type!=="merge-gate")return!1;try{return Qn(n)==="evaluate"}catch{return!1}}function Zn(n){let e=n.attrs.merge;if(e!==void 0){if(e==="off"||e==="agent-only")return e;throw new Error(`node '${n.id}': merge= must be "off" or "agent-only", got ${JSON.stringify(e)}`)}}function kt(n){if(!(n.type!=="merge-gate"||n.attrs.merge===void 0))try{return Zn(n)}catch{return"off"}}function ei(n){return be(n)||kt(n)!==void 0}function Fe(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 Ee(n){return n.attrs.select==="sweep"&&n.type==="pr-review"&&we(n)&&n.attrs.schedule!==void 0}function ti(n){return Ee(n)&&n.attrs.requires_review===!0}var fr="<!-- gp-foundry:also-head:[^:\\s]+:";function ln(n){return n.attrs.post==="review"&&(n.type==="pr-review"||n.type==="analyst")&&we(n)}var ni="PR #<n> head <sha>";function un(n){let e=n.attrs.post_marker;if(e===void 0)return ni;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 ve(n,e){return Ye(e)?n.attrs.schedule===void 0&&(dn(n)||je(n)):(n.type==="pr-review"||n.type==="analyst")&&we(n)&&n.attrs.schedule===void 0&&($e(n).length>0||Ne(n,e)!==void 0)}var ws="ubuntu-latest",ys=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function cn(n,e){if(typeof n!="string"||!ys.test(n))throw new Error(`${e} must be one runner label like "ubuntu-latest", got ${JSON.stringify(n)}`);return n}function ii(n,e){for(let[t,o]of[[n?.attrs.runs_on,"runs_on="],[e.runtime?.runs_on,"runtime.runs_on"]])if(t!==void 0)try{return cn(t,o)}catch{}return ws}function Ye(n){return n.rollout!==void 0&&n.rollout!==null}function At(n){if(Ye(n))try{return rt(n.rollout,n.labels)??{}}catch{return{authors:[]}}}function dn(n){return(n.type==="pr-review"||n.type==="analyst")&&we(n)}function je(n){return n.type==="pr-fix"}var rn="github.event.pull_request";function ri(n,e,t){let o=[`${rn}.draft == false`];n.skipLabel&&o.push(`!contains(${rn}.labels.*.name, ${_e(n.skipLabel)})`);let s=a=>`${rn}.user.login == ${_e(a)}`;if(t)o.push(s(e??vt));else if(n.authors!==void 0||n.optInLabel!==void 0){let a=[...e?[s(e)]:[],...(n.authors??[]).map(s)];n.optInLabel&&a.push(`contains(${rn}.labels.*.name, ${_e(n.optInLabel)})`),o.push(a.length===1?a[0]:`(${a.length?a.join(" || "):s(vt)})`)}return o.join(" && ")}function Ie(n){return Ee(n)?`${n.id}_select`:`${n.id}_guard`}function pn(n){return`${n.id} #`}function oi(n){return`gp-foundry/sweep-failed (${n.id})`}function si(n){return`gp-foundry/sweep-idle (${n.id})`}function ai(n){return`gp-foundry/swept (${n.id})`}function hn(n){return`<!-- gp-foundry:diff:${n.id}:`}function gr(n){return`<!-- gp-foundry:also-head:${n.id}:`}var mr="<!-- gp-foundry:posted:",Rt='(((.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 ot(n){try{return Kn(Ve(n.verdicts))}catch{return Kn(Ve(void 0))}}N();function st(n){return`\${{ secrets.${n} }}`}function ye(n,e){if(!e)return"";let t=n.specDir?.replace(/\/+$/,"");return t?`${t}/${e}`:e}function ne(n){let e=Et(n.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?st(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}var _s=new Set(["actions","checks","contents","deployments","issues","packages","pages","pull-requests","security-events","statuses","workflows"]);function Ue(n,e){let t=Et(n.config);if(t.mode!=="app"||!t.appIdSecret||!t.appKeySecret)return;let o={"client-id":st(t.appIdSecret),"private-key":st(t.appKeySecret)};for(let[s,a]of Object.entries(e??{}))_s.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 Je=".gp-foundry/harness";function fn(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 gn(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(r=>!!r).map(r=>o?`${o}/${r}`:r),a=new Set([".github/agent-setup"]);t&&a.add(".github/actions");for(let r of s){let h=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"";h&&a.add(h)}let l=[...a].sort(),d=l.filter(r=>!l.some(h=>h!==r&&r.startsWith(`${h}/`))),p=[{uses:"actions/checkout@v5",name:"Checkout harness files (base ref)",with:{ref:e,path:Je,"fetch-depth":1,"sparse-checkout":d.join(`
|
|
25
|
-
`),token:ne(n),"persist-credentials":!1}},
|
|
26
|
-
echo "/${
|
|
23
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(s=>t.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Qi(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})}Zi.Command=Wn});var rr=Me(fe=>{"use strict";I();var{Argument:tr}=Zt(),{Command:Vn}=er(),{CommanderError:ss,InvalidArgumentError:nr}=Et(),{Help:as}=Dn(),{Option:ir}=qn();fe.program=new Vn;fe.createCommand=n=>new Vn(n);fe.createOption=(n,e)=>new ir(n,e);fe.createArgument=(n,e)=>new tr(n,e);fe.Command=Vn;fe.Option=ir;fe.Argument=tr;fe.Help=as;fe.CommanderError=ss;fe.InvalidArgumentError=nr;fe.InvalidOptionArgumentError=nr});var nn=Me((ll,Kn)=>{"use strict";I();var tn=process||{},ar=tn.argv||[],en=tn.env||{},ls=!(en.NO_COLOR||ar.includes("--no-color"))&&(!!en.FORCE_COLOR||ar.includes("--color")||tn.platform==="win32"||(tn.stdout||{}).isTTY&&en.TERM!=="dumb"||!!en.CI),us=(n,e,t=n)=>o=>{let s=""+o,a=s.indexOf(e,n.length);return~a?n+cs(s,e,t,a)+e:n+s+e},cs=(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)},lr=(n=ls)=>{let e=n?us:()=>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")}};Kn.exports=lr();Kn.exports.createColors=lr});I();I();var or=zt(rr(),1),{program:Xa,createCommand:za,createArgument:Qa,createOption:Za,CommanderError:el,InvalidArgumentError:tl,InvalidOptionArgumentError:nl,Command:sr,Argument:il,Option:rl,Help:ol}=or.default;var K=zt(nn(),1),Mo=require("child_process"),J=require("fs"),re=require("path");I();I();I();var rt=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function ur(n){return n.uses!==void 0}I();function vt(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 ds="**Verdict:**",ps=["APPROVE","REQUEST_CHANGES","ESCALATE"],hs=/^[A-Za-z][A-Za-z0-9_-]*$/;function Ve(n){if(n==null||n===""){let[o,s,a]=ps;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(!hs.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 fs(n){return`${ds} ${n}`}function Yn(n){return[n.approve,n.requestChanges,n.escalate].map(fs).join(`
|
|
24
|
+
`)}I();var gs=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function ms(n,e){if(n!=null){if(typeof n!="string"||!n.trim())throw new Error(`rollout.${e} must be a non-empty label name`);if(/[\r\n]/.test(n))throw new Error(`rollout.${e} must be a single line`);return n.trim()}}function ot(n,e={}){if(n==null)return;if(typeof n!="object"||Array.isArray(n))throw new Error("rollout must be a mapping with authors, opt_in_label and/or skip_label");let t=n,o=new Set(["authors","opt_in_label","skip_label"]);for(let p of Object.keys(t))if(!o.has(p))throw new Error(`rollout: unknown key '${p}' \u2014 expected authors, opt_in_label or skip_label`);let s={};if(t.authors!==void 0&&t.authors!==null){if(!Array.isArray(t.authors))throw new Error("rollout.authors must be a list of GitHub logins");let p=[];for(let u of t.authors){let r=String(u).trim();if(!gs.test(r))throw new Error(`rollout.authors: '${r}' is not a GitHub login`);p.includes(r.toLowerCase())||p.push(r.toLowerCase())}s.authors=p}let a=p=>{let u=ms(t[p],p);return u===void 0?void 0:e[u]??u},l=a("opt_in_label"),c=a("skip_label");if(l!==void 0&&(s.optInLabel=l),c!==void 0&&(s.skipLabel=c),l!==void 0&&l===c)throw new Error(`rollout: opt_in_label and skip_label are the same label ('${l}')`);return s}I();I();var Jn=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","runs_on","opt_in_label","mode","merge","check_name","requires_review","post","post_marker"]),Xn=new Set(["on","when","do"]);function cr(n,e){let t=(a,l)=>{let c=Array.from({length:l.length+1},(p,u)=>u);for(let p=1;p<=a.length;p++){let u=c[0];c[0]=p;for(let r=1;r<=l.length;r++){let h=c[r];c[r]=Math.min(c[r]+1,c[r-1]+1,u+(a[p-1]===l[r-1]?0:1)),u=h}}return c[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 zn(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 c={name:l,kind:/\.ya?ml$/i.test(l)?"workflow":"check"};for(let p of a.map(u=>u.trim()))if(p==="info")c.info=!0;else if(/^[1-9]\d*$/.test(p)&&c.graceSeconds===void 0)c.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(c)}return t}function dr(n){try{return zn(n)}catch{return[]}}function on(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 Ee(n){try{return on(n)}catch{return[]}}var bs=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function pr(n,e){let t=[];for(let o of n){let s=String(o).trim();if(!s)continue;if(!bs.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 sn(n){return n.type==="pr-fix"||(n.type==="pr-review"||n.type==="analyst")&&ye(n)||we(n)}function an(n,e){let t=n.attrs.authors;return t!==void 0?pr(String(t).split(","),`node '${n.id}': authors=`):kt(e)}function kt(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 pr(e,"repo.authors")}}function Ne(n,e){if(sn(n))try{return an(n,e)}catch{return[St]}}var St="no author matches a malformed allowlist";function hr(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, ${be(e)}))`}function be(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 Ke(n,e){if(Ne(n,e)!==void 0)try{return Qn(n,e)}catch{return}}function Zn(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 we(n){if(n.type!=="merge-gate")return!1;try{return Zn(n)==="evaluate"}catch{return!1}}function ei(n){let e=n.attrs.merge;if(e!==void 0){if(e==="off"||e==="agent-only")return e;throw new Error(`node '${n.id}': merge= must be "off" or "agent-only", got ${JSON.stringify(e)}`)}}function Ye(n){if(!(n.type!=="merge-gate"||n.attrs.merge===void 0))try{return ei(n)}catch{return"off"}}function ti(n){return we(n)||Ye(n)!==void 0}function Fe(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 ye(n){return n.context==="pr-diff"||n.context==="pr-review"}function ve(n){return n.attrs.select==="sweep"&&n.type==="pr-review"&&ye(n)&&n.attrs.schedule!==void 0}function ln(n){return ve(n)&&n.attrs.requires_review===!0}var fr="<!-- gp-foundry:also-head:[^:\\s]+:";function un(n){return n.attrs.post==="review"&&(n.type==="pr-review"||n.type==="analyst")&&ye(n)}var ni="PR #<n> head <sha>";function cn(n){let e=n.attrs.post_marker;if(e===void 0)return ni;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 Se(n,e){return Je(e)?n.attrs.schedule===void 0&&(pn(n)||je(n)):(n.type==="pr-review"||n.type==="analyst")&&ye(n)&&n.attrs.schedule===void 0&&(Ee(n).length>0||Ne(n,e)!==void 0)}var ws="ubuntu-latest",ys=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function dn(n,e){if(typeof n!="string"||!ys.test(n))throw new Error(`${e} must be one runner label like "ubuntu-latest", got ${JSON.stringify(n)}`);return n}function ii(n,e){for(let[t,o]of[[n?.attrs.runs_on,"runs_on="],[e.runtime?.runs_on,"runtime.runs_on"]])if(t!==void 0)try{return dn(t,o)}catch{}return ws}function Je(n){return n.rollout!==void 0&&n.rollout!==null}function At(n){if(Je(n))try{return ot(n.rollout,n.labels)??{}}catch{return{authors:[]}}}function pn(n){return(n.type==="pr-review"||n.type==="analyst")&&ye(n)}function je(n){return n.type==="pr-fix"}var rn="github.event.pull_request";function ri(n,e,t){let o=[`${rn}.draft == false`];n.skipLabel&&o.push(`!contains(${rn}.labels.*.name, ${be(n.skipLabel)})`);let s=a=>`${rn}.user.login == ${be(a)}`;if(t)o.push(s(e??St));else if(n.authors!==void 0||n.optInLabel!==void 0){let a=[...e?[s(e)]:[],...(n.authors??[]).map(s)];n.optInLabel&&a.push(`contains(${rn}.labels.*.name, ${be(n.optInLabel)})`),o.push(a.length===1?a[0]:`(${a.length?a.join(" || "):s(St)})`)}return o.join(" && ")}function Ie(n){return ve(n)?`${n.id}_select`:`${n.id}_guard`}function hn(n){return`${n.id} #`}function oi(n){return`gp-foundry/sweep-failed (${n.id})`}function si(n){return`gp-foundry/sweep-idle (${n.id})`}function ai(n){return`gp-foundry/swept (${n.id})`}function fn(n){return`<!-- gp-foundry:diff:${n.id}:`}function gr(n){return`<!-- gp-foundry:also-head:${n.id}:`}var mr="<!-- gp-foundry:posted:",Rt='(((.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 st(n){try{return Yn(Ve(n.verdicts))}catch{return Yn(Ve(void 0))}}I();function at(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=vt(n.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?at(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}var _s=new Set(["actions","checks","contents","deployments","issues","packages","pages","pull-requests","security-events","statuses","workflows"]);function qe(n,e){let t=vt(n.config);if(t.mode!=="app"||!t.appIdSecret||!t.appKeySecret)return;let o={"client-id":at(t.appIdSecret),"private-key":at(t.appKeySecret)};for(let[s,a]of Object.entries(e??{}))_s.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 Xe=".gp-foundry/harness";function gn(n,e=!1){return n.attrs.harness_ref==="head"?!1:e||n.type==="pr-fix"||(n.type==="pr-review"||n.type==="analyst")&&ye(n)}function mn(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(r=>!!r).map(r=>o?`${o}/${r}`:r),a=new Set([".github/agent-setup"]);t&&a.add(".github/actions");for(let r of s){let h=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"";h&&a.add(h)}let l=[...a].sort(),c=l.filter(r=>!l.some(h=>h!==r&&r.startsWith(`${h}/`))),p=[{uses:"actions/checkout@v5",name:"Checkout harness files (base ref)",with:{ref:e,path:Xe,"fetch-depth":1,"sparse-checkout":c.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 "/${Xe.split("/")[0]}/" >> .git/info/exclude`}),ie({name:"Use this PR's harness files if the base ref has no harness yet",env:{HARNESS:Xe,SPEC:o?`${o}/${n.specFile??"harness.dot"}`:n.specFile??"harness.dot",DIRS:c.join(`
|
|
27
27
|
`)},run:['if [ -f "$HARNESS/$SPEC" ]; then exit 0; fi',`echo "::notice::the base ref has no harness yet ($SPEC) \u2014 using this pull request's own harness files. This only happens while the harness itself is being installed."`,"while IFS= read -r D; do",' [ -n "$D" ] && [ -d "$D" ] || continue',' mkdir -p "$HARNESS/$(dirname "$D")"',' rm -rf "${HARNESS:?}/$D"',' cp -R "$D" "$HARNESS/$D"','done <<< "$DIRS"'].join(`
|
|
28
|
-
`)})],u=t?r=>`./${
|
|
29
|
-
git config user.email "$GIT_EMAIL"`})}function
|
|
30
|
-
`));let
|
|
28
|
+
`)})],u=t?r=>`./${Xe}/.github/actions/${r}`:n.actionRef;return{ctx:{...n,specDir:o?`${Xe}/${o}`:Xe,harnessRoot:Xe,actionRef:u},steps:p}}function lt(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 ut(n){return{uses:`${n?.harnessRoot?`./${n.harnessRoot}`:"."}/.github/agent-setup`,name:"Setup agent toolchain"}}function br(n){let e=n.attrs.persist_credentials;return typeof e=="boolean"?e:n.attrs.checkout==="partial"}function li(n){return n===void 0?!0:n.split(",").some(e=>{let t=e.trim();return t==="Bash"||/^Bash\(\s*gh\b/.test(t)})}function wr(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"
|
|
29
|
+
git config user.email "$GIT_EMAIL"`})}function Tt(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 ct(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":at(o.agent.api_key_secret)}:{"claude-code-oauth-token":at(o.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")}};!e.outputContract&&li(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(u=>u.trim()).filter(Boolean):[],l=[...new Set([...o.agent.secrets??[],...a])];l.length&&(s["extra-env"]=l.map(u=>`${u}=${at(u)}`).join(`
|
|
30
|
+
`));let c=t.attrs.agent_attempts;c!==void 0&&(s["max-attempts"]=String(c));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 $s=`set -euo pipefail
|
|
31
31
|
# post="review": the agent printed its review; this step posts it with the lane's
|
|
32
32
|
# token. The agent's output is DATA \u2014 nothing here evaluates it, and it reaches gh
|
|
33
33
|
# only as a JSON file built by jq.
|
|
@@ -175,84 +175,84 @@ fi
|
|
|
175
175
|
echo "::error::could not post the review: $(head -c 500 "$ERR" | tr '\\n\\r' ' ')"
|
|
176
176
|
note "_No review was posted: GitHub rejected it. See the job log._"
|
|
177
177
|
exit 1
|
|
178
|
-
`;function yr(n,e){let t=ni;try{t=
|
|
178
|
+
`;function yr(n,e){let t=ni;try{t=cn(n.node)}catch{}return ie({name:"Post the review",if:"${{ success() }}",env:{GH_TOKEN:ne(n),NODE:n.node.id,POSTED_PREFIX:mr,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:st(n.config)},run:$s.replaceAll("__IS_VERDICT_JQ__",()=>Rt)})}function _r(n,e){let t=st(n.config).split(`
|
|
179
179
|
`);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.`]:[],"The fence is required: a bare object at the very end is accepted as a fallback, but always use the fence.","If the block is missing or is not valid JSON, nothing is posted."].join(`
|
|
180
|
-
`)}function
|
|
181
|
-
`)})}function Ss(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,
|
|
182
|
-
`)})}function As(n){let e=n.node,t=n.config,o=
|
|
183
|
-
`)}));let s
|
|
180
|
+
`)}function bn(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 Er(n,e){let t;try{t=bn(n)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var ze="${{ github.event.issue.number }}",dt="${{ github.event.pull_request.number }}",ci="${{ github.event.pull_request.head.sha }}",$r="${{ github.event.pull_request.head.ref }}",di="${{ github.event.pull_request.base.ref }}";function pi(n,e){try{return{...e,...bn(n)}}catch{return e}}function $e(n,e){let t=n.attrs.timeout;return typeof t=="number"?t:e}var Es=10;function wn(n){return Math.max(1,n-Es)}function yn(n,e,t){let o=[],s=qe(n,t&&pi(n.node,t));return s&&o.push(s),o.push(lt(n,e)),o.push(wr(n)),o}function ui(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=ve(t),c=!l&&Se(t,e.config),p=Ie(t),u=l?"${{ matrix.pr.number }}":dt,r=l?"${{ matrix.pr.sha }}":ci,h=[],f=qe(e,pi(t,a));f&&h.push(f);let m=br(t);if(h.push(lt(e,s?{ref:r,fetchDepth:0,persistCredentials:m}:{persistCredentials:m})),s&&gn(t)){let U=mn(e,l?"${{ matrix.pr.base }}":di);h.push(...U.steps),e=U.ctx}let $=s?dr(t):[],w=$.map(U=>U.name),y=w.map((U,X)=>Ss(`gate-${U}`,X,w));$.forEach((U,X)=>{h.push({uses:e.actionRef("wait-for-checks"),id:y[X],name:`Wait for ${U.name}`,with:{sha:r,...U.kind==="workflow"?{"workflow-name":U.name,token:ne(e)}:{"check-name":U.name,token:"${{ github.token }}"},...U.graceSeconds!==void 0?{"missing-grace-seconds":U.graceSeconds}:{}}})}),h.push(ut(e));let C=o==="pr-diff"?"pr-diff":o==="pr-review"?"pr-review":"issue";h.push(Tt(e,C,s?u:ze,{framing:"baseline",checks:s})),$.length&&h.push(ks($,y));let P=$e(t,w.length?15+15*w.length:25),F=un(t),j=ct(e,{withContext:!0,...F?{outputContract:_r(e,l)}:{}});h.push(w.length?j:{...j,timeoutMinutes:wn(P)}),F&&h.push(yr(e,{prNumber:u,headSha:r,verdictLane:l}));let q={jobId:t.id,name:t.id,permissions:a,timeoutMinutes:P,steps:h};return l?(q.needs=[p],q.displayName=`${hn(t)}\${{ matrix.pr.number }}`,q.if=`needs.${p}.outputs.count != '0'`,q.strategy={"fail-fast":!1,matrix:{pr:`\${{ fromJSON(needs.${p}.outputs.prs) }}`}}):c&&(q.needs=[p],q.if=`needs.${p}.outputs.run == 'true'`,Ee(t).some(U=>U.kind==="unchanged-diff")&&h.push(vs(e,p))),q}function vs(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:dt,HEAD_SHA:`\${{ needs.${e}.outputs.head_sha }}`,DIFF_HASH:`\${{ needs.${e}.outputs.diff_hash }}`,BOT_LOGIN:n.config.identity?.bot_login??"",MARKER_PREFIX:fn(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(`
|
|
181
|
+
`)})}function Ss(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,c)=>c!==e&&o(`gate-${l}`)===s).length>0?`${s}-${e+1}`:s}function ks(n,e){let t={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},o=["{",' echo ""',' echo "=== CI GATES ==="'],s=c=>` echo "$GATE_${c+1}_NAME: $GATE_${c+1}_RESULT"`;n.forEach((c,p)=>{t[`GATE_${p+1}_NAME`]=c.name,t[`GATE_${p+1}_RESULT`]=`\${{ steps.${e[p]}.outputs.conclusion }}`});let a=n.map((c,p)=>({g:c,i:p})).filter(({g:c})=>!c.info),l=n.map((c,p)=>({g:c,i:p})).filter(({g:c})=>c.info);return a.length&&(a.forEach(({i:c})=>o.push(s(c))),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:c})=>o.push(s(c))),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(`
|
|
182
|
+
`)})}function As(n){let e=n.node,t=n.config,o=yn(n,void 0,{contents:"write","pull-requests":"write",issues:"write"});o.push(ie({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:ze,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(`
|
|
183
|
+
`)}));let s=$e(e,35);return o.push(ut(n)),o.push(Tt(n,"issue",ze)),o.push({...ct(n,{withContext:!0}),timeoutMinutes:wn(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":ze,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
|
|
184
184
|
|
|
185
185
|
The agent finished but didn't open a PR itself, so one was created automatically. See the commits and the linked issue for context.
|
|
186
186
|
|
|
187
|
-
Closes #${
|
|
188
|
-
`)}));let p="steps.attempts.outputs.exhausted != 'true'";return o.push({...
|
|
189
|
-
`)})),{jobId:t.id,name:t.id,permissions:{contents:"write","pull-requests":"write",checks:"read"},timeoutMinutes
|
|
190
|
-
`)})]}}function
|
|
191
|
-
`)})),o.push(
|
|
192
|
-
`)})),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":
|
|
187
|
+
Closes #${ze}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:s,steps:o}}function Rs(n){let e=n,t=e.node,o=yn(e,{ref:$r,fetchDepth:0},{contents:"write","pull-requests":"write",checks:"read"});if(gn(t)){let u=mn(e,di);o.push(...u.steps),e=u.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",c=e.config.identity?.bot_login??"";o.push(ie({id:"attempts",name:`Enforce attempt budget (max ${s})`,env:{GH_TOKEN:ne(e),PR:dt,MARKER:a,MAX:String(s),BOT_LOGIN:c},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(`
|
|
188
|
+
`)}));let p="steps.attempts.outputs.exhausted != 'true'";return o.push({...ut(e),if:p}),o.push({...Tt(e,"pr-review",dt,{framing:"work-item",checks:!0}),if:p}),o.push({...ct(e,{withContext:!0}),if:p,timeoutMinutes:wn($e(t,35))}),o.push(ie({name:"Commit and push fixes",if:`${p} && !cancelled()`,env:{BRANCH:$r},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(`
|
|
189
|
+
`)})),{jobId:t.id,name:t.id,permissions:{contents:"write","pull-requests":"write",checks:"read"},timeoutMinutes:$e(t,35),steps:o,...Se(t,e.config)?{needs:[Ie(t)],if:`needs.${Ie(t)}.outputs.run == 'true'`}:{}}}function vr(n){return`gp-foundry/human-approval (${String(n.attrs.environment??"production")})`}var Ts="github-actions";function Os(n){return`${vr(n)}@${Ts}`}function pt(n){if(n.config.verdicts!==void 0)try{let e=Ve(n.config.verdicts);return[e.approve,e.requestChanges,e.escalate].join(",")}catch{return}}function Cs(n){let e=n.node,o=n.inEdges.map(l=>n.nodeById?.(l.from)).filter(l=>!!l&&l.type==="human-gate").map(Os),s=Ye(e);if(s)return Ns(n,s,o);if(we(e))return Is(n,o);let a=yn(n,{fetchDepth:0});return a.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}:{},...pt(n)?{verdicts:pt(n)}:{},...o.length?{"required-checks":o.join(",")}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write",checks:"read"},timeoutMinutes:$e(e,10),steps:a}}function xs(n){let e=n.trim().split(/\s+/);if(e.length!==5)return 300;let[t,o,s,a,l]=e,c=[s,a,l].every(u=>u==="*"),p=/^\*\/(\d+)$/;return c&&o==="*"&&p.test(t)?Number(p.exec(t)[1])*60:c&&o==="*"&&/^\d+$/.test(t)?3600:c&&/^\d+$/.test(t)&&p.test(o)?Number(p.exec(o)[1])*3600:c&&/^\d+$/.test(t)&&/^\d+$/.test(o)?86400:300}function Ns(n,e,t){let o=n.node,s=e==="agent-only",a;try{a=Fe(o)}catch{a=`gp-foundry/approval (${o.id})`}let l;try{let r=ot(n.config.rollout,n.config.labels);l=r&&Object.keys(r).length?JSON.stringify(r):void 0}catch{l=JSON.stringify({authors:[]})}let c=[],p=qe(n,s?void 0:{contents:"read","pull-requests":"read",checks:"write"});p&&c.push(p);let u=lt(n,{persistCredentials:!1});return u.with={...u.with,token:"${{ github.token }}"},c.push(u),c.push({uses:n.actionRef("merge-gate"),name:s?"Evaluate merge gate (publish check, merge agent-written PRs)":"Evaluate merge gate (publish check, never merge)",with:{merge:e,"check-name":a,token:s||p?ne(n):"${{ github.token }}","checks-token":p?ne(n):"${{ github.token }}",...p?{"check-app":"${{ steps.app-token.outputs.app-slug }}"}:{},"policy-path":_e(n,o.files.policy),"base-branch":n.config.repo.base_branch,...n.config.identity?.bot_login?{"bot-login":n.config.identity.bot_login}:{},...pt(n)?{verdicts:pt(n)}:{},...t.length?{"required-checks":t.join(",")}:{},...l?{rollout:l}:{},"pr-number":"${{ github.event.pull_request.number }}","rotation-period-seconds":String(xs(String(o.attrs.schedule??""))),"time-budget-seconds":String(Math.max(60,($e(o,10)-2)*60))}}),{jobId:o.id,name:o.id,permissions:p?{contents:"read"}:s?{contents:"write","pull-requests":"write",issues:"write",checks:"write"}:{contents:"read","pull-requests":"read",checks:"write"},timeoutMinutes:$e(o,10),steps:c}}function Is(n,e){let t=n.node,o=lt(n,{persistCredentials:!1});o.with={...o.with,token:"${{ github.token }}"};let s;try{s=Fe(t)}catch{s=`gp-foundry/approval (${t.id})`}let a=Ne(t,n.config),l=Ke(t,n.config),c=Ee(t),p=c.flatMap(r=>r.kind==="label"?[n.config.labels?.[r.label]??r.label]:[]),u=c.some(r=>r.kind==="bot-author");return{jobId:t.id,name:t.id,permissions:{contents:"read","pull-requests":"read",checks:"write"},timeoutMinutes:$e(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}:{},...pt(n)?{verdicts:pt(n)}:{},...e.length?{"required-checks":e.join(",")}:{},...a?{authors:a.join(",")}:{},...a&&l?{"opt-in-label":l}:{},...p.length?{"skip-labels":p.join(",")}:{},...u?{"skip-bot-authors":"true"}:{}}}]}}function Hs(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:vr(e),HEAD_SHA:ci,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(`
|
|
190
|
+
`)})]}}function Ps(n){let e=n.node,t=n.config,o=yn(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(`
|
|
191
|
+
`)})),o.push(ut(n)),o.push({...ct(n,{withContext:!1}),id:"agent",timeoutMinutes:wn($e(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(`
|
|
192
|
+
`)})),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:$e(e,20),steps:o}}function Sr(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=[],c=qe(o,pi(s,a));if(c&&l.push(c),l.push(lt(o,t?{ref:ci,fetchDepth:0,persistCredentials:!1}:{persistCredentials:!1})),gn(s,t)){let u=mn(o,di);l.push(...u.steps),o=u.ctx}l.push(ut(o)),l.push(Tt(o,t?"pr-review":"issue",t?dt:ze,{framing:"baseline",checks:t})),s.files.role&&l.push(ct(o,{withContext:!0}));let p=s.attrs.on_complete_label;if(typeof p=="string"&&p){let u=o.config.labels?.[p]??p;l.push(ie({name:"Apply completion label",env:{GH_TOKEN:ne(o),NUM:t?dt:ze},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${u}'`}))}return Er(s,{jobId:s.id,name:s.id,needs:e,permissions:a,timeoutMinutes:$e(s,15),steps:l})}var Ls={analyst:ui,"issue-agent":ui,"pr-review":ui,producer:As,"pr-fix":Rs,"merge-gate":Cs,"human-gate":Hs,"scheduled-agent":Ps,start:()=>null,exit:()=>null};function hi(n,e,t){let o=Ls[n.type];if(!o)return null;let s=o(t);return s&&Er(n,s)}I();var kr=require("fs"),Ar=require("url"),fi;function Ds(){if(fi===void 0){let n=(0,Ar.fileURLToPath)(new URL("../../package.json",B));fi=JSON.parse((0,kr.readFileSync)(n,"utf8")).version}return fi}function Ot(){return`v${Ds()}`}var gi="v1";I();var Ms=new Set(rt);function Qe(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 c=t.get(l.id)??[];if(c.length<2)continue;let p=[],u,r=!0;for(let $ of c){let w=e.get($.from);if(!w||!Ms.has(w.type)){r=!1;break}let y=t.get(w.id)??[],C=o.get(w.id)??[];if(y.length!==1||C.length!==1||C[0].to!==l.id){r=!1;break}let P=e.get(y[0].from);if(!P||P.type!=="parallel"){r=!1;break}if(y[0].on||y[0].when){r=!1;break}if(u===void 0)u=P.id;else if(u!==P.id){r=!1;break}p.push(w.id)}if(!r||u===void 0)continue;let h=t.get(u)??[],f=o.get(u)??[];if(h.length!==1||!h[0].on)continue;let m=new Set(p);if(!(!f.every($=>m.has($.to))||f.length!==p.length)){s.set(l.id,{parallelId:u,entryEdge:h[0],legIds:p,faninId:l.id}),a.add(u);for(let $ of p)a.add($)}}return{byFanin:s,memberIds:a}}I();I();function Fs(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var le={},_n={},Ue={},Rr;function Ct(){if(Rr)return Ue;Rr=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,c){if(c){let p=Object.keys(c);for(let u=0,r=p.length;u<r;u+=1){let h=p[u];l[h]=c[h]}}return l}function s(l,c){let p="";for(let u=0;u<c;u+=1)p+=l;return p}function a(l){return l===0&&Number.NEGATIVE_INFINITY===1/l}return Ue.isNothing=n,Ue.isObject=e,Ue.toArray=t,Ue.repeat=s,Ue.isNegativeZero=a,Ue.extend=o,Ue}var mi,Tr;function xt(){if(Tr)return mi;Tr=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+=`
|
|
193
193
|
|
|
194
|
-
`+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)},mi=e,mi}var bi,
|
|
195
|
-
`+h}let $=e(s.buffer,
|
|
194
|
+
`+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)},mi=e,mi}var bi,Or;function js(){if(Or)return bi;Or=1;let n=Ct();function e(s,a,l,c,p){let u="",r="",h=Math.floor(p/2)-1;return c-a>h&&(u=" ... ",a=c-h+u.length),l-c>h&&(r=" ...",l=c+h-r.length),{str:u+s.slice(a,l).replace(/\t/g,"\u2192")+r,pos:c-a+u.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,c=[0],p=[],u,r=-1;for(;u=l.exec(s.buffer);)p.push(u.index),c.push(u.index+u[0].length),s.position<=u.index&&r<0&&(r=c.length-2);r<0&&(r=c.length-1);let h="",f=Math.min(s.line+a.linesAfter,p.length).toString().length,m=a.maxLength-(a.indent+f+3);for(let w=1;w<=a.linesBefore&&!(r-w<0);w++){let y=e(s.buffer,c[r-w],p[r-w],s.position-(c[r]-c[r-w]),m);h=n.repeat(" ",a.indent)+t((s.line-w+1).toString(),f)+" | "+y.str+`
|
|
195
|
+
`+h}let $=e(s.buffer,c[r],p[r],s.position,m);h+=n.repeat(" ",a.indent)+t((s.line+1).toString(),f)+" | "+$.str+`
|
|
196
196
|
`,h+=n.repeat("-",a.indent+f+3+$.pos)+`^
|
|
197
|
-
`;for(let w=1;w<=a.linesAfter&&!(r+w>=p.length);w++){let y=e(s.buffer,
|
|
198
|
-
`}return h.replace(/\n$/,"")}return bi=o,bi}var wi,Cr;function
|
|
199
|
-
\r`;function t(l){if(l===null)return!1;let
|
|
200
|
-
`;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 pe(i){return i<=65535?String.fromCharCode(i):String.fromCharCode((i-65536>>10)+55296,(i-65536&1023)+56320)}function
|
|
201
|
-
`,g-1))}function
|
|
197
|
+
`;for(let w=1;w<=a.linesAfter&&!(r+w>=p.length);w++){let y=e(s.buffer,c[r+w],p[r+w],s.position-(c[r]-c[r+w]),m);h+=n.repeat(" ",a.indent)+t((s.line+w+1).toString(),f)+" | "+y.str+`
|
|
198
|
+
`}return h.replace(/\n$/,"")}return bi=o,bi}var wi,Cr;function ce(){if(Cr)return wi;Cr=1;let n=xt(),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(c){a[c].forEach(function(p){l[String(p)]=c})}),l}function s(a,l){if(l=l||{},Object.keys(l).forEach(function(c){if(e.indexOf(c)===-1)throw new n('Unknown option "'+c+'" 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(c){return c},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 wi=s,wi}var yi,xr;function Qr(){if(xr)return yi;xr=1;let n=xt(),e=ce();function t(a,l){let c=[];return a[l].forEach(function(p){let u=c.length;c.forEach(function(r,h){r.tag===p.tag&&r.kind===p.kind&&r.multi===p.multi&&(u=h)}),c[u]=p}),c}function o(){let a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function l(c){c.multi?(a.multi[c.kind].push(c),a.multi.fallback.push(c)):a[c.kind][c.tag]=a.fallback[c.tag]=c}for(let c=0,p=arguments.length;c<p;c+=1)arguments[c].forEach(l);return a}function s(a){return this.extend(a)}return s.prototype.extend=function(l){let c=[],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&&(c=c.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: [...] })");c.forEach(function(r){if(!(r instanceof e))throw new n("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(r.loadKind&&r.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(r.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(r){if(!(r instanceof e))throw new n("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let u=Object.create(s.prototype);return u.implicit=(this.implicit||[]).concat(c),u.explicit=(this.explicit||[]).concat(p),u.compiledImplicit=t(u,"implicit"),u.compiledExplicit=t(u,"explicit"),u.compiledTypeMap=o(u.compiledImplicit,u.compiledExplicit),u},yi=s,yi}var _i,Nr;function Zr(){if(Nr)return _i;Nr=1;let n=ce();return _i=new n("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),_i}var $i,Ir;function eo(){if(Ir)return $i;Ir=1;let n=ce();return $i=new n("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),$i}var Ei,Hr;function to(){if(Hr)return Ei;Hr=1;let n=ce();return Ei=new n("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Ei}var vi,Pr;function no(){if(Pr)return vi;Pr=1;let n=Qr();return vi=new n({explicit:[Zr(),eo(),to()]}),vi}var Si,Lr;function io(){if(Lr)return Si;Lr=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 Si=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"}),Si}var ki,Dr;function ro(){if(Dr)return ki;Dr=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 ki=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"}),ki}var Ai,Mr;function oo(){if(Mr)return Ai;Mr=1;let n=Ct(),e=ce();function t(u){return u>=48&&u<=57||u>=65&&u<=70||u>=97&&u<=102}function o(u){return u>=48&&u<=55}function s(u){return u>=48&&u<=57}function a(u){if(u===null)return!1;let r=u.length,h=0,f=!1;if(!r)return!1;let m=u[h];if((m==="-"||m==="+")&&(m=u[++h]),m==="0"){if(h+1===r)return!0;if(m=u[++h],m==="b"){for(h++;h<r;h++){if(m=u[h],m!=="0"&&m!=="1")return!1;f=!0}return f&&isFinite(l(u))}if(m==="x"){for(h++;h<r;h++){if(!t(u.charCodeAt(h)))return!1;f=!0}return f&&isFinite(l(u))}if(m==="o"){for(h++;h<r;h++){if(!o(u.charCodeAt(h)))return!1;f=!0}return f&&isFinite(l(u))}}for(;h<r;h++){if(!s(u.charCodeAt(h)))return!1;f=!0}return f?isFinite(l(u)):!1}function l(u){let r=u,h=1,f=r[0];if((f==="-"||f==="+")&&(f==="-"&&(h=-1),r=r.slice(1),f=r[0]),r==="0")return 0;if(f==="0"){if(r[1]==="b")return h*parseInt(r.slice(2),2);if(r[1]==="x")return h*parseInt(r.slice(2),16);if(r[1]==="o")return h*parseInt(r.slice(2),8)}return h*parseInt(r,10)}function c(u){return l(u)}function p(u){return Object.prototype.toString.call(u)==="[object Number]"&&u%1===0&&!n.isNegativeZero(u)}return Ai=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:a,construct:c,predicate:p,represent:{binary:function(u){return u>=0?"0b"+u.toString(2):"-0b"+u.toString(2).slice(1)},octal:function(u){return u>=0?"0o"+u.toString(8):"-0o"+u.toString(8).slice(1)},decimal:function(u){return u.toString(10)},hexadecimal:function(u){return u>=0?"0x"+u.toString(16).toUpperCase():"-0x"+u.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Ai}var Ri,Fr;function so(){if(Fr)return Ri;Fr=1;let n=Ct(),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(u){return u===null||!t.test(u)?!1:isFinite(parseFloat(u,10))?!0:o.test(u)}function a(u){let r=u.toLowerCase(),h=r[0]==="-"?-1:1;return"+-".indexOf(r[0])>=0&&(r=r.slice(1)),r===".inf"?h===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:r===".nan"?NaN:h*parseFloat(r,10)}let l=/^[-+]?[0-9]+e/;function c(u,r){if(isNaN(u))switch(r){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===u)switch(r){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===u)switch(r){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(n.isNegativeZero(u))return"-0.0";let h=u.toString(10);return l.test(h)?h.replace("e",".e"):h}function p(u){return Object.prototype.toString.call(u)==="[object Number]"&&(u%1!==0||n.isNegativeZero(u))}return Ri=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:p,represent:c,defaultStyle:"lowercase"}),Ri}var Ti,jr;function ao(){return jr||(jr=1,Ti=no().extend({implicit:[io(),ro(),oo(),so()]})),Ti}var Oi,qr;function lo(){return qr||(qr=1,Oi=ao()),Oi}var Ci,Ur;function uo(){if(Ur)return Ci;Ur=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 c=0,p=null,u=e.exec(l);if(u===null&&(u=t.exec(l)),u===null)throw new Error("Date resolve error");let r=+u[1],h=+u[2]-1,f=+u[3];if(!u[4])return new Date(Date.UTC(r,h,f));let m=+u[4],$=+u[5],w=+u[6];if(u[7]){for(c=u[7].slice(0,3);c.length<3;)c+="0";c=+c}if(u[9]){let C=+u[10],P=+(u[11]||0);p=(C*60+P)*6e4,u[9]==="-"&&(p=-p)}let y=new Date(Date.UTC(r,h,f,m,$,w,c));return p&&y.setTime(y.getTime()-p),y}function a(l){return l.toISOString()}return Ci=new n("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:o,construct:s,instanceOf:Date,represent:a}),Ci}var xi,Br;function co(){if(Br)return xi;Br=1;let n=ce();function e(t){return t==="<<"||t===null}return xi=new n("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),xi}var Ni,Gr;function po(){if(Gr)return Ni;Gr=1;let n=ce(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
199
|
+
\r`;function t(l){if(l===null)return!1;let c=0,p=l.length,u=e;for(let r=0;r<p;r++){let h=u.indexOf(l.charAt(r));if(!(h>64)){if(h<0)return!1;c+=6}}return c%8===0}function o(l){let c=l.replace(/[\r\n=]/g,""),p=c.length,u=e,r=0,h=[];for(let m=0;m<p;m++)m%4===0&&m&&(h.push(r>>16&255),h.push(r>>8&255),h.push(r&255)),r=r<<6|u.indexOf(c.charAt(m));let f=p%4*6;return f===0?(h.push(r>>16&255),h.push(r>>8&255),h.push(r&255)):f===18?(h.push(r>>10&255),h.push(r>>2&255)):f===12&&h.push(r>>4&255),new Uint8Array(h)}function s(l){let c="",p=0,u=l.length,r=e;for(let f=0;f<u;f++)f%3===0&&f&&(c+=r[p>>18&63],c+=r[p>>12&63],c+=r[p>>6&63],c+=r[p&63]),p=(p<<8)+l[f];let h=u%3;return h===0?(c+=r[p>>18&63],c+=r[p>>12&63],c+=r[p>>6&63],c+=r[p&63]):h===2?(c+=r[p>>10&63],c+=r[p>>4&63],c+=r[p<<2&63],c+=r[64]):h===1&&(c+=r[p>>2&63],c+=r[p<<4&63],c+=r[64],c+=r[64]),c}function a(l){return Object.prototype.toString.call(l)==="[object Uint8Array]"}return Ni=new n("tag:yaml.org,2002:binary",{kind:"scalar",resolve:t,construct:o,predicate:a,represent:s}),Ni}var Ii,Wr;function ho(){if(Wr)return Ii;Wr=1;let n=ce(),e=Object.prototype.hasOwnProperty,t=Object.prototype.toString;function o(a){if(a===null)return!0;let l=[],c=a;for(let p=0,u=c.length;p<u;p+=1){let r=c[p],h=!1;if(t.call(r)!=="[object Object]")return!1;let f;for(f in r)if(e.call(r,f))if(!h)h=!0;else return!1;if(!h)return!1;if(l.indexOf(f)===-1)l.push(f);else return!1}return!0}function s(a){return a!==null?a:[]}return Ii=new n("tag:yaml.org,2002:omap",{kind:"sequence",resolve:o,construct:s}),Ii}var Hi,Vr;function fo(){if(Vr)return Hi;Vr=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 c=0,p=a.length;c<p;c+=1){let u=a[c];if(e.call(u)!=="[object Object]")return!1;let r=Object.keys(u);if(r.length!==1)return!1;l[c]=[r[0],u[r[0]]]}return!0}function o(s){if(s===null)return[];let a=s,l=new Array(a.length);for(let c=0,p=a.length;c<p;c+=1){let u=a[c],r=Object.keys(u);l[c]=[r[0],u[r[0]]]}return l}return Hi=new n("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:t,construct:o}),Hi}var Pi,Kr;function go(){if(Kr)return Pi;Kr=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 Pi=new n("tag:yaml.org,2002:set",{kind:"mapping",resolve:t,construct:o}),Pi}var Li,Yr;function Mi(){return Yr||(Yr=1,Li=lo().extend({implicit:[uo(),co()],explicit:[po(),ho(),fo(),go()]})),Li}var Jr;function qs(){if(Jr)return _n;Jr=1;let n=Ct(),e=xt(),t=js(),o=Mi(),s=Object.prototype.hasOwnProperty,a=1,l=2,c=3,p=4,u=1,r=2,h=3,f=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,m=/[\x85\u2028\u2029]/,$=/[,\[\]{}]/,w=/^(?:!|!!|![0-9A-Za-z-]+!)$/,y=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function C(i){return Object.prototype.toString.call(i)}function P(i){return i===10||i===13}function F(i){return i===9||i===32}function j(i){return i===9||i===32||i===10||i===13}function q(i){return i===44||i===91||i===93||i===123||i===125}function U(i){if(i>=48&&i<=57)return i-48;let g=i|32;return g>=97&&g<=102?g-97+10:-1}function X(i){return i===120?2:i===117?4:i===85?8:0}function de(i){return i>=48&&i<=57?i-48:-1}function oe(i){switch(i){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
|
|
200
|
+
`;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 pe(i){return i<=65535?String.fromCharCode(i):String.fromCharCode((i-65536>>10)+55296,(i-65536&1023)+56320)}function ue(i,g,E){g==="__proto__"?Object.defineProperty(i,g,{configurable:!0,enumerable:!0,writable:!0,value:E}):i[g]=E}let M=new Array(256),ae=new Array(256);for(let i=0;i<256;i++)M[i]=oe(i)?1:0,ae[i]=oe(i);function Z(i,g){this.input=i,this.filename=g.filename||null,this.schema=g.schema||o,this.onWarning=g.onWarning||null,this.legacy=g.legacy||!1,this.json=g.json||!1,this.listener=g.listener||null,this.maxDepth=typeof g.maxDepth=="number"?g.maxDepth:100,this.maxTotalMergeKeys=typeof g.maxTotalMergeKeys=="number"?g.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 se(i,g){let E={name:i.filename,buffer:i.input.slice(0,-1),position:i.position,line:i.line,column:i.position-i.lineStart};return E.snippet=t(E),new e(g,E)}function N(i,g){throw se(i,g)}function et(i,g){i.onWarning&&i.onWarning.call(null,se(i,g))}function Ae(i,g,E){let k=i.anchorMapTransactions;if(k.length!==0){let _=k[k.length-1];s.call(_,g)||(_[g]={existed:s.call(i.anchorMap,g),value:i.anchorMap[g]})}i.anchorMap[g]=E}function An(i){i.anchorMapTransactions.push(Object.create(null))}function We(i){let g=i.anchorMapTransactions.pop(),E=i.anchorMapTransactions;if(E.length===0)return;let k=E[E.length-1],_=Object.keys(g);for(let O=0,d=_.length;O<d;O+=1){let b=_[O];s.call(k,b)||(k[b]=g[b])}}function Rn(i){let g=i.anchorMapTransactions.pop(),E=Object.keys(g);for(let k=E.length-1;k>=0;k-=1){let _=g[E[k]];_.existed?i.anchorMap[E[k]]=_.value:delete i.anchorMap[E[k]]}}function wt(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 tt(i,g){i.position=g.position,i.line=g.line,i.lineStart=g.lineStart,i.lineIndent=g.lineIndent,i.firstTabInLine=g.firstTabInLine,i.tag=g.tag,i.anchor=g.anchor,i.kind=g.kind,i.result=g.result}let qt={YAML:function(g,E,k){g.version!==null&&N(g,"duplication of %YAML directive"),k.length!==1&&N(g,"YAML directive accepts exactly one argument");let _=/^([0-9]+)\.([0-9]+)$/.exec(k[0]);_===null&&N(g,"ill-formed argument of the YAML directive");let O=parseInt(_[1],10),d=parseInt(_[2],10);O!==1&&N(g,"unacceptable YAML version of the document"),g.version=k[0],g.checkLineBreaks=d<2,d!==1&&d!==2&&et(g,"unsupported YAML version of the document")},TAG:function(g,E,k){let _;k.length!==2&&N(g,"TAG directive accepts exactly two arguments");let O=k[0];_=k[1],w.test(O)||N(g,"ill-formed tag handle (first argument) of the TAG directive"),s.call(g.tagMap,O)&&N(g,'there is a previously declared suffix for "'+O+'" tag handle'),y.test(_)||N(g,"ill-formed tag prefix (second argument) of the TAG directive");try{_=decodeURIComponent(_)}catch{N(g,"tag prefix is malformed: "+_)}g.tagMap[O]=_}};function he(i,g,E,k){if(g<E){let _=i.input.slice(g,E);if(k)for(let O=0,d=_.length;O<d;O+=1){let b=_.charCodeAt(O);b===9||b>=32&&b<=1114111||N(i,"expected valid JSON character")}else f.test(_)&&N(i,"the stream contains non-printable characters");i.result+=_}}function De(i,g,E,k){n.isObject(E)||N(i,"cannot merge mappings; the provided source object is unacceptable");let _=Object.keys(E);for(let O=0,d=_.length;O<d;O+=1){let b=_[O];i.maxTotalMergeKeys!==-1&&++i.totalMergeKeys>i.maxTotalMergeKeys&&N(i,"merge keys exceeded maxTotalMergeKeys ("+i.maxTotalMergeKeys+")"),s.call(g,b)||(ue(g,b,E[b]),k[b]=!0)}}function Re(i,g,E,k,_,O,d,b,R){if(Array.isArray(_)){_=Array.prototype.slice.call(_);for(let v=0,S=_.length;v<S;v+=1)Array.isArray(_[v])&&N(i,"nested arrays are not supported inside keys"),typeof _=="object"&&C(_[v])==="[object Object]"&&(_[v]="[object Object]")}if(typeof _=="object"&&C(_)==="[object Object]"&&(_="[object Object]"),_=String(_),g===null&&(g={}),k==="tag:yaml.org,2002:merge")if(Array.isArray(O))for(let v=0,S=O.length;v<S;v+=1)De(i,g,O[v],E);else De(i,g,O,E);else!i.json&&!s.call(E,_)&&s.call(g,_)&&(i.line=d||i.line,i.lineStart=b||i.lineStart,i.position=R||i.position,N(i,"duplicated mapping key")),ue(g,_,O),delete E[_];return g}function nt(i){let g=i.input.charCodeAt(i.position);g===10?i.position++:g===13?(i.position++,i.input.charCodeAt(i.position)===10&&i.position++):N(i,"a line break is expected"),i.line+=1,i.lineStart=i.position,i.firstTabInLine=-1}function ee(i,g,E){let k=0,_=i.input.charCodeAt(i.position);for(;_!==0;){for(;F(_);)_===9&&i.firstTabInLine===-1&&(i.firstTabInLine=i.position),_=i.input.charCodeAt(++i.position);if(g&&_===35)do _=i.input.charCodeAt(++i.position);while(_!==10&&_!==13&&_!==0);if(P(_))for(nt(i),_=i.input.charCodeAt(i.position),k++,i.lineIndent=0;_===32;)i.lineIndent++,_=i.input.charCodeAt(++i.position);else break}return E!==-1&&k!==0&&i.lineIndent<E&&et(i,"deficient indentation"),k}function it(i){let g=i.position,E=i.input.charCodeAt(g);return!!((E===45||E===46)&&E===i.input.charCodeAt(g+1)&&E===i.input.charCodeAt(g+2)&&(g+=3,E=i.input.charCodeAt(g),E===0||j(E)))}function Te(i,g){g===1?i.result+=" ":g>1&&(i.result+=n.repeat(`
|
|
201
|
+
`,g-1))}function Ut(i,g,E){let k,_,O,d,b,R,v=i.kind,S=i.result,T=i.input.charCodeAt(i.position);if(j(T)||q(T)||T===35||T===38||T===42||T===33||T===124||T===62||T===39||T===34||T===37||T===64||T===96)return!1;if(T===63||T===45){let A=i.input.charCodeAt(i.position+1);if(j(A)||E&&q(A))return!1}for(i.kind="scalar",i.result="",k=_=i.position,O=!1;T!==0;){if(T===58){let A=i.input.charCodeAt(i.position+1);if(j(A)||E&&q(A))break}else if(T===35){let A=i.input.charCodeAt(i.position-1);if(j(A))break}else{if(i.position===i.lineStart&&it(i)||E&&q(T))break;if(P(T))if(d=i.line,b=i.lineStart,R=i.lineIndent,ee(i,!1,-1),i.lineIndent>=g){O=!0,T=i.input.charCodeAt(i.position);continue}else{i.position=_,i.line=d,i.lineStart=b,i.lineIndent=R;break}}O&&(he(i,k,_,!1),Te(i,i.line-d),k=_=i.position,O=!1),F(T)||(_=i.position+1),T=i.input.charCodeAt(++i.position)}return he(i,k,_,!1),i.result?!0:(i.kind=v,i.result=S,!1)}function Bt(i,g){let E,k,_=i.input.charCodeAt(i.position);if(_!==39)return!1;for(i.kind="scalar",i.result="",i.position++,E=k=i.position;(_=i.input.charCodeAt(i.position))!==0;)if(_===39)if(he(i,E,i.position,!0),_=i.input.charCodeAt(++i.position),_===39)E=i.position,i.position++,k=i.position;else return!0;else P(_)?(he(i,E,k,!0),Te(i,ee(i,!1,g)),E=k=i.position):i.position===i.lineStart&&it(i)?N(i,"unexpected end of the document within a single quoted scalar"):(i.position++,F(_)||(k=i.position));N(i,"unexpected end of the stream within a single quoted scalar")}function yt(i,g){let E,k,_,O=i.input.charCodeAt(i.position);if(O!==34)return!1;for(i.kind="scalar",i.result="",i.position++,E=k=i.position;(O=i.input.charCodeAt(i.position))!==0;){if(O===34)return he(i,E,i.position,!0),i.position++,!0;if(O===92){if(he(i,E,i.position,!0),O=i.input.charCodeAt(++i.position),P(O))ee(i,!1,g);else if(O<256&&M[O])i.result+=ae[O],i.position++;else if((_=X(O))>0){let d=_,b=0;for(;d>0;d--)O=i.input.charCodeAt(++i.position),(_=U(O))>=0?b=(b<<4)+_:N(i,"expected hexadecimal character");i.result+=pe(b),i.position++}else N(i,"unknown escape sequence");E=k=i.position}else P(O)?(he(i,E,k,!0),Te(i,ee(i,!1,g)),E=k=i.position):i.position===i.lineStart&&it(i)?N(i,"unexpected end of the document within a double quoted scalar"):(i.position++,F(O)||(k=i.position))}N(i,"unexpected end of the stream within a double quoted scalar")}function Gt(i,g){let E=!0,k,_,O,d=i.tag,b,R=i.anchor,v,S,T,A,H=Object.create(null),x,L,D,G=i.input.charCodeAt(i.position);if(G===91)v=93,A=!1,b=[];else if(G===123)v=125,A=!0,b={};else return!1;for(i.anchor!==null&&Ae(i,i.anchor,b),G=i.input.charCodeAt(++i.position);G!==0;){if(ee(i,!0,g),G=i.input.charCodeAt(i.position),G===v)return i.position++,i.tag=d,i.anchor=R,i.kind=A?"mapping":"sequence",i.result=b,!0;if(E?G===44&&N(i,"expected the node content, but found ','"):N(i,"missed comma between flow collection entries"),L=x=D=null,S=T=!1,G===63){let z=i.input.charCodeAt(i.position+1);j(z)&&(S=T=!0,i.position++,ee(i,!0,g))}k=i.line,_=i.lineStart,O=i.position,Ce(i,g,a,!1,!0),L=i.tag,x=i.result,ee(i,!0,g),G=i.input.charCodeAt(i.position),(T||i.line===k)&&G===58&&(S=!0,G=i.input.charCodeAt(++i.position),ee(i,!0,g),Ce(i,g,a,!1,!0),D=i.result),A?Re(i,b,H,L,x,D,k,_,O):S?b.push(Re(i,null,H,L,x,D,k,_,O)):b.push(x),ee(i,!0,g),G=i.input.charCodeAt(i.position),G===44?(E=!0,G=i.input.charCodeAt(++i.position)):E=!1}N(i,"unexpected end of the stream within a flow collection")}function Wt(i,g){let E,k=u,_=!1,O=!1,d=g,b=0,R=!1,v,S=i.input.charCodeAt(i.position);if(S===124)E=!1;else if(S===62)E=!0;else return!1;for(i.kind="scalar",i.result="";S!==0;)if(S=i.input.charCodeAt(++i.position),S===43||S===45)u===k?k=S===43?h:r:N(i,"repeat of a chomping mode identifier");else if((v=de(S))>=0)v===0?N(i,"bad explicit indentation width of a block scalar; it cannot be less than one"):O?N(i,"repeat of an indentation width identifier"):(d=g+v-1,O=!0);else break;if(F(S)){do S=i.input.charCodeAt(++i.position);while(F(S));if(S===35)do S=i.input.charCodeAt(++i.position);while(!P(S)&&S!==0)}for(;S!==0;){for(nt(i),i.lineIndent=0,S=i.input.charCodeAt(i.position);(!O||i.lineIndent<d)&&S===32;)i.lineIndent++,S=i.input.charCodeAt(++i.position);if(!O&&i.lineIndent>d&&(d=i.lineIndent),P(S)){b++;continue}if(!O&&d===0&&N(i,"missing indentation for block scalar"),i.lineIndent<d){k===h?i.result+=n.repeat(`
|
|
202
202
|
`,_?1+b:b):k===u&&_&&(i.result+=`
|
|
203
|
-
`);break}E?
|
|
203
|
+
`);break}E?F(S)?(R=!0,i.result+=n.repeat(`
|
|
204
204
|
`,_?1+b:b)):R?(R=!1,i.result+=n.repeat(`
|
|
205
205
|
`,b+1)):b===0?_&&(i.result+=" "):i.result+=n.repeat(`
|
|
206
206
|
`,b):i.result+=n.repeat(`
|
|
207
|
-
`,_?1+b:b),_=!0,
|
|
208
|
-
`),i.charCodeAt(0)===65279&&(i=i.slice(1)));let E=new
|
|
209
|
-
`,v);
|
|
210
|
-
`&&(S+=R),S+=A}return S}function
|
|
211
|
-
`+n.repeat(" ",
|
|
212
|
-
`,
|
|
213
|
-
`||
|
|
214
|
-
`)?"+":v?"":"-";return R+
|
|
215
|
-
`}function Yt(
|
|
216
|
-
`?
|
|
217
|
-
`);return
|
|
218
|
-
`||
|
|
219
|
-
`:"")+Ce(x,b),S=
|
|
220
|
-
`+
|
|
221
|
-
`,
|
|
222
|
-
`+
|
|
223
|
-
`:""}return Di.dump=T,Di}var zr;function qs(){if(zr)return ae;zr=1;let n=js(),e=Us();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 ae.Type=le(),ae.Schema=Qr(),ae.FAILSAFE_SCHEMA=no(),ae.JSON_SCHEMA=ao(),ae.CORE_SCHEMA=lo(),ae.DEFAULT_SCHEMA=Mi(),ae.load=n.load,ae.loadAll=n.loadAll,ae.dump=e.dump,ae.YAMLException=xt(),ae.types={binary:po(),float:so(),map:to(),null:io(),pairs:fo(),set:go(),timestamp:uo(),bool:ro(),int:oo(),merge:co(),omap:ho(),seq:eo(),str:Zr()},ae.safeLoad=t("safeLoad","load"),ae.safeLoadAll=t("safeLoadAll","loadAll"),ae.safeDump=t("safeDump","dump"),ae}var Bs=qs(),He=Ms(Bs),{Type:Fl,Schema:jl,FAILSAFE_SCHEMA:Ul,JSON_SCHEMA:ql,CORE_SCHEMA:Bl,DEFAULT_SCHEMA:Gl,load:Wl,loadAll:Vl,dump:Kl,YAMLException:Yl,types:Jl,safeLoad:Xl,safeLoadAll:zl,safeDump:Ql}=He;var Gs=/^---\r?\n([\s\S]*?)\r?\n---/;function pt(n){let e=Gs.exec(n);if(e)try{let t=He.load(e[1]);if(t&&typeof t=="object")return t}catch{return}}var ht=new Set(it);function Nt(n,e={}){let t=[],o=new Map(n.nodes.map(r=>[r.id,r])),s=ze(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,h,f,m)=>{let $=cr(r,h);t.push({level:"error",code:"attr.unknown",message:`unknown attribute '${r}=' on ${f} \u2014 it would be silently ignored`,where:m,hint:$?`did you mean '${$}='?`:"see reference/node-types.md for the attributes this version of gp-foundry understands"})};for(let r of n.nodes)for(let h of Object.keys(r.raw))Yn.has(h)||a(h,Yn,`node '${r.id}'`,{node:r.id,line:r.line});for(let r of n.edges)for(let h of Object.keys(r.raw))Jn.has(h)||a(h,Jn,`edge '${r.from} -> ${r.to}'`,{edge:[r.from,r.to],line:r.line});try{Ve(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{rt(n.config.rollout,n.config.labels)}catch(r){t.push({level:"error",code:"config.bad-rollout",message:r.message,hint:"rollout: { authors: [alice], opt_in_label: agent-review, skip_label: no-agent-review } \u2014 every key optional"})}let l=Ye(n.config);if(l){n.config.repo?.authors!==void 0&&t.push({level:"error",code:"config.authors-and-rollout",message:"repo.authors and rollout are both set \u2014 with a rollout block, scope is rollout.authors",hint:"move the logins to rollout.authors and delete repo.authors"});for(let r of n.nodes){let h={node:r.id,line:r.line};for(let f of["authors","opt_in_label"])r.attrs[f]!==void 0&&r.type!=="merge-gate"&&t.push({level:"error",code:"node.scope-attr-with-rollout",message:`${f}= on '${r.id}' does not apply in a harness with a rollout block \u2014 every lane takes its scope from it`,where:h,hint:"move it to rollout: { authors, opt_in_label, skip_label } in foundry.config.yaml"});if(r.attrs.skip!==void 0&&r.type!=="merge-gate"){let f=[];try{f=on(r)}catch{}let m=f.filter($=>$.kind!=="unchanged-diff").map($=>$.kind==="label"?`label:${$.label}`:$.kind);m.length&&t.push({level:"error",code:"node.scope-attr-with-rollout",message:`skip="${m.join(",")}" on '${r.id}' does not apply in a harness with a rollout block \u2014 drafts and other bots' PRs are always skipped, and the skip label is rollout.skip_label`,where:h,hint:'keep only skip="unchanged-diff" on the node, if it is there'})}je(r)&&!n.config.identity?.bot_login&&t.push({level:"error",code:"node.writing-lane-needs-bot-login",message:`'${r.id}' (type ${r.type}) only pushes to PRs the pipeline wrote, but identity.bot_login is unset \u2014 no PR could be attributed to it`,where:h,hint:"set identity.bot_login in foundry.config.yaml to the login that opens the agent PRs"})}}else for(let r of n.nodes)r.type==="merge-gate"&&r.attrs.merge!==void 0&&t.push({level:"error",code:"node.merge-needs-rollout",message:`merge= on '${r.id}' needs a rollout block in foundry.config.yaml \u2014 it is what puts the gate and every lane on one scope`,where:{node:r.id,line:r.line},hint:"add `rollout: {}` (every PR), or rollout: { authors: [...], opt_in_label: ..., skip_label: ... }"});try{St(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 d=new Map;for(let r of n.nodes){if(!ei(r))continue;let h;try{h=Fe(r)}catch{continue}let f=d.get(h);f?t.push({level:"error",code:"node.duplicate-check-name",message:`merge gates '${f}' and '${r.id}' both publish the check '${h}'`,where:{node:r.id,line:r.line},hint:"give each gate its own check_name="}):d.set(h,r.id)}for(let r of n.nodes){if(r.attrs.authors!==void 0)if(!sn(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{an(r,n.config)}catch(w){t.push({level:"error",code:"node.bad-authors",message:w.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(!sn(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{zn(r,n.config)}catch(y){t.push({level:"error",code:"node.bad-opt-in-label",message:y.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 w;try{w=an(r,n.config)}catch{w=[]}w===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(ht.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{mn(r)}catch(w){t.push({level:"error",code:"node.bad-permissions",message:w.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 w=r.attrs.agent_attempts;(typeof w!="number"||!Number.isInteger(w)||w<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(w)}`,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"}),ht.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 h=r.type!=="start"&&r.type!=="exit"&&r.type!=="parallel",f=r.type==="analyst"||r.type==="issue-agent"||r.type==="pr-review"||r.type==="fan_in",m=r.type==="pr-fix"||(r.type==="pr-review"||r.type==="analyst")&&we(r)||r.type==="fan_in",$=(w,y,C)=>{t.push({level:"error",code:w,message:y,where:{node:r.id,line:r.line},...C?{hint:C}:{}})};if(r.attrs.runs_on!==void 0)try{cn(r.attrs.runs_on,`runs_on= on '${r.id}'`),h||$("node.runs-on-unsupported",`runs_on= on '${r.id}' (type ${r.type}) does not apply \u2014 this node emits no job`)}catch(w){$("node.bad-runs-on",w.message,'one runner label, e.g. runs_on="ubuntu-latest"; the default for every job is runtime.runs_on in foundry.config.yaml')}if(r.attrs.title!==void 0&&(typeof r.attrs.title!="string"||!r.attrs.title.trim()||r.attrs.title.includes("${{")?$("node.bad-title",`title= on '${r.id}' must be a plain, non-empty string, got ${JSON.stringify(r.attrs.title)}`):(!h||s.has(r.id))&&$("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"?$("node.bad-harness-ref",`harness_ref= on '${r.id}' must be "base" or "head", got ${JSON.stringify(r.attrs.harness_ref)}`):m?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"}):$("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"?$("node.bad-persist-credentials",`persist_credentials= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.persist_credentials)}`):f?r.attrs.persist_credentials===!1&&r.attrs.checkout==="partial"&&$("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'):$("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"?$("node.bad-repo-guides",`repo_guides= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.repo_guides)}`):!ht.has(r.type)&&r.type!=="fan_in"&&$("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}}),!ht.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{Xn(r)}catch(w){t.push({level:"error",code:"node.bad-gates",message:w.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 w=[];try{w=on(r)}catch(C){t.push({level:"error",code:"node.bad-skip",message:C.message,where:{node:r.id,line:r.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}let y=(r.type==="pr-review"||r.type==="analyst")&&we(r)&&r.attrs.schedule===void 0&&!s.has(r.id);Ee(r)&&!s.has(r.id)||be(r)?w.some(C=>C.kind==="unchanged-diff")&&t.push({level:"error",code:"node.skip-unsupported",message:`skip="unchanged-diff" on '${r.id}' is not supported on a ${be(r)?"merge gate":"sweep"} \u2014 it compares a push against the last review, and a ${be(r)?"merge gate":"sweep"} reacts to no push`,where:{node:r.id,line:r.line},hint:be(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>"}):y||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'}),w.some(C=>C.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(!ln(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 w=e.roles?.get(r.id)?.tools??(r.files.role&&e.readFile?pt(e.readFile(r.files.role)??"")?.tools:void 0);typeof w=="string"&&li(w)&&t.push({level:"warning",code:"node.post-review-gh-tools",message:`post="review" on '${r.id}': its role still lists gh tools (${w}), 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{un(r)}catch(w){t.push({level:"error",code:"node.bad-post-marker",message:w.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}}):(!Ee(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{Qn(r)}catch(w){t.push({level:"error",code:"node.bad-mode",message:w.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.merge!==void 0)if(r.type!=="merge-gate")$("node.merge-unsupported",`merge= on '${r.id}' is not supported here \u2014 it is the merge-gate's setting ("off" or "agent-only")`);else{let w;try{w=Zn(r)}catch(y){$("node.bad-merge",y.message,`merge="off" publishes the gate's result as a check and never merges; merge="agent-only" also merges the PRs the pipeline wrote`)}r.attrs.mode!==void 0&&$("node.merge-and-mode",`'${r.id}' sets both merge= and mode= \u2014 merge= replaces mode=`,'drop mode=: mode="evaluate" is merge="off"');for(let y of["authors","opt_in_label","skip"])r.attrs[y]!==void 0&&$("node.gate-scope-attr",`${y}= on '${r.id}' does not apply to a gate with merge= \u2014 its scope is the rollout block in foundry.config.yaml`,"move it to rollout: { authors, opt_in_label, skip_label }");w==="agent-only"&&!n.config.identity?.bot_login&&$("node.merge-needs-bot-login",`merge="agent-only" on '${r.id}' merges the PRs the pipeline wrote, but identity.bot_login is unset \u2014 no PR could be attributed to it`,"set identity.bot_login in foundry.config.yaml to the login that opens the agent PRs")}else r.type==="merge-gate"&&r.attrs.mode===void 0&&t.push({level:"info",code:"node.merge-implicit",message:`merge-gate '${r.id}' has no merge= \u2014 it merges every approved PR on a '${n.config.repo.branch_prefix}' branch, as before`,where:{node:r.id,line:r.line},hint:'merge="agent-only" merges only PRs the pipeline wrote and publishes the result as a check; merge="off" publishes the check and never merges'});if(r.attrs.check_name!==void 0)if(!ei(r))t.push({level:"error",code:"node.check-name-without-evaluate",message:`check_name= on '${r.id}' needs a merge-gate that publishes a check \u2014 one with merge= (or the older mode="evaluate")`,where:{node:r.id,line:r.line},hint:'add merge="off" or merge="agent-only" to the merge-gate, or drop check_name='});else try{Fe(r)}catch(w){t.push({level:"error",code:"node.bad-check-name",message:w.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 h of["role","policy","prompt","tools"]){let f=r.files[h];f&&!e.fileExists(f)&&t.push({level:"error",code:"file.missing",message:`node '${r.id}' references ${h}="${f}" which does not exist`,where:{node:r.id,line:r.line,file:f}})}if(e.roles){let r=new Map;for(let f of n.nodes)r.set(f.id,[]);for(let f of n.edges){let m=o.get(f.to);m&&r.get(f.from)?.push({node:m,edge:f})}let h=f=>(e.roles?.get(f.id)?.role??f.id).toLowerCase();for(let f of n.nodes){let m=e.roles.get(f.id);if(!m?.handoffs)continue;let $=r.get(f.id)??[],w=new Set($.flatMap(C=>[C.node.id.toLowerCase(),h(C.node)])),y=new Set(m.handoffs.map(C=>String(C.to).toLowerCase()));for(let C of m.handoffs)w.has(String(C.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${m.role}' (node '${f.id}') declares a handoff to '${C.to}' but there is no matching out-edge`,where:{node:f.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:C,edge:P}of $)C.type==="exit"&&!P.when||!y.has(C.id.toLowerCase())&&!y.has(h(C))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${f.id}' has an out-edge to '${C.id}' not declared as a handoff in role '${m.role}'`,where:{node:f.id,edge:[f.id,C.id]},hint:"document the handoff in the role, or remove the edge"})}}let p=(r,h)=>{if(typeof r=="string"){let f=r.match(/<[A-Za-z][^<>]{0,80}>/);f&&t.push({level:"error",code:"config.placeholder",message:`config value ${h} still contains the placeholder ${f[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((f,m)=>p(f,`${h}[${m}]`));else if(r&&typeof r=="object")for(let[f,m]of Object.entries(r))p(m,h?`${h}.${f}`:f)};if(p(n.config,""),n.config.runtime?.runs_on!==void 0)try{cn(n.config.runtime.runs_on,"runtime.runs_on")}catch(r){t.push({level:"error",code:"config.bad-runs-on",message:r.message,hint:"one runner label; a node's runs_on= overrides it for that lane"})}if((n.config.runtime?.mode??"pinned")==="pinned"&&n.config.runtime?.ref===gi&&t.push({level:"warning",code:"runtime.stale-ref",message:`runtime.ref is '${gi}', a tag that has not moved since 0.1.2 \u2014 the generated workflows would call actions far older than this compiler (${Tt()})`,hint:`delete runtime.ref to pin the actions to this compiler's own release (${Tt()}), or name an exact tag or commit`}),e.fileExists&&(n.config.runtime?.mode??"pinned")==="vendored"){let r=new Set,h=!1;for(let f of n.nodes)ht.has(f.type)&&(h=!0,r.add("run-agent")),ht.has(f.type)&&f.type!=="scheduled-agent"&&r.add("agent-context"),(f.type==="producer"||f.type==="scheduled-agent")&&r.add("agent-fallback"),f.type==="merge-gate"&&r.add("merge-gate"),l&&ve(f,n.config)&&r.add("pr-scope"),f.type==="pr-review"&&f.attrs.gates!==void 0&&r.add("wait-for-checks");for(let f of r)e.fileExists(`actions/${f}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${f}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});h&&!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:h}=ze(n);for(let f of n.nodes)if(f.type==="parallel"&&!h.has(f.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${f.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:f.id,line:f.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),f.type==="fan_in"){let m=r.get(f.id);if(!m)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${f.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:f.id,line:f.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!f.files.role&&f.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${f.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:f.id,line:f.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let $=m.legIds.filter(w=>o.get(w)?.type==="pr-review");$.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${f.id}' lanes [${$.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:f.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(Et(n.config).mode==="github-token"){let r=n.edges.filter(h=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(h.on??"")||/^(label=|verdict=)/.test(h.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}N();var Ws=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),mo=new Set(["start"]);function It(n){let e=[],t=new Set(n.nodes.map(u=>u.id)),o=new Map(n.nodes.map(u=>[u.id,u])),s=new Map;for(let u of t)s.set(u,[]);for(let u of n.edges)t.has(u.from)&&t.has(u.to)&&s.get(u.from).push(u.to);let a=n.nodes.filter(u=>mo.has(u.type)||u.attrs.schedule!==void 0||u.type==="merge-gate"),l=new Set,d=a.map(u=>u.id);for(;d.length;){let u=d.pop();if(!l.has(u)){l.add(u);for(let r of s.get(u)??[])d.push(r)}}for(let u of n.nodes)!l.has(u.id)&&!mo.has(u.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${u.id}' is unreachable from any entry (start/scheduled) node`,where:{node:u.id,line:u.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let u of n.nodes)(s.get(u.id)??[]).length===0&&!Ws.has(u.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${u.id}' (type ${u.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:u.id,line:u.line},hint:"route it to a next node, or make it an exit"});for(let u of Ys(t,s)){if(!(u.length>1||(s.get(u[0])??[]).includes(u[0])))continue;let h=new Set(u),f=[];for(let m of u)for(let $ of s.get(m)??[])h.has($)||f.push({from:m,to:$});f.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${u.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:u[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):f.some(m=>Ks(Vs(n,m.from,m.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${u.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:u[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let p=new Map;for(let u of n.edges){let r=`${u.on??""}|${u.when??""}`;p.has(u.from)||p.set(u.from,new Map);let h=p.get(u.from);h.has(r)||h.set(r,new Set),h.get(r).add(u.to)}for(let[u,r]of p)for(let[h,f]of r)f.size>1&&h!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${u}' has multiple edges with identical trigger/guard (${h}) to different targets: ${[...f].join(", ")}`,where:{node:u},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function Vs(n,e,t){return n.edges.find(o=>o.from===e&&o.to===t)?.when}function Ks(n){return n?/(>=|>|attempts|max|count|limit)/i.test(n):!1}function Ys(n,e){let t=0,o=new Map,s=new Map,a=new Set,l=[],d=[],p=u=>{o.set(u,t),s.set(u,t),t++,l.push(u),a.add(u);for(let r of e.get(u)??[])o.has(r)?a.has(r)&&s.set(u,Math.min(s.get(u),o.get(r))):(p(r),s.set(u,Math.min(s.get(u),s.get(r))));if(s.get(u)===o.get(u)){let r=[],h;do h=l.pop(),a.delete(h),r.push(h);while(h!==u);d.push(r.reverse())}};for(let u of n)o.has(u)||p(u);return d}N();var Js=new Set(it),Xs=new Set(["pr-review","pr-fix"]);function zs(n,e){return e.labels?.[n]??n}function En(n){return Xs.has(n.type)||n.context==="pr-diff"||n.context==="pr-review"}function _n(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(En(t))return o("pull_request","synchronize");n.push??={};return;case"workflow_dispatch":n.workflow_dispatch??={};return;default:n[e]??={}}}function Ht(n,e){return n==="push"&&En(e)?"pull_request.synchronize":n}function Fi(n){let[e,t]=n.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function Qs(n,e,t){if(n.on){let s=n.on.split(",").map(l=>l.trim()).filter(Boolean),a=s.map(l=>Ht(l,e));return{events:s,guard:n.when?$n(n.when,a,t):void 0}}if(!n.when)return;let o=n.when;if(o.startsWith("label=")){let s=[En(e)?"pull_request.labeled":"issues.labeled"];return{events:s,guard:$n(o,s,t)}}if(o.startsWith("verdict=")){let s=["pull_request_review.submitted"];return{events:s,guard:$n(o,s,t)}}}function $n(n,e,t){if(n.startsWith("label=")){let s=`github.event.label.name == '${zs(n.slice(6),t)}'`,a=Zs(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=ea(t);return a?`${s} && ${a}`:s}}function Zs(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 ea(n){let e=n.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function bo(n){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(n)}function ta(n){let e=n.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function wo(n,e,t){return Pt(n,e,ta(t))}function yo(n,e,t,o){return Pt(n,e,t?hr(t,o):void 0)}function Pt(n,e,t){let o=[...e].filter(bo);if(!t||o.length===0)return n;let s=[...e].filter(l=>!bo(l)),a=s.length?`(${s.map(Fi).join(" || ")} || ${t})`:t;return n?`(${n}) && ${a}`:a}function _o(n,e){let t=n.attrs.cancel_in_progress;return typeof t=="boolean"&&Js.has(n.type)?t:e}function na(n,e){if(n.attrs.schedule!==void 0)return{group:n.id,"cancel-in-progress":_o(n,!1)};let t=En(n)||n.type==="human-gate",o=t?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}",s=_o(n,n.type==="issue-agent");return e!==void 0&&t?{group:`\${{ github.event.action == 'labeled' && github.event.label.name != ${_e(e)} && format(${_e(`${n.id}-noop-{0}`)}, github.run_id) || format(${_e(`${n.id}-{0}`)}, github.event.pull_request.number) }}`,"cancel-in-progress":s}:{group:`${n.id}-${o}`,"cancel-in-progress":s}}function $o(n){let e={},t=new Map(n.nodes.map(d=>[d.id,d])),o=new Map;for(let d of n.nodes)o.set(d.id,[]);for(let d of n.edges)o.get(d.to)?.push(d);let s=ze(n),a=At(n.config),l=n.config.identity?.bot_login;for(let d of n.nodes){if(d.type==="start"||d.type==="exit"||s.memberIds.has(d.id))continue;let p=s.byFanin.get(d.id);if(p){let M=p.entryEdge,q=t.get(p.legIds[0]),U={},ie=(M.on??"").split(",").map(Q=>Q.trim()).filter(Boolean);for(let Q of ie)_n(U,Q,q);let ue={nodeId:d.id,triggers:U,dispatches:[]},oe=new Set(ie.map(Q=>Ht(Q,q))),pe;try{pe=St(n.config)}catch{pe=[vt]}let ce=M.when?$n(M.when,[...oe],n.config):void 0,F=a?Pt(ce,oe,ri(a,l,!1)):yo(wo(ce,oe,n.config),oe,pe);F&&(ue.guard=F);let z=ie.some(Q=>Ht(Q,q).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";ue.concurrency={group:`${d.id}-${z}`,"cancel-in-progress":!1},e[d.id]=ue;continue}if(d.type==="parallel"||d.type==="fan_in")continue;let u={},r=new Set,h=new Set,f=new Set,m=[],$=a!==void 0&&(dn(d)||je(d)),w=a?dn(d)?a.optInLabel:void 0:Ke(d,n.config),y=!1;if(d.attrs.schedule!==void 0)u.schedule=[{cron:String(d.attrs.schedule)}],u.workflow_dispatch={};else{for(let M of o.get(d.id)??[]){let q=Qs(M,d,n.config);if(q){for(let U of q.events)_n(u,U,d);for(let U of q.events)f.add(Ht(U,d));if(q.guard)r.add(q.guard);else for(let U of q.events)h.add(Ht(U,d))}}if(u.pull_request&&ve(d,n.config)&&($||$e(d).some(M=>M.kind==="draft"))&&(_n(u,"pull_request.ready_for_review",d),f.add("pull_request.ready_for_review"),h.add("pull_request.ready_for_review")),w&&u.pull_request&&ve(d,n.config)&&(f.has("pull_request.labeled")?h.has("pull_request.labeled")||r.add(`(${Fi("pull_request.labeled")} && github.event.label.name == ${_e(w)})`):(_n(u,"pull_request.labeled",d),f.add("pull_request.labeled"),h.add("pull_request.labeled"),y=!0)),r.size&&h.size)for(let M of h)r.add(Fi(M))}for(let M of n.edges)M.from===d.id&&M.do&&m.push({toNode:M.to,when:M.when});let C=r.size?[...r].join(" || "):void 0,P=$?Pt(C,f,ri(a,l,je(d))):yo(wo(C,f,n.config),f,Ne(d,n.config),w);y&&w&&(P=Pt(P,f,`(github.event.action != 'labeled' || github.event.label.name == ${_e(w)})`));let j={nodeId:d.id,triggers:u,dispatches:m};P&&(j.guard=P),Object.keys(u).length&&(j.concurrency=na(d,y?w:void 0)),e[d.id]=j}return{perNode:e}}N();N();var ji="${{ github.event.pull_request.number }}",ia=10,Eo=3,vo=3,ra=600;function So(n){return Ee(n.node)?ca(n):ve(n.node,n.config)?Ye(n.config)?la(n):ua(n):null}function ko(n){return Ee(n.node)?da(n):null}var Ao='(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',oa=["[ .[] | select(.commit_id == env.SHA)",` | select(${Ao})`,` | select(${Rt}) ] | length`],sa=[`[ .[] | select(${Ao}) | ${Rt} 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"],aa="github-actions";function Ro(n,e,t){let o=n.node;e.MARKER_PREFIX=hn(o),e.ALSO_HEAD_PREFIX=gr(o),e.EVENT_ACTION="${{ github.event.action }}",e.STAMP_TOKEN=ne(n),t.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. Skip only once the marker is there: a sweep with"," # requires_review selects a head only on a review that covers it, so a"," # skip without the marker would leave the head unreviewed and never"," # selected. If the read or the edit fails, the lane runs again instead.",' MARK="$ALSO_HEAD_PREFIX$HEAD_SHA -->"',' MARKED=""',` if BODY=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$LAST_ID" --jq '.body // ""' 2>/dev/null); then`,' case "$BODY" in',' *"$MARK"*) MARKED=1 ;;',' *) if 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; then MARKED=1; fi ;;`," esac"," fi",' if [ -n "$MARKED" ]; then',' skip "the diff is unchanged since the last review"'," fi",' echo "::notice::the diff is unchanged since review $LAST_ID, but it could not be marked as covering $HEAD_SHA \u2014 running the lane again"'," fi","else",' echo "::warning::could not hash the diff of PR #$PR \u2014 not skipping on unchanged-diff"',"fi")}function la(n){let e=n.node,t=je(e),o=!t&&$e(e).some(f=>f.kind==="unchanged-diff"),s=At(n.config),a=n.config.runtime?.mode==="vendored",l=[];a&&l.push({uses:"actions/checkout@v5",name:"Checkout the scope action (base ref)",with:{ref:"${{ github.event.pull_request.base.ref }}","sparse-checkout":".github/actions/pr-scope","fetch-depth":1,"persist-credentials":!1}}),l.push({uses:n.actionRef("pr-scope"),id:"scope",name:t?"Is this a PR the pipeline wrote?":"Is this PR in scope?",with:{number:ji,token:"${{ github.token }}",...s&&Object.keys(s).length?{rollout:JSON.stringify(s)}:{},...n.config.identity?.bot_login?{"bot-login":n.config.identity.bot_login}:{},...n.config.repo?.branch_prefix?{"branch-prefix":n.config.repo.branch_prefix}:{},...t?{"require-agent-written":"true"}:{}}});let d={jobId:Ie(e),name:`${e.id} guard`,displayName:`${e.id} guard`,timeoutMinutes:5};if(!o)return{...d,permissions:{contents:"read","pull-requests":"read"},outputs:{run:"${{ steps.scope.outputs.run }}",reason:"${{ steps.scope.outputs.reason }}",head_sha:"",diff_hash:"",started_at:""},steps:l};let p={GH_TOKEN:"${{ github.token }}",PR:ji,NODE:e.id,BOT_LOGIN:n.config.identity?.bot_login??"",SCOPE_RUN:"${{ steps.scope.outputs.run }}",SCOPE_REASON:"${{ steps.scope.outputs.reason }}"},u=['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; }',"","# Scope was decided by the step above, by the rule every lane and the gate share.",'if [ "$SCOPE_RUN" != "true" ]; then skip "$SCOPE_REASON"; fi',"","# From here on only the unchanged-diff skip, which fails OPEN: a lane that runs","# once too often costs a run, one wrongly skipped costs a review nobody misses.",'PR_JSON=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" 2>/dev/null) || PR_JSON=""','if [ -z "$PR_JSON" ]; then',' echo "::warning::could not read PR #$PR \u2014 not skipping on unchanged-diff"'," finish","fi",`HEAD_SHA=$(jq -r '.head.sha // ""' <<< "$PR_JSON")`,""];Ro(n,p,u),u.push("","finish");let r=Ue(n,{"pull-requests":"write"}),h=ne(n)==="${{ github.token }}";return r&&l.push(r),l.push(re({id:"decide",name:"Decide whether to run",env:p,run:u.join(`
|
|
224
|
-
`)})),{...
|
|
225
|
-
`)})]}}function
|
|
226
|
-
`);return{jobId:Ie(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:[...f,
|
|
227
|
-
`)})]}}
|
|
207
|
+
`,_?1+b:b),_=!0,O=!0,b=0;let T=i.position;for(;!P(S)&&S!==0;)S=i.input.charCodeAt(++i.position);he(i,T,i.position,!1)}return!0}function Oe(i,g){let E=i.tag,k=i.anchor,_=[],O=!1;if(i.firstTabInLine!==-1)return!1;i.anchor!==null&&Ae(i,i.anchor,_);let d=i.input.charCodeAt(i.position);for(;d!==0&&(i.firstTabInLine!==-1&&(i.position=i.firstTabInLine,N(i,"tab characters must not be used in indentation")),d===45);){let b=i.input.charCodeAt(i.position+1);if(!j(b))break;if(O=!0,i.position++,ee(i,!0,-1)&&i.lineIndent<=g){_.push(null),d=i.input.charCodeAt(i.position);continue}let R=i.line;if(Ce(i,g,c,!1,!0),_.push(i.result),ee(i,!0,-1),d=i.input.charCodeAt(i.position),(i.line===R||i.lineIndent>g)&&d!==0)N(i,"bad indentation of a sequence entry");else if(i.lineIndent<g)break}return O?(i.tag=E,i.anchor=k,i.kind="sequence",i.result=_,!0):!1}function Vt(i,g,E){let k,_,O,d,b=i.tag,R=i.anchor,v={},S=Object.create(null),T=null,A=null,H=null,x=!1,L=!1;if(i.firstTabInLine!==-1)return!1;i.anchor!==null&&Ae(i,i.anchor,v);let D=i.input.charCodeAt(i.position);for(;D!==0;){!x&&i.firstTabInLine!==-1&&(i.position=i.firstTabInLine,N(i,"tab characters must not be used in indentation"));let G=i.input.charCodeAt(i.position+1),z=i.line;if((D===63||D===58)&&j(G))D===63?(x&&(Re(i,v,S,T,A,null,_,O,d),T=A=H=null),L=!0,x=!0,k=!0):x?(x=!1,k=!0):N(i,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),i.position+=1,D=G;else{if(_=i.line,O=i.lineStart,d=i.position,!Ce(i,E,l,!1,!0))break;if(i.line===z){for(D=i.input.charCodeAt(i.position);F(D);)D=i.input.charCodeAt(++i.position);if(D===58)D=i.input.charCodeAt(++i.position),j(D)||N(i,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(Re(i,v,S,T,A,null,_,O,d),T=A=H=null),L=!0,x=!1,k=!1,T=i.tag,A=i.result;else if(L)N(i,"can not read an implicit mapping pair; a colon is missed");else return i.tag=b,i.anchor=R,!0}else if(L)N(i,"can not read a block mapping entry; a multiline key may not be an implicit key");else return i.tag=b,i.anchor=R,!0}if((i.line===z||i.lineIndent>g)&&(x&&(_=i.line,O=i.lineStart,d=i.position),Ce(i,g,p,!0,k)&&(x?A=i.result:H=i.result),x||(Re(i,v,S,T,A,H,_,O,d),T=A=H=null),ee(i,!0,-1),D=i.input.charCodeAt(i.position)),(i.line===z||i.lineIndent>g)&&D!==0)N(i,"bad indentation of a mapping entry");else if(i.lineIndent<g)break}return x&&Re(i,v,S,T,A,null,_,O,d),L&&(i.tag=b,i.anchor=R,i.kind="mapping",i.result=v),L}function Tn(i){let g=!1,E=!1,k,_,O=i.input.charCodeAt(i.position);if(O!==33)return!1;i.tag!==null&&N(i,"duplication of a tag property"),O=i.input.charCodeAt(++i.position),O===60?(g=!0,O=i.input.charCodeAt(++i.position)):O===33?(E=!0,k="!!",O=i.input.charCodeAt(++i.position)):k="!";let d=i.position;if(g){do O=i.input.charCodeAt(++i.position);while(O!==0&&O!==62);i.position<i.length?(_=i.input.slice(d,i.position),O=i.input.charCodeAt(++i.position)):N(i,"unexpected end of the stream within a verbatim tag")}else{for(;O!==0&&!j(O);)O===33&&(E?N(i,"tag suffix cannot contain exclamation marks"):(k=i.input.slice(d-1,i.position+1),w.test(k)||N(i,"named tag handle cannot contain such characters"),E=!0,d=i.position+1)),O=i.input.charCodeAt(++i.position);_=i.input.slice(d,i.position),$.test(_)&&N(i,"tag suffix cannot contain flow indicator characters")}_&&!y.test(_)&&N(i,"tag name cannot contain such characters: "+_);try{_=decodeURIComponent(_)}catch{N(i,"tag name is malformed: "+_)}return g?i.tag=_:s.call(i.tagMap,k)?i.tag=i.tagMap[k]+_:k==="!"?i.tag="!"+_:k==="!!"?i.tag="tag:yaml.org,2002:"+_:N(i,'undeclared tag handle "'+k+'"'),!0}function Kt(i){let g=i.input.charCodeAt(i.position);if(g!==38)return!1;i.anchor!==null&&N(i,"duplication of an anchor property"),g=i.input.charCodeAt(++i.position);let E=i.position;for(;g!==0&&!j(g)&&!q(g);)g=i.input.charCodeAt(++i.position);return i.position===E&&N(i,"name of an anchor node must contain at least one character"),i.anchor=i.input.slice(E,i.position),!0}function Yt(i){let g=i.input.charCodeAt(i.position);if(g!==42)return!1;g=i.input.charCodeAt(++i.position);let E=i.position;for(;g!==0&&!j(g)&&!q(g);)g=i.input.charCodeAt(++i.position);i.position===E&&N(i,"name of an alias node must contain at least one character");let k=i.input.slice(E,i.position);return s.call(i.anchorMap,k)||N(i,'unidentified alias "'+k+'"'),i.result=i.anchorMap[k],ee(i,!0,-1),!0}function On(i,g,E,k){let _=wt(i);return An(i),tt(i,g),i.tag=null,i.anchor=null,i.kind=null,i.result=null,Vt(i,E,k)&&i.kind==="mapping"?(We(i),!0):(Rn(i),tt(i,_),!1)}function Ce(i,g,E,k,_){let O,d,b=1,R=!1,v=!1,S=null,T,A,H;i.depth>=i.maxDepth&&N(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 x=O=d=p===E||c===E;if(k&&ee(i,!0,-1)&&(R=!0,i.lineIndent>g?b=1:i.lineIndent===g?b=0:i.lineIndent<g&&(b=-1)),b===1)for(;;){let L=i.input.charCodeAt(i.position),D=wt(i);if(R&&(L===33&&i.tag!==null||L===38&&i.anchor!==null)||!Tn(i)&&!Kt(i))break;S===null&&(S=D),ee(i,!0,-1)?(R=!0,d=x,i.lineIndent>g?b=1:i.lineIndent===g?b=0:i.lineIndent<g&&(b=-1)):d=!1}if(d&&(d=R||_),b===1||p===E)if(a===E||l===E?A=g:A=g+1,H=i.position-i.lineStart,b===1)if(d&&(Oe(i,H)||Vt(i,H,A))||Gt(i,A))v=!0;else{let L=i.input.charCodeAt(i.position);S!==null&&x&&!d&&L!==124&&L!==62&&On(i,S,S.position-S.lineStart,A)||O&&Wt(i,A)||Bt(i,A)||yt(i,A)?v=!0:Yt(i)?(v=!0,(i.tag!==null||i.anchor!==null)&&N(i,"alias node should not have any properties")):Ut(i,A,a===E)&&(v=!0,i.tag===null&&(i.tag="?")),i.anchor!==null&&Ae(i,i.anchor,i.result)}else b===0&&(v=d&&Oe(i,H));if(i.tag===null)i.anchor!==null&&Ae(i,i.anchor,i.result);else if(i.tag==="?"){i.result!==null&&i.kind!=="scalar"&&N(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(T=i.implicitTypes[L],T.resolve(i.result)){i.result=T.construct(i.result),i.tag=T.tag,i.anchor!==null&&Ae(i,i.anchor,i.result);break}}else if(i.tag!=="!"){if(s.call(i.typeMap[i.kind||"fallback"],i.tag))T=i.typeMap[i.kind||"fallback"][i.tag];else{T=null;let L=i.typeMap.multi[i.kind||"fallback"];for(let D=0,G=L.length;D<G;D+=1)if(i.tag.slice(0,L[D].tag.length)===L[D].tag){T=L[D];break}}T||N(i,"unknown tag !<"+i.tag+">"),i.result!==null&&T.kind!==i.kind&&N(i,"unacceptable node kind for !<"+i.tag+'> tag; it should be "'+T.kind+'", not "'+i.kind+'"'),T.resolve(i.result,i.tag)?(i.result=T.construct(i.result,i.tag),i.anchor!==null&&Ae(i,i.anchor,i.result)):N(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||v}function Cn(i){let g=i.position,E=!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&&(ee(i,!0,-1),k=i.input.charCodeAt(i.position),!(i.lineIndent>0||k!==37));){E=!0,k=i.input.charCodeAt(++i.position);let _=i.position;for(;k!==0&&!j(k);)k=i.input.charCodeAt(++i.position);let O=i.input.slice(_,i.position),d=[];for(O.length<1&&N(i,"directive name must not be less than one character in length");k!==0;){for(;F(k);)k=i.input.charCodeAt(++i.position);if(k===35){do k=i.input.charCodeAt(++i.position);while(k!==0&&!P(k));break}if(P(k))break;for(_=i.position;k!==0&&!j(k);)k=i.input.charCodeAt(++i.position);d.push(i.input.slice(_,i.position))}k!==0&&nt(i),s.call(qt,O)?qt[O](i,O,d):et(i,'unknown document directive "'+O+'"')}if(ee(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,ee(i,!0,-1)):E&&N(i,"directives end mark is expected"),Ce(i,i.lineIndent-1,p,!1,!0),ee(i,!0,-1),i.checkLineBreaks&&m.test(i.input.slice(g,i.position))&&et(i,"non-ASCII line breaks are interpreted as content"),i.documents.push(i.result),i.position===i.lineStart&&it(i)){i.input.charCodeAt(i.position)===46&&(i.position+=3,ee(i,!0,-1));return}i.position<i.length-1&&N(i,"end of the stream or a document separator is expected")}function Jt(i,g){i=String(i),g=g||{},i.length!==0&&(i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
|
|
208
|
+
`),i.charCodeAt(0)===65279&&(i=i.slice(1)));let E=new Z(i,g),k=i.indexOf("\0");for(k!==-1&&(E.position=k,N(E,"null byte is not allowed in input")),E.input+="\0";E.input.charCodeAt(E.position)===32;)E.lineIndent+=1,E.position+=1;for(;E.position<E.length-1;)Cn(E);return E.documents}function Xt(i,g,E){g!==null&&typeof g=="object"&&typeof E>"u"&&(E=g,g=null);let k=Jt(i,E);if(typeof g!="function")return k;for(let _=0,O=k.length;_<O;_+=1)g(k[_])}function xn(i,g){let E=Jt(i,g);if(E.length!==0){if(E.length===1)return E[0];throw new e("expected a single document in the stream, but found more")}}return _n.loadAll=Xt,_n.load=xn,_n}var Di={},Xr;function Us(){if(Xr)return Di;Xr=1;let n=Ct(),e=xt(),t=Mi(),o=Object.prototype.toString,s=Object.prototype.hasOwnProperty,a=65279,l=9,c=10,p=13,u=32,r=33,h=34,f=35,m=37,$=38,w=39,y=42,C=44,P=45,F=58,j=61,q=62,U=63,X=64,de=91,oe=93,pe=96,ue=123,M=124,ae=125,Z={};Z[0]="\\0",Z[7]="\\a",Z[8]="\\b",Z[9]="\\t",Z[10]="\\n",Z[11]="\\v",Z[12]="\\f",Z[13]="\\r",Z[27]="\\e",Z[34]='\\"',Z[92]="\\\\",Z[133]="\\N",Z[160]="\\_",Z[8232]="\\L",Z[8233]="\\P";let se=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],N=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function et(d,b){if(b===null)return{};let R={},v=Object.keys(b);for(let S=0,T=v.length;S<T;S+=1){let A=v[S],H=String(b[A]);A.slice(0,2)==="!!"&&(A="tag:yaml.org,2002:"+A.slice(2));let x=d.compiledTypeMap.fallback[A];x&&s.call(x.styleAliases,H)&&(H=x.styleAliases[H]),R[A]=H}return R}function Ae(d){let b,R,v=d.toString(16).toUpperCase();if(d<=255)b="x",R=2;else if(d<=65535)b="u",R=4;else if(d<=4294967295)b="U",R=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+b+n.repeat("0",R-v.length)+v}let An=1,We=2;function Rn(d){this.schema=d.schema||t,this.indent=Math.max(1,d.indent||2),this.noArrayIndent=d.noArrayIndent||!1,this.skipInvalid=d.skipInvalid||!1,this.flowLevel=n.isNothing(d.flowLevel)?-1:d.flowLevel,this.styleMap=et(this.schema,d.styles||null),this.sortKeys=d.sortKeys||!1,this.lineWidth=d.lineWidth||80,this.noRefs=d.noRefs||!1,this.noCompatMode=d.noCompatMode||!1,this.condenseFlow=d.condenseFlow||!1,this.quotingType=d.quotingType==='"'?We:An,this.forceQuotes=d.forceQuotes||!1,this.replacer=typeof d.replacer=="function"?d.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function wt(d,b){let R=n.repeat(" ",b),v=0,S="",T=d.length;for(;v<T;){let A,H=d.indexOf(`
|
|
209
|
+
`,v);H===-1?(A=d.slice(v),v=T):(A=d.slice(v,H+1),v=H+1),A.length&&A!==`
|
|
210
|
+
`&&(S+=R),S+=A}return S}function tt(d,b){return`
|
|
211
|
+
`+n.repeat(" ",d.indent*b)}function qt(d,b){for(let R=0,v=d.implicitTypes.length;R<v;R+=1)if(d.implicitTypes[R].resolve(b))return!0;return!1}function he(d){return d===u||d===l}function De(d){return d>=32&&d<=126||d>=161&&d<=55295&&d!==8232&&d!==8233||d>=57344&&d<=65533&&d!==a||d>=65536&&d<=1114111}function Re(d){return De(d)&&d!==a&&d!==p&&d!==c}function nt(d,b,R){let v=Re(d),S=v&&!he(d);return(R?v:v&&d!==C&&d!==de&&d!==oe&&d!==ue&&d!==ae)&&d!==f&&!(b===F&&!S)||Re(b)&&!he(b)&&d===f||b===F&&S}function ee(d){return De(d)&&d!==a&&!he(d)&&d!==P&&d!==U&&d!==F&&d!==C&&d!==de&&d!==oe&&d!==ue&&d!==ae&&d!==f&&d!==$&&d!==y&&d!==r&&d!==M&&d!==j&&d!==q&&d!==w&&d!==h&&d!==m&&d!==X&&d!==pe}function it(d){return!he(d)&&d!==F}function Te(d,b){let R=d.charCodeAt(b),v;return R>=55296&&R<=56319&&b+1<d.length&&(v=d.charCodeAt(b+1),v>=56320&&v<=57343)?(R-55296)*1024+v-56320+65536:R}function Ut(d){return/^\n* /.test(d)}let Bt=1,yt=2,Gt=3,Wt=4,Oe=5;function Vt(d,b,R,v,S,T,A,H){let x,L=0,D=null,G=!1,z=!1,Wi=v!==-1,_t=-1,$t=ee(Te(d,0))&&it(Te(d,d.length-1));if(b||A)for(x=0;x<d.length;L>=65536?x+=2:x++){if(L=Te(d,x),!De(L))return Oe;$t=$t&&nt(L,D,H),D=L}else{for(x=0;x<d.length;L>=65536?x+=2:x++){if(L=Te(d,x),L===c)G=!0,Wi&&(z=z||x-_t-1>v&&d[_t+1]!==" ",_t=x);else if(!De(L))return Oe;$t=$t&&nt(L,D,H),D=L}z=z||Wi&&x-_t-1>v&&d[_t+1]!==" "}return!G&&!z?$t&&!A&&!S(d)?Bt:T===We?Oe:yt:R>9&&Ut(d)?Oe:A?T===We?Oe:yt:z?Wt:Gt}function Tn(d,b,R,v,S){d.dump=(function(){if(b.length===0)return d.quotingType===We?'""':"''";if(!d.noCompatMode&&(se.indexOf(b)!==-1||N.test(b)))return d.quotingType===We?'"'+b+'"':"'"+b+"'";let T=d.indent*Math.max(1,R),A=d.lineWidth===-1?-1:Math.max(Math.min(d.lineWidth,40),d.lineWidth-T),H=v||d.flowLevel>-1&&R>=d.flowLevel;function x(L){return qt(d,L)}switch(Vt(b,H,d.indent,A,x,d.quotingType,d.forceQuotes&&!v,S)){case Bt:return b;case yt:return"'"+b.replace(/'/g,"''")+"'";case Gt:return"|"+Kt(b,d.indent)+Yt(wt(b,T));case Wt:return">"+Kt(b,d.indent)+Yt(wt(On(b,A),T));case Oe:return'"'+Cn(b)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function Kt(d,b){let R=Ut(d)?String(b):"",v=d[d.length-1]===`
|
|
212
|
+
`,T=v&&(d[d.length-2]===`
|
|
213
|
+
`||d===`
|
|
214
|
+
`)?"+":v?"":"-";return R+T+`
|
|
215
|
+
`}function Yt(d){return d[d.length-1]===`
|
|
216
|
+
`?d.slice(0,-1):d}function On(d,b){let R=/(\n+)([^\n]*)/g,v=(function(){let H=d.indexOf(`
|
|
217
|
+
`);return H=H!==-1?H:d.length,R.lastIndex=H,Ce(d.slice(0,H),b)})(),S=d[0]===`
|
|
218
|
+
`||d[0]===" ",T,A;for(;A=R.exec(d);){let H=A[1],x=A[2];T=x[0]===" ",v+=H+(!S&&!T&&x!==""?`
|
|
219
|
+
`:"")+Ce(x,b),S=T}return v}function Ce(d,b){if(d===""||d[0]===" ")return d;let R=/ [^ ]/g,v,S=0,T,A=0,H=0,x="";for(;v=R.exec(d);)H=v.index,H-S>b&&(T=A>S?A:H,x+=`
|
|
220
|
+
`+d.slice(S,T),S=T+1),A=H;return x+=`
|
|
221
|
+
`,d.length-S>b&&A>S?x+=d.slice(S,A)+`
|
|
222
|
+
`+d.slice(A+1):x+=d.slice(S),x.slice(1)}function Cn(d){let b="",R=0;for(let v=0;v<d.length;R>=65536?v+=2:v++){R=Te(d,v);let S=Z[R];!S&&De(R)?(b+=d[v],R>=65536&&(b+=d[v+1])):b+=S||Ae(R)}return b}function Jt(d,b,R){let v="",S=d.tag;for(let T=0,A=R.length;T<A;T+=1){let H=R[T];d.replacer&&(H=d.replacer.call(R,String(T),H)),(E(d,b,H,!1,!1)||typeof H>"u"&&E(d,b,null,!1,!1))&&(v!==""&&(v+=","+(d.condenseFlow?"":" ")),v+=d.dump)}d.tag=S,d.dump="["+v+"]"}function Xt(d,b,R,v){let S="",T=d.tag;for(let A=0,H=R.length;A<H;A+=1){let x=R[A];d.replacer&&(x=d.replacer.call(R,String(A),x)),(E(d,b+1,x,!0,!0,!1,!0)||typeof x>"u"&&E(d,b+1,null,!0,!0,!1,!0))&&((!v||S!=="")&&(S+=tt(d,b)),d.dump&&c===d.dump.charCodeAt(0)?S+="-":S+="- ",S+=d.dump)}d.tag=T,d.dump=S||"[]"}function xn(d,b,R){let v="",S=d.tag,T=Object.keys(R);for(let A=0,H=T.length;A<H;A+=1){let x="";v!==""&&(x+=", "),d.condenseFlow&&(x+='"');let L=T[A],D=R[L];d.replacer&&(D=d.replacer.call(R,L,D)),E(d,b,L,!1,!1)&&(d.dump.length>1024&&(x+="? "),x+=d.dump+(d.condenseFlow?'"':"")+":"+(d.condenseFlow?"":" "),E(d,b,D,!1,!1)&&(x+=d.dump,v+=x))}d.tag=S,d.dump="{"+v+"}"}function i(d,b,R,v){let S="",T=d.tag,A=Object.keys(R);if(d.sortKeys===!0)A.sort();else if(typeof d.sortKeys=="function")A.sort(d.sortKeys);else if(d.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let H=0,x=A.length;H<x;H+=1){let L="";(!v||S!=="")&&(L+=tt(d,b));let D=A[H],G=R[D];if(d.replacer&&(G=d.replacer.call(R,D,G)),!E(d,b+1,D,!0,!0,!0))continue;let z=d.tag!==null&&d.tag!=="?"||d.dump&&d.dump.length>1024;z&&(d.dump&&c===d.dump.charCodeAt(0)?L+="?":L+="? "),L+=d.dump,z&&(L+=tt(d,b)),E(d,b+1,G,!0,z)&&(d.dump&&c===d.dump.charCodeAt(0)?L+=":":L+=": ",L+=d.dump,S+=L)}d.tag=T,d.dump=S||"{}"}function g(d,b,R){let v=R?d.explicitTypes:d.implicitTypes;for(let S=0,T=v.length;S<T;S+=1){let A=v[S];if((A.instanceOf||A.predicate)&&(!A.instanceOf||typeof b=="object"&&b instanceof A.instanceOf)&&(!A.predicate||A.predicate(b))){if(R?A.multi&&A.representName?d.tag=A.representName(b):d.tag=A.tag:d.tag="?",A.represent){let H=d.styleMap[A.tag]||A.defaultStyle,x;if(o.call(A.represent)==="[object Function]")x=A.represent(b,H);else if(s.call(A.represent,H))x=A.represent[H](b,H);else throw new e("!<"+A.tag+'> tag resolver accepts not "'+H+'" style');d.dump=x}return!0}}return!1}function E(d,b,R,v,S,T,A){d.tag=null,d.dump=R,g(d,R,!1)||g(d,R,!0);let H=o.call(d.dump),x=v;v&&(v=d.flowLevel<0||d.flowLevel>b);let L=H==="[object Object]"||H==="[object Array]",D,G;if(L&&(D=d.duplicates.indexOf(R),G=D!==-1),(d.tag!==null&&d.tag!=="?"||G||d.indent!==2&&b>0)&&(S=!1),G&&d.usedDuplicates[D])d.dump="*ref_"+D;else{if(L&&G&&!d.usedDuplicates[D]&&(d.usedDuplicates[D]=!0),H==="[object Object]")v&&Object.keys(d.dump).length!==0?(i(d,b,d.dump,S),G&&(d.dump="&ref_"+D+d.dump)):(xn(d,b,d.dump),G&&(d.dump="&ref_"+D+" "+d.dump));else if(H==="[object Array]")v&&d.dump.length!==0?(d.noArrayIndent&&!A&&b>0?Xt(d,b-1,d.dump,S):Xt(d,b,d.dump,S),G&&(d.dump="&ref_"+D+d.dump)):(Jt(d,b,d.dump),G&&(d.dump="&ref_"+D+" "+d.dump));else if(H==="[object String]")d.tag!=="?"&&Tn(d,d.dump,b,T,x);else{if(H==="[object Undefined]")return!1;if(d.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+H)}if(d.tag!==null&&d.tag!=="?"){let z=encodeURI(d.tag[0]==="!"?d.tag.slice(1):d.tag).replace(/!/g,"%21");d.tag[0]==="!"?z="!"+z:z.slice(0,18)==="tag:yaml.org,2002:"?z="!!"+z.slice(18):z="!<"+z+">",d.dump=z+" "+d.dump}}return!0}function k(d,b){let R=[],v=[];_(d,R,v);let S=v.length;for(let T=0;T<S;T+=1)b.duplicates.push(R[v[T]]);b.usedDuplicates=new Array(S)}function _(d,b,R){if(d!==null&&typeof d=="object"){let v=b.indexOf(d);if(v!==-1)R.indexOf(v)===-1&&R.push(v);else if(b.push(d),Array.isArray(d))for(let S=0,T=d.length;S<T;S+=1)_(d[S],b,R);else{let S=Object.keys(d);for(let T=0,A=S.length;T<A;T+=1)_(d[S[T]],b,R)}}}function O(d,b){b=b||{};let R=new Rn(b);R.noRefs||k(d,R);let v=d;return R.replacer&&(v=R.replacer.call({"":v},"",v)),E(R,0,v,!0,!0)?R.dump+`
|
|
223
|
+
`:""}return Di.dump=O,Di}var zr;function Bs(){if(zr)return le;zr=1;let n=qs(),e=Us();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 le.Type=ce(),le.Schema=Qr(),le.FAILSAFE_SCHEMA=no(),le.JSON_SCHEMA=ao(),le.CORE_SCHEMA=lo(),le.DEFAULT_SCHEMA=Mi(),le.load=n.load,le.loadAll=n.loadAll,le.dump=e.dump,le.YAMLException=xt(),le.types={binary:po(),float:so(),map:to(),null:io(),pairs:fo(),set:go(),timestamp:uo(),bool:ro(),int:oo(),merge:co(),omap:ho(),seq:eo(),str:Zr()},le.safeLoad=t("safeLoad","load"),le.safeLoadAll=t("safeLoadAll","loadAll"),le.safeDump=t("safeDump","dump"),le}var Gs=Bs(),He=Fs(Gs),{Type:Ul,Schema:Bl,FAILSAFE_SCHEMA:Gl,JSON_SCHEMA:Wl,CORE_SCHEMA:Vl,DEFAULT_SCHEMA:Kl,load:Yl,loadAll:Jl,dump:Xl,YAMLException:zl,types:Ql,safeLoad:Zl,safeLoadAll:eu,safeDump:tu}=He;var Ws=/^---\r?\n([\s\S]*?)\r?\n---/;function ht(n){let e=Ws.exec(n);if(e)try{let t=He.load(e[1]);if(t&&typeof t=="object")return t}catch{return}}var ft=new Set(rt);function Nt(n,e={}){let t=[],o=new Map(n.nodes.map(r=>[r.id,r])),s=Qe(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,h,f,m)=>{let $=cr(r,h);t.push({level:"error",code:"attr.unknown",message:`unknown attribute '${r}=' on ${f} \u2014 it would be silently ignored`,where:m,hint:$?`did you mean '${$}='?`:"see reference/node-types.md for the attributes this version of gp-foundry understands"})};for(let r of n.nodes)for(let h of Object.keys(r.raw))Jn.has(h)||a(h,Jn,`node '${r.id}'`,{node:r.id,line:r.line});for(let r of n.edges)for(let h of Object.keys(r.raw))Xn.has(h)||a(h,Xn,`edge '${r.from} -> ${r.to}'`,{edge:[r.from,r.to],line:r.line});try{Ve(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{ot(n.config.rollout,n.config.labels)}catch(r){t.push({level:"error",code:"config.bad-rollout",message:r.message,hint:"rollout: { authors: [alice], opt_in_label: agent-review, skip_label: no-agent-review } \u2014 every key optional"})}let l=Je(n.config);if(l){n.config.repo?.authors!==void 0&&t.push({level:"error",code:"config.authors-and-rollout",message:"repo.authors and rollout are both set \u2014 with a rollout block, scope is rollout.authors",hint:"move the logins to rollout.authors and delete repo.authors"});for(let r of n.nodes){let h={node:r.id,line:r.line};for(let f of["authors","opt_in_label"])r.attrs[f]!==void 0&&r.type!=="merge-gate"&&t.push({level:"error",code:"node.scope-attr-with-rollout",message:`${f}= on '${r.id}' does not apply in a harness with a rollout block \u2014 every lane takes its scope from it`,where:h,hint:"move it to rollout: { authors, opt_in_label, skip_label } in foundry.config.yaml"});if(r.attrs.skip!==void 0&&r.type!=="merge-gate"){let f=[];try{f=on(r)}catch{}let m=f.filter($=>$.kind!=="unchanged-diff").map($=>$.kind==="label"?`label:${$.label}`:$.kind);m.length&&t.push({level:"error",code:"node.scope-attr-with-rollout",message:`skip="${m.join(",")}" on '${r.id}' does not apply in a harness with a rollout block \u2014 drafts and other bots' PRs are always skipped, and the skip label is rollout.skip_label`,where:h,hint:'keep only skip="unchanged-diff" on the node, if it is there'})}je(r)&&!n.config.identity?.bot_login&&t.push({level:"error",code:"node.writing-lane-needs-bot-login",message:`'${r.id}' (type ${r.type}) only pushes to PRs the pipeline wrote, but identity.bot_login is unset \u2014 no PR could be attributed to it`,where:h,hint:"set identity.bot_login in foundry.config.yaml to the login that opens the agent PRs"})}}else for(let r of n.nodes)r.type==="merge-gate"&&r.attrs.merge!==void 0&&t.push({level:"error",code:"node.merge-needs-rollout",message:`merge= on '${r.id}' needs a rollout block in foundry.config.yaml \u2014 it is what puts the gate and every lane on one scope`,where:{node:r.id,line:r.line},hint:"add `rollout: {}` (every PR), or rollout: { authors: [...], opt_in_label: ..., skip_label: ... }"});try{kt(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 c=new Map;for(let r of n.nodes){if(!ti(r))continue;let h;try{h=Fe(r)}catch{continue}let f=c.get(h);f?t.push({level:"error",code:"node.duplicate-check-name",message:`merge gates '${f}' and '${r.id}' both publish the check '${h}'`,where:{node:r.id,line:r.line},hint:"give each gate its own check_name="}):c.set(h,r.id)}for(let r of n.nodes){if(r.attrs.authors!==void 0)if(!sn(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{an(r,n.config)}catch(w){t.push({level:"error",code:"node.bad-authors",message:w.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(!sn(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(y){t.push({level:"error",code:"node.bad-opt-in-label",message:y.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 w;try{w=an(r,n.config)}catch{w=[]}w===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(ft.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{bn(r)}catch(w){t.push({level:"error",code:"node.bad-permissions",message:w.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 w=r.attrs.agent_attempts;(typeof w!="number"||!Number.isInteger(w)||w<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(w)}`,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"}),ft.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 h=r.type!=="start"&&r.type!=="exit"&&r.type!=="parallel",f=r.type==="analyst"||r.type==="issue-agent"||r.type==="pr-review"||r.type==="fan_in",m=r.type==="pr-fix"||(r.type==="pr-review"||r.type==="analyst")&&ye(r)||r.type==="fan_in",$=(w,y,C)=>{t.push({level:"error",code:w,message:y,where:{node:r.id,line:r.line},...C?{hint:C}:{}})};if(r.attrs.runs_on!==void 0)try{dn(r.attrs.runs_on,`runs_on= on '${r.id}'`),h||$("node.runs-on-unsupported",`runs_on= on '${r.id}' (type ${r.type}) does not apply \u2014 this node emits no job`)}catch(w){$("node.bad-runs-on",w.message,'one runner label, e.g. runs_on="ubuntu-latest"; the default for every job is runtime.runs_on in foundry.config.yaml')}if(r.attrs.title!==void 0&&(typeof r.attrs.title!="string"||!r.attrs.title.trim()||r.attrs.title.includes("${{")?$("node.bad-title",`title= on '${r.id}' must be a plain, non-empty string, got ${JSON.stringify(r.attrs.title)}`):(!h||s.has(r.id))&&$("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"?$("node.bad-harness-ref",`harness_ref= on '${r.id}' must be "base" or "head", got ${JSON.stringify(r.attrs.harness_ref)}`):m?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"}):$("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"?$("node.bad-persist-credentials",`persist_credentials= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.persist_credentials)}`):f?r.attrs.persist_credentials===!1&&r.attrs.checkout==="partial"&&$("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'):$("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"?$("node.bad-repo-guides",`repo_guides= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.repo_guides)}`):!ft.has(r.type)&&r.type!=="fan_in"&&$("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}}),!ft.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{zn(r)}catch(w){t.push({level:"error",code:"node.bad-gates",message:w.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 w=[];try{w=on(r)}catch(C){t.push({level:"error",code:"node.bad-skip",message:C.message,where:{node:r.id,line:r.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}let y=(r.type==="pr-review"||r.type==="analyst")&&ye(r)&&r.attrs.schedule===void 0&&!s.has(r.id);ve(r)&&!s.has(r.id)||we(r)?w.some(C=>C.kind==="unchanged-diff")&&t.push({level:"error",code:"node.skip-unsupported",message:`skip="unchanged-diff" on '${r.id}' is not supported on a ${we(r)?"merge gate":"sweep"} \u2014 it compares a push against the last review, and a ${we(r)?"merge gate":"sweep"} reacts to no push`,where:{node:r.id,line:r.line},hint:we(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>"}):y||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'}),w.some(C=>C.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"||!ye(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(!un(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 w=e.roles?.get(r.id)?.tools??(r.files.role&&e.readFile?ht(e.readFile(r.files.role)??"")?.tools:void 0);typeof w=="string"&&li(w)&&t.push({level:"warning",code:"node.post-review-gh-tools",message:`post="review" on '${r.id}': its role still lists gh tools (${w}), 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{cn(r)}catch(w){t.push({level:"error",code:"node.bad-post-marker",message:w.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}}):(!ve(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{Zn(r)}catch(w){t.push({level:"error",code:"node.bad-mode",message:w.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.merge!==void 0)if(r.type!=="merge-gate")$("node.merge-unsupported",`merge= on '${r.id}' is not supported here \u2014 it is the merge-gate's setting ("off" or "agent-only")`);else{let w;try{w=ei(r)}catch(y){$("node.bad-merge",y.message,`merge="off" publishes the gate's result as a check and never merges; merge="agent-only" also merges the PRs the pipeline wrote`)}r.attrs.mode!==void 0&&$("node.merge-and-mode",`'${r.id}' sets both merge= and mode= \u2014 merge= replaces mode=`,'drop mode=: mode="evaluate" is merge="off"');for(let y of["authors","opt_in_label","skip"])r.attrs[y]!==void 0&&$("node.gate-scope-attr",`${y}= on '${r.id}' does not apply to a gate with merge= \u2014 its scope is the rollout block in foundry.config.yaml`,"move it to rollout: { authors, opt_in_label, skip_label }");w==="agent-only"&&!n.config.identity?.bot_login&&$("node.merge-needs-bot-login",`merge="agent-only" on '${r.id}' merges the PRs the pipeline wrote, but identity.bot_login is unset \u2014 no PR could be attributed to it`,"set identity.bot_login in foundry.config.yaml to the login that opens the agent PRs")}else r.type==="merge-gate"&&r.attrs.mode===void 0&&t.push({level:"info",code:"node.merge-implicit",message:`merge-gate '${r.id}' has no merge= \u2014 it merges every approved PR on a '${n.config.repo.branch_prefix}' branch, as before`,where:{node:r.id,line:r.line},hint:'merge="agent-only" merges only PRs the pipeline wrote and publishes the result as a check; merge="off" publishes the check and never merges'});if(r.attrs.check_name!==void 0)if(!ti(r))t.push({level:"error",code:"node.check-name-without-evaluate",message:`check_name= on '${r.id}' needs a merge-gate that publishes a check \u2014 one with merge= (or the older mode="evaluate")`,where:{node:r.id,line:r.line},hint:'add merge="off" or merge="agent-only" to the merge-gate, or drop check_name='});else try{Fe(r)}catch(w){t.push({level:"error",code:"node.bad-check-name",message:w.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 h of["role","policy","prompt","tools"]){let f=r.files[h];f&&!e.fileExists(f)&&t.push({level:"error",code:"file.missing",message:`node '${r.id}' references ${h}="${f}" which does not exist`,where:{node:r.id,line:r.line,file:f}})}if(e.roles){let r=new Map;for(let f of n.nodes)r.set(f.id,[]);for(let f of n.edges){let m=o.get(f.to);m&&r.get(f.from)?.push({node:m,edge:f})}let h=f=>(e.roles?.get(f.id)?.role??f.id).toLowerCase();for(let f of n.nodes){let m=e.roles.get(f.id);if(!m?.handoffs)continue;let $=r.get(f.id)??[],w=new Set($.flatMap(C=>[C.node.id.toLowerCase(),h(C.node)])),y=new Set(m.handoffs.map(C=>String(C.to).toLowerCase()));for(let C of m.handoffs)w.has(String(C.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${m.role}' (node '${f.id}') declares a handoff to '${C.to}' but there is no matching out-edge`,where:{node:f.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:C,edge:P}of $)C.type==="exit"&&!P.when||!y.has(C.id.toLowerCase())&&!y.has(h(C))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${f.id}' has an out-edge to '${C.id}' not declared as a handoff in role '${m.role}'`,where:{node:f.id,edge:[f.id,C.id]},hint:"document the handoff in the role, or remove the edge"})}}let p=(r,h)=>{if(typeof r=="string"){let f=r.match(/<[A-Za-z][^<>]{0,80}>/);f&&t.push({level:"error",code:"config.placeholder",message:`config value ${h} still contains the placeholder ${f[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((f,m)=>p(f,`${h}[${m}]`));else if(r&&typeof r=="object")for(let[f,m]of Object.entries(r))p(m,h?`${h}.${f}`:f)};if(p(n.config,""),n.config.runtime?.runs_on!==void 0)try{dn(n.config.runtime.runs_on,"runtime.runs_on")}catch(r){t.push({level:"error",code:"config.bad-runs-on",message:r.message,hint:"one runner label; a node's runs_on= overrides it for that lane"})}if((n.config.runtime?.mode??"pinned")==="pinned"&&n.config.runtime?.ref===gi&&t.push({level:"warning",code:"runtime.stale-ref",message:`runtime.ref is '${gi}', a tag that has not moved since 0.1.2 \u2014 the generated workflows would call actions far older than this compiler (${Ot()})`,hint:`delete runtime.ref to pin the actions to this compiler's own release (${Ot()}), or name an exact tag or commit`}),e.fileExists&&(n.config.runtime?.mode??"pinned")==="vendored"){let r=new Set,h=!1;for(let f of n.nodes)ft.has(f.type)&&(h=!0,r.add("run-agent")),ft.has(f.type)&&f.type!=="scheduled-agent"&&r.add("agent-context"),(f.type==="producer"||f.type==="scheduled-agent")&&r.add("agent-fallback"),f.type==="merge-gate"&&r.add("merge-gate"),l&&Se(f,n.config)&&r.add("pr-scope"),f.type==="pr-review"&&f.attrs.gates!==void 0&&r.add("wait-for-checks");for(let f of r)e.fileExists(`actions/${f}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${f}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});h&&!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:h}=Qe(n);for(let f of n.nodes)if(f.type==="parallel"&&!h.has(f.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${f.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:f.id,line:f.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),f.type==="fan_in"){let m=r.get(f.id);if(!m)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${f.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:f.id,line:f.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!f.files.role&&f.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${f.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:f.id,line:f.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let $=m.legIds.filter(w=>o.get(w)?.type==="pr-review");$.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${f.id}' lanes [${$.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:f.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(vt(n.config).mode==="github-token"){let r=n.edges.filter(h=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(h.on??"")||/^(label=|verdict=)/.test(h.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 Vs=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),mo=new Set(["start"]);function It(n){let e=[],t=new Set(n.nodes.map(u=>u.id)),o=new Map(n.nodes.map(u=>[u.id,u])),s=new Map;for(let u of t)s.set(u,[]);for(let u of n.edges)t.has(u.from)&&t.has(u.to)&&s.get(u.from).push(u.to);let a=n.nodes.filter(u=>mo.has(u.type)||u.attrs.schedule!==void 0||u.type==="merge-gate"),l=new Set,c=a.map(u=>u.id);for(;c.length;){let u=c.pop();if(!l.has(u)){l.add(u);for(let r of s.get(u)??[])c.push(r)}}for(let u of n.nodes)!l.has(u.id)&&!mo.has(u.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${u.id}' is unreachable from any entry (start/scheduled) node`,where:{node:u.id,line:u.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let u of n.nodes)(s.get(u.id)??[]).length===0&&!Vs.has(u.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${u.id}' (type ${u.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:u.id,line:u.line},hint:"route it to a next node, or make it an exit"});for(let u of Js(t,s)){if(!(u.length>1||(s.get(u[0])??[]).includes(u[0])))continue;let h=new Set(u),f=[];for(let m of u)for(let $ of s.get(m)??[])h.has($)||f.push({from:m,to:$});f.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${u.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:u[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):f.some(m=>Ys(Ks(n,m.from,m.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${u.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:u[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let p=new Map;for(let u of n.edges){let r=`${u.on??""}|${u.when??""}`;p.has(u.from)||p.set(u.from,new Map);let h=p.get(u.from);h.has(r)||h.set(r,new Set),h.get(r).add(u.to)}for(let[u,r]of p)for(let[h,f]of r)f.size>1&&h!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${u}' has multiple edges with identical trigger/guard (${h}) to different targets: ${[...f].join(", ")}`,where:{node:u},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function Ks(n,e,t){return n.edges.find(o=>o.from===e&&o.to===t)?.when}function Ys(n){return n?/(>=|>|attempts|max|count|limit)/i.test(n):!1}function Js(n,e){let t=0,o=new Map,s=new Map,a=new Set,l=[],c=[],p=u=>{o.set(u,t),s.set(u,t),t++,l.push(u),a.add(u);for(let r of e.get(u)??[])o.has(r)?a.has(r)&&s.set(u,Math.min(s.get(u),o.get(r))):(p(r),s.set(u,Math.min(s.get(u),s.get(r))));if(s.get(u)===o.get(u)){let r=[],h;do h=l.pop(),a.delete(h),r.push(h);while(h!==u);c.push(r.reverse())}};for(let u of n)o.has(u)||p(u);return c}I();var Xs=new Set(rt),zs=new Set(["pr-review","pr-fix"]);function Qs(n,e){return e.labels?.[n]??n}function vn(n){return zs.has(n.type)||n.context==="pr-diff"||n.context==="pr-review"}function $n(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(vn(t))return o("pull_request","synchronize");n.push??={};return;case"workflow_dispatch":n.workflow_dispatch??={};return;default:n[e]??={}}}function Ht(n,e){return n==="push"&&vn(e)?"pull_request.synchronize":n}function Fi(n){let[e,t]=n.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function Zs(n,e,t){if(n.on){let s=n.on.split(",").map(l=>l.trim()).filter(Boolean),a=s.map(l=>Ht(l,e));return{events:s,guard:n.when?En(n.when,a,t):void 0}}if(!n.when)return;let o=n.when;if(o.startsWith("label=")){let s=[vn(e)?"pull_request.labeled":"issues.labeled"];return{events:s,guard:En(o,s,t)}}if(o.startsWith("verdict=")){let s=["pull_request_review.submitted"];return{events:s,guard:En(o,s,t)}}}function En(n,e,t){if(n.startsWith("label=")){let s=`github.event.label.name == '${Qs(n.slice(6),t)}'`,a=ea(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=ta(t);return a?`${s} && ${a}`:s}}function ea(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 ta(n){let e=n.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function bo(n){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(n)}function na(n){let e=n.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function wo(n,e,t){return Pt(n,e,na(t))}function yo(n,e,t,o){return Pt(n,e,t?hr(t,o):void 0)}function Pt(n,e,t){let o=[...e].filter(bo);if(!t||o.length===0)return n;let s=[...e].filter(l=>!bo(l)),a=s.length?`(${s.map(Fi).join(" || ")} || ${t})`:t;return n?`(${n}) && ${a}`:a}function _o(n,e){let t=n.attrs.cancel_in_progress;return typeof t=="boolean"&&Xs.has(n.type)?t:e}function ia(n,e){if(n.attrs.schedule!==void 0)return{group:n.id,"cancel-in-progress":_o(n,!1)};let t=vn(n)||n.type==="human-gate",o=t?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}",s=_o(n,n.type==="issue-agent");return e!==void 0&&t?{group:`\${{ github.event.action == 'labeled' && github.event.label.name != ${be(e)} && format(${be(`${n.id}-noop-{0}`)}, github.run_id) || format(${be(`${n.id}-{0}`)}, github.event.pull_request.number) }}`,"cancel-in-progress":s}:{group:`${n.id}-${o}`,"cancel-in-progress":s}}var ra=["synchronize","reopened","ready_for_review","labeled","unlabeled","review_requested","review_request_removed"];function oa(n){let e="github.event.pull_request";return`github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (${[`${e}.state == 'open'`,`${e}.base.ref == ${be(n)}`,`${e}.head.repo.full_name == github.repository`,"github.actor != 'dependabot[bot]'"].join(" && ")})`}function $o(n){let e={},t=new Map(n.nodes.map(c=>[c.id,c])),o=new Map;for(let c of n.nodes)o.set(c.id,[]);for(let c of n.edges)o.get(c.to)?.push(c);let s=Qe(n),a=At(n.config),l=n.config.identity?.bot_login;for(let c of n.nodes){if(c.type==="start"||c.type==="exit"||s.memberIds.has(c.id))continue;let p=s.byFanin.get(c.id);if(p){let q=p.entryEdge,U=t.get(p.legIds[0]),X={},de=(q.on??"").split(",").map(N=>N.trim()).filter(Boolean);for(let N of de)$n(X,N,U);let oe={nodeId:c.id,triggers:X,dispatches:[]},pe=new Set(de.map(N=>Ht(N,U))),ue;try{ue=kt(n.config)}catch{ue=[St]}let M=q.when?En(q.when,[...pe],n.config):void 0,ae=a?Pt(M,pe,ri(a,l,!1)):yo(wo(M,pe,n.config),pe,ue);ae&&(oe.guard=ae);let se=de.some(N=>Ht(N,U).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";oe.concurrency={group:`${c.id}-${se}`,"cancel-in-progress":!1},e[c.id]=oe;continue}if(c.type==="parallel"||c.type==="fan_in")continue;let u={},r=new Set,h=new Set,f=new Set,m=[],$=c.type==="merge-gate"&&Ye(c)!==void 0,w=a!==void 0&&(pn(c)||je(c)),y=a?pn(c)?a.optInLabel:void 0:Ke(c,n.config),C=!1;if(c.attrs.schedule!==void 0)u.schedule=[{cron:String(c.attrs.schedule)}],u.workflow_dispatch={},$&&(u.pull_request={types:[...ra]},u.pull_request_review={types:["submitted","dismissed"]});else{for(let q of o.get(c.id)??[]){let U=Zs(q,c,n.config);if(U){for(let X of U.events)$n(u,X,c);for(let X of U.events)f.add(Ht(X,c));if(U.guard)r.add(U.guard);else for(let X of U.events)h.add(Ht(X,c))}}if(u.pull_request&&Se(c,n.config)&&(w||Ee(c).some(q=>q.kind==="draft"))&&($n(u,"pull_request.ready_for_review",c),f.add("pull_request.ready_for_review"),h.add("pull_request.ready_for_review")),y&&u.pull_request&&Se(c,n.config)&&(f.has("pull_request.labeled")?h.has("pull_request.labeled")||r.add(`(${Fi("pull_request.labeled")} && github.event.label.name == ${be(y)})`):($n(u,"pull_request.labeled",c),f.add("pull_request.labeled"),h.add("pull_request.labeled"),C=!0)),r.size&&h.size)for(let q of h)r.add(Fi(q))}for(let q of n.edges)q.from===c.id&&q.do&&m.push({toNode:q.to,when:q.when});let P=r.size?[...r].join(" || "):void 0,F=w?Pt(P,f,ri(a,l,je(c))):yo(wo(P,f,n.config),f,Ne(c,n.config),y);C&&y&&(F=Pt(F,f,`(github.event.action != 'labeled' || github.event.label.name == ${be(y)})`));let j={nodeId:c.id,triggers:u,dispatches:m};F&&(j.guard=F),Object.keys(u).length&&(j.concurrency=ia(c,C?y:void 0)),$&&(j.guard=oa(n.config.repo.base_branch),j.concurrency={group:`\${{ github.event.pull_request.number && format('${c.id}-pr-{0}', github.event.pull_request.number) || '${c.id}' }}`,"cancel-in-progress":"${{ github.event.pull_request.number != null }}"}),e[c.id]=j}return{perNode:e}}I();I();var ji="${{ github.event.pull_request.number }}",sa=10,Eo=3,vo=3,aa=600;function So(n){return ve(n.node)?ha(n):Se(n.node,n.config)?Je(n.config)?da(n):pa(n):null}function ko(n){return ve(n.node)?fa(n):null}var Ao='(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',la=["[ .[] | select(.commit_id == env.SHA)",` | select(${Ao})`,` | select(${Rt}) ] | length`],ua=[`[ .[] | select(${Ao}) | ${Rt} 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"],ca="github-actions";function Ro(n,e,t){let o=n.node;e.MARKER_PREFIX=fn(o),e.ALSO_HEAD_PREFIX=gr(o),e.EVENT_ACTION="${{ github.event.action }}",e.STAMP_TOKEN=ne(n),t.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. Skip only once the marker is there: a sweep with"," # requires_review selects a head only on a review that covers it, so a"," # skip without the marker would leave the head unreviewed and never"," # selected. If the read or the edit fails, the lane runs again instead.",' MARK="$ALSO_HEAD_PREFIX$HEAD_SHA -->"',' MARKED=""',` if BODY=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$LAST_ID" --jq '.body // ""' 2>/dev/null); then`,' case "$BODY" in',' *"$MARK"*) MARKED=1 ;;',' *) if 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; then MARKED=1; fi ;;`," esac"," fi",' if [ -n "$MARKED" ]; then',' skip "the diff is unchanged since the last review"'," fi",' echo "::notice::the diff is unchanged since review $LAST_ID, but it could not be marked as covering $HEAD_SHA \u2014 running the lane again"'," fi","else",' echo "::warning::could not hash the diff of PR #$PR \u2014 not skipping on unchanged-diff"',"fi")}function da(n){let e=n.node,t=je(e),o=!t&&Ee(e).some(f=>f.kind==="unchanged-diff"),s=At(n.config),a=n.config.runtime?.mode==="vendored",l=[];a&&l.push({uses:"actions/checkout@v5",name:"Checkout the scope action (base ref)",with:{ref:"${{ github.event.pull_request.base.ref }}","sparse-checkout":".github/actions/pr-scope","fetch-depth":1,"persist-credentials":!1}}),l.push({uses:n.actionRef("pr-scope"),id:"scope",name:t?"Is this a PR the pipeline wrote?":"Is this PR in scope?",with:{number:ji,token:"${{ github.token }}",...s&&Object.keys(s).length?{rollout:JSON.stringify(s)}:{},...n.config.identity?.bot_login?{"bot-login":n.config.identity.bot_login}:{},...n.config.repo?.branch_prefix?{"branch-prefix":n.config.repo.branch_prefix}:{},...t?{"require-agent-written":"true"}:{}}});let c={jobId:Ie(e),name:`${e.id} guard`,displayName:`${e.id} guard`,timeoutMinutes:5};if(!o)return{...c,permissions:{contents:"read","pull-requests":"read"},outputs:{run:"${{ steps.scope.outputs.run }}",reason:"${{ steps.scope.outputs.reason }}",head_sha:"",diff_hash:"",started_at:""},steps:l};let p={GH_TOKEN:"${{ github.token }}",PR:ji,NODE:e.id,BOT_LOGIN:n.config.identity?.bot_login??"",SCOPE_RUN:"${{ steps.scope.outputs.run }}",SCOPE_REASON:"${{ steps.scope.outputs.reason }}"},u=['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; }',"","# Scope was decided by the step above, by the rule every lane and the gate share.",'if [ "$SCOPE_RUN" != "true" ]; then skip "$SCOPE_REASON"; fi',"","# From here on only the unchanged-diff skip, which fails OPEN: a lane that runs","# once too often costs a run, one wrongly skipped costs a review nobody misses.",'PR_JSON=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" 2>/dev/null) || PR_JSON=""','if [ -z "$PR_JSON" ]; then',' echo "::warning::could not read PR #$PR \u2014 not skipping on unchanged-diff"'," finish","fi",`HEAD_SHA=$(jq -r '.head.sha // ""' <<< "$PR_JSON")`,""];Ro(n,p,u),u.push("","finish");let r=qe(n,{"pull-requests":"write"}),h=ne(n)==="${{ github.token }}";return r&&l.push({...r,if:"${{ steps.scope.outputs.run == 'true' }}"}),l.push(ie({id:"decide",name:"Decide whether to run",env:p,run:u.join(`
|
|
224
|
+
`)})),{...c,permissions:{contents:"read","pull-requests":h?"write":"read"},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:l}}function pa(n){let e=n.node,t=Ee(e),o=Ne(e,n.config),s=Ke(e,n.config),a={GH_TOKEN:"${{ github.token }}",PR:ji,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 c=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"){c+=1;let f=`SKIP_LABEL_${c}`;a[f]=n.config.labels?.[h.label]??h.label,l.push(`# label:${h.label}`,`if jq -e --arg l "$${f}" 'any(.labels[]?; .name == $l)' <<< "$PR_JSON" >/dev/null; then`,` skip "the PR carries the label $${f}"`,"fi")}else Ro(n,a,l);l.push("","finish");let p=t.some(h=>h.kind==="unchanged-diff"),u=p?qe(n,{"pull-requests":"write"}):void 0,r=p&&ne(n)==="${{ github.token }}";return{jobId:Ie(e),name:`${e.id} skip guard`,displayName:`${e.id} guard`,permissions:{contents:"read","pull-requests":r?"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:[...u?[u]:[],ie({id:"decide",name:"Decide whether to run",env:a,run:l.join(`
|
|
225
|
+
`)})]}}function ha(n){let e=n.node,t=Ne(e,n.config),o=Ke(e,n.config),s='((.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a))',a=Ee(e),l=a.some($=>$.kind==="bot-author"),c={};for(let $ of a)$.kind==="label"&&(c[`SKIP_LABEL_${Object.keys(c).length+1}`]=n.config.labels?.[$.label]??$.label);let p=['LIST=$(list_prs) || { sleep "${LIST_RETRY_SECONDS:-5}"; LIST=$(list_prs); } || {',' echo "::notice::could not list open pull requests this tick \u2014 nothing selected; the next sweep tries again"',' { echo "prs=[]"; echo "count=0"; } >> "$GITHUB_OUTPUT"'," exit 0","}"],u=Je(n.config),r=u?["# The candidates were listed and scoped by the step above: the rollout rule","# every lane and the gate share, not a copy of it here.",'if [ "$SCOPE_LISTED" != "true" ]; then',' echo "::notice::could not list open pull requests this tick \u2014 nothing selected; the next sweep tries again"',' { echo "prs=[]"; echo "count=0"; } >> "$GITHUB_OUTPUT"'," exit 0","fi",`LIST=$(jq -r '.[] | "\\(.number) \\(.sha) \\(.requested) \\(.quiet) \\(.base)"' <<< "$SCOPED")`]:["list_prs() {",` 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(c).map($=>` | select((.labels // []) | any(.name == env.${$}) | not)`),` | "\\(.number) \\(.head.sha) \\((.requested_reviewers | length) + (.requested_teams | length)) \\(now - (.updated_at | fromdateiso8601) | floor) \\(.base.ref)"'`,"}",...p],h=At(n.config),f=u?[...n.config.runtime?.mode==="vendored"?[{uses:"actions/checkout@v5",name:"Checkout the scope action",with:{"sparse-checkout":".github/actions/pr-scope","fetch-depth":1,"persist-credentials":!1}}]:[],{uses:n.actionRef("pr-scope"),id:"scope",name:"List the pull requests in scope",with:{list:"true",token:"${{ github.token }}","base-branch":n.config.repo.base_branch,...ln(e)&&n.config.identity?.bot_login?{"reviewed-by":n.config.identity.bot_login}:{},...h&&Object.keys(h).length?{rollout:JSON.stringify(h)}:{},...n.config.identity?.bot_login?{"bot-login":n.config.identity.bot_login}:{}}}]:[],m=["# 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.","#",u?"# candidate open and in scope by the rollout (decided by the step above)":`# candidate open, not a draft, on a harness branch${t?", by an allowlisted author":""}${o?" or labelled $OPT_IN_LABEL":""}`,...l||Object.keys(c).length?[`# not skipped ${[l?"not opened by a bot (the harness's own is exempt)":"",Object.keys(c).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)",...ln(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",...r,"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 '`,...ua.map($=>` ${$}`),` ' | 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(`
|
|
226
|
+
`);return{jobId:Ie(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:[...f,ie({id:"select",name:"Select pull requests ready for a decision",env:{GH_TOKEN:"${{ github.token }}",...u?{SCOPED:"${{ steps.scope.outputs.prs }}",SCOPE_LISTED:"${{ steps.scope.outputs.listed }}"}:{},PREFIX:n.config.repo.branch_prefix,BOT_LOGIN:n.config.identity?.bot_login??"",VERDICT_LINES:st(n.config),REQUIRES_REVIEW:String(ln(e)),ALSO_HEAD_PATTERN:fr,SWEPT_CHECK:ai(e),FAILED_CHECK:oi(e),IDLE_CHECK:si(e),MAX_IDLE:String(vo),MARK_APP:ca,LIMIT:String(sa),MAX_FAILURES:String(Eo),SETTLE_SECONDS:String(aa),...t?{AUTHORS:t.join(",")}:{},...o?{OPT_IN_LABEL:o}:{},...c},run:m})]}}function fa(n){let e=n.node,t=Ie(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:st(n.config),JOB_PREFIX:hn(e),SWEPT_CHECK:ai(e),FAILED_CHECK:oi(e),IDLE_CHECK:si(e),MAX_IDLE:String(vo),MAX_FAILURES:String(Eo),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 '`,...la.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(`
|
|
227
|
+
`)})]}}I();var To=[" /^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 qi="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.",ga=`${qi}
|
|
228
228
|
# Edit harness.dot / roles / foundry.config.yaml and run \`gp-foundry build\`.
|
|
229
|
-
`;function
|
|
230
|
-
`)}]}}}}function
|
|
229
|
+
`;function ma(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??Ot();return s=>`${t}/actions/${s}@${o}`}function ba(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),ur(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 Oo(n){return String(n.attrs.title??n.attrs.name??n.id)}function wa(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":ii(void 0,n),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 '",...To,` ' "$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(`
|
|
230
|
+
`)}]}}}}function ya(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=ma(n.config),l=new Map(n.nodes.map(m=>[m.id,m])),c=new Map,p=new Map;for(let m of n.nodes)c.set(m.id,[]),p.set(m.id,[]);for(let m of n.edges)c.get(m.from)?.push(m),p.get(m.to)?.push(m);let u=m=>({config:n.config,node:m,outEdges:c.get(m.id)??[],inEdges:p.get(m.id)??[],actionRef:a,nodeById:$=>l.get($),specDir:t,specFile:(n.sourcePath??"harness.dot").split(/[\\/]/).pop()||"harness.dot",roleTools:o.roleTools}),r=(m,$,w)=>{let y={};m.displayName&&(y.name=m.displayName),y["runs-on"]=ii($,n.config);let C=m.if??w;return C&&(y.if=C),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(ba),y},h=(m,$)=>{let w=He.dump($,{lineWidth:-1,noRefs:!0,quotingType:'"'});s.push({path:`.github/workflows/${m}.yml`,contents:ga+w,generated:!0})},f=Qe(n);ya(n)&&h("immutable-guard",wa(n.config,t));for(let m of n.nodes){if(f.memberIds.has(m.id))continue;let $=e.perNode[m.id];if(!$||Object.keys($.triggers).length===0)continue;let w=f.byFanin.get(m.id);if(w){let j={};for(let X of w.legIds){let{skip:de,select:oe,...pe}=l.get(X).attrs,ue={...l.get(X),attrs:pe},M=hi(ue,n,u(ue));M&&(j[M.jobId]=r(M,ue,$.guard))}let q=JSON.stringify($.triggers).includes('"pull_request"'),U=Sr(u(m),w.legIds,q);j[U.jobId]=r(U,m),h(m.id,{name:Oo(m),on:$.triggers,...$.concurrency?{concurrency:$.concurrency}:{},permissions:{contents:"read"},jobs:j});continue}let y=hi(m,n,u(m));if(!y)continue;let C=So(u(m)),P=C?{[C.jobId]:r(C,m,$.guard),[y.jobId]:r(y,m)}:{[y.jobId]:r(y,m,$.guard)},F=ko(u(m));F&&(P[F.jobId]=r(F,m)),h(m.id,{name:Oo(m),on:$.triggers,...$.concurrency?{concurrency:$.concurrency}:{},permissions:{contents:"read"},jobs:P})}return s}I();function _a(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 $a(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 Ea(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}${va(n)}</small>`}function va(n){let e=Ye(n);if(!e&&!we(n))return"";let t=e?`merge ${e}`:"evaluate",o;try{o=Fe(n)}catch{return` \xB7 ${t}`}return` \xB7 ${t} \u2192 check ${o.replace(/"/g,"'")}`}function Sn(n,e){let t=["```mermaid","flowchart TD"];for(let s of n.nodes){let[a,l]=$a(s);t.push(` ${s.id}${a}"${Ea(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}\` | ${_a(s.triggers)} |`);t.push("")}return`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
|
|
231
231
|
|
|
232
232
|
# ${n.config?.name&&n.config.name!=="harness"?n.config.name:n.name} \u2014 agent harness
|
|
233
233
|
|
|
234
234
|
${t.join(`
|
|
235
|
-
`)}`}
|
|
235
|
+
`)}`}I();var Sa=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),ka=new Set(["role","prompt","policy","tools"]);function Aa(n){let e=[],t=[],o=1,s=0,a=n;for(;s<a.length;){let l=a[s];if(l===`
|
|
236
236
|
`){o++,s++;continue}if(l===" "||l===" "||l==="\r"){s++;continue}if(l==="/"&&a[s+1]==="/"){for(;s<a.length&&a[s]!==`
|
|
237
237
|
`;)s++;continue}if(l==="/"&&a[s+1]==="*"){for(s+=2;s<a.length&&!(a[s]==="*"&&a[s+1]==="/");)a[s]===`
|
|
238
|
-
`&&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
|
|
239
|
-
`&&o++,p+=a[
|
|
240
|
-
`)}function
|
|
241
|
-
`),e.hint&&process.stderr.write(` ${
|
|
242
|
-
`)}}function Le(n){let e=(0,ge.resolve)(n.dot??".github/harness.dot"),t=(0,ge.dirname)(e),o=n.config?(0,ge.resolve)(n.config):void 0;if(!o){for(let a of[(0,ge.join)(t,"foundry.config.yaml"),(0,ge.join)(t,"agents/foundry.config.yaml")])if((0,Pe.existsSync)(a)){o=a;break}}let s=t.endsWith(".github")?(0,ge.dirname)(t):t;return{dot:e,config:o,base:t,root:s}}function jt(n){return e=>{let t=(0,ge.join)(n,e);try{return(0,Pe.existsSync)(t)?(0,Pe.readFileSync)(t,"utf8"):void 0}catch{return}}}
|
|
238
|
+
`&&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 c=s+1,p="";for(;c<a.length&&a[c]!=='"';){if(a[c]==="\\"&&c+1<a.length){p+=a[c+1],c+=2;continue}a[c]===`
|
|
239
|
+
`&&o++,p+=a[c],c++}c>=a.length&&t.push({message:"unterminated string",line:o}),e.push({kind:"id",value:p,line:o}),s=c+1;continue}if(/[A-Za-z0-9_]/.test(l)){let c=s,p="";for(;c<a.length&&/[A-Za-z0-9_.\-]/.test(a[c]);)p+=a[c],c++;e.push({kind:"id",value:p,line:o}),s=c;continue}t.push({message:`unexpected character '${l}'`,line:o}),s++}return{toks:e,errors:t}}function Ra(n){return n==="true"?!0:n==="false"?!1:/^-?\d+$/.test(n)?Number(n):n}function Lt(n){let{toks:e,errors:t}=Aa(n),o=[],s=[],a=new Map,l="harness",c=0,p=()=>e[c],u=()=>e[c++],r=(w,y)=>t.push({message:w,line:y});p()?.kind==="id"&&p()?.value==="digraph"?(u(),p()?.kind==="id"&&p()?.value!==void 0&&(l=u().value),p()?.kind==="lbrace"?u():r("expected '{' after digraph header",p()?.line)):r("expected 'digraph' keyword",p()?.line);function h(){let w={};if(p()?.kind!=="lbrack")return{attrs:w};let y=u().line;for(;p()&&p().kind!=="rbrack";){let C=u();if(!C||C.kind!=="id"){r("expected attribute name",C?.line);break}if(p()?.kind!=="eq"){r(`expected '=' after attribute '${C.value}'`,C.line);break}u();let P=u();if(!P||P.kind!=="id"){r(`expected value for attribute '${C.value}'`,P?.line);break}w[C.value]=P.value,p()?.kind==="comma"&&u()}return p()?.kind==="rbrack"?u():r("unterminated attribute list '['",y),{attrs:w,line:y}}function f(w,y){let C=a.get(w);return C||(C={id:w,type:"analyst",attrs:{},files:{},raw:{},line:y},a.set(w,C),o.push(C)),C}function m(w,y,C){w.declared=!0,w.raw={...w.raw,...y},C!==void 0&&(w.line=w.line??C);for(let[P,F]of Object.entries(y))P==="type"?(Sa.has(F)||r(`unknown node type '${F}' on node '${w.id}'`,C),w.type=F):P==="context"?w.context=F:ka.has(P)?w.files[P]=F:w.attrs[P]=Ra(F)}let $=0;for(;p()&&p().kind!=="rbrace"&&!($++>1e5);){let w=p();if(w.kind==="semi"){u();continue}if(w.kind!=="id"){r(`unexpected token '${w.value}'`,w.line),u();continue}let y=u();if(p()?.kind==="arrow"){let C=[{id:y.value,line:y.line}];for(;p()?.kind==="arrow";){u();let j=u();if(!j||j.kind!=="id"){r("expected node id after '->'",j?.line);break}C.push({id:j.value,line:j.line})}let{attrs:P,line:F}=h();for(let j=0;j+1<C.length;j++){let q=C[j],U=C[j+1];f(q.id,q.line),f(U.id,U.line);let X={from:q.id,to:U.id,raw:{...P},line:F??q.line};P.on!==void 0&&(X.on=P.on),P.when!==void 0&&(X.when=P.when),P.do!==void 0&&(X.do=P.do),s.push(X)}}else{let{attrs:C,line:P}=h(),F=f(y.value,y.line);m(F,C,P??y.line)}p()?.kind==="semi"&&u()}return p()?.kind==="rbrace"&&u(),{name:l,nodes:o,edges:s,errors:t}}I();var Dt=require("fs");var gt={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 kn(n){if(!n||!(0,Dt.existsSync)(n))return structuredClone(gt);let e=He.load((0,Dt.readFileSync)(n,"utf8"))??{};return{...gt,...e,identity:{...gt.identity,...e.identity??{}},agent:{...gt.agent,...e.agent??{}},repo:{...gt.repo,...e.repo??{}},labels:{...gt.labels,...e.labels??{}}}}function ke(n,e){let t=Lt((0,Dt.readFileSync)(n,"utf8")),o=kn(e);return{harness:{name:t.name,nodes:t.nodes,edges:t.edges,config:o,sourcePath:n},parseErrors:t.errors}}function mt(n,e={},t={}){let o=[...Nt(n,e),...It(n)],s=c=>{let p=n.nodes.find(h=>h.id===c)?.files.role,u=p&&e.readFile?e.readFile(p):void 0;if(u===void 0)return;let r=ht(u)?.tools;return typeof r=="string"?r:void 0},a=$o(n),l=Co(n,a,t.specDir??"",{roleTools:s});return l.push({path:".github/HARNESS.md",contents:Sn(n,a),generated:!0}),{files:l,diagnostics:o}}function Mt(n){return n.some(e=>e.level==="error")}I();var Pe=require("fs"),ge=require("path"),xo=require("url"),Ze=zt(nn(),1);function Ft(n,e){let t=(0,ge.join)(n,".github","workflows");if(!(0,Pe.existsSync)(t))return[];let o=new Set(e.map(s=>s.path));return(0,Pe.readdirSync)(t).filter(s=>/\.ya?ml$/.test(s)).map(s=>`.github/workflows/${s}`).filter(s=>!o.has(s)).filter(s=>(0,Pe.readFileSync)((0,ge.join)(n,s),"utf8").startsWith(qi)).sort()}function me(n){return(0,xo.fileURLToPath)(new URL(`../../${n}`,B))}function Q(n){process.stdout.write(JSON.stringify(n,null,2)+`
|
|
240
|
+
`)}function Ui(n){for(let e of n){let t=e.level==="error"?Ze.default.red("error"):e.level==="warning"?Ze.default.yellow("warn"):Ze.default.blue("info"),o=e.where?.node?Ze.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${t} ${Ze.default.dim(e.code)}${o} ${e.message}
|
|
241
|
+
`),e.hint&&process.stderr.write(` ${Ze.default.dim("hint: "+e.hint)}
|
|
242
|
+
`)}}function Le(n){let e=(0,ge.resolve)(n.dot??".github/harness.dot"),t=(0,ge.dirname)(e),o=n.config?(0,ge.resolve)(n.config):void 0;if(!o){for(let a of[(0,ge.join)(t,"foundry.config.yaml"),(0,ge.join)(t,"agents/foundry.config.yaml")])if((0,Pe.existsSync)(a)){o=a;break}}let s=t.endsWith(".github")?(0,ge.dirname)(t):t;return{dot:e,config:o,base:t,root:s}}function jt(n){return e=>{let t=(0,ge.join)(n,e);try{return(0,Pe.existsSync)(t)?(0,Pe.readFileSync)(t,"utf8"):void 0}catch{return}}}I();var Bi=require("child_process"),W=require("fs"),Y=require("path");var V=zt(nn(),1);var Gi=require("path");function bt(n,e={}){try{return{ok:!0,out:(0,Bi.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 Be(n,e){let t=bt(n,{cwd:e});if(!t.ok)return null;try{return JSON.parse(t.out)}catch{return null}}function Po(){let n=me("actions");return(0,W.readdirSync)(n,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(0,W.existsSync)((0,Y.join)(n,e.name,"action.yml"))).map(e=>e.name)}function Lo(n){let e=kn(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 No(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}
|
|
243
243
|
`),t.hint&&t.status!=="ok"&&process.stdout.write(` ${V.default.dim("hint: "+t.hint)}
|
|
244
|
-
`)}function
|
|
244
|
+
`)}function Ta(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,W.existsSync)(a))return!0;try{let l=He.load((0,W.readFileSync)(a,"utf8"));return(l?.require_ci??l?.requireCi)!==!1}catch{return!0}})}function Io(n){let e=[];for(let o of Po()){let s=me(`actions/${o}`),a=(0,Y.join)(n,".github/actions",o);(0,W.mkdirSync)(a,{recursive:!0}),(0,W.cpSync)((0,Y.join)(s,"action.yml"),(0,Y.join)(a,"action.yml")),(0,W.existsSync)((0,Y.join)(s,"dist"))&&(0,W.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,W.existsSync)(t)||((0,W.mkdirSync)((0,Y.dirname)(t),{recursive:!0}),(0,W.writeFileSync)(t,(0,W.readFileSync)(me("skill/templates/agent-setup.yml"),"utf8")),e.push(".github/agent-setup/action.yml")),e}function Oa(n){(0,W.mkdirSync)(n,{recursive:!0}),(0,W.cpSync)(me("skill/SKILL.md"),(0,Y.join)(n,"SKILL.md")),(0,W.cpSync)(me("skill/reference"),(0,Y.join)(n,"reference"),{recursive:!0}),(0,W.cpSync)(me("skill/templates"),(0,Y.join)(n,"templates"),{recursive:!0})}function Ho(n){let e=[],{dot:t,config:o,base:s,root:a}=Le(n);if(!(0,W.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:c}=ke(t,o),p=M=>(0,W.existsSync)((0,Y.join)(s,M)),u=(0,Gi.relative)(a,s).replace(/\\/g,"/"),{files:r,diagnostics:h}=mt(l,{fileExists:p,readFile:jt(s)},{specDir:u}),f=h.filter(M=>M.level==="error").length+c.length,m=h.filter(M=>M.level==="warning");e.push(f?{name:"validate",status:"fail",detail:`${f} 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(M=>M.code).join(", ")}`:"no diagnostics"});let $=r.filter(M=>{let ae=(0,Y.join)(a,M.path);return((0,W.existsSync)(ae)?(0,W.readFileSync)(ae,"utf8"):null)!==M.contents}),w=Ft(a,r),y=[...$.map(M=>M.path),...w.map(M=>`${M} (stale)`)];if(e.push(y.length?{name:"workflows in sync",status:"fail",detail:`${y.length} file(s) out of sync: ${y.slice(0,3).join(", ")}${y.length>3?", \u2026":""}`,hint:"run `gp-foundry build`"}:{name:"workflows in sync",status:"ok",detail:`${r.length} generated files match`}),(l.config.runtime?.mode??"pinned")==="vendored"){let M=Po().filter(ae=>!(0,W.existsSync)((0,Y.join)(a,".github/actions",ae,"action.yml")));e.push(M.length?{name:"vendored actions",status:"fail",detail:`missing: ${M.join(", ")}`,hint:"run `gp-foundry vendor`"}:{name:"vendored actions",status:"ok",detail:"all runtime actions vendored"})}if(e.push((0,W.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`)"}),!bt(["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(M=>M.status==="fail")};e.push({name:"gh cli",status:"ok",detail:"authenticated"});let P=Be(["repo","view","--json","nameWithOwner,defaultBranchRef"],a);if(!P)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(M=>M.status==="fail")};e.push({name:"github repo",status:"ok",detail:P.nameWithOwner});let F=P.defaultBranchRef?.name;F&&e.push(F===l.config.repo.base_branch?{name:"base branch",status:"ok",detail:F}:{name:"base branch",status:"fail",detail:`config says '${l.config.repo.base_branch}' but the repo default is '${F}'`,hint:"fix repo.base_branch in foundry.config.yaml and re-run `gp-foundry up`"});let j=new Set((Be(["label","list","--json","name","--limit","1000"],a)??[]).map(M=>M.name)),q=Lo(o).map(M=>M.name),U=q.filter(M=>!j.has(M));e.push(U.length?{name:"labels",status:"fail",detail:`missing: ${U.join(", ")}`,hint:"run `gp-foundry up` to create them"}:{name:"labels",status:"ok",detail:q.join(", ")});let X=new Set((Be(["secret","list","--json","name"],a)??[]).map(M=>M.name)),de=[l.config.agent.api_key_secret||(l.config.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")],oe=l.config.auth;oe?.mode==="pat"&&oe.token_secret&&de.push(oe.token_secret),oe?.mode==="app"&&de.push(oe.app_id_secret??"APP_ID",oe.app_key_secret??"APP_PRIVATE_KEY");let pe=de.filter(M=>!X.has(M));if(e.push(pe.length?{name:"secrets",status:"fail",detail:`missing: ${pe.join(", ")}`,hint:`gh secret set ${pe[0]}`}:{name:"secrets",status:"ok",detail:de.join(", ")}),Ta(l,a)){let ae=r.filter(se=>/\/workflows\/.*\.yml$/.test(se.path)&&se.contents.includes("actions/merge-gate")).map(se=>(0,Y.join)(a,se.path)).filter(se=>(0,W.existsSync)(se)).map(se=>(0,W.readFileSync)(se,"utf8")),Z=ae.filter(se=>!se.includes("checks-token"));ae.length&&Z.length&&e.push({name:"merge gate ci read",status:"fail",detail:`${Z.length} merge-gate workflow(s) read check-runs with the harness token`,hint:"a fine-grained PAT cannot be granted the Checks permission, so that read 403s and nothing merges \u2014 run `gp-foundry build` to pass GITHUB_TOKEN instead, then commit"})}let ue=bt(["--version"]);try{let M=(0,Bi.execFileSync)("git",["status","--porcelain",".github"],{cwd:a,encoding:"utf8"}).trim();e.push(M?{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(M=>M.status==="fail")}}function Ca(n){let{dot:e,config:t,root:o}=Le(n);if(!bt(["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=Be(["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}=ke(e,t),l=a.config.repo.branch_prefix,c=Date.now(),p=y=>Math.round((c-Date.parse(y))/36e5),u={};for(let y of["plan","build","needs-human"]){let C=y==="needs-human"?"needs-human":a.config.labels?.[y]??y,P=Be(["issue","list","--label",C,"--state","open","--json","number,title,createdAt","--limit","50"],o)??[];u[C]=P.map(F=>({number:F.number,title:F.title,ageHours:p(F.createdAt)}))}let h=(Be(["pr","list","--state","open","--json","number,title,labels,mergeable,headRefName,body,updatedAt","--limit","50"],o)??[]).filter(y=>y.headRefName.startsWith(l)),f=[],m=new Set;for(let y of h)for(let C of y.body?.matchAll(/[Cc]loses #(\d+)/g)??[])m.add(Number(C[1]));let $=a.config.labels?.build??"build";for(let y of u[$]??[])!m.has(y.number)&&y.ageHours>=2&&f.push({kind:"issue-no-pr",number:y.number,title:y.title,detail:`labeled ${$} ${y.ageHours}h ago, no open PR closes it`});for(let y of h)y.updatedAt&&p(y.updatedAt)>=4&&f.push({kind:"pr-idle",number:y.number,title:y.title,detail:`no activity for ${p(y.updatedAt)}h`});let w=(Be(["run","list","--status","failure","--limit","15","--json","name,url,createdAt,conclusion"],o)??[]).filter(y=>p(y.createdAt)<=24).map(y=>({workflow:y.name,url:y.url,ageHours:p(y.createdAt)}));return{repo:s.nameWithOwner,lanes:u,prs:h.map(y=>({number:y.number,title:y.title,labels:y.labels.map(C=>C.name),mergeable:y.mergeable,headRefName:y.headRefName})),stalled:f,recentFailures:w}}function Do(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=Io(e.dir);if(e.json)return Q({written:t});for(let o of t)process.stdout.write(V.default.green(`vendored ${o}
|
|
245
245
|
`));process.stdout.write(V.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
|
|
246
|
-
`))}),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(
|
|
246
|
+
`))}),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(Oa(o),e.json)return Q({installed:o});process.stdout.write(V.default.green(`installed skill \u2192 ${o}
|
|
247
247
|
`)),process.stdout.write(V.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
|
|
248
248
|
The skill interviews you Socratically, drafts harness.dot + roles, and drives this CLI.
|
|
249
|
-
`))}),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}=Ho(e);e.json?
|
|
249
|
+
`))}),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}=Ho(e);e.json?Q({ok:!o,checks:t}):(No(t),process.stdout.write(o?V.default.red(`
|
|
250
250
|
not ready \u2014 fix the \u2717 items above
|
|
251
251
|
`):V.default.green(`
|
|
252
252
|
factory is ready
|
|
253
|
-
`))),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=
|
|
253
|
+
`))),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=Ca(e);if("error"in t&&(e.json?Q(t):(process.stderr.write(V.default.red(t.error+`
|
|
254
254
|
`)),t.hint&&process.stderr.write(V.default.dim("hint: "+t.hint+`
|
|
255
|
-
`))),process.exit(1)),e.json)return
|
|
255
|
+
`))),process.exit(1)),e.json)return Q(t);process.stdout.write(V.default.bold(`
|
|
256
256
|
${t.repo} \u2014 factory status
|
|
257
257
|
|
|
258
258
|
`));for(let[o,s]of Object.entries(t.lanes)){process.stdout.write(V.default.cyan(`${o} (${s.length})
|
|
@@ -268,34 +268,34 @@ failed runs, last 24h (${t.recentFailures.length})
|
|
|
268
268
|
`));for(let o of t.recentFailures.slice(0,10))process.stdout.write(` ${o.workflow} ${V.default.dim(`${o.ageHours}h ago`)} ${o.url}
|
|
269
269
|
`)}!t.stalled.length&&!t.recentFailures.length&&process.stdout.write(V.default.green(`
|
|
270
270
|
no stalled work, no recent failures
|
|
271
|
-
`))}),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}=Le(e),l={};if(
|
|
272
|
-
`))}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:
|
|
273
|
-
`)));let p=y=>(0,W.existsSync)((0,Y.join)(s,y)),u=(0,Gi.relative)(a,s).replace(/\\/g,"/"),{files:r,diagnostics:h}=
|
|
271
|
+
`))}),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}=Le(e),l={};if(bt(["auth","status"]).ok&&Be(["repo","view","--json","nameWithOwner"],a)){let y=[];for(let C of Lo(o))bt(["label","create",C.name,"--color",C.color,"--description",C.description],{cwd:a}).ok&&y.push(C.name);l.labels=y,e.json||process.stdout.write(V.default.green(`labels ensured (created: ${y.length?y.join(", "):"none \u2014 already present"})
|
|
272
|
+
`))}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:c}=ke(t,o);(c.config.runtime?.mode??"pinned")==="vendored"&&(l.vendored=Io(a),e.json||process.stdout.write(V.default.green(`vendored ${l.vendored.length} runtime action(s)
|
|
273
|
+
`)));let p=y=>(0,W.existsSync)((0,Y.join)(s,y)),u=(0,Gi.relative)(a,s).replace(/\\/g,"/"),{files:r,diagnostics:h}=mt(c,{fileExists:p,readFile:jt(s)},{specDir:u});Mt(h)&&(e.json?Q({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 y of r){let C=(0,Y.join)(a,y.path);(0,W.mkdirSync)((0,Y.dirname)(C),{recursive:!0}),(0,W.writeFileSync)(C,y.contents)}l.wrote=r.map(y=>y.path);let f=Ft(a,r);for(let y of f)(0,W.rmSync)((0,Y.join)(a,y));l.removed=f,f.length&&!e.json&&process.stdout.write(V.default.yellow(`removed ${f.length} stale generated workflow(s): ${f.join(", ")}
|
|
274
274
|
`));let m=r.filter(y=>y.path.startsWith(".github/workflows/")).length;e.json||process.stdout.write(V.default.green(`built ${m} workflows + HARNESS.md
|
|
275
|
-
`));let{checks:$,failed:w}=Ho(e);if(l.checks=$,l.ok=!w,e.json)return
|
|
275
|
+
`));let{checks:$,failed:w}=Ho(e);if(l.checks=$,l.ok=!w,e.json)return Q(l);process.stdout.write(`
|
|
276
276
|
`),No($),process.stdout.write(w?V.default.yellow(`
|
|
277
277
|
almost there \u2014 fix the \u2717 items above, commit .github/, push, then file an issue
|
|
278
278
|
`):V.default.green(`
|
|
279
279
|
factory is up \u2014 commit .github/, push, then file an issue to watch it run
|
|
280
|
-
`)),process.exit(w?1:0)})}var Ge=new sr,
|
|
281
|
-
`));for(let
|
|
280
|
+
`)),process.exit(w?1:0)})}var Ge=new sr,xa=JSON.parse((0,J.readFileSync)(me("package.json"),"utf8")).version;Ge.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(xa);function Na(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,J.existsSync)(s)){let a=ht((0,J.readFileSync)(s,"utf8"));a&&t.set(o.id,a)}}return t}var Ia=[["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"]];Ge.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=(c,p)=>{let u=(0,re.join)(e,c);if((0,J.existsSync)(u)&&!n.force){o.push(c);return}(0,J.mkdirSync)((0,re.dirname)(u),{recursive:!0}),(0,J.writeFileSync)(u,p),t.push(c)},a="main";try{let c=(0,Mo.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();c&&(a=c)}catch{}for(let[c,p]of Ia){let u=(0,J.readFileSync)(me(c),"utf8");p.endsWith("foundry.config.yaml")&&a!=="main"&&(u=u.replace(/^(\s*base_branch:\s*)main\b/m,`$1${a}`)),s(p,u)}let l=(0,re.join)(e,".github/harness.dot");if((0,J.existsSync)(l))for(let c of Lt((0,J.readFileSync)(l,"utf8")).nodes){if(!c.files.role)continue;let p=c.files.role.replace(/^.*\//,"").replace(/\.md$/,""),u=me(`roles/software/${p}.md`),r=(0,J.existsSync)(u)?u:me("skill/templates/role.md");s((0,re.join)(".github",c.files.role),(0,J.readFileSync)(r,"utf8"))}if(n.json)return Q({written:t,skipped:o});for(let c of t)process.stdout.write(K.default.green(`created ${c}
|
|
281
|
+
`));for(let c of o)process.stderr.write(K.default.yellow(`skipped ${c} (exists; --force to overwrite)
|
|
282
282
|
`));process.stdout.write(["",K.default.bold("Next steps \u2014 dark factory in 4 moves:"),` 1. ${K.default.cyan("gp-foundry up")} vendor actions, create labels, build workflows, run checks`,` 2. set two secrets: ${K.default.cyan("gh secret set CLAUDE_CODE_OAUTH_TOKEN")} (agent auth)`,` ${K.default.cyan("gh secret set AGENT_PAT")} (fine-grained PAT: contents/PRs/issues RW)`,` 3. commit + push ${K.default.cyan(".github/")}`," 4. file an issue \u2192 the \u{1F575}\uFE0F scout triages it and the factory takes it from there","",K.default.dim("Merging starts OFF: the gate publishes its verdict on each PR as a check and a person merges."),K.default.dim(`To have the pipeline merge the PRs it wrote, set ${K.default.cyan('merge="agent-only"')} on merge_gate in harness.dot and rebuild.`),"",K.default.dim("Tune later: .github/harness.dot (topology) \xB7 agents/roles/*.md (behavior) \xB7 agents/policy/merge.yaml (merge rules)"),""].join(`
|
|
283
|
-
`))});Ge.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}=Le(n);(0,J.existsSync)(e)||(n.json?
|
|
284
|
-
`)),process.exit(1));let{harness:a,parseErrors:l}=ke(e,t);if(l.length){if(n.json)
|
|
285
|
-
`));process.exit(1)}let
|
|
283
|
+
`))});Ge.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}=Le(n);(0,J.existsSync)(e)||(n.json?Q({error:`no harness.dot at ${e}`}):process.stderr.write(K.default.red(`no harness.dot at ${e}
|
|
284
|
+
`)),process.exit(1));let{harness:a,parseErrors:l}=ke(e,t);if(l.length){if(n.json)Q({parseErrors:l});else for(let m of l)process.stderr.write(K.default.red(`parse: ${m.message}${m.line?` (line ${m.line})`:""}
|
|
285
|
+
`));process.exit(1)}let c=(0,re.resolve)(n.out??s),p=(0,re.relative)(c,o).replace(/\\/g,"/"),u=m=>(0,J.existsSync)((0,re.join)(o,m)),{files:r,diagnostics:h}=mt(a,{fileExists:u,readFile:jt(o)},{specDir:p});n.json||Ui(h);let f=Ft(c,r);if(n.check){let m=r.filter(w=>{let y=(0,re.join)(c,w.path);return((0,J.existsSync)(y)?(0,J.readFileSync)(y,"utf8"):null)!==w.contents}),$=m.length===0&&f.length===0;if(n.json)Q({upToDate:$,drift:m.map(w=>w.path),stale:f,diagnostics:h});else if($)process.stdout.write(K.default.green(`up to date
|
|
286
286
|
`));else{for(let w of m)process.stderr.write(K.default.yellow(`drift: ${w.path}
|
|
287
287
|
`));for(let w of f)process.stderr.write(K.default.yellow(`stale: ${w} (no longer generated)
|
|
288
|
-
`));process.stderr.write(K.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}process.exit($?0:1)}if(Mt(h)&&!n.force&&(n.json?
|
|
289
|
-
`)),process.exit(1)),n.dryRun){if(n.json)
|
|
288
|
+
`));process.stderr.write(K.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}process.exit($?0:1)}if(Mt(h)&&!n.force&&(n.json?Q({ok:!1,diagnostics:h,wrote:[]}):process.stderr.write(K.default.red(`errors present \u2014 not writing (use --force to override)
|
|
289
|
+
`)),process.exit(1)),n.dryRun){if(n.json)Q({diagnostics:h,files:r,stale:f});else{for(let m of r)process.stdout.write(K.default.cyan(`--- ${m.path}
|
|
290
290
|
`)+m.contents+`
|
|
291
291
|
`);for(let m of f)process.stdout.write(K.default.yellow(`would remove ${m} (no longer generated)
|
|
292
|
-
`))}return}for(let m of r){let $=(0,
|
|
293
|
-
`))}for(let m of f)(0,J.rmSync)((0,
|
|
294
|
-
`));n.json&&
|
|
295
|
-
`)),process.exit(1));let{harness:s,parseErrors:a}=ke(e,t),l=r=>(0,J.existsSync)((0,
|
|
296
|
-
`));
|
|
297
|
-
`)),process.exit(1));let{harness:t}=ke(e);n.json?
|
|
298
|
-
`)});Ge.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}=Le(e);(0,J.existsSync)(t)||(e.json?
|
|
299
|
-
`)),process.exit(1));let{harness:s}=ke(t,o),{files:a}=
|
|
300
|
-
`)),process.exit(1)),e.json?
|
|
292
|
+
`))}return}for(let m of r){let $=(0,re.join)(c,m.path);(0,J.mkdirSync)((0,re.dirname)($),{recursive:!0}),(0,J.writeFileSync)($,m.contents),n.json||process.stdout.write(K.default.green(`wrote ${m.path}
|
|
293
|
+
`))}for(let m of f)(0,J.rmSync)((0,re.join)(c,m)),n.json||process.stdout.write(K.default.yellow(`removed ${m} (no longer generated)
|
|
294
|
+
`));n.json&&Q({ok:!Mt(h),diagnostics:h,wrote:r.map(m=>m.path),removed:f})});Ge.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}=Le(n);(0,J.existsSync)(e)||(n.json?Q({ok:!1,error:`no harness.dot at ${e}`}):process.stderr.write(K.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
|
|
295
|
+
`)),process.exit(1));let{harness:s,parseErrors:a}=ke(e,t),l=r=>(0,J.existsSync)((0,re.join)(o,r)),c=Na(s,o),p=[...Nt(s,{fileExists:l,roles:c}),...It(s)],u=p.some(r=>r.level==="error")||a.length>0;if(n.json)Q({ok:!u,parseErrors:a,diagnostics:p});else{for(let r of a)process.stderr.write(K.default.red(`parse: ${r.message}
|
|
296
|
+
`));Ui(p)}process.exit(u?1:0)});Ge.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}=Le(n);(0,J.existsSync)(e)||(n.json?Q({error:`no harness.dot at ${e}`}):process.stderr.write(K.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
|
|
297
|
+
`)),process.exit(1));let{harness:t}=ke(e);n.json?Q({name:t.name,nodes:t.nodes,edges:t.edges}):process.stdout.write(Sn(t)+`
|
|
298
|
+
`)});Ge.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}=Le(e);(0,J.existsSync)(t)||(e.json?Q({error:`no harness.dot at ${t}`}):process.stderr.write(K.default.red(`no harness.dot at ${t} \u2014 run \`gp-foundry init\` first
|
|
299
|
+
`)),process.exit(1));let{harness:s}=ke(t,o),{files:a}=mt(s),l=a.find(c=>c.path.endsWith(`/${n}.yml`))??a.find(c=>c.path.startsWith(".github/workflows/")&&new RegExp(`^ ${n}:`,"m").test(c.contents));l||(e.json?Q({error:`no generated workflow for node '${n}'`}):process.stderr.write(K.default.red(`no generated workflow for node '${n}'
|
|
300
|
+
`)),process.exit(1)),e.json?Q({node:n,path:l.path,contents:l.contents}):process.stdout.write(l.contents+`
|
|
301
301
|
`)});Do(Ge);Ge.parseAsync(process.argv);
|