@thegpvc/gp-foundry 0.2.15 → 0.3.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/AGENTS.md +8 -1
- package/README.md +37 -2
- package/actions/config-loader/dist/index.cjs +1 -1
- package/actions/merge-gate/README.md +50 -2
- package/actions/merge-gate/action.yml +28 -1
- package/actions/merge-gate/dist/index.cjs +61 -58
- package/actions/pr-scope/README.md +36 -0
- package/actions/pr-scope/action.yml +76 -0
- package/actions/pr-scope/dist/index.cjs +70 -0
- package/dist/cli/index.cjs +173 -110
- package/package.json +1 -1
- package/schema/config.schema.json +32 -2
- package/skill/SKILL.md +11 -2
- package/skill/reference/node-types.md +40 -6
- package/skill/templates/foundry.config.yaml +21 -2
- package/skill/templates/harness.dot +9 -5
- package/skill/templates/policy-merge.yaml +14 -3
package/dist/cli/index.cjs
CHANGED
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`).replace(/^/gm," ".repeat(a))}let
|
|
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 Uo=Object.getOwnPropertyNames;var qo=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 Uo(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(qo(n)):{},Wo(e||!n||!n.__esModule?Vi(t,"default",{value:n,enumerable:!0}):t,n));var Vo,B,N=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 $t=Me(Nn=>{"use strict";N();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}},xn=class extends Qt{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Nn.CommanderError=Qt;Nn.InvalidArgumentError=xn});var Zt=Me(Hn=>{"use strict";N();var{InvalidArgumentError:Ko}=$t(),In=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+"]"}Hn.Argument=In;Hn.humanReadableArgName=Yo});var Ln=Me(Ki=>{"use strict";N();var{humanReadableArgName:Jo}=Zt(),Pn=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 d($,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($=>d(t.argumentTerm($),t.argumentDescription($)));h.length>0&&(u=u.concat(["Arguments:",p(h),""]));let f=t.visibleOptions(e).map($=>d(t.optionTerm($),t.optionDescription($)));if(f.length>0&&(u=u.concat(["Options:",p(f),""])),this.showGlobalOptions){let $=t.visibleGlobalOptions(e).map(w=>d(t.optionTerm(w),t.optionDescription(w)));$.length>0&&(u=u.concat(["Global Options:",p($),""]))}let m=t.visibleCommands(e).map($=>d(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 d=t-o;if(d<s)return e;let p=e.slice(0,o),u=e.slice(o).replace(`\r
|
|
5
5
|
`,`
|
|
6
|
-
`),
|
|
7
|
-
|.{1,${
|
|
8
|
-
`?"":(
|
|
9
|
-
`)}};
|
|
6
|
+
`),r=" ".repeat(o),f="\\s\u200B",m=new RegExp(`
|
|
7
|
+
|.{1,${d-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),$=u.match(m)||[];return p+$.map((w,y)=>w===`
|
|
8
|
+
`?"":(y>0?r:"")+w.trimEnd()).join(`
|
|
9
|
+
`)}};Ki.Help=Pn});var jn=Me(Fn=>{"use strict";N();var{InvalidArgumentError:Xo}=$t(),Dn=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}},Mn=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}}Fn.Option=Dn;Fn.DualOptions=Mn});var Ji=Me(Yi=>{"use strict";N();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 d=Zo(n,l),p=Math.max(n.length,l.length);(p-d)/p>a&&(d<s?(s=d,o=[l]):d===s&&o.push(l))}),o.sort((l,d)=>l.localeCompare(d)),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]}?)`:""}
|
|
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
|
|
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,
|
|
11
|
+
(Did you mean ${o[0]}?)`:""}Yi.suggestSimilar=es});var er=Me(Zi=>{"use strict";N();var ts=require("events").EventEmitter,Un=require("child_process"),xe=require("path"),qn=require("fs"),te=require("process"),{Argument:ns,humanReadableArgName:is}=Zt(),{CommanderError:Bn}=$t(),{Help:rs}=Ln(),{Option:Xi,DualOptions:os}=jn(),{suggestSimilar:zi}=Ji(),Gn=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,d]=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,d&&p.arguments(d),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
|
+
- 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 Bn(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,d)=>{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,d)};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 d=s;s=(p,u)=>{let r=d.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(qn.existsSync(f))return f;if(s.includes(xe.extname(h)))return;let m=s.find($=>qn.existsSync(`${f}${$}`));if(m)return`${f}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let l=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||"";if(this._scriptPath){let r;try{r=qn.realpathSync(this._scriptPath)}catch{r=this._scriptPath}d=xe.resolve(xe.dirname(r),d)}if(d){let r=a(d,l);if(!r&&!e._executableFile&&this._scriptPath){let h=xe.basename(this._scriptPath,xe.extname(this._scriptPath));h!==this._name&&(r=a(d,`${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 Bn(r,"commander.executeSubCommandAsync","(close)")):te.exit(r)}),p.on("error",r=>{if(r.code==="ENOENT"){let h=d?`searched for local subcommand relative to directory '${d}'`:"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(
|
|
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 Bn(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 d=`error: command-argument value '${s}' is invalid for argument '${o.name()}'.`;l=this._callParseArg(o,s,a,d)}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,d)=>e(o,d,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 d=null;for(;a.length;){let p=a.shift();if(p==="--"){s===o&&s.push(p),s.push(...a);break}if(d&&!l(p)){this.emit(`option:${d.name()}`,p);continue}if(d=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()}`);d=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
|
|
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=>
|
|
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 d=l.attributeName(),p=this.getOptionValue(d),u=this.options.find(h=>h.negate&&d===h.attributeName()),r=this.options.find(h=>!h.negate&&d===h.attributeName());return u&&(u.presetArg===void 0&&p===!1||u.presetArg!==void 0&&p===u.presetArg)?u:r||l},s=l=>{let d=o(l),p=d.attributeName();return this.getOptionValueSource(p)==="env"?`environment variable '${d.envVar}'`:`option '${d.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(d=>d.long).map(d=>d.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
|
+
`),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
|
|
24
|
-
`)}I();I();var Ln=new Set(["type","role","prompt","policy","tools","context","name","output","gates","skip","select","authors","max_attempts","agent_attempts","schedule","timeout","environment","paths","commit","secrets","permissions","on_complete_label","cancel_in_progress","checkout","title","harness_ref","persist_credentials","repo_guides","opt_in_label","mode","check_name","requires_review","post","post_marker"]),Dn=new Set(["on","when","do"]);function Ki(n,e){let t=(a,l)=>{let u=Array.from({length:l.length+1},(p,r)=>r);for(let p=1;p<=a.length;p++){let r=u[0];u[0]=p;for(let d=1;d<=l.length;d++){let h=u[d];u[d]=Math.min(u[d]+1,u[d-1]+1,r+(a[p-1]===l[d-1]?0:1)),r=h}}return u[l.length]},o,s=3;for(let a of e){let l=t(n.toLowerCase(),a);l<s&&([o,s]=[a,l])}return o}function Mn(n){let e=n.attrs.gates;if(e===void 0)return[];if(typeof e!="string")throw new Error(`node '${n.id}': gates= must be a string like "ci.yml" or "lint?90"`);let t=[];for(let o of e.split(",").map(s=>s.trim()).filter(Boolean)){let[s,...a]=o.split("?"),l=s.trim();if(!l)throw new Error(`node '${n.id}': gates= entry '${o}' names no workflow or check`);let u={name:l,kind:/\.ya?ml$/i.test(l)?"workflow":"check"};for(let p of a.map(r=>r.trim()))if(p==="info")u.info=!0;else if(/^[1-9]\d*$/.test(p)&&u.graceSeconds===void 0)u.graceSeconds=Number(p);else throw new Error(`node '${n.id}': gates= entry '${o}' has a bad '?${p}' suffix \u2014 expected '?<seconds>' (a whole number >= 1) and/or '?info', e.g. "${l}?90" or "${l}?info"`);t.push(u)}return t}function Ji(n){try{return Mn(n)}catch{return[]}}function Fn(n){let e=n.attrs.skip;if(e===void 0)return[];if(typeof e!="string"||!e.trim())throw new Error(`node '${n.id}': skip= must be a non-empty string like "draft,unchanged-diff"`);let t=[],o=new Set;for(let s of e.split(",").map(a=>a.trim()).filter(Boolean))if(!o.has(s))if(o.add(s),s==="draft"||s==="bot-author"||s==="unchanged-diff")t.push({kind:s});else if(s.startsWith("label:")&&s.slice(6).trim())t.push({kind:"label",label:s.slice(6).trim()});else throw new Error(`node '${n.id}': unknown skip= entry '${s}' \u2014 expected draft, bot-author, label:<key> or unchanged-diff`);if(!t.length)throw new Error(`node '${n.id}': skip= has no entries`);return t}function Ce(n){try{return Fn(n)}catch{return[]}}var Jo=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function Xi(n,e){let t=[];for(let o of n){let s=String(o).trim();if(!s)continue;if(!Jo.test(s))throw new Error(`${e}: '${s}' is not a GitHub login`);let a=s.toLowerCase();t.includes(a)||t.push(a)}if(!t.length)throw new Error(`${e}: names no login \u2014 an empty allowlist would match nobody`);return t}function Kt(n){return n.type==="pr-fix"||(n.type==="pr-review"||n.type==="analyst")&&we(n)||he(n)}function Jt(n,e){let t=n.attrs.authors;return t!==void 0?Xi(String(t).split(","),`node '${n.id}': authors=`):wt(e)}function wt(n){let e=n.repo?.authors;if(e!==void 0){if(!Array.isArray(e))throw new Error("repo.authors must be a list of GitHub logins");return Xi(e,"repo.authors")}}function Te(n,e){if(Kt(n))try{return Jt(n,e)}catch{return[jn]}}var jn="no author matches a malformed allowlist";function zi(n,e){let t=n.map(s=>`github.event.pull_request.user.login == '${s}'`),o=t.length===1?t[0]:`(${t.join(" || ")})`;return e===void 0?o:`(${o} || contains(github.event.pull_request.labels.*.name, ${qe(e)}))`}function qe(n){return`'${n.replace(/'/g,"''")}'`}function qn(n,e){let t=n.attrs.opt_in_label;if(t===void 0)return;if(typeof t!="string"||!t.trim())throw new Error(`node '${n.id}': opt_in_label= must be a label key like "agent_review"`);let o=t.trim();return e.labels?.[o]??o}function Ue(n,e){if(Te(n,e)!==void 0)try{return qn(n,e)}catch{return}}function Un(n){let e=n.attrs.mode;if(e===void 0)return"merge";if(e==="merge"||e==="evaluate")return e;throw new Error(`node '${n.id}': mode= must be "merge" or "evaluate", got ${JSON.stringify(e)}`)}function he(n){if(n.type!=="merge-gate")return!1;try{return Un(n)==="evaluate"}catch{return!1}}function Be(n){let e=n.attrs.check_name;if(e===void 0)return`gp-foundry/approval (${n.id})`;if(typeof e!="string"||!e.trim()||/[\u0000-\u001f\u007f]/.test(e))throw new Error(`node '${n.id}': check_name= must be a non-empty, single-line check-run name like "fletch/approval"`);return e.trim()}function we(n){return n.context==="pr-diff"||n.context==="pr-review"}function ye(n){return n.attrs.select==="sweep"&&n.type==="pr-review"&&we(n)&&n.attrs.schedule!==void 0}function Bn(n){return ye(n)&&n.attrs.requires_review===!0}var Qi="<!-- gp-foundry:also-head:[^:\\s]+:";function Xt(n){return n.attrs.post==="review"&&(n.type==="pr-review"||n.type==="analyst")&&we(n)}var Gn="PR #<n> head <sha>";function zt(n){let e=n.attrs.post_marker;if(e===void 0)return Gn;if(typeof e!="string"||!e.trim()||/[\u0000-\u001f\u007f]/.test(e))throw new Error(`node '${n.id}': post_marker= must be a non-empty single line, e.g. "PR #<n> head <sha>"`);return e.trim()}function Ge(n,e){return(n.type==="pr-review"||n.type==="analyst")&&we(n)&&n.attrs.schedule===void 0&&(Ce(n).length>0||Te(n,e)!==void 0)}function Ze(n){return ye(n)?`${n.id}_select`:`${n.id}_guard`}function Qt(n){return`${n.id} #`}function Vn(n){return`gp-foundry/sweep-failed (${n.id})`}function Wn(n){return`gp-foundry/sweep-idle (${n.id})`}function Yn(n){return`gp-foundry/swept (${n.id})`}function Zt(n){return`<!-- gp-foundry:diff:${n.id}:`}function Zi(n){return`<!-- gp-foundry:also-head:${n.id}:`}var yt='(((.body // "") | gsub("<!--[\\\\s\\\\S]*?-->"; "") | split("\\n") | map(gsub("^\\\\s+|\\\\s+$"; "")) | map(select(length > 0)) | (last // "")) as $line | env.VERDICT_LINES | split("\\n") | any(.[]; . == $line))';function et(n){try{return Pn(je(n.verdicts))}catch{return Pn(je(void 0))}}I();function nt(n){return`\${{ secrets.${n} }}`}function _e(n,e){if(!e)return"";let t=n.specDir?.replace(/\/+$/,"");return t?`${t}/${e}`:e}function ne(n){let e=bt(n.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?nt(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}var Xo=new Set(["actions","checks","contents","deployments","issues","packages","pages","pull-requests","security-events","statuses","workflows"]);function it(n,e){let t=bt(n.config);if(t.mode!=="app"||!t.appIdSecret||!t.appKeySecret)return;let o={"client-id":nt(t.appIdSecret),"private-key":nt(t.appKeySecret)};for(let[s,a]of Object.entries(e??{}))Xo.has(s)&&a!=="none"&&(o[`permission-${s}`]=a);return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:o}}var tt=".gp-foundry/harness";function en(n,e=!1){return n.attrs.harness_ref==="head"?!1:e||n.type==="pr-fix"||(n.type==="pr-review"||n.type==="analyst")&&we(n)}function tn(n,e){let t=n.config.runtime?.mode==="vendored",o=n.specDir.replace(/\/+$/,""),s=[n.node.files.role,n.node.files.prompt,"agents/scope.yaml","agents/communication.md"].filter(d=>!!d).map(d=>o?`${o}/${d}`:d),a=new Set([".github/agent-setup"]);t&&a.add(".github/actions");for(let d of s){let h=d.includes("/")?d.slice(0,d.lastIndexOf("/")):"";h&&a.add(h)}let l=[...a].sort(),u=l.filter(d=>!l.some(h=>h!==d&&d.startsWith(`${h}/`))),p=[{uses:"actions/checkout@v5",name:"Checkout harness files (base ref)",with:{ref:e,path:tt,"fetch-depth":1,"sparse-checkout":u.join(`
|
|
25
|
-
`),token:ne(n),"persist-credentials":!1}},
|
|
26
|
-
echo "/${
|
|
27
|
-
|
|
28
|
-
`))
|
|
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=Gn});var rr=Me(fe=>{"use strict";N();var{Argument:tr}=Zt(),{Command:Wn}=er(),{CommanderError:ss,InvalidArgumentError:nr}=$t(),{Help:as}=Ln(),{Option:ir}=jn();fe.program=new Wn;fe.createCommand=n=>new Wn(n);fe.createOption=(n,e)=>new ir(n,e);fe.createArgument=(n,e)=>new tr(n,e);fe.Command=Wn;fe.Option=ir;fe.Argument=tr;fe.Help=as;fe.CommanderError=ss;fe.InvalidArgumentError=nr;fe.InvalidOptionArgumentError=nr});var nn=Me((ol,Vn)=>{"use strict";N();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")}};Vn.exports=lr();Vn.exports.createColors=lr});N();N();var or=zt(rr(),1),{program:Ka,createCommand:Ya,createArgument:Ja,createOption:Xa,CommanderError:za,InvalidArgumentError:Qa,InvalidOptionArgumentError:Za,Command:sr,Argument:el,Option:tl,Help:nl}=or.default;var K=zt(nn(),1),Mo=require("child_process"),J=require("fs"),se=require("path");N();N();N();var it=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function ur(n){return n.uses!==void 0}N();function Et(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"}}N();N();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 Kn(n){return[n.approve,n.requestChanges,n.escalate].map(fs).join(`
|
|
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}},re({name:"Keep the harness copy out of the working tree",run:`mkdir -p .git/info
|
|
26
|
+
echo "/${Je.split("/")[0]}/" >> .git/info/exclude`}),re({name:"Use this PR's harness files if the base ref has no harness yet",env:{HARNESS:Je,SPEC:o?`${o}/${n.specFile??"harness.dot"}`:n.specFile??"harness.dot",DIRS:d.join(`
|
|
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=>`./${Je}/.github/actions/${r}`:n.actionRef;return{ctx:{...n,specDir:o?`${Je}/${o}`:Je,harnessRoot:Je,actionRef:u},steps:p}}function at(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 lt(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 re({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 Ot(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 ut(n,e){let t=n.node,o=n.config,s={"role-file":ye(n,t.files.role),model:o.agent.model,"comms-file":ye(n,"agents/communication.md"),"scope-path":ye(n,"agents/scope.yaml"),...o.agent.api_key_secret?{"anthropic-api-key":st(o.agent.api_key_secret)}:{"claude-code-oauth-token":st(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}=${st(u)}`).join(`
|
|
30
|
+
`));let d=t.attrs.agent_attempts;d!==void 0&&(s["max-attempts"]=String(d));let p=t.files.prompt;return p&&(s["prompt-override-file"]=ye(n,p)),{uses:n.actionRef("run-agent"),...e.outputContract?{id:"agent"}:{},name:"Run agent",with:s}}function re(n){return{shell:"bash",...n}}var $s=`set -euo pipefail
|
|
29
31
|
# post="review": the agent printed its review; this step posts it with the lane's
|
|
30
32
|
# token. The agent's output is DATA \u2014 nothing here evaluates it, and it reaches gh
|
|
31
33
|
# only as a JSON file built by jq.
|
|
32
34
|
preview() { head -c 200 "$STDOUT_FILE" | tr '\\n\\r' ' '; }
|
|
35
|
+
# One line in the job summary saying what became of the review, under the agent's
|
|
36
|
+
# output: a link to it when posted, and a plain statement when not \u2014 so nobody
|
|
37
|
+
# has to read the log to learn whether the text above ever reached the PR.
|
|
38
|
+
note() { if [ -n "\${GITHUB_STEP_SUMMARY:-}" ]; then printf '\\n%s\\n' "$1" >> "$GITHUB_STEP_SUMMARY"; fi; }
|
|
33
39
|
if [ -z "\${STDOUT_FILE:-}" ] || [ ! -s "$STDOUT_FILE" ]; then
|
|
34
40
|
echo "::warning::the agent printed nothing \u2014 no review posted"
|
|
41
|
+
note "_No review was posted: the agent printed nothing._"
|
|
35
42
|
exit 0
|
|
36
43
|
fi
|
|
37
44
|
|
|
@@ -42,8 +49,30 @@ BLOCK=$(awk '
|
|
|
42
49
|
inb && /^[ \\t]*\`\`\`[ \\t]*$/ { inb = 0; last = buf; found = 1; next }
|
|
43
50
|
inb { buf = buf $0 "\\n" }
|
|
44
51
|
END { if (found) printf "%s", last }' "$STDOUT_FILE")
|
|
52
|
+
|
|
53
|
+
# No fence: fall back to a BARE object at the end of the output, which models
|
|
54
|
+
# print often enough. It ends on the last line ending in "}" (anything after it
|
|
55
|
+
# is ignored) and starts on a line beginning with "{"; the start is the latest
|
|
56
|
+
# such line from which the slice parses as exactly one object with a string
|
|
57
|
+
# body. A line inside a pretty-printed object (a comment's "{") leaves the rest
|
|
58
|
+
# of the object behind it, so it never parses alone and the scan moves up. A
|
|
59
|
+
# fenced block, when there is one, always wins.
|
|
60
|
+
if [ -z "$BLOCK" ]; then
|
|
61
|
+
END_LINE=$(awk '/}[ \\t\\r]*$/ { e = NR } END { print e + 0 }' "$STDOUT_FILE")
|
|
62
|
+
if [ "$END_LINE" -gt 0 ]; then
|
|
63
|
+
for START in $(awk -v e="$END_LINE" 'NR <= e && /^[ \\t]*[{]/ { print NR }' "$STDOUT_FILE" | tail -n 200 | sort -rn); do
|
|
64
|
+
SLICE=$(sed -n "\${START},\${END_LINE}p" "$STDOUT_FILE")
|
|
65
|
+
if jq -se 'length == 1 and (.[0] | type == "object" and (.body | type) == "string")' <<< "$SLICE" > /dev/null 2>&1; then
|
|
66
|
+
BLOCK=$SLICE
|
|
67
|
+
echo "::notice::no fenced json block in the agent's output \u2014 using the bare JSON object at its end"
|
|
68
|
+
break
|
|
69
|
+
fi
|
|
70
|
+
done
|
|
71
|
+
fi
|
|
72
|
+
fi
|
|
45
73
|
if [ -z "$BLOCK" ]; then
|
|
46
|
-
echo "::warning::no
|
|
74
|
+
echo "::warning::no review in the agent's output: neither a fenced json block nor a bare JSON object with a string body at its end \u2014 nothing posted. It began: $(preview)"
|
|
75
|
+
note "_No review was posted: the agent's output held no review block._"
|
|
47
76
|
exit 0
|
|
48
77
|
fi
|
|
49
78
|
|
|
@@ -61,6 +90,7 @@ if ! REVIEW=$(jq -c '
|
|
|
61
90
|
| {body, event: "COMMENT", comments: [$c[] | {path, line, side: (if .side == "LEFT" then "LEFT" else "RIGHT" end), body}]}
|
|
62
91
|
' <<< "$BLOCK" 2> "$ERR"); then
|
|
63
92
|
echo "::warning::the review block is not a valid review \u2014 nothing posted: $(head -c 300 "$ERR" | tr '\\n\\r' ' ')"
|
|
93
|
+
note "_No review was posted: the review block was not valid._"
|
|
64
94
|
exit 0
|
|
65
95
|
fi
|
|
66
96
|
|
|
@@ -68,31 +98,61 @@ fi
|
|
|
68
98
|
# the exact verdict lines, or the sweep and the gate would read it differently.
|
|
69
99
|
if [ "$REQUIRE_VERDICT" = "true" ] && ! jq -e '__IS_VERDICT_JQ__' <<< "$REVIEW" > /dev/null; then
|
|
70
100
|
echo "::warning::the review's last line is not one of the verdict lines ($(tr '\\n' '|' <<< "$VERDICT_LINES")) \u2014 nothing posted"
|
|
101
|
+
note "_No review was posted: its last line is not one of the verdict lines._"
|
|
71
102
|
exit 0
|
|
72
103
|
fi
|
|
73
104
|
|
|
74
|
-
#
|
|
105
|
+
# Idempotency: has THIS lane already posted on this head? Each review this step
|
|
106
|
+
# posts ends with a hidden marker naming the lane and the head, and that marker
|
|
107
|
+
# is what a re-run looks for. Several lanes post as one bot, often under one
|
|
108
|
+
# heading, so neither the heading nor the shape of the review says whose it is:
|
|
109
|
+
# a reviewer's review must not silence an approver, and a reviewer that posts
|
|
110
|
+
# its own verdict must still recognize its own review on a re-run.
|
|
111
|
+
#
|
|
112
|
+
# A review with no posted marker at all predates the marker. For those the old
|
|
113
|
+
# test stands in: the heading on line 1 \u2014 and, on a verdict lane, only a review
|
|
114
|
+
# that is itself a verdict, so a plain review under the same heading cannot
|
|
115
|
+
# stop the verdict being posted.
|
|
75
116
|
MARKER="\${POST_MARKER//<n>/$PR}"
|
|
76
117
|
MARKER="\${MARKER//<sha>/$HEAD_SHA}"
|
|
77
|
-
|
|
118
|
+
POSTED="$POSTED_PREFIX$NODE:$HEAD_SHA -->"
|
|
119
|
+
export MARKER POSTED
|
|
78
120
|
if ! EXISTING=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews?per_page=100" --paginate --jq '
|
|
79
121
|
[.[] | select(.user.login == env.BOT_LOGIN and .commit_id == env.HEAD_SHA)
|
|
80
|
-
|
|
|
122
|
+
| (.body // "") as $b
|
|
123
|
+
| select(($b | contains(env.POSTED))
|
|
124
|
+
or ((($b | contains(env.POSTED_PREFIX)) | not)
|
|
125
|
+
and ((($b | split("\\n") | .[0]) // "" | gsub("^\\\\s+|\\\\s+$"; "")) == env.MARKER)
|
|
126
|
+
and (env.REQUIRE_VERDICT != "true" or __IS_VERDICT_JQ__)))] | length' \\
|
|
81
127
|
| awk '{s+=$1} END {print s+0}'); then
|
|
82
128
|
echo "::error::could not read the PR's reviews \u2014 not posting, so a re-run cannot post the review twice"
|
|
83
129
|
exit 1
|
|
84
130
|
fi
|
|
85
131
|
if [ "$EXISTING" != "0" ]; then
|
|
86
|
-
echo "
|
|
132
|
+
echo "$NODE has already posted its review on $HEAD_SHA \u2014 not posting it again"
|
|
133
|
+
note "_The review for this head was already posted; nothing new was posted._"
|
|
87
134
|
exit 0
|
|
88
135
|
fi
|
|
89
136
|
|
|
90
137
|
PAYLOAD=$(mktemp)
|
|
91
138
|
jq -c --arg sha "$HEAD_SHA" --arg head "$MARKER" \\
|
|
92
139
|
'{commit_id: $sha, event, body: ($head + "\\n\\n" + .body), comments}' <<< "$REVIEW" > "$PAYLOAD"
|
|
93
|
-
|
|
140
|
+
# The posted marker goes on last, after any reshaping of the body below: it is
|
|
141
|
+
# an HTML comment, which every verdict test ignores, so a verdict line above it
|
|
142
|
+
# is still the review's last visible line.
|
|
143
|
+
RESP=$(mktemp)
|
|
144
|
+
post() {
|
|
145
|
+
jq -c --arg m "$POSTED" '.body += "\\n\\n" + $m' "$1" > "$1.out"
|
|
146
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --input "$1.out" > "$RESP" 2> "$ERR"
|
|
147
|
+
}
|
|
148
|
+
# The review's own URL, from the API's response, for the job summary.
|
|
149
|
+
posted_note() {
|
|
150
|
+
URL=$(jq -r '.html_url // empty' "$RESP" 2> /dev/null || true)
|
|
151
|
+
if [ -n "$URL" ]; then note "**Review posted:** $URL"; else note "**Review posted** on $HEAD_SHA."; fi
|
|
152
|
+
}
|
|
94
153
|
if post "$PAYLOAD"; then
|
|
95
154
|
echo "posted the review on $HEAD_SHA"
|
|
155
|
+
posted_note
|
|
96
156
|
exit 0
|
|
97
157
|
fi
|
|
98
158
|
|
|
@@ -108,88 +168,91 @@ if grep -q "422" "$ERR" && grep -qiE "line|diff|position|resolve" "$ERR" && [ "$
|
|
|
108
168
|
| .comments = []' "$PAYLOAD" > "$PAYLOAD.flat"
|
|
109
169
|
if post "$PAYLOAD.flat"; then
|
|
110
170
|
echo "posted the review on $HEAD_SHA, with its inline findings in the body"
|
|
171
|
+
posted_note
|
|
111
172
|
exit 0
|
|
112
173
|
fi
|
|
113
174
|
fi
|
|
114
175
|
echo "::error::could not post the review: $(head -c 500 "$ERR" | tr '\\n\\r' ' ')"
|
|
176
|
+
note "_No review was posted: GitHub rejected it. See the job log._"
|
|
115
177
|
exit 1
|
|
116
|
-
`;function
|
|
117
|
-
`);return["Do not post anything to GitHub yourself, and do not run `gh`: a workflow step posts your review for you.","End your final message with exactly one fenced code block tagged `json` holding one object:","","```json",'{"body": "<the whole review, in markdown>", "comments": [{"path": "src/file.ts", "line": 42, "side": "RIGHT", "body": "<one finding>"}], "event": "COMMENT"}',"```","","- `body`: the review. Do not add a heading with the PR number or commit; the step adds it.","- `comments`: optional inline findings, each on a line of the diff (`side` RIGHT is the new file, LEFT the old). Use `[]` for none.",'- `event`: always `"COMMENT"`. Do not include a `commit_id`; the step sets it to the head you reviewed.',...e?[`- The LAST line of \`body\` must be exactly one of: ${t.map(o=>`\`${o}\``).join(", ")}. Anything else, and nothing is posted.`]:[],"If the block is missing or is not valid JSON, nothing is posted."].join(`
|
|
118
|
-
`)}function
|
|
119
|
-
`)})}function
|
|
120
|
-
`)})}function
|
|
121
|
-
`)}));let s=
|
|
178
|
+
`;function yr(n,e){let t=ni;try{t=un(n.node)}catch{}return re({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:ot(n.config)},run:$s.replaceAll("__IS_VERDICT_JQ__",()=>Rt)})}function _r(n,e){let t=ot(n.config).split(`
|
|
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 mn(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=mn(n)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var Xe="${{ github.event.issue.number }}",ct="${{ 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,...mn(n)}}catch{return e}}function Se(n,e){let t=n.attrs.timeout;return typeof t=="number"?t:e}var Es=10;function bn(n){return Math.max(1,n-Es)}function wn(n,e,t){let o=[],s=Ue(n,t&&pi(n.node,t));return s&&o.push(s),o.push(at(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=Ee(t),d=!l&&ve(t,e.config),p=Ie(t),u=l?"${{ matrix.pr.number }}":ct,r=l?"${{ matrix.pr.sha }}":ci,h=[],f=Ue(e,pi(t,a));f&&h.push(f);let m=br(t);if(h.push(at(e,s?{ref:r,fetchDepth:0,persistCredentials:m}:{persistCredentials:m})),s&&fn(t)){let U=gn(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,ie)=>Ss(`gate-${U}`,ie,w));$.forEach((U,ie)=>{h.push({uses:e.actionRef("wait-for-checks"),id:y[ie],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(lt(e));let C=o==="pr-diff"?"pr-diff":o==="pr-review"?"pr-review":"issue";h.push(Ot(e,C,s?u:Xe,{framing:"baseline",checks:s})),$.length&&h.push(ks($,y));let P=Se(t,w.length?15+15*w.length:25),j=ln(t),M=ut(e,{withContext:!0,...j?{outputContract:_r(e,l)}:{}});h.push(w.length?M:{...M,timeoutMinutes:bn(P)}),j&&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=`${pn(t)}\${{ matrix.pr.number }}`,q.if=`needs.${p}.outputs.count != '0'`,q.strategy={"fail-fast":!1,matrix:{pr:`\${{ fromJSON(needs.${p}.outputs.prs) }}`}}):d&&(q.needs=[p],q.if=`needs.${p}.outputs.run == 'true'`,$e(t).some(U=>U.kind==="unchanged-diff")&&h.push(vs(e,p))),q}function vs(n,e){return re({name:"Stamp the review with the diff hash",if:`\${{ success() && needs.${e}.outputs.diff_hash != '' }}`,env:{GH_TOKEN:ne(n),PR:ct,HEAD_SHA:`\${{ needs.${e}.outputs.head_sha }}`,DIFF_HASH:`\${{ needs.${e}.outputs.diff_hash }}`,BOT_LOGIN:n.config.identity?.bot_login??"",MARKER_PREFIX:hn(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,d)=>d!==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=d=>` echo "$GATE_${d+1}_NAME: $GATE_${d+1}_RESULT"`;n.forEach((d,p)=>{t[`GATE_${p+1}_NAME`]=d.name,t[`GATE_${p+1}_RESULT`]=`\${{ steps.${e[p]}.outputs.conclusion }}`});let a=n.map((d,p)=>({g:d,i:p})).filter(({g:d})=>!d.info),l=n.map((d,p)=>({g:d,i:p})).filter(({g:d})=>d.info);return a.length&&(a.forEach(({i:d})=>o.push(s(d))),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:d})=>o.push(s(d))),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"'),re({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=wn(n,void 0,{contents:"write","pull-requests":"write",issues:"write"});o.push(re({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:Xe,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=Se(e,35);return o.push(lt(n)),o.push(Ot(n,"issue",Xe)),o.push({...ut(n,{withContext:!0}),timeoutMinutes:bn(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":Xe,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
|
|
122
184
|
|
|
123
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.
|
|
124
186
|
|
|
125
|
-
Closes #${
|
|
126
|
-
`)}));let p="steps.attempts.outputs.exhausted != 'true'";return o.push({...
|
|
127
|
-
`)})),{jobId:t.id,name:t.id,permissions:{contents:"write","pull-requests":"write",checks:"read"},timeoutMinutes:
|
|
128
|
-
`)})]}}function
|
|
129
|
-
`)})),o.push(
|
|
130
|
-
`)})),o.push({uses:n.actionRef("agent-fallback"),name:"Preserve failed agent output for review",if:"${{ !cancelled() && steps.agent.outcome == 'failure' && steps.recovery.outcome == 'success' }}",with:{branch:"${{ steps.recovery.outputs.branch }}","base-branch":t.repo.base_branch,token:ne(n),"agent-name":e.id,"scope-path":
|
|
187
|
+
Closes #${Xe}`}}),{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=wn(e,{ref:$r,fetchDepth:0},{contents:"write","pull-requests":"write",checks:"read"});if(fn(t)){let u=gn(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",d=e.config.identity?.bot_login??"";o.push(re({id:"attempts",name:`Enforce attempt budget (max ${s})`,env:{GH_TOKEN:ne(e),PR:ct,MARKER:a,MAX:String(s),BOT_LOGIN:d},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({...lt(e),if:p}),o.push({...Ot(e,"pr-review",ct,{framing:"work-item",checks:!0}),if:p}),o.push({...ut(e,{withContext:!0}),if:p,timeoutMinutes:bn(Se(t,35))}),o.push(re({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:Se(t,35),steps:o,...ve(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 Os="github-actions";function Ts(n){return`${vr(n)}@${Os}`}function dt(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(Ts),s=kt(e);if(s)return xs(n,s,o);if(be(e))return Ns(n,o);let a=wn(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":ye(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}:{},...dt(n)?{verdicts:dt(n)}:{},...o.length?{"required-checks":o.join(",")}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write",checks:"read"},timeoutMinutes:Se(e,10),steps:a}}function xs(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=rt(n.config.rollout,n.config.labels);l=r&&Object.keys(r).length?JSON.stringify(r):void 0}catch{l=JSON.stringify({authors:[]})}let d=[],p=Ue(n,s?void 0:{contents:"read","pull-requests":"read",checks:"write"});p&&d.push(p);let u=at(n,{persistCredentials:!1});return u.with={...u.with,token:"${{ github.token }}"},d.push(u),d.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":ye(n,o.files.policy),"base-branch":n.config.repo.base_branch,...n.config.identity?.bot_login?{"bot-login":n.config.identity.bot_login}:{},...dt(n)?{verdicts:dt(n)}:{},...t.length?{"required-checks":t.join(",")}:{},...l?{rollout:l}:{}}}),{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:Se(o,10),steps:d}}function Ns(n,e){let t=n.node,o=at(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),d=$e(t),p=d.flatMap(r=>r.kind==="label"?[n.config.labels?.[r.label]??r.label]:[]),u=d.some(r=>r.kind==="bot-author");return{jobId:t.id,name:t.id,permissions:{contents:"read","pull-requests":"read",checks:"write"},timeoutMinutes:Se(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":ye(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}:{},...dt(n)?{verdicts:dt(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 Is(n){let e=n.node,t=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:t,steps:[re({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME: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 Hs(n){let e=n.node,t=n.config,o=wn(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(re({id:"branch",name:"Create branch",env:{PREFIX:t.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}"},run:['BRANCH="$PREFIX$NODE-$RUN_ID"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
191
|
+
`)})),o.push(lt(n)),o.push({...ut(n,{withContext:!1}),id:"agent",timeoutMinutes:bn(Se(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":ye(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":ye(n,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...a?{"allowed-paths":a}:{}}}),o.push(re({id:"recovery",name:"Create recovery branch",if:"${{ !cancelled() && steps.agent.outcome == 'failure' }}",env:{PREFIX:t.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:['BRANCH="$PREFIX$NODE-recovery-$RUN_ID-$RUN_ATTEMPT"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
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":ye(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:Se(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=[],d=Ue(o,pi(s,a));if(d&&l.push(d),l.push(at(o,t?{ref:ci,fetchDepth:0,persistCredentials:!1}:{persistCredentials:!1})),fn(s,t)){let u=gn(o,di);l.push(...u.steps),o=u.ctx}l.push(lt(o)),l.push(Ot(o,t?"pr-review":"issue",t?ct:Xe,{framing:"baseline",checks:t})),s.files.role&&l.push(ut(o,{withContext:!0}));let p=s.attrs.on_complete_label;if(typeof p=="string"&&p){let u=o.config.labels?.[p]??p;l.push(re({name:"Apply completion label",env:{GH_TOKEN:ne(o),NUM:t?ct:Xe},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:Se(s,15),steps:l})}var Ps={analyst:ui,"issue-agent":ui,"pr-review":ui,producer:As,"pr-fix":Rs,"merge-gate":Cs,"human-gate":Is,"scheduled-agent":Hs,start:()=>null,exit:()=>null};function hi(n,e,t){let o=Ps[n.type];if(!o)return null;let s=o(t);return s&&Er(n,s)}N();var kr=require("fs"),Ar=require("url"),fi;function Ls(){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 Tt(){return`v${Ls()}`}var gi="v1";N();var Ds=new Set(it);function ze(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 d=t.get(l.id)??[];if(d.length<2)continue;let p=[],u,r=!0;for(let $ of d){let w=e.get($.from);if(!w||!Ds.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}}N();N();function Ms(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ae={},yn={},qe={},Rr;function Ct(){if(Rr)return qe;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,d){if(d){let p=Object.keys(d);for(let u=0,r=p.length;u<r;u+=1){let h=p[u];l[h]=d[h]}}return l}function s(l,d){let p="";for(let u=0;u<d;u+=1)p+=l;return p}function a(l){return l===0&&Number.NEGATIVE_INFINITY===1/l}return qe.isNothing=n,qe.isObject=e,qe.toArray=t,qe.repeat=s,qe.isNegativeZero=a,qe.extend=o,qe}var mi,Or;function xt(){if(Or)return mi;Or=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+=`
|
|
131
193
|
|
|
132
|
-
`+t.mark.snippet),a+" "+s):a}function e(t,o){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=o,this.message=n(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(o){return this.name+": "+n(this,o)},
|
|
133
|
-
`+h}let $=e(s.buffer,
|
|
134
|
-
`,h+=n.repeat("-",a.indent+
|
|
135
|
-
`;for(let
|
|
136
|
-
`}return h.replace(/\n$/,"")}return
|
|
137
|
-
\r`;function t(l){if(l===null)return!1;let
|
|
138
|
-
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function
|
|
139
|
-
`,
|
|
140
|
-
`,
|
|
141
|
-
`);break}
|
|
142
|
-
`,
|
|
143
|
-
`,
|
|
144
|
-
`,
|
|
145
|
-
`,
|
|
146
|
-
`),i.charCodeAt(0)===65279&&(i=i.slice(1)));let
|
|
147
|
-
`,
|
|
148
|
-
`&&(
|
|
149
|
-
`+n.repeat(" ",c.indent*
|
|
150
|
-
`,
|
|
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,Tr;function Fs(){if(Tr)return bi;Tr=1;let n=Ct();function e(s,a,l,d,p){let u="",r="",h=Math.floor(p/2)-1;return d-a>h&&(u=" ... ",a=d-h+u.length),l-d>h&&(r=" ...",l=d+h-r.length),{str:u+s.slice(a,l).replace(/\t/g,"\u2192")+r,pos:d-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,d=[0],p=[],u,r=-1;for(;u=l.exec(s.buffer);)p.push(u.index),d.push(u.index+u[0].length),s.position<=u.index&&r<0&&(r=d.length-2);r<0&&(r=d.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,d[r-w],p[r-w],s.position-(d[r]-d[r-w]),m);h=n.repeat(" ",a.indent)+t((s.line-w+1).toString(),f)+" | "+y.str+`
|
|
195
|
+
`+h}let $=e(s.buffer,d[r],p[r],s.position,m);h+=n.repeat(" ",a.indent)+t((s.line+1).toString(),f)+" | "+$.str+`
|
|
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,d[r+w],p[r+w],s.position-(d[r]-d[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 le(){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(d){a[d].forEach(function(p){l[String(p)]=d})}),l}function s(a,l){if(l=l||{},Object.keys(l).forEach(function(d){if(e.indexOf(d)===-1)throw new n('Unknown option "'+d+'" 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(d){return d},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=le();function t(a,l){let d=[];return a[l].forEach(function(p){let u=d.length;d.forEach(function(r,h){r.tag===p.tag&&r.kind===p.kind&&r.multi===p.multi&&(u=h)}),d[u]=p}),d}function o(){let a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function l(d){d.multi?(a.multi[d.kind].push(d),a.multi.fallback.push(d)):a[d.kind][d.tag]=a.fallback[d.tag]=d}for(let d=0,p=arguments.length;d<p;d+=1)arguments[d].forEach(l);return a}function s(a){return this.extend(a)}return s.prototype.extend=function(l){let d=[],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&&(d=d.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: [...] })");d.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(d),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=le();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=le();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=le();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=le();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=le();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=le();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 d(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:d,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=le(),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 d(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:d,defaultStyle:"lowercase"}),Ri}var Oi,jr;function ao(){return jr||(jr=1,Oi=no().extend({implicit:[io(),ro(),oo(),so()]})),Oi}var Ti,Ur;function lo(){return Ur||(Ur=1,Ti=ao()),Ti}var Ci,qr;function uo(){if(qr)return Ci;qr=1;let n=le(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function o(l){return l===null?!1:e.exec(l)!==null||t.exec(l)!==null}function s(l){let d=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(d=u[7].slice(0,3);d.length<3;)d+="0";d=+d}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,d));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=le();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=le(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
199
|
+
\r`;function t(l){if(l===null)return!1;let d=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;d+=6}}return d%8===0}function o(l){let d=l.replace(/[\r\n=]/g,""),p=d.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(d.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 d="",p=0,u=l.length,r=e;for(let f=0;f<u;f++)f%3===0&&f&&(d+=r[p>>18&63],d+=r[p>>12&63],d+=r[p>>6&63],d+=r[p&63]),p=(p<<8)+l[f];let h=u%3;return h===0?(d+=r[p>>18&63],d+=r[p>>12&63],d+=r[p>>6&63],d+=r[p&63]):h===2?(d+=r[p>>10&63],d+=r[p>>4&63],d+=r[p<<2&63],d+=r[64]):h===1&&(d+=r[p>>2&63],d+=r[p<<4&63],d+=r[64],d+=r[64]),d}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=le(),e=Object.prototype.hasOwnProperty,t=Object.prototype.toString;function o(a){if(a===null)return!0;let l=[],d=a;for(let p=0,u=d.length;p<u;p+=1){let r=d[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=le(),e=Object.prototype.toString;function t(s){if(s===null)return!0;let a=s,l=new Array(a.length);for(let d=0,p=a.length;d<p;d+=1){let u=a[d];if(e.call(u)!=="[object Object]")return!1;let r=Object.keys(u);if(r.length!==1)return!1;l[d]=[r[0],u[r[0]]]}return!0}function o(s){if(s===null)return[];let a=s,l=new Array(a.length);for(let d=0,p=a.length;d<p;d+=1){let u=a[d],r=Object.keys(u);l[d]=[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=le(),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 js(){if(Jr)return yn;Jr=1;let n=Ct(),e=xt(),t=Fs(),o=Mi(),s=Object.prototype.hasOwnProperty,a=1,l=2,d=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 j(i){return i===9||i===32}function M(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 ie(i){return i===120?2:i===117?4:i===85?8:0}function ue(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 ce(i,g,E){g==="__proto__"?Object.defineProperty(i,g,{configurable:!0,enumerable:!0,writable:!0,value:E}):i[g]=E}let F=new Array(256),de=new Array(256);for(let i=0;i<256;i++)F[i]=oe(i)?1:0,de[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 Q(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 H(i,g){throw Q(i,g)}function Ze(i,g){i.onWarning&&i.onWarning.call(null,Q(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 kn(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 T=0,c=_.length;T<c;T+=1){let b=_[T];s.call(k,b)||(k[b]=g[b])}}function An(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 bt(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 et(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 Ut={YAML:function(g,E,k){g.version!==null&&H(g,"duplication of %YAML directive"),k.length!==1&&H(g,"YAML directive accepts exactly one argument");let _=/^([0-9]+)\.([0-9]+)$/.exec(k[0]);_===null&&H(g,"ill-formed argument of the YAML directive");let T=parseInt(_[1],10),c=parseInt(_[2],10);T!==1&&H(g,"unacceptable YAML version of the document"),g.version=k[0],g.checkLineBreaks=c<2,c!==1&&c!==2&&Ze(g,"unsupported YAML version of the document")},TAG:function(g,E,k){let _;k.length!==2&&H(g,"TAG directive accepts exactly two arguments");let T=k[0];_=k[1],w.test(T)||H(g,"ill-formed tag handle (first argument) of the TAG directive"),s.call(g.tagMap,T)&&H(g,'there is a previously declared suffix for "'+T+'" tag handle'),y.test(_)||H(g,"ill-formed tag prefix (second argument) of the TAG directive");try{_=decodeURIComponent(_)}catch{H(g,"tag prefix is malformed: "+_)}g.tagMap[T]=_}};function he(i,g,E,k){if(g<E){let _=i.input.slice(g,E);if(k)for(let T=0,c=_.length;T<c;T+=1){let b=_.charCodeAt(T);b===9||b>=32&&b<=1114111||H(i,"expected valid JSON character")}else f.test(_)&&H(i,"the stream contains non-printable characters");i.result+=_}}function De(i,g,E,k){n.isObject(E)||H(i,"cannot merge mappings; the provided source object is unacceptable");let _=Object.keys(E);for(let T=0,c=_.length;T<c;T+=1){let b=_[T];i.maxTotalMergeKeys!==-1&&++i.totalMergeKeys>i.maxTotalMergeKeys&&H(i,"merge keys exceeded maxTotalMergeKeys ("+i.maxTotalMergeKeys+")"),s.call(g,b)||(ce(g,b,E[b]),k[b]=!0)}}function Re(i,g,E,k,_,T,c,b,R){if(Array.isArray(_)){_=Array.prototype.slice.call(_);for(let v=0,S=_.length;v<S;v+=1)Array.isArray(_[v])&&H(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(T))for(let v=0,S=T.length;v<S;v+=1)De(i,g,T[v],E);else De(i,g,T,E);else!i.json&&!s.call(E,_)&&s.call(g,_)&&(i.line=c||i.line,i.lineStart=b||i.lineStart,i.position=R||i.position,H(i,"duplicated mapping key")),ce(g,_,T),delete E[_];return g}function tt(i){let g=i.input.charCodeAt(i.position);g===10?i.position++:g===13?(i.position++,i.input.charCodeAt(i.position)===10&&i.position++):H(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(;j(_);)_===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(tt(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&&Ze(i,"deficient indentation"),k}function nt(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||M(E)))}function Oe(i,g){g===1?i.result+=" ":g>1&&(i.result+=n.repeat(`
|
|
201
|
+
`,g-1))}function qt(i,g,E){let k,_,T,c,b,R,v=i.kind,S=i.result,O=i.input.charCodeAt(i.position);if(M(O)||q(O)||O===35||O===38||O===42||O===33||O===124||O===62||O===39||O===34||O===37||O===64||O===96)return!1;if(O===63||O===45){let A=i.input.charCodeAt(i.position+1);if(M(A)||E&&q(A))return!1}for(i.kind="scalar",i.result="",k=_=i.position,T=!1;O!==0;){if(O===58){let A=i.input.charCodeAt(i.position+1);if(M(A)||E&&q(A))break}else if(O===35){let A=i.input.charCodeAt(i.position-1);if(M(A))break}else{if(i.position===i.lineStart&&nt(i)||E&&q(O))break;if(P(O))if(c=i.line,b=i.lineStart,R=i.lineIndent,ee(i,!1,-1),i.lineIndent>=g){T=!0,O=i.input.charCodeAt(i.position);continue}else{i.position=_,i.line=c,i.lineStart=b,i.lineIndent=R;break}}T&&(he(i,k,_,!1),Oe(i,i.line-c),k=_=i.position,T=!1),j(O)||(_=i.position+1),O=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),Oe(i,ee(i,!1,g)),E=k=i.position):i.position===i.lineStart&&nt(i)?H(i,"unexpected end of the document within a single quoted scalar"):(i.position++,j(_)||(k=i.position));H(i,"unexpected end of the stream within a single quoted scalar")}function wt(i,g){let E,k,_,T=i.input.charCodeAt(i.position);if(T!==34)return!1;for(i.kind="scalar",i.result="",i.position++,E=k=i.position;(T=i.input.charCodeAt(i.position))!==0;){if(T===34)return he(i,E,i.position,!0),i.position++,!0;if(T===92){if(he(i,E,i.position,!0),T=i.input.charCodeAt(++i.position),P(T))ee(i,!1,g);else if(T<256&&F[T])i.result+=de[T],i.position++;else if((_=ie(T))>0){let c=_,b=0;for(;c>0;c--)T=i.input.charCodeAt(++i.position),(_=U(T))>=0?b=(b<<4)+_:H(i,"expected hexadecimal character");i.result+=pe(b),i.position++}else H(i,"unknown escape sequence");E=k=i.position}else P(T)?(he(i,E,k,!0),Oe(i,ee(i,!1,g)),E=k=i.position):i.position===i.lineStart&&nt(i)?H(i,"unexpected end of the document within a double quoted scalar"):(i.position++,j(T)||(k=i.position))}H(i,"unexpected end of the stream within a double quoted scalar")}function Gt(i,g){let E=!0,k,_,T,c=i.tag,b,R=i.anchor,v,S,O,A,I=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=c,i.anchor=R,i.kind=A?"mapping":"sequence",i.result=b,!0;if(E?G===44&&H(i,"expected the node content, but found ','"):H(i,"missed comma between flow collection entries"),L=x=D=null,S=O=!1,G===63){let X=i.input.charCodeAt(i.position+1);M(X)&&(S=O=!0,i.position++,ee(i,!0,g))}k=i.line,_=i.lineStart,T=i.position,Ce(i,g,a,!1,!0),L=i.tag,x=i.result,ee(i,!0,g),G=i.input.charCodeAt(i.position),(O||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,I,L,x,D,k,_,T):S?b.push(Re(i,null,I,L,x,D,k,_,T)):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}H(i,"unexpected end of the stream within a flow collection")}function Wt(i,g){let E,k=u,_=!1,T=!1,c=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:H(i,"repeat of a chomping mode identifier");else if((v=ue(S))>=0)v===0?H(i,"bad explicit indentation width of a block scalar; it cannot be less than one"):T?H(i,"repeat of an indentation width identifier"):(c=g+v-1,T=!0);else break;if(j(S)){do S=i.input.charCodeAt(++i.position);while(j(S));if(S===35)do S=i.input.charCodeAt(++i.position);while(!P(S)&&S!==0)}for(;S!==0;){for(tt(i),i.lineIndent=0,S=i.input.charCodeAt(i.position);(!T||i.lineIndent<c)&&S===32;)i.lineIndent++,S=i.input.charCodeAt(++i.position);if(!T&&i.lineIndent>c&&(c=i.lineIndent),P(S)){b++;continue}if(!T&&c===0&&H(i,"missing indentation for block scalar"),i.lineIndent<c){k===h?i.result+=n.repeat(`
|
|
202
|
+
`,_?1+b:b):k===u&&_&&(i.result+=`
|
|
203
|
+
`);break}E?j(S)?(R=!0,i.result+=n.repeat(`
|
|
204
|
+
`,_?1+b:b)):R?(R=!1,i.result+=n.repeat(`
|
|
205
|
+
`,b+1)):b===0?_&&(i.result+=" "):i.result+=n.repeat(`
|
|
206
|
+
`,b):i.result+=n.repeat(`
|
|
207
|
+
`,_?1+b:b),_=!0,T=!0,b=0;let O=i.position;for(;!P(S)&&S!==0;)S=i.input.charCodeAt(++i.position);he(i,O,i.position,!1)}return!0}function Te(i,g){let E=i.tag,k=i.anchor,_=[],T=!1;if(i.firstTabInLine!==-1)return!1;i.anchor!==null&&Ae(i,i.anchor,_);let c=i.input.charCodeAt(i.position);for(;c!==0&&(i.firstTabInLine!==-1&&(i.position=i.firstTabInLine,H(i,"tab characters must not be used in indentation")),c===45);){let b=i.input.charCodeAt(i.position+1);if(!M(b))break;if(T=!0,i.position++,ee(i,!0,-1)&&i.lineIndent<=g){_.push(null),c=i.input.charCodeAt(i.position);continue}let R=i.line;if(Ce(i,g,d,!1,!0),_.push(i.result),ee(i,!0,-1),c=i.input.charCodeAt(i.position),(i.line===R||i.lineIndent>g)&&c!==0)H(i,"bad indentation of a sequence entry");else if(i.lineIndent<g)break}return T?(i.tag=E,i.anchor=k,i.kind="sequence",i.result=_,!0):!1}function Vt(i,g,E){let k,_,T,c,b=i.tag,R=i.anchor,v={},S=Object.create(null),O=null,A=null,I=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,H(i,"tab characters must not be used in indentation"));let G=i.input.charCodeAt(i.position+1),X=i.line;if((D===63||D===58)&&M(G))D===63?(x&&(Re(i,v,S,O,A,null,_,T,c),O=A=I=null),L=!0,x=!0,k=!0):x?(x=!1,k=!0):H(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,T=i.lineStart,c=i.position,!Ce(i,E,l,!1,!0))break;if(i.line===X){for(D=i.input.charCodeAt(i.position);j(D);)D=i.input.charCodeAt(++i.position);if(D===58)D=i.input.charCodeAt(++i.position),M(D)||H(i,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(Re(i,v,S,O,A,null,_,T,c),O=A=I=null),L=!0,x=!1,k=!1,O=i.tag,A=i.result;else if(L)H(i,"can not read an implicit mapping pair; a colon is missed");else return i.tag=b,i.anchor=R,!0}else if(L)H(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===X||i.lineIndent>g)&&(x&&(_=i.line,T=i.lineStart,c=i.position),Ce(i,g,p,!0,k)&&(x?A=i.result:I=i.result),x||(Re(i,v,S,O,A,I,_,T,c),O=A=I=null),ee(i,!0,-1),D=i.input.charCodeAt(i.position)),(i.line===X||i.lineIndent>g)&&D!==0)H(i,"bad indentation of a mapping entry");else if(i.lineIndent<g)break}return x&&Re(i,v,S,O,A,null,_,T,c),L&&(i.tag=b,i.anchor=R,i.kind="mapping",i.result=v),L}function Rn(i){let g=!1,E=!1,k,_,T=i.input.charCodeAt(i.position);if(T!==33)return!1;i.tag!==null&&H(i,"duplication of a tag property"),T=i.input.charCodeAt(++i.position),T===60?(g=!0,T=i.input.charCodeAt(++i.position)):T===33?(E=!0,k="!!",T=i.input.charCodeAt(++i.position)):k="!";let c=i.position;if(g){do T=i.input.charCodeAt(++i.position);while(T!==0&&T!==62);i.position<i.length?(_=i.input.slice(c,i.position),T=i.input.charCodeAt(++i.position)):H(i,"unexpected end of the stream within a verbatim tag")}else{for(;T!==0&&!M(T);)T===33&&(E?H(i,"tag suffix cannot contain exclamation marks"):(k=i.input.slice(c-1,i.position+1),w.test(k)||H(i,"named tag handle cannot contain such characters"),E=!0,c=i.position+1)),T=i.input.charCodeAt(++i.position);_=i.input.slice(c,i.position),$.test(_)&&H(i,"tag suffix cannot contain flow indicator characters")}_&&!y.test(_)&&H(i,"tag name cannot contain such characters: "+_);try{_=decodeURIComponent(_)}catch{H(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:"+_:H(i,'undeclared tag handle "'+k+'"'),!0}function Kt(i){let g=i.input.charCodeAt(i.position);if(g!==38)return!1;i.anchor!==null&&H(i,"duplication of an anchor property"),g=i.input.charCodeAt(++i.position);let E=i.position;for(;g!==0&&!M(g)&&!q(g);)g=i.input.charCodeAt(++i.position);return i.position===E&&H(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&&!M(g)&&!q(g);)g=i.input.charCodeAt(++i.position);i.position===E&&H(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)||H(i,'unidentified alias "'+k+'"'),i.result=i.anchorMap[k],ee(i,!0,-1),!0}function On(i,g,E,k){let _=bt(i);return kn(i),et(i,g),i.tag=null,i.anchor=null,i.kind=null,i.result=null,Vt(i,E,k)&&i.kind==="mapping"?(We(i),!0):(An(i),et(i,_),!1)}function Ce(i,g,E,k,_){let T,c,b=1,R=!1,v=!1,S=null,O,A,I;i.depth>=i.maxDepth&&H(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=T=c=p===E||d===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=bt(i);if(R&&(L===33&&i.tag!==null||L===38&&i.anchor!==null)||!Rn(i)&&!Kt(i))break;S===null&&(S=D),ee(i,!0,-1)?(R=!0,c=x,i.lineIndent>g?b=1:i.lineIndent===g?b=0:i.lineIndent<g&&(b=-1)):c=!1}if(c&&(c=R||_),b===1||p===E)if(a===E||l===E?A=g:A=g+1,I=i.position-i.lineStart,b===1)if(c&&(Te(i,I)||Vt(i,I,A))||Gt(i,A))v=!0;else{let L=i.input.charCodeAt(i.position);S!==null&&x&&!c&&L!==124&&L!==62&&On(i,S,S.position-S.lineStart,A)||T&&Wt(i,A)||Bt(i,A)||wt(i,A)?v=!0:Yt(i)?(v=!0,(i.tag!==null||i.anchor!==null)&&H(i,"alias node should not have any properties")):qt(i,A,a===E)&&(v=!0,i.tag===null&&(i.tag="?")),i.anchor!==null&&Ae(i,i.anchor,i.result)}else b===0&&(v=c&&Te(i,I));if(i.tag===null)i.anchor!==null&&Ae(i,i.anchor,i.result);else if(i.tag==="?"){i.result!==null&&i.kind!=="scalar"&&H(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(O=i.implicitTypes[L],O.resolve(i.result)){i.result=O.construct(i.result),i.tag=O.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))O=i.typeMap[i.kind||"fallback"][i.tag];else{O=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){O=L[D];break}}O||H(i,"unknown tag !<"+i.tag+">"),i.result!==null&&O.kind!==i.kind&&H(i,"unacceptable node kind for !<"+i.tag+'> tag; it should be "'+O.kind+'", not "'+i.kind+'"'),O.resolve(i.result,i.tag)?(i.result=O.construct(i.result,i.tag),i.anchor!==null&&Ae(i,i.anchor,i.result)):H(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 Tn(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&&!M(k);)k=i.input.charCodeAt(++i.position);let T=i.input.slice(_,i.position),c=[];for(T.length<1&&H(i,"directive name must not be less than one character in length");k!==0;){for(;j(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&&!M(k);)k=i.input.charCodeAt(++i.position);c.push(i.input.slice(_,i.position))}k!==0&&tt(i),s.call(Ut,T)?Ut[T](i,T,c):Ze(i,'unknown document directive "'+T+'"')}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&&H(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))&&Ze(i,"non-ASCII line breaks are interpreted as content"),i.documents.push(i.result),i.position===i.lineStart&&nt(i)){i.input.charCodeAt(i.position)===46&&(i.position+=3,ee(i,!0,-1));return}i.position<i.length-1&&H(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,H(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;)Tn(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,T=k.length;_<T;_+=1)g(k[_])}function Cn(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 yn.loadAll=Xt,yn.load=Cn,yn}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,d=10,p=13,u=32,r=33,h=34,f=35,m=37,$=38,w=39,y=42,C=44,P=45,j=58,M=61,q=62,U=63,ie=64,ue=91,oe=93,pe=96,ce=123,F=124,de=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 Q=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],H=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Ze(c,b){if(b===null)return{};let R={},v=Object.keys(b);for(let S=0,O=v.length;S<O;S+=1){let A=v[S],I=String(b[A]);A.slice(0,2)==="!!"&&(A="tag:yaml.org,2002:"+A.slice(2));let x=c.compiledTypeMap.fallback[A];x&&s.call(x.styleAliases,I)&&(I=x.styleAliases[I]),R[A]=I}return R}function Ae(c){let b,R,v=c.toString(16).toUpperCase();if(c<=255)b="x",R=2;else if(c<=65535)b="u",R=4;else if(c<=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 kn=1,We=2;function An(c){this.schema=c.schema||t,this.indent=Math.max(1,c.indent||2),this.noArrayIndent=c.noArrayIndent||!1,this.skipInvalid=c.skipInvalid||!1,this.flowLevel=n.isNothing(c.flowLevel)?-1:c.flowLevel,this.styleMap=Ze(this.schema,c.styles||null),this.sortKeys=c.sortKeys||!1,this.lineWidth=c.lineWidth||80,this.noRefs=c.noRefs||!1,this.noCompatMode=c.noCompatMode||!1,this.condenseFlow=c.condenseFlow||!1,this.quotingType=c.quotingType==='"'?We:kn,this.forceQuotes=c.forceQuotes||!1,this.replacer=typeof c.replacer=="function"?c.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function bt(c,b){let R=n.repeat(" ",b),v=0,S="",O=c.length;for(;v<O;){let A,I=c.indexOf(`
|
|
209
|
+
`,v);I===-1?(A=c.slice(v),v=O):(A=c.slice(v,I+1),v=I+1),A.length&&A!==`
|
|
210
|
+
`&&(S+=R),S+=A}return S}function et(c,b){return`
|
|
211
|
+
`+n.repeat(" ",c.indent*b)}function Ut(c,b){for(let R=0,v=c.implicitTypes.length;R<v;R+=1)if(c.implicitTypes[R].resolve(b))return!0;return!1}function he(c){return c===u||c===l}function De(c){return c>=32&&c<=126||c>=161&&c<=55295&&c!==8232&&c!==8233||c>=57344&&c<=65533&&c!==a||c>=65536&&c<=1114111}function Re(c){return De(c)&&c!==a&&c!==p&&c!==d}function tt(c,b,R){let v=Re(c),S=v&&!he(c);return(R?v:v&&c!==C&&c!==ue&&c!==oe&&c!==ce&&c!==de)&&c!==f&&!(b===j&&!S)||Re(b)&&!he(b)&&c===f||b===j&&S}function ee(c){return De(c)&&c!==a&&!he(c)&&c!==P&&c!==U&&c!==j&&c!==C&&c!==ue&&c!==oe&&c!==ce&&c!==de&&c!==f&&c!==$&&c!==y&&c!==r&&c!==F&&c!==M&&c!==q&&c!==w&&c!==h&&c!==m&&c!==ie&&c!==pe}function nt(c){return!he(c)&&c!==j}function Oe(c,b){let R=c.charCodeAt(b),v;return R>=55296&&R<=56319&&b+1<c.length&&(v=c.charCodeAt(b+1),v>=56320&&v<=57343)?(R-55296)*1024+v-56320+65536:R}function qt(c){return/^\n* /.test(c)}let Bt=1,wt=2,Gt=3,Wt=4,Te=5;function Vt(c,b,R,v,S,O,A,I){let x,L=0,D=null,G=!1,X=!1,Wi=v!==-1,yt=-1,_t=ee(Oe(c,0))&&nt(Oe(c,c.length-1));if(b||A)for(x=0;x<c.length;L>=65536?x+=2:x++){if(L=Oe(c,x),!De(L))return Te;_t=_t&&tt(L,D,I),D=L}else{for(x=0;x<c.length;L>=65536?x+=2:x++){if(L=Oe(c,x),L===d)G=!0,Wi&&(X=X||x-yt-1>v&&c[yt+1]!==" ",yt=x);else if(!De(L))return Te;_t=_t&&tt(L,D,I),D=L}X=X||Wi&&x-yt-1>v&&c[yt+1]!==" "}return!G&&!X?_t&&!A&&!S(c)?Bt:O===We?Te:wt:R>9&&qt(c)?Te:A?O===We?Te:wt:X?Wt:Gt}function Rn(c,b,R,v,S){c.dump=(function(){if(b.length===0)return c.quotingType===We?'""':"''";if(!c.noCompatMode&&(Q.indexOf(b)!==-1||H.test(b)))return c.quotingType===We?'"'+b+'"':"'"+b+"'";let O=c.indent*Math.max(1,R),A=c.lineWidth===-1?-1:Math.max(Math.min(c.lineWidth,40),c.lineWidth-O),I=v||c.flowLevel>-1&&R>=c.flowLevel;function x(L){return Ut(c,L)}switch(Vt(b,I,c.indent,A,x,c.quotingType,c.forceQuotes&&!v,S)){case Bt:return b;case wt:return"'"+b.replace(/'/g,"''")+"'";case Gt:return"|"+Kt(b,c.indent)+Yt(bt(b,O));case Wt:return">"+Kt(b,c.indent)+Yt(bt(On(b,A),O));case Te:return'"'+Tn(b)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function Kt(c,b){let R=qt(c)?String(b):"",v=c[c.length-1]===`
|
|
212
|
+
`,O=v&&(c[c.length-2]===`
|
|
151
213
|
`||c===`
|
|
152
|
-
`)?"+":
|
|
153
|
-
`}function
|
|
154
|
-
`?c.slice(0,-1):c}function
|
|
155
|
-
`);return
|
|
156
|
-
`||c[0]===" ",
|
|
157
|
-
`:"")+
|
|
158
|
-
`+c.slice(
|
|
159
|
-
`,c.length-
|
|
160
|
-
`+c.slice(
|
|
161
|
-
`:""}return $i.dump=T,$i}var Nr;function ms(){if(Nr)return se;Nr=1;let n=fs(),e=gs();function t(o,s){return function(){throw new Error("Function yaml."+o+" is removed in js-yaml 4. Use yaml."+s+" instead, which is now safe by default.")}}return se.Type=ce(),se.Schema=Ir(),se.FAILSAFE_SCHEMA=Dr(),se.JSON_SCHEMA=Ur(),se.CORE_SCHEMA=Br(),se.DEFAULT_SCHEMA=Ei(),se.load=n.load,se.loadAll=n.loadAll,se.dump=e.dump,se.YAMLException=At(),se.types={binary:Wr(),float:qr(),map:Lr(),null:Mr(),pairs:Kr(),set:Jr(),timestamp:Gr(),bool:Fr(),int:jr(),merge:Vr(),omap:Yr(),seq:Pr(),str:Hr()},se.safeLoad=t("safeLoad","load"),se.safeLoadAll=t("safeLoadAll","loadAll"),se.safeDump=t("safeDump","dump"),se}var bs=ms(),Re=ps(bs),{Type:al,Schema:ll,FAILSAFE_SCHEMA:cl,JSON_SCHEMA:ul,CORE_SCHEMA:dl,DEFAULT_SCHEMA:pl,load:hl,loadAll:fl,dump:gl,YAMLException:ml,types:bl,safeLoad:wl,safeLoadAll:yl,safeDump:_l}=Re;var ws=/^---\r?\n([\s\S]*?)\r?\n---/;function at(n){let e=ws.exec(n);if(e)try{let t=Re.load(e[1]);if(t&&typeof t=="object")return t}catch{return}}var lt=new Set(Qe);function vt(n,e={}){let t=[],o=new Map(n.nodes.map(r=>[r.id,r])),s=We(n).memberIds;for(let r of n.nodes)r.declared||t.push({level:"error",code:"node.undeclared",message:`node '${r.id}' is referenced in an edge but never declared`,where:{node:r.id,line:r.line},hint:`add a node statement, e.g. ${r.id} [type=...]`});let a=(r,d,h,y)=>{let m=Ki(r,d);t.push({level:"error",code:"attr.unknown",message:`unknown attribute '${r}=' on ${h} \u2014 it would be silently ignored`,where:y,hint:m?`did you mean '${m}='?`:"see reference/node-types.md for the attributes this version of gp-foundry understands"})};for(let r of n.nodes)for(let d of Object.keys(r.raw))Ln.has(d)||a(d,Ln,`node '${r.id}'`,{node:r.id,line:r.line});for(let r of n.edges)for(let d of Object.keys(r.raw))Dn.has(d)||a(d,Dn,`edge '${r.from} -> ${r.to}'`,{edge:[r.from,r.to],line:r.line});try{je(n.config.verdicts)}catch(r){t.push({level:"error",code:"config.bad-verdicts",message:r.message,hint:"verdicts: [APPROVE, REQUEST_CHANGES, ESCALATE] \u2014 approve, request changes, escalate, in that order"})}try{wt(n.config)}catch(r){t.push({level:"error",code:"config.bad-authors",message:r.message,hint:"repo.authors is a list of GitHub logins, e.g. authors: [dpup]"})}let l=new Map;for(let r of n.nodes){if(!he(r))continue;let d;try{d=Be(r)}catch{continue}let h=l.get(d);h?t.push({level:"error",code:"node.duplicate-check-name",message:`merge gates '${h}' and '${r.id}' both publish the check '${d}'`,where:{node:r.id,line:r.line},hint:"give each evaluate gate its own check_name="}):l.set(d,r.id)}for(let r of n.nodes){if(r.attrs.authors!==void 0)if(!Kt(r)||s.has(r.id))t.push({level:"error",code:"node.authors-unsupported",message:`authors= on '${r.id}' is not supported here \u2014 it binds a standalone pr-review / pr-fix node, an analyst with context="pr-diff" or "pr-review", or a merge-gate with mode="evaluate"`,where:{node:r.id,line:r.line},hint:s.has(r.id)?"a diamond is bound by repo.authors in foundry.config.yaml":"to restrict every PR lane at once, set repo.authors in foundry.config.yaml"});else try{Jt(r,n.config)}catch($){t.push({level:"error",code:"node.bad-authors",message:$.message,where:{node:r.id,line:r.line},hint:'comma-separated GitHub logins, e.g. authors="dpup, octocat"'})}if(r.attrs.opt_in_label!==void 0)if(!Kt(r)||s.has(r.id))t.push({level:"error",code:"node.opt-in-label-unsupported",message:`opt_in_label= on '${r.id}' is not supported here \u2014 it widens the allowlist of a standalone pr-review / pr-fix node, an analyst with context="pr-diff" or "pr-review", or a merge-gate with mode="evaluate"`,where:{node:r.id,line:r.line}});else{try{qn(r,n.config)}catch(E){t.push({level:"error",code:"node.bad-opt-in-label",message:E.message,where:{node:r.id,line:r.line},hint:'a key into labels: in foundry.config.yaml (or a literal label), e.g. opt_in_label="agent_review"'})}let $;try{$=Jt(r,n.config)}catch{$=[]}$===void 0&&t.push({level:"error",code:"node.opt-in-without-authors",message:`opt_in_label= on '${r.id}' has no allowlist to widen \u2014 the lane already runs for every author`,where:{node:r.id,line:r.line},hint:"opt_in_label= widens an allowlist; set authors= or repo.authors, or drop the label to run for everyone"})}if(lt.has(r.type)&&!r.files.role&&t.push({level:"error",code:"node.missing-role",message:`agent node '${r.id}' (type ${r.type}) needs a role="..." job description`,where:{node:r.id,line:r.line}}),r.attrs.permissions!==void 0){try{rn(r)}catch($){t.push({level:"error",code:"node.bad-permissions",message:$.message,where:{node:r.id,line:r.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(r.type==="start"||r.type==="exit"||r.type==="parallel")&&t.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${r.id}' (type ${r.type}) is ignored \u2014 this node emits no workflow job`,where:{node:r.id,line:r.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}if(r.attrs.agent_attempts!==void 0){let $=r.attrs.agent_attempts;(typeof $!="number"||!Number.isInteger($)||$<1)&&t.push({level:"error",code:"node.bad-agent-attempts",message:`agent_attempts= on '${r.id}' must be a whole number >= 1, got ${JSON.stringify($)}`,where:{node:r.id,line:r.line},hint:"1 disables retrying; omit the attr to use run-agent's default \u2014 e.g. agent_attempts=1"}),lt.has(r.type)||t.push({level:"warning",code:"node.agent-attempts-ignored",message:`agent_attempts= on '${r.id}' (type ${r.type}) is ignored \u2014 this node runs no agent`,where:{node:r.id,line:r.line},hint:"move agent_attempts= to the agent lane whose retry budget you meant to change"})}let d=r.type!=="start"&&r.type!=="exit"&&r.type!=="parallel",h=r.type==="analyst"||r.type==="issue-agent"||r.type==="pr-review"||r.type==="fan_in",y=r.type==="pr-fix"||(r.type==="pr-review"||r.type==="analyst")&&we(r)||r.type==="fan_in",m=($,E,b)=>{t.push({level:"error",code:$,message:E,where:{node:r.id,line:r.line},...b?{hint:b}:{}})};if(r.attrs.title!==void 0&&(typeof r.attrs.title!="string"||!r.attrs.title.trim()||r.attrs.title.includes("${{")?m("node.bad-title",`title= on '${r.id}' must be a plain, non-empty string, got ${JSON.stringify(r.attrs.title)}`):(!d||s.has(r.id))&&m("node.title-unsupported",`title= on '${r.id}' has no workflow to name \u2014 this node does not own one`,"set it on the node that owns the workflow (for a diamond, the fan_in)")),r.attrs.harness_ref!==void 0&&(r.attrs.harness_ref!=="base"&&r.attrs.harness_ref!=="head"?m("node.bad-harness-ref",`harness_ref= on '${r.id}' must be "base" or "head", got ${JSON.stringify(r.attrs.harness_ref)}`):y?r.attrs.harness_ref==="head"&&t.push({level:"warning",code:"node.harness-from-head",message:`harness_ref="head" on '${r.id}': its role, scope and setup composite are read from the PR under review, so a PR can rewrite the instructions it is judged by \u2014 and the setup step that runs with this job's secrets`,where:{node:r.id,line:r.line},hint:"omit harness_ref (the default is the base ref) unless you are testing a harness change in its own PR"}):m("node.harness-ref-unsupported",`harness_ref= on '${r.id}' does not apply \u2014 only a lane handed a pull request chooses between the base ref's harness files and the PR head's`)),r.attrs.persist_credentials!==void 0&&(typeof r.attrs.persist_credentials!="boolean"?m("node.bad-persist-credentials",`persist_credentials= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.persist_credentials)}`):h?r.attrs.persist_credentials===!1&&r.attrs.checkout==="partial"&&m("node.partial-needs-credentials",`'${r.id}' sets checkout="partial" with persist_credentials=false \u2014 a blob-less clone fetches file contents on demand and cannot without the credential`,'drop checkout="partial" (a full clone needs no credential after checkout), or drop persist_credentials=false'):m("node.persist-credentials-unsupported",`persist_credentials= on '${r.id}' (type ${r.type}) does not apply \u2014 only read-and-advise lanes drop the checkout credential; a lane that pushes needs it`)),r.attrs.repo_guides!==void 0&&(typeof r.attrs.repo_guides!="boolean"?m("node.bad-repo-guides",`repo_guides= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.repo_guides)}`):!lt.has(r.type)&&r.type!=="fan_in"&&m("node.repo-guides-unsupported",`repo_guides= on '${r.id}' (type ${r.type}) does not apply \u2014 this node runs no agent`)),r.attrs.cancel_in_progress!==void 0&&(typeof r.attrs.cancel_in_progress!="boolean"&&t.push({level:"error",code:"node.bad-cancel-in-progress",message:`cancel_in_progress= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.cancel_in_progress)}`,where:{node:r.id,line:r.line}}),!lt.has(r.type)||s.has(r.id)?t.push({level:"warning",code:"node.cancel-in-progress-ignored",message:`cancel_in_progress= on '${r.id}' is ignored \u2014 it applies to an agent node that owns its own workflow`,where:{node:r.id,line:r.line},hint:"set it on a standalone agent lane (analyst, issue-agent, producer, pr-review, pr-fix, scheduled-agent)"}):r.attrs.cancel_in_progress===!0&&(r.type==="producer"||r.type==="pr-fix"||r.type==="scheduled-agent"&&r.attrs.commit!=="none")&&t.push({level:"warning",code:"node.cancel-in-progress-discards-work",message:`cancel_in_progress=true on '${r.id}' (type ${r.type}): a cancelled run skips the commit/push salvage, so whatever the agent had written but not yet pushed is lost`,where:{node:r.id,line:r.line},hint:"keep it for lanes where the newer event supersedes the older run's work; otherwise leave the default (queue)"})),r.attrs.checkout!==void 0&&(r.attrs.checkout!=="partial"?t.push({level:"error",code:"node.bad-checkout",message:`checkout= on '${r.id}' must be "partial", got ${JSON.stringify(r.attrs.checkout)}`,where:{node:r.id,line:r.line},hint:`checkout="partial" is a blob-less clone with full history; omit the attr for the lane's default checkout`}):(r.type==="start"||r.type==="exit"||r.type==="parallel"||r.type==="human-gate")&&t.push({level:"warning",code:"node.checkout-ignored",message:`checkout= on '${r.id}' (type ${r.type}) is ignored \u2014 this node checks nothing out`,where:{node:r.id,line:r.line}})),r.attrs.gates!==void 0)try{Mn(r)}catch($){t.push({level:"error",code:"node.bad-gates",message:$.message,where:{node:r.id,line:r.line},hint:'comma-separated workflow files or check-run names, each with an optional ?<seconds> grace \u2014 e.g. gates="ci.yml, e2e (chromium)?90"'})}if(r.attrs.skip!==void 0){let $=[];try{$=Fn(r)}catch(b){t.push({level:"error",code:"node.bad-skip",message:b.message,where:{node:r.id,line:r.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}let E=(r.type==="pr-review"||r.type==="analyst")&&we(r)&&r.attrs.schedule===void 0&&!s.has(r.id);ye(r)&&!s.has(r.id)||he(r)?$.some(b=>b.kind==="unchanged-diff")&&t.push({level:"error",code:"node.skip-unsupported",message:`skip="unchanged-diff" on '${r.id}' is not supported on a ${he(r)?"merge gate":"sweep"} \u2014 it compares a push against the last review, and a ${he(r)?"merge gate":"sweep"} reacts to no push`,where:{node:r.id,line:r.line},hint:he(r)?"keep draft, bot-author and label:<key>":"a sweep already skips a head it has run on; keep draft, bot-author and label:<key>"}):E||t.push({level:"error",code:"node.skip-unsupported",message:`skip= on '${r.id}' is not supported here \u2014 it needs a standalone, event-driven pr-review/analyst node with context="pr-diff" or "pr-review"`,where:{node:r.id,line:r.line},hint:r.attrs.select!==void 0||r.attrs.schedule!==void 0?'a scheduled (select="sweep") lane picks its own PRs; skip= guards a lane that reacts to PR events':s.has(r.id)?"a diamond leg has no guard job of its own; put the review lane outside the diamond":'set context="pr-diff" on the node \u2014 skip= reads the pull request the event is about'}),$.some(b=>b.kind==="unchanged-diff")&&!n.config.identity?.bot_login&&t.push({level:"error",code:"node.skip-needs-bot-login",message:`skip="unchanged-diff" on '${r.id}' compares against the bot's last review, but identity.bot_login is unset`,where:{node:r.id,line:r.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"})}if(r.attrs.select!==void 0&&(r.attrs.select!=="sweep"?t.push({level:"error",code:"node.bad-select",message:`select= on '${r.id}' must be "sweep", got ${JSON.stringify(r.attrs.select)}`,where:{node:r.id,line:r.line}}):r.type!=="pr-review"||!we(r)||s.has(r.id)?t.push({level:"error",code:"node.select-unsupported",message:`select="sweep" on '${r.id}' needs a standalone pr-review node with context="pr-diff" or "pr-review"`,where:{node:r.id,line:r.line}}):r.attrs.schedule===void 0?t.push({level:"error",code:"node.sweep-no-schedule",message:`select="sweep" on '${r.id}' needs schedule="<cron>" \u2014 a sweep is driven by its schedule, not by PR events`,where:{node:r.id,line:r.line},hint:'e.g. schedule="*/15 * * * *"'}):n.config.identity?.bot_login||t.push({level:"warning",code:"node.sweep-no-bot-login",message:`select="sweep" on '${r.id}': identity.bot_login is unset, so ANY review carrying a '**Verdict:**' marker counts as the decision \u2014 a user can pre-empt the lane by posting one`,where:{node:r.id,line:r.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the verdict"})),r.attrs.post!==void 0)if(r.attrs.post!=="review")t.push({level:"error",code:"node.bad-post",message:`post= on '${r.id}' must be "review", got ${JSON.stringify(r.attrs.post)}`,where:{node:r.id,line:r.line}});else if(!Xt(r)||s.has(r.id))t.push({level:"error",code:"node.post-unsupported",message:`post="review" on '${r.id}' needs a standalone pr-review node, or an analyst, with context="pr-diff" or "pr-review"`,where:{node:r.id,line:r.line}});else{let $=e.roles?.get(r.id)?.tools??(r.files.role&&e.readFile?at(e.readFile(r.files.role)??"")?.tools:void 0);typeof $=="string"&&Kn($)&&t.push({level:"warning",code:"node.post-review-gh-tools",message:`post="review" on '${r.id}': its role still lists gh tools (${$}), but the agent gets no GitHub token \u2014 the post step posts; drop gh from tools`,where:{node:r.id,line:r.line},hint:"remove Bash(gh \u2026) / Bash from the role's tools: front-matter"})}if(r.attrs.post_marker!==void 0)if(r.attrs.post!=="review")t.push({level:"error",code:"node.post-marker-without-post",message:`post_marker= on '${r.id}' needs post="review" \u2014 it heads the review the post step posts`,where:{node:r.id,line:r.line}});else try{zt(r)}catch($){t.push({level:"error",code:"node.bad-post-marker",message:$.message,where:{node:r.id,line:r.line}})}if(r.attrs.requires_review!==void 0&&(typeof r.attrs.requires_review!="boolean"?t.push({level:"error",code:"node.bad-requires-review",message:`requires_review= on '${r.id}' must be true or false, got ${JSON.stringify(r.attrs.requires_review)}`,where:{node:r.id,line:r.line}}):(!ye(r)||s.has(r.id))&&t.push({level:"error",code:"node.requires-review-unsupported",message:`requires_review= on '${r.id}' is not supported here \u2014 it narrows the heads a select="sweep" lane picks`,where:{node:r.id,line:r.line}})),r.type==="human-gate"&&r.attrs.environment===void 0&&t.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${r.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:r.id,line:r.line}}),r.attrs.mode!==void 0)if(r.type!=="merge-gate")t.push({level:"error",code:"node.mode-unsupported",message:`mode= on '${r.id}' is not supported here \u2014 it selects a merge-gate's mode ("merge" or "evaluate")`,where:{node:r.id,line:r.line}});else try{Un(r)}catch($){t.push({level:"error",code:"node.bad-mode",message:$.message,where:{node:r.id,line:r.line},hint:`mode="evaluate" publishes the gate's result as a check run and never merges`})}if(r.attrs.check_name!==void 0)if(!he(r))t.push({level:"error",code:"node.check-name-without-evaluate",message:`check_name= on '${r.id}' needs a merge-gate with mode="evaluate" \u2014 only that mode publishes a check run`,where:{node:r.id,line:r.line},hint:'add mode="evaluate" to the merge-gate, or drop check_name='});else try{Be(r)}catch($){t.push({level:"error",code:"node.bad-check-name",message:$.message,where:{node:r.id,line:r.line}})}r.type==="merge-gate"&&!r.files.policy&&t.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${r.id}' has no policy="..."; default merge policy will be used`,where:{node:r.id,line:r.line}})}if(e.fileExists)for(let r of n.nodes)for(let d of["role","policy","prompt","tools"]){let h=r.files[d];h&&!e.fileExists(h)&&t.push({level:"error",code:"file.missing",message:`node '${r.id}' references ${d}="${h}" which does not exist`,where:{node:r.id,line:r.line,file:h}})}if(e.roles){let r=new Map;for(let h of n.nodes)r.set(h.id,[]);for(let h of n.edges){let y=o.get(h.to);y&&r.get(h.from)?.push({node:y,edge:h})}let d=h=>(e.roles?.get(h.id)?.role??h.id).toLowerCase();for(let h of n.nodes){let y=e.roles.get(h.id);if(!y?.handoffs)continue;let m=r.get(h.id)??[],$=new Set(m.flatMap(b=>[b.node.id.toLowerCase(),d(b.node)])),E=new Set(y.handoffs.map(b=>String(b.to).toLowerCase()));for(let b of y.handoffs)$.has(String(b.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${y.role}' (node '${h.id}') declares a handoff to '${b.to}' but there is no matching out-edge`,where:{node:h.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:b,edge:x}of m)b.type==="exit"&&!x.when||!E.has(b.id.toLowerCase())&&!E.has(d(b))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${h.id}' has an out-edge to '${b.id}' not declared as a handoff in role '${y.role}'`,where:{node:h.id,edge:[h.id,b.id]},hint:"document the handoff in the role, or remove the edge"})}}let u=(r,d)=>{if(typeof r=="string"){let h=r.match(/<[A-Za-z][^<>]{0,80}>/);h&&t.push({level:"error",code:"config.placeholder",message:`config value ${d} still contains the placeholder ${h[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(r))r.forEach((h,y)=>u(h,`${d}[${y}]`));else if(r&&typeof r=="object")for(let[h,y]of Object.entries(r))u(y,d?`${d}.${h}`:h)};if(u(n.config,""),e.fileExists&&(n.config.runtime?.mode??"pinned")==="vendored"){let r=new Set,d=!1;for(let h of n.nodes)lt.has(h.type)&&(d=!0,r.add("run-agent")),lt.has(h.type)&&h.type!=="scheduled-agent"&&r.add("agent-context"),(h.type==="producer"||h.type==="scheduled-agent")&&r.add("agent-fallback"),h.type==="merge-gate"&&r.add("merge-gate"),h.type==="pr-review"&&h.attrs.gates!==void 0&&r.add("wait-for-checks");for(let h of r)e.fileExists(`actions/${h}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${h}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});d&&!e.fileExists("agent-setup/action.yml")&&t.push({level:"warning",code:"runtime.agent-setup-missing",message:"generated agent jobs use ./.github/agent-setup, which does not exist",hint:"run `gp-foundry vendor` (or `gp-foundry init`) to scaffold the agent-setup shim"})}{let{byFanin:r,memberIds:d}=We(n);for(let h of n.nodes)if(h.type==="parallel"&&!d.has(h.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${h.id}' is not part of a clean diamond (need: exactly one in-edge carrying on=, \u22652 bare out-edges to agent legs that each flow into one fan_in)`,where:{node:h.id,line:h.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),h.type==="fan_in"){let y=r.get(h.id);if(!y)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${h.id}' is not the join of a clean diamond (need \u22652 legs, each with exactly one in-edge from a shared parallel and one out-edge into this fan_in)`,where:{node:h.id,line:h.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!h.files.role&&h.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${h.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:h.id,line:h.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let m=y.legIds.filter($=>o.get($)?.type==="pr-review");m.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${h.id}' lanes [${m.join(", ")}] are pr-review typed \u2014 if a lane role posts a '**Verdict:**' review, the merge gate acts on ONE lane's opinion and the join is bypassed`,where:{node:h.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(bt(n.config).mode==="github-token"){let r=n.edges.filter(d=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(d.on??"")||/^(label=|verdict=)/.test(d.when??""));r.length&&t.push({level:n.config.auth?.mode==="github-token"?"error":"warning",code:"auth.github-token-no-cascade",message:`auth mode 'github-token': commits/PRs made with GITHUB_TOKEN do not trigger other workflows, so ${r.length} event-cascade edge(s) (pull_request.opened/synchronize/push) will not fire and the harness will stall`,hint:"use auth.mode 'app' or 'pat' (a fine-grained PAT secret), or drive those stages via explicit dispatch"})}return!n.config.identity?.bot_login&&n.edges.some(r=>/^verdict=/.test(r.when??""))&&t.push({level:"warning",code:"auth.no-bot-login",message:"identity.bot_login is unset, so verdict-triggered workflows (fixer, human-gate) guard only on the verdict marker \u2014 any user who can review the PR can fire them",hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"}),n.nodes.some(r=>r.type==="start"||r.attrs.schedule!==void 0||r.type==="merge-gate")||t.push({level:"warning",code:"graph.no-entry",message:"harness has no entry node (a start node or a scheduled node) \u2014 nothing will trigger it"}),t}I();var ys=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),Xr=new Set(["start"]);function kt(n){let e=[],t=new Set(n.nodes.map(r=>r.id)),o=new Map(n.nodes.map(r=>[r.id,r])),s=new Map;for(let r of t)s.set(r,[]);for(let r of n.edges)t.has(r.from)&&t.has(r.to)&&s.get(r.from).push(r.to);let a=n.nodes.filter(r=>Xr.has(r.type)||r.attrs.schedule!==void 0||r.type==="merge-gate"),l=new Set,u=a.map(r=>r.id);for(;u.length;){let r=u.pop();if(!l.has(r)){l.add(r);for(let d of s.get(r)??[])u.push(d)}}for(let r of n.nodes)!l.has(r.id)&&!Xr.has(r.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${r.id}' is unreachable from any entry (start/scheduled) node`,where:{node:r.id,line:r.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let r of n.nodes)(s.get(r.id)??[]).length===0&&!ys.has(r.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${r.id}' (type ${r.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:r.id,line:r.line},hint:"route it to a next node, or make it an exit"});for(let r of Es(t,s)){if(!(r.length>1||(s.get(r[0])??[]).includes(r[0])))continue;let h=new Set(r),y=[];for(let m of r)for(let $ of s.get(m)??[])h.has($)||y.push({from:m,to:$});y.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${r.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:r[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):y.some(m=>$s(_s(n,m.from,m.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${r.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:r[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let p=new Map;for(let r of n.edges){let d=`${r.on??""}|${r.when??""}`;p.has(r.from)||p.set(r.from,new Map);let h=p.get(r.from);h.has(d)||h.set(d,new Set),h.get(d).add(r.to)}for(let[r,d]of p)for(let[h,y]of d)y.size>1&&h!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${r}' has multiple edges with identical trigger/guard (${h}) to different targets: ${[...y].join(", ")}`,where:{node:r},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function _s(n,e,t){return n.edges.find(o=>o.from===e&&o.to===t)?.when}function $s(n){return n?/(>=|>|attempts|max|count|limit)/i.test(n):!1}function Es(n,e){let t=0,o=new Map,s=new Map,a=new Set,l=[],u=[],p=r=>{o.set(r,t),s.set(r,t),t++,l.push(r),a.add(r);for(let d of e.get(r)??[])o.has(d)?a.has(d)&&s.set(r,Math.min(s.get(r),o.get(d))):(p(d),s.set(r,Math.min(s.get(r),s.get(d))));if(s.get(r)===o.get(r)){let d=[],h;do h=l.pop(),a.delete(h),d.push(h);while(h!==r);u.push(d.reverse())}};for(let r of n)o.has(r)||p(r);return u}I();var As=new Set(Qe),vs=new Set(["pr-review","pr-fix"]);function ks(n,e){return e.labels?.[n]??n}function un(n){return vs.has(n.type)||n.context==="pr-diff"||n.context==="pr-review"}function ln(n,e,t){let o=(s,a)=>{n[s]??={},n[s].types??=[],n[s].types.includes(a)||n[s].types.push(a)};switch(e){case"issues.opened":return o("issues","opened");case"issues.labeled":return o("issues","labeled");case"issue_comment.created":return o("issue_comment","created");case"pull_request.opened":return o("pull_request","opened");case"pull_request.synchronize":return o("pull_request","synchronize");case"pull_request.labeled":return o("pull_request","labeled");case"pull_request.closed":return o("pull_request","closed");case"pull_request.ready_for_review":return o("pull_request","ready_for_review");case"pull_request_review.submitted":return o("pull_request_review","submitted");case"push":if(un(t))return o("pull_request","synchronize");n.push??={};return;case"workflow_dispatch":n.workflow_dispatch??={};return;default:n[e]??={}}}function St(n,e){return n==="push"&&un(e)?"pull_request.synchronize":n}function Ai(n){let[e,t]=n.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function Ss(n,e,t){if(n.on){let s=n.on.split(",").map(l=>l.trim()).filter(Boolean),a=s.map(l=>St(l,e));return{events:s,guard:n.when?cn(n.when,a,t):void 0}}if(!n.when)return;let o=n.when;if(o.startsWith("label=")){let s=[un(e)?"pull_request.labeled":"issues.labeled"];return{events:s,guard:cn(o,s,t)}}if(o.startsWith("verdict=")){let s=["pull_request_review.submitted"];return{events:s,guard:cn(o,s,t)}}}function cn(n,e,t){if(n.startsWith("label=")){let s=`github.event.label.name == '${ks(n.slice(6),t)}'`,a=Os(e);return a?`${s} && ${a}`:s}let o=n==="verdict=approve"?"APPROVE":n==="verdict=request_changes"?"REQUEST_CHANGES":void 0;if(o){let s=`contains(github.event.review.body, '**Verdict:** ${o}')`,a=Cs(t);return a?`${s} && ${a}`:s}}function Os(n){if(n.length&&n.every(e=>e.split(".")[0]==="issues"))return"github.event.issue.state == 'open'";if(n.length&&n.every(e=>e.split(".")[0]==="pull_request"))return"github.event.pull_request.state == 'open'"}function Cs(n){let e=n.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function zr(n){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(n)}function Ts(n){let e=n.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function Qr(n,e,t){return vi(n,e,Ts(t))}function Zr(n,e,t,o){return vi(n,e,t?zi(t,o):void 0)}function vi(n,e,t){let o=[...e].filter(zr);if(!t||o.length===0)return n;let s=[...e].filter(l=>!zr(l)),a=s.length?`(${s.map(Ai).join(" || ")} || ${t})`:t;return n?`(${n}) && ${a}`:a}function eo(n,e){let t=n.attrs.cancel_in_progress;return typeof t=="boolean"&&As.has(n.type)?t:e}function xs(n,e){if(n.attrs.schedule!==void 0)return{group:n.id,"cancel-in-progress":eo(n,!1)};let t=un(n)||n.type==="human-gate",o=t?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}",s=eo(n,n.type==="issue-agent");return e!==void 0&&t?{group:`\${{ github.event.action == 'labeled' && github.event.label.name != ${qe(e)} && format(${qe(`${n.id}-noop-{0}`)}, github.run_id) || format(${qe(`${n.id}-{0}`)}, github.event.pull_request.number) }}`,"cancel-in-progress":s}:{group:`${n.id}-${o}`,"cancel-in-progress":s}}function to(n){let e={},t=new Map(n.nodes.map(a=>[a.id,a])),o=new Map;for(let a of n.nodes)o.set(a.id,[]);for(let a of n.edges)o.get(a.to)?.push(a);let s=We(n);for(let a of n.nodes){if(a.type==="start"||a.type==="exit"||s.memberIds.has(a.id))continue;let l=s.byFanin.get(a.id);if(l){let b=l.entryEdge,x=t.get(l.legIds[0]),H={},M=(b.on??"").split(",").map(oe=>oe.trim()).filter(Boolean);for(let oe of M)ln(H,oe,x);let j={nodeId:a.id,triggers:H,dispatches:[]},W=new Set(M.map(oe=>St(oe,x))),B;try{B=wt(n.config)}catch{B=[jn]}let te=Zr(Qr(b.when?cn(b.when,[...W],n.config):void 0,W,n.config),W,B);te&&(j.guard=te);let ae=M.some(oe=>St(oe,x).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";j.concurrency={group:`${a.id}-${ae}`,"cancel-in-progress":!1},e[a.id]=j;continue}if(a.type==="parallel"||a.type==="fan_in")continue;let u={},p=new Set,r=new Set,d=new Set,h=[],y=Ue(a,n.config),m=!1;if(a.attrs.schedule!==void 0)u.schedule=[{cron:String(a.attrs.schedule)}],u.workflow_dispatch={};else{for(let b of o.get(a.id)??[]){let x=Ss(b,a,n.config);if(x){for(let H of x.events)ln(u,H,a);for(let H of x.events)d.add(St(H,a));if(x.guard)p.add(x.guard);else for(let H of x.events)r.add(St(H,a))}}if(u.pull_request&&Ge(a,n.config)&&Ce(a).some(b=>b.kind==="draft")&&(ln(u,"pull_request.ready_for_review",a),d.add("pull_request.ready_for_review"),r.add("pull_request.ready_for_review")),y&&u.pull_request&&Ge(a,n.config)&&(d.has("pull_request.labeled")?r.has("pull_request.labeled")||p.add(`(${Ai("pull_request.labeled")} && github.event.label.name == ${qe(y)})`):(ln(u,"pull_request.labeled",a),d.add("pull_request.labeled"),r.add("pull_request.labeled"),m=!0)),p.size&&r.size)for(let b of r)p.add(Ai(b))}for(let b of n.edges)b.from===a.id&&b.do&&h.push({toNode:b.to,when:b.when});let $=Zr(Qr(p.size?[...p].join(" || "):void 0,d,n.config),d,Te(a,n.config),y);m&&y&&($=vi($,d,`(github.event.action != 'labeled' || github.event.label.name == ${qe(y)})`));let E={nodeId:a.id,triggers:u,dispatches:h};$&&(E.guard=$),Object.keys(u).length&&(E.concurrency=xs(a,m?y:void 0)),e[a.id]=E}return{perNode:e}}I();I();var Rs="${{ github.event.pull_request.number }}",Ns=10,no=3,io=3,Is=600;function ro(n){return ye(n.node)?Ms(n):Ge(n.node,n.config)?Ds(n):null}function oo(n){return ye(n.node)?Fs(n):null}var so='(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',Hs=["[ .[] | select(.commit_id == env.SHA)",` | select(${so})`,` | select(${yt}) ] | length`],Ps=[`[ .[] | select(${so}) | ${yt} as $verdict`," | { decided: (.commit_id == env.SHA and $verdict),",' reviewed: ((.commit_id == env.SHA or ((.body // "") | test(env.ALSO_HEAD_PATTERN + env.SHA + " -->"))) and ($verdict | not)) } ]',"| [ (map(select(.decided)) | length), (map(select(.reviewed)) | length) ] | @tsv"],Ls="github-actions";function Ds(n){let e=n.node,t=Ce(e),o=Te(e,n.config),s=Ue(e,n.config),a={GH_TOKEN:"${{ github.token }}",PR:Rs,NODE:e.id,BOT_LOGIN:n.config.identity?.bot_login??""};o&&(a.AUTHORS=o.join(",")),s&&(a.OPT_IN_LABEL=s);let l=["# Decide whether this lane should run for the PR. The skip= reads fail OPEN:","# a lane that runs once too often costs a run, one that is wrongly skipped","# costs a review nobody knows is missing. The author allowlist is the one","# exception and fails CLOSED \u2014 it says whose PRs the lane may touch at all.",'RUN=true; REASON=""; HEAD_SHA=""; DIFF_HASH=""',"# The lane's stamp step edits only a review submitted after this moment (its own).","STARTED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)","finish() {",' { echo "run=$RUN"; echo "reason=$REASON"; echo "head_sha=$HEAD_SHA"; echo "diff_hash=$DIFF_HASH"; echo "started_at=$STARTED_AT"; } >> "$GITHUB_OUTPUT"',' if [ "$RUN" = "true" ]; then echo "Running $NODE."; else echo "::notice::Skipping $NODE: $REASON"; fi'," exit 0","}",'skip() { RUN=false; REASON="$1"; finish; }',"","# Live PR state, not the event payload: the run may have queued for a while.",'PR_JSON=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" 2>/dev/null) || PR_JSON=""','if [ -z "$PR_JSON" ]; then',...o?[' skip "could not read PR #$PR to verify its author"']:[' echo "::warning::could not read PR #$PR \u2014 not skipping"'," finish"],"fi",`HEAD_SHA=$(jq -r '.head.sha // ""' <<< "$PR_JSON")`];if(o){let h='((.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a))';l.push("",`# authors: only these logins' PRs (case-insensitive)${s?", or a PR carrying the opt-in label":""}.`,"# The job-level `if:` already turned everyone else away from the event","# payload; this is the same test against the PR as it is now, and anything","# but a match skips.",...s?[`if ! jq -e '${h} or any(.labels[]?; .name == env.OPT_IN_LABEL)' <<< "$PR_JSON" >/dev/null; then`,` skip "the author $(jq -r '.user.login // "?"' <<< "$PR_JSON") is not in the allowlist and no $OPT_IN_LABEL label"`]:[`if ! jq -e '${h}' <<< "$PR_JSON" >/dev/null; then`,` skip "the author $(jq -r '.user.login // "?"' <<< "$PR_JSON") is not in the allowlist"`],"fi")}let u=0;for(let h of t)if(l.push(""),h.kind==="draft")l.push("# draft",`if [ "$(jq -r '.draft' <<< "$PR_JSON")" = "true" ]; then skip "the PR is a draft"; fi`);else if(h.kind==="bot-author")l.push("# bot-author: a PR opened by a bot (dependabot, renovate, \u2026). The harness's","# own bot is exempt \u2014 its PRs are the ones this lane exists to review.",`AUTHOR=$(jq -r '.user.login // ""' <<< "$PR_JSON")`,`AUTHOR_TYPE=$(jq -r '.user.type // ""' <<< "$PR_JSON")`,'if [ "$AUTHOR" != "$BOT_LOGIN" ]; then',' case "$AUTHOR_TYPE:$AUTHOR" in',' Bot:*|*"[bot]") skip "authored by the bot $AUTHOR" ;;'," esac","fi");else if(h.kind==="label"){u+=1;let y=`SKIP_LABEL_${u}`;a[y]=n.config.labels?.[h.label]??h.label,l.push(`# label:${h.label}`,`if jq -e --arg l "$${y}" 'any(.labels[]?; .name == $l)' <<< "$PR_JSON" >/dev/null; then`,` skip "the PR carries the label $${y}"`,"fi")}else a.MARKER_PREFIX=Zt(e),a.ALSO_HEAD_PREFIX=Zi(e),a.EVENT_ACTION="${{ github.event.action }}",a.STAMP_TOKEN=ne(n),l.push("# unchanged-diff: hash the PR's merge-base diff and compare it with the hash","# stamped into this bot's last review. Blob ids and hunk positions are","# dropped first, so a rebase or a merge from the base branch that leaves the","# change itself untouched hashes the same. Only a push (synchronize) is","# ever skipped this way: a label, a ready-for-review or a re-request is",'# someone asking for a review, and "nothing changed" is no answer to that.',`BASE_SHA=$(jq -r '.base.sha // ""' <<< "$PR_JSON")`,'if [ -n "$HEAD_SHA" ] && [ -n "$BASE_SHA" ] \\',' && DIFF=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA" -H "Accept: application/vnd.github.diff" 2>/dev/null) \\',' && [ -n "$DIFF" ]; then',` DIFF_HASH=$(printf '%s\\n' "$DIFF" \\`," | sed -E -e '/^index [0-9a-f]+\\.\\.[0-9a-f]+/d' -e 's/^@@ -[0-9,]+ \\+[0-9,]+ @@/@@/' \\"," | sha256sum | cut -d' ' -f1)",` LAST_REVIEW=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`,' .[] | select(.user.login == env.BOT_LOGIN) | select((.body // "") | contains(env.MARKER_PREFIX))',` | "\\(.id) \\((.body // "") | split(env.MARKER_PREFIX) | last | .[0:64])"' 2>/dev/null | tail -n 1) || LAST_REVIEW=""`," LAST_ID=${LAST_REVIEW%% *}; LAST=${LAST_REVIEW#* }",' if [ "$EVENT_ACTION" = "synchronize" ] && [ -n "$LAST" ] && [ "$LAST" = "$DIFF_HASH" ]; then'," # That review covers this head too: say so in it, so a downstream lane can",' # tell "reviewed" from the other reasons this lane skips. One marker per'," # head, appended; best-effort \u2014 the skip stands either way.",' MARK="$ALSO_HEAD_PREFIX$HEAD_SHA -->"',` if BODY=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$LAST_ID" --jq '.body // ""' 2>/dev/null); then`,' case "$BODY" in',' *"$MARK"*) ;;',' *) GH_TOKEN="$STAMP_TOKEN" gh api --method PUT "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$LAST_ID" \\',` -f body="$(printf '%s\\n%s' "$BODY" "$MARK")" >/dev/null \\`,' || echo "::warning::could not mark review $LAST_ID as covering $HEAD_SHA" ;;'," esac"," else",' echo "::warning::could not read review $LAST_ID to mark it as covering $HEAD_SHA"'," fi",' skip "the diff is unchanged since the last review"'," fi","else",' echo "::warning::could not hash the diff of PR #$PR \u2014 not skipping on unchanged-diff"',"fi");l.push("","finish");let p=t.some(h=>h.kind==="unchanged-diff"),r=p?it(n,{"pull-requests":"write"}):void 0,d=p&&ne(n)==="${{ github.token }}";return{jobId:Ze(e),name:`${e.id} skip guard`,displayName:`${e.id} guard`,permissions:{contents:"read","pull-requests":d?"write":"read"},timeoutMinutes:5,outputs:{run:"${{ steps.decide.outputs.run }}",reason:"${{ steps.decide.outputs.reason }}",head_sha:"${{ steps.decide.outputs.head_sha }}",diff_hash:"${{ steps.decide.outputs.diff_hash }}",started_at:"${{ steps.decide.outputs.started_at }}"},steps:[...r?[r]:[],ie({id:"decide",name:"Decide whether to run",env:a,run:l.join(`
|
|
162
|
-
`)})
|
|
163
|
-
`)
|
|
164
|
-
`)})]}}
|
|
214
|
+
`)?"+":v?"":"-";return R+O+`
|
|
215
|
+
`}function Yt(c){return c[c.length-1]===`
|
|
216
|
+
`?c.slice(0,-1):c}function On(c,b){let R=/(\n+)([^\n]*)/g,v=(function(){let I=c.indexOf(`
|
|
217
|
+
`);return I=I!==-1?I:c.length,R.lastIndex=I,Ce(c.slice(0,I),b)})(),S=c[0]===`
|
|
218
|
+
`||c[0]===" ",O,A;for(;A=R.exec(c);){let I=A[1],x=A[2];O=x[0]===" ",v+=I+(!S&&!O&&x!==""?`
|
|
219
|
+
`:"")+Ce(x,b),S=O}return v}function Ce(c,b){if(c===""||c[0]===" ")return c;let R=/ [^ ]/g,v,S=0,O,A=0,I=0,x="";for(;v=R.exec(c);)I=v.index,I-S>b&&(O=A>S?A:I,x+=`
|
|
220
|
+
`+c.slice(S,O),S=O+1),A=I;return x+=`
|
|
221
|
+
`,c.length-S>b&&A>S?x+=c.slice(S,A)+`
|
|
222
|
+
`+c.slice(A+1):x+=c.slice(S),x.slice(1)}function Tn(c){let b="",R=0;for(let v=0;v<c.length;R>=65536?v+=2:v++){R=Oe(c,v);let S=z[R];!S&&De(R)?(b+=c[v],R>=65536&&(b+=c[v+1])):b+=S||Ae(R)}return b}function Jt(c,b,R){let v="",S=c.tag;for(let O=0,A=R.length;O<A;O+=1){let I=R[O];c.replacer&&(I=c.replacer.call(R,String(O),I)),(E(c,b,I,!1,!1)||typeof I>"u"&&E(c,b,null,!1,!1))&&(v!==""&&(v+=","+(c.condenseFlow?"":" ")),v+=c.dump)}c.tag=S,c.dump="["+v+"]"}function Xt(c,b,R,v){let S="",O=c.tag;for(let A=0,I=R.length;A<I;A+=1){let x=R[A];c.replacer&&(x=c.replacer.call(R,String(A),x)),(E(c,b+1,x,!0,!0,!1,!0)||typeof x>"u"&&E(c,b+1,null,!0,!0,!1,!0))&&((!v||S!=="")&&(S+=et(c,b)),c.dump&&d===c.dump.charCodeAt(0)?S+="-":S+="- ",S+=c.dump)}c.tag=O,c.dump=S||"[]"}function Cn(c,b,R){let v="",S=c.tag,O=Object.keys(R);for(let A=0,I=O.length;A<I;A+=1){let x="";v!==""&&(x+=", "),c.condenseFlow&&(x+='"');let L=O[A],D=R[L];c.replacer&&(D=c.replacer.call(R,L,D)),E(c,b,L,!1,!1)&&(c.dump.length>1024&&(x+="? "),x+=c.dump+(c.condenseFlow?'"':"")+":"+(c.condenseFlow?"":" "),E(c,b,D,!1,!1)&&(x+=c.dump,v+=x))}c.tag=S,c.dump="{"+v+"}"}function i(c,b,R,v){let S="",O=c.tag,A=Object.keys(R);if(c.sortKeys===!0)A.sort();else if(typeof c.sortKeys=="function")A.sort(c.sortKeys);else if(c.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let I=0,x=A.length;I<x;I+=1){let L="";(!v||S!=="")&&(L+=et(c,b));let D=A[I],G=R[D];if(c.replacer&&(G=c.replacer.call(R,D,G)),!E(c,b+1,D,!0,!0,!0))continue;let X=c.tag!==null&&c.tag!=="?"||c.dump&&c.dump.length>1024;X&&(c.dump&&d===c.dump.charCodeAt(0)?L+="?":L+="? "),L+=c.dump,X&&(L+=et(c,b)),E(c,b+1,G,!0,X)&&(c.dump&&d===c.dump.charCodeAt(0)?L+=":":L+=": ",L+=c.dump,S+=L)}c.tag=O,c.dump=S||"{}"}function g(c,b,R){let v=R?c.explicitTypes:c.implicitTypes;for(let S=0,O=v.length;S<O;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?c.tag=A.representName(b):c.tag=A.tag:c.tag="?",A.represent){let I=c.styleMap[A.tag]||A.defaultStyle,x;if(o.call(A.represent)==="[object Function]")x=A.represent(b,I);else if(s.call(A.represent,I))x=A.represent[I](b,I);else throw new e("!<"+A.tag+'> tag resolver accepts not "'+I+'" style');c.dump=x}return!0}}return!1}function E(c,b,R,v,S,O,A){c.tag=null,c.dump=R,g(c,R,!1)||g(c,R,!0);let I=o.call(c.dump),x=v;v&&(v=c.flowLevel<0||c.flowLevel>b);let L=I==="[object Object]"||I==="[object Array]",D,G;if(L&&(D=c.duplicates.indexOf(R),G=D!==-1),(c.tag!==null&&c.tag!=="?"||G||c.indent!==2&&b>0)&&(S=!1),G&&c.usedDuplicates[D])c.dump="*ref_"+D;else{if(L&&G&&!c.usedDuplicates[D]&&(c.usedDuplicates[D]=!0),I==="[object Object]")v&&Object.keys(c.dump).length!==0?(i(c,b,c.dump,S),G&&(c.dump="&ref_"+D+c.dump)):(Cn(c,b,c.dump),G&&(c.dump="&ref_"+D+" "+c.dump));else if(I==="[object Array]")v&&c.dump.length!==0?(c.noArrayIndent&&!A&&b>0?Xt(c,b-1,c.dump,S):Xt(c,b,c.dump,S),G&&(c.dump="&ref_"+D+c.dump)):(Jt(c,b,c.dump),G&&(c.dump="&ref_"+D+" "+c.dump));else if(I==="[object String]")c.tag!=="?"&&Rn(c,c.dump,b,O,x);else{if(I==="[object Undefined]")return!1;if(c.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+I)}if(c.tag!==null&&c.tag!=="?"){let X=encodeURI(c.tag[0]==="!"?c.tag.slice(1):c.tag).replace(/!/g,"%21");c.tag[0]==="!"?X="!"+X:X.slice(0,18)==="tag:yaml.org,2002:"?X="!!"+X.slice(18):X="!<"+X+">",c.dump=X+" "+c.dump}}return!0}function k(c,b){let R=[],v=[];_(c,R,v);let S=v.length;for(let O=0;O<S;O+=1)b.duplicates.push(R[v[O]]);b.usedDuplicates=new Array(S)}function _(c,b,R){if(c!==null&&typeof c=="object"){let v=b.indexOf(c);if(v!==-1)R.indexOf(v)===-1&&R.push(v);else if(b.push(c),Array.isArray(c))for(let S=0,O=c.length;S<O;S+=1)_(c[S],b,R);else{let S=Object.keys(c);for(let O=0,A=S.length;O<A;O+=1)_(c[S[O]],b,R)}}}function T(c,b){b=b||{};let R=new An(b);R.noRefs||k(c,R);let v=c;return R.replacer&&(v=R.replacer.call({"":v},"",v)),E(R,0,v,!0,!0)?R.dump+`
|
|
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
|
+
`)})),{...d,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 ua(n){let e=n.node,t=$e(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 d=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"){d+=1;let f=`SKIP_LABEL_${d}`;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?Ue(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]:[],re({id:"decide",name:"Decide whether to run",env:a,run:l.join(`
|
|
225
|
+
`)})]}}function ca(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=$e(e),l=a.some($=>$.kind==="bot-author"),d={};for(let $ of a)$.kind==="label"&&(d[`SKIP_LABEL_${Object.keys(d).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=Ye(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(d).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,...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(d).length?[`# not skipped ${[l?"not opened by a bot (the harness's own is exempt)":"",Object.keys(d).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)",...ti(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 '`,...sa.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,re({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:ot(n.config),REQUIRES_REVIEW:String(ti(e)),ALSO_HEAD_PATTERN:fr,SWEPT_CHECK:ai(e),FAILED_CHECK:oi(e),IDLE_CHECK:si(e),MAX_IDLE:String(vo),MARK_APP:aa,LIMIT:String(ia),MAX_FAILURES:String(Eo),SETTLE_SECONDS:String(ra),...t?{AUTHORS:t.join(",")}:{},...o?{OPT_IN_LABEL:o}:{},...d},run:m})]}}function da(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:[re({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:ot(n.config),JOB_PREFIX:pn(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 '`,...oa.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
|
+
`)})]}}N();var Oo=[" /^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 Ui="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.",pa=`${Ui}
|
|
165
228
|
# Edit harness.dot / roles / foundry.config.yaml and run \`gp-foundry build\`.
|
|
166
|
-
`;function
|
|
167
|
-
`)}]}}}}function
|
|
229
|
+
`;function ha(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??Tt();return s=>`${t}/actions/${s}@${o}`}function fa(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 To(n){return String(n.attrs.title??n.attrs.name??n.id)}function ga(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 '",...Oo,` ' "$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 ma(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=ha(n.config),l=new Map(n.nodes.map(m=>[m.id,m])),d=new Map,p=new Map;for(let m of n.nodes)d.set(m.id,[]),p.set(m.id,[]);for(let m of n.edges)d.get(m.from)?.push(m),p.get(m.to)?.push(m);let u=m=>({config:n.config,node:m,outEdges:d.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(fa),y},h=(m,$)=>{let w=He.dump($,{lineWidth:-1,noRefs:!0,quotingType:'"'});s.push({path:`.github/workflows/${m}.yml`,contents:pa+w,generated:!0})},f=ze(n);ma(n)&&h("immutable-guard",ga(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 M={};for(let ie of w.legIds){let{skip:ue,select:oe,...pe}=l.get(ie).attrs,ce={...l.get(ie),attrs:pe},F=hi(ce,n,u(ce));F&&(M[F.jobId]=r(F,ce,$.guard))}let q=JSON.stringify($.triggers).includes('"pull_request"'),U=Sr(u(m),w.legIds,q);M[U.jobId]=r(U,m),h(m.id,{name:To(m),on:$.triggers,...$.concurrency?{concurrency:$.concurrency}:{},permissions:{contents:"read"},jobs:M});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)},j=ko(u(m));j&&(P[j.jobId]=r(j,m)),h(m.id,{name:To(m),on:$.triggers,...$.concurrency?{concurrency:$.concurrency}:{},permissions:{contents:"read"},jobs:P})}return s}N();function ba(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 wa(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 ya(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}${_a(n)}</small>`}function _a(n){let e=kt(n);if(!e&&!be(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 vn(n,e){let t=["```mermaid","flowchart TD"];for(let s of n.nodes){let[a,l]=wa(s);t.push(` ${s.id}${a}"${ya(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}\` | ${ba(s.triggers)} |`);t.push("")}return`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
|
|
168
231
|
|
|
169
232
|
# ${n.config?.name&&n.config.name!=="harness"?n.config.name:n.name} \u2014 agent harness
|
|
170
233
|
|
|
171
234
|
${t.join(`
|
|
172
|
-
`)}`}
|
|
235
|
+
`)}`}N();var $a=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),Ea=new Set(["role","prompt","policy","tools"]);function va(n){let e=[],t=[],o=1,s=0,a=n;for(;s<a.length;){let l=a[s];if(l===`
|
|
173
236
|
`){o++,s++;continue}if(l===" "||l===" "||l==="\r"){s++;continue}if(l==="/"&&a[s+1]==="/"){for(;s<a.length&&a[s]!==`
|
|
174
237
|
`;)s++;continue}if(l==="/"&&a[s+1]==="*"){for(s+=2;s<a.length&&!(a[s]==="*"&&a[s+1]==="/");)a[s]===`
|
|
175
|
-
`&&o++,s++;s+=2;continue}if(l==="-"&&a[s+1]===">"){e.push({kind:"arrow",value:"->",line:o}),s+=2;continue}if(l==="{"){e.push({kind:"lbrace",value:l,line:o}),s++;continue}if(l==="}"){e.push({kind:"rbrace",value:l,line:o}),s++;continue}if(l==="["){e.push({kind:"lbrack",value:l,line:o}),s++;continue}if(l==="]"){e.push({kind:"rbrack",value:l,line:o}),s++;continue}if(l==="="){e.push({kind:"eq",value:l,line:o}),s++;continue}if(l===","){e.push({kind:"comma",value:l,line:o}),s++;continue}if(l===";"){e.push({kind:"semi",value:l,line:o}),s++;continue}if(l==='"'){let
|
|
176
|
-
`&&o++,p+=a[
|
|
177
|
-
`)}function
|
|
178
|
-
`),e.hint&&process.stderr.write(` ${
|
|
179
|
-
`)}}function
|
|
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 d=s+1,p="";for(;d<a.length&&a[d]!=='"';){if(a[d]==="\\"&&d+1<a.length){p+=a[d+1],d+=2;continue}a[d]===`
|
|
239
|
+
`&&o++,p+=a[d],d++}d>=a.length&&t.push({message:"unterminated string",line:o}),e.push({kind:"id",value:p,line:o}),s=d+1;continue}if(/[A-Za-z0-9_]/.test(l)){let d=s,p="";for(;d<a.length&&/[A-Za-z0-9_.\-]/.test(a[d]);)p+=a[d],d++;e.push({kind:"id",value:p,line:o}),s=d;continue}t.push({message:`unexpected character '${l}'`,line:o}),s++}return{toks:e,errors:t}}function Sa(n){return n==="true"?!0:n==="false"?!1:/^-?\d+$/.test(n)?Number(n):n}function Lt(n){let{toks:e,errors:t}=va(n),o=[],s=[],a=new Map,l="harness",d=0,p=()=>e[d],u=()=>e[d++],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,j]of Object.entries(y))P==="type"?($a.has(j)||r(`unknown node type '${j}' on node '${w.id}'`,C),w.type=j):P==="context"?w.context=j:Ea.has(P)?w.files[P]=j:w.attrs[P]=Sa(j)}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 M=u();if(!M||M.kind!=="id"){r("expected node id after '->'",M?.line);break}C.push({id:M.value,line:M.line})}let{attrs:P,line:j}=h();for(let M=0;M+1<C.length;M++){let q=C[M],U=C[M+1];f(q.id,q.line),f(U.id,U.line);let ie={from:q.id,to:U.id,raw:{...P},line:j??q.line};P.on!==void 0&&(ie.on=P.on),P.when!==void 0&&(ie.when=P.when),P.do!==void 0&&(ie.do=P.do),s.push(ie)}}else{let{attrs:C,line:P}=h(),j=f(y.value,y.line);m(j,C,P??y.line)}p()?.kind==="semi"&&u()}return p()?.kind==="rbrace"&&u(),{name:l,nodes:o,edges:s,errors:t}}N();var Dt=require("fs");var ft={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 Sn(n){if(!n||!(0,Dt.existsSync)(n))return structuredClone(ft);let e=He.load((0,Dt.readFileSync)(n,"utf8"))??{};return{...ft,...e,identity:{...ft.identity,...e.identity??{}},agent:{...ft.agent,...e.agent??{}},repo:{...ft.repo,...e.repo??{}},labels:{...ft.labels,...e.labels??{}}}}function ke(n,e){let t=Lt((0,Dt.readFileSync)(n,"utf8")),o=Sn(e);return{harness:{name:t.name,nodes:t.nodes,edges:t.edges,config:o,sourcePath:n},parseErrors:t.errors}}function gt(n,e={},t={}){let o=[...Nt(n,e),...It(n)],s=d=>{let p=n.nodes.find(h=>h.id===d)?.files.role,u=p&&e.readFile?e.readFile(p):void 0;if(u===void 0)return;let r=pt(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:vn(n,a),generated:!0}),{files:l,diagnostics:o}}function Mt(n){return n.some(e=>e.level==="error")}N();var Pe=require("fs"),ge=require("path"),xo=require("url"),Qe=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(Ui)).sort()}function me(n){return(0,xo.fileURLToPath)(new URL(`../../${n}`,B))}function Z(n){process.stdout.write(JSON.stringify(n,null,2)+`
|
|
240
|
+
`)}function qi(n){for(let e of n){let t=e.level==="error"?Qe.default.red("error"):e.level==="warning"?Qe.default.yellow("warn"):Qe.default.blue("info"),o=e.where?.node?Qe.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${t} ${Qe.default.dim(e.code)}${o} ${e.message}
|
|
241
|
+
`),e.hint&&process.stderr.write(` ${Qe.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}}}N();var Bi=require("child_process"),W=require("fs"),Y=require("path");var V=zt(nn(),1);var Gi=require("path");function mt(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=mt(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=Sn(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}
|
|
180
243
|
`),t.hint&&t.status!=="ok"&&process.stdout.write(` ${V.default.dim("hint: "+t.hint)}
|
|
181
|
-
`)}function
|
|
244
|
+
`)}function ka(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 Aa(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:d}=ke(t,o),p=F=>(0,W.existsSync)((0,Y.join)(s,F)),u=(0,Gi.relative)(a,s).replace(/\\/g,"/"),{files:r,diagnostics:h}=gt(l,{fileExists:p,readFile:jt(s)},{specDir:u}),f=h.filter(F=>F.level==="error").length+d.length,m=h.filter(F=>F.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(F=>F.code).join(", ")}`:"no diagnostics"});let $=r.filter(F=>{let de=(0,Y.join)(a,F.path);return((0,W.existsSync)(de)?(0,W.readFileSync)(de,"utf8"):null)!==F.contents}),w=Ft(a,r),y=[...$.map(F=>F.path),...w.map(F=>`${F} (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 F=Po().filter(de=>!(0,W.existsSync)((0,Y.join)(a,".github/actions",de,"action.yml")));e.push(F.length?{name:"vendored actions",status:"fail",detail:`missing: ${F.join(", ")}`,hint:"run `gp-foundry vendor`"}:{name:"vendored actions",status:"ok",detail:"all runtime actions vendored"})}if(e.push((0,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`)"}),!mt(["auth","status"]).ok)return e.push({name:"gh cli",status:"skip",detail:"gh missing or unauthenticated \u2014 skipping repo checks",hint:"install GitHub CLI and `gh auth login`"}),{checks:e,failed:e.some(F=>F.status==="fail")};e.push({name:"gh cli",status:"ok",detail:"authenticated"});let 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(F=>F.status==="fail")};e.push({name:"github repo",status:"ok",detail:P.nameWithOwner});let j=P.defaultBranchRef?.name;j&&e.push(j===l.config.repo.base_branch?{name:"base branch",status:"ok",detail:j}:{name:"base branch",status:"fail",detail:`config says '${l.config.repo.base_branch}' but the repo default is '${j}'`,hint:"fix repo.base_branch in foundry.config.yaml and re-run `gp-foundry up`"});let M=new Set((Be(["label","list","--json","name","--limit","1000"],a)??[]).map(F=>F.name)),q=Lo(o).map(F=>F.name),U=q.filter(F=>!M.has(F));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 ie=new Set((Be(["secret","list","--json","name"],a)??[]).map(F=>F.name)),ue=[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&&ue.push(oe.token_secret),oe?.mode==="app"&&ue.push(oe.app_id_secret??"APP_ID",oe.app_key_secret??"APP_PRIVATE_KEY");let pe=ue.filter(F=>!ie.has(F));if(e.push(pe.length?{name:"secrets",status:"fail",detail:`missing: ${pe.join(", ")}`,hint:`gh secret set ${pe[0]}`}:{name:"secrets",status:"ok",detail:ue.join(", ")}),ka(l,a)){let de=r.filter(Q=>/\/workflows\/.*\.yml$/.test(Q.path)&&Q.contents.includes("actions/merge-gate")).map(Q=>(0,Y.join)(a,Q.path)).filter(Q=>(0,W.existsSync)(Q)).map(Q=>(0,W.readFileSync)(Q,"utf8")),z=de.filter(Q=>!Q.includes("checks-token"));de.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 ce=mt(["--version"]);try{let F=(0,Bi.execFileSync)("git",["status","--porcelain",".github"],{cwd:a,encoding:"utf8"}).trim();e.push(F?{name:"committed",status:"warn",detail:".github/ has uncommitted changes",hint:"commit + push so GitHub picks them up"}:{name:"committed",status:"ok",detail:".github/ clean"})}catch{e.push({name:"committed",status:"skip",detail:"not a git repo"})}return{checks:e,failed:e.some(F=>F.status==="fail")}}function Ra(n){let{dot:e,config:t,root:o}=Le(n);if(!mt(["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,d=Date.now(),p=y=>Math.round((d-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(j=>({number:j.number,title:j.title,ageHours:p(j.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 Z({written:t});for(let o of t)process.stdout.write(V.default.green(`vendored ${o}
|
|
182
245
|
`));process.stdout.write(V.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
|
|
183
|
-
`))}),n.command("skill").description("Install the Claude skill (Socratic setup) into .claude/skills/gp-foundry/").option("--user","install for all projects (~/.claude/skills/) instead of this repo").option("--dir <path>","target repo root (project mode)",".").option("--json","machine-readable output").action(e=>{let t=process.env.HOME??process.env.USERPROFILE??".",o=e.user?(0,Y.join)(t,".claude/skills/gp-foundry"):(0,Y.join)(e.dir,".claude/skills/gp-foundry");if(
|
|
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(Aa(o),e.json)return Z({installed:o});process.stdout.write(V.default.green(`installed skill \u2192 ${o}
|
|
184
247
|
`)),process.stdout.write(V.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
|
|
185
248
|
The skill interviews you Socratically, drafts harness.dot + roles, and drives this CLI.
|
|
186
|
-
`))}),n.command("doctor").description("Preflight the factory: config, drift, vendored actions, gh auth, labels, secrets").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{checks:t,failed:o}=
|
|
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?Z({ok:!o,checks:t}):(No(t),process.stdout.write(o?V.default.red(`
|
|
187
250
|
not ready \u2014 fix the \u2717 items above
|
|
188
251
|
`):V.default.green(`
|
|
189
252
|
factory is ready
|
|
190
|
-
`))),process.exit(o?1:0)}),n.command("status").description("Factory dashboard: work in flight, stalled items, recent failures").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let t=
|
|
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=Ra(e);if("error"in t&&(e.json?Z(t):(process.stderr.write(V.default.red(t.error+`
|
|
191
254
|
`)),t.hint&&process.stderr.write(V.default.dim("hint: "+t.hint+`
|
|
192
|
-
`))),process.exit(1)),e.json)return
|
|
255
|
+
`))),process.exit(1)),e.json)return Z(t);process.stdout.write(V.default.bold(`
|
|
193
256
|
${t.repo} \u2014 factory status
|
|
194
257
|
|
|
195
258
|
`));for(let[o,s]of Object.entries(t.lanes)){process.stdout.write(V.default.cyan(`${o} (${s.length})
|
|
@@ -205,34 +268,34 @@ failed runs, last 24h (${t.recentFailures.length})
|
|
|
205
268
|
`));for(let o of t.recentFailures.slice(0,10))process.stdout.write(` ${o.workflow} ${V.default.dim(`${o.ageHours}h ago`)} ${o.url}
|
|
206
269
|
`)}!t.stalled.length&&!t.recentFailures.length&&process.stdout.write(V.default.green(`
|
|
207
270
|
no stalled work, no recent failures
|
|
208
|
-
`))}),n.command("up").description("Bring the factory up: create labels, vendor actions, build workflows, run doctor").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{dot:t,config:o,base:s,root:a}=
|
|
209
|
-
`))}else l.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(V.default.yellow("skipped label creation (gh unavailable or no GitHub repo yet) \u2014 re-run `gp-foundry up` once the repo exists\n"));let{harness:
|
|
210
|
-
`)));let p=
|
|
211
|
-
`));let m=
|
|
212
|
-
`));let{checks:$,failed:
|
|
213
|
-
`),
|
|
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(mt(["auth","status"]).ok&&Be(["repo","view","--json","nameWithOwner"],a)){let y=[];for(let C of Lo(o))mt(["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:d}=ke(t,o);(d.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}=gt(d,{fileExists:p,readFile:jt(s)},{specDir:u});Mt(h)&&(e.json?Z({ok:!1,diagnostics:h}):process.stderr.write(V.default.red("build errors \u2014 run `gp-foundry validate` for details\n")),process.exit(1));for(let 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
|
+
`));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 Z(l);process.stdout.write(`
|
|
276
|
+
`),No($),process.stdout.write(w?V.default.yellow(`
|
|
214
277
|
almost there \u2014 fix the \u2717 items above, commit .github/, push, then file an issue
|
|
215
278
|
`):V.default.green(`
|
|
216
279
|
factory is up \u2014 commit .github/, push, then file an issue to watch it run
|
|
217
|
-
`)),process.exit(
|
|
218
|
-
`));for(let
|
|
219
|
-
`));process.stdout.write(["",
|
|
220
|
-
`))});
|
|
221
|
-
`)),process.exit(1));let{harness:a,parseErrors:l}
|
|
222
|
-
`));process.exit(1)}let
|
|
223
|
-
`));else{for(let
|
|
224
|
-
`));for(let
|
|
225
|
-
`));process.stderr.write(
|
|
226
|
-
`)),process.exit(1)),n.dryRun){if(n.json)
|
|
280
|
+
`)),process.exit(w?1:0)})}var Ge=new sr,Oa=JSON.parse((0,J.readFileSync)(me("package.json"),"utf8")).version;Ge.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(Oa);function Ta(n,e){let t=new Map;for(let o of n.nodes){if(!o.files.role)continue;let s=(0,se.join)(e,o.files.role);if((0,J.existsSync)(s)){let a=pt((0,J.readFileSync)(s,"utf8"));a&&t.set(o.id,a)}}return t}var Ca=[["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,se.resolve)(n.dir),t=[],o=[],s=(d,p)=>{let u=(0,se.join)(e,d);if((0,J.existsSync)(u)&&!n.force){o.push(d);return}(0,J.mkdirSync)((0,se.dirname)(u),{recursive:!0}),(0,J.writeFileSync)(u,p),t.push(d)},a="main";try{let d=(0,Mo.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();d&&(a=d)}catch{}for(let[d,p]of Ca){let u=(0,J.readFileSync)(me(d),"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,se.join)(e,".github/harness.dot");if((0,J.existsSync)(l))for(let d of Lt((0,J.readFileSync)(l,"utf8")).nodes){if(!d.files.role)continue;let p=d.files.role.replace(/^.*\//,"").replace(/\.md$/,""),u=me(`roles/software/${p}.md`),r=(0,J.existsSync)(u)?u:me("skill/templates/role.md");s((0,se.join)(".github",d.files.role),(0,J.readFileSync)(r,"utf8"))}if(n.json)return Z({written:t,skipped:o});for(let d of t)process.stdout.write(K.default.green(`created ${d}
|
|
281
|
+
`));for(let d of o)process.stderr.write(K.default.yellow(`skipped ${d} (exists; --force to overwrite)
|
|
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?Z({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)Z({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 d=(0,se.resolve)(n.out??s),p=(0,se.relative)(d,o).replace(/\\/g,"/"),u=m=>(0,J.existsSync)((0,se.join)(o,m)),{files:r,diagnostics:h}=gt(a,{fileExists:u,readFile:jt(o)},{specDir:p});n.json||qi(h);let f=Ft(d,r);if(n.check){let m=r.filter(w=>{let y=(0,se.join)(d,w.path);return((0,J.existsSync)(y)?(0,J.readFileSync)(y,"utf8"):null)!==w.contents}),$=m.length===0&&f.length===0;if(n.json)Z({upToDate:$,drift:m.map(w=>w.path),stale:f,diagnostics:h});else if($)process.stdout.write(K.default.green(`up to date
|
|
286
|
+
`));else{for(let w of m)process.stderr.write(K.default.yellow(`drift: ${w.path}
|
|
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?Z({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)Z({diagnostics:h,files:r,stale:f});else{for(let m of r)process.stdout.write(K.default.cyan(`--- ${m.path}
|
|
227
290
|
`)+m.contents+`
|
|
228
|
-
`);for(let m of
|
|
229
|
-
`))}return}for(let m of
|
|
230
|
-
`))}for(let m of
|
|
231
|
-
`));n.json&&
|
|
232
|
-
`)),process.exit(1));let{harness:s,parseErrors:a}
|
|
233
|
-
`));
|
|
234
|
-
`)),process.exit(1));let{harness:t}
|
|
235
|
-
`)});
|
|
236
|
-
`)),process.exit(1));let{harness:s}
|
|
237
|
-
`)),process.exit(1)),e.json?
|
|
238
|
-
`)});
|
|
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,se.join)(d,m.path);(0,J.mkdirSync)((0,se.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,se.join)(d,m)),n.json||process.stdout.write(K.default.yellow(`removed ${m} (no longer generated)
|
|
294
|
+
`));n.json&&Z({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?Z({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,se.join)(o,r)),d=Ta(s,o),p=[...Nt(s,{fileExists:l,roles:d}),...It(s)],u=p.some(r=>r.level==="error")||a.length>0;if(n.json)Z({ok:!u,parseErrors:a,diagnostics:p});else{for(let r of a)process.stderr.write(K.default.red(`parse: ${r.message}
|
|
296
|
+
`));qi(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?Z({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?Z({name:t.name,nodes:t.nodes,edges:t.edges}):process.stdout.write(vn(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?Z({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}=gt(s),l=a.find(d=>d.path.endsWith(`/${n}.yml`))??a.find(d=>d.path.startsWith(".github/workflows/")&&new RegExp(`^ ${n}:`,"m").test(d.contents));l||(e.json?Z({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?Z({node:n,path:l.path,contents:l.contents}):process.stdout.write(l.contents+`
|
|
301
|
+
`)});Do(Ge);Ge.parseAsync(process.argv);
|